Switch build system to mesonbuild.

There is no more integrated build of dependencies in the build system.
Dependencies are discovered using pkg-config except for ctpp2 where there
is no pkg-config file.
This commit is contained in:
Matthieu Gautier 2016-12-19 23:48:30 +01:00
parent 1c68cf87b9
commit 8ce1fb0ba8
42 changed files with 161 additions and 141 deletions

View File

@ -37,7 +37,7 @@
#include <direct.h> #include <direct.h>
#endif #endif
#include <stringTools.h> #include "stringTools.h"
using namespace std; using namespace std;

View File

@ -34,7 +34,7 @@
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <pathTools.h> #include "pathTools.h"
namespace kiwix { namespace kiwix {

View File

@ -20,12 +20,12 @@
#ifndef _CTPP2_VM_STRING_LOADER_HPP__ #ifndef _CTPP2_VM_STRING_LOADER_HPP__
#define _CTPP2_VM_STRING_LOADER_HPP__ 1 #define _CTPP2_VM_STRING_LOADER_HPP__ 1
#include "ctpp2/CTPP2VMLoader.hpp" #include <ctpp2/CTPP2VMLoader.hpp>
#include "ctpp2/CTPP2Util.hpp" #include <ctpp2/CTPP2Util.hpp>
#include "ctpp2/CTPP2Exception.hpp" #include <ctpp2/CTPP2Exception.hpp>
#include "ctpp2/CTPP2VMExecutable.hpp" #include <ctpp2/CTPP2VMExecutable.hpp>
#include "ctpp2/CTPP2VMInstruction.hpp" #include <ctpp2/CTPP2VMInstruction.hpp>
#include "ctpp2/CTPP2VMMemoryCore.hpp" #include <ctpp2/CTPP2VMMemoryCore.hpp>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -34,7 +34,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <resourceTools.h> // #include <common/resourceTools.h>
#include <iostream> #include <iostream>
#include <string> #include <string>

View File

@ -29,9 +29,9 @@
#include <sstream> #include <sstream>
#include <pthread.h> #include <pthread.h>
#include <stringTools.h> #include "common/stringTools.h"
#include <otherTools.h> #include "common/otherTools.h"
#include <resourceTools.h> #include "common/resourceTools.h"
#include <zim/file.h> #include <zim/file.h>
#include <zim/article.h> #include <zim/article.h>
#include <zim/fileiterator.h> #include <zim/fileiterator.h>

View File

@ -17,28 +17,10 @@
* MA 02110-1301, USA. * MA 02110-1301, USA.
*/ */
#ifndef KIWIX_COMPONENTTOOLS_H #ifndef KIWIX_H
#define KIWIX_COMPONENTTOOLS_H #define KIWIX_H
#ifdef _WIN32 #include "library.h"
#include <mozilla/Char16.h>
#endif
#include<string>
#ifdef __APPLE__
#include <stdint.h>
#endif
#ifdef _WIN32
#include <stdlib.h>
#endif
#include "nsStringAPI.h"
#include "nsEmbedString.h"
const char *nsStringToCString(const nsAString &str);
std::string nsStringToString(const nsEmbedString &str);
const char *nsStringToUTF8(const nsAString &str);
#endif #endif

View File

@ -27,8 +27,8 @@
#include <vector> #include <vector>
#include <stack> #include <stack>
#include <stringTools.h> #include "common/stringTools.h"
#include <regexTools.h> #include "common/regexTools.h"
#define KIWIX_LIBRARY_VERSION "20110515" #define KIWIX_LIBRARY_VERSION "20110515"

View File

@ -26,11 +26,11 @@
#include <pugixml.hpp> #include <pugixml.hpp>
#include "../base64.h" #include "common/base64.h"
#include "../regexTools.h" #include "common/regexTools.h"
#include "../pathTools.h" #include "common/pathTools.h"
#include <kiwix/library.h> #include "library.h"
#include <kiwix/reader.h> #include "reader.h"
using namespace std; using namespace std;

31
include/meson.build Normal file
View File

@ -0,0 +1,31 @@
headers = [
'indexer.h',
'library.h',
'manager.h',
'reader.h',
'searcher.h'
]
if xapian_dep.found()
headers += ['xapianIndexer.h', 'xapianSearcher.h']
endif
install_headers(headers, subdir:'kiwix')
install_headers(
'common/base64.h',
'common/networkTools.h',
'common/otherTools.h',
'common/pathTools.h',
'common/regexTools.h',
'common/resourceTools.h',
'common/stringTools.h',
'common/tree.h',
subdir:'kiwix/common'
)
install_headers(
'ctpp2/CTPP2VMStringLoader.hpp',
subdir:'kiwix/ctpp2'
)

View File

@ -29,9 +29,8 @@
#include <exception> #include <exception>
#include <sstream> #include <sstream>
#include <map> #include <map>
#include "time.h" #include "common/pathTools.h"
#include <pathTools.h> #include "common/stringTools.h"
#include <stringTools.h>
using namespace std; using namespace std;

View File

@ -28,16 +28,16 @@
#include <locale> #include <locale>
#include <cctype> #include <cctype>
#include <vector> #include <vector>
#include <resourceTools.h> #include "common/resourceTools.h"
#include <pathTools.h> #include "common/pathTools.h"
#include <stringTools.h> #include "common/stringTools.h"
#include "unicode/putil.h" #include <unicode/putil.h>
#ifndef __ANDROID__ #ifndef __ANDROID__
#include <ctpp2/CDT.hpp> #include <ctpp2/CDT.hpp>
#include <ctpp2/CTPP2FileLogger.hpp> #include <ctpp2/CTPP2FileLogger.hpp>
#include <ctpp2/CTPP2SimpleVM.hpp> #include <ctpp2/CTPP2SimpleVM.hpp>
#include "kiwix/ctpp2/CTPP2VMStringLoader.hpp" #include "ctpp2/CTPP2VMStringLoader.hpp"
using namespace CTPP; using namespace CTPP;
#endif #endif

61
meson.build Normal file
View File

@ -0,0 +1,61 @@
project('kiwixlib', 'cpp',
version : '1.0.0',
license : 'GPL')
compiler = meson.get_compiler('cpp')
thread_dep = dependency('threads')
zlib_dep = dependency('zlib')
bzip_dep = dependency('bzip2')
libicu_dep = dependency('icu-i18n')
lzma_dep = dependency('liblzma')
libzim_dep = dependency('zimlib')
pugixml_dep = dependency('pugixml')
aria2_dep = find_program('aria2c')
ctpp2_prefix_install = get_option('ctpp2-install-prefix')
if get_option('default_library') == 'static'
libname = 'ctpp2-st'
else
libname = 'ctpp2'
endif
if ctpp2_prefix_install == ''
if not compiler.has_header('ctpp2/CTPP2Logger.hpp')
error('ctpp2/CTPP2Logger.hppnot found')
endif
ctpp2_lib = compiler.find_library(libname)
ctpp2_dep = declare_dependency(dependencies:[ctpp2_lib])
else
ctpp2_include_path = ctpp2_prefix_install + '/include'
ctpp2_include_args = ['-I'+ctpp2_include_path]
if not compiler.has_header('ctpp2/CTPP2Logger.hpp', args:ctpp2_include_args)
error('ctpp2/CTPP2Logger.hppnot found')
endif
ctpp2_include_path = include_directories(ctpp2_include_path, is_system:true)
ctpp2_lib_path = ctpp2_prefix_install+'/lib'
ctpp2_lib = compiler.find_library(libname, dirs:ctpp2_lib_path)
ctpp2_dep = declare_dependency(include_directories:ctpp2_include_path, dependencies:[ctpp2_lib])
endif
xapian_dep = dependency('xapian-core', required:false)
if xapian_dep.found()
message('xapian_dep found')
else
message('xapian_dep not found')
endif
all_deps = [thread_dep, zlib_dep, libicu_dep, lzma_dep, libzim_dep, ctpp2_dep, xapian_dep, pugixml_dep, bzip_dep]
inc = include_directories('include')
subdir('include')
subdir('src')
pkg_mod = import('pkgconfig')
pkg_mod.generate(libraries : kiwixlib,
version : '1.0',
name : 'libkiwix',
filebase : 'kiwix',
description : 'A library that contains a lot of things used by used by other kiwix programs',
requires: ['zimlib', 'zlib', 'xapian-core', 'icu-i18n', 'liblzma', 'bzip2', 'pugixml'])

2
meson_options.txt Normal file
View File

@ -0,0 +1,2 @@
option('ctpp2-install-prefix', type : 'string', value : '',
description : 'Prefix where ctpp libs has been installed')

View File

@ -24,7 +24,7 @@
René Nyffenegger rene.nyffenegger@adp-gmbh.ch René Nyffenegger rene.nyffenegger@adp-gmbh.ch
*/ */
#include "base64.h" #include <common/base64.h>
#include <iostream> #include <iostream>
static const std::string base64_chars = static const std::string base64_chars =

View File

@ -1,84 +0,0 @@
/*
* Copyright 2011 Emmanuel Engelhart <kelson@kiwix.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include "componentTools.h"
const char *nsStringToCString(const nsAString &str) {
const char *cStr;
nsCString tmpStr;
#ifdef _WIN32
LossyCopyUTF16toASCII(str, tmpStr);
#else
CopyUTF16toUTF8(str, tmpStr);
#endif
NS_CStringGetData(tmpStr, &cStr);
#ifdef _WIN32
return _strdup(cStr);
#else
return strdup(cStr);
#endif
}
std::string nsStringToString(const nsEmbedString &str) {
#ifdef _WIN32
PRUnichar *start = (PRUnichar *)str.get();
PRUnichar *end = start + str.Length();
wchar_t wca[4096];
wchar_t *wstart = wca;
wchar_t *wpr = wstart;
for(; start < end; ++start)
{
*wstart = (wchar_t) *start;
++wstart;
}
*wstart = 0;
std::string ptr;
ptr.resize(4096);
size_t size = wcstombs((char*)ptr.data(), wpr, 4096);
ptr.resize(size);
return ptr;
#else
const char *cStr;
nsCString tmpStr;
CopyUTF16toUTF8(str, tmpStr);
NS_CStringGetData(tmpStr, &cStr);
return std::string(cStr);
#endif
}
const char *nsStringToUTF8(const nsAString &str) {
const char *cStr;
nsCString tmpStr;
CopyUTF16toUTF8(str, tmpStr);
NS_CStringGetData(tmpStr, &cStr);
#ifdef _WIN32
return _strdup(cStr);
#else
return strdup(cStr);
#endif
}

View File

@ -17,7 +17,7 @@
* MA 02110-1301, USA. * MA 02110-1301, USA.
*/ */
#include "networkTools.h" #include <common/networkTools.h>
std::map<std::string, std::string> kiwix::getNetworkInterfaces() { std::map<std::string, std::string> kiwix::getNetworkInterfaces() {
std::map<std::string, std::string> interfaces; std::map<std::string, std::string> interfaces;

View File

@ -17,7 +17,7 @@
* MA 02110-1301, USA. * MA 02110-1301, USA.
*/ */
#include "otherTools.h" #include <common/otherTools.h>
void kiwix::sleep(unsigned int milliseconds) { void kiwix::sleep(unsigned int milliseconds) {
#ifdef _WIN32 #ifdef _WIN32

View File

@ -17,7 +17,7 @@
* MA 02110-1301, USA. * MA 02110-1301, USA.
*/ */
#include "pathTools.h" #include <common/pathTools.h>
#ifdef __APPLE__ #ifdef __APPLE__
#include <mach-o/dyld.h> #include <mach-o/dyld.h>
@ -41,6 +41,8 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <stdlib.h>
#ifndef PATH_MAX #ifndef PATH_MAX
#define PATH_MAX 1024 #define PATH_MAX 1024
#endif #endif

View File

@ -17,7 +17,7 @@
* MA 02110-1301, USA. * MA 02110-1301, USA.
*/ */
#include "regexTools.h" #include <common/regexTools.h>
std::map<std::string, RegexMatcher*> regexCache; std::map<std::string, RegexMatcher*> regexCache;

View File

@ -1,4 +1,4 @@
#include <resourceTools.h> #include <common/resourceTools.h>
#include <iostream> #include <iostream>
std::string getResourceAsString(const std::string &name) { std::string getResourceAsString(const std::string &name) {

View File

@ -17,7 +17,7 @@
* MA 02110-1301, USA. * MA 02110-1301, USA.
*/ */
#include "stringTools.h" #include <common/stringTools.h>
/* tell ICU where to find its dat file (tables) */ /* tell ICU where to find its dat file (tables) */
void kiwix::loadICUExternalTables() { void kiwix::loadICUExternalTables() {

View File

@ -17,7 +17,7 @@
* MA 02110-1301, USA. * MA 02110-1301, USA.
*/ */
#include "CTPP2VMStringLoader.hpp" #include <ctpp2/CTPP2VMStringLoader.hpp>
namespace CTPP // C++ Template Engine namespace CTPP // C++ Template Engine
{ {

27
src/meson.build Normal file
View File

@ -0,0 +1,27 @@
kiwix_sources = [
'library.cpp',
'manager.cpp',
'reader.cpp',
'searcher.cpp',
'indexer.cpp',
'common/base64.cpp',
'common/pathTools.cpp',
'common/regexTools.cpp',
'common/stringTools.cpp',
'common/resourceTools.cpp',
'common/networkTools.cpp',
'common/otherTools.cpp',
'ctpp2/CTPP2VMStringLoader.cpp',
'xapian/htmlparse.cc',
'xapian/myhtmlparse.cc'
]
if xapian_dep.found()
kiwix_sources += ['xapianIndexer.cpp', 'xapianSearcher.cpp']
endif
kiwixlib = library('kiwix',
kiwix_sources,
include_directories : inc,
dependencies : all_deps,
install : true)