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. No use 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 @depends(target, host)
412 def want_wine(target, host):
413 return target.kernel == "WINNT" and host.kernel != "WINNT"
421 bootstrap="wine/bin",
423 check_prog("WGET", ("wget",), allow_missing=True)
426 include("build/moz.configure/toolchain.configure", when="--enable-compile-environment")
428 include("build/moz.configure/pkg.configure")
429 # Make this assignment here rather than in pkg.configure to avoid
430 # requiring this file in unit tests.
431 add_old_configure_assignment("PKG_CONFIG", pkg_config)
433 include("build/moz.configure/memory.configure", when="--enable-compile-environment")
434 include("build/moz.configure/headers.configure", when="--enable-compile-environment")
435 include("build/moz.configure/warnings.configure", when="--enable-compile-environment")
436 include("build/moz.configure/flags.configure", when="--enable-compile-environment")
437 include("build/moz.configure/lto-pgo.configure", when="--enable-compile-environment")
438 # rust.configure is included by js/moz.configure.
440 option("--enable-valgrind", help="Enable Valgrind integration hooks")
442 valgrind_h = check_header("valgrind/valgrind.h", when="--enable-valgrind")
445 @depends("--enable-valgrind", valgrind_h)
446 def check_valgrind(valgrind, valgrind_h):
449 die("--enable-valgrind specified but Valgrind is not installed")
453 set_define("MOZ_VALGRIND", check_valgrind)
454 set_config("MOZ_VALGRIND", check_valgrind)
457 @depends(target, host)
458 def is_openbsd(target, host):
459 return target.kernel == "OpenBSD" or host.kernel == "OpenBSD"
467 help="Shared library version for OpenBSD systems",
471 @depends("SO_VERSION", when=is_openbsd)
472 def so_version(value):
477 def library_name_info_template(host_or_target):
478 assert host_or_target in {host, target}
480 host: host_c_compiler,
484 @depends(host_or_target, compiler, so_version)
485 def library_name_info_impl(host_or_target, compiler, so_version):
486 if host_or_target.kernel == "WINNT":
487 # There aren't artifacts for mingw builds, so it's OK that the
488 # results are inaccurate in that case.
489 if compiler and compiler.type != "clang-cl":
491 dll=namespace(prefix="", suffix=".dll"),
492 lib=namespace(prefix="lib", suffix="a"),
493 import_lib=namespace(prefix="lib", suffix="a"),
494 obj=namespace(prefix="", suffix="o"),
498 dll=namespace(prefix="", suffix=".dll"),
499 lib=namespace(prefix="", suffix="lib"),
500 import_lib=namespace(prefix="", suffix="lib"),
501 obj=namespace(prefix="", suffix="obj"),
504 elif host_or_target.kernel == "Darwin":
506 dll=namespace(prefix="lib", suffix=".dylib"),
507 lib=namespace(prefix="lib", suffix="a"),
508 import_lib=namespace(prefix=None, suffix=""),
509 obj=namespace(prefix="", suffix="o"),
512 so = ".so.%s" % so_version
517 dll=namespace(prefix="lib", suffix=so),
518 lib=namespace(prefix="lib", suffix="a"),
519 import_lib=namespace(prefix=None, suffix=""),
520 obj=namespace(prefix="", suffix="o"),
523 return library_name_info_impl
526 host_library_name_info = library_name_info_template(host)
527 library_name_info = library_name_info_template(target)
529 set_config("DLL_PREFIX", library_name_info.dll.prefix)
530 set_config("DLL_SUFFIX", library_name_info.dll.suffix)
531 set_config("HOST_DLL_PREFIX", host_library_name_info.dll.prefix)
532 set_config("HOST_DLL_SUFFIX", host_library_name_info.dll.suffix)
533 set_config("LIB_PREFIX", library_name_info.lib.prefix)
534 set_config("LIB_SUFFIX", library_name_info.lib.suffix)
535 set_config("OBJ_SUFFIX", library_name_info.obj.suffix)
536 # Lots of compilation tests depend on this variable being present.
537 add_old_configure_assignment("OBJ_SUFFIX", library_name_info.obj.suffix)
538 set_config("IMPORT_LIB_SUFFIX", library_name_info.import_lib.suffix)
540 "MOZ_DLL_PREFIX", depends(library_name_info.dll.prefix)(lambda s: '"%s"' % s)
543 "MOZ_DLL_SUFFIX", depends(library_name_info.dll.suffix)(lambda s: '"%s"' % s)
545 set_config("WASM_OBJ_SUFFIX", "wasm")
547 # Make `profiling` available to this file even when js/moz.configure
548 # doesn't end up included.
549 profiling = dependable(False)
550 # Same for js_standalone
551 js_standalone = dependable(False)
553 fold_libs = dependable(False)
555 include(include_project_configure)
559 @imports(_from="mozbuild.backend", _import="backends")
560 def build_backends_choices(_):
561 return tuple(backends)
564 @deprecated_option("--enable-build-backend", nargs="+", choices=build_backends_choices)
565 def build_backend(backends):
567 return tuple("+%s" % b for b in backends)
570 imply_option("--build-backends", build_backend)
574 "--enable-artifact-builds",
575 "--disable-compile-environment",
576 "--enable-build-backend",
578 "--enable-application",
582 def build_backend_defaults(
583 artifact_builds, compile_environment, requested_backends, project, application, _
586 project = application[0]
590 if "Tup" in requested_backends:
591 # As a special case, if Tup was requested, do not combine it with any
592 # Make based backend by default.
594 elif artifact_builds:
595 all_backends = ["FasterMake+RecursiveMake"]
597 all_backends = ["RecursiveMake", "FasterMake"]
598 # Normally, we'd use target.os == 'WINNT', but a dependency on target
599 # would require target to depend on --help, as well as host and shell,
600 # and this is not a can of worms we can open at the moment.
602 sys.platform == "win32"
603 and compile_environment
604 and project not in ("mobile/android", "memory", "tools/update-programs")
606 all_backends.append("VisualStudio")
607 return tuple(all_backends) or None
613 default=build_backend_defaults,
614 choices=build_backends_choices,
615 help="Build backends to generate",
619 @depends("--build-backends")
620 def build_backends(backends):
624 set_config("BUILD_BACKENDS", build_backends)
627 @depends(check_build_environment, build_backends)
629 def check_objdir_backend_reuse(build_env, backends):
630 # "Make based" might be RecursiveMake or a hybrid backend, so "Make" is
631 # intentionally vague for use with the substring match below.
632 incompatible_backends = (("Tup", "Make"), ("Make", "Tup"))
633 for backend_file in glob.iglob(
634 os.path.join(build_env.topobjdir, "backend.*Backend")
636 for prev, curr in incompatible_backends:
637 if prev in backend_file and any(curr in b for b in backends):
639 "The active objdir, %s, was previously "
640 "used to build with a %s based backend. "
641 "Change objdirs (by setting MOZ_OBJDIR in "
642 "your mozconfig) or clobber to continue.\n",
648 # Determine whether to build the gtest xul. This happens in automation
649 # on Android and Desktop platforms with the exception of:
650 # - Windows PGO, where linking xul-gtest.dll takes too long;
651 # - Android other than x86_64, where gtest is not required.
658 when="--enable-compile-environment",
660 def build_gtest(pgo, build_project, target, automation, enable_tests):
664 and build_project in ("browser", "comm/mail", "mobile/android")
666 (pgo and target.os == "WINNT")
667 or (target.os == "Android" and target.cpu != "x86_64")
673 "--enable-gtest-in-build",
675 help="{Enable|Force disable} building the gtest libxul during the build.",
676 when="--enable-compile-environment",
679 set_config("LINK_GTEST_DURING_COMPILE", True, when="--enable-gtest-in-build")
682 # ==============================================================
684 "--enable-ui-locale",
686 help="Select the user interface locale (default: en-US)",
689 set_config("MOZ_UI_LOCALE", depends("--enable-ui-locale")(lambda x: x))
691 # clang-plugin location
692 # ==============================================================
695 @depends(host_library_name_info, check_build_environment, when="--enable-clang-plugin")
696 def clang_plugin_path(library_name_info, build_env):
697 topobjdir = build_env.topobjdir
698 if topobjdir.endswith("/js/src"):
699 topobjdir = topobjdir[:-7]
700 return os.path.abspath(
706 % (library_name_info.dll.prefix, library_name_info.dll.suffix),
711 set_config("CLANG_PLUGIN", clang_plugin_path)
712 add_old_configure_assignment("CLANG_PLUGIN", clang_plugin_path)
716 # ==============================================================
717 awk = check_prog("AWK", ("gawk", "mawk", "nawk", "awk"))
719 # Until the AWK variable is not necessary in old-configure
723 def awk_for_old_configure(value):
727 add_old_configure_assignment("AWK", awk_for_old_configure)
731 # ==============================================================
732 perl = check_prog("PERL", ("perl5", "perl"))
734 # Until the PERL variable is not necessary in old-configure
738 def perl_for_old_configure(value):
742 add_old_configure_assignment("PERL", perl_for_old_configure)
746 def perl_version_check(min_version):
748 @checking("for minimum required perl version >= %s" % min_version)
749 def get_perl_version(perl):
755 onerror=lambda: die("Failed to get perl version."),
759 @depends(get_perl_version)
760 def check_perl_version(version):
761 if version < min_version:
762 die("Perl %s or higher is required.", min_version)
765 @checking("for full perl installation")
766 @imports("subprocess")
767 def has_full_perl_installation(perl):
768 ret = subprocess.call([perl, "-e", "use Config; exit(!-d $Config{archlib})"])
771 @depends(has_full_perl_installation)
772 def require_full_perl_installation(has_full_perl_installation):
773 if not has_full_perl_installation:
775 "Cannot find Config.pm or $Config{archlib}. "
776 "A full perl installation is required."
780 perl_version_check("5.006")
784 # ==============================================================
785 option(env="MAKE", nargs=1, help="Path to GNU make")
788 @depends("MAKE", host)
789 def possible_makes(make, host):
791 if host.kernel == "WINNT":
792 candidates.append("mingw32-make")
794 candidates.append(make[0])
795 if host.kernel == "WINNT":
796 candidates.extend(("mozmake", "make", "gmake"))
798 candidates.extend(("gmake", "make"))
802 check_prog("GMAKE", possible_makes, bootstrap="mozmake")
805 # ==============================================================
807 option(env="WATCHMAN", nargs=1, help="Path to the watchman program")
810 @depends(host, "WATCHMAN")
811 @checking("for watchman", callback=lambda w: w.path if w else "not found")
812 def watchman(host, prog):
813 # On Windows, `watchman` is only supported on 64-bit hosts.
814 if host.os == "WINNT" and host.cpu != "x86_64":
818 prog = find_program("watchman")
823 # `watchman version` will talk to the Watchman daemon service.
824 # This can hang due to permissions problems. e.g.
825 # https://github.com/facebook/watchman/issues/376. So use
826 # `watchman --version` to prevent a class of failures.
827 out = check_cmd_output(prog, "--version", onerror=lambda: None)
831 return namespace(path=prog, version=Version(out.strip()))
834 @depends_if(watchman)
835 @checking("for watchman version")
836 def watchman_version(w):
840 set_config("WATCHMAN", watchman.path)
843 @depends_all(hg_version, hg_config, watchman)
844 @checking("for watchman Mercurial integration")
846 def watchman_hg(hg_version, hg_config, watchman):
847 if hg_version < Version("3.8"):
848 return "no (Mercurial 3.8+ required)"
851 mode_disabled = False
853 for k in ("extensions.fsmonitor", "extensions.hgext.fsmonitor"):
854 if k in hg_config and hg_config[k] != "!":
857 mode_disabled = hg_config.get("fsmonitor.mode") == "off"
860 return "no (fsmonitor extension not enabled)"
862 return "no (fsmonitor.mode=off disables fsmonitor)"
867 # Miscellaneous programs
868 # ==============================================================
869 check_prog("XARGS", ("xargs",))
873 def extra_programs(target):
874 if target.kernel == "Darwin":
876 DSYMUTIL=("dsymutil", "llvm-dsymutil"),
877 MKFSHFS=("newfs_hfs", "mkfs.hfsplus"),
878 HFS_TOOL=("hfsplus",),
880 if target.os == "GNU" and target.kernel == "Linux":
881 return namespace(RPMBUILD=("rpmbuild",))
884 check_prog("DSYMUTIL", extra_programs.DSYMUTIL, allow_missing=True)
885 check_prog("MKFSHFS", extra_programs.MKFSHFS, allow_missing=True)
886 check_prog("HFS_TOOL", extra_programs.HFS_TOOL, allow_missing=True)
887 check_prog("RPMBUILD", extra_programs.RPMBUILD, allow_missing=True)
892 def makensis_progs(target):
893 if target.kernel != "WINNT":
903 # Look for nsis installed by msys environment. But only the 32-bit version.
904 # We use an absolute path and insert as the first entry so it is preferred
905 # over a 64-bit exe that may be in PATH.
906 if "MSYSTEM_PREFIX" in os.environ:
907 prefix = os.path.dirname(os.environ["MSYSTEM_PREFIX"])
908 candidates.insert(0, os.path.join(prefix, "mingw32", "bin", "makensis.exe"))
910 return tuple(candidates)
913 nsis = check_prog("MAKENSISU", makensis_progs, allow_missing=True)
915 # Make sure the version of makensis is up to date.
919 @checking("for NSIS version")
921 def nsis_version(nsis, wine):
924 nsis_min_version = "3.0b1"
927 return die("Failed to get nsis version.")
929 if wine and nsis.lower().endswith(".exe"):
930 out = check_cmd_output(wine, nsis, "-version", onerror=onerror)
932 out = check_cmd_output(nsis, "-version", onerror=onerror)
934 m = re.search(r"(?<=v)[0-9]+\.[0-9]+((a|b|rc)[0-9]+)?", out)
937 raise FatalCheckError("Unknown version of makensis")
938 ver = Version(m.group(0))
940 # Versions comparisons don't quite work well with beta versions, so ensure
941 # it works for the non-beta version.
942 if ver < nsis_min_version and (ver >= "3.0a" or ver < "3"):
943 raise FatalCheckError(
944 "To build the installer you must have NSIS"
945 " version %s or greater in your path" % nsis_min_version
951 # And that makensis is 32-bit (but only on Windows).
952 @depends_if(nsis, when=depends(host)(lambda h: h.kernel == "WINNT"))
953 @checking("for 32-bit NSIS")
954 def nsis_binary_type(nsis):
955 bin_type = windows_binary_type(nsis)
956 if bin_type != "win32":
957 raise FatalCheckError("%s is not a 32-bit Windows application" % nsis)
962 # And any flags we have to give to makensis
964 def nsis_flags(host):
965 if host.kernel != "WINNT":
970 set_config("MAKENSISU_FLAGS", nsis_flags)
972 check_prog("7Z", ("7z", "7za"), allow_missing=True, when=target_is_windows)
973 check_prog("UPX", ("upx",), allow_missing=True, when=target_is_windows)
976 @depends(host_c_compiler, c_compiler, bindgen_config_paths)
977 def llvm_objdump(host_c_compiler, c_compiler, bindgen_config_paths):
979 for compiler in (host_c_compiler, c_compiler):
980 if compiler and compiler.type == "clang":
981 clang = compiler.compiler
983 elif compiler and compiler.type == "clang-cl":
984 clang = os.path.join(os.path.dirname(compiler.compiler), "clang")
987 if not clang and bindgen_config_paths:
988 clang = bindgen_config_paths.clang_path
989 llvm_objdump = "llvm-objdump"
991 out = check_cmd_output(
992 clang, "--print-prog-name=llvm-objdump", onerror=lambda: None
995 llvm_objdump = out.rstrip()
996 return (llvm_objdump,)
999 llvm_objdump = check_prog(
1002 what="llvm-objdump",
1003 when="--enable-compile-environment",
1004 paths=clang_search_path,
1007 add_old_configure_assignment("LLVM_OBJDUMP", llvm_objdump)
1010 option("--enable-dtrace", help="Build with dtrace support")
1012 dtrace = check_header(
1014 when="--enable-dtrace",
1015 onerror=lambda: die("dtrace enabled but sys/sdt.h not found"),
1018 set_config("HAVE_DTRACE", True, when=dtrace)
1019 set_define("INCLUDE_MOZILLA_DTRACE", True, when=dtrace)
1020 add_old_configure_assignment("enable_dtrace", "yes", when=dtrace)
1023 option("--disable-icf", help="Disable Identical Code Folding")
1025 add_old_configure_assignment(
1026 "MOZ_DISABLE_ICF", "1", when=depends("--enable-icf")(lambda x: not x)
1032 when=compile_environment,
1033 help="Enable stripping of libs & executables",
1036 # This should be handled as a `when` once bug 1617793 is fixed.
1039 @depends("--enable-strip", c_compiler, when=compile_environment)
1040 def enable_strip(strip, c_compiler):
1041 if strip and c_compiler.type != "clang-cl":
1045 set_config("ENABLE_STRIP", enable_strip)
1048 "--disable-install-strip",
1049 when=compile_environment,
1050 help="Enable stripping of libs & executables when packaging",
1053 # This should be handled as a `when` once bug 1617793 is fixed.
1056 @depends("--enable-install-strip", c_compiler, when=compile_environment)
1057 def enable_install_strip(strip, c_compiler):
1058 if strip and c_compiler.type != "clang-cl":
1062 set_config("PKG_STRIP", enable_install_strip)
1065 @depends("--enable-strip", "--enable-install-strip", when=compile_environment)
1066 def strip(strip, install_strip):
1067 return strip or install_strip
1070 option(env="STRIP_FLAGS", nargs=1, when=strip, help="Flags for the strip command")
1073 @depends("STRIP_FLAGS", profiling, target, when=strip)
1074 def strip_flags(flags, profiling, target):
1076 return flags[0].split()
1078 # Only strip debug info and symbols when profiling is enabled, keeping
1080 if target.kernel == "Darwin":
1082 elif target.os == "Android":
1083 # The tooling we use with Android supports detached symbols, and the
1084 # size increase caused by local symbols are too much for mobile. So,
1085 # don't restrict the amount of stripping with a flag.
1088 return ["--strip-debug"]
1089 # Otherwise strip everything we can, which happens without flags on non-Darwin.
1090 # On Darwin, it tries to strip things it can't, so we need to limit its scope.
1091 elif target.kernel == "Darwin":
1095 set_config("STRIP_FLAGS", strip_flags)
1098 @depends(js_standalone, target)
1099 def system_zlib_default(js_standalone, target):
1100 return js_standalone and target.kernel not in ("WINNT", "Darwin")
1104 "--with-system-zlib",
1106 default=system_zlib_default,
1107 help="{Use|Do not use} system libz",
1111 @depends("--with-system-zlib")
1112 def deprecated_system_zlib_path(value):
1115 "--with-system-zlib=PATH is not supported anymore. Please use "
1116 "--with-system-zlib and set any necessary pkg-config environment variable."
1120 pkg_check_modules("MOZ_ZLIB", "zlib >= 1.2.3", when="--with-system-zlib")
1122 set_config("MOZ_SYSTEM_ZLIB", True, when="--with-system-zlib")
1123 add_old_configure_assignment("MOZ_SYSTEM_ZLIB", True, when="--with-system-zlib")
1126 # Please do not add configure checks from here on.
1128 # Fallthrough to autoconf-based configure
1129 include("build/moz.configure/old.configure")
1132 include("js/sub.configure", when=compile_environment & toolkit)
1135 @depends(check_build_environment, build_project)
1136 @imports("__sandbox__")
1138 @imports(_from="os.path", _import="exists")
1139 def config_status_deps(build_env, build_project):
1141 topsrcdir = build_env.topsrcdir
1142 topobjdir = build_env.topobjdir
1144 if not topobjdir.endswith("js/src"):
1145 extra_deps = [os.path.join(topobjdir, ".mozconfig.json")]
1147 # mozconfig changes may impact js configure.
1148 extra_deps = [os.path.join(topobjdir[:-7], ".mozconfig.json")]
1150 confvars = os.path.join(topsrcdir, build_project, "confvars.sh")
1151 if exists(confvars):
1152 extra_deps.append(confvars)
1155 list(__sandbox__._all_paths)
1158 os.path.join(topsrcdir, "CLOBBER"),
1159 os.path.join(topsrcdir, "configure.in"),
1160 os.path.join(topsrcdir, "js", "src", "configure.in"),
1161 os.path.join(topsrcdir, "nsprpub", "configure"),
1162 os.path.join(topsrcdir, "config", "milestone.txt"),
1163 os.path.join(topsrcdir, "browser", "config", "version.txt"),
1164 os.path.join(topsrcdir, "browser", "config", "version_display.txt"),
1165 os.path.join(topsrcdir, "build", "build_virtualenv_packages.txt"),
1166 os.path.join(topsrcdir, "build", "common_virtualenv_packages.txt"),
1167 os.path.join(topsrcdir, "build", "mach_virtualenv_packages.txt"),
1168 os.path.join(topsrcdir, "python", "mozbuild", "mozbuild", "virtualenv.py"),
1169 os.path.join(topsrcdir, "aclocal.m4"),
1170 os.path.join(topsrcdir, "old-configure.in"),
1171 os.path.join(topsrcdir, "js", "src", "aclocal.m4"),
1172 os.path.join(topsrcdir, "js", "src", "old-configure.in"),
1174 + glob.glob(os.path.join(topsrcdir, "build", "autoconf", "*.m4"))
1178 set_config("CONFIG_STATUS_DEPS", config_status_deps)
1179 # Please do not add anything after setting config_dep_paths.