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 "--with-debug-label",
143 help="Debug DEBUG_<value> for each comma-separated value given",
147 @depends(moz_debug, "--with-debug-label")
148 def debug_defines(debug, labels):
150 return ["DEBUG"] + ["DEBUG_%s" % label for label in labels]
151 return ["NDEBUG", "TRIMMED"]
154 set_config("MOZ_DEBUG_DEFINES", debug_defines)
156 option(env="MOZ_PGO", help="Build with profile guided optimizations")
158 set_config("MOZ_PGO", depends("MOZ_PGO")(lambda x: bool(x)))
161 imply_option("--enable-release", mozilla_official)
162 imply_option("--enable-release", depends_if("MOZ_AUTOMATION")(lambda x: True))
166 default=milestone.is_release_or_beta,
167 help="{Build|Do not build} with more conservative, release "
168 "engineering-oriented options.{ This may slow down builds.|}",
172 @depends("--enable-release")
173 def developer_options(value):
178 add_old_configure_assignment("DEVELOPER_OPTIONS", developer_options)
179 set_config("DEVELOPER_OPTIONS", developer_options)
182 # hybrid build handling
183 # ==============================================================
186 "--disable-unified-build",
187 help="Enable building modules that are not marked with `REQUIRES_UNIFIED_BUILD` in non unified context",
190 set_config("ENABLE_UNIFIED_BUILD", True, when="--disable-unified-build")
194 env="MOZ_FETCHES_DIR",
196 when="MOZ_AUTOMATION",
197 help="Directory containing fetched artifacts",
201 @depends("MOZ_FETCHES_DIR", when="MOZ_AUTOMATION")
202 def moz_fetches_dir(value):
207 @depends(vcs_checkout_type, milestone.is_nightly, "MOZ_AUTOMATION")
208 def bootstrap_default(vcs_checkout_type, is_nightly, automation):
211 # We only enable if building off a VCS checkout of central.
212 if is_nightly and vcs_checkout_type:
217 "--enable-bootstrap",
218 default=bootstrap_default,
219 help="{Automatically bootstrap or update some toolchains|Disable bootstrap or update of toolchains}",
223 @depends(developer_options, "--enable-bootstrap", moz_fetches_dir)
224 def bootstrap_search_path_order(developer_options, bootstrap, moz_fetches_dir):
226 log.debug("Prioritizing MOZ_FETCHES_DIR in toolchain path.")
231 "Prioritizing mozbuild state dir in toolchain paths because "
232 "bootstrap mode is enabled."
236 if developer_options:
238 "Prioritizing mozbuild state dir in toolchain paths because "
239 "you are not building in release mode."
244 "Prioritizing system over mozbuild state dir in "
245 "toolchain paths because you are building in "
251 toolchains_base_dir = moz_fetches_dir | mozbuild_state_path
256 @imports(_from="os", _import="environ")
258 return environ["PATH"].split(os.pathsep)
261 @depends(host, when="--enable-bootstrap")
263 @imports("traceback")
264 @imports(_from="mozbuild.toolchains", _import="toolchain_task_definitions")
265 @imports(_from="__builtin__", _import="Exception")
266 def bootstrap_toolchain_tasks(host):
268 ("x86_64", "GNU", "Linux"): "linux64",
269 ("x86_64", "OSX", "Darwin"): "macosx64",
270 ("aarch64", "OSX", "Darwin"): "macosx64-aarch64",
271 ("x86_64", "WINNT", "WINNT"): "win64",
272 }.get((host.cpu, host.os, host.kernel))
274 return namespace(prefix=prefix, tasks=toolchain_task_definitions())
275 except Exception as e:
276 message = traceback.format_exc()
283 def bootstrap_path(path, **kwargs):
284 when = kwargs.pop("when", None)
286 configure_error("bootstrap_path only takes `when` as a keyword argument")
289 "--enable-bootstrap",
291 bootstrap_toolchain_tasks,
293 check_build_environment,
298 @imports("subprocess")
299 @imports(_from="mozbuild.util", _import="ensureParentDir")
300 @imports(_from="__builtin__", _import="open")
301 @imports(_from="__builtin__", _import="Exception")
302 def bootstrap_path(bootstrap, toolchains_base_dir, tasks, shell, build_env, path):
303 path_parts = path.split("/")
305 def try_bootstrap(exists):
310 prefixes.insert(0, "{}-".format(tasks.prefix))
311 for prefix in prefixes:
312 label = "toolchain-{}{}".format(prefix, path_parts[0])
313 task = tasks.tasks.get(label)
316 log.debug("Trying to bootstrap %s", label)
319 task_index = task.optimization.get("index-search")
322 log.debug("Resolved %s to %s", label, task_index[0])
323 task_index = task_index[0].split(".")[-1]
324 artifact = task.attributes["toolchain-artifact"]
325 # `mach artifact toolchain` doesn't support authentication for
327 if not artifact.startswith("public/"):
328 log.debug("Cannot bootstrap %s: not a public artifact", label)
330 index_file = os.path.join(toolchains_base_dir, "indices", path_parts[0])
332 with open(index_file) as fh:
333 index = fh.read().strip()
336 if index == task_index and exists:
337 log.debug("%s is up-to-date", label)
340 "%s bootstrapped toolchain in %s",
341 "Updating" if exists else "Installing",
342 os.path.join(toolchains_base_dir, path_parts[0]),
347 os.path.join(build_env.topsrcdir, "mach"),
354 cwd=toolchains_base_dir,
357 ensureParentDir(index_file)
358 with open(index_file, "w") as fh:
362 path = os.path.join(toolchains_base_dir, *path_parts)
365 if not try_bootstrap(os.path.exists(path)):
366 # If there aren't toolchain artifacts to use for this build,
367 # don't return a path.
369 except Exception as e:
371 die("If you can't fix the above, retry with --disable-bootstrap.")
372 # We re-test whether the path exists because it may have been created by
373 # try_bootstrap. Automation will not have gone through the bootstrap
374 # process, but we want to return the path if it exists.
375 if os.path.exists(path):
378 return bootstrap_path
382 def bootstrap_search_path(path, paths=original_path, **kwargs):
384 bootstrap_path(path, **kwargs),
385 bootstrap_search_path_order,
389 def bootstrap_search_path(path, order, paths, original_path):
391 paths = original_path
394 if order == "prepend":
395 return [path] + paths
396 return paths + [path]
398 return bootstrap_search_path
401 # The execution model of the configure sandbox doesn't allow for
402 # check_prog to use bootstrap_search_path directly because check_prog
403 # comes first, so we use a trick to allow it. Uses of check_prog
404 # happening before here won't allow bootstrap.
406 def check_prog(*args, **kwargs):
407 kwargs["bootstrap_search_path"] = bootstrap_search_path
408 return check_prog(*args, **kwargs)
411 check_prog("WGET", ("wget",), allow_missing=True)
414 include("build/moz.configure/toolchain.configure", when="--enable-compile-environment")
416 include("build/moz.configure/pkg.configure")
417 # Make this assignment here rather than in pkg.configure to avoid
418 # requiring this file in unit tests.
419 add_old_configure_assignment("PKG_CONFIG", pkg_config)
421 include("build/moz.configure/memory.configure", when="--enable-compile-environment")
422 include("build/moz.configure/headers.configure", when="--enable-compile-environment")
423 include("build/moz.configure/warnings.configure", when="--enable-compile-environment")
424 include("build/moz.configure/flags.configure", when="--enable-compile-environment")
425 include("build/moz.configure/lto-pgo.configure", when="--enable-compile-environment")
426 # rust.configure is included by js/moz.configure.
428 option("--enable-valgrind", help="Enable Valgrind integration hooks")
430 valgrind_h = check_header("valgrind/valgrind.h", when="--enable-valgrind")
433 @depends("--enable-valgrind", valgrind_h)
434 def check_valgrind(valgrind, valgrind_h):
437 die("--enable-valgrind specified but Valgrind is not installed")
441 set_define("MOZ_VALGRIND", check_valgrind)
442 set_config("MOZ_VALGRIND", check_valgrind)
445 @depends(target, host)
446 def is_openbsd(target, host):
447 return target.kernel == "OpenBSD" or host.kernel == "OpenBSD"
455 help="Shared library version for OpenBSD systems",
459 @depends("SO_VERSION", when=is_openbsd)
460 def so_version(value):
465 def library_name_info_template(host_or_target):
466 assert host_or_target in {host, target}
468 host: host_c_compiler,
472 @depends(host_or_target, compiler, so_version)
473 def library_name_info_impl(host_or_target, compiler, so_version):
474 if host_or_target.kernel == "WINNT":
475 # There aren't artifacts for mingw builds, so it's OK that the
476 # results are inaccurate in that case.
477 if compiler and compiler.type != "clang-cl":
479 dll=namespace(prefix="", suffix=".dll"),
480 lib=namespace(prefix="lib", suffix="a"),
481 import_lib=namespace(prefix="lib", suffix="a"),
482 obj=namespace(prefix="", suffix="o"),
486 dll=namespace(prefix="", suffix=".dll"),
487 lib=namespace(prefix="", suffix="lib"),
488 import_lib=namespace(prefix="", suffix="lib"),
489 obj=namespace(prefix="", suffix="obj"),
492 elif host_or_target.kernel == "Darwin":
494 dll=namespace(prefix="lib", suffix=".dylib"),
495 lib=namespace(prefix="lib", suffix="a"),
496 import_lib=namespace(prefix=None, suffix=""),
497 obj=namespace(prefix="", suffix="o"),
500 so = ".so.%s" % so_version
505 dll=namespace(prefix="lib", suffix=so),
506 lib=namespace(prefix="lib", suffix="a"),
507 import_lib=namespace(prefix=None, suffix=""),
508 obj=namespace(prefix="", suffix="o"),
511 return library_name_info_impl
514 host_library_name_info = library_name_info_template(host)
515 library_name_info = library_name_info_template(target)
517 set_config("DLL_PREFIX", library_name_info.dll.prefix)
518 set_config("DLL_SUFFIX", library_name_info.dll.suffix)
519 set_config("HOST_DLL_PREFIX", host_library_name_info.dll.prefix)
520 set_config("HOST_DLL_SUFFIX", host_library_name_info.dll.suffix)
521 set_config("LIB_PREFIX", library_name_info.lib.prefix)
522 set_config("LIB_SUFFIX", library_name_info.lib.suffix)
523 set_config("OBJ_SUFFIX", library_name_info.obj.suffix)
524 # Lots of compilation tests depend on this variable being present.
525 add_old_configure_assignment("OBJ_SUFFIX", library_name_info.obj.suffix)
526 set_config("IMPORT_LIB_SUFFIX", library_name_info.import_lib.suffix)
528 "MOZ_DLL_PREFIX", depends(library_name_info.dll.prefix)(lambda s: '"%s"' % s)
531 "MOZ_DLL_SUFFIX", depends(library_name_info.dll.suffix)(lambda s: '"%s"' % s)
533 set_config("WASM_OBJ_SUFFIX", "wasm")
535 # Make `profiling` available to this file even when js/moz.configure
536 # doesn't end up included.
537 profiling = dependable(False)
538 # Same for js_standalone
539 js_standalone = dependable(False)
541 fold_libs = dependable(False)
543 include(include_project_configure)
547 @imports(_from="mozbuild.backend", _import="backends")
548 def build_backends_choices(_):
549 return tuple(backends)
552 @deprecated_option("--enable-build-backend", nargs="+", choices=build_backends_choices)
553 def build_backend(backends):
555 return tuple("+%s" % b for b in backends)
558 imply_option("--build-backends", build_backend)
562 "--enable-artifact-builds",
563 "--disable-compile-environment",
564 "--enable-build-backend",
566 "--enable-application",
570 def build_backend_defaults(
571 artifact_builds, compile_environment, requested_backends, project, application, _
574 project = application[0]
578 if "Tup" in requested_backends:
579 # As a special case, if Tup was requested, do not combine it with any
580 # Make based backend by default.
582 elif artifact_builds:
583 all_backends = ["FasterMake+RecursiveMake"]
585 all_backends = ["RecursiveMake", "FasterMake"]
586 # Normally, we'd use target.os == 'WINNT', but a dependency on target
587 # would require target to depend on --help, as well as host and shell,
588 # and this is not a can of worms we can open at the moment.
590 sys.platform == "win32"
591 and compile_environment
592 and project not in ("mobile/android", "memory", "tools/update-programs")
594 all_backends.append("VisualStudio")
595 return tuple(all_backends) or None
601 default=build_backend_defaults,
602 choices=build_backends_choices,
603 help="Build backends to generate",
607 @depends("--build-backends")
608 def build_backends(backends):
612 set_config("BUILD_BACKENDS", build_backends)
615 @depends(check_build_environment, build_backends)
617 def check_objdir_backend_reuse(build_env, backends):
618 # "Make based" might be RecursiveMake or a hybrid backend, so "Make" is
619 # intentionally vague for use with the substring match below.
620 incompatible_backends = (("Tup", "Make"), ("Make", "Tup"))
621 for backend_file in glob.iglob(
622 os.path.join(build_env.topobjdir, "backend.*Backend")
624 for prev, curr in incompatible_backends:
625 if prev in backend_file and any(curr in b for b in backends):
627 "The active objdir, %s, was previously "
628 "used to build with a %s based backend. "
629 "Change objdirs (by setting MOZ_OBJDIR in "
630 "your mozconfig) or clobber to continue.\n",
636 # Determine whether to build the gtest xul. This happens in automation
637 # on Android and Desktop platforms with the exception of:
638 # - Windows PGO, where linking xul-gtest.dll takes too long;
639 # - Android other than x86_64, where gtest is not required.
646 when="--enable-compile-environment",
648 def build_gtest(pgo, build_project, target, automation, enable_tests):
652 and build_project in ("browser", "comm/mail", "mobile/android")
654 (pgo and target.os == "WINNT")
655 or (target.os == "Android" and target.cpu != "x86_64")
661 "--enable-gtest-in-build",
663 help="{Enable|Force disable} building the gtest libxul during the build.",
664 when="--enable-compile-environment",
667 set_config("LINK_GTEST_DURING_COMPILE", True, when="--enable-gtest-in-build")
670 # ==============================================================
672 "--enable-ui-locale",
674 help="Select the user interface locale (default: en-US)",
677 set_config("MOZ_UI_LOCALE", depends("--enable-ui-locale")(lambda x: x))
681 help="An experiment to use ICU4X instead of ICU4C. See intl/ICU4X.md",
684 set_config("MOZ_ICU4X", True, when="--enable-icu4x")
686 # clang-plugin location
687 # ==============================================================
690 @depends(host_library_name_info, check_build_environment, when="--enable-clang-plugin")
691 def clang_plugin_path(library_name_info, build_env):
692 topobjdir = build_env.topobjdir
693 if topobjdir.endswith("/js/src"):
694 topobjdir = topobjdir[:-7]
695 return os.path.abspath(
701 % (library_name_info.dll.prefix, library_name_info.dll.suffix),
706 set_config("CLANG_PLUGIN", clang_plugin_path)
707 add_old_configure_assignment("CLANG_PLUGIN", clang_plugin_path)
711 # ==============================================================
712 awk = check_prog("AWK", ("gawk", "mawk", "nawk", "awk"))
714 # Until the AWK variable is not necessary in old-configure
718 def awk_for_old_configure(value):
722 add_old_configure_assignment("AWK", awk_for_old_configure)
726 # ==============================================================
727 perl = check_prog("PERL", ("perl5", "perl"))
729 # Until the PERL variable is not necessary in old-configure
733 def perl_for_old_configure(value):
737 add_old_configure_assignment("PERL", perl_for_old_configure)
741 def perl_version_check(min_version):
743 @checking("for minimum required perl version >= %s" % min_version)
744 def get_perl_version(perl):
750 onerror=lambda: die("Failed to get perl version."),
754 @depends(get_perl_version)
755 def check_perl_version(version):
756 if version < min_version:
757 die("Perl %s or higher is required.", min_version)
760 @checking("for full perl installation")
761 @imports("subprocess")
762 def has_full_perl_installation(perl):
763 ret = subprocess.call([perl, "-e", "use Config; exit(!-d $Config{archlib})"])
766 @depends(has_full_perl_installation)
767 def require_full_perl_installation(has_full_perl_installation):
768 if not has_full_perl_installation:
770 "Cannot find Config.pm or $Config{archlib}. "
771 "A full perl installation is required."
775 perl_version_check("5.006")
779 # ==============================================================
780 option(env="MAKE", nargs=1, help="Path to GNU make")
783 @depends("MAKE", host)
784 def possible_makes(make, host):
786 if host.kernel == "WINNT":
787 candidates.append("mingw32-make")
789 candidates.append(make[0])
790 if host.kernel == "WINNT":
791 candidates.extend(("mozmake", "make", "gmake"))
793 candidates.extend(("gmake", "make"))
797 check_prog("GMAKE", possible_makes, bootstrap="mozmake")
800 # ==============================================================
802 option(env="WATCHMAN", nargs=1, help="Path to the watchman program")
805 @depends(host, "WATCHMAN")
806 @checking("for watchman", callback=lambda w: w.path if w else "not found")
807 def watchman(host, prog):
808 # On Windows, `watchman` is only supported on 64-bit hosts.
809 if host.os == "WINNT" and host.cpu != "x86_64":
813 prog = find_program("watchman")
818 # `watchman version` will talk to the Watchman daemon service.
819 # This can hang due to permissions problems. e.g.
820 # https://github.com/facebook/watchman/issues/376. So use
821 # `watchman --version` to prevent a class of failures.
822 out = check_cmd_output(prog, "--version", onerror=lambda: None)
826 return namespace(path=prog, version=Version(out.strip()))
829 @depends_if(watchman)
830 @checking("for watchman version")
831 def watchman_version(w):
835 set_config("WATCHMAN", watchman.path)
838 @depends_all(hg_version, hg_config, watchman)
839 @checking("for watchman Mercurial integration")
841 def watchman_hg(hg_version, hg_config, watchman):
842 if hg_version < Version("3.8"):
843 return "no (Mercurial 3.8+ required)"
846 mode_disabled = False
848 for k in ("extensions.fsmonitor", "extensions.hgext.fsmonitor"):
849 if k in hg_config and hg_config[k] != "!":
852 mode_disabled = hg_config.get("fsmonitor.mode") == "off"
855 return "no (fsmonitor extension not enabled)"
857 return "no (fsmonitor.mode=off disables fsmonitor)"
862 # Miscellaneous programs
863 # ==============================================================
864 check_prog("XARGS", ("xargs",))
868 def extra_programs(target):
869 if target.kernel == "Darwin":
871 DSYMUTIL=("dsymutil", "llvm-dsymutil"),
872 MKFSHFS=("newfs_hfs", "mkfs.hfsplus"),
873 HFS_TOOL=("hfsplus",),
875 if target.os == "GNU" and target.kernel == "Linux":
876 return namespace(RPMBUILD=("rpmbuild",))
879 check_prog("DSYMUTIL", extra_programs.DSYMUTIL, allow_missing=True)
880 check_prog("MKFSHFS", extra_programs.MKFSHFS, allow_missing=True)
881 check_prog("HFS_TOOL", extra_programs.HFS_TOOL, allow_missing=True)
882 check_prog("RPMBUILD", extra_programs.RPMBUILD, allow_missing=True)
888 bootstrap="nsis/bin",
890 when=target_is_windows,
893 # Make sure the version of makensis is up to date.
897 @checking("for NSIS version")
899 def nsis_version(nsis):
900 nsis_min_version = "3.0b1"
903 return die("Failed to get nsis version.")
905 out = check_cmd_output(nsis, "-version", onerror=onerror)
907 m = re.search(r"(?<=v)[0-9]+\.[0-9]+((a|b|rc)[0-9]+)?", out)
910 raise FatalCheckError("Unknown version of makensis")
911 ver = Version(m.group(0))
913 # Versions comparisons don't quite work well with beta versions, so ensure
914 # it works for the non-beta version.
915 if ver < nsis_min_version and (ver >= "3.0a" or ver < "3"):
916 raise FatalCheckError(
917 "To build the installer you must have NSIS"
918 " version %s or greater in your path" % nsis_min_version
924 # And that makensis is 32-bit (but only on Windows).
925 @depends_if(nsis, when=depends(host)(lambda h: h.kernel == "WINNT"))
926 @checking("for 32-bit NSIS")
927 def nsis_binary_type(nsis):
928 bin_type = windows_binary_type(nsis)
929 if bin_type != "win32":
930 raise FatalCheckError("%s is not a 32-bit Windows application" % nsis)
935 # And any flags we have to give to makensis
937 def nsis_flags(host):
938 if host.kernel != "WINNT":
943 set_config("MAKENSISU_FLAGS", nsis_flags)
945 check_prog("7Z", ("7z", "7za"), allow_missing=True, when=target_is_windows)
946 check_prog("UPX", ("upx",), allow_missing=True, when=target_is_windows)
949 @depends(host_c_compiler, c_compiler, bindgen_config_paths)
950 def llvm_objdump(host_c_compiler, c_compiler, bindgen_config_paths):
952 for compiler in (host_c_compiler, c_compiler):
953 if compiler and compiler.type == "clang":
954 clang = compiler.compiler
956 elif compiler and compiler.type == "clang-cl":
957 clang = os.path.join(os.path.dirname(compiler.compiler), "clang")
960 if not clang and bindgen_config_paths:
961 clang = bindgen_config_paths.clang_path
962 llvm_objdump = "llvm-objdump"
964 out = check_cmd_output(
965 clang, "--print-prog-name=llvm-objdump", onerror=lambda: None
968 llvm_objdump = out.rstrip()
969 return (llvm_objdump,)
972 llvm_objdump = check_prog(
976 when="--enable-compile-environment",
977 paths=clang_search_path,
980 add_old_configure_assignment("LLVM_OBJDUMP", llvm_objdump)
983 option("--enable-dtrace", help="Build with dtrace support")
985 dtrace = check_header(
987 when="--enable-dtrace",
988 onerror=lambda: die("dtrace enabled but sys/sdt.h not found"),
991 set_config("HAVE_DTRACE", True, when=dtrace)
992 set_define("INCLUDE_MOZILLA_DTRACE", True, when=dtrace)
993 add_old_configure_assignment("enable_dtrace", "yes", when=dtrace)
996 option("--disable-icf", help="Disable Identical Code Folding")
998 add_old_configure_assignment(
999 "MOZ_DISABLE_ICF", "1", when=depends("--enable-icf")(lambda x: not x)
1005 when=compile_environment,
1006 help="Enable stripping of libs & executables",
1009 # This should be handled as a `when` once bug 1617793 is fixed.
1012 @depends("--enable-strip", c_compiler, when=compile_environment)
1013 def enable_strip(strip, c_compiler):
1014 if strip and c_compiler.type != "clang-cl":
1018 set_config("ENABLE_STRIP", enable_strip)
1021 "--disable-install-strip",
1022 when=compile_environment,
1023 help="Enable stripping of libs & executables when packaging",
1026 # This should be handled as a `when` once bug 1617793 is fixed.
1029 @depends("--enable-install-strip", c_compiler, when=compile_environment)
1030 def enable_install_strip(strip, c_compiler):
1031 if strip and c_compiler.type != "clang-cl":
1035 set_config("PKG_STRIP", enable_install_strip)
1038 @depends("--enable-strip", "--enable-install-strip", when=compile_environment)
1039 def strip(strip, install_strip):
1040 return strip or install_strip
1043 option(env="STRIP_FLAGS", nargs=1, when=strip, help="Flags for the strip command")
1046 @depends("STRIP_FLAGS", profiling, target, when=strip)
1047 def strip_flags(flags, profiling, target):
1049 return flags[0].split()
1051 # Only strip debug info and symbols when profiling is enabled, keeping
1053 if target.kernel == "Darwin":
1055 elif target.os == "Android":
1056 # The tooling we use with Android supports detached symbols, and the
1057 # size increase caused by local symbols are too much for mobile. So,
1058 # don't restrict the amount of stripping with a flag.
1061 return ["--strip-debug"]
1062 # Otherwise strip everything we can, which happens without flags on non-Darwin.
1063 # On Darwin, it tries to strip things it can't, so we need to limit its scope.
1064 elif target.kernel == "Darwin":
1068 set_config("STRIP_FLAGS", strip_flags)
1071 @depends(js_standalone, target)
1072 def system_zlib_default(js_standalone, target):
1073 return js_standalone and target.kernel not in ("WINNT", "Darwin")
1077 "--with-system-zlib",
1079 default=system_zlib_default,
1080 help="{Use|Do not use} system libz",
1084 @depends("--with-system-zlib")
1085 def deprecated_system_zlib_path(value):
1088 "--with-system-zlib=PATH is not supported anymore. Please use "
1089 "--with-system-zlib and set any necessary pkg-config environment variable."
1093 pkg_check_modules("MOZ_ZLIB", "zlib >= 1.2.3", when="--with-system-zlib")
1095 set_config("MOZ_SYSTEM_ZLIB", True, when="--with-system-zlib")
1096 add_old_configure_assignment("MOZ_SYSTEM_ZLIB", True, when="--with-system-zlib")
1099 # Please do not add configure checks from here on.
1101 # Fallthrough to autoconf-based configure
1102 include("build/moz.configure/old.configure")
1105 include("js/sub.configure", when=compile_environment & toolkit)
1108 @depends(check_build_environment, build_project)
1109 @imports("__sandbox__")
1111 @imports(_from="os.path", _import="exists")
1112 def config_status_deps(build_env, build_project):
1114 topsrcdir = build_env.topsrcdir
1115 topobjdir = build_env.topobjdir
1117 if not topobjdir.endswith("js/src"):
1118 extra_deps = [os.path.join(topobjdir, ".mozconfig.json")]
1120 # mozconfig changes may impact js configure.
1121 extra_deps = [os.path.join(topobjdir[:-7], ".mozconfig.json")]
1123 confvars = os.path.join(topsrcdir, build_project, "confvars.sh")
1124 if exists(confvars):
1125 extra_deps.append(confvars)
1128 list(__sandbox__._all_paths)
1131 os.path.join(topsrcdir, "CLOBBER"),
1132 os.path.join(topsrcdir, "configure.in"),
1133 os.path.join(topsrcdir, "js", "src", "configure.in"),
1134 os.path.join(topsrcdir, "nsprpub", "configure"),
1135 os.path.join(topsrcdir, "config", "milestone.txt"),
1136 os.path.join(topsrcdir, "browser", "config", "version.txt"),
1137 os.path.join(topsrcdir, "browser", "config", "version_display.txt"),
1138 os.path.join(topsrcdir, "build", "build_virtualenv_packages.txt"),
1139 os.path.join(topsrcdir, "build", "common_virtualenv_packages.txt"),
1140 os.path.join(topsrcdir, "build", "mach_virtualenv_packages.txt"),
1141 os.path.join(topsrcdir, "python", "mach", "mach", "site.py"),
1142 os.path.join(topsrcdir, "aclocal.m4"),
1143 os.path.join(topsrcdir, "old-configure.in"),
1144 os.path.join(topsrcdir, "js", "src", "aclocal.m4"),
1145 os.path.join(topsrcdir, "js", "src", "old-configure.in"),
1147 + glob.glob(os.path.join(topsrcdir, "build", "autoconf", "*.m4"))
1151 set_config("CONFIG_STATUS_DEPS", config_status_deps)
1152 # Please do not add anything after setting config_dep_paths.