Bug 1701957 [wpt PR 28298] - Incorrect reference for hsl() test, a=testonly
[gecko.git] / js / moz.configure
bloba040621040fa51ddf9caf0f106218931ab69991d
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/.
8 @depends(build_project)
9 def js_standalone(build_project):
10     if build_project == "js":
11         return True
14 # Branding
15 # ==============================================================
16 option(
17     "--with-app-name",
18     env="MOZ_APP_NAME",
19     nargs=1,
20     help="Used for e.g. the binary program file name. If not set, "
21     "defaults to a lowercase form of MOZ_APP_BASENAME.",
25 @depends("--with-app-name", js_standalone, moz_app_basename)
26 def moz_app_name(value, js_standalone, moz_app_basename):
27     if value:
28         return value[0]
29     if js_standalone:
30         return "js"
31     return moz_app_basename.lower()
34 set_config("MOZ_APP_NAME", moz_app_name)
36 # SmooshMonkey (new frontend)
37 # ==================================================
39 # Define here in order to use the option from bindgen.configure.
40 option(
41     "--enable-smoosh",
42     default=False,
43     help="Enable SmooshMonkey (new JS engine frontend)",
47 @depends("--enable-smoosh")
48 def enable_smoosh(value):
49     if value:
50         return True
53 set_config("JS_ENABLE_SMOOSH", enable_smoosh)
54 set_define("JS_ENABLE_SMOOSH", enable_smoosh)
56 include("../build/moz.configure/nspr.configure", when="--enable-compile-environment")
57 include("../build/moz.configure/rust.configure", when="--enable-compile-environment")
58 include("../build/moz.configure/bindgen.configure", when="--enable-compile-environment")
60 set_config("JS_STANDALONE", js_standalone)
61 set_define("JS_STANDALONE", js_standalone)
62 add_old_configure_assignment("JS_STANDALONE", js_standalone)
63 option(
64     "--enable-js-shell", default=js_standalone, help="{Build|Do not build} the JS shell"
68 @depends("--enable-js-shell")
69 def js_disable_shell(value):
70     if not value:
71         return True
74 set_config("JS_DISABLE_SHELL", js_disable_shell)
76 set_define("JS_64BIT", depends(target)(lambda t: t.bitness == 64 or None))
78 set_define("JS_PUNBOX64", depends(target)(lambda t: t.bitness == 64 or None))
79 set_define("JS_NUNBOX32", depends(target)(lambda t: t.bitness == 32 or None))
82 # SpiderMonkey as a shared library, and how its symbols are exported
83 # ==================================================================
84 option(
85     "--disable-shared-js",
86     when=js_standalone,
87     help="{Create|Do not create} a shared library",
90 option(
91     "--disable-export-js",
92     when=js_standalone,
93     help="{Mark|Do not mark} JS symbols as DLL exported/visible",
97 @depends("--disable-shared-js", "--disable-export-js", when=js_standalone)
98 def shared_js(shared_js, export_js):
99     if shared_js:
100         if not export_js:
101             die("Must export JS symbols when building a shared library.")
102         return True
105 set_config("JS_SHARED_LIBRARY", shared_js)
106 add_old_configure_assignment("JS_SHARED_LIBRARY", shared_js)
109 @depends(shared_js, "--disable-export-js", when=js_standalone)
110 def exportable_js_api(shared_js, export_js):
111     if not shared_js and export_js:
112         return True
115 set_define("STATIC_EXPORTABLE_JS_API", exportable_js_api)
118 @depends(shared_js, exportable_js_api)
119 def static_js_api(shared_js, export_js):
120     if not shared_js and not export_js:
121         return True
124 set_define("STATIC_JS_API", static_js_api)
127 @depends(shared_js)
128 def static_js(value):
129     if not value:
130         return True
133 set_define("MOZ_STATIC_JS", static_js)
136 option(env="NO_RUST_PANIC_HOOK", when=js_standalone, help="Disable rust panic hook")
138 set_define("NO_RUST_PANIC_HOOK", True, when="NO_RUST_PANIC_HOOK")
141 # JIT support
142 # =======================================================
143 @depends(target)
144 def jit_default(target):
145     if target.cpu in ("x86", "x86_64", "arm", "aarch64", "mips32", "mips64"):
146         return True
147     return False
150 option("--enable-jit", default=jit_default, help="{Enable|Disable} use of the JITs")
153 @deprecated_option("--enable-ion")
154 def report_deprecated(value):
155     if value:
156         die("--enable-ion is deprecated, use --enable-jit instead")
157     else:
158         die("--disable-ion is deprecated, use --disable-jit instead")
161 # JIT code simulator for cross compiles
162 # =======================================================
163 option(
164     "--enable-simulator",
165     choices=("arm", "arm64", "mips32", "mips64"),
166     nargs=1,
167     help="Enable a JIT code simulator for the specified architecture",
171 @depends("--enable-jit", "--enable-simulator", target)
172 def simulator(jit_enabled, simulator_enabled, target):
173     if not jit_enabled or not simulator_enabled:
174         return
176     sim_cpu = simulator_enabled[0]
178     if sim_cpu in ("arm", "mips32"):
179         if target.cpu != "x86":
180             die("The %s simulator only works on x86." % sim_cpu)
182     if sim_cpu in ("arm64", "mips64"):
183         if target.cpu != "x86_64":
184             die("The %s simulator only works on x86-64." % sim_cpu)
186     return namespace(**{sim_cpu: True})
189 set_config("JS_SIMULATOR", depends_if(simulator)(lambda x: True))
190 set_config("JS_SIMULATOR_ARM", simulator.arm)
191 set_config("JS_SIMULATOR_ARM64", simulator.arm64)
192 set_config("JS_SIMULATOR_MIPS32", simulator.mips32)
193 set_config("JS_SIMULATOR_MIPS64", simulator.mips64)
194 set_define("JS_SIMULATOR", depends_if(simulator)(lambda x: True))
195 set_define("JS_SIMULATOR_ARM", simulator.arm)
196 set_define("JS_SIMULATOR_ARM64", simulator.arm64)
197 set_define("JS_SIMULATOR_MIPS32", simulator.mips32)
198 set_define("JS_SIMULATOR_MIPS64", simulator.mips64)
201 @depends("--enable-jit", simulator, target)
202 def jit_codegen(jit_enabled, simulator, target):
203     if not jit_enabled:
204         return namespace(none=True)
206     if simulator:
207         return simulator
209     if target.cpu == "aarch64":
210         return namespace(arm64=True)
211     elif target.cpu == "x86_64":
212         return namespace(x64=True)
214     return namespace(**{str(target.cpu): True})
217 set_config("JS_CODEGEN_NONE", jit_codegen.none)
218 set_config("JS_CODEGEN_ARM", jit_codegen.arm)
219 set_config("JS_CODEGEN_ARM64", jit_codegen.arm64)
220 set_config("JS_CODEGEN_MIPS32", jit_codegen.mips32)
221 set_config("JS_CODEGEN_MIPS64", jit_codegen.mips64)
222 set_config("JS_CODEGEN_X86", jit_codegen.x86)
223 set_config("JS_CODEGEN_X64", jit_codegen.x64)
224 set_define("JS_CODEGEN_NONE", jit_codegen.none)
225 set_define("JS_CODEGEN_ARM", jit_codegen.arm)
226 set_define("JS_CODEGEN_ARM64", jit_codegen.arm64)
227 set_define("JS_CODEGEN_MIPS32", jit_codegen.mips32)
228 set_define("JS_CODEGEN_MIPS64", jit_codegen.mips64)
229 set_define("JS_CODEGEN_X86", jit_codegen.x86)
230 set_define("JS_CODEGEN_X64", jit_codegen.x64)
232 # Profiling
233 # =======================================================
234 option(
235     "--enable-instruments",
236     env="MOZ_INSTRUMENTS",
237     help="Enable instruments remote profiling",
241 @depends("--enable-instruments", target)
242 def instruments(value, target):
243     if value and target.os != "OSX":
244         die("--enable-instruments cannot be used when targeting %s", target.os)
245     if value:
246         return True
249 set_config("MOZ_INSTRUMENTS", instruments)
250 set_define("MOZ_INSTRUMENTS", instruments)
251 add_old_configure_assignment("MOZ_INSTRUMENTS", instruments)
252 imply_option("--enable-profiling", instruments, reason="--enable-instruments")
254 option("--enable-callgrind", env="MOZ_CALLGRIND", help="Enable callgrind profiling")
257 @depends("--enable-callgrind")
258 def callgrind(value):
259     if value:
260         return True
263 set_define("MOZ_CALLGRIND", callgrind)
264 imply_option("--enable-profiling", callgrind)
267 @depends(milestone)
268 def enable_profiling(milestone):
269     return milestone.is_nightly
272 option(
273     "--enable-profiling",
274     env="MOZ_PROFILING",
275     default=enable_profiling,
276     help="{Set|Do not set} compile flags necessary for using sampling "
277     "profilers (e.g. shark, perf)",
281 @depends("--enable-profiling")
282 def profiling(value):
283     if value:
284         return True
287 add_old_configure_assignment("MOZ_PROFILING", profiling)
289 with only_when("--enable-compile-environment"):
290     imply_option("--enable-frame-pointers", True, when=profiling)
293 @depends(profiling, target)
294 def imply_vtune(value, target):
295     ok_cpu = target.cpu in ["x86", "x86_64"]
296     ok_kernel = target.kernel == "WINNT" or (
297         target.kernel == "Linux" and target.os == "GNU"
298     )
300     if value and ok_cpu and ok_kernel:
301         return True
304 set_config("MOZ_PROFILING", profiling)
305 set_define("MOZ_PROFILING", profiling)
306 imply_option("--enable-vtune", imply_vtune, reason="--enable-profiling")
309 option("--enable-vtune", env="MOZ_VTUNE", help="Enable VTune profiling")
312 @depends("--enable-vtune")
313 def vtune(value):
314     if value:
315         return True
318 set_config("MOZ_VTUNE", vtune)
319 set_define("MOZ_VTUNE", vtune)
322 option(
323     "--enable-gc-probes",
324     env="JS_GC_PROBES",
325     help="Turn on probes for allocation and finalization",
329 @depends("--enable-gc-probes")
330 def gc_probes(value):
331     if value:
332         return True
335 set_define("JS_GC_PROBES", gc_probes)
338 option(
339     "--enable-gczeal",
340     default=depends(when=moz_debug)(lambda: True),
341     help="{Enable|Disable} zealous GCing",
344 set_define("JS_GC_ZEAL", depends_if("--enable-gczeal")(lambda _: True))
347 # Use a smaller chunk size for GC chunks
348 # ========================================================
349 # Use large (1MB) chunks by default.  This option can be used to give
350 # smaller (currently 256K) chunks.
351 option(
352     "--enable-small-chunk-size",
353     help="Allocate memory for JS GC things in smaller chunks",
356 set_define(
357     "JS_GC_SMALL_CHUNK_SIZE", depends(when="--enable-small-chunk-size")(lambda: True)
361 # Trace logging.
362 # =======================================================
363 @depends(milestone)
364 def default_trace_logging(milestone):
365     return milestone.is_nightly
368 option(
369     "--enable-trace-logging",
370     default=default_trace_logging,
371     help="{Enable|Disable} trace logging",
374 set_config("ENABLE_TRACE_LOGGING", depends_if("--enable-trace-logging")(lambda x: True))
375 set_define("JS_TRACE_LOGGING", depends_if("--enable-trace-logging")(lambda x: True))
378 # Enable breakpoint for artificial OOMs
379 # =======================================================
380 option(
381     "--enable-oom-breakpoint", help="Enable a breakpoint function for artificial OOMs"
384 set_define("JS_OOM_BREAKPOINT", depends_if("--enable-oom-breakpoint")(lambda _: True))
387 option("--enable-perf", env="JS_ION_PERF", help="Enable Linux perf integration")
390 @depends("--enable-perf")
391 def ion_perf(value):
392     if value:
393         return True
396 set_define("JS_ION_PERF", ion_perf)
399 option(
400     "--enable-jitspew",
401     default=depends(when=moz_debug)(lambda: True),
402     help="{Enable|Disable} the Jit spew and IONFLAGS environment " "variable",
405 set_define("JS_JITSPEW", depends_if("--enable-jitspew")(lambda _: True))
406 set_config("JS_JITSPEW", depends_if("--enable-jitspew")(lambda _: True))
408 # Also enable the structured spewer
409 set_define("JS_STRUCTURED_SPEW", depends_if("--enable-jitspew")(lambda _: True))
410 set_config("JS_STRUCTURED_SPEW", depends_if("--enable-jitspew")(lambda _: True))
413 @depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
414 def jit_disasm_arm(jit_enabled, spew, simulator, target, debug):
415     if not jit_enabled:
416         return
418     if simulator and (debug or spew):
419         if getattr(simulator, "arm", None):
420             return True
422     if target.cpu == "arm" and (debug or spew):
423         return True
426 set_config("JS_DISASM_ARM", jit_disasm_arm)
427 set_define("JS_DISASM_ARM", jit_disasm_arm)
430 @depends("--enable-jit", "--enable-jitspew", simulator, target, moz_debug)
431 def jit_disasm_arm64(jit_enabled, spew, simulator, target, debug):
432     if not jit_enabled:
433         return
435     if simulator and (debug or spew):
436         if getattr(simulator, "arm64", None):
437             return True
439     if target.cpu == "aarch64" and (debug or spew):
440         return True
443 set_config("JS_DISASM_ARM64", jit_disasm_arm64)
444 set_define("JS_DISASM_ARM64", jit_disasm_arm64)
446 # When enabled, masm will generate assumeUnreachable calls that act as
447 # assertions in the generated code. This option is worth disabling when you
448 # have to track mutated values through the generated code, to avoid constantly
449 # dumping registers on and off the stack.
450 option(
451     "--enable-masm-verbose",
452     default=depends(when=moz_debug)(lambda: True),
453     help="{Enable|Disable} MacroAssembler verbosity of generated code.",
455 set_define("JS_MASM_VERBOSE", depends_if("--enable-masm-verbose")(lambda _: True))
456 set_config("JS_MASM_VERBOSE", depends_if("--enable-masm-verbose")(lambda _: True))
458 # Architecture feature flags
459 # =======================================================
461 # Apple silicon does not seem to have any way to query the OS for the JSCVT
462 # flag stored in the ID_AA64ISAR1_EL1 system register. In the mean time, we
463 # hard code the value of the JSCVT flag which guards the implementation of
464 # FJCVTZS instruction as part of ARMv8.3-JSConv.
465 @depends(target)
466 def is_apple_silicon(target):
467     return target.os == "OSX" and target.kernel == "Darwin" and target.cpu == "aarch64"
470 option(
471     "--enable-arm64-fjcvtzs",
472     default=is_apple_silicon,
473     help="{Enable|Disable} static use of FJCVTZS instruction on Aarch64 targets.",
476 # The "ARM Architecture Reference Manual" for ARMv8 defines the JSCVT flag as
477 # being a 4 bit integer (D12.2.52) and it can be manipulated using >= operator
478 # (D12.1.4).
480 # The FJCVTZS instruction is implemented if ID_AA64ISAR1_EL1.JSCVT >= 1.
481 @depends("--enable-arm64-fjcvtzs", target, simulator)
482 def aarch64_jscvt(fjcvtzs, target, simulator):
483     if target.cpu == "aarch64" and fjcvtzs:
484         return 1
486     if simulator and getattr(simulator, "arm64", False) and fjcvtzs:
487         return 1
489     return 0
492 set_define("MOZ_AARCH64_JSCVT", aarch64_jscvt)
494 # CTypes
495 # =======================================================
496 @depends(js_standalone)
497 def ctypes_default(js_standalone):
498     return not js_standalone
501 option("--enable-ctypes", default=ctypes_default, help="{Enable|Disable} js-ctypes")
503 build_ctypes = depends_if("--enable-ctypes")(lambda _: True)
505 set_config("BUILD_CTYPES", build_ctypes)
506 set_define("BUILD_CTYPES", build_ctypes)
508 set_config("JS_HAS_CTYPES", build_ctypes)
509 set_define("JS_HAS_CTYPES", build_ctypes)
512 @depends("--enable-ctypes", "--enable-compile-environment")
513 def ctypes_and_compile_environment(ctypes, compile_environment):
514     return ctypes and compile_environment
517 include("ffi.configure", when=ctypes_and_compile_environment)
520 # Enable pipeline operator
521 # ===================================================
522 option("--enable-pipeline-operator", default=False, help="Enable pipeline operator")
525 @depends("--enable-pipeline-operator")
526 def enable_pipeline_operator(value):
527     if value:
528         return True
531 set_config("ENABLE_PIPELINE_OPERATOR", enable_pipeline_operator)
532 set_define("ENABLE_PIPELINE_OPERATOR", enable_pipeline_operator)
535 # SIMD acceleration for encoding_rs
536 # ==============================================================
538 option(
539     "--enable-rust-simd", env="MOZ_RUST_SIMD", help="Enable explicit SIMD in Rust code."
543 @depends("--enable-rust-simd", target)
544 def rust_simd(value, target):
545     # As of 2019-09-17, the simd-accel feature of encoding_rs has not
546     # been properly set up outside aarch64, armv7, x86 and x86_64.
547     if target.cpu in ("aarch64", "arm", "x86", "x86_64") and value:
548         return True
551 set_config("MOZ_RUST_SIMD", rust_simd)
552 set_define("MOZ_RUST_SIMD", rust_simd)
555 # Support for wasm code generation with Cranelift
556 # ==============================================================
559 @depends(
560     milestone.is_nightly,
561     "--enable-jit",
562     "--enable-simulator",
563     target,
564     target_is_windows,
566 def cranelift_default(is_nightly, jit_enabled, simulator, target, is_windows):
567     if is_nightly and jit_enabled and not is_windows:
568         if target.cpu == "aarch64":
569             return True
570         if simulator and simulator[0] == "arm64":
571             return True
574 option(
575     "--enable-cranelift",
576     default=cranelift_default,
577     help="{Enable|Disable} Cranelift code generator for wasm",
580 set_config("ENABLE_WASM_CRANELIFT", depends_if("--enable-cranelift")(lambda x: True))
581 set_define("ENABLE_WASM_CRANELIFT", depends_if("--enable-cranelift")(lambda x: True))
583 # Telemetry to measure compile time and generated-code runtime
584 # ============================================================
586 option(
587     "--enable-spidermonkey-telemetry",
588     default=milestone.is_nightly,
589     help="{Enable|Disable} performance telemetry for SpiderMonkey (e.g. compile and run times)",
592 set_define(
593     "ENABLE_SPIDERMONKEY_TELEMETRY",
594     depends_if("--enable-spidermonkey-telemetry")(lambda x: True),
597 # Support for debugging code generated by wasm backends
598 # =====================================================
600 option(
601     "--enable-wasm-codegen-debug",
602     default=depends(when=moz_debug)(lambda: True),
603     help="{Enable|Disable} debugging for wasm codegen",
606 set_config(
607     "WASM_CODEGEN_DEBUG", depends_if("--enable-wasm-codegen-debug")(lambda x: True)
609 set_define(
610     "WASM_CODEGEN_DEBUG", depends_if("--enable-wasm-codegen-debug")(lambda x: True)
613 # Support for WebAssembly reference types.
614 # =====================================================
616 option("--disable-wasm-reftypes", help="Disable WebAssembly reference types")
619 @depends("--disable-wasm-reftypes")
620 def enable_wasm_reftypes(value):
621     if value:
622         return True
625 set_config("ENABLE_WASM_REFTYPES", enable_wasm_reftypes)
626 set_define("ENABLE_WASM_REFTYPES", enable_wasm_reftypes)
628 # Support for WebAssembly function-references.
629 # ===========================
632 @depends(milestone.is_nightly, "--disable-wasm-reftypes")
633 def default_wasm_function_references(is_nightly, reftypes):
634     if is_nightly and reftypes:
635         return True
638 option(
639     "--enable-wasm-function-references",
640     default=default_wasm_function_references,
641     help="{Enable|Disable} WebAssembly function-references",
645 @depends("--enable-wasm-function-references", "--disable-wasm-reftypes")
646 def wasm_function_references(value, reftypes):
647     if not value:
648         return
650     if reftypes:
651         return True
653     die(
654         "--enable-wasm-function-references only possible without --disable-wasm-reftypes"
655     )
658 set_config("ENABLE_WASM_FUNCTION_REFERENCES", wasm_function_references)
659 set_define("ENABLE_WASM_FUNCTION_REFERENCES", wasm_function_references)
661 # Support for WebAssembly GC.
662 # ===========================
665 @depends(milestone.is_nightly, "--enable-wasm-function-references")
666 def default_wasm_gc(is_nightly, function_references):
667     if is_nightly and function_references:
668         return True
671 option(
672     "--enable-wasm-gc", default=default_wasm_gc, help="{Enable|Disable} WebAssembly GC"
676 @depends("--enable-wasm-gc", "--enable-wasm-function-references")
677 def wasm_gc(value, function_references):
678     if not value:
679         return
681     if function_references:
682         return True
684     die("--enable-wasm-gc only possible with --enable-wasm-function-references")
687 set_config("ENABLE_WASM_GC", wasm_gc)
688 set_define("ENABLE_WASM_GC", wasm_gc)
691 # Support for WebAssembly private ref types.
692 # Prevent (ref T) types from being exposed to JS content so that wasm need do
693 # no typechecking at the JS/wasm boundary
694 # ===========================================================================
697 @depends(milestone.is_nightly, "--enable-wasm-gc")
698 def default_wasm_private_reftypes(is_nightly, gc):
699     if gc and is_nightly:
700         return True
703 option(
704     "--enable-wasm-private-reftypes",
705     default=default_wasm_private_reftypes,
706     help="{Enable|Disable} WebAssembly private reference types",
709 set_config(
710     "WASM_PRIVATE_REFTYPES",
711     depends_if("--enable-wasm-private-reftypes")(lambda x: True),
713 set_define(
714     "WASM_PRIVATE_REFTYPES",
715     depends_if("--enable-wasm-private-reftypes")(lambda x: True),
719 # Support for the WebAssembly multi-value proposal.
720 # Do not remove until Cranelift supports multi-value.
721 # =====================================================
723 option(
724     "--disable-wasm-multi-value",
725     help="Disable WebAssembly multi-value blocks and function calls",
729 @depends("--disable-wasm-multi-value")
730 def enable_wasm_multi_value(value):
731     if value:
732         return True
735 set_config("ENABLE_WASM_MULTI_VALUE", enable_wasm_multi_value)
736 set_define("ENABLE_WASM_MULTI_VALUE", enable_wasm_multi_value)
739 # Support for WebAssembly shared memory and atomics.
741 # This affects the JS shell only and here to allow the use of
742 # Cranelift in the shell.  Once Cranelift supports shared memory
743 # and atomics it can go away.
744 # =====================================================
746 option(
747     "--disable-shared-memory", help="Disable JS/WebAssembly shared memory and atomics"
751 @depends("--disable-shared-memory")
752 def enable_shared_memory(value):
753     if value:
754         return True
757 set_config("ENABLE_SHARED_MEMORY", enable_shared_memory)
758 set_define("ENABLE_SHARED_MEMORY", enable_shared_memory)
761 # Support for WebAssembly SIMD
762 # =====================================================
765 @depends("--enable-jit", "--enable-simulator", target)
766 def default_wasm_simd(jit_enabled, simulator, target):
767     if not jit_enabled:
768         return
770     if simulator:
771         return
773     if target.cpu in ("x86_64", "x86"):
774         return True
777 option(
778     "--enable-wasm-simd",
779     default=default_wasm_simd,
780     help="{Enable|Disable} WebAssembly SIMD",
784 @depends("--enable-wasm-simd", "--enable-jit", "--enable-simulator", target)
785 def wasm_simd(value, jit_enabled, simulator, target):
786     if not value:
787         return
789     if not jit_enabled:
790         return
792     if simulator:
793         return
795     if target.cpu in ("x86_64", "x86"):
796         return True
798     die("--enable-wasm-simd only possible when targeting the x86_64/x86 jits")
801 set_config("ENABLE_WASM_SIMD", wasm_simd)
802 set_define("ENABLE_WASM_SIMD", wasm_simd)
804 # Wormhole opcodes are Intel-only.  They are private to Firefox, but we need them for some
805 # experiments on release and so they ride the trains.
808 @depends("--enable-simulator", "--enable-wasm-simd", target)
809 def default_wasm_simd_wormhole(simulator, wasm_simd, target):
810     if wasm_simd and target.cpu in ("x86", "x86_64") and not simulator:
811         return True
814 option(
815     "--enable-wasm-simd-wormhole",
816     default=default_wasm_simd_wormhole,
817     help="{Enable|Disable} WebAssembly SIMD wormhole opcodes",
821 @depends(
822     "--enable-wasm-simd-wormhole", "--enable-wasm-simd", "--enable-simulator", target
824 def wasm_simd_wormhole(value, wasm_simd, simulator, target):
825     if not value:
826         return
828     if wasm_simd and target.cpu in ("x86", "x86_64") and not simulator:
829         return True
831     die("SIMD wormhole currently supported on native x86/x64 only, with --wasm-simd")
834 set_config("ENABLE_WASM_SIMD_WORMHOLE", wasm_simd_wormhole)
835 set_define("ENABLE_WASM_SIMD_WORMHOLE", wasm_simd_wormhole)
838 # Options for generating the shell as a script
839 # ============================================
840 option("--with-qemu-exe", nargs=1, help="Use path as an arm emulator on host platforms")
841 set_config("QEMU_EXE", depends_if("--with-qemu-exe")(lambda x: x))
843 option(
844     "--with-cross-lib",
845     nargs=1,
846     default=depends(target.alias)(lambda x: "/usr/%s" % x),
847     help="Use dir as the location for arm libraries",
849 set_config("CROSS_LIB", depends_if("--with-cross-lib")(lambda x: x))
851 # Enable static checking using sixgill
852 # ====================================
854 option("--with-sixgill", nargs=1, help="Enable static checking of code using sixgill")
857 @depends_if("--with-sixgill")
858 @imports("os")
859 def sixgill(value):
860     for f in ("bin/xdbfind", "gcc/xgill.so", "scripts/wrap_gcc/g++"):
861         if not os.path.exists(os.path.join(value[0], f)):
862             die("The sixgill plugin and binaries are not at the specified path")
863     return value[0]
866 set_config("SIXGILL_PATH", sixgill)
869 # Support for readline
870 # =====================================================
871 @depends("--enable-js-shell", target_is_windows, compile_environment)
872 def editline(js_shell, is_windows, compile_environment):
873     return js_shell and not is_windows and compile_environment
876 option(
877     "--enable-readline", help="Link js shell to system readline library", when=editline
880 has_readline = check_symbol(
881     "readline",
882     flags=["-lreadline"],
883     when="--enable-readline",
884     onerror=lambda: die("No system readline library found"),
887 set_config("EDITLINE_LIBS", ["-lreadline"], when=has_readline)
890 @depends("--enable-readline", editline, when=editline)
891 def bundled_editline(readline, editline):
892     return editline and not readline
895 set_config("JS_BUNDLED_EDITLINE", bundled_editline)
897 set_define("EDITLINE", True, when=editline)
900 # JIT observers
901 # =============
903 option(
904     "--with-jitreport-granularity",
905     default="3",
906     choices=("0", "1", "2", "3"),
907     help="Default granularity at which to report JIT code to external tools "
908     "(0 - no info, 1 - code ranges for while functions only, "
909     "2 - per-line information, 3 - per-op information)",
912 set_define(
913     "JS_DEFAULT_JITREPORT_GRANULARITY",
914     depends_if("--with-jitreport-granularity")(lambda value: value[0]),
918 # ECMAScript Internationalization API Support (uses ICU)
919 # ======================================================
920 option("--with-system-icu", help="Use system ICU")
922 system_icu = pkg_check_modules("MOZ_ICU", "icu-i18n >= 67.1", when="--with-system-icu")
924 set_config("MOZ_SYSTEM_ICU", True, when=system_icu)
925 set_define("MOZ_SYSTEM_ICU", True, when=system_icu)
927 option("--without-intl-api", help="Disable ECMAScript Internationalization API")
930 @depends("--with-intl-api", js_standalone)
931 def check_intl_api(enabled, js_standalone):
932     if not enabled and not js_standalone:
933         die("--without-intl-api is not supported")
936 set_config("JS_HAS_INTL_API", True, when="--with-intl-api")
937 set_define("JS_HAS_INTL_API", True, when="--with-intl-api")
940 @depends(check_build_environment, when="--with-intl-api")
941 @imports(_from="__builtin__", _import="open")
942 @imports(_from="__builtin__", _import="ValueError")
943 def icu_version(build_env):
944     path = os.path.join(
945         build_env.topsrcdir, "intl", "icu", "source", "common", "unicode", "uvernum.h"
946     )
947     with open(path, encoding="utf-8") as fh:
948         for line in fh:
949             if line.startswith("#define"):
950                 define = line.split(None, 3)
951                 if len(define) == 3 and define[1] == "U_ICU_VERSION_MAJOR_NUM":
952                     try:
953                         return str(int(define[2]))
954                     except ValueError:
955                         pass
956     die("Cannot determine ICU version number from uvernum.h header file")
959 set_config("MOZ_ICU_VERSION", icu_version)
961 # Source files that use ICU should have control over which parts of the ICU
962 # namespace they want to use.
963 set_define("U_USING_ICU_NAMESPACE", "0", when="--with-intl-api")
965 # We build ICU as a static library.
966 set_define("U_STATIC_IMPLEMENTATION", True, when=depends(system_icu)(lambda x: not x))
969 # Initial support for WebAssembly JS-API Type Reflections
970 # =======================================================
973 @depends(milestone.is_nightly)
974 def default_wasm_type_reflections(is_nightly):
975     return is_nightly
978 option(
979     "--enable-wasm-type-reflections",
980     default=default_wasm_type_reflections,
981     help="{Enable|Disable} type reflection in WASM JS-API",
984 set_config(
985     "ENABLE_WASM_TYPE_REFLECTIONS",
986     depends_if("--enable-wasm-type-reflections")(lambda x: True),
988 set_define(
989     "ENABLE_WASM_TYPE_REFLECTIONS",
990     depends_if("--enable-wasm-type-reflections")(lambda x: True),
993 # Support for WebAssembly exceptions
994 # ==================================
997 @depends(milestone.is_nightly, "--enable-wasm-multi-value")
998 def default_wasm_exceptions(is_nightly, multi_value):
999     if multi_value and is_nightly:
1000         return True
1003 option(
1004     "--enable-wasm-exceptions",
1005     default=default_wasm_exceptions,
1006     help="{Enable|Disable} WebAssembly exceptions",
1009 set_config(
1010     "ENABLE_WASM_EXCEPTIONS", depends_if("--enable-wasm-exceptions")(lambda x: True)
1012 set_define(
1013     "ENABLE_WASM_EXCEPTIONS", depends_if("--enable-wasm-exceptions")(lambda x: True)