Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: meson.build

Issue 29537638: Issue 6226 - Use mesonbuild as a build system (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Cross compiling for Android on macOS works. Created April 3, 2018, 2:53 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cross/android-x86.in ('k') | wrap_make » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: meson.build
===================================================================
new file mode 100644
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,269 @@
+project('libadblockplus', 'cpp', default_options : ['cpp_std=c++11'], meson_version: '>0.40.0')
+
+V8_DIR=join_paths('third_party', 'v8')
+
+#
+# A quick note about the terms.
+# -HOST_MACHINE is the machine we build on.
+# -TARGET_MACHINE is the machine we build for (like the Android phone)
+#
+# However, meson use the GNU terms where build_machine is HOST_MACHINE,
+# host_machine is TARGET_MACHINE, and target_machine isn't relevant here
+# since we are not building a compiler.
+# See http://mesonbuild.com/Cross-compilation.html for details
+#
+# We will not use the meson (GNU) terms, unless stricly necessary.
+#
+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',
+)
+
+
+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
+
+android_target = false
+target_os = host_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'
+elif target_os == 'android'
+ android_target = true
+endif
+
+target_arch = host_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 ]
+
+if android_target
+ GYP_PARAMETERS += [ '-D', 'v8_target_arch=' + target_arch ]
+ V8_BUILD_GYP_FILE = join_paths(meson.source_root(), V8_DIR,
+ 'gypfiles', 'standalone.gypi')
+ V8_GYP_FILE = join_paths('src', 'v8.gyp')
+ V8_GYP = [ join_paths(meson.source_root(), 'wrap_make_gyp'), V8_DIR ]
+ V8_GYP_OUTPUT = meson.build_root()
+else
+ V8_BUILD_GYP_FILE = files('build-v8.gypi')
+ V8_GYP_FILE = files(join_paths(V8_DIR, 'src', 'v8.gyp'))
+ V8_GYP = [ join_paths(meson.source_root(), 'third_party', 'gyp', 'gyp')]
+ V8_GYP_OUTPUT = join_paths(meson.build_root(), 'v8')
+endif
+
+GYP_COMMAND = V8_GYP + [ GYP_PARAMETERS, '--depth=.', '-I', V8_BUILD_GYP_FILE,
+ '--generator-output=' + V8_GYP_OUTPUT, V8_GYP_FILE ]
+
+if android_target
+ GYP_COMMAND += [ '-S.android_' + target_arch + '.release',
+ '-I../../android-v8-options.gypi' ]
+ V8_BUILDDIR = '.'
+ V8_BUILDOUT = join_paths(meson.build_root(),
+ 'android_' + target_arch + '.release')
+ build_v8 = custom_target('build_v8',
+ output: 'Makefile.android_' + target_arch + '.release',
+ command: GYP_COMMAND)
+ V8_ANDROID_MAKE = [
+ '-f', build_v8, 'BUILDTYPE=Release', 'builddir=' + V8_BUILDOUT
+ ]
+else
+ GYP_COMMAND += [ '-f', 'make' ]
+ V8_BUILDDIR = 'v8'
+ V8_BUILDOUT = join_paths(meson.build_root(), 'v8', 'out', BUILD_CONFIG_DIR)
+ build_v8 = custom_target('build_v8', output: 'Makefile',
+ command: GYP_COMMAND)
+ V8_ANDROID_MAKE = []
+endif
+
+WRAP_MAKE = [ join_paths(meson.source_root(), 'wrap_make') ]
+if android_target
+ WRAP_MAKE += [ '-a', target_arch ]
+endif
+
+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', V8_BUILDOUT,
+ '-C', V8_BUILDDIR, 'v8_libplatform', BUILD_FLAVOUR ] + V8_ANDROID_MAKE)
+v8_libsampler = custom_target('v8_libsampler',
+ input: [ build_v8 ], output: SAMPLER_LIBRARIES,
+ command: [ WRAP_MAKE, '@OUTPUT@', '-D', V8_BUILDOUT,
+ '-C', V8_BUILDDIR, 'v8_libsampler', BUILD_FLAVOUR ] + V8_ANDROID_MAKE)
+v8_snapshot = custom_target('v8_snapshot',
+ input: [ build_v8 ], output: SNAPSHOT_LIBRARIES,
+ command: [ WRAP_MAKE, '@OUTPUT@', '-D', V8_BUILDOUT,
+ '-C', V8_BUILDDIR, 'v8_snapshot', BUILD_FLAVOUR ] + V8_ANDROID_MAKE)
+
+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,
+ cpp_args: [ '-std=c++11' ],
+ 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'
+)
+
+if not android_target
+ 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)
+endif
« no previous file with comments | « cross/android-x86.in ('k') | wrap_make » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld