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

Delta Between Two Patch Sets: meson.build

Issue 29587914: Issue 5142 - Convert Element Hiding to C++ (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Created Oct. 25, 2017, 1:07 a.m.
Right Patch Set: mFiltersByDomain is now an OwnedStringMap Created Jan. 26, 2018, 8:41 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/elemHide.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', 'cpp', license: ['GPL3']) 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 18 matching lines...) Expand all
65 'compiled/filter/ElemHideException.cpp', 80 'compiled/filter/ElemHideException.cpp',
66 'compiled/filter/ElemHideFilter.cpp', 81 'compiled/filter/ElemHideFilter.cpp',
67 'compiled/filter/Filter.cpp', 82 'compiled/filter/Filter.cpp',
68 'compiled/filter/InvalidFilter.cpp', 83 'compiled/filter/InvalidFilter.cpp',
69 'compiled/filter/RegExpFilter.cpp', 84 'compiled/filter/RegExpFilter.cpp',
70 'compiled/filter/WhitelistFilter.cpp', 85 'compiled/filter/WhitelistFilter.cpp',
71 'compiled/storage/FilterStorage.cpp', 86 'compiled/storage/FilterStorage.cpp',
72 'compiled/subscription/DownloadableSubscription.cpp', 87 'compiled/subscription/DownloadableSubscription.cpp',
73 'compiled/subscription/Subscription.cpp', 88 'compiled/subscription/Subscription.cpp',
74 'compiled/subscription/UserDefinedSubscription.cpp', 89 'compiled/subscription/UserDefinedSubscription.cpp',
75 'compiled/ElemHide.cpp', 90 'compiled/ElemHide.cpp',
hub 2017/10/25 01:19:38 I'm based on top of the meson build system patch.
76 ] 91 ]
77 # sources specific to core 92 # sources specific to core
78 core_sources = [ 93 core_sources = [
79 'compiled/traceInit.cpp', 94 'compiled/traceInit.cpp',
80 ] 95 ]
81 # sources for the bindings generator 96 # sources for the bindings generator
82 bindings_sources = [ 97 bindings_sources = [
83 'compiled/bindings/generator.cpp', 98 'compiled/bindings/generator.cpp',
84 'compiled/bindings/main.cpp', 99 'compiled/bindings/main.cpp',
85 ] 100 ]
101 # native sources
102 native_sources = [
103 'compiled/library.cpp',
104 'compiled/Utils.cpp',
105 ]
86 106
87 defines_args = [] 107 defines_args = []
88 foreach define : DEFINES 108 foreach define : DEFINES
89 defines_args += '-D' + define 109 defines_args += '-D' + define
90 endforeach 110 endforeach
91 111
92 generation_args = [] 112 generation_args = []
93 foreach param : GENERATION_PARAMS 113 foreach param : GENERATION_PARAMS
94 generation_args += '-s' 114 generation_args += '-s'
95 generation_args += param[0] + '=' + '@0@'.format(param[1]) 115 generation_args += param[0] + '=' + '@0@'.format(param[1])
96 endforeach 116 endforeach
97 117
98 optional_args = [] 118 optional_args = []
99 buildtype = get_option('buildtype') 119 buildtype = get_option('buildtype')
100 if buildtype.startswith('debug') 120 if buildtype.startswith('debug')
121 optional_args += '-DDEBUG'
101 optional_args += '-g3' 122 optional_args += '-g3'
123 if target_type == 'native'
124 ADDITIONAL_PARAMS += [ '-fsanitize=address' ]
125 LINK_PARAMS = [ '-fsanitize=address' ]
126 endif
102 endif 127 endif
103 tracing = get_option('tracing') 128 tracing = get_option('tracing')
104 if tracing 129 if tracing
105 optional_args += '--tracing' 130 optional_args += '--tracing'
106 endif 131 endif
107 132
108 compiler_args = defines_args + generation_args + optional_args + ADDITIONAL_PARA MS 133 compiler_args = defines_args + generation_args + ADDITIONAL_PARAMS
109 134
110 # build objects. 135 if target_type == 'js'
111 core_objects = [] 136 # build objects.
112 bindings_objects = [] 137 core_objects = []
113 shared_objects = [] 138 bindings_objects = []
114 foreach group : ['core', 'bindings', 'shared'] 139 shared_objects = []
115 objects = [] 140 foreach group : ['core', 'bindings', 'shared']
116 foreach source_file : get_variable(group + '_sources') 141 objects = []
117 output_file = source_file.underscorify() + '.o' 142 foreach source_file : get_variable(group + '_sources')
118 command = [ emcc, '-MD', '-MF', '@DEPFILE@', '-c', '-o', '@OUTPUT@', 143 output_file = source_file.underscorify() + '.o'
119 '@INPUT@' ] + compiler_args 144 command = [ emcc, '-MD', '-MF', '@DEPFILE@', '-c', '-o', '@OUTPUT@',
120 if group != 'bindings' 145 '@INPUT@' ] + compiler_args
121 command += CORE_PARAMS + optional_args 146 if group != 'bindings'
122 endif 147 command += CORE_PARAMS + optional_args
123 objects += custom_target(output_file, 148 endif
124 input: files(source_file), 149 objects += custom_target(output_file,
125 output: output_file, 150 input: files(source_file),
126 depfile: output_file + '.deps', 151 output: output_file,
127 command: command) 152 depfile: output_file + '.deps',
153 command: command)
154 endforeach
155 # Ideally, we would call set_variable() here but that doesn't work
156 # with arrays (see
157 # https://github.com/mesonbuild/meson/issues/1481). So we have to
158 # do this shifting dance instead.
159 core_objects = bindings_objects
160 bindings_objects = shared_objects
161 shared_objects = objects
128 endforeach 162 endforeach
129 # Ideally, we would call set_variable() here but that doesn't work with arrays 163
130 # (see https://github.com/mesonbuild/meson/issues/1481). So we have to do this 164 # link the binding generator
131 # shifting dance instead. 165 bindings_generator = custom_target(BINDINGS_GENERATOR,
132 core_objects = bindings_objects 166 input: bindings_objects + shared_objects,
133 bindings_objects = shared_objects 167 output: BINDINGS_GENERATOR,
134 shared_objects = objects 168 depend_files: [ JS_LIBRARY, BINDINGS_JS_LIB RARY ],
135 endforeach 169 command: [
136 170 emcc, '-o', '@OUTPUT@',
137 # link the binding generator 171 '--js-library', JS_LIBRARY,
138 bindings_generator = custom_target(BINDINGS_GENERATOR, 172 '--js-library', BINDINGS_JS_LIBRARY,
139 input: bindings_objects + shared_objects, 173 '@INPUT@'
140 output: BINDINGS_GENERATOR, 174 ])
141 depend_files: [ JS_LIBRARY, BINDINGS_JS_LIBRA RY ], 175 # run the binding generator
142 command: [ 176 bindings_output = custom_target(BINDINGS_OUTPUT,
143 emcc, '-o', '@OUTPUT@', 177 input: bindings_generator,
144 '--js-library', JS_LIBRARY, 178 output: BINDINGS_OUTPUT,
145 '--js-library', BINDINGS_JS_LIBRARY, 179 capture: true,
146 '@INPUT@' 180 command: [nodejs, '@INPUT@'])
147 ]) 181 # link the core
148 # run the binding generator 182 output_file = join_paths(meson.source_root(), 'lib', COMPILER_OUTPUT)
149 bindings_output = custom_target(BINDINGS_OUTPUT, 183 compiler_output = custom_target(COMPILER_OUTPUT,
150 input: bindings_generator, 184 build_by_default: true,
151 output: BINDINGS_OUTPUT, 185 input: core_objects + shared_objects,
152 capture: true, 186 output: COMPILER_OUTPUT,
153 command: [nodejs, '@INPUT@']) 187 depend_files: [ JS_LIBRARY ],
154 188 command: [
155 # link the core 189 emcc, '-o', output_file,
156 output_file = join_paths(meson.source_root(), 'lib', COMPILER_OUTPUT) 190 '--post-js', bindings_output,
157 compiler_output = custom_target(COMPILER_OUTPUT, 191 '--js-library', JS_LIBRARY,
158 build_by_default: true, 192 '@INPUT@'
159 input: core_objects + shared_objects, 193 ] + compiler_args + optional_args)
160 output: COMPILER_OUTPUT, 194 else
161 depend_files: [ JS_LIBRARY ], 195 adblockpluscore = library('adblockpluscore', shared_sources,
162 command: [ 196 native_sources,
163 emcc, '-o', output_file, 197 cpp_args: ADDITIONAL_PARAMS + CORE_PARAMS,
164 '--post-js', bindings_output, 198 link_args: LINK_PARAMS)
165 '--js-library', JS_LIBRARY, 199 endif
166 '@INPUT@' 200
167 ] + compiler_args + optional_args)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld