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)
157 "--enable-rust-debug",
158 default=depends(when="--enable-debug")(lambda: True),
159 help="{Build|Do not build} Rust code with debug assertions turned " "on.",
163 @depends(when="--enable-rust-debug")
168 set_config("MOZ_DEBUG_RUST", debug_rust)
169 set_define("MOZ_DEBUG_RUST", debug_rust)
171 option(env="MOZ_PGO", help="Build with profile guided optimizations")
173 set_config("MOZ_PGO", depends("MOZ_PGO")(lambda x: bool(x)))
176 imply_option("--enable-release", mozilla_official)
177 imply_option("--enable-release", depends_if("MOZ_AUTOMATION")(lambda x: True))
181 default=milestone.is_release_or_beta,
182 help="{Build|Do not build} with more conservative, release "
183 "engineering-oriented options.{ This may slow down builds.|}",
187 @depends("--enable-release")
188 def developer_options(value):
193 add_old_configure_assignment("DEVELOPER_OPTIONS", developer_options)
194 set_config("DEVELOPER_OPTIONS", developer_options)
198 env="MOZ_FETCHES_DIR",
200 when="MOZ_AUTOMATION",
201 help="Directory containing fetched artifacts",
205 @depends("MOZ_FETCHES_DIR", when="MOZ_AUTOMATION")
206 def moz_fetches_dir(value):
212 "--enable-bootstrap",
214 choices=("install", "update"),
215 help="Automatically update/bootstrap some toolchains when they are present but out of date",
219 @depends(developer_options, "--enable-bootstrap", moz_fetches_dir)
220 def bootstrap_search_path_order(developer_options, bootstrap, moz_fetches_dir):
222 log.debug("Prioritizing MOZ_FETCHES_DIR in toolchain path.")
227 "Prioritizing mozbuild state dir in toolchain paths because "
228 "bootstrap mode is enabled."
232 if developer_options:
234 "Prioritizing mozbuild state dir in toolchain paths because "
235 "you are not building in release mode."
240 "Prioritizing system over mozbuild state dir in "
241 "toolchain paths because you are building in "
247 toolchains_base_dir = moz_fetches_dir | mozbuild_state_path
252 @imports(_from="os", _import="environ")
254 return environ["PATH"].split(os.pathsep)
257 @depends("--enable-bootstrap")
258 def bootstrap(value):
260 # value here is either an empty tuple, or a tuple containing either
261 # 'install' or 'update'. All values but 'install' mean 'update'.
262 if len(value) and value[0] == "install":
268 def bootstrap_toolchain_tasks(host_or_target):
269 @depends(host_or_target, when=bootstrap)
271 @imports(_from="mozbuild.toolchains", _import="toolchain_task_definitions")
272 @imports(_from="__builtin__", _import="Exception")
273 def bootstrap_toolchain_tasks(host_or_target):
275 ("x86", "GNU", "Linux"): "linux32",
276 ("x86_64", "GNU", "Linux"): "linux64",
277 ("aarch64", "GNU", "Linux"): "linux64-aarch64",
278 ("x86_64", "OSX", "Darwin"): "macosx64",
279 ("aarch64", "OSX", "Darwin"): "macosx64-aarch64",
280 ("x86_64", "WINNT", "WINNT"): "win64",
281 }.get((host_or_target.cpu, host_or_target.os, host_or_target.kernel))
284 return namespace(prefix=prefix, tasks=toolchain_task_definitions())
288 return bootstrap_toolchain_tasks
291 host_bootstrap_toolchain_tasks = bootstrap_toolchain_tasks(host)
292 target_bootstrap_toolchain_tasks = bootstrap_toolchain_tasks(target)
296 def bootstrap_path(*path_parts, **kwargs):
297 when = kwargs.pop("when", None)
298 context = kwargs.pop("context", host)
301 "bootstrap_path only takes `when` or `context` as keyword arguments"
304 bootstrap_toolchain_tasks = {
305 host: host_bootstrap_toolchain_tasks,
306 target: target_bootstrap_toolchain_tasks,
312 bootstrap_toolchain_tasks,
314 check_build_environment,
318 @imports("subprocess")
319 @imports(_from="mozbuild.util", _import="ensureParentDir")
320 @imports(_from="__builtin__", _import="open")
321 @imports(_from="__builtin__", _import="Exception")
322 def bootstrap_path(bootstrap, toolchains_base_dir, tasks, shell, build_env):
323 def try_bootstrap(exists):
326 label = "toolchain-{}-{}".format(
327 tasks.prefix, path_parts[0].replace("_", "-")
329 task = tasks.tasks.get(label)
332 task_index = task.optimization.get("index-search")
335 task_index = task_index[0].split(".")[-1]
336 artifact = task.attributes["toolchain-artifact"]
337 # `mach artifact toolchain` doesn't support authentication for
339 if not artifact.startswith("public/"):
341 index_file = os.path.join(toolchains_base_dir, "indices", path_parts[0])
343 with open(index_file) as fh:
344 index = fh.read().strip()
347 if index == task_index and exists:
350 "%s bootstrapped toolchain in %s",
351 "Updating" if exists else "Installing",
352 os.path.join(toolchains_base_dir, path_parts[0]),
357 os.path.join(build_env.topsrcdir, "mach"),
364 cwd=toolchains_base_dir,
367 ensureParentDir(index_file)
368 with open(index_file, "w") as fh:
372 path = os.path.join(toolchains_base_dir, *path_parts)
373 exists = os.path.exists(path)
374 if bootstrap and (exists or bootstrap == "install"):
376 if not try_bootstrap(exists):
377 # If there aren't toolchain artifacts to use for this build,
378 # don't return a path.
380 except Exception as e:
382 die("If you can't fix the above, retry with --disable-bootstrap.")
383 # We re-test whether the path exists because it may have been created by
384 # try_bootstrap. Automation will not have gone through the bootstrap
385 # process, but we want to return the path if it exists.
386 if os.path.exists(path):
389 return bootstrap_path
393 def bootstrap_search_path(*path_parts, **kwargs):
395 bootstrap_path(*path_parts, **kwargs),
396 bootstrap_search_path_order,
399 def bootstrap_search_path(path, order, original_path):
402 if order == "prepend":
403 return [path] + original_path
404 return original_path + [path]
406 return bootstrap_search_path
409 @depends(target, host)
410 def want_wine(target, host):
411 return target.kernel == "WINNT" and host.kernel != "WINNT"
419 paths=bootstrap_search_path("wine", "bin", when=want_wine),
421 check_prog("WGET", ("wget",), allow_missing=True)
424 include("build/moz.configure/toolchain.configure", when="--enable-compile-environment")
426 include("build/moz.configure/pkg.configure")
427 # Make this assignment here rather than in pkg.configure to avoid
428 # requiring this file in unit tests.
429 add_old_configure_assignment("PKG_CONFIG", pkg_config)
431 include("build/moz.configure/memory.configure", when="--enable-compile-environment")
432 include("build/moz.configure/headers.configure", when="--enable-compile-environment")
433 include("build/moz.configure/warnings.configure", when="--enable-compile-environment")
434 include("build/moz.configure/flags.configure", when="--enable-compile-environment")
435 include("build/moz.configure/lto-pgo.configure", when="--enable-compile-environment")
436 # rust.configure is included by js/moz.configure.
438 option("--enable-valgrind", help="Enable Valgrind integration hooks")
440 valgrind_h = check_header("valgrind/valgrind.h", when="--enable-valgrind")
443 @depends("--enable-valgrind", valgrind_h)
444 def check_valgrind(valgrind, valgrind_h):
447 die("--enable-valgrind specified but Valgrind is not installed")
451 set_define("MOZ_VALGRIND", check_valgrind)
452 set_config("MOZ_VALGRIND", check_valgrind)
455 @depends(target, host)
456 def is_openbsd(target, host):
457 return target.kernel == "OpenBSD" or host.kernel == "OpenBSD"
465 help="Shared library version for OpenBSD systems",
469 @depends("SO_VERSION", when=is_openbsd)
470 def so_version(value):
475 def library_name_info_template(host_or_target):
476 assert host_or_target in {host, target}
478 host: host_c_compiler,
482 @depends(host_or_target, compiler, so_version)
483 def library_name_info_impl(host_or_target, compiler, so_version):
484 if host_or_target.kernel == "WINNT":
485 # There aren't artifacts for mingw builds, so it's OK that the
486 # results are inaccurate in that case.
487 if compiler and compiler.type != "clang-cl":
489 dll=namespace(prefix="", suffix=".dll"),
490 lib=namespace(prefix="lib", suffix="a"),
491 import_lib=namespace(prefix="lib", suffix="a"),
492 obj=namespace(prefix="", suffix="o"),
496 dll=namespace(prefix="", suffix=".dll"),
497 lib=namespace(prefix="", suffix="lib"),
498 import_lib=namespace(prefix="", suffix="lib"),
499 obj=namespace(prefix="", suffix="obj"),
502 elif host_or_target.kernel == "Darwin":
504 dll=namespace(prefix="lib", suffix=".dylib"),
505 lib=namespace(prefix="lib", suffix="a"),
506 import_lib=namespace(prefix=None, suffix=""),
507 obj=namespace(prefix="", suffix="o"),
510 so = ".so.%s" % so_version
515 dll=namespace(prefix="lib", suffix=so),
516 lib=namespace(prefix="lib", suffix="a"),
517 import_lib=namespace(prefix=None, suffix=""),
518 obj=namespace(prefix="", suffix="o"),
521 return library_name_info_impl
524 host_library_name_info = library_name_info_template(host)
525 library_name_info = library_name_info_template(target)
527 set_config("DLL_PREFIX", library_name_info.dll.prefix)
528 set_config("DLL_SUFFIX", library_name_info.dll.suffix)
529 set_config("HOST_DLL_PREFIX", host_library_name_info.dll.prefix)
530 set_config("HOST_DLL_SUFFIX", host_library_name_info.dll.suffix)
531 set_config("LIB_PREFIX", library_name_info.lib.prefix)
532 set_config("LIB_SUFFIX", library_name_info.lib.suffix)
533 set_config("OBJ_SUFFIX", library_name_info.obj.suffix)
534 # Lots of compilation tests depend on this variable being present.
535 add_old_configure_assignment("OBJ_SUFFIX", library_name_info.obj.suffix)
536 set_config("IMPORT_LIB_SUFFIX", library_name_info.import_lib.suffix)
538 "MOZ_DLL_PREFIX", depends(library_name_info.dll.prefix)(lambda s: '"%s"' % s)
541 "MOZ_DLL_SUFFIX", depends(library_name_info.dll.suffix)(lambda s: '"%s"' % s)
543 set_config("WASM_OBJ_SUFFIX", "wasm")
545 # Make `profiling` available to this file even when js/moz.configure
546 # doesn't end up included.
547 profiling = dependable(False)
548 # Same for js_standalone
549 js_standalone = dependable(False)
551 fold_libs = dependable(False)
553 include(include_project_configure)
557 @imports(_from="mozbuild.backend", _import="backends")
558 def build_backends_choices(_):
559 return tuple(backends)
562 @deprecated_option("--enable-build-backend", nargs="+", choices=build_backends_choices)
563 def build_backend(backends):
565 return tuple("+%s" % b for b in backends)
568 imply_option("--build-backends", build_backend)
572 "--enable-artifact-builds",
573 "--disable-compile-environment",
574 "--enable-build-backend",
576 "--enable-application",
580 def build_backend_defaults(
581 artifact_builds, compile_environment, requested_backends, project, application, _
584 project = application[0]
588 if "Tup" in requested_backends:
589 # As a special case, if Tup was requested, do not combine it with any
590 # Make based backend by default.
592 elif artifact_builds:
593 all_backends = ["FasterMake+RecursiveMake"]
595 all_backends = ["RecursiveMake", "FasterMake"]
596 # Normally, we'd use target.os == 'WINNT', but a dependency on target
597 # would require target to depend on --help, as well as host and shell,
598 # and this is not a can of worms we can open at the moment.
599 if sys.platform == "win32" and compile_environment and project != "mobile/android":
600 all_backends.append("VisualStudio")
601 return tuple(all_backends) or None
607 default=build_backend_defaults,
608 choices=build_backends_choices,
609 help="Build backends to generate",
613 @depends("--build-backends")
614 def build_backends(backends):
618 set_config("BUILD_BACKENDS", build_backends)
621 @depends(check_build_environment, build_backends)
623 def check_objdir_backend_reuse(build_env, backends):
624 # "Make based" might be RecursiveMake or a hybrid backend, so "Make" is
625 # intentionally vague for use with the substring match below.
626 incompatible_backends = (("Tup", "Make"), ("Make", "Tup"))
627 for backend_file in glob.iglob(
628 os.path.join(build_env.topobjdir, "backend.*Backend")
630 for prev, curr in incompatible_backends:
631 if prev in backend_file and any(curr in b for b in backends):
633 "The active objdir, %s, was previously "
634 "used to build with a %s based backend. "
635 "Change objdirs (by setting MOZ_OBJDIR in "
636 "your mozconfig) or clobber to continue.\n",
643 "--disable-gtest-in-build",
644 help="Force disable building the gtest libxul during the build.",
645 when="--enable-compile-environment",
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.
657 "--disable-gtest-in-build",
659 when="--enable-compile-environment",
661 def build_gtest(pgo, build_project, target, automation, enabled, enable_tests):
662 if not enable_tests or not enabled:
666 and build_project in ("browser", "comm/mail", "mobile/android")
668 (pgo and target.os == "WINNT")
669 or (target.os == "Android" and target.cpu != "x86_64")
675 set_config("LINK_GTEST_DURING_COMPILE", build_gtest)
678 # ==============================================================
680 "--enable-ui-locale",
682 help="Select the user interface locale (default: en-US)",
685 set_config("MOZ_UI_LOCALE", depends("--enable-ui-locale")(lambda x: x))
687 # clang-plugin location
688 # ==============================================================
689 @depends(host_library_name_info, check_build_environment, when="--enable-clang-plugin")
690 def clang_plugin_path(library_name_info, build_env):
691 topobjdir = build_env.topobjdir
692 if topobjdir.endswith("/js/src"):
693 topobjdir = topobjdir[:-7]
694 return os.path.abspath(
700 % (library_name_info.dll.prefix, library_name_info.dll.suffix),
705 add_old_configure_assignment("CLANG_PLUGIN", clang_plugin_path)
709 # ==============================================================
710 awk = check_prog("AWK", ("gawk", "mawk", "nawk", "awk"))
712 # Until the AWK variable is not necessary in old-configure
714 def awk_for_old_configure(value):
718 add_old_configure_assignment("AWK", awk_for_old_configure)
722 # ==============================================================
723 perl = check_prog("PERL", ("perl5", "perl"))
725 # Until the PERL variable is not necessary in old-configure
727 def perl_for_old_configure(value):
731 add_old_configure_assignment("PERL", perl_for_old_configure)
735 def perl_version_check(min_version):
737 @checking("for minimum required perl version >= %s" % min_version)
738 def get_perl_version(perl):
744 onerror=lambda: die("Failed to get perl version."),
748 @depends(get_perl_version)
749 def check_perl_version(version):
750 if version < min_version:
751 die("Perl %s or higher is required.", min_version)
754 @checking("for full perl installation")
755 @imports("subprocess")
756 def has_full_perl_installation(perl):
757 ret = subprocess.call([perl, "-e", "use Config; exit(!-d $Config{archlib})"])
760 @depends(has_full_perl_installation)
761 def require_full_perl_installation(has_full_perl_installation):
762 if not has_full_perl_installation:
764 "Cannot find Config.pm or $Config{archlib}. "
765 "A full perl installation is required."
769 perl_version_check("5.006")
773 # ==============================================================
774 option(env="MAKE", nargs=1, help="Path to GNU make")
777 @depends("MAKE", host)
778 def possible_makes(make, host):
780 if host.kernel == "WINNT":
781 candidates.append("mingw32-make")
783 candidates.append(make[0])
784 if host.kernel == "WINNT":
785 candidates.extend(("make", "gmake"))
787 candidates.extend(("gmake", "make"))
791 check_prog("GMAKE", possible_makes)
794 # ==============================================================
796 option(env="WATCHMAN", nargs=1, help="Path to the watchman program")
799 @depends(host, "WATCHMAN")
800 @checking("for watchman", callback=lambda w: w.path if w else "not found")
801 def watchman(host, prog):
802 # On Windows, `watchman` is only supported on 64-bit hosts.
803 if host.os == "WINNT" and host.cpu != "x86_64":
807 prog = find_program("watchman")
812 # `watchman version` will talk to the Watchman daemon service.
813 # This can hang due to permissions problems. e.g.
814 # https://github.com/facebook/watchman/issues/376. So use
815 # `watchman --version` to prevent a class of failures.
816 out = check_cmd_output(prog, "--version", onerror=lambda: None)
820 return namespace(path=prog, version=Version(out.strip()))
823 @depends_if(watchman)
824 @checking("for watchman version")
825 def watchman_version(w):
829 set_config("WATCHMAN", watchman.path)
832 @depends_all(hg_version, hg_config, watchman)
833 @checking("for watchman Mercurial integration")
835 def watchman_hg(hg_version, hg_config, watchman):
836 if hg_version < Version("3.8"):
837 return "no (Mercurial 3.8+ required)"
840 mode_disabled = False
842 for k in ("extensions.fsmonitor", "extensions.hgext.fsmonitor"):
843 if k in hg_config and hg_config[k] != "!":
846 mode_disabled = hg_config.get("fsmonitor.mode") == "off"
849 return "no (fsmonitor extension not enabled)"
851 return "no (fsmonitor.mode=off disables fsmonitor)"
856 # Miscellaneous programs
857 # ==============================================================
858 check_prog("XARGS", ("xargs",))
862 def extra_programs(target):
863 if target.kernel == "Darwin":
865 DSYMUTIL=("dsymutil", "llvm-dsymutil"),
866 MKFSHFS=("newfs_hfs", "mkfs.hfsplus"),
867 HFS_TOOL=("hfsplus",),
869 if target.os == "GNU" and target.kernel == "Linux":
870 return namespace(RPMBUILD=("rpmbuild",))
873 check_prog("DSYMUTIL", extra_programs.DSYMUTIL, allow_missing=True)
874 check_prog("MKFSHFS", extra_programs.MKFSHFS, allow_missing=True)
875 check_prog("HFS_TOOL", extra_programs.HFS_TOOL, allow_missing=True)
876 check_prog("RPMBUILD", extra_programs.RPMBUILD, allow_missing=True)
881 def makensis_progs(target):
882 if target.kernel != "WINNT":
892 # Look for nsis installed by msys environment. But only the 32-bit version.
893 # We use an absolute path and insert as the first entry so it is preferred
894 # over a 64-bit exe that may be in PATH.
895 if "MSYSTEM_PREFIX" in os.environ:
896 prefix = os.path.dirname(os.environ["MSYSTEM_PREFIX"])
897 candidates.insert(0, os.path.join(prefix, "mingw32", "bin", "makensis.exe"))
899 return tuple(candidates)
902 nsis = check_prog("MAKENSISU", makensis_progs, allow_missing=True)
904 # Make sure the version of makensis is up to date.
906 @checking("for NSIS version")
908 def nsis_version(nsis, wine):
911 nsis_min_version = "3.0b1"
912 onerror = lambda: die("Failed to get nsis version.")
913 if wine and nsis.lower().endswith(".exe"):
914 out = check_cmd_output(wine, nsis, "-version", onerror=onerror)
916 out = check_cmd_output(nsis, "-version", onerror=onerror)
918 m = re.search(r"(?<=v)[0-9]+\.[0-9]+((a|b|rc)[0-9]+)?", out)
921 raise FatalCheckError("Unknown version of makensis")
922 ver = Version(m.group(0))
924 # Versions comparisons don't quite work well with beta versions, so ensure
925 # it works for the non-beta version.
926 if ver < nsis_min_version and (ver >= "3.0a" or ver < "3"):
927 raise FatalCheckError(
928 "To build the installer you must have NSIS"
929 " version %s or greater in your path" % nsis_min_version
935 # And that makensis is 32-bit (but only on Windows).
936 @depends_if(nsis, when=depends(host)(lambda h: h.kernel == "WINNT"))
937 @checking("for 32-bit NSIS")
938 def nsis_binary_type(nsis):
939 bin_type = windows_binary_type(nsis)
940 if bin_type != "win32":
941 raise FatalCheckError("%s is not a 32-bit Windows application" % nsis)
946 # And any flags we have to give to makensis
948 def nsis_flags(host):
949 if host.kernel != "WINNT":
954 set_config("MAKENSISU_FLAGS", nsis_flags)
956 check_prog("7Z", ("7z", "7za"), allow_missing=True, when=target_is_windows)
957 check_prog("UPX", ("upx",), allow_missing=True, when=target_is_windows)
960 @depends(host_c_compiler, c_compiler, bindgen_config_paths)
961 def llvm_objdump(host_c_compiler, c_compiler, bindgen_config_paths):
963 for compiler in (host_c_compiler, c_compiler):
964 if compiler and compiler.type == "clang":
965 clang = compiler.compiler
967 elif compiler and compiler.type == "clang-cl":
968 clang = os.path.join(os.path.dirname(compiler.compiler), "clang")
971 if not clang and bindgen_config_paths:
972 clang = bindgen_config_paths.clang_path
973 llvm_objdump = "llvm-objdump"
975 out = check_cmd_output(
976 clang, "--print-prog-name=llvm-objdump", onerror=lambda: None
979 llvm_objdump = out.rstrip()
980 return (llvm_objdump,)
983 llvm_objdump = check_prog(
987 when="--enable-compile-environment",
988 paths=clang_search_path,
991 add_old_configure_assignment("LLVM_OBJDUMP", llvm_objdump)
994 option("--enable-dtrace", help="Build with dtrace support")
996 dtrace = check_header(
998 when="--enable-dtrace",
999 onerror=lambda: die("dtrace enabled but sys/sdt.h not found"),
1002 set_config("HAVE_DTRACE", True, when=dtrace)
1003 set_define("INCLUDE_MOZILLA_DTRACE", True, when=dtrace)
1004 add_old_configure_assignment("enable_dtrace", "yes", when=dtrace)
1007 option("--disable-icf", help="Disable Identical Code Folding")
1009 add_old_configure_assignment(
1010 "MOZ_DISABLE_ICF", "1", when=depends("--enable-icf")(lambda x: not x)
1016 when=compile_environment,
1017 help="Enable stripping of libs & executables",
1020 # This should be handled as a `when` once bug 1617793 is fixed.
1021 @depends("--enable-strip", c_compiler, when=compile_environment)
1022 def enable_strip(strip, c_compiler):
1023 if strip and c_compiler.type != "clang-cl":
1027 set_config("ENABLE_STRIP", enable_strip)
1030 "--disable-install-strip",
1031 when=compile_environment,
1032 help="Enable stripping of libs & executables when packaging",
1035 # This should be handled as a `when` once bug 1617793 is fixed.
1036 @depends("--enable-install-strip", c_compiler, when=compile_environment)
1037 def enable_install_strip(strip, c_compiler):
1038 if strip and c_compiler.type != "clang-cl":
1042 set_config("PKG_STRIP", enable_install_strip)
1045 @depends("--enable-strip", "--enable-install-strip", when=compile_environment)
1046 def strip(strip, install_strip):
1047 return strip or install_strip
1050 option(env="STRIP_FLAGS", nargs=1, when=strip, help="Flags for the strip command")
1053 @depends("STRIP_FLAGS", profiling, target, when=strip)
1054 def strip_flags(flags, profiling, target):
1056 return flags[0].split()
1058 # Only strip debug info and symbols when profiling is enabled, keeping
1060 if target.kernel == "Darwin":
1062 elif target.os == "Android":
1063 # The tooling we use with Android supports detached symbols, and the
1064 # size increase caused by local symbols are too much for mobile. So,
1065 # don't restrict the amount of stripping with a flag.
1068 return ["--strip-debug"]
1069 # Otherwise strip everything we can, which happens without flags on non-Darwin.
1070 # On Darwin, it tries to strip things it can't, so we need to limit its scope.
1071 elif target.kernel == "Darwin":
1075 set_config("STRIP_FLAGS", strip_flags)
1078 @depends(js_standalone, target)
1079 def system_zlib_default(js_standalone, target):
1080 return js_standalone and target.kernel != "WINNT"
1084 "--with-system-zlib",
1086 default=system_zlib_default,
1087 help="{Use|Do not use} system libz",
1091 @depends("--with-system-zlib")
1092 def deprecated_system_zlib_path(value):
1095 "--with-system-zlib=PATH is not supported anymore. Please use "
1096 "--with-system-zlib and set any necessary pkg-config environment variable."
1100 pkg_check_modules("MOZ_ZLIB", "zlib >= 1.2.3", when="--with-system-zlib")
1102 set_config("MOZ_SYSTEM_ZLIB", True, when="--with-system-zlib")
1103 add_old_configure_assignment("MOZ_SYSTEM_ZLIB", True, when="--with-system-zlib")
1106 # Please do not add configure checks from here on.
1108 # Fallthrough to autoconf-based configure
1109 include("build/moz.configure/old.configure")
1112 include("js/sub.configure", when=compile_environment & toolkit)
1115 @depends(check_build_environment, build_project)
1116 @imports("__sandbox__")
1118 @imports(_from="os.path", _import="exists")
1119 def config_status_deps(build_env, build_project):
1121 topsrcdir = build_env.topsrcdir
1122 topobjdir = build_env.topobjdir
1124 if not topobjdir.endswith("js/src"):
1125 extra_deps = [os.path.join(topobjdir, ".mozconfig.json")]
1127 # mozconfig changes may impact js configure.
1128 extra_deps = [os.path.join(topobjdir[:-7], ".mozconfig.json")]
1130 confvars = os.path.join(topsrcdir, build_project, "confvars.sh")
1131 if exists(confvars):
1132 extra_deps.append(confvars)
1135 list(__sandbox__._all_paths)
1138 os.path.join(topsrcdir, "CLOBBER"),
1139 os.path.join(topsrcdir, "configure.in"),
1140 os.path.join(topsrcdir, "js", "src", "configure.in"),
1141 os.path.join(topsrcdir, "nsprpub", "configure"),
1142 os.path.join(topsrcdir, "config", "milestone.txt"),
1143 os.path.join(topsrcdir, "browser", "config", "version.txt"),
1144 os.path.join(topsrcdir, "browser", "config", "version_display.txt"),
1145 os.path.join(topsrcdir, "build", "build_virtualenv_packages.txt"),
1146 os.path.join(topsrcdir, "build", "common_virtualenv_packages.txt"),
1147 os.path.join(topsrcdir, "build", "mach_virtualenv_packages.txt"),
1148 os.path.join(topsrcdir, "python", "mozbuild", "mozbuild", "virtualenv.py"),
1149 os.path.join(topsrcdir, "testing", "mozbase", "packages.txt"),
1150 os.path.join(topsrcdir, "aclocal.m4"),
1151 os.path.join(topsrcdir, "old-configure.in"),
1152 os.path.join(topsrcdir, "js", "src", "aclocal.m4"),
1153 os.path.join(topsrcdir, "js", "src", "old-configure.in"),
1155 + glob.glob(os.path.join(topsrcdir, "build", "autoconf", "*.m4"))
1159 set_config("CONFIG_STATUS_DEPS", config_status_deps)
1160 # Please do not add anything after setting config_dep_paths.