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

Side by Side Diff: meson.build

Issue 29527808: Noissue - Use meson to build the C++ code (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Last bits of feedback Created Oct. 13, 2017, 6:24 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« README.md ('K') | « README.md ('k') | meson_options.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 project('adblockpluscore', 'cpp', license: ['GPL3'])
sergei 2017/10/16 15:27:13 I wonder how we plan to use it in the derived proj
2
3 # locate emscripten-config
4 python = import('python3').find_python()
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)
7 if command.returncode() != 0
8 error(command.stderr().strip())
9 endif
10 emscripten_config = command.stdout().strip()
11 message('Emscripten config file: ' + emscripten_config)
12
13 # locate emcc
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
16 error(command.stderr().strip())
17 endif
18 emcc = join_paths(command.stdout().strip(), 'emcc')
19 emcc = find_program(emcc)
20
21 # locate node
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
24 error(command.stderr().strip())
25 endif
26 nodejs = find_program(command.stdout().strip(), 'node', 'nodejs')
27
28 JS_LIBRARY = files(join_paths('compiled', 'library.js'))
29 BINDINGS_JS_LIBRARY = files(join_paths('compiled', 'bindings', 'library.js'))
30 BINDINGS_GENERATOR = 'bindings.cpp.js'
31 BINDINGS_OUTPUT = 'bindings.js'
32 COMPILER_OUTPUT = 'compiled.js'
33 # params for emcc compilation
34 ADDITIONAL_PARAMS = [ '-O3', '-m32', '-std=c++1z', '--memory-init-file', '0',
35 '--emit-symbol-map', '-Wall', '-Werror',
36 '-fno-rtti' ]
37 # additional params just for core
38 CORE_PARAMS = [ '-fno-exceptions' ]
39
40 DEFINES = []
41 GENERATION_PARAMS = [
42 ['SHELL_FILE', '"' +
43 join_paths(meson.source_root(), 'compiled', 'shell.js') +
44 '"'],
45 ['ASM_JS', '2'], # "almost asm"
46 ['TOTAL_MEMORY', 16*1024*1024],
47 ['TOTAL_STACK', 1*1024*1024],
48 ['ALLOW_MEMORY_GROWTH', 1],
49 ['NO_EXIT_RUNTIME', 1],
50 ['NO_DYNAMIC_EXECUTION', 1],
51 ['NO_FILESYSTEM', 1],
52 ['INVOKE_RUN', 0],
53 ['TEXTDECODER', 0],
54 ['EXPORTED_RUNTIME_METHODS', '["cwrap", "ccall", "stringToAscii"]']
55 ]
56
57
58 shared_sources = [
59 'compiled/bindings/runtime_utils.cpp',
60 'compiled/filter/ActiveFilter.cpp',
61 'compiled/filter/BlockingFilter.cpp',
62 'compiled/filter/CommentFilter.cpp',
63 'compiled/filter/ElemHideBase.cpp',
64 'compiled/filter/ElemHideEmulationFilter.cpp',
65 'compiled/filter/ElemHideException.cpp',
66 'compiled/filter/ElemHideFilter.cpp',
67 'compiled/filter/Filter.cpp',
68 'compiled/filter/InvalidFilter.cpp',
69 'compiled/filter/RegExpFilter.cpp',
70 'compiled/filter/WhitelistFilter.cpp',
71 'compiled/storage/FilterStorage.cpp',
72 'compiled/subscription/DownloadableSubscription.cpp',
73 'compiled/subscription/Subscription.cpp',
74 'compiled/subscription/UserDefinedSubscription.cpp',
75 ]
76 # sources specific to core
77 core_sources = [
78 'compiled/traceInit.cpp',
79 ]
80 # sources for the bindings generator
81 bindings_sources = [
82 'compiled/bindings/generator.cpp',
83 'compiled/bindings/main.cpp',
84 ]
85
86 defines_args = []
87 foreach define : DEFINES
sergei 2017/10/16 15:27:12 DEFINES is empty, it seems a good idea to keep it,
88 defines_args += '-D' + define
89 endforeach
90
91 generation_args = []
92 foreach param : GENERATION_PARAMS
93 generation_args += '-s'
94 generation_args += param[0] + '=' + '@0@'.format(param[1])
95 endforeach
96
97 optional_args = []
98 buildtype = get_option('buildtype')
99 if buildtype.startswith('debug')
100 optional_args += '-g3'
sergei 2017/10/16 15:27:13 We need to check why -g3 is added twice.
101 endif
102 tracing = get_option('tracing')
103 if tracing
104 optional_args += '--tracing'
105 endif
106
107 compiler_args = defines_args + generation_args + optional_args + ADDITIONAL_PARA MS
sergei 2017/10/16 15:27:12 optional_args are included two times, the second t
hub 2017/10/26 16:15:27 good catch.
108
109 # build objects.
110 core_objects = []
111 bindings_objects = []
112 shared_objects = []
113 foreach group : ['core', 'bindings', 'shared']
114 objects = []
115 foreach source_file : get_variable(group + '_sources')
116 output_file = source_file.underscorify() + '.o'
117 command = [ emcc, '-MD', '-MF', '@DEPFILE@', '-c', '-o', '@OUTPUT@',
118 '@INPUT@' ] + compiler_args
119 if group != 'bindings'
120 command += CORE_PARAMS + optional_args
121 endif
122 objects += custom_target(output_file,
123 input: files(source_file),
124 output: output_file,
125 depfile: output_file + '.deps',
126 command: command)
127 endforeach
128 # Ideally, we would call set_variable() here but that doesn't work with arrays
129 # (see https://github.com/mesonbuild/meson/issues/1481). So we have to do this
130 # shifting dance instead.
131 core_objects = bindings_objects
132 bindings_objects = shared_objects
133 shared_objects = objects
134 endforeach
135
136 # link the binding generator
137 bindings_generator = custom_target(BINDINGS_GENERATOR,
138 input: bindings_objects + shared_objects,
139 output: BINDINGS_GENERATOR,
140 depend_files: [ JS_LIBRARY, BINDINGS_JS_LIBRA RY ],
141 command: [
142 emcc, '-o', '@OUTPUT@',
143 '--js-library', JS_LIBRARY,
144 '--js-library', BINDINGS_JS_LIBRARY,
145 '@INPUT@'
146 ])
147 # run the binding generator
148 bindings_output = custom_target(BINDINGS_OUTPUT,
149 input: bindings_generator,
150 output: BINDINGS_OUTPUT,
151 capture: true,
152 command: [nodejs, '@INPUT@'])
153
154 # link the core
155 output_file = join_paths(meson.source_root(), 'lib', COMPILER_OUTPUT)
sergei 2017/10/16 15:27:12 On 2017/10/11 10:00:47, Wladimir Palant wrote: htt
156 compiler_output = custom_target(COMPILER_OUTPUT,
157 build_by_default: true,
158 input: core_objects + shared_objects,
159 output: COMPILER_OUTPUT,
160 depend_files: [ JS_LIBRARY ],
161 command: [
162 emcc, '-o', output_file,
163 '--post-js', bindings_output,
164 '--js-library', JS_LIBRARY,
165 '@INPUT@'
166 ] + compiler_args + optional_args)
OLDNEW
« README.md ('K') | « README.md ('k') | meson_options.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld