From cf93c8719f4f0c7bdc1078b07197bb8b982ebee7 Mon Sep 17 00:00:00 2001 From: Chris Li Date: Mon, 14 Aug 2017 10:31:15 -0400 Subject: [PATCH] Allow kiwix-lib to compile without ctpp2c. ctpp2c is used to pre-compile the template resource. However, on OSX, ctpp2c seems to be difficult to compile, as we don't need ctpp2 at all on OSX/iOS, lets just stop to force the use of ctpp2c. --- include/searcher.h | 1 - src/searcher.cpp | 3 +-- static/meson.build | 24 ++++++++++++------- ...rces_list.txt => resources_list_ctpp2.txt} | 0 static/resources_list_noctpp2.txt | 3 +++ 5 files changed, 20 insertions(+), 11 deletions(-) rename static/{resources_list.txt => resources_list_ctpp2.txt} (100%) create mode 100644 static/resources_list_noctpp2.txt diff --git a/include/searcher.h b/include/searcher.h index fc9c73079..bc3bcbd9d 100644 --- a/include/searcher.h +++ b/include/searcher.h @@ -93,7 +93,6 @@ class Searcher std::string searchPattern; std::string protocolPrefix; std::string searchProtocolPrefix; - std::string template_ct2; unsigned int resultCountPerPage; unsigned int estimatedResultCount; unsigned int resultStart; diff --git a/src/searcher.cpp b/src/searcher.cpp index 7ea4fa672..4d7038a16 100644 --- a/src/searcher.cpp +++ b/src/searcher.cpp @@ -85,7 +85,6 @@ Searcher::Searcher(const string& xapianDirectoryPath, resultStart(0), resultEnd(0) { - template_ct2 = RESOURCE::results_ct2; loadICUExternalTables(); if (!reader || !reader->hasFulltextIndex()) { internal->_xapianSearcher = new XapianSearcher(xapianDirectoryPath, reader); @@ -104,7 +103,6 @@ Searcher::Searcher() resultStart(0), resultEnd(0) { - template_ct2 = RESOURCE::results_ct2; loadICUExternalTables(); } @@ -375,6 +373,7 @@ string Searcher::getHtml() oData["searchProtocolPrefix"] = this->searchProtocolPrefix; oData["contentId"] = this->contentHumanReadableId; + std::string template_ct2 = RESOURCE::results_ct2; VMStringLoader oLoader(template_ct2.c_str(), template_ct2.size()); FileLogger oLogger(stderr); diff --git a/static/meson.build b/static/meson.build index 67e6fa834..2b8b29393 100644 --- a/static/meson.build +++ b/static/meson.build @@ -1,19 +1,27 @@ -ctpp2c = find_program('ctpp2c') -search_result_template = custom_target('result_template', - input: 'results.tmpl', - output: 'results.ct2', - command: [intermediate_ctpp2c, ctpp2c, '@INPUT@', '@OUTPUT@'] -) +ctpp2c = find_program('ctpp2c', required:false) + +if ctpp2c.found() + search_result_template = custom_target('result_template', + input: 'results.tmpl', + output: 'results.ct2', + command: [intermediate_ctpp2c, ctpp2c, '@INPUT@', '@OUTPUT@'] + ) + resources_list = 'resources_list_ctpp2.txt' + resources_depends = [search_result_template] +else + resources_list = 'resources_list_noctpp2.txt' + resources_depends = [] +endif lib_resources = custom_target('resources', - input: 'resources_list.txt', + input: resources_list, output: ['kiwixlib-resources.cpp', 'kiwixlib-resources.h'], command:[res_compiler, '--cxxfile', '@OUTPUT0@', '--hfile', '@OUTPUT1@', '--source_dir', '@OUTDIR@', '@INPUT@'], - depends: [search_result_template] + depends: resources_depends ) diff --git a/static/resources_list.txt b/static/resources_list_ctpp2.txt similarity index 100% rename from static/resources_list.txt rename to static/resources_list_ctpp2.txt diff --git a/static/resources_list_noctpp2.txt b/static/resources_list_noctpp2.txt new file mode 100644 index 000000000..7851cdb8f --- /dev/null +++ b/static/resources_list_noctpp2.txt @@ -0,0 +1,3 @@ +stopwords/en +stopwords/he +stopwords/fra