Index: meson.build |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/meson.build |
@@ -0,0 +1,218 @@ |
+project('libadblockplus', 'cpp', default_options : ['cpp_std=c++14'], meson_version: '>0.40.0') |
+ |
+V8_DIR=join_paths('third_party', 'v8') |
+V8_GYP=join_paths(meson.source_root(), 'third_party', 'gyp', 'gyp') |
+HOST_ARCH=run_command('python', |
+ join_paths('third_party', |
+ 'detect_v8_host_arch.py')).stdout().strip() |
+ |
+have_curl = dependency('curl', required: false) |
+incdir = include_directories('include', join_paths(V8_DIR, 'include')) |
+ |
+ensure_dependencies = run_target('ensure_dependencies', |
+ command: ['python', 'ensure_dependencies.py']) |
+ |
+sources = files( |
+ 'include/AdblockPlus/ITimer.h', |
+ 'include/AdblockPlus/IWebRequest.h', |
+ 'include/AdblockPlus/IFileSystem.h', |
+ 'include/AdblockPlus/Scheduler.h', |
+ 'include/AdblockPlus/Platform.h', |
+ 'src/ActiveObject.cpp', |
+ 'src/AsyncExecutor.cpp', |
+ 'src/AppInfoJsObject.cpp', |
+ 'src/ConsoleJsObject.cpp', |
+ 'src/DefaultLogSystem.cpp', |
+ 'src/DefaultFileSystem.h', |
+ 'src/DefaultFileSystem.cpp', |
+ 'src/DefaultTimer.cpp', |
+ 'src/DefaultTimer.h', |
+ 'src/DefaultWebRequest.h', |
+ 'src/DefaultWebRequest.cpp', |
+ 'src/FileSystemJsObject.cpp', |
+ 'src/FilterEngine.cpp', |
+ 'src/GlobalJsObject.cpp', |
+ 'src/JsContext.cpp', |
+ 'src/JsEngine.cpp', |
+ 'src/JsError.cpp', |
+ 'src/JsValue.cpp', |
+ 'src/Notification.cpp', |
+ 'src/Platform.cpp', |
+ 'src/ReferrerMapping.cpp', |
+ 'src/Thread.cpp', |
+ 'src/Utils.cpp', |
+ 'src/WebRequestJsObject.cpp', |
+) |
+ |
+target_os = target_machine.system() |
+if target_os == 'windows' |
+ sources += files('src/DefaultWebRequestWinInet.cpp') |
+elif have_curl.found() |
+ sources += files('src/DefaultWebRequestCurl.cpp') |
+else |
+ sources += files('src/DefaultWebRequestDummy.cpp') |
+endif |
+if target_os == 'darwin' |
+ target_os = 'mac' |
+endif |
+ |
+target_arch = target_machine.cpu_family() |
+if target_arch == 'x86' |
+ target_arch = 'ia32' |
+elif target_arch == 'x86_64' |
+ target_arch = 'x64' |
+elif target_arch == 'aarch64' |
+ target_arch = 'arm64' |
+endif |
+ |
+GYP_PARAMETERS=[ '-D', 'host_arch=' + HOST_ARCH, |
+ '-D', 'OS=' + target_os, |
+ '-D', 'target_arch=' + target_arch ] |
+ |
+build_v8 = custom_target('build_v8', input: files('build-v8.gypi', |
+ join_paths(V8_DIR, 'src', 'v8.gyp')), |
+ output: 'Makefile', |
+ command: [ V8_GYP, GYP_PARAMETERS, '--depth=.', '-f', |
+ 'make', '-I', '@INPUT0@', |
+ '--generator-output=v8', '@INPUT1@' ]) |
+ |
+buildtype = get_option('buildtype') |
+if buildtype.startswith('debug') |
+ BUILD_CONFIG_DIR='Debug' |
+ BUILD_FLAVOUR='BUILDTYPE=Debug' |
+else |
+ BUILD_CONFIG_DIR='Release' |
+ BUILD_FLAVOUR='BUILDTYPE=Release' |
+endif |
+OUT_DIR=join_paths(meson.build_root(), 'v8', 'out', BUILD_CONFIG_DIR) |
+ |
+WRAP_MAKE=join_paths(meson.source_root(), 'wrap_make') |
+ |
+if target_os == 'windows' |
+ PLATFORM_LIBRARIES = [ 'v8_libplatform.lib', 'v8_libbase.lib', |
+ 'v8_base_0.lib', 'v8_base_1.lib', |
+ 'v8_base_2.lib', 'v8_base_3.lib' ] |
+ SAMPLER_LIBRARIES = 'v8_libsampler.lib' |
+ SNAPSHOT_LIBRARIES = 'v8_snapshot.lib' |
+else |
+ PLATFORM_LIBRARIES = [ 'libv8_libplatform.a' ] |
+ SAMPLER_LIBRARIES = [ 'libv8_libsampler.a' ] |
+ SNAPSHOT_LIBRARIES = [ 'libv8_snapshot.a', 'libv8_libbase.a', |
+ 'libv8_base.a' ] |
+endif |
+v8_libplatform = custom_target('v8_libplatform', |
+ input: [ build_v8 ], |
+ output: PLATFORM_LIBRARIES, |
+ command: [ WRAP_MAKE, '@OUTPUT@', '-D', OUT_DIR, |
+ '-C', 'v8', 'v8_libplatform', BUILD_FLAVOUR ]) |
+v8_libsampler = custom_target('v8_libsampler', |
+ input: [ build_v8 ], output: SAMPLER_LIBRARIES, |
+ command: [ WRAP_MAKE, '@OUTPUT@', '-D', OUT_DIR, |
+ '-C', 'v8', 'v8_libsampler', BUILD_FLAVOUR ]) |
+v8_snapshot = custom_target('v8_snapshot', |
+ input: [ build_v8 ], output: SNAPSHOT_LIBRARIES, |
+ command: [ WRAP_MAKE, '@OUTPUT@', '-D', OUT_DIR, |
+ '-C', 'v8', 'v8_snapshot', BUILD_FLAVOUR ]) |
+ |
+ |
+library_files = files( |
+ 'lib/info.js', |
+ 'lib/io.js', |
+ 'lib/prefs.js', |
+ 'lib/utils.js', |
+ 'lib/elemHideHitRegistration.js', |
+ 'adblockpluscore/lib/events.js', |
+ 'adblockpluscore/lib/coreUtils.js', |
+ 'adblockpluscore/lib/filterNotifier.js', |
+ 'lib/init.js', |
+ 'adblockpluscore/lib/common.js', |
+ 'adblockpluscore/lib/filterClasses.js', |
+ 'adblockpluscore/lib/subscriptionClasses.js', |
+ 'adblockpluscore/lib/filterStorage.js', |
+ 'adblockpluscore/lib/elemHide.js', |
+ 'adblockpluscore/lib/elemHideEmulation.js', |
+ 'adblockpluscore/lib/matcher.js', |
+ 'adblockpluscore/lib/filterListener.js', |
+ 'adblockpluscore/lib/downloader.js', |
+ 'adblockpluscore/lib/notification.js', |
+ 'lib/notificationShowRegistration.js', |
+ 'adblockpluscore/lib/synchronizer.js', |
+ 'lib/filterUpdateRegistration.js', |
+ 'adblockpluscore/chrome/content/ui/subscriptions.xml', |
+ 'lib/updater.js' |
+) |
+load_before_files = files('lib/compat.js') |
+load_after_files = files( |
+ 'lib/api.js', |
+ 'lib/publicSuffixList.js', |
+ 'lib/punycode.js', |
+ 'lib/basedomain.js' |
+) |
+ |
+js_sources = custom_target('js_sources', |
+ input: load_before_files + load_after_files + library_files, |
+ output: 'adblockplus.js.cpp', |
+ command: [ 'python', join_paths(meson.source_root(), 'convert_js.py'), |
+ '@OUTPUT@', |
+ '--before', load_before_files, |
+ '--convert', library_files, |
+ '--after', load_after_files ]) |
+ |
+LIBRARIES = [] |
+if target_os == 'windows' |
+ LIBRARIES = [ 'shlwapi.lib', 'winhttp.lib', 'winmm.lib' ] |
+endif |
+adblockplus = shared_library('adblockplus', sources, js_sources, |
+ v8_snapshot, v8_libsampler, v8_libplatform, |
+ include_directories: incdir, |
+ link_with: LIBRARIES, |
+ dependencies: [ have_curl ]) |
+ |
+test_sources = files( |
+ 'test/AsyncExecutor.cpp', |
+ 'test/BaseJsTest.h', |
+ 'test/BaseJsTest.cpp', |
+ 'test/AppInfoJsObject.cpp', |
+ 'test/ConsoleJsObject.cpp', |
+ 'test/DefaultFileSystem.cpp', |
+ 'test/FileSystemJsObject.cpp', |
+ 'test/FilterEngine.cpp', |
+ 'test/GlobalJsObject.cpp', |
+ 'test/JsEngine.cpp', |
+ 'test/JsValue.cpp', |
+ 'test/Notification.cpp', |
+ 'test/Prefs.cpp', |
+ 'test/ReferrerMapping.cpp', |
+ 'test/UpdateCheck.cpp', |
+ 'test/WebRequest.cpp', |
+ 'third_party/googletest/googletest/src/gtest_main.cc' |
+) |
+ |
+GTEST_DIR = join_paths('third_party', 'googletest', 'googletest') |
+GTEST_PARAMS = [] |
+LINK_PARAMS = [] |
+compiler = meson.get_compiler('cpp') |
+if compiler.has_argument('-pthread') |
+ GTEST_PARAMS += '-pthread' |
+ LINK_PARAMS += '-lpthread' |
+endif |
+ |
+gtest = static_library('gtest', |
+ files(join_paths(GTEST_DIR, 'src', 'gtest-all.cc')), |
+ include_directories: [ |
+ include_directories(join_paths(GTEST_DIR, 'include'), is_system: true), |
+ include_directories(GTEST_DIR) |
+ ], |
+ cpp_args: GTEST_PARAMS) |
+ |
+tests = executable('tests', test_sources, |
+ link_with: [adblockplus, gtest], |
+ link_args: LINK_PARAMS, |
+ include_directories: [ |
+ incdir, |
+ include_directories(join_paths(GTEST_DIR, 'include')) |
+ ]) |
+ |
+# Adjust the timeout to run the test. Default value is 30sec. |
+# |
+test('tests', tests, timeout: 60) |