| LEFT | RIGHT | 
|    1 project('libadblockplus', 'cpp', default_options : ['cpp_std=c++14'], meson_vers
     ion: '>0.40.0') |    1 project('libadblockplus', 'cpp', default_options : ['cpp_std=c++14'], meson_vers
     ion: '>0.40.0') | 
|    2  |    2  | 
|    3 V8_DIR=join_paths('third_party', 'v8') |    3 V8_DIR=join_paths('third_party', 'v8') | 
|    4 V8_GYP=join_paths(meson.source_root(), 'third_party', 'gyp', 'gyp') |    4  | 
|    5 HOST_ARCH=run_command('python', |    5 # | 
|    6                       join_paths('third_party', |    6 # A quick note about the terms. | 
|    7                                  'detect_v8_host_arch.py')).stdout().strip() |    7 # -HOST_MACHINE is the machine we build on. | 
 |    8 # -TARGET_MACHINE is the machine we build for (like the Android phone) | 
 |    9 # | 
 |   10 # However, meson use the GNU terms where build_machine is HOST_MACHINE, | 
 |   11 # host_machine is TARGET_MACHINE, and target_machine isn't relevant here | 
 |   12 # since we are not building a compiler. | 
 |   13 # See http://mesonbuild.com/Cross-compilation.html for details | 
 |   14 # | 
 |   15 # We will not use the meson (GNU) terms, unless stricly necessary. | 
 |   16 # | 
 |   17 host_arch = run_command('python', | 
 |   18                         join_paths('third_party', | 
 |   19                                    'detect_v8_host_arch.py')).stdout().strip() | 
|    8  |   20  | 
|    9 have_curl = dependency('curl', required: false) |   21 have_curl = dependency('curl', required: false) | 
|   10 incdir = include_directories('include', join_paths(V8_DIR, 'include')) |   22 incdir = include_directories('include', join_paths(V8_DIR, 'include')) | 
|   11  |   23  | 
|   12 ensure_dependencies = run_target('ensure_dependencies', |   24 ensure_dependencies = run_target('ensure_dependencies', | 
|   13                                  command: ['python', 'ensure_dependencies.py']) |   25                                  command: ['python', 'ensure_dependencies.py']) | 
|   14  |   26  | 
|   15 sources = files( |   27 sources = files( | 
|   16   'include/AdblockPlus/ITimer.h', |   28   'include/AdblockPlus/ITimer.h', | 
|   17   'include/AdblockPlus/IWebRequest.h', |   29   'include/AdblockPlus/IWebRequest.h', | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
|   37   'src/JsError.cpp', |   49   'src/JsError.cpp', | 
|   38   'src/JsValue.cpp', |   50   'src/JsValue.cpp', | 
|   39   'src/Notification.cpp', |   51   'src/Notification.cpp', | 
|   40   'src/Platform.cpp', |   52   'src/Platform.cpp', | 
|   41   'src/ReferrerMapping.cpp', |   53   'src/ReferrerMapping.cpp', | 
|   42   'src/Thread.cpp', |   54   'src/Thread.cpp', | 
|   43   'src/Utils.cpp', |   55   'src/Utils.cpp', | 
|   44   'src/WebRequestJsObject.cpp', |   56   'src/WebRequestJsObject.cpp', | 
|   45 ) |   57 ) | 
|   46  |   58  | 
|   47 target_os = target_machine.system() |   59  | 
 |   60 buildtype = get_option('buildtype') | 
 |   61 if buildtype.startswith('debug') | 
 |   62      BUILD_CONFIG_DIR='Debug' | 
 |   63      BUILD_FLAVOUR='BUILDTYPE=Debug' | 
 |   64 else | 
 |   65      BUILD_CONFIG_DIR='Release' | 
 |   66      BUILD_FLAVOUR='BUILDTYPE=Release' | 
 |   67 endif | 
 |   68  | 
 |   69 android_target = false | 
 |   70 target_os = host_machine.system() | 
