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":
15 # ==============================================================
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):
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.
43 help="Enable SmooshMonkey (new JS engine frontend)",
47 @depends("--enable-smoosh")
48 def enable_smoosh(value):
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)
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):
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 # ==================================================================
85 "--disable-shared-js",
87 help="{Create|Do not create} a shared library",
91 "--disable-export-js",
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):
101 die("Must export JS symbols when building a shared library.")
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:
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:
124 set_define("STATIC_JS_API", static_js_api)
128 def static_js(value):
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")
142 # =======================================================
144 def jit_default(target):
145 if target.cpu in ("x86", "x86_64", "arm", "aarch64", "mips32", "mips64"):
150 option("--enable-jit", default=jit_default, help="{Enable|Disable} use of the JITs")
153 @deprecated_option("--enable-ion")
154 def report_deprecated(value):
156 die("--enable-ion is deprecated, use --enable-jit instead")
158 die("--disable-ion is deprecated, use --disable-jit instead")
161 # JIT code simulator for cross compiles
162 # =======================================================
164 "--enable-simulator",
165 choices=("arm", "arm64", "mips32", "mips64"),
167 help="Enable a JIT code simulator for the specified architecture",
171 @depends("--enable-jit", "--enable-simulator", target, "--help")
172 def simulator(jit_enabled, simulator_enabled, target, _):
173 if not jit_enabled or not simulator_enabled:
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):
204 return namespace(none=True)
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)
233 # =======================================================
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)
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):
263 set_define("MOZ_CALLGRIND", callgrind)
264 imply_option("--enable-profiling", callgrind)
268 def enable_profiling(milestone):
269 return milestone.is_nightly
273 "--enable-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):
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"
300 if value and ok_cpu and ok_kernel:
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")
318 set_config("MOZ_VTUNE", vtune)
319 set_define("MOZ_VTUNE", vtune)
323 "--enable-gc-probes",
325 help="Turn on probes for allocation and finalization",
329 @depends("--enable-gc-probes")
330 def gc_probes(value):
335 set_define("JS_GC_PROBES", gc_probes)
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.
352 "--enable-small-chunk-size",
353 help="Allocate memory for JS GC things in smaller chunks",
357 "JS_GC_SMALL_CHUNK_SIZE", depends(when="--enable-small-chunk-size")(lambda: True)
362 # =======================================================
364 def default_trace_logging(milestone):
365 return milestone.is_nightly
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 # =======================================================
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")
396 set_define("JS_ION_PERF", ion_perf)
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):
418 if simulator and (debug or spew):
419 if getattr(simulator, "arm", None):
422 if target.cpu == "arm" and (debug or spew):
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):
435 if simulator and (debug or spew):
436 if getattr(simulator, "arm64", None):
439 if target.cpu == "aarch64" and (debug or spew):
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.
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.
466 def is_apple_silicon(target):
467 return target.os == "OSX" and target.kernel == "Darwin" and target.cpu == "aarch64"
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
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:
486 if simulator and getattr(simulator, "arm64", False) and fjcvtzs:
492 set_define("MOZ_AARCH64_JSCVT", aarch64_jscvt)
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):
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 # ==============================================================
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:
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 # ==============================================================
560 milestone.is_nightly,
562 "--enable-simulator",
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":
570 if simulator and simulator[0] == "arm64":
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 # ============================================================
587 "--enable-spidermonkey-telemetry",
588 default=milestone.is_nightly,
589 help="{Enable|Disable} performance telemetry for SpiderMonkey (e.g. compile and run times)",
593 "ENABLE_SPIDERMONKEY_TELEMETRY",
594 depends_if("--enable-spidermonkey-telemetry")(lambda x: True),
597 # Support for debugging code generated by wasm backends
598 # =====================================================
601 "--enable-wasm-codegen-debug",
602 default=depends(when=moz_debug)(lambda: True),
603 help="{Enable|Disable} debugging for wasm codegen",
607 "WASM_CODEGEN_DEBUG", depends_if("--enable-wasm-codegen-debug")(lambda x: True)
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):
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:
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):
654 "--enable-wasm-function-references only possible without --disable-wasm-reftypes"
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:
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):
681 if function_references:
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:
704 "--enable-wasm-private-reftypes",
705 default=default_wasm_private_reftypes,
706 help="{Enable|Disable} WebAssembly private reference types",
710 "WASM_PRIVATE_REFTYPES",
711 depends_if("--enable-wasm-private-reftypes")(lambda x: True),
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 # =====================================================
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):
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 # =====================================================
747 "--disable-shared-memory", help="Disable JS/WebAssembly shared memory and atomics"
751 @depends("--disable-shared-memory")
752 def enable_shared_memory(value):
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):
771 if simulator[0] == "arm64":
776 if target.cpu in ("x86_64", "x86", "aarch64"):
781 "--enable-wasm-simd",
782 default=default_wasm_simd,
783 help="{Enable|Disable} WebAssembly SIMD",
787 @depends("--enable-wasm-simd", "--enable-jit", "--enable-simulator", target)
788 def wasm_simd(value, jit_enabled, simulator, target):
796 if simulator[0] == "arm64":
801 if target.cpu in ("x86_64", "x86", "aarch64"):
804 die("--enable-wasm-simd only possible when targeting the x86_64/x86/arm64 jits")
807 set_config("ENABLE_WASM_SIMD", wasm_simd)
808 set_define("ENABLE_WASM_SIMD", wasm_simd)
810 # Experimental SIMD opcodes are Nightly-only by default
813 @depends(milestone.is_nightly, "--enable-wasm-simd")
814 def default_wasm_simd_experimental(is_nightly, wasm_simd):
815 if is_nightly and wasm_simd:
820 "--enable-wasm-simd-experimental",
821 default=default_wasm_simd_experimental,
822 help="{Enable|Disable} WebAssembly SIMD experimental opcodes",
826 @depends("--enable-wasm-simd-experimental", "--enable-wasm-simd")
827 def wasm_simd_experimental(value, wasm_simd):
834 die("--enable-wasm-simd-experimental only possible with --enable-wasm-simd")
837 set_config("ENABLE_WASM_SIMD_EXPERIMENTAL", wasm_simd_experimental)
838 set_define("ENABLE_WASM_SIMD_EXPERIMENTAL", wasm_simd_experimental)
840 # Wormhole opcodes are experimental *and* x64-only
843 @depends("--enable-wasm-simd-experimental", target)
844 def default_wasm_simd_wormhole(wasm_simd_experimental, target):
845 if wasm_simd_experimental and target.cpu == "x86_64":
850 "--enable-wasm-simd-wormhole",
851 default=default_wasm_simd_wormhole,
852 help="{Enable|Disable} WebAssembly SIMD wormhole opcodes",
856 @depends("--enable-wasm-simd-wormhole", "--enable-wasm-simd-experimental", target)
857 def wasm_simd_wormhole(value, wasm_simd_experimental, target):
861 if not wasm_simd_experimental:
862 die("SIMD wormhole also requires --enable-wasm-simd-experimental.")
864 if target.cpu != "x86_64":
865 die("SIMD wormhole is only available on x86_64.")
870 set_config("ENABLE_WASM_SIMD_WORMHOLE", wasm_simd_wormhole)
871 set_define("ENABLE_WASM_SIMD_WORMHOLE", wasm_simd_wormhole)
874 # Options for generating the shell as a script
875 # ============================================
876 option("--with-qemu-exe", nargs=1, help="Use path as an arm emulator on host platforms")
877 set_config("QEMU_EXE", depends_if("--with-qemu-exe")(lambda x: x))
882 default=depends(target.alias)(lambda x: "/usr/%s" % x),
883 help="Use dir as the location for arm libraries",
885 set_config("CROSS_LIB", depends_if("--with-cross-lib")(lambda x: x))
887 # Enable static checking using sixgill
888 # ====================================
890 option("--with-sixgill", nargs=1, help="Enable static checking of code using sixgill")
893 @depends_if("--with-sixgill")
896 for f in ("bin/xdbfind", "gcc/xgill.so", "scripts/wrap_gcc/g++"):
897 if not os.path.exists(os.path.join(value[0], f)):
898 die("The sixgill plugin and binaries are not at the specified path")
902 set_config("SIXGILL_PATH", sixgill)
905 # Support for readline
906 # =====================================================
907 @depends("--enable-js-shell", target_is_windows, compile_environment)
908 def editline(js_shell, is_windows, compile_environment):
909 return js_shell and not is_windows and compile_environment
913 "--enable-readline", help="Link js shell to system readline library", when=editline
916 has_readline = check_symbol(
918 flags=["-lreadline"],
919 when="--enable-readline",
920 onerror=lambda: die("No system readline library found"),
923 set_config("EDITLINE_LIBS", ["-lreadline"], when=has_readline)
926 @depends("--enable-readline", editline, when=editline)
927 def bundled_editline(readline, editline):
928 return editline and not readline
931 set_config("JS_BUNDLED_EDITLINE", bundled_editline)
933 set_define("EDITLINE", True, when=editline)
940 "--with-jitreport-granularity",
942 choices=("0", "1", "2", "3"),
943 help="Default granularity at which to report JIT code to external tools "
944 "(0 - no info, 1 - code ranges for while functions only, "
945 "2 - per-line information, 3 - per-op information)",
949 "JS_DEFAULT_JITREPORT_GRANULARITY",
950 depends_if("--with-jitreport-granularity")(lambda value: value[0]),
954 # ECMAScript Internationalization API Support (uses ICU)
955 # ======================================================
956 option("--with-system-icu", help="Use system ICU")
958 system_icu = pkg_check_modules("MOZ_ICU", "icu-i18n >= 67.1", when="--with-system-icu")
960 set_config("MOZ_SYSTEM_ICU", True, when=system_icu)
961 set_define("MOZ_SYSTEM_ICU", True, when=system_icu)
963 option("--without-intl-api", help="Disable ECMAScript Internationalization API")
966 @depends("--with-intl-api", js_standalone)
967 def check_intl_api(enabled, js_standalone):
968 if not enabled and not js_standalone:
969 die("--without-intl-api is not supported")
972 set_config("JS_HAS_INTL_API", True, when="--with-intl-api")
973 set_define("JS_HAS_INTL_API", True, when="--with-intl-api")
976 @depends(check_build_environment, when="--with-intl-api")
977 @imports(_from="__builtin__", _import="open")
978 @imports(_from="__builtin__", _import="ValueError")
979 def icu_version(build_env):
981 build_env.topsrcdir, "intl", "icu", "source", "common", "unicode", "uvernum.h"
983 with open(path, encoding="utf-8") as fh:
985 if line.startswith("#define"):
986 define = line.split(None, 3)
987 if len(define) == 3 and define[1] == "U_ICU_VERSION_MAJOR_NUM":
989 return str(int(define[2]))
992 die("Cannot determine ICU version number from uvernum.h header file")
995 set_config("MOZ_ICU_VERSION", icu_version)
997 # Source files that use ICU should have control over which parts of the ICU
998 # namespace they want to use.
999 set_define("U_USING_ICU_NAMESPACE", "0", when="--with-intl-api")
1001 # We build ICU as a static library.
1002 set_define("U_STATIC_IMPLEMENTATION", True, when=depends(system_icu)(lambda x: not x))
1005 @depends(yasm, gnu_as, target, compile_environment)
1006 def can_build_data_file(yasm, gnu_as, target, compile_environment):
1007 if not compile_environment or (
1008 target.kernel == "WINNT" and target.cpu == "aarch64"
1011 if not yasm and not gnu_as:
1013 "Building ICU requires either yasm or a GNU assembler. If you do not have "
1014 "either of those available for this platform you must use --without-intl-api"
1018 # Initial support for WebAssembly JS-API Type Reflections
1019 # =======================================================
1022 @depends(milestone.is_nightly)
1023 def default_wasm_type_reflections(is_nightly):
1028 "--enable-wasm-type-reflections",
1029 default=default_wasm_type_reflections,
1030 help="{Enable|Disable} type reflection in WASM JS-API",
1034 "ENABLE_WASM_TYPE_REFLECTIONS",
1035 depends_if("--enable-wasm-type-reflections")(lambda x: True),
1038 "ENABLE_WASM_TYPE_REFLECTIONS",
1039 depends_if("--enable-wasm-type-reflections")(lambda x: True),
1042 # Support for WebAssembly exceptions
1043 # ==================================
1046 @depends(milestone.is_nightly, "--enable-wasm-multi-value")
1047 def default_wasm_exceptions(is_nightly, multi_value):
1048 if multi_value and is_nightly:
1053 "--enable-wasm-exceptions",
1054 default=default_wasm_exceptions,
1055 help="{Enable|Disable} WebAssembly exceptions",
1059 "ENABLE_WASM_EXCEPTIONS", depends_if("--enable-wasm-exceptions")(lambda x: True)
1062 "ENABLE_WASM_EXCEPTIONS", depends_if("--enable-wasm-exceptions")(lambda x: True)