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

Delta Between Two Patch Sets: meson.build

Issue 29594607: Issue 5143 - Convert ElemHideEmulation to C++ (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Created Nov. 1, 2017, 2:42 p.m.
Right Patch Set: Review comments addressed Created Jan. 30, 2018, 5:37 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/elemHideEmulation.js ('k') | test/elemHideEmulation.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 project('adblockpluscore', license: ['GPL3'], meson_version: '>0.40.0') 1 project('adblockpluscore', 'cpp', license: ['GPL3'], meson_version: '>0.40.0')
2 2
3 # locate emscripten-config 3 native = get_option('native')
4 python = import('python3').find_python() 4 if native
5 emscripten_config = get_option('emscripten-config') 5 target_type='native'
6 command = run_command(python, '-c', 'import os.path, sys;print(os.path.expanduse r(sys.argv[1]))', emscripten_config) 6 else
7 if command.returncode() != 0 7 target_type='js'
8 error(command.stderr().strip()) 8 endif
9 endif 9
10 emscripten_config = command.stdout().strip() 10 if target_type == 'js'
11 message('Emscripten config file: ' + emscripten_config) 11 # locate emscripten-config
12 12 python = import('python3').find_python()
13 # locate emcc 13 emscripten_config = get_option('emscripten-config')
14 command = run_command(python, '-c', 'import sys;exec(open(sys.argv[1]).read());p rint(EMSCRIPTEN_ROOT)', emscripten_config) 14 command = run_command(python, '-c', 'import os.path, sys;print(os.path.expandu ser(sys.argv[1]))', emscripten_config)
15 if command.returncode() != 0 15 if command.returncode() != 0
16 error(command.stderr().strip()) 16 error(command.stderr().strip())
17 endif 17 endif
18 emcc = join_paths(command.stdout().strip(), 'emcc') 18 emscripten_config = command.stdout().strip()
19 emcc = find_program(emcc) 19 message('Emscripten config file: ' + emscripten_config)
20 20
21 # locate node 21 # locate emcc
22 command = run_command(python, '-c', 'import sys;exec(open(sys.argv[1]).read());p rint(NODE_JS)', emscripten_config) 22 command = run_command(python, '-c', 'import sys;exec(open(sys.argv[1]).read()) ;print(EMSCRIPTEN_ROOT)', emscripten_config)
23 if command.returncode() != 0 23 if command.returncode() != 0
24 error(command.stderr().strip()) 24 error(command.stderr().strip())
25 endif 25 endif
26 nodejs = find_program(command.stdout().strip(), 'node', 'nodejs') 26 emcc = join_paths(command.stdout().strip(), 'emcc')
27 emcc = find_program(emcc)
28
29 # locate node
30 command = run_command(python, '-c', 'import sys;exec(open(sys.argv[1]).read()) ;print(NODE_JS)', emscripten_config)
31 if command.returncode() != 0
32 error(command.stderr().strip())
33 endif
34 nodejs = find_program(command.stdout().strip(), 'node', 'nodejs')
35 endif
27 36
28 JS_LIBRARY = files(join_paths('compiled', 'library.js')) 37 JS_LIBRARY = files(join_paths('compiled', 'library.js'))
29 BINDINGS_JS_LIBRARY = files(join_paths('compiled', 'bindings', 'library.js')) 38 BINDINGS_JS_LIBRARY = files(join_paths('compiled', 'bindings', 'library.js'))
30 BINDINGS_GENERATOR = 'bindings.cpp.js' 39 BINDINGS_GENERATOR = 'bindings.cpp.js'
31 BINDINGS_OUTPUT = 'bindings.js' 40 BINDINGS_OUTPUT = 'bindings.js'
32 COMPILER_OUTPUT = 'compiled.js' 41 COMPILER_OUTPUT = 'compiled.js'
33 # params for emcc compilation 42 # params for emcc compilation
34 ADDITIONAL_PARAMS = [ '-O3', '-m32', '-std=c++1z', '--memory-init-file', '0', 43 ADDITIONAL_PARAMS = [ '-O3', '-std=c++1z', '-Wall', '-Werror',
35 '--emit-symbol-map', '-Wall', '-Werror',
36 '-fno-rtti' ] 44 '-fno-rtti' ]
45 if target_type == 'js'
46 # CXXFLAGS specific to emcc
47 ADDITIONAL_PARAMS += [ '-m32', '--memory-init-file', '0',
48 '--emit-symbol-map' ]
49 else
50 ADDITIONAL_PARAMS += [ '-fsanitize=address' ]
51 endif
37 # additional params just for core 52 # additional params just for core
38 CORE_PARAMS = [ '-fno-exceptions' ] 53 CORE_PARAMS = [ '-fno-exceptions' ]
39 54
40 DEFINES = [] 55 DEFINES = []
41 GENERATION_PARAMS = [ 56 GENERATION_PARAMS = [
42 ['SHELL_FILE', '"' + 57 ['SHELL_FILE', '"' +
43 join_paths(meson.source_root(), 'compiled', 'shell.js') + 58 join_paths(meson.source_root(), 'compiled', 'shell.js') +
44 '"'], 59 '"'],
45 ['ASM_JS', '2'], # "almost asm" 60 ['ASM_JS', '2'], # "almost asm"
46 ['TOTAL_MEMORY', 16*1024*1024], 61 ['TOTAL_MEMORY', 16*1024*1024],
(...skipping 30 matching lines...) Expand all
77 ] 92 ]
78 # sources specific to core 93 # sources specific to core
79 core_sources = [ 94 core_sources = [
80 'compiled/traceInit.cpp', 95 'compiled/traceInit.cpp',
81 ] 96 ]
82 # sources for the bindings generator 97 # sources for the bindings generator
83 bindings_sources = [ 98 bindings_sources = [
84 'compiled/bindings/generator.cpp', 99 'compiled/bindings/generator.cpp',
85 'compiled/bindings/main.cpp', 100 'compiled/bindings/main.cpp',
86 ] 101 ]
102 # native sources
103 native_sources = [
104 'compiled/library.cpp',
105 'compiled/Utils.cpp',
106 ]
87 107
88 defines_args = [] 108 defines_args = []
89 foreach define : DEFINES 109 foreach define : DEFINES
90 defines_args += '-D' + define 110 defines_args += '-D' + define
91 endforeach 111 endforeach
92 112
93 generation_args = [] 113 generation_args = []
94 foreach param : GENERATION_PARAMS 114 foreach param : GENERATION_PARAMS
95 generation_args += '-s' 115 generation_args += '-s'
96 generation_args += param[0] + '=' + '@0@'.format(param[1]) 116 generation_args += param[0] + '=' + '@0@'.format(param[1])
97 endforeach 117 endforeach
98 118
99 optional_args = [] 119 optional_args = []
100 buildtype = get_option('buildtype') 120 buildtype = get_option('buildtype')
101 if buildtype.startswith('debug') 121 if buildtype.startswith('debug')
122 optional_args += '-DDEBUG'
102 optional_args += '-g3' 123 optional_args += '-g3'
124 if target_type == 'native'
125 ADDITIONAL_PARAMS += [ '-fsanitize=address' ]
126 LINK_PARAMS = [ '-fsanitize=address' ]
127 endif
103 endif 128 endif
104 tracing = get_option('tracing') 129 tracing = get_option('tracing')
105 if tracing 130 if tracing
106 optional_args += '--tracing' 131 optional_args += '--tracing'
107 endif 132 endif
108 133
109 compiler_args = defines_args + generation_args + ADDITIONAL_PARAMS 134 compiler_args = defines_args + generation_args + ADDITIONAL_PARAMS
110 135
111 # build objects. 136 if target_type == 'js'
112 core_objects = [] 137 # build objects.
113 bindings_objects = [] 138 core_objects = []
114 shared_objects = [] 139 bindings_objects = []
115 foreach group : ['core', 'bindings', 'shared'] 140 shared_objects = []
116 objects = [] 141 foreach group : ['core', 'bindings', 'shared']
117 foreach source_file : get_variable(group + '_sources') 142 objects = []
118 output_file = source_file.underscorify() + '.o' 143 foreach source_file : get_variable(group + '_sources')
119 command = [ emcc, '-MD', '-MF', '@DEPFILE@', '-c', '-o', '@OUTPUT@', 144 output_file = source_file.underscorify() + '.o'
120 '@INPUT@' ] + compiler_args 145 command = [ emcc, '-MD', '-MF', '@DEPFILE@', '-c', '-o', '@OUTPUT@',
121 if group != 'bindings' 146 '@INPUT@' ] + compiler_args
122 command += CORE_PARAMS + optional_args 147 if group != 'bindings'
123 endif 148 command += CORE_PARAMS + optional_args
124 objects += custom_target(output_file, 149 endif
125 input: files(source_file), 150 objects += custom_target(output_file,
126 output: output_file, 151 input: files(source_file),
127 depfile: output_file + '.deps', 152 output: output_file,
128 command: command) 153 depfile: output_file + '.deps',
154 command: command)
155 endforeach
156 # Ideally, we would call set_variable() here but that doesn't work
157 # with arrays (see
158 # https://github.com/mesonbuild/meson/issues/1481). So we have to
159 # do this shifting dance instead.
160 core_objects = bindings_objects
161 bindings_objects = shared_objects
162 shared_objects = objects
129 endforeach 163 endforeach
130 # Ideally, we would call set_variable() here but that doesn't work with arrays 164
131 # (see https://github.com/mesonbuild/meson/issues/1481). So we have to do this 165 # link the binding generator
132 # shifting dance instead. 166 bindings_generator = custom_target(BINDINGS_GENERATOR,
133 core_objects = bindings_objects 167 input: bindings_objects + shared_objects,
134 bindings_objects = shared_objects 168 output: BINDINGS_GENERATOR,
135 shared_objects = objects 169 depend_files: [ JS_LIBRARY, BINDINGS_JS_LIB RARY ],
136 endforeach 170 command: [
137 171 emcc, '-o', '@OUTPUT@',
138 # link the binding generator 172 '--js-library', JS_LIBRARY,
139 bindings_generator = custom_target(BINDINGS_GENERATOR, 173 '--js-library', BINDINGS_JS_LIBRARY,
140 input: bindings_objects + shared_objects, 174 '@INPUT@'
141 output: BINDINGS_GENERATOR, 175 ])
142 depend_files: [ JS_LIBRARY, BINDINGS_JS_LIBRA RY ], 176 # run the binding generator
143 command: [ 177 bindings_output = custom_target(BINDINGS_OUTPUT,
144 emcc, '-o', '@OUTPUT@', 178 input: bindings_generator,
145 '--js-library', JS_LIBRARY, 179 output: BINDINGS_OUTPUT,
146 '--js-library', BINDINGS_JS_LIBRARY, 180 capture: true,
147 '@INPUT@' 181 command: [nodejs, '@INPUT@'])
148 ]) 182 # link the core
149 # run the binding generator 183 output_file = join_paths(meson.source_root(), 'lib', COMPILER_OUTPUT)
150 bindings_output = custom_target(BINDINGS_OUTPUT, 184 compiler_output = custom_target(COMPILER_OUTPUT,
151 input: bindings_generator, 185 build_by_default: true,
152 output: BINDINGS_OUTPUT, 186 input: core_objects + shared_objects,
153 capture: true, 187 output: COMPILER_OUTPUT,
154 command: [nodejs, '@INPUT@']) 188 depend_files: [ JS_LIBRARY ],
155 189 command: [
156 # link the core 190 emcc, '-o', output_file,
157 output_file = join_paths(meson.source_root(), 'lib', COMPILER_OUTPUT) 191 '--post-js', bindings_output,
158 compiler_output = custom_target(COMPILER_OUTPUT, 192 '--js-library', JS_LIBRARY,
159 build_by_default: true, 193 '@INPUT@'
160 input: core_objects + shared_objects, 194 ] + compiler_args + optional_args)
161 output: COMPILER_OUTPUT, 195 else
162 depend_files: [ JS_LIBRARY ], 196 GTEST_DIR = join_paths('third_party', 'googletest', 'googletest')
163 command: [ 197 GTEST_PARAMS = []
164 emcc, '-o', output_file, 198 compiler = meson.get_compiler('cpp')
165 '--post-js', bindings_output, 199 if compiler.has_argument('-pthread')
166 '--js-library', JS_LIBRARY, 200 GTEST_PARAMS += '-pthread'
167 '@INPUT@' 201 LINK_PARAMS += '-lpthread'
168 ] + compiler_args + optional_args) 202 endif
203
204 test_sources = [
205 'test/compiled/abptest.cpp',
206 'test/compiled/String.cpp',
207 'test/compiled/StringMap.cpp',
208 'test/compiled/RegExp.cpp',
209 ]
210
211 adblockpluscore = library('adblockpluscore', shared_sources,
212 native_sources,
213 cpp_args: ADDITIONAL_PARAMS + CORE_PARAMS,
214 link_args: LINK_PARAMS)
215 gtest = static_library('gtest', files(join_paths(GTEST_DIR, 'src', 'gtest-all. cc')),
216 include_directories: [
217 include_directories(join_paths(GTEST_DIR, 'include' ), is_system: true),
218 include_directories(GTEST_DIR)
219 ],
220 cpp_args: GTEST_PARAMS)
221 abptest = executable('abptest', test_sources,
222 cpp_args: ADDITIONAL_PARAMS + CORE_PARAMS,
223 include_directories: include_directories(join_paths(GTEST _DIR, 'include')),
224 link_args: LINK_PARAMS,
225 link_with: [ adblockpluscore, gtest ])
226 test('abptest', abptest)
227 endif
228
LEFTRIGHT

Powered by Google App Engine
This is Rietveld