|   48 if target_os == 'windows' |   71 if target_os == 'windows' | 
|   49    sources += files('src/DefaultWebRequestWinInet.cpp') |   72    sources += files('src/DefaultWebRequestWinInet.cpp') | 
|   50 elif have_curl.found() |   73 elif have_curl.found() | 
|   51    sources += files('src/DefaultWebRequestCurl.cpp') |   74    sources += files('src/DefaultWebRequestCurl.cpp') | 
|   52 else |   75 else | 
|   53    sources += files('src/DefaultWebRequestDummy.cpp') |   76    sources += files('src/DefaultWebRequestDummy.cpp') | 
|   54 endif |   77 endif | 
|   55 if target_os == 'darwin' |   78 if target_os == 'darwin' | 
|   56    target_os = 'mac' |   79    target_os = 'mac' | 
|   57 endif |   80 elif target_os == 'android' | 
|   58  |   81    android_target = true | 
|   59 target_arch = target_machine.cpu_family() |   82 endif | 
 |   83  | 
 |   84 target_arch = host_machine.cpu_family() | 
|   60 if target_arch == 'x86' |   85 if target_arch == 'x86' | 
|   61    target_arch = 'ia32' |   86    target_arch = 'ia32' | 
|   62 elif target_arch == 'x86_64' |   87 elif target_arch == 'x86_64' | 
|   63    target_arch = 'x64' |   88    target_arch = 'x64' | 
|   64 elif target_arch == 'aarch64' |   89 elif target_arch == 'aarch64' | 
|   65    target_arch = 'arm64' |   90    target_arch = 'arm64' | 
|   66 endif |   91 endif | 
|   67  |   92  | 
|   68 GYP_PARAMETERS=[ '-D', 'host_arch=' + HOST_ARCH, |   93 GYP_PARAMETERS = [ '-D', 'host_arch=' + host_arch, | 
|   69                  '-D', 'OS=' + target_os, |   94                   '-D', 'OS=' + target_os, | 
|   70                  '-D', 'target_arch=' + target_arch ] |   95                   '-D', 'target_arch=' + target_arch ] | 
|   71  |   96  | 
|   72 build_v8 = custom_target('build_v8', input: files('build-v8.gypi', |   97 if android_target | 
|   73                          join_paths(V8_DIR, 'src', 'v8.gyp')), |   98    GYP_PARAMETERS += [ '-D', 'v8_target_arch=' + target_arch ] | 
|   74                          output: 'Makefile', |   99    V8_BUILD_GYP_FILE = join_paths(meson.source_root(), V8_DIR, | 
|   75                          command: [ V8_GYP, GYP_PARAMETERS, '--depth=.', '-f', |  100                                   'gypfiles', 'standalone.gypi') | 
|   76                                     'make', '-I', '@INPUT0@', |  101    V8_GYP_FILE = join_paths('src', 'v8.gyp') | 
|   77                                     '--generator-output=v8', '@INPUT1@' ]) |  102    V8_GYP = [ join_paths(meson.source_root(), 'wrap_make_gyp'), V8_DIR ] | 
|   78  |  103    V8_GYP_OUTPUT = meson.build_root() | 
|   79 buildtype = get_option('buildtype') |  104 else | 
|   80 if buildtype.startswith('debug') |  105    V8_BUILD_GYP_FILE = files('build-v8.gypi') | 
|   81      BUILD_CONFIG_DIR='Debug' |  106    V8_GYP_FILE = files(join_paths(V8_DIR, 'src', 'v8.gyp')) | 
|   82      BUILD_FLAVOUR='BUILDTYPE=Debug' |  107    V8_GYP = [ join_paths(meson.source_root(), 'third_party', 'gyp', 'gyp')] | 
|   83 else |  108    V8_GYP_OUTPUT = join_paths(meson.build_root(), 'v8') | 
|   84      BUILD_CONFIG_DIR='Release' |  109 endif | 
|   85      BUILD_FLAVOUR='BUILDTYPE=Release' |  110  | 
|   86 endif |  111 GYP_COMMAND = V8_GYP + [ GYP_PARAMETERS, '--depth=.', '-I', V8_BUILD_GYP_FILE, | 
|   87 OUT_DIR=join_paths(meson.build_root(), 'v8', 'out', BUILD_CONFIG_DIR) |  112               '--generator-output=' + V8_GYP_OUTPUT, V8_GYP_FILE ] | 
|   88  |  113  | 
|   89 WRAP_MAKE=join_paths(meson.source_root(), 'wrap_make') |  114 if android_target | 
 |  115    GYP_COMMAND += [ '-S.android_' + target_arch + '.release', | 
 |  116                     '-I../../android-v8-options.gypi' ] | 
 |  117    V8_BUILDDIR = '.' | 
 |  118    V8_BUILDOUT = join_paths(meson.build_root(), | 
 |  119                               'android_' + target_arch + '.release') | 
 |  120    build_v8 = custom_target('build_v8', | 
 |  121                             output: 'Makefile.android_' + target_arch + '.releas
     e', | 
 |  122                             command: GYP_COMMAND) | 
 |  123    V8_ANDROID_MAKE = [ | 
 |  124       '-f', build_v8, 'BUILDTYPE=Release', 'builddir=' + V8_BUILDOUT | 
 |  125    ] | 
 |  126 else | 
 |  127    GYP_COMMAND += [ '-f', 'make' ] | 
 |  128    V8_BUILDDIR = 'v8' | 
 |  129    V8_BUILDOUT = join_paths(meson.build_root(), 'v8', 'out', BUILD_CONFIG_DIR) | 
 |  130    build_v8 = custom_target('build_v8', output: 'Makefile', | 
 |  131                             command: GYP_COMMAND) | 
 |  132    V8_ANDROID_MAKE = [] | 
 |  133 endif | 
 |  134  | 
 |  135 WRAP_MAKE = [ join_paths(meson.source_root(), 'wrap_make') ] | 
 |  136 if android_target | 
 |  137    WRAP_MAKE += [ '-a', target_arch ] | 
 |  138 endif | 
