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 include("build/moz.configure/init.configure")
10 # - Gecko-specific options and rules should go in toolkit/moz.configure.
11 # - Firefox-specific options and rules should go in browser/moz.configure.
12 # - Fennec-specific options and rules should go in
13 # mobile/android/moz.configure.
14 # - Spidermonkey-specific options and rules should go in js/moz.configure.
18 "--enable-artifact-build-symbols",
19 depends(artifact_builds)(lambda v: False if v is None else None),
20 reason="--disable-artifact-builds",
24 "--enable-artifact-build-symbols",
27 help="Download symbols when artifact builds are enabled.",
31 @depends("--enable-artifact-build-symbols", "MOZ_AUTOMATION", target)
32 def enable_artifact_build_symbols(value, automation, target):
36 if target.os == "Android" and not automation:
42 set_config("MOZ_ARTIFACT_BUILD_SYMBOLS", enable_artifact_build_symbols)
45 @depends("--enable-artifact-builds")
46 def imply_disable_compile_environment(value):
53 help="For builds that do not support symbols in the normal fashion,"
54 " generate and copy them into the resulting build archive.",
57 set_config("MOZ_COPY_PDBS", depends_if("MOZ_COPY_PDBS")(lambda _: True))
59 imply_option("--enable-compile-environment", imply_disable_compile_environment)
61 option("--disable-compile-environment", help="Disable compiler/library checks")
64 @depends("--disable-compile-environment")
65 def compile_environment(compile_env):
70 set_config("COMPILE_ENVIRONMENT", compile_environment)
71 add_old_configure_assignment("COMPILE_ENVIRONMENT", compile_environment)
73 option("--disable-tests", help="Do not build test libraries & programs")
76 @depends("--disable-tests")
77 def enable_tests(value):
82 set_config("ENABLE_TESTS", enable_tests)
83 set_define("ENABLE_TESTS", enable_tests)
86 @depends(enable_tests)
87 def gtest_has_rtti(value):
92 set_define("GTEST_HAS_RTTI", gtest_has_rtti)
95 @depends(target, enable_tests)
96 def linux_gtest_defines(target, enable_tests):
97 if enable_tests and target.os == "Android":
98 return namespace(os_linux_android=True, use_own_tr1_tuple=True, has_clone="0")
101 set_define("GTEST_OS_LINUX_ANDROID", linux_gtest_defines.os_linux_android)
102 set_define("GTEST_USE_OWN_TR1_TUPLE", linux_gtest_defines.use_own_tr1_tuple)
103 set_define("GTEST_HAS_CLONE", linux_gtest_defines.has_clone)
108 help="Enable building with developer debug info "
109 "(using the given compiler flags).",
113 @depends("--enable-debug")
114 def moz_debug(debug):
119 set_config("MOZ_DEBUG", moz_debug)
120 set_define("MOZ_DEBUG", moz_debug)
121 # Override any value MOZ_DEBUG may have from the environment when passing it
122 # down to old-configure.
123 add_old_configure_assignment("MOZ_DEBUG", depends("--enable-debug")(lambda x: bool(x)))
126 "MOZ_DIAGNOSTIC_ASSERT_ENABLED",
128 when=moz_debug | milestone.is_early_beta_or_earlier,
131 "MOZ_DIAGNOSTIC_ASSERT_ENABLED",
133 when=moz_debug | milestone.is_early_beta_or_earlier,
137 "--with-debug-label",
139 help="Debug DEBUG_<value> for each comma-separated value given",
143 @depends(moz_debug, "--with-debug-label")
144 def debug_defines(debug, labels):
146 return ["DEBUG"] + ["DEBUG_%s" % label for label in labels]
147 return ["NDEBUG", "TRIMMED"]
150 set_config("MOZ_DEBUG_DEFINES", debug_defines)
152 option(env="MOZ_PGO", help="Build with profile guided optimizations")
154 set_config("MOZ_PGO", depends("MOZ_PGO")(lambda x: bool(x)))
157 # Imply --enable-release when MOZILLA_OFFICIAL is set rather than adjusting the
158 # default so that we can't have both MOZILLA_OFFICIAL and --disable-release set.
159 imply_option("--enable-release", mozilla_official)
163 default=milestone.is_release_or_beta | depends("MOZ_AUTOMATION")(lambda x: bool(x)),
164 help="{Build|Do not build} with more conservative, release "
165 "engineering-oriented options.{ This may slow down builds.|}",
169 @depends("--enable-release")
170 def developer_options(value):
175 add_old_configure_assignment("DEVELOPER_OPTIONS", developer_options)
176 set_config("DEVELOPER_OPTIONS", developer_options)
179 # hybrid build handling
180 # ==============================================================
183 "--disable-unified-build",
184 help="Enable building modules in non unified context",
187 set_config("ENABLE_UNIFIED_BUILD", True, when="--disable-unified-build")
190 include("build/moz.configure/bootstrap.configure")
193 # The execution model of the configure sandbox doesn't allow for
194 # check_prog to use bootstrap_search_path directly because check_prog
195 # comes first, so we use a trick to allow it. Uses of check_prog
196 # happening before here won't allow bootstrap.
198 def check_prog(*args, **kwargs):
199 kwargs["bootstrap_search_path"] = bootstrap_search_path
200 return check_prog(*args, **kwargs)
203 check_prog("WGET", ("wget",), allow_missing=True)
206 include("build/moz.configure/toolchain.configure", when="--enable-compile-environment")
208 include("build/moz.configure/pkg.configure")
209 # Make this assignment here rather than in pkg.configure to avoid
210 # requiring this file in unit tests.
211 add_old_configure_assignment("PKG_CONFIG", pkg_config)
213 include("build/moz.configure/memory.configure", when="--enable-compile-environment")
214 include("build/moz.configure/headers.configure", when="--enable-compile-environment")
215 include("build/moz.configure/warnings.configure", when="--enable-compile-environment")
216 include("build/moz.configure/flags.configure", when="--enable-compile-environment")
217 include("build/moz.configure/lto-pgo.configure", when="--enable-compile-environment")
218 # rust.configure is included by js/moz.configure.
220 option("--enable-valgrind", help="Enable Valgrind integration hooks")
222 valgrind_h = check_header("valgrind/valgrind.h", when="--enable-valgrind")
225 @depends("--enable-valgrind", valgrind_h)
226 def check_valgrind(valgrind, valgrind_h):
229 die("--enable-valgrind specified but Valgrind is not installed")
233 set_define("MOZ_VALGRIND", check_valgrind)
234 set_config("MOZ_VALGRIND", check_valgrind)
237 @depends(target, host)
238 def is_openbsd(target, host):
239 return target.kernel == "OpenBSD" or host.kernel == "OpenBSD"
247 help="Shared library version for OpenBSD systems",
251 @depends("SO_VERSION", when=is_openbsd)
252 def so_version(value):
257 def library_name_info_template(host_or_target):
258 assert host_or_target in {host, target}
260 host: host_windows_abi,
261 target: target_windows_abi,
264 @depends(host_or_target, host_or_target.abi | windows_abi, so_version)
265 def library_name_info_impl(host_or_target, windows_abi, so_version):
266 if host_or_target.kernel == "WINNT":
267 # There aren't artifacts for mingw builds, so it's OK that the
268 # results are inaccurate in that case.
269 if windows_abi and windows_abi != "msvc":
271 dll=namespace(prefix="", suffix=".dll"),
272 lib=namespace(prefix="lib", suffix="a"),
273 import_lib=namespace(prefix="lib", suffix="a"),
274 obj=namespace(prefix="", suffix="o"),
278 dll=namespace(prefix="", suffix=".dll"),
279 lib=namespace(prefix="", suffix="lib"),
280 import_lib=namespace(prefix="", suffix="lib"),
281 obj=namespace(prefix="", suffix="obj"),
284 elif host_or_target.kernel == "Darwin":
286 dll=namespace(prefix="lib", suffix=".dylib"),
287 lib=namespace(prefix="lib", suffix="a"),
288 import_lib=namespace(prefix=None, suffix=""),
289 obj=namespace(prefix="", suffix="o"),
292 so = ".so.%s" % so_version
297 dll=namespace(prefix="lib", suffix=so),
298 lib=namespace(prefix="lib", suffix="a"),
299 import_lib=namespace(prefix=None, suffix=""),
300 obj=namespace(prefix="", suffix="o"),
303 return library_name_info_impl
306 host_library_name_info = library_name_info_template(host)
307 library_name_info = library_name_info_template(target)
309 set_config("DLL_PREFIX", library_name_info.dll.prefix)
310 set_config("DLL_SUFFIX", library_name_info.dll.suffix)
311 set_config("HOST_DLL_PREFIX", host_library_name_info.dll.prefix)
312 set_config("HOST_DLL_SUFFIX", host_library_name_info.dll.suffix)
313 set_config("LIB_PREFIX", library_name_info.lib.prefix)
314 set_config("LIB_SUFFIX", library_name_info.lib.suffix)
315 set_config("OBJ_SUFFIX", library_name_info.obj.suffix)
316 # Lots of compilation tests depend on this variable being present.
317 add_old_configure_assignment("OBJ_SUFFIX", library_name_info.obj.suffix)
318 set_config("IMPORT_LIB_SUFFIX", library_name_info.import_lib.suffix)
320 "MOZ_DLL_PREFIX", depends(library_name_info.dll.prefix)(lambda s: '"%s"' % s)
323 "MOZ_DLL_SUFFIX", depends(library_name_info.dll.suffix)(lambda s: '"%s"' % s)
325 set_config("HOST_LIB_PREFIX", host_library_name_info.lib.prefix)
326 set_config("HOST_IMPORT_LIB_SUFFIX", host_library_name_info.import_lib.suffix)
327 set_config("WASM_OBJ_SUFFIX", "wasm")
329 # Make `profiling` available to this file even when js/moz.configure
330 # doesn't end up included.
331 profiling = dependable(False)
332 # Same for js_standalone
333 js_standalone = dependable(False)
334 js_shared = dependable(False)
335 moz_linker = dependable(False)
337 fold_libs = dependable(False)
339 dmd = dependable(False)
341 include(include_project_configure)
345 @imports(_from="mozbuild.backend", _import="backends")
346 def build_backends_choices(_):
347 return tuple(backends)
350 @deprecated_option("--enable-build-backend", nargs="+", choices=build_backends_choices)
351 def build_backend(backends):
353 return tuple("+%s" % b for b in backends)
356 imply_option("--build-backends", build_backend)
362 "--enable-artifact-builds",
363 "--disable-compile-environment",
365 "--enable-application",
369 def build_backend_defaults(
379 project = application[0]
384 all_backends = ["FasterMake+RecursiveMake"]
386 all_backends = ["RecursiveMake", "FasterMake"]
389 and target.os == "WINNT"
390 and compile_environment
391 and project not in ("mobile/android", "memory", "tools/update-programs")
393 all_backends.append("VisualStudio")
394 if compile_environment and project not in ("memory", "tools/update-programs"):
395 all_backends.append("Clangd")
396 return tuple(all_backends) or None
402 default=build_backend_defaults,
403 choices=build_backends_choices,
404 help="Build backends to generate",
408 @depends("--build-backends")
409 def build_backends(backends):
413 set_config("BUILD_BACKENDS", build_backends)
416 # Determine whether to build the gtest xul. This happens in automation
417 # on Android and Desktop platforms with the exception of:
418 # - Windows PGO, where linking xul-gtest.dll takes too long;
419 # - Android other than x86_64, where gtest is not required.
425 when="--enable-compile-environment",
427 def build_gtest(build_project, target, automation, enable_tests):
431 and build_project in ("browser", "comm/mail", "mobile/android")
432 and not (target.os == "Android" and target.cpu != "x86_64")
437 "--enable-gtest-in-build",
439 help="{Enable|Force disable} building the gtest libxul during the build.",
440 when="--enable-compile-environment",
443 set_config("LINK_GTEST_DURING_COMPILE", True, when="--enable-gtest-in-build")
446 # ==============================================================
448 "--enable-ui-locale",
450 help="Select the user interface locale (default: en-US)",
453 set_config("MOZ_UI_LOCALE", depends("--enable-ui-locale")(lambda x: x))
457 help="An experiment to use ICU4X instead of ICU4C. See intl/ICU4X.md",
460 set_config("MOZ_ICU4X", True, when="--enable-icu4x")
462 # clang-plugin location
463 # ==============================================================
466 @depends(host_library_name_info, build_environment, when="--enable-clang-plugin")
467 def clang_plugin_path(library_name_info, build_env):
468 topobjdir = build_env.topobjdir
469 if topobjdir.endswith("/js/src"):
470 topobjdir = topobjdir[:-7]
471 return os.path.abspath(
477 % (library_name_info.dll.prefix, library_name_info.dll.suffix),
482 set_config("CLANG_PLUGIN", clang_plugin_path)
483 add_old_configure_assignment("CLANG_PLUGIN", clang_plugin_path)
487 # ==============================================================
488 awk = check_prog("AWK", ("gawk", "mawk", "nawk", "awk"), paths=prefer_mozillabuild_path)
490 # Until the AWK variable is not necessary in old-configure
494 def awk_for_old_configure(value):
498 add_old_configure_assignment("AWK", awk_for_old_configure)
502 # ==============================================================
503 perl = check_prog("PERL", ("perl5", "perl"))
505 # Until the PERL variable is not necessary in old-configure
509 def perl_for_old_configure(value):
513 add_old_configure_assignment("PERL", perl_for_old_configure)
517 def perl_version_check(min_version):
519 @checking("for minimum required perl version >= %s" % min_version)
520 def get_perl_version(perl):
526 onerror=lambda: die("Failed to get perl version."),
530 @depends(get_perl_version)
531 def check_perl_version(version):
532 if version < min_version:
533 die("Perl %s or higher is required.", min_version)
536 @checking("for full perl installation")
537 @imports("subprocess")
538 def has_full_perl_installation(perl):
539 ret = subprocess.call([perl, "-e", "use Config; exit(!-d $Config{archlib})"])
542 @depends(has_full_perl_installation)
543 def require_full_perl_installation(has_full_perl_installation):
544 if not has_full_perl_installation:
546 "Cannot find Config.pm or $Config{archlib}. "
547 "A full perl installation is required."
551 perl_version_check("5.006")
555 # ==============================================================
556 option(env="MAKE", nargs=1, help="Path to GNU make")
559 @depends("MAKE", host)
560 def possible_makes(make, host):
563 candidates.append(make[0])
564 if host.kernel == "WINNT":
565 candidates.extend(("mozmake", "mingw32-make", "make", "gmake"))
567 candidates.extend(("gmake", "make"))
571 check_prog("GMAKE", possible_makes, bootstrap="mozmake")
574 # ==============================================================
576 option(env="WATCHMAN", nargs=1, help="Path to the watchman program")
579 @depends(host, "WATCHMAN")
580 @checking("for watchman", callback=lambda w: w.path if w else "not found")
581 def watchman(host, prog):
582 # On Windows, `watchman` is only supported on 64-bit hosts.
583 if host.os == "WINNT" and host.cpu != "x86_64":
587 prog = find_program("watchman")
592 # `watchman version` will talk to the Watchman daemon service.
593 # This can hang due to permissions problems. e.g.
594 # https://github.com/facebook/watchman/issues/376. So use
595 # `watchman --version` to prevent a class of failures.
596 out = check_cmd_output(prog, "--version", onerror=lambda: None)
600 return namespace(path=prog, version=Version(out.strip()))
603 @depends_if(watchman)
604 @checking("for watchman version")
605 def watchman_version(w):
609 set_config("WATCHMAN", watchman.path)
612 @depends_all(hg_version, hg_config, watchman)
613 @checking("for watchman Mercurial integration")
615 def watchman_hg(hg_version, hg_config, watchman):
616 if hg_version < Version("3.8"):
617 return "no (Mercurial 3.8+ required)"
620 mode_disabled = False
622 for k in ("extensions.fsmonitor", "extensions.hgext.fsmonitor"):
623 if k in hg_config and hg_config[k] != "!":
626 mode_disabled = hg_config.get("fsmonitor.mode") == "off"
629 return "no (fsmonitor extension not enabled)"
631 return "no (fsmonitor.mode=off disables fsmonitor)"
636 # Miscellaneous programs
637 # ==============================================================
638 check_prog("XARGS", ("xargs",))
642 def extra_programs(target):
643 if target.kernel == "Darwin":
645 DSYMUTIL=("dsymutil", "llvm-dsymutil"),
646 MKFSHFS=("newfs_hfs", "mkfs.hfsplus"),
647 HFS_TOOL=("hfsplus",),
649 if target.os == "GNU" and target.kernel == "Linux":
650 return namespace(RPMBUILD=("rpmbuild",))
653 check_prog("DSYMUTIL", extra_programs.DSYMUTIL, allow_missing=True)
654 check_prog("MKFSHFS", extra_programs.MKFSHFS, allow_missing=True)
655 check_prog("HFS_TOOL", extra_programs.HFS_TOOL, allow_missing=True)
656 check_prog("RPMBUILD", extra_programs.RPMBUILD, allow_missing=True)
662 bootstrap="nsis/bin",
664 when=target_is_windows,
667 # Make sure the version of makensis is up to date.
671 @checking("for NSIS version")
673 def nsis_version(nsis):
674 nsis_min_version = "3.0b1"
677 return die("Failed to get nsis version.")
679 out = check_cmd_output(nsis, "-version", onerror=onerror)
681 m = re.search(r"(?<=v)[0-9]+\.[0-9]+((a|b|rc)[0-9]+)?", out)
684 raise FatalCheckError("Unknown version of makensis")
685 ver = Version(m.group(0))
687 # Versions comparisons don't quite work well with beta versions, so ensure
688 # it works for the non-beta version.
689 if ver < nsis_min_version and (ver >= "3.0a" or ver < "3"):
690 raise FatalCheckError(
691 "To build the installer you must have NSIS"
692 " version %s or greater in your path" % nsis_min_version
698 # And that makensis is 32-bit (but only on Windows).
699 @depends_if(nsis, when=depends(host)(lambda h: h.kernel == "WINNT"))
700 @checking("for 32-bit NSIS")
701 def nsis_binary_type(nsis):
702 bin_type = windows_binary_type(nsis)
703 if bin_type != "win32":
704 raise FatalCheckError("%s is not a 32-bit Windows application" % nsis)
709 # And any flags we have to give to makensis
711 def nsis_flags(host):
712 if host.kernel != "WINNT":
717 set_config("MAKENSISU_FLAGS", nsis_flags)
719 check_prog("7Z", ("7z", "7za"), allow_missing=True, when=target_is_windows)
720 check_prog("UPX", ("upx",), allow_missing=True, when=target_is_windows)
725 @depends(host_c_compiler, c_compiler, bindgen_config_paths)
726 def llvm_tool(host_c_compiler, c_compiler, bindgen_config_paths):
728 for compiler in (host_c_compiler, c_compiler):
729 if compiler and compiler.type == "clang":
730 clang = compiler.compiler
732 elif compiler and compiler.type == "clang-cl":
733 clang = os.path.join(os.path.dirname(compiler.compiler), "clang")
736 if not clang and bindgen_config_paths:
737 clang = bindgen_config_paths.clang_path
740 out = check_cmd_output(
741 clang, "--print-prog-name=%s" % tool, onerror=lambda: None
750 llvm_objdump = check_prog(
752 llvm_tool("llvm-objdump"),
754 when="--enable-compile-environment",
755 paths=clang_search_path,
758 add_old_configure_assignment("LLVM_OBJDUMP", llvm_objdump)
761 @depends(llvm_tool("llvm-readelf"), toolchain_prefix)
762 def readelf(llvm_readelf, toolchain_prefix):
763 commands = [llvm_readelf[0], "readelf"]
764 for prefix in toolchain_prefix or ():
765 commands.insert(1, "%sreadelf" % prefix)
766 return tuple(commands)
769 def validate_readelf(path):
770 # llvm-readelf from llvm < 8 doesn't support the GNU binutils-compatible `-d`
771 # flag. We could try running `$path -d $some_binary` but we might be cross
772 # compiling and not have a binary at hand to run that against. `$path -d` alone
773 # would fail whether the flag is supported or not. So we resort to look for the
774 # option in the `--help` output, which fortunately, s compatible between
775 # llvm-readelf and readelf.
776 retcode, stdout, stderr = get_cmd_output(path, "--help")
777 return retcode == 0 and any(l.startswith(" -d ") for l in stdout.splitlines())
780 @depends("--enable-compile-environment", target, host)
781 def readelf_when(compile_env, target, host):
782 return compile_env and any(
783 x.kernel not in ("Darwin", "WINNT") for x in (target, host)
791 paths=clang_search_path,
792 validate=validate_readelf,
796 @depends(llvm_tool("llvm-objcopy"), toolchain_prefix)
797 def objcopy(llvm_objcopy, toolchain_prefix):
798 commands = [llvm_objcopy[0], "objcopy"]
799 for prefix in toolchain_prefix or ():
800 commands.insert(1, "%sreadelf" % prefix)
801 return tuple(commands)
804 def validate_objcopy(path):
805 if "llvm-objcopy" not in path:
807 # llvm-objcopy doesn't support --only-keep-debug before llvm 9.0.
808 retcode, stdout, stderr = get_cmd_output(path, "--help")
809 return retcode == 0 and any(
810 l.startswith(" --only-keep-debug ") for l in stdout.splitlines()
818 paths=clang_search_path,
819 validate=validate_objcopy,
822 option("--enable-dtrace", help="Build with dtrace support")
824 dtrace = check_header(
826 when="--enable-dtrace",
827 onerror=lambda: die("dtrace enabled but sys/sdt.h not found"),
830 set_config("HAVE_DTRACE", True, when=dtrace)
831 set_define("INCLUDE_MOZILLA_DTRACE", True, when=dtrace)
832 add_old_configure_assignment("enable_dtrace", "yes", when=dtrace)
835 option("--disable-icf", help="Disable Identical Code Folding")
837 add_old_configure_assignment(
838 "MOZ_DISABLE_ICF", "1", when=depends("--enable-icf")(lambda x: not x)
844 when=compile_environment,
845 help="Enable stripping of libs & executables",
848 # This should be handled as a `when` once bug 1617793 is fixed.
851 @depends("--enable-strip", c_compiler, when=compile_environment)
852 def enable_strip(strip, c_compiler):
853 if strip and c_compiler.type != "clang-cl":
857 set_config("ENABLE_STRIP", enable_strip)
860 "--disable-install-strip",
861 when=compile_environment,
862 help="Enable stripping of libs & executables when packaging",
865 # This should be handled as a `when` once bug 1617793 is fixed.
868 @depends("--enable-install-strip", c_compiler, when=compile_environment)
869 def enable_install_strip(strip, c_compiler):
870 if strip and c_compiler.type != "clang-cl":
874 set_config("PKG_STRIP", enable_install_strip)
877 @depends("--enable-strip", "--enable-install-strip", when=compile_environment)
878 def strip(strip, install_strip):
879 return strip or install_strip
882 option(env="STRIP_FLAGS", nargs=1, when=strip, help="Flags for the strip command")
885 @depends("STRIP_FLAGS", profiling, target, when=strip)
886 def strip_flags(flags, profiling, target):
888 return flags[0].split()
890 # Only strip debug info and symbols when profiling is enabled, keeping
892 if target.kernel == "Darwin":
894 elif target.os == "Android":
895 # The tooling we use with Android supports detached symbols, and the
896 # size increase caused by local symbols are too much for mobile. So,
897 # don't restrict the amount of stripping with a flag.
900 return ["--strip-debug"]
901 # Otherwise strip everything we can, which happens without flags on non-Darwin.
902 # On Darwin, it tries to strip things it can't, so we need to limit its scope.
903 elif target.kernel == "Darwin":
907 set_config("STRIP_FLAGS", strip_flags)
910 @depends(llvm_tool("llvm-strip"), toolchain_prefix, target)
911 def strip(llvm_strip, toolchain_prefix, target):
913 for prefix in toolchain_prefix or ():
914 commands.insert(0, "%sstrip" % prefix)
915 # llvm-strip causes some problems on macos targets.
916 if target.kernel == "Darwin":
917 commands.append(llvm_strip[0])
919 commands.insert(0, llvm_strip[0])
920 return tuple(commands)
923 def validate_strip(path):
924 if "llvm-strip" not in path:
926 # llvm-strip doesn't support -S before llvm 8.0.
927 retcode, stdout, stderr = get_cmd_output(path, "--help")
928 return retcode == 0 and any(l.startswith(" -S ") for l in stdout.splitlines())
931 @depends("--enable-compile-environment", target, host)
932 def strip_when(compile_env, target, host):
933 return compile_env and any(x.kernel != "WINNT" for x in (target, host))
940 paths=clang_search_path,
941 validate=validate_strip,
945 @depends(js_standalone, target)
946 def system_zlib_default(js_standalone, target):
949 and target.kernel not in ("WINNT", "Darwin")
950 and target.os != "Android"
955 "--with-system-zlib",
957 default=system_zlib_default,
958 help="{Use|Do not use} system libz",
962 @depends("--with-system-zlib")
963 def deprecated_system_zlib_path(value):
966 "--with-system-zlib=PATH is not supported anymore. Please use "
967 "--with-system-zlib and set any necessary pkg-config environment variable."
971 pkg_check_modules("MOZ_ZLIB", "zlib >= 1.2.3", when="--with-system-zlib")
973 set_config("MOZ_SYSTEM_ZLIB", True, when="--with-system-zlib")
976 @depends("--with-system-zlib", js_shared, moz_linker, target.os)
977 def zlib_in_mozglue(system_zlib, js_shared, linker, os):
978 if not system_zlib and (js_shared or linker or os == "Android"):
982 set_config("ZLIB_IN_MOZGLUE", zlib_in_mozglue)
983 set_define("ZLIB_IN_MOZGLUE", zlib_in_mozglue)
986 # Please do not add configure checks from here on.
988 # Fallthrough to autoconf-based configure
989 include("build/moz.configure/old.configure")
992 include("js/sub.configure", when=compile_environment & toolkit)
995 @depends(build_environment, configure_cache)
996 @imports(_import="json")
997 @imports(_from="pathlib", _import="Path")
998 def save_cache(build_environment, configure_cache):
999 cache_file = Path(build_environment.topobjdir) / "configure.cache"
1001 with cache_file.open(mode="w") as fd:
1002 json.dump(configure_cache, fd, indent=4)
1005 @depends(build_environment, build_project)
1006 @imports("__sandbox__")
1008 @imports(_from="os.path", _import="exists")
1009 def config_status_deps(build_env, build_project):
1011 topsrcdir = build_env.topsrcdir
1012 topobjdir = build_env.topobjdir
1014 if not topobjdir.endswith("js/src"):
1015 extra_deps = [os.path.join(topobjdir, ".mozconfig.json")]
1017 # mozconfig changes may impact js configure.
1018 extra_deps = [os.path.join(topobjdir[:-7], ".mozconfig.json")]
1020 confvars = os.path.join(topsrcdir, build_project, "confvars.sh")
1021 if exists(confvars):
1022 extra_deps.append(confvars)
1025 list(__sandbox__._all_paths)
1028 os.path.join(topsrcdir, "CLOBBER"),
1029 os.path.join(topsrcdir, "configure"),
1030 os.path.join(topsrcdir, "js", "src", "configure"),
1031 os.path.join(topsrcdir, "nsprpub", "configure"),
1032 os.path.join(topsrcdir, "config", "milestone.txt"),
1033 os.path.join(topsrcdir, "browser", "config", "version.txt"),
1034 os.path.join(topsrcdir, "browser", "config", "version_display.txt"),
1035 os.path.join(topsrcdir, "python", "sites", "build.txt"),
1036 os.path.join(topsrcdir, "python", "sites", "common.txt"),
1037 os.path.join(topsrcdir, "python", "sites", "mach.txt"),
1038 os.path.join(topsrcdir, "python", "mach", "mach", "site.py"),
1039 os.path.join(topsrcdir, "aclocal.m4"),
1040 os.path.join(topsrcdir, "old-configure.in"),
1041 os.path.join(topsrcdir, "js", "src", "aclocal.m4"),
1042 os.path.join(topsrcdir, "js", "src", "old-configure.in"),
1044 + glob.glob(os.path.join(topsrcdir, "build", "autoconf", "*.m4"))
1048 set_config("CONFIG_STATUS_DEPS", config_status_deps)
1049 # Please do not add anything after setting config_dep_paths.