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: Reworked. Now build source files one by one. Created Oct. 11, 2017, 6:22 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'])
Wladimir Palant 2017/10/11 21:01:23 I suspect that the build will now fail if no C++ c
sergei 2017/10/16 15:27:11 Yes, it fails if it cannot find any C++ compiler,
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_GENERATOR = 'bindings.cpp.js'
30 BINDINGS_OUTPUT = 'bindings.js'
31 COMPILER_OUTPUT = 'compiled.js'
32 # params for emcc compilation
33 ADDITIONAL_PARAMS = ['-O3', '-m32', '-std=c++1z', '--memory-init-file', '0',
34 '--emit-symbol-map', '-Wall', '-Werror', '-fno-exceptions',
35 '-fno-rtti', '--js-library', JS_LIBRARY]
36 DEFINES = []
37 GENERATION_PARAMS = [
38 ['SHELL_FILE', '"' +
39 join_paths(meson.source_root(), 'compiled', 'shell.js') +
40 '"'],
41 ['ASM_JS', '2'], # "almost asm"
42 ['TOTAL_MEMORY', 16*1024*1024],
43 ['TOTAL_STACK', 1*1024*1024],
44 ['ALLOW_MEMORY_GROWTH', 1],
45 ['NO_EXIT_RUNTIME', 1],
46 ['NO_DYNAMIC_EXECUTION', 1],
47 ['NO_FILESYSTEM', 1],
48 ['INVOKE_RUN', 0],
49 ['TEXTDECODER', 0],
50 ['EXPORTED_RUNTIME_METHODS', '["cwrap", "ccall", "stringToAscii"]']
51 ]
52
53 # We want these to be strings.
54 core_sources = [ 'compiled/traceInit.cpp' ]
55 sources = [
56 'compiled/bindings/runtime_utils.cpp',
57 'compiled/filter/ActiveFilter.cpp',
58 'compiled/filter/BlockingFilter.cpp',
59 'compiled/filter/CommentFilter.cpp',
60 'compiled/filter/ElemHideBase.cpp',
61 'compiled/filter/ElemHideEmulationFilter.cpp',
62 'compiled/filter/ElemHideException.cpp',
63 'compiled/filter/ElemHideFilter.cpp',
64 'compiled/filter/Filter.cpp',
65 'compiled/filter/InvalidFilter.cpp',
66 'compiled/filter/RegExpFilter.cpp',
67 'compiled/filter/WhitelistFilter.cpp',
68 'compiled/storage/FilterStorage.cpp',
69 'compiled/subscription/DownloadableSubscription.cpp',
70 'compiled/subscription/Subscription.cpp',
71 'compiled/subscription/UserDefinedSubscription.cpp',
72 ]
73
74
75 # bindings
76 bindings_sources = files(
77 'compiled/bindings/generator.cpp',
78 'compiled/bindings/main.cpp',
79 )
80
81 # convert the string list to a filesarray.
82 foreach source : sources
83 bindings_sources += files(source)
84 endforeach
85
86 bindings_generator = custom_target('bindings-generator',
87 input: bindings_sources,
88 output: BINDINGS_GENERATOR,
89 command: [
90 emcc, '-o', '@OUTPUT@',
91 '-std=c++1z', '--js-library',
92 JS_LIBRARY,
93 '--js-library',
94 files('compiled/bindings/library.js'),
95 '@INPUT@'
96 ])
97 bindings_output = custom_target('bindings-output',
98 input: bindings_generator,
99 output: BINDINGS_OUTPUT,
100 capture: true,
101 command: [nodejs, '@INPUT@'])
102
103
104 defines_args = []
105 foreach define : DEFINES
106 defines_args += '-D' + define
107 endforeach
108
109 generation_args = []
110 foreach param : GENERATION_PARAMS
111 generation_args += '-s'
112 generation_args += param[0] + '=' + '@0@'.format(param[1])
113 endforeach
114
115 optional_args = []
116 debug = get_option('buildtype')
117 if debug.startswith('debug')
118 optional_args += '-g3'
119 endif
120 tracing = get_option('tracing')
121 if tracing
122 optional_args += '--tracing'
123 endif
124
125 compiler_args = defines_args + generation_args + optional_args + ADDITIONAL_PARA MS
126
127 # build objects.
128 objects = []
129 all_sources = sources + core_sources
130 foreach source_file : all_sources
131 output_file = source_file.underscorify() + '.o'
Wladimir Palant 2017/10/12 08:46:09 Nit: You have three spaces indentation here.
hub 2017/10/12 18:12:11 Done.
132 objects += custom_target(output_file,
133 input: files(source_file),
134 output: output_file,
135 command: [
136 emcc, '-c', '-o', '@OUTPUT@', '@INPUT@'
137 ] + compiler_args)
Wladimir Palant 2017/10/11 21:01:23 I looked into dependencies generation and we need
Wladimir Palant 2017/10/12 08:46:09 Actually, I succeeded reusing objects between bind
hub 2017/10/12 18:12:11 Done.
hub 2017/10/12 18:12:11 Done.
138 endforeach
139
140 # link it all.
141 output_file = join_paths(meson.source_root(), 'lib', COMPILER_OUTPUT)
142 compiler_output = custom_target('compiled.js',
143 build_by_default: true,
144 input: objects,
145 output: COMPILER_OUTPUT,
146 command: [
147 emcc, '-o', output_file,
148 '--post-js', bindings_output,
149 '@INPUT@'
150 ] + compiler_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