|   90  |  139  | 
|   91 if target_os == 'windows' |  140 if target_os == 'windows' | 
|   92      PLATFORM_LIBRARIES = [ 'v8_libplatform.lib', 'v8_libbase.lib', |  141      PLATFORM_LIBRARIES = [ 'v8_libplatform.lib', 'v8_libbase.lib', | 
|   93                             'v8_base_0.lib', 'v8_base_1.lib', |  142                             'v8_base_0.lib', 'v8_base_1.lib', | 
|   94                             'v8_base_2.lib', 'v8_base_3.lib' ] |  143                             'v8_base_2.lib', 'v8_base_3.lib' ] | 
|   95      SAMPLER_LIBRARIES = 'v8_libsampler.lib' |  144      SAMPLER_LIBRARIES = 'v8_libsampler.lib' | 
|   96      SNAPSHOT_LIBRARIES = 'v8_snapshot.lib' |  145      SNAPSHOT_LIBRARIES = 'v8_snapshot.lib' | 
|   97 else |  146 else | 
|   98      PLATFORM_LIBRARIES = [ 'libv8_libplatform.a' ] |  147      PLATFORM_LIBRARIES = [ 'libv8_libplatform.a' ] | 
|   99      SAMPLER_LIBRARIES = [ 'libv8_libsampler.a' ] |  148      SAMPLER_LIBRARIES = [ 'libv8_libsampler.a' ] | 
|  100      SNAPSHOT_LIBRARIES = [ 'libv8_snapshot.a', 'libv8_libbase.a', |  149      SNAPSHOT_LIBRARIES = [ 'libv8_snapshot.a', 'libv8_libbase.a', | 
|  101                             'libv8_base.a' ] |  150                             'libv8_base.a' ] | 
|  102 endif |  151 endif | 
|  103 v8_libplatform = custom_target('v8_libplatform', |  152 v8_libplatform = custom_target('v8_libplatform', | 
|  104     input: [ build_v8 ], |  153     input: [ build_v8 ], | 
|  105     output: PLATFORM_LIBRARIES, |  154     output: PLATFORM_LIBRARIES, | 
|  106     command: [ WRAP_MAKE, '@OUTPUT@', '-D', OUT_DIR, |  155     command: [ WRAP_MAKE, '@OUTPUT@', '-D', V8_BUILDOUT, | 
|  107                '-C', 'v8', 'v8_libplatform', BUILD_FLAVOUR ]) |  156                '-C', V8_BUILDDIR, 'v8_libplatform', BUILD_FLAVOUR ] + V8_ANDROID
     _MAKE) | 
|  108 v8_libsampler = custom_target('v8_libsampler', |  157 v8_libsampler = custom_target('v8_libsampler', | 
|  109     input: [ build_v8 ], output: SAMPLER_LIBRARIES, |  158     input: [ build_v8 ], output: SAMPLER_LIBRARIES, | 
|  110     command: [ WRAP_MAKE, '@OUTPUT@', '-D', OUT_DIR, |  159     command: [ WRAP_MAKE, '@OUTPUT@', '-D', V8_BUILDOUT, | 
|  111                '-C', 'v8', 'v8_libsampler', BUILD_FLAVOUR ]) |  160                '-C', V8_BUILDDIR, 'v8_libsampler', BUILD_FLAVOUR ] + V8_ANDROID_
     MAKE) | 
|  112 v8_snapshot = custom_target('v8_snapshot', |  161 v8_snapshot = custom_target('v8_snapshot', | 
|  113     input: [ build_v8 ], output: SNAPSHOT_LIBRARIES, |  162     input: [ build_v8 ], output: SNAPSHOT_LIBRARIES, | 
|  114     command: [ WRAP_MAKE, '@OUTPUT@', '-D', OUT_DIR, |  163     command: [ WRAP_MAKE, '@OUTPUT@', '-D', V8_BUILDOUT, | 
|  115                '-C', 'v8', 'v8_snapshot', BUILD_FLAVOUR ]) |  164                '-C', V8_BUILDDIR, 'v8_snapshot', BUILD_FLAVOUR ] + V8_ANDROID_MA
     KE) | 
|  116  |  | 
|  117  |  165  | 
|  118 library_files = files( |  166 library_files = files( | 
|  119           'lib/info.js', |  167           'lib/info.js', | 
|  120           'lib/io.js', |  168           'lib/io.js', | 
|  121           'lib/prefs.js', |  169           'lib/prefs.js', | 
|  122           'lib/utils.js', |  170           'lib/utils.js', | 
|  123           'lib/elemHideHitRegistration.js', |  171           'lib/elemHideHitRegistration.js', | 
|  124           'adblockpluscore/lib/events.js', |  172           'adblockpluscore/lib/events.js', | 
|  125           'adblockpluscore/lib/coreUtils.js', |  173           'adblockpluscore/lib/coreUtils.js', | 
|  126           'adblockpluscore/lib/filterNotifier.js', |  174           'adblockpluscore/lib/filterNotifier.js', | 
| (...skipping 24 matching lines...) Expand all  Loading... | 
|  151  |  199  | 
|  152 js_sources = custom_target('js_sources', |  200 js_sources = custom_target('js_sources', | 
|  153     input: load_before_files + load_after_files + library_files, |  201     input: load_before_files + load_after_files + library_files, | 
|  154     output: 'adblockplus.js.cpp', |  202     output: 'adblockplus.js.cpp', | 
|  155     command: [ 'python', join_paths(meson.source_root(), 'convert_js.py'), |  203     command: [ 'python', join_paths(meson.source_root(), 'convert_js.py'), | 
|  156                '@OUTPUT@', |  204                '@OUTPUT@', | 
|  157                '--before', load_before_files, |  205                '--before', load_before_files, | 
|  158                '--convert', library_files, |  206                '--convert', library_files, | 
|  159                '--after', load_after_files ]) |  207                '--after', load_after_files ]) | 
|  160  |  208  | 
 |  209 CXX_FLAGS = [ '-std=c++14' ] | 
|  161 LIBRARIES = [] |  210 LIBRARIES = [] | 
|  162 if target_os == 'windows' |  211 if target_os == 'windows' | 
|  163   LIBRARIES = [ 'shlwapi.lib', 'winhttp.lib', 'winmm.lib' ] |  212   LIBRARIES = [ 'shlwapi.lib', 'winhttp.lib', 'winmm.lib' ] | 
 |  213 else | 
 |  214   CXX_FLAGS += '-fPIC' | 
 |  215 endif | 
 |  216 LD_FLAGS = [] | 
 |  217 if android_target | 
 |  218   LD_FLAGS += '-Wl,--allow-multiple-definition' | 
|  164 endif |  219 endif | 
|  165 adblockplus = shared_library('adblockplus', sources, js_sources, |  220 adblockplus = shared_library('adblockplus', sources, js_sources, | 
|  166                              v8_snapshot, v8_libsampler, v8_libplatform, |  221                              v8_snapshot, v8_libsampler, v8_libplatform, | 
|  167                              include_directories: incdir, |  222                              include_directories: incdir, | 
 |  223                              cpp_args: CXX_FLAGS, | 
 |  224                              link_args: LD_FLAGS, | 
|  168                              link_with: LIBRARIES, |  225                              link_with: LIBRARIES, | 
|  169                              dependencies: [ have_curl ]) |  226                              dependencies: [ have_curl ]) | 
|  170  |  227  | 
|  171 test_sources = files( |  228 test_sources = files( | 
|  172   'test/AsyncExecutor.cpp', |  229   'test/AsyncExecutor.cpp', | 
|  173   'test/BaseJsTest.h', |  230   'test/BaseJsTest.h', | 
|  174   'test/BaseJsTest.cpp', |  231   'test/BaseJsTest.cpp', | 
|  175   'test/AppInfoJsObject.cpp', |  232   'test/AppInfoJsObject.cpp', | 
|  176   'test/ConsoleJsObject.cpp', |  233   'test/ConsoleJsObject.cpp', | 
|  177   'test/DefaultFileSystem.cpp', |  234   'test/DefaultFileSystem.cpp', | 
|  178   'test/FileSystemJsObject.cpp', |  235   'test/FileSystemJsObject.cpp', | 
|  179   'test/FilterEngine.cpp', |  236   'test/FilterEngine.cpp', | 
|  180   'test/GlobalJsObject.cpp', |  237   'test/GlobalJsObject.cpp', | 
|  181   'test/JsEngine.cpp', |  238   'test/JsEngine.cpp', | 
|  182   'test/JsValue.cpp', |  239   'test/JsValue.cpp', | 
|  183   'test/Notification.cpp', |  240   'test/Notification.cpp', | 
|  184   'test/Prefs.cpp', |  241   'test/Prefs.cpp', | 
|  185   'test/ReferrerMapping.cpp', |  242   'test/ReferrerMapping.cpp', | 
|  186   'test/UpdateCheck.cpp', |  243   'test/UpdateCheck.cpp', | 
|  187   'test/WebRequest.cpp', |  244   'test/WebRequest.cpp', | 
|  188   'third_party/googletest/googletest/src/gtest_main.cc' |  245   'third_party/googletest/googletest/src/gtest_main.cc' | 
|  189 ) |  246 ) | 
|  190  |  247  | 
|  191 GTEST_DIR = join_paths('third_party', 'googletest', 'googletest') |  248 if not android_target | 
|  192 GTEST_PARAMS = [] |  249    GTEST_DIR = join_paths('third_party', 'googletest', 'googletest') | 
|  193 LINK_PARAMS = [] |  250    GTEST_PARAMS = [] | 
|  194 compiler = meson.get_compiler('cpp') |  251    LINK_PARAMS = [] | 
|  195 if compiler.has_argument('-pthread') |  252    compiler = meson.get_compiler('cpp') | 
|  196   GTEST_PARAMS += '-pthread' |  253    if compiler.has_argument('-pthread') | 
|  197   LINK_PARAMS += '-lpthread' |  254       GTEST_PARAMS += '-pthread' | 
|  198 endif |  255       LINK_PARAMS += '-lpthread' | 
|  199  |  256    endif | 
|  200 gtest = static_library('gtest', |  257  | 
|  201                        files(join_paths(GTEST_DIR, 'src', 'gtest-all.cc')), |  258    gtest = static_library('gtest', | 
|  202                        include_directories: [ |  259                           files(join_paths(GTEST_DIR, 'src', 'gtest-all.cc')), | 
|  203                            include_directories(join_paths(GTEST_DIR, 'include'),
      is_system: true), |  260                           include_directories: [ | 
|  204                            include_directories(GTEST_DIR) |  261                              include_directories(join_paths(GTEST_DIR, 'include'
     ), is_system: true), | 
|  205                        ], |  262                              include_directories(GTEST_DIR) | 
|  206                        cpp_args: GTEST_PARAMS) |  263                           ], | 
|  207  |  264                           cpp_args: GTEST_PARAMS) | 
|  208 tests = executable('tests', test_sources, |  265  | 
|  209                    link_with: [adblockplus, gtest], |  266    tests = executable('tests', test_sources, | 
|  210                    link_args: LINK_PARAMS, |  267                       link_with: [adblockplus, gtest], | 
|  211                    include_directories: [ |  268                       link_args: LINK_PARAMS, | 
|  212                        incdir, |  269                       include_directories: [ | 
|  213                        include_directories(join_paths(GTEST_DIR, 'include')) |  270                          incdir, | 
|  214                    ]) |  271                          include_directories(join_paths(GTEST_DIR, 'include')) | 
|  215  |  272                       ]) | 
|  216 # Adjust the timeout to run the test. Default value is 30sec. |  273  | 
|  217 # |  274    # Adjust the timeout to run the test. Default value is 30sec. | 
|  218 test('tests', tests, timeout: 60) |  275    # | 
 |  276    test('tests', tests, timeout: 60) | 
 |  277 endif | 
| LEFT | RIGHT |