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-builds",
19 env="MOZ_ARTIFACT_BUILDS",
20 help="Download and use prebuilt binary artifacts.",
24 @depends("--enable-artifact-builds")
25 def artifact_builds(value):
30 set_config("MOZ_ARTIFACT_BUILDS", artifact_builds)
33 "--enable-artifact-build-symbols",
34 depends(artifact_builds)(lambda v: False if v is None else None),
35 reason="--disable-artifact-builds",
39 "--enable-artifact-build-symbols",
42 help="Download symbols when artifact builds are enabled.",
46 @depends("--enable-artifact-build-symbols", "MOZ_AUTOMATION", target)
47 def enable_artifact_build_symbols(value, automation, target):
51 if target.os == "Android" and not automation:
57 set_config("MOZ_ARTIFACT_BUILD_SYMBOLS", enable_artifact_build_symbols)
60 @depends("--enable-artifact-builds")
61 def imply_disable_compile_environment(value):
68 help="For builds that do not support symbols in the normal fashion,"
69 " generate and copy them into the resulting build archive.",
72 set_config("MOZ_COPY_PDBS", depends_if("MOZ_COPY_PDBS")(lambda _: True))
74 imply_option("--enable-compile-environment", imply_disable_compile_environment)
76 option("--disable-compile-environment", help="Disable compiler/library checks")
79 @depends("--disable-compile-environment")
80 def compile_environment(compile_env):
85 set_config("COMPILE_ENVIRONMENT", compile_environment)
86 add_old_configure_assignment("COMPILE_ENVIRONMENT", compile_environment)
88 option("--disable-tests", help="Do not build test libraries & programs")
91 @depends("--disable-tests")
92 def enable_tests(value):
97 set_config("ENABLE_TESTS", enable_tests)
98 set_define("ENABLE_TESTS", enable_tests)
101 @depends(enable_tests)
102 def gtest_has_rtti(value):
107 set_define("GTEST_HAS_RTTI", gtest_has_rtti)
110 @depends(target, enable_tests)
111 def linux_gtest_defines(target, enable_tests):
112 if enable_tests and target.os == "Android":
113 return namespace(os_linux_android=True, use_own_tr1_tuple=True, has_clone="0")
116 set_define("GTEST_OS_LINUX_ANDROID", linux_gtest_defines.os_linux_android)
117 set_define("GTEST_USE_OWN_TR1_TUPLE", linux_gtest_defines.use_own_tr1_tuple)
118 set_define("GTEST_HAS_CLONE", linux_gtest_defines.has_clone)
123 help="Enable building with developer debug info "
124 "(using the given compiler flags).",
128 @depends("--enable-debug")
129 def moz_debug(debug):
134 set_config("MOZ_DEBUG", moz_debug)
135 set_define("MOZ_DEBUG", moz_debug)
136 # Override any value MOZ_DEBUG may have from the environment when passing it
137 # down to old-configure.
138 add_old_configure_assignment("MOZ_DEBUG", depends("--enable-debug")(lambda x: bool(x)))
141 "MOZ_DIAGNOSTIC_ASSERT_ENABLED",
143 when=moz_debug | milestone.is_early_beta_or_earlier,
146 "MOZ_DIAGNOSTIC_ASSERT_ENABLED",
148 when=moz_debug | milestone.is_early_beta_or_earlier,
152 "--with-debug-label",
154 help="Debug DEBUG_<value> for each comma-separated value given",
158 @depends(moz_debug, "--with-debug-label")
159 def debug_defines(debug, labels):
161 return ["DEBUG"] + ["DEBUG_%s" % label for label in labels]
162 return ["NDEBUG", "TRIMMED"]
165 set_config("MOZ_DEBUG_DEFINES", debug_defines)
167 option(env="MOZ_PGO", help="Build with profile guided optimizations")
169 set_config("MOZ_PGO", depends("MOZ_PGO")(lambda x: bool(x)))
172 imply_option("--enable-release", mozilla_official)
173 imply_option("--enable-release", depends_if("MOZ_AUTOMATION")(lambda x: True))
177 default=milestone.is_release_or_beta,
178 help="{Build|Do not build} with more conservative, release "
179 "engineering-oriented options.{ This may slow down builds.|}",
183 @depends("--enable-release")
184 def developer_options(value):
189 add_old_configure_assignment("DEVELOPER_OPTIONS", developer_options)
190 set_config("DEVELOPER_OPTIONS", developer_options)
193 # hybrid build handling
194 # ==============================================================
197 "--disable-unified-build",
198 help="Enable building modules that are not marked with `REQUIRES_UNIFIED_BUILD` in non unified context",
201 set_config("ENABLE_UNIFIED_BUILD", True, when="--disable-unified-build")
204 include("build/moz.configure/bootstrap.configure")
206 # The execution model of the configure sandbox doesn't allow for
207 # check_prog to use bootstrap_search_path directly because check_prog
208 # comes first, so we use a trick to allow it. Uses of check_prog
209 # happening before here won't allow bootstrap.
211 def check_prog(*args, **kwargs):
212 kwargs["bootstrap_search_path"] = bootstrap_search_path
213 return check_prog(*args, **kwargs)
216 check_prog("WGET", ("wget",), allow_missing=True)
219 include("build/moz.configure/toolchain.configure", when="--enable-compile-environment")
221 include("build/moz.configure/pkg.configure")
222 # Make this assignment here rather than in pkg.configure to avoid
223 # requiring this file in unit tests.
224 add_old_configure_assignment("PKG_CONFIG", pkg_config)
226 include("build/moz.configure/memory.configure", when="--enable-compile-environment")
227 include("build/moz.configure/headers.configure", when="--enable-compile-environment")
228 include("build/moz.configure/warnings.configure", when="--enable-compile-environment")
229 include("build/moz.configure/flags.configure", when="--enable-compile-environment")
230 include("build/moz.configure/lto-pgo.configure", when="--enable-compile-environment")
231 # rust.configure is included by js/moz.configure.
233 option("--enable-valgrind", help="Enable Valgrind integration hooks")
235 valgrind_h = check_header("valgrind/valgrind.h", when="--enable-valgrind")
238 @depends("--enable-valgrind", valgrind_h)
239 def check_valgrind(valgrind, valgrind_h):
242 die("--enable-valgrind specified but Valgrind is not installed")
246 set_define("MOZ_VALGRIND", check_valgrind)
247 set_config("MOZ_VALGRIND", check_valgrind)
250 @depends(target, host)
251 def is_openbsd(target, host):
252 return target.kernel == "OpenBSD" or host.kernel == "OpenBSD"
260 help="Shared library version for OpenBSD systems",
264 @depends("SO_VERSION", when=is_openbsd)
265 def so_version(value):
270 def library_name_info_template(host_or_target):
271 assert host_or_target in {host, target}
273 host: host_c_compiler,
277 @depends(host_or_target, compiler, so_version)
278 def library_name_info_impl(host_or_target, compiler, so_version):
279 if host_or_target.kernel == "WINNT":
280 # There aren't artifacts for mingw builds, so it's OK that the
281 # results are inaccurate in that case.
282 if compiler and compiler.type != "clang-cl":
284 dll=namespace(prefix="", suffix=".dll"),
285 lib=namespace(prefix="lib", suffix="a"),
286 import_lib=namespace(prefix="lib", suffix="a"),
287 obj=namespace(prefix="", suffix="o"),
291 dll=namespace(prefix="", suffix=".dll"),
292 lib=namespace(prefix="", suffix="lib"),
293 import_lib=namespace(prefix="", suffix="lib"),
294 obj=namespace(prefix="", suffix="obj"),
297 elif host_or_target.kernel == "Darwin":
299 dll=namespace(prefix="lib", suffix=".dylib"),
300 lib=namespace(prefix="lib", suffix="a"),
301 import_lib=namespace(prefix=None, suffix=""),
302 obj=namespace(prefix="", suffix="o"),
305 so = ".so.%s" % so_version
310 dll=namespace(prefix="lib", suffix=so),
311 lib=namespace(prefix="lib", suffix="a"),
312 import_lib=namespace(prefix=None, suffix=""),
313 obj=namespace(prefix="", suffix="o"),
316 return library_name_info_impl
319 host_library_name_info = library_name_info_template(host)
320 library_name_info = library_name_info_template(target)
322 set_config("DLL_PREFIX", library_name_info.dll.prefix)
323 set_config("DLL_SUFFIX", library_name_info.dll.suffix)
324 set_config("HOST_DLL_PREFIX", host_library_name_info.dll.prefix)
325 set_config("HOST_DLL_SUFFIX", host_library_name_info.dll.suffix)
326 set_config("LIB_PREFIX", library_name_info.lib.prefix)
327 set_config("LIB_SUFFIX", library_name_info.lib.suffix)
328 set_config("OBJ_SUFFIX", library_name_info.obj.suffix)
329 # Lots of compilation tests depend on this variable being present.
330 add_old_configure_assignment("OBJ_SUFFIX", library_name_info.obj.suffix)
331 set_config("IMPORT_LIB_SUFFIX", library_name_info.import_lib.suffix)
333 "MOZ_DLL_PREFIX", depends(library_name_info.dll.prefix)(lambda s: '"%s"' % s)
336 "MOZ_DLL_SUFFIX", depends(library_name_info.dll.suffix)(lambda s: '"%s"' % s)
338 set_config("HOST_LIB_PREFIX", host_library_name_info.lib.prefix)
339 set_config("HOST_IMPORT_LIB_SUFFIX", host_library_name_info.import_lib.suffix)
340 set_config("WASM_OBJ_SUFFIX", "wasm")
342 # Make `profiling` available to this file even when js/moz.configure
343 # doesn't end up included.
344 profiling = dependable(False)
345 # Same for js_standalone
346 js_standalone = dependable(False)
347 js_shared = dependable(False)
348 moz_linker = dependable(False)
350 fold_libs = dependable(False)
352 dmd = dependable(False)
354 include(include_project_configure)
358 @imports(_from="mozbuild.backend", _import="backends")
359 def build_backends_choices(_):
360 return tuple(backends)
363 @deprecated_option("--enable-build-backend", nargs="+", choices=build_backends_choices)
364 def build_backend(backends):
366 return tuple("+%s" % b for b in backends)
369 imply_option("--build-backends", build_backend)
375 "--enable-artifact-builds",
376 "--disable-compile-environment",
377 "--enable-build-backend",
379 "--enable-application",
383 def build_backend_defaults(
394 project = application[0]
398 if "Tup" in requested_backends:
399 # As a special case, if Tup was requested, do not combine it with any
400 # Make based backend by default.
402 elif artifact_builds:
403 all_backends = ["FasterMake+RecursiveMake"]
405 all_backends = ["RecursiveMake", "FasterMake"]
408 and target.os == "WINNT"
409 and compile_environment
410 and project not in ("mobile/android", "memory", "tools/update-programs")
412 all_backends.append("VisualStudio")
413 return tuple(all_backends) or None
419 default=build_backend_defaults,
420 choices=build_backends_choices,
421 help="Build backends to generate",
425 @depends("--build-backends")
426 def build_backends(backends):
430 set_config("BUILD_BACKENDS", build_backends)
433 @depends(build_environment, build_backends)
435 def check_objdir_backend_reuse(build_env, backends):
436 # "Make based" might be RecursiveMake or a hybrid backend, so "Make" is
437 # intentionally vague for use with the substring match below.
438 incompatible_backends = (("Tup", "Make"), ("Make", "Tup"))
439 for backend_file in glob.iglob(
440 os.path.join(build_env.topobjdir, "backend.*Backend")
442 for prev, curr in incompatible_backends:
443 if prev in backend_file and any(curr in b for b in backends):
445 "The active objdir, %s, was previously "
446 "used to build with a %s based backend. "
447 "Change objdirs (by setting MOZ_OBJDIR in "
448 "your mozconfig) or clobber to continue.\n",
454 # Determine whether to build the gtest xul. This happens in automation
455 # on Android and Desktop platforms with the exception of:
456 # - Windows PGO, where linking xul-gtest.dll takes too long;
457 # - Android other than x86_64, where gtest is not required.
463 when="--enable-compile-environment",
465 def build_gtest(build_project, target, automation, enable_tests):
469 and build_project in ("browser", "comm/mail", "mobile/android")
470 and not (target.os == "Android" and target.cpu != "x86_64")
475 "--enable-gtest-in-build",
477 help="{Enable|Force disable} building the gtest libxul during the build.",
478 when="--enable-compile-environment",
481 set_config("LINK_GTEST_DURING_COMPILE", True, when="--enable-gtest-in-build")
484 # ==============================================================
486 "--enable-ui-locale",
488 help="Select the user interface locale (default: en-US)",
491 set_config("MOZ_UI_LOCALE", depends("--enable-ui-locale")(lambda x: x))
495 help="An experiment to use ICU4X instead of ICU4C. See intl/ICU4X.md",
498 set_config("MOZ_ICU4X", True, when="--enable-icu4x")
500 # clang-plugin location
501 # ==============================================================
504 @depends(host_library_name_info, build_environment, when="--enable-clang-plugin")
505 def clang_plugin_path(library_name_info, build_env):
506 topobjdir = build_env.topobjdir
507 if topobjdir.endswith("/js/src"):
508 topobjdir = topobjdir[:-7]
509 return os.path.abspath(
515 % (library_name_info.dll.prefix, library_name_info.dll.suffix),
520 set_config("CLANG_PLUGIN", clang_plugin_path)
521 add_old_configure_assignment("CLANG_PLUGIN", clang_plugin_path)
525 # ==============================================================
526 awk = check_prog("AWK", ("gawk", "mawk", "nawk", "awk"))
528 # Until the AWK variable is not necessary in old-configure
532 def awk_for_old_configure(value):
536 add_old_configure_assignment("AWK", awk_for_old_configure)
540 # ==============================================================
541 perl = check_prog("PERL", ("perl5", "perl"))
543 # Until the PERL variable is not necessary in old-configure
547 def perl_for_old_configure(value):
551 add_old_configure_assignment("PERL", perl_for_old_configure)
555 def perl_version_check(min_version):
557 @checking("for minimum required perl version >= %s" % min_version)
558 def get_perl_version(perl):
564 onerror=lambda: die("Failed to get perl version."),
568 @depends(get_perl_version)
569 def check_perl_version(version):
570 if version < min_version:
571 die("Perl %s or higher is required.", min_version)
574 @checking("for full perl installation")
575 @imports("subprocess")
576 def has_full_perl_installation(perl):
577 ret = subprocess.call([perl, "-e", "use Config; exit(!-d $Config{archlib})"])
580 @depends(has_full_perl_installation)
581 def require_full_perl_installation(has_full_perl_installation):
582 if not has_full_perl_installation:
584 "Cannot find Config.pm or $Config{archlib}. "
585 "A full perl installation is required."
589 perl_version_check("5.006")
593 # ==============================================================
594 option(env="MAKE", nargs=1, help="Path to GNU make")
597 @depends("MAKE", host)
598 def possible_makes(make, host):
600 if host.kernel == "WINNT":
601 candidates.append("mingw32-make")
603 candidates.append(make[0])
604 if host.kernel == "WINNT":
605 candidates.extend(("mozmake", "make", "gmake"))
607 candidates.extend(("gmake", "make"))
611 check_prog("GMAKE", possible_makes, bootstrap="mozmake")
614 # ==============================================================
616 option(env="WATCHMAN", nargs=1, help="Path to the watchman program")
619 @depends(host, "WATCHMAN")
620 @checking("for watchman", callback=lambda w: w.path if w else "not found")
621 def watchman(host, prog):
622 # On Windows, `watchman` is only supported on 64-bit hosts.
623 if host.os == "WINNT" and host.cpu != "x86_64":
627 prog = find_program("watchman")
632 # `watchman version` will talk to the Watchman daemon service.
633 # This can hang due to permissions problems. e.g.
634 # https://github.com/facebook/watchman/issues/376. So use
635 # `watchman --version` to prevent a class of failures.
636 out = check_cmd_output(prog, "--version", onerror=lambda: None)
640 return namespace(path=prog, version=Version(out.strip()))
643 @depends_if(watchman)
644 @checking("for watchman version")
645 def watchman_version(w):
649 set_config("WATCHMAN", watchman.path)
652 @depends_all(hg_version, hg_config, watchman)
653 @checking("for watchman Mercurial integration")
655 def watchman_hg(hg_version, hg_config, watchman):
656 if hg_version < Version("3.8"):
657 return "no (Mercurial 3.8+ required)"
660 mode_disabled = False
662 for k in ("extensions.fsmonitor", "extensions.hgext.fsmonitor"):
663 if k in hg_config and hg_config[k] != "!":
666 mode_disabled = hg_config.get("fsmonitor.mode") == "off"
669 return "no (fsmonitor extension not enabled)"
671 return "no (fsmonitor.mode=off disables fsmonitor)"
676 # Miscellaneous programs
677 # ==============================================================
678 check_prog("XARGS", ("xargs",))
682 def extra_programs(target):
683 if target.kernel == "Darwin":
685 DSYMUTIL=("dsymutil", "llvm-dsymutil"),
686 MKFSHFS=("newfs_hfs", "mkfs.hfsplus"),
687 HFS_TOOL=("hfsplus",),
689 if target.os == "GNU" and target.kernel == "Linux":
690 return namespace(RPMBUILD=("rpmbuild",))
693 check_prog("DSYMUTIL", extra_programs.DSYMUTIL, allow_missing=True)
694 check_prog("MKFSHFS", extra_programs.MKFSHFS, allow_missing=True)
695 check_prog("HFS_TOOL", extra_programs.HFS_TOOL, allow_missing=True)
696 check_prog("RPMBUILD", extra_programs.RPMBUILD, allow_missing=True)
702 bootstrap="nsis/bin",
704 when=target_is_windows,
707 # Make sure the version of makensis is up to date.
711 @checking("for NSIS version")
713 def nsis_version(nsis):
714 nsis_min_version = "3.0b1"
717 return die("Failed to get nsis version.")
719 out = check_cmd_output(nsis, "-version", onerror=onerror)
721 m = re.search(r"(?<=v)[0-9]+\.[0-9]+((a|b|rc)[0-9]+)?", out)
724 raise FatalCheckError("Unknown version of makensis")
725 ver = Version(m.group(0))
727 # Versions comparisons don't quite work well with beta versions, so ensure
728 # it works for the non-beta version.
729 if ver < nsis_min_version and (ver >= "3.0a" or ver < "3"):
730 raise FatalCheckError(
731 "To build the installer you must have NSIS"
732 " version %s or greater in your path" % nsis_min_version
738 # And that makensis is 32-bit (but only on Windows).
739 @depends_if(nsis, when=depends(host)(lambda h: h.kernel == "WINNT"))
740 @checking("for 32-bit NSIS")
741 def nsis_binary_type(nsis):
742 bin_type = windows_binary_type(nsis)
743 if bin_type != "win32":
744 raise FatalCheckError("%s is not a 32-bit Windows application" % nsis)
749 # And any flags we have to give to makensis
751 def nsis_flags(host):
752 if host.kernel != "WINNT":
757 set_config("MAKENSISU_FLAGS", nsis_flags)
759 check_prog("7Z", ("7z", "7za"), allow_missing=True, when=target_is_windows)
760 check_prog("UPX", ("upx",), allow_missing=True, when=target_is_windows)
765 @depends(host_c_compiler, c_compiler, bindgen_config_paths)
766 def llvm_tool(host_c_compiler, c_compiler, bindgen_config_paths):
768 for compiler in (host_c_compiler, c_compiler):
769 if compiler and compiler.type == "clang":
770 clang = compiler.compiler
772 elif compiler and compiler.type == "clang-cl":
773 clang = os.path.join(os.path.dirname(compiler.compiler), "clang")
776 if not clang and bindgen_config_paths:
777 clang = bindgen_config_paths.clang_path
780 out = check_cmd_output(
781 clang, "--print-prog-name=%s" % tool, onerror=lambda: None
790 llvm_objdump = check_prog(
792 llvm_tool("llvm-objdump"),
794 when="--enable-compile-environment",
795 paths=clang_search_path,
798 add_old_configure_assignment("LLVM_OBJDUMP", llvm_objdump)
801 @depends(llvm_tool("llvm-readelf"), toolchain_prefix)
802 def readelf(llvm_readelf, toolchain_prefix):
803 commands = [llvm_readelf[0], "readelf"]
804 for prefix in toolchain_prefix or ():
805 commands.insert(1, "%sreadelf" % prefix)
806 return tuple(commands)
809 def validate_readelf(path):
810 # llvm-readelf from llvm < 8 doesn't support the GNU binutils-compatible `-d`
811 # flag. We could try running `$path -d $some_binary` but we might be cross
812 # compiling and not have a binary at hand to run that against. `$path -d` alone
813 # would fail whether the flag is supported or not. So we resort to look for the
814 # option in the `--help` output, which fortunately, s compatible between
815 # llvm-readelf and readelf.
816 retcode, stdout, stderr = get_cmd_output(path, "--help")
817 return retcode == 0 and any(l.startswith(" -d ") for l in stdout.splitlines())
820 @depends("--enable-compile-environment", target, host)
821 def readelf_when(compile_env, target, host):
822 return compile_env and any(
823 x.kernel not in ("Darwin", "WINNT") for x in (target, host)
831 paths=clang_search_path,
832 validate=validate_readelf,
836 @depends(llvm_tool("llvm-objcopy"), toolchain_prefix)
837 def objcopy(llvm_objcopy, toolchain_prefix):
838 commands = [llvm_objcopy[0], "objcopy"]
839 for prefix in toolchain_prefix or ():
840 commands.insert(1, "%sreadelf" % prefix)
841 return tuple(commands)
844 def validate_objcopy(path):
845 if "llvm-objcopy" not in path:
847 # llvm-objcopy doesn't support --only-keep-debug before llvm 9.0.
848 retcode, stdout, stderr = get_cmd_output(path, "--help")
849 return retcode == 0 and any(
850 l.startswith(" --only-keep-debug ") for l in stdout.splitlines()
858 paths=clang_search_path,
859 validate=validate_objcopy,
862 option("--enable-dtrace", help="Build with dtrace support")
864 dtrace = check_header(
866 when="--enable-dtrace",
867 onerror=lambda: die("dtrace enabled but sys/sdt.h not found"),
870 set_config("HAVE_DTRACE", True, when=dtrace)
871 set_define("INCLUDE_MOZILLA_DTRACE", True, when=dtrace)
872 add_old_configure_assignment("enable_dtrace", "yes", when=dtrace)
875 option("--disable-icf", help="Disable Identical Code Folding")
877 add_old_configure_assignment(
878 "MOZ_DISABLE_ICF", "1", when=depends("--enable-icf")(lambda x: not x)
884 when=compile_environment,
885 help="Enable stripping of libs & executables",
888 # This should be handled as a `when` once bug 1617793 is fixed.
891 @depends("--enable-strip", c_compiler, when=compile_environment)
892 def enable_strip(strip, c_compiler):
893 if strip and c_compiler.type != "clang-cl":
897 set_config("ENABLE_STRIP", enable_strip)
900 "--disable-install-strip",
901 when=compile_environment,
902 help="Enable stripping of libs & executables when packaging",
905 # This should be handled as a `when` once bug 1617793 is fixed.
908 @depends("--enable-install-strip", c_compiler, when=compile_environment)
909 def enable_install_strip(strip, c_compiler):
910 if strip and c_compiler.type != "clang-cl":
914 set_config("PKG_STRIP", enable_install_strip)
917 @depends("--enable-strip", "--enable-install-strip", when=compile_environment)
918 def strip(strip, install_strip):
919 return strip or install_strip
922 option(env="STRIP_FLAGS", nargs=1, when=strip, help="Flags for the strip command")
925 @depends("STRIP_FLAGS", profiling, target, when=strip)
926 def strip_flags(flags, profiling, target):
928 return flags[0].split()
930 # Only strip debug info and symbols when profiling is enabled, keeping
932 if target.kernel == "Darwin":
934 elif target.os == "Android":
935 # The tooling we use with Android supports detached symbols, and the
936 # size increase caused by local symbols are too much for mobile. So,
937 # don't restrict the amount of stripping with a flag.
940 return ["--strip-debug"]
941 # Otherwise strip everything we can, which happens without flags on non-Darwin.
942 # On Darwin, it tries to strip things it can't, so we need to limit its scope.
943 elif target.kernel == "Darwin":
947 set_config("STRIP_FLAGS", strip_flags)
950 @depends(llvm_tool("llvm-strip"), toolchain_prefix, target)
951 def strip(llvm_strip, toolchain_prefix, target):
953 for prefix in toolchain_prefix or ():
954 commands.insert(0, "%sstrip" % prefix)
955 # llvm-strip causes some problems on macos targets.
956 if target.kernel == "Darwin":
957 commands.append(llvm_strip[0])
959 commands.insert(0, llvm_strip[0])
960 return tuple(commands)
963 def validate_strip(path):
964 if "llvm-strip" not in path:
966 # llvm-strip doesn't support -S before llvm 8.0.
967 retcode, stdout, stderr = get_cmd_output(path, "--help")
968 return retcode == 0 and any(l.startswith(" -S ") for l in stdout.splitlines())
971 @depends("--enable-compile-environment", target, host)
972 def strip_when(compile_env, target, host):
973 return compile_env and any(x.kernel != "WINNT" for x in (target, host))
980 paths=clang_search_path,
981 validate=validate_strip,
985 @depends(js_standalone, target)
986 def system_zlib_default(js_standalone, target):
987 return js_standalone and target.kernel not in ("WINNT", "Darwin")
991 "--with-system-zlib",
993 default=system_zlib_default,
994 help="{Use|Do not use} system libz",
998 @depends("--with-system-zlib")
999 def deprecated_system_zlib_path(value):
1002 "--with-system-zlib=PATH is not supported anymore. Please use "
1003 "--with-system-zlib and set any necessary pkg-config environment variable."
1007 pkg_check_modules("MOZ_ZLIB", "zlib >= 1.2.3", when="--with-system-zlib")
1009 set_config("MOZ_SYSTEM_ZLIB", True, when="--with-system-zlib")
1012 @depends("--with-system-zlib", js_shared, moz_linker, target.os)
1013 def zlib_in_mozglue(system_zlib, js_shared, linker, os):
1014 if not system_zlib and (js_shared or linker or os == "Android"):
1018 set_config("ZLIB_IN_MOZGLUE", zlib_in_mozglue)
1019 set_define("ZLIB_IN_MOZGLUE", zlib_in_mozglue)
1022 # Please do not add configure checks from here on.
1024 # Fallthrough to autoconf-based configure
1025 include("build/moz.configure/old.configure")
1028 include("js/sub.configure", when=compile_environment & toolkit)
1031 @depends(build_environment, build_project)
1032 @imports("__sandbox__")
1034 @imports(_from="os.path", _import="exists")
1035 def config_status_deps(build_env, build_project):
1037 topsrcdir = build_env.topsrcdir
1038 topobjdir = build_env.topobjdir
1040 if not topobjdir.endswith("js/src"):
1041 extra_deps = [os.path.join(topobjdir, ".mozconfig.json")]
1043 # mozconfig changes may impact js configure.
1044 extra_deps = [os.path.join(topobjdir[:-7], ".mozconfig.json")]
1046 confvars = os.path.join(topsrcdir, build_project, "confvars.sh")
1047 if exists(confvars):
1048 extra_deps.append(confvars)
1051 list(__sandbox__._all_paths)
1054 os.path.join(topsrcdir, "CLOBBER"),
1055 os.path.join(topsrcdir, "configure.in"),
1056 os.path.join(topsrcdir, "js", "src", "configure.in"),
1057 os.path.join(topsrcdir, "nsprpub", "configure"),
1058 os.path.join(topsrcdir, "config", "milestone.txt"),
1059 os.path.join(topsrcdir, "browser", "config", "version.txt"),
1060 os.path.join(topsrcdir, "browser", "config", "version_display.txt"),
1061 os.path.join(topsrcdir, "python", "sites", "build.txt"),
1062 os.path.join(topsrcdir, "python", "sites", "common.txt"),
1063 os.path.join(topsrcdir, "python", "sites", "mach.txt"),
1064 os.path.join(topsrcdir, "python", "mach", "mach", "site.py"),
1065 os.path.join(topsrcdir, "aclocal.m4"),
1066 os.path.join(topsrcdir, "old-configure.in"),
1067 os.path.join(topsrcdir, "js", "src", "aclocal.m4"),
1068 os.path.join(topsrcdir, "js", "src", "old-configure.in"),
1070 + glob.glob(os.path.join(topsrcdir, "build", "autoconf", "*.m4"))
1074 set_config("CONFIG_STATUS_DEPS", config_status_deps)
1075 # Please do not add anything after setting config_dep_paths.