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

Delta Between Two Patch Sets: meson.build

Issue 29527808: Noissue - Use meson to build the C++ code (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Now build objects one by one, with dependencies, and share them. Created Oct. 12, 2017, 6:11 p.m.
Right Patch Set: Removed compile. meson > 0.40.0 Created Dec. 15, 2017, 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 | « compile ('k') | meson_options.txt » ('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', license: ['GPL3'], meson_version: '>0.40.0')
2 2
3 # locate emscripten-config 3 # locate emscripten-config
4 python = import('python3').find_python() 4 python = import('python3').find_python()
5 emscripten_config = get_option('emscripten-config') 5 emscripten_config = get_option('emscripten-config')
6 command = run_command(python, '-c', 'import os.path, sys;print(os.path.expanduse r(sys.argv[1]))', emscripten_config) 6 command = run_command(python, '-c', 'import os.path, sys;print(os.path.expanduse r(sys.argv[1]))', emscripten_config)
7 if command.returncode() != 0 7 if command.returncode() != 0
8 error(command.stderr().strip()) 8 error(command.stderr().strip())
9 endif 9 endif
10 emscripten_config = command.stdout().strip() 10 emscripten_config = command.stdout().strip()
11 message('Emscripten config file: ' + emscripten_config) 11 message('Emscripten config file: ' + emscripten_config)
12 12
13 # locate emcc 13 # locate emcc
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 sys;exec(open(sys.argv[1]).read());p rint(EMSCRIPTEN_ROOT)', 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 emcc = join_paths(command.stdout().strip(), 'emcc')
19 emcc = find_program(emcc) 19 emcc = find_program(emcc)
20 20
21 # locate node 21 # locate node
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());p rint(NODE_JS)', 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 nodejs = find_program(command.stdout().strip(), 'node', 'nodejs')
27 27
28 JS_LIBRARY = files(join_paths('compiled', 'library.js')) 28 JS_LIBRARY = files(join_paths('compiled', 'library.js'))
29 BINDINGS_JS_LIBRARY = files(join_paths('compiled', 'bindings', 'library.js'))
29 BINDINGS_GENERATOR = 'bindings.cpp.js' 30 BINDINGS_GENERATOR = 'bindings.cpp.js'
30 BINDINGS_OUTPUT = 'bindings.js' 31 BINDINGS_OUTPUT = 'bindings.js'
31 COMPILER_OUTPUT = 'compiled.js' 32 COMPILER_OUTPUT = 'compiled.js'
32 # params for emcc compilation 33 # params for emcc compilation
33 ADDITIONAL_PARAMS = [ '-O3', '-m32', '-std=c++1z', '--memory-init-file', '0', 34 ADDITIONAL_PARAMS = [ '-O3', '-m32', '-std=c++1z', '--memory-init-file', '0',
34 '--emit-symbol-map', '-Wall', '-Werror', 35 '--emit-symbol-map', '-Wall', '-Werror',
35 '-fno-rtti', '--js-library', JS_LIBRARY ] 36 '-fno-rtti' ]
36 # additional params just for core 37 # additional params just for core
37 CORE_PARAMS = [ '-fno-exceptions' ] 38 CORE_PARAMS = [ '-fno-exceptions' ]
38 39
39 DEFINES = [] 40 DEFINES = []
40 GENERATION_PARAMS = [ 41 GENERATION_PARAMS = [
41 ['SHELL_FILE', '"' + 42 ['SHELL_FILE', '"' +
42 join_paths(meson.source_root(), 'compiled', 'shell.js') + 43 join_paths(meson.source_root(), 'compiled', 'shell.js') +
43 '"'], 44 '"'],
44 ['ASM_JS', '2'], # "almost asm" 45 ['ASM_JS', '2'], # "almost asm"
45 ['TOTAL_MEMORY', 16*1024*1024], 46 ['TOTAL_MEMORY', 16*1024*1024],
(...skipping 20 matching lines...) Expand all
66 'compiled/filter/Filter.cpp', 67 'compiled/filter/Filter.cpp',
67 'compiled/filter/InvalidFilter.cpp', 68 'compiled/filter/InvalidFilter.cpp',
68 'compiled/filter/RegExpFilter.cpp', 69 'compiled/filter/RegExpFilter.cpp',
69 'compiled/filter/WhitelistFilter.cpp', 70 'compiled/filter/WhitelistFilter.cpp',
70 'compiled/storage/FilterStorage.cpp', 71 'compiled/storage/FilterStorage.cpp',
71 'compiled/subscription/DownloadableSubscription.cpp', 72 'compiled/subscription/DownloadableSubscription.cpp',
72 'compiled/subscription/Subscription.cpp', 73 'compiled/subscription/Subscription.cpp',
73 'compiled/subscription/UserDefinedSubscription.cpp', 74 'compiled/subscription/UserDefinedSubscription.cpp',
74 ] 75 ]
75 # sources specific to core 76 # sources specific to core
76 core_sources = [ 'compiled/traceInit.cpp' ] 77 core_sources = [
Wladimir Palant 2017/10/13 09:45:40 Nit: I'd list the file name here on a separate lin
hub 2017/10/13 18:16:52 Done.
78 'compiled/traceInit.cpp',
79 ]
77 # sources for the bindings generator 80 # sources for the bindings generator
78 bindings_sources = [ 81 bindings_sources = [
79 'compiled/bindings/generator.cpp', 82 'compiled/bindings/generator.cpp',
80 'compiled/bindings/main.cpp', 83 'compiled/bindings/main.cpp',
81 ] 84 ]
82 85
83 defines_args = [] 86 defines_args = []
84 foreach define : DEFINES 87 foreach define : DEFINES
85 defines_args += '-D' + define 88 defines_args += '-D' + define
86 endforeach 89 endforeach
87 90
88 generation_args = [] 91 generation_args = []
89 foreach param : GENERATION_PARAMS 92 foreach param : GENERATION_PARAMS
90 generation_args += '-s' 93 generation_args += '-s'
91 generation_args += param[0] + '=' + '@0@'.format(param[1]) 94 generation_args += param[0] + '=' + '@0@'.format(param[1])
92 endforeach 95 endforeach
93 96
94 optional_args = [] 97 optional_args = []
95 debug = get_option('buildtype') 98 buildtype = get_option('buildtype')
Wladimir Palant 2017/10/13 09:45:39 Nit: This variable should be named buildtype or mo
hub 2017/10/13 18:16:52 Done.
96 if debug.startswith('debug') 99 if buildtype.startswith('debug')
100 optional_args += '-DDEBUG'
97 optional_args += '-g3' 101 optional_args += '-g3'
98 endif 102 endif
99 tracing = get_option('tracing') 103 tracing = get_option('tracing')
100 if tracing 104 if tracing
101 optional_args += '--tracing' 105 optional_args += '--tracing'
102 endif 106 endif
103 107
104 compiler_args = defines_args + generation_args + optional_args + ADDITIONAL_PARA MS 108 compiler_args = defines_args + generation_args + ADDITIONAL_PARAMS
105 109
106 # build objects. 110 # build objects.
107 core_objects = [] 111 core_objects = []
108 bindings_objects = [] 112 bindings_objects = []
109 shared_objects = [] 113 shared_objects = []
110 foreach group : ['core', 'bindings', 'shared'] 114 foreach group : ['core', 'bindings', 'shared']
111 objects = [] 115 objects = []
112 foreach source_file : get_variable(group + '_sources') 116 foreach source_file : get_variable(group + '_sources')
113 output_file = source_file.underscorify() + '.o' 117 output_file = source_file.underscorify() + '.o'
114 command = [ emcc, '-MD', '-MF', '@DEPFILE@', '-c', '-o', '@OUTPUT@', 118 command = [ emcc, '-MD', '-MF', '@DEPFILE@', '-c', '-o', '@OUTPUT@',
115 '@INPUT@' ] + compiler_args 119 '@INPUT@' ] + compiler_args
116 if group != 'bindings' 120 if group != 'bindings'
117 command += CORE_PARAMS 121 command += CORE_PARAMS + optional_args
Wladimir Palant 2017/10/13 09:45:39 I think we should add optional args only here and
118 endif 122 endif
119 objects += custom_target(output_file, 123 objects += custom_target(output_file,
120 input: files(source_file), 124 input: files(source_file),
121 output: output_file, 125 output: output_file,
122 depfile: output_file + '.deps', 126 depfile: output_file + '.deps',
123 command: command) 127 command: command)
124 endforeach 128 endforeach
125 # Ideally, we would call set_variable() here but that doesn't work with arrays 129 # Ideally, we would call set_variable() here but that doesn't work with arrays
126 # (see https://github.com/mesonbuild/meson/issues/1481). So we have to do this 130 # (see https://github.com/mesonbuild/meson/issues/1481). So we have to do this
127 # shifting dance instead. 131 # shifting dance instead.
128 core_objects = bindings_objects 132 core_objects = bindings_objects
129 bindings_objects = shared_objects 133 bindings_objects = shared_objects
130 shared_objects = objects 134 shared_objects = objects
131 endforeach 135 endforeach
132 136
133 # link the binding generator 137 # link the binding generator
134 bindings_generator = custom_target('bindings-generator', 138 bindings_generator = custom_target(BINDINGS_GENERATOR,
135 input: bindings_objects + shared_objects, 139 input: bindings_objects + shared_objects,
136 output: BINDINGS_GENERATOR, 140 output: BINDINGS_GENERATOR,
141 depend_files: [ JS_LIBRARY, BINDINGS_JS_LIBRA RY ],
137 command: [ 142 command: [
138 emcc, '-o', '@OUTPUT@', 143 emcc, '-o', '@OUTPUT@',
139 '--js-library', 144 '--js-library', JS_LIBRARY,
140 JS_LIBRARY, 145 '--js-library', BINDINGS_JS_LIBRARY,
141 '--js-library',
142 files('compiled/bindings/library.js'),
Wladimir Palant 2017/10/13 09:45:39 Does this detect compiled/bindings/library.js as a
hub 2017/10/13 18:16:52 I wasn't sure, but it actually does. I checked.
143 '@INPUT@' 146 '@INPUT@'
144 ]) 147 ])
145 # run the binding generator 148 # run the binding generator
146 bindings_output = custom_target('bindings-output', 149 bindings_output = custom_target(BINDINGS_OUTPUT,
Wladimir Palant 2017/10/13 09:45:39 Nit: Use BINDINGS_OUTPUT for target name?
hub 2017/10/13 18:16:52 Done.
147 input: bindings_generator, 150 input: bindings_generator,
148 output: BINDINGS_OUTPUT, 151 output: BINDINGS_OUTPUT,
149 capture: true, 152 capture: true,
150 command: [nodejs, '@INPUT@']) 153 command: [nodejs, '@INPUT@'])
151 154
152 # link the core 155 # link the core
153 output_file = join_paths(meson.source_root(), 'lib', COMPILER_OUTPUT) 156 output_file = join_paths(meson.source_root(), 'lib', COMPILER_OUTPUT)
154 compiler_output = custom_target('compiled.js', 157 compiler_output = custom_target(COMPILER_OUTPUT,
Wladimir Palant 2017/10/13 09:45:40 Nit: Use COMPILER_OUTPUT for target name?
hub 2017/10/13 18:16:52 Done.
155 build_by_default: true, 158 build_by_default: true,
156 input: core_objects + shared_objects, 159 input: core_objects + shared_objects,
157 output: COMPILER_OUTPUT, 160 output: COMPILER_OUTPUT,
161 depend_files: [ JS_LIBRARY ],
158 command: [ 162 command: [
159 emcc, '-o', output_file, 163 emcc, '-o', output_file,
160 '--post-js', bindings_output, 164 '--post-js', bindings_output,
165 '--js-library', JS_LIBRARY,
161 '@INPUT@' 166 '@INPUT@'
162 ] + compiler_args) 167 ] + compiler_args + optional_args)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld