Bug 1467936 [wpt PR 11436] - Split up editing/run/* with `variant`, a=testonly
[gecko.git] / js / moz.configure
blob47a682e551d294ffaf2681953b93d153a14f2530
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 include('../build/moz.configure/rust.configure',
22         when='--enable-compile-environment')
24 @depends('JS_STANDALONE')
25 def js_standalone(value):
26     if value:
27         return True
28 set_config('JS_STANDALONE', js_standalone)
29 set_define('JS_STANDALONE', js_standalone)
30 add_old_configure_assignment('JS_STANDALONE', js_standalone)
31 js_option('--disable-js-shell', default=building_js,
32           help='Do not build the JS shell')
34 @depends('--disable-js-shell')
35 def js_disable_shell(value):
36     if not value:
37         return True
39 set_config('JS_DISABLE_SHELL', js_disable_shell)
41 set_define('JS_64BIT', depends(target)(lambda t: t.bitness == 64 or None))
43 set_define('JS_PUNBOX64', depends(target)(lambda t: t.bitness == 64 or None))
44 set_define('JS_NUNBOX32', depends(target)(lambda t: t.bitness == 32 or None))
47 # SpiderMonkey as a shared library, and how its symbols are exported
48 # ==================================================================
49 js_option('--disable-shared-js', default=building_js,
50           help='Do not create a shared library')
52 js_option('--disable-export-js', default=building_js,
53           help='Do not mark JS symbols as DLL exported/visible')
55 @depends('--disable-shared-js', '--disable-export-js')
56 def shared_js(shared_js, export_js):
57     if shared_js:
58         if not export_js:
59             die('Must export JS symbols when building a shared library.')
60         return True
62 set_config('JS_SHARED_LIBRARY', shared_js)
63 add_old_configure_assignment('JS_SHARED_LIBRARY', shared_js)
65 @depends('--disable-shared-js', '--disable-export-js')
66 def exportable_js_api(shared_js, export_js):
67     if not shared_js and export_js:
68         return True
70 set_define('STATIC_EXPORTABLE_JS_API', exportable_js_api)
72 @depends('--disable-shared-js', '--disable-export-js')
73 def static_js_api(shared_js, export_js):
74     if not shared_js and not export_js:
75         return True
77 set_define('STATIC_JS_API', static_js_api)
79 @depends('--disable-shared-js')
80 def static_js(value):
81     if not value:
82         return True
84 set_define('MOZ_STATIC_JS', static_js)
86 @deprecated_option(env='DISABLE_SHARED_JS', nargs='?')
87 def disable_shared_js(value):
88     # DISABLE_SHARED_JS=1 gets us an empty PositiveOptionValue
89     if value and not len(value):
90         suggestion = '--disable-shared-js'
91     else:
92         suggestion = '--enable-shared-js'
94     die('Setting %s is deprecated, use %s instead.',
95         value.format('DISABLE_SHARED_JS'), suggestion)
97 @deprecated_option(env='DISABLE_EXPORT_JS', nargs='?')
98 def disable_export_js(value):
99     # DISABLE_EXPORT_JS=1 gets us an empty PositiveOptionValue
100     if value and not len(value):
101         suggestion = '--disable-export-js'
102     else:
103         suggestion = '--enable-export-js'
105     die('Setting %s is deprecated, use %s instead.',
106         value.format('DISABLE_EXPORT_JS'), suggestion)
108 # Experimental BigInt support
109 # =======================================================
110 js_option('--enable-bigint',
111           default=False,
112           help='Enable BigInt')
114 @depends('--enable-bigint')
115 def enable_bigint(value):
116     if value:
117         return True
119 set_config('ENABLE_BIGINT', enable_bigint)
120 set_define('ENABLE_BIGINT', enable_bigint)
122 # JIT support
123 # =======================================================
124 @depends(target, '--enable-bigint')
125 def ion_default(target, enable_bigint):
126     if enable_bigint:
127         return False
128     if target.cpu in ('x86', 'x86_64', 'arm', 'aarch64', 'mips32', 'mips64'):
129         return True
130     return False
132 js_option('--enable-ion',
133           default=ion_default,
134           help='Enable use of the IonMonkey JIT')
136 set_config('ENABLE_ION', depends_if('--enable-ion')(lambda x: True))
138 # JIT code simulator for cross compiles
139 # =======================================================
140 js_option('--enable-simulator', choices=('arm', 'arm64', 'mips32', 'mips64'),
141           nargs=1,
142           help='Enable a JIT code simulator for the specified architecture')
144 @depends('--enable-ion', '--enable-simulator', target)
145 def simulator(ion_enabled, simulator_enabled, target):
146     if not ion_enabled or not simulator_enabled:
147         return
149     sim_cpu = simulator_enabled[0]
151     if sim_cpu in ('arm', 'mips32'):
152         if target.cpu != 'x86':
153             die('The %s simulator only works on x86.' % sim_cpu)
155     if sim_cpu in ('arm64', 'mips64'):
156         if target.cpu != 'x86_64':
157             die('The %s simulator only works on x86-64.' % sim_cpu)
159     return namespace(**{sim_cpu: True})
161 set_config('JS_SIMULATOR', depends_if(simulator)(lambda x: True))
162 set_config('JS_SIMULATOR_ARM', simulator.arm)
163 set_config('JS_SIMULATOR_ARM64', simulator.arm64)
164 set_config('JS_SIMULATOR_MIPS32', simulator.mips32)
165 set_config('JS_SIMULATOR_MIPS64', simulator.mips64)
166 set_define('JS_SIMULATOR', depends_if(simulator)(lambda x: True))
167 set_define('JS_SIMULATOR_ARM', simulator.arm)
168 set_define('JS_SIMULATOR_ARM64', simulator.arm64)
169 set_define('JS_SIMULATOR_MIPS32', simulator.mips32)
170 set_define('JS_SIMULATOR_MIPS64', simulator.mips64)
172 @depends('--enable-ion', simulator, target)
173 def jit_codegen(ion_enabled, simulator, target):
174     if not ion_enabled:
175         return namespace(none=True)
177     if simulator:
178         return simulator
180     if target.cpu == 'aarch64':
181         return namespace(arm64=True)
182     elif target.cpu == 'x86_64':
183         return namespace(x64=True)
185     return namespace(**{str(target.cpu): True})
187 set_config('JS_CODEGEN_NONE', jit_codegen.none)
188 set_config('JS_CODEGEN_ARM', jit_codegen.arm)
189 set_config('JS_CODEGEN_ARM64', jit_codegen.arm64)
190 set_config('JS_CODEGEN_MIPS32', jit_codegen.mips32)
191 set_config('JS_CODEGEN_MIPS64', jit_codegen.mips64)
192 set_config('JS_CODEGEN_X86', jit_codegen.x86)
193 set_config('JS_CODEGEN_X64', jit_codegen.x64)
194 set_define('JS_CODEGEN_NONE', jit_codegen.none)
195 set_define('JS_CODEGEN_ARM', jit_codegen.arm)
196 set_define('JS_CODEGEN_ARM64', jit_codegen.arm64)
197 set_define('JS_CODEGEN_MIPS32', jit_codegen.mips32)
198 set_define('JS_CODEGEN_MIPS64', jit_codegen.mips64)
199 set_define('JS_CODEGEN_X86', jit_codegen.x86)
200 set_define('JS_CODEGEN_X64', jit_codegen.x64)
202 @depends('--enable-ion', simulator, target, moz_debug)
203 def jit_disasm_arm(ion_enabled, simulator, target, debug):
204     if not ion_enabled:
205         return
207     if simulator and debug:
208         if getattr(simulator, 'arm', None):
209             return True
211     if target.cpu == 'arm' and debug:
212         return True
214 set_config('JS_DISASM_ARM', jit_disasm_arm)
215 set_define('JS_DISASM_ARM', jit_disasm_arm)
217 @depends('--enable-ion', simulator, target, moz_debug)
218 def jit_disasm_arm64(ion_enabled, simulator, target, debug):
219     if not ion_enabled:
220         return
222     if simulator and debug:
223         if getattr(simulator, 'arm64', None):
224             return True
226     if target.cpu == 'aarch64' and debug:
227         return True
229 set_config('JS_DISASM_ARM64', jit_disasm_arm64)
230 set_define('JS_DISASM_ARM64', jit_disasm_arm64)
232 # Profiling
233 # =======================================================
234 js_option('--enable-instruments', env='MOZ_INSTRUMENTS',
235           help='Enable instruments remote profiling')
237 @depends('--enable-instruments', target)
238 def instruments(value, target):
239     if value and target.os != 'OSX':
240         die('--enable-instruments cannot be used when targeting %s',
241             target.os)
242     if value:
243         return True
245 set_config('MOZ_INSTRUMENTS', instruments)
246 set_define('MOZ_INSTRUMENTS', instruments)
247 add_old_configure_assignment('MOZ_INSTRUMENTS', instruments)
248 imply_option('--enable-profiling', instruments, reason='--enable-instruments')
250 js_option('--enable-callgrind', env='MOZ_CALLGRIND',
251           help='Enable callgrind profiling')
253 @depends('--enable-callgrind')
254 def callgrind(value):
255     if value:
256         return True
258 set_define('MOZ_CALLGRIND', callgrind)
259 imply_option('--enable-profiling', callgrind)
261 @depends(milestone, '--help')
262 def enable_profiling(milestone, help):
263     return milestone.is_nightly
265 js_option('--enable-profiling', env='MOZ_PROFILING', default=enable_profiling,
266           help='Set compile flags necessary for using sampling profilers '
267                '(e.g. shark, perf)')
269 @depends('--enable-profiling')
270 def profiling(value):
271     if value:
272         return True
274 add_old_configure_assignment('MOZ_PROFILING', profiling)
276 @depends(profiling, target)
277 def imply_vtune(value, target):
278     ok_cpu    = target.cpu in ['x86', 'x86_64']
279     ok_kernel = target.kernel == 'WINNT' or \
280                 (target.kernel == 'Linux' and target.os == 'GNU')
282     if value and ok_cpu and ok_kernel:
283         return True
285 set_config('MOZ_PROFILING', profiling)
286 set_define('MOZ_PROFILING', profiling)
287 imply_option('--enable-vtune', imply_vtune, reason='--enable-profiling')
290 js_option('--enable-vtune', env='MOZ_VTUNE', help='Enable VTune profiling')
292 @depends('--enable-vtune')
293 def vtune(value):
294     if value:
295         return True
297 set_config('MOZ_VTUNE', vtune)
298 set_define('MOZ_VTUNE', vtune)
301 js_option('--enable-gc-trace', env='JS_GC_TRACE',
302           help='Enable tracing of allocation and finalization')
304 @depends('--enable-gc-trace')
305 def gc_trace(value):
306     if value:
307         return True
309 set_define('JS_GC_TRACE', gc_trace)
312 js_option('--enable-gczeal',
313           default=depends(when=moz_debug)(lambda: True),
314           help='Enable zealous GCing')
316 set_define('JS_GC_ZEAL',
317            depends_if('--enable-gczeal')(lambda _: True))
320 # Use a smaller chunk size for GC chunks
321 # ========================================================
322 # Use large (1MB) chunks by default.  This option can be used to give
323 # smaller (currently 256K) chunks.
324 js_option('--enable-small-chunk-size',
325           help='Allocate memory for JS GC things in smaller chunks')
327 set_define('JS_GC_SMALL_CHUNK_SIZE',
328            depends(when='--enable-small-chunk-size')(lambda: True))
331 # Trace logging.
332 # =======================================================
333 js_option('--enable-trace-logging',
334           default=depends(when=moz_debug)(lambda: True),
335           help='Enable trace logging')
337 set_config('ENABLE_TRACE_LOGGING',
338            depends_if('--enable-trace-logging')(lambda x: True))
339 set_define('JS_TRACE_LOGGING',
340            depends_if('--enable-trace-logging')(lambda x: True))
343 # Enable breakpoint for artificial OOMs
344 # =======================================================
345 js_option('--enable-oom-breakpoint',
346           help='Enable a breakpoint function for artificial OOMs')
348 set_define('JS_OOM_BREAKPOINT',
349            depends_if('--enable-oom-breakpoint')(lambda _: True))
352 js_option('--enable-perf', env='JS_ION_PERF',
353           help='Enable Linux perf integration')
355 @depends('--enable-perf')
356 def ion_perf(value):
357     if value:
358         return True
360 set_define('JS_ION_PERF', ion_perf)
363 js_option('--enable-jitspew',
364           default=depends(when=moz_debug)(lambda: True),
365           help='Enable the Jit spew and IONFLAGS environment variable.')
367 set_define('JS_JITSPEW',
368            depends_if('--enable-jitspew')(lambda _: True))
369 set_config('JS_JITSPEW',
370            depends_if('--enable-jitspew')(lambda _: True))
373 js_option('--enable-more-deterministic', env='JS_MORE_DETERMINISTIC',
374           help='Enable changes that make the shell more deterministic')
376 @depends('--enable-more-deterministic')
377 def more_deterministic(value):
378     if value:
379         return True
381 set_define('JS_MORE_DETERMINISTIC', more_deterministic)
384 # CTypes
385 # =======================================================
386 @depends(building_js, '--help')
387 def ctypes_default(building_js, _):
388     return not building_js
390 js_option('--enable-ctypes', help='Enable js-ctypes',
391           default=ctypes_default)
393 build_ctypes = depends_if('--enable-ctypes')(lambda _: True)
395 set_config('BUILD_CTYPES', build_ctypes)
396 set_define('BUILD_CTYPES', build_ctypes)
397 add_old_configure_assignment('BUILD_CTYPES', build_ctypes)
399 @depends(build_ctypes, building_js)
400 def js_has_ctypes(ctypes, js):
401     if ctypes and js:
402         return True
404 set_config('JS_HAS_CTYPES', js_has_ctypes)
405 set_define('JS_HAS_CTYPES', js_has_ctypes)
406 add_old_configure_assignment('JS_HAS_CTYPES', js_has_ctypes)
408 @depends('--enable-ctypes', '--enable-compile-environment', '--help')
409 def ctypes_and_compile_environment(ctypes, compile_environment, _):
410     return ctypes and compile_environment
412 include('ffi.configure', when=ctypes_and_compile_environment)
415 # Support various fuzzing options
416 # ==============================================================
417 with only_when('--enable-compile-environment'):
418     js_option('--enable-fuzzing', help='Enable fuzzing support')
420     @depends('--enable-fuzzing')
421     def enable_fuzzing(value):
422         if value:
423             return True
425     @depends(try_compile(body='__AFL_COMPILER;',
426                          check_msg='for AFL compiler',
427                          when='--enable-fuzzing'))
428     def enable_aflfuzzer(afl):
429         if afl:
430             return True
432     @depends(enable_fuzzing,
433              enable_aflfuzzer,
434              c_compiler)
435     def enable_libfuzzer(fuzzing, afl, c_compiler):
436         if fuzzing and not afl and c_compiler.type == 'clang':
437             return True
439     @depends(enable_fuzzing,
440              enable_aflfuzzer,
441              enable_libfuzzer)
442     def enable_fuzzing_interfaces(fuzzing, afl, libfuzzer):
443         if fuzzing and (afl or libfuzzer):
444             return True
446     set_config('FUZZING', enable_fuzzing)
447     set_define('FUZZING', enable_fuzzing)
449     set_config('LIBFUZZER', enable_libfuzzer)
450     set_define('LIBFUZZER', enable_libfuzzer)
452     set_config('FUZZING_INTERFACES', enable_fuzzing_interfaces)
453     set_define('FUZZING_INTERFACES', enable_fuzzing_interfaces)
455 # Enable pipeline operator
456 # ===================================================
457 js_option('--enable-pipeline-operator', default=False, help='Enable pipeline operator')
459 @depends('--enable-pipeline-operator')
460 def enable_pipeline_operator(value):
461     if value:
462         return True
464 set_config('ENABLE_PIPELINE_OPERATOR', enable_pipeline_operator)
465 set_define('ENABLE_PIPELINE_OPERATOR', enable_pipeline_operator)
469 # Experimental support for BinAST
470 # ==============================================================
472 @depends(target, milestone)
473 def enable_build_binast(target, milestone):
474     # For reasons unknown at this time, BinAST causes timeouts on win32
475     # and failures on Android.
476     if milestone.is_nightly and not (target.kernel == 'WINNT' and target.cpu == 'x86') and not (target.os == 'Android'):
477         return True
479 set_define('JS_BUILD_BINAST', enable_build_binast)
480 set_config('JS_BUILD_BINAST', enable_build_binast)
483 # Experimental support for wasm code generation with Cranelift
484 # ==============================================================
485 js_option('--enable-cranelift',
486           help='Enable Cranelift code generator for wasm')
488 @depends('--enable-cranelift')
489 def enable_cranelift(value):
490     if value:
491         return True
493 set_config('MOZ_WASM_CRANELIFT', enable_cranelift)
494 set_define('MOZ_WASM_CRANELIFT', enable_cranelift)