1 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
2 # vim: set filetype=python:
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 # /!\ Use js_option() instead of option() in this file. /!\
8 # =========================================================
10 @depends(build_project, '--help')
11 def building_js(build_project, help):
12 return build_project == 'js'
14 # Exception to the rule above: JS_STANDALONE is a special option that doesn't
15 # want the js_option treatment. When we're done merging js/src/configure and
16 # top-level configure, it can go away, although the JS_STANDALONE config
17 # will still need to be set depending on building_js above.
18 option(env='JS_STANDALONE', default=building_js,
19 help='Reserved for internal use')
21 @depends('JS_STANDALONE')
22 def js_standalone(value):
25 set_config('JS_STANDALONE', js_standalone)
26 set_define('JS_STANDALONE', js_standalone)
27 add_old_configure_assignment('JS_STANDALONE', js_standalone)
28 js_option('--disable-js-shell', default=building_js,
29 help='Do not build the JS shell')
31 @depends('--disable-js-shell')
32 def js_disable_shell(value):
36 set_config('JS_DISABLE_SHELL', js_disable_shell)
38 set_define('JS_64BIT', depends(target)(lambda t: t.bitness == 64 or None))
40 set_define('JS_PUNBOX64', depends(target)(lambda t: t.bitness == 64 or None))
41 set_define('JS_NUNBOX32', depends(target)(lambda t: t.bitness == 32 or None))
44 # SpiderMonkey as a shared library, and how its symbols are exported
45 # ==================================================================
46 js_option('--disable-shared-js', default=building_js,
47 help='Do not create a shared library')
49 js_option('--disable-export-js', default=building_js,
50 help='Do not mark JS symbols as DLL exported/visible')
52 @depends('--disable-shared-js', '--disable-export-js')
53 def shared_js(shared_js, export_js):
56 die('Must export JS symbols when building a shared library.')
59 set_config('JS_SHARED_LIBRARY', shared_js)
60 add_old_configure_assignment('JS_SHARED_LIBRARY', shared_js)
62 @depends('--disable-shared-js', '--disable-export-js')
63 def exportable_js_api(shared_js, export_js):
64 if not shared_js and export_js:
67 set_define('STATIC_EXPORTABLE_JS_API', exportable_js_api)
69 @depends('--disable-shared-js', '--disable-export-js')
70 def static_js_api(shared_js, export_js):
71 if not shared_js and not export_js:
74 set_define('STATIC_JS_API', static_js_api)
76 @depends('--disable-shared-js')
81 set_define('MOZ_STATIC_JS', static_js)
83 @deprecated_option(env='DISABLE_SHARED_JS', nargs='?')
84 def disable_shared_js(value):
85 # DISABLE_SHARED_JS=1 gets us an empty PositiveOptionValue
86 if value and not len(value):
87 suggestion = '--disable-shared-js'
89 suggestion = '--enable-shared-js'
91 die('Setting %s is deprecated, use %s instead.',
92 value.format('DISABLE_SHARED_JS'), suggestion)
94 @deprecated_option(env='DISABLE_EXPORT_JS', nargs='?')
95 def disable_export_js(value):
96 # DISABLE_EXPORT_JS=1 gets us an empty PositiveOptionValue
97 if value and not len(value):
98 suggestion = '--disable-export-js'
100 suggestion = '--enable-export-js'
102 die('Setting %s is deprecated, use %s instead.',
103 value.format('DISABLE_EXPORT_JS'), suggestion)
107 # =======================================================
109 def ion_default(target):
110 if target.cpu in ('x86', 'x86_64', 'arm', 'aarch64', 'mips32', 'mips64'):
113 js_option('--enable-ion',
115 help='Enable use of the IonMonkey JIT')
117 set_config('ENABLE_ION', depends_if('--enable-ion')(lambda x: True))
119 # JIT code simulator for cross compiles
120 # =======================================================
121 js_option('--enable-simulator', choices=('arm', 'arm64', 'mips32', 'mips64'),
123 help='Enable a JIT code simulator for the specified architecture')
125 @depends('--enable-ion', '--enable-simulator', target)
126 def simulator(ion_enabled, simulator_enabled, target):
127 if not ion_enabled or not simulator_enabled:
130 sim_cpu = simulator_enabled[0]
132 if sim_cpu in ('arm', 'mips32'):
133 if target.cpu != 'x86':
134 die('The %s simulator only works on x86.' % sim_cpu)
136 if sim_cpu in ('arm64', 'mips64'):
137 if target.cpu != 'x86_64':
138 die('The %s simulator only works on x86-64.' % sim_cpu)
140 return namespace(**{sim_cpu: True})
142 set_config('JS_SIMULATOR', depends_if(simulator)(lambda x: True))
143 set_config('JS_SIMULATOR_ARM', simulator.arm)
144 set_config('JS_SIMULATOR_ARM64', simulator.arm64)
145 set_config('JS_SIMULATOR_MIPS32', simulator.mips32)
146 set_config('JS_SIMULATOR_MIPS64', simulator.mips64)
147 set_define('JS_SIMULATOR', depends_if(simulator)(lambda x: True))
148 set_define('JS_SIMULATOR_ARM', simulator.arm)
149 set_define('JS_SIMULATOR_ARM64', simulator.arm64)
150 set_define('JS_SIMULATOR_MIPS32', simulator.mips32)
151 set_define('JS_SIMULATOR_MIPS64', simulator.mips64)
153 @depends('--enable-ion', simulator, target)
154 def jit_codegen(ion_enabled, simulator, target):
156 return namespace(none=True)
161 if target.cpu == 'aarch64':
162 return namespace(arm64=True)
163 elif target.cpu == 'x86_64':
164 return namespace(x64=True)
166 return namespace(**{str(target.cpu): True})
168 set_config('JS_CODEGEN_NONE', jit_codegen.none)
169 set_config('JS_CODEGEN_ARM', jit_codegen.arm)
170 set_config('JS_CODEGEN_ARM64', jit_codegen.arm64)
171 set_config('JS_CODEGEN_MIPS32', jit_codegen.mips32)
172 set_config('JS_CODEGEN_MIPS64', jit_codegen.mips64)
173 set_config('JS_CODEGEN_X86', jit_codegen.x86)
174 set_config('JS_CODEGEN_X64', jit_codegen.x64)
175 set_define('JS_CODEGEN_NONE', jit_codegen.none)
176 set_define('JS_CODEGEN_ARM', jit_codegen.arm)
177 set_define('JS_CODEGEN_ARM64', jit_codegen.arm64)
178 set_define('JS_CODEGEN_MIPS32', jit_codegen.mips32)
179 set_define('JS_CODEGEN_MIPS64', jit_codegen.mips64)
180 set_define('JS_CODEGEN_X86', jit_codegen.x86)
181 set_define('JS_CODEGEN_X64', jit_codegen.x64)
183 @depends('--enable-ion', simulator, target, moz_debug)
184 def jit_disasm_arm(ion_enabled, simulator, target, debug):
188 if simulator and debug:
189 if getattr(simulator, 'arm', None):
192 if target.cpu == 'arm' and debug:
195 set_config('JS_DISASM_ARM', jit_disasm_arm)
196 set_define('JS_DISASM_ARM', jit_disasm_arm)
198 @depends('--enable-ion', simulator, target, moz_debug)
199 def jit_disasm_arm64(ion_enabled, simulator, target, debug):
203 if simulator and debug:
204 if getattr(simulator, 'arm64', None):
207 if target.cpu == 'aarch64' and debug:
210 set_config('JS_DISASM_ARM64', jit_disasm_arm64)
211 set_define('JS_DISASM_ARM64', jit_disasm_arm64)
214 # =======================================================
215 js_option('--enable-instruments', env='MOZ_INSTRUMENTS',
216 help='Enable instruments remote profiling')
218 @depends('--enable-instruments', target)
219 def instruments(value, target):
220 if value and target.os != 'OSX':
221 die('--enable-instruments cannot be used when targeting %s',
226 set_config('MOZ_INSTRUMENTS', instruments)
227 set_define('MOZ_INSTRUMENTS', instruments)
228 add_old_configure_assignment('MOZ_INSTRUMENTS', instruments)
229 imply_option('--enable-profiling', instruments, reason='--enable-instruments')
231 js_option('--enable-callgrind', env='MOZ_CALLGRIND',
232 help='Enable callgrind profiling')
234 @depends('--enable-callgrind')
235 def callgrind(value):
239 set_define('MOZ_CALLGRIND', callgrind)
240 imply_option('--enable-profiling', callgrind)
242 @depends(milestone, '--help')
243 def enable_profiling(milestone, help):
244 return milestone.is_nightly
246 js_option('--enable-profiling', env='MOZ_PROFILING', default=enable_profiling,
247 help='Set compile flags necessary for using sampling profilers '
248 '(e.g. shark, perf)')
250 @depends('--enable-profiling')
251 def profiling(value):
255 add_old_configure_assignment('MOZ_PROFILING', profiling)
257 @depends(profiling, target)
258 def imply_vtune(value, target):
259 ok_cpu = target.cpu in ['x86', 'x86_64']
260 ok_kernel = target.kernel == 'WINNT' or \
261 (target.kernel == 'Linux' and target.os == 'GNU')
263 if value and ok_cpu and ok_kernel:
266 set_config('MOZ_PROFILING', profiling)
267 set_define('MOZ_PROFILING', profiling)
268 imply_option('--enable-vtune', imply_vtune, reason='--enable-profiling')
271 js_option('--enable-vtune', env='MOZ_VTUNE', help='Enable VTune profiling')
273 @depends('--enable-vtune')
278 set_config('MOZ_VTUNE', vtune)
279 set_define('MOZ_VTUNE', vtune)
282 js_option('--enable-gc-trace', env='JS_GC_TRACE',
283 help='Enable tracing of allocation and finalization')
285 @depends('--enable-gc-trace')
290 set_define('JS_GC_TRACE', gc_trace)
293 js_option('--enable-gczeal',
294 default=depends(when=moz_debug)(lambda: True),
295 help='Enable zealous GCing')
297 set_define('JS_GC_ZEAL',
298 depends_if('--enable-gczeal')(lambda _: True))
301 # Use a smaller chunk size for GC chunks
302 # ========================================================
303 # Use large (1MB) chunks by default. This option can be used to give
304 # smaller (currently 256K) chunks.
305 js_option('--enable-small-chunk-size',
306 help='Allocate memory for JS GC things in smaller chunks')
308 set_define('JS_GC_SMALL_CHUNK_SIZE',
309 depends(when='--enable-small-chunk-size')(lambda: True))
313 # =======================================================
314 js_option('--enable-trace-logging',
315 default=depends(when=moz_debug)(lambda: True),
316 help='Enable trace logging')
318 set_config('ENABLE_TRACE_LOGGING',
319 depends_if('--enable-trace-logging')(lambda x: True))
320 set_define('JS_TRACE_LOGGING',
321 depends_if('--enable-trace-logging')(lambda x: True))
324 # Enable breakpoint for artificial OOMs
325 # =======================================================
326 js_option('--enable-oom-breakpoint',
327 help='Enable a breakpoint function for artificial OOMs')
329 set_define('JS_OOM_BREAKPOINT',
330 depends_if('--enable-oom-breakpoint')(lambda _: True))
333 js_option('--enable-perf', env='JS_ION_PERF',
334 help='Enable Linux perf integration')
336 @depends('--enable-perf')
341 set_define('JS_ION_PERF', ion_perf)
344 js_option('--enable-jitspew',
345 default=depends(when=moz_debug)(lambda: True),
346 help='Enable the Jit spew and IONFLAGS environment variable.')
348 set_define('JS_JITSPEW',
349 depends_if('--enable-jitspew')(lambda _: True))
350 set_config('JS_JITSPEW',
351 depends_if('--enable-jitspew')(lambda _: True))
354 js_option('--enable-more-deterministic', env='JS_MORE_DETERMINISTIC',
355 help='Enable changes that make the shell more deterministic')
357 @depends('--enable-more-deterministic')
358 def more_deterministic(value):
362 set_define('JS_MORE_DETERMINISTIC', more_deterministic)
366 # =======================================================
367 @depends(building_js, '--help')
368 def ctypes_default(building_js, _):
369 return not building_js
371 js_option('--enable-ctypes', help='Enable js-ctypes',
372 default=ctypes_default)
374 build_ctypes = depends_if('--enable-ctypes')(lambda _: True)
376 set_config('BUILD_CTYPES', build_ctypes)
377 set_define('BUILD_CTYPES', build_ctypes)
378 add_old_configure_assignment('BUILD_CTYPES', build_ctypes)
380 @depends(build_ctypes, building_js)
381 def js_has_ctypes(ctypes, js):
385 set_config('JS_HAS_CTYPES', js_has_ctypes)
386 set_define('JS_HAS_CTYPES', js_has_ctypes)
387 add_old_configure_assignment('JS_HAS_CTYPES', js_has_ctypes)
389 @depends('--enable-ctypes', '--enable-compile-environment', '--help')
390 def ctypes_and_compile_environment(ctypes, compile_environment, _):
391 return ctypes and compile_environment
393 include('ffi.configure', when=ctypes_and_compile_environment)
396 # Support various fuzzing options
397 # ==============================================================
398 with only_when('--enable-compile-environment'):
399 js_option('--enable-fuzzing', help='Enable fuzzing support')
401 @depends('--enable-fuzzing')
402 def enable_fuzzing(value):
406 @depends(try_compile(body='__AFL_COMPILER;',
407 check_msg='for AFL compiler',
408 when='--enable-fuzzing'))
409 def enable_aflfuzzer(afl):
413 @depends(enable_fuzzing,
416 def enable_libfuzzer(fuzzing, afl, c_compiler):
417 if fuzzing and not afl and c_compiler.type == 'clang':
420 @depends(enable_fuzzing,
423 def enable_fuzzing_interfaces(fuzzing, afl, libfuzzer):
424 if fuzzing and (afl or libfuzzer):
427 set_config('FUZZING', enable_fuzzing)
428 set_define('FUZZING', enable_fuzzing)
430 set_config('LIBFUZZER', enable_libfuzzer)
431 set_define('LIBFUZZER', enable_libfuzzer)
433 set_config('FUZZING_INTERFACES', enable_fuzzing_interfaces)
434 set_define('FUZZING_INTERFACES', enable_fuzzing_interfaces)
436 # Enable pipeline operator
437 # ===================================================
438 js_option('--enable-pipeline-operator', default=False, help='Enable pipeline operator')
440 @depends('--enable-pipeline-operator')
441 def enable_pipeline_operator(value):
445 set_config('ENABLE_PIPELINE_OPERATOR', enable_pipeline_operator)
446 set_define('ENABLE_PIPELINE_OPERATOR', enable_pipeline_operator)
450 # Experimental support for BinAST
451 # ==============================================================
453 @depends(target, milestone)
454 def enable_build_binast(target, milestone):
455 # For reasons unknown at this time, BinAST causes timeouts on win32
456 # and failures on Android.
457 if milestone.is_nightly and not (target.kernel == 'WINNT' and target.cpu == 'x86') and not (target.os == 'Android'):
460 set_define('JS_BUILD_BINAST', enable_build_binast)
461 set_config('JS_BUILD_BINAST', enable_build_binast)