From 425bb31e1dd095e16cdc463a636a78193e6c86b5 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Tue, 21 Jan 2020 01:05:49 +0000 Subject: [PATCH] [Minor] contrib/snowball: fix modules.h location * Reproducible builds! No more absolute paths in source files, so the generated binary is also invariant of the build directory. * Output modules.h in snowball/libstemmer/ instead of snowball/. This allows removal of the extra include directory and -f option. * This partially reverts some changes in https://github.com/snowballstem/snowball/commit/d178f201fda878c26538401650a7d46c37a5e6f1 and matches the commands in GNUmakefile. --- contrib/snowball/CMakeLists.txt | 7 +++---- contrib/snowball/libstemmer/mkmodules.pl | 11 +---------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/contrib/snowball/CMakeLists.txt b/contrib/snowball/CMakeLists.txt index 8674e2d88..7910c7b3a 100644 --- a/contrib/snowball/CMakeLists.txt +++ b/contrib/snowball/CMakeLists.txt @@ -37,14 +37,14 @@ MACRO(gen_stem IN ENCODING) SET(_input "${CMAKE_CURRENT_SOURCE_DIR}/algorithms/${_it}/stem_${_in_enc}.sbl") IF(${_in_enc} STREQUAL "Unicode" AND NOT EXISTS ${_input}) ADD_CUSTOM_COMMAND(OUTPUT ${_source} - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/snowball "${CMAKE_CURRENT_SOURCE_DIR}/algorithms/${_it}/stem_ISO_8859_1.sbl" -o ${_base} -eprefix ${_it}_${ENCODING}_ -r ${CMAKE_CURRENT_SOURCE_DIR}/runtime -u + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/snowball "${CMAKE_CURRENT_SOURCE_DIR}/algorithms/${_it}/stem_ISO_8859_1.sbl" -o ${_base} -eprefix ${_it}_${ENCODING}_ -r ../runtime -u DEPENDS snowball) LIST(APPEND STEMMER_SOURCES ${_source}) ELSE() IF(EXISTS "${_input}") ADD_CUSTOM_COMMAND(OUTPUT ${_source} - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/snowball ${_input} -o ${_base} -eprefix ${_it}_${ENCODING}_ -r ${CMAKE_CURRENT_SOURCE_DIR}/runtime -u + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/snowball ${_input} -o ${_base} -eprefix ${_it}_${ENCODING}_ -r ../runtime -u DEPENDS snowball) LIST(APPEND STEMMER_SOURCES ${_source}) ENDIF() @@ -53,12 +53,11 @@ MACRO(gen_stem IN ENCODING) ENDMACRO() INCLUDE_DIRECTORIES("include") -INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/libstemmer") ADD_EXECUTABLE(snowball ${COMPILER_SOURCES}) ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libstemmer/modules.h - COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/libstemmer/mkmodules.pl -f ${CMAKE_CURRENT_BINARY_DIR}/libstemmer/modules.h ${CMAKE_CURRENT_BINARY_DIR}/libstemmer ${CMAKE_CURRENT_SOURCE_DIR}/libstemmer/modules.txt ${CMAKE_CURRENT_BINARY_DIR}/libstemmer/mkinc.mak) + COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/libstemmer/mkmodules.pl libstemmer/modules.h libstemmer ${CMAKE_CURRENT_SOURCE_DIR}/libstemmer/modules.txt libstemmer/mkinc.mak) ADD_CUSTOM_TARGET(modules DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libstemmer/modules.h") SET(STEMMER_SOURCES "${CMAKE_CURRENT_BINARY_DIR}/libstemmer/libstemmer.c") diff --git a/contrib/snowball/libstemmer/mkmodules.pl b/contrib/snowball/libstemmer/mkmodules.pl index 93870b247..ff8c19e7c 100755 --- a/contrib/snowball/libstemmer/mkmodules.pl +++ b/contrib/snowball/libstemmer/mkmodules.pl @@ -1,17 +1,8 @@ #!/usr/bin/perl -w use strict; -use Getopt::Std; my $progname = $0; -my $include_path = '../'; -our($opt_f); - -getopts('f'); -if ($opt_f) { - $include_path = ''; -} - if (scalar @ARGV < 4 || scalar @ARGV > 5) { print "Usage: $progname []\n"; exit 1; @@ -109,7 +100,7 @@ EOS foreach $lang (@algorithms) { my $hashref = $algorithm_encs{$lang}; foreach $enc (sort keys (%$hashref)) { - print OUT "#include \"${include_path}$c_src_dir/stem_${enc}_$lang.h\"\n"; + print OUT "#include \"../$c_src_dir/stem_${enc}_$lang.h\"\n"; } } -- 2.39.5