Bug 1686581 [wpt PR 27175] - [manifest] Explicitly terminate the multiprocessing...
[gecko.git] / moz.configure
blob29952a66ade2c946614dbc1be74172aa469c2881
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")
9 # Note:
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.
15 # - etc.
17 option(
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):
26     if value:
27         return True
30 set_config("MOZ_ARTIFACT_BUILDS", artifact_builds)
32 imply_option(
33     "--enable-artifact-build-symbols",
34     depends(artifact_builds)(lambda v: False if v is None else None),
35     reason="--disable-artifact-builds",
38 option(
39     "--enable-artifact-build-symbols",
40     nargs="?",
41     choices=("full",),
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):
48     if len(value):
49         return value[0]
50     if bool(value):
51         if target.os == "Android" and not automation:
52             return "full"
53         return True
54     return None
57 set_config("MOZ_ARTIFACT_BUILD_SYMBOLS", enable_artifact_build_symbols)
60 @depends("--enable-artifact-builds")
61 def imply_disable_compile_environment(value):
62     if value:
63         return False
66 option(
67     env="MOZ_COPY_PDBS",
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):
81     if compile_env:
82         return True
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):
93     if value:
94         return True
97 set_config("ENABLE_TESTS", enable_tests)
98 set_define("ENABLE_TESTS", enable_tests)
101 @depends(enable_tests)
102 def gtest_has_rtti(value):
103     if value:
104         return "0"
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)
120 option(
121     "--enable-debug",
122     nargs="?",
123     help="Enable building with developer debug info "
124     "(using the given compiler flags).",
128 @depends("--enable-debug")
129 def moz_debug(debug):
130     if debug:
131         return bool(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)))
140 option(
141     "--with-debug-label",
142     nargs="+",
143     help="Debug DEBUG_<value> for each comma-separated value given",
147 @depends(moz_debug, "--with-debug-label")
148 def debug_defines(debug, labels):
149     if debug:
150         return ["DEBUG"] + ["DEBUG_%s" % label for label in labels]
151     return ["NDEBUG", "TRIMMED"]
154 set_config("MOZ_DEBUG_DEFINES", debug_defines)
156 option(
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")
164 def debug_rust():
165     return True
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))
179 option(
180     "--enable-release",
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):
189     if not value:
190         return True
193 add_old_configure_assignment("DEVELOPER_OPTIONS", developer_options)
194 set_config("DEVELOPER_OPTIONS", developer_options)
197 option(
198     env="MOZ_FETCHES_DIR",
199     nargs=1,
200     when="MOZ_AUTOMATION",
201     help="Directory containing fetched artifacts",
205 @depends("MOZ_FETCHES_DIR", when="MOZ_AUTOMATION")
206 def moz_fetches_dir(value):
207     if value:
208         return value[0]
211 @depends(developer_options, moz_fetches_dir)
212 def bootstrap_search_path_order(developer_options, moz_fetches_dir):
213     if moz_fetches_dir:
214         log.debug("Prioritizing MOZ_FETCHES_DIR in toolchain path.")
215         return "prepend"
217     if developer_options:
218         log.debug(
219             "Prioritizing mozbuild state dir in toolchain paths because "
220             "you are not building in release mode."
221         )
222         return "prepend"
224     log.debug(
225         "Prioritizing system over mozbuild state dir in "
226         "toolchain paths because you are building in "
227         "release mode."
228     )
229     return "append"
232 toolchains_base_dir = moz_fetches_dir | mozbuild_state_path
235 @dependable
236 @imports("os")
237 @imports(_from="os", _import="environ")
238 def original_path():
239     return environ["PATH"].split(os.pathsep)
242 @template
243 def bootstrap_search_path(*path_parts, **kwargs):
244     when = kwargs.pop("when", None)
245     if kwargs:
246         configure_error("bootstrap_search_path only takes `when` as keyword argument")
248     @depends(bootstrap_search_path_order, original_path, toolchains_base_dir, when=when)
249     def bootstrap_search_path(order, original_path, toolchains_base_dir):
250         path = [os.path.join(toolchains_base_dir, *path_parts)]
251         if order == "prepend":
252             return path + original_path
253         return original_path + path
255     return bootstrap_search_path
258 @depends(target, host)
259 def want_wine(target, host):
260     return target.kernel == "WINNT" and host.kernel != "WINNT"
263 wine = check_prog(
264     "WINE",
265     ["wine64", "wine"],
266     allow_missing=True,
267     when=want_wine,
268     paths=bootstrap_search_path("wine", "bin", when=want_wine),
270 check_prog("WGET", ("wget",), allow_missing=True)
273 include("build/moz.configure/toolchain.configure", when="--enable-compile-environment")
275 include("build/moz.configure/pkg.configure")
276 # Make this assignment here rather than in pkg.configure to avoid
277 # requiring this file in unit tests.
278 add_old_configure_assignment("PKG_CONFIG", pkg_config)
280 include("build/moz.configure/memory.configure", when="--enable-compile-environment")
281 include("build/moz.configure/headers.configure", when="--enable-compile-environment")
282 include("build/moz.configure/warnings.configure", when="--enable-compile-environment")
283 include("build/moz.configure/flags.configure", when="--enable-compile-environment")
284 include("build/moz.configure/lto-pgo.configure", when="--enable-compile-environment")
285 # rust.configure is included by js/moz.configure.
287 option("--enable-valgrind", help="Enable Valgrind integration hooks")
289 valgrind_h = check_header("valgrind/valgrind.h", when="--enable-valgrind")
292 @depends("--enable-valgrind", valgrind_h)
293 def check_valgrind(valgrind, valgrind_h):
294     if valgrind:
295         if not valgrind_h:
296             die("--enable-valgrind specified but Valgrind is not installed")
297         return True
300 set_define("MOZ_VALGRIND", check_valgrind)
301 set_config("MOZ_VALGRIND", check_valgrind)
304 @depends(target, host)
305 def is_openbsd(target, host):
306     return target.kernel == "OpenBSD" or host.kernel == "OpenBSD"
309 option(
310     env="SO_VERSION",
311     nargs=1,
312     default="1.0",
313     when=is_openbsd,
314     help="Shared library version for OpenBSD systems",
318 @depends("SO_VERSION", when=is_openbsd)
319 def so_version(value):
320     return value
323 @template
324 def library_name_info_template(host_or_target):
325     assert host_or_target in {host, target}
326     compiler = {
327         host: host_c_compiler,
328         target: c_compiler,
329     }[host_or_target]
331     @depends(host_or_target, compiler, so_version)
332     def library_name_info_impl(host_or_target, compiler, so_version):
333         if host_or_target.kernel == "WINNT":
334             # There aren't artifacts for mingw builds, so it's OK that the
335             # results are inaccurate in that case.
336             if compiler and compiler.type != "clang-cl":
337                 return namespace(
338                     dll=namespace(prefix="", suffix=".dll"),
339                     lib=namespace(prefix="lib", suffix="a"),
340                     import_lib=namespace(prefix="lib", suffix="a"),
341                     obj=namespace(prefix="", suffix="o"),
342                 )
344             return namespace(
345                 dll=namespace(prefix="", suffix=".dll"),
346                 lib=namespace(prefix="", suffix="lib"),
347                 import_lib=namespace(prefix="", suffix="lib"),
348                 obj=namespace(prefix="", suffix="obj"),
349             )
351         elif host_or_target.kernel == "Darwin":
352             return namespace(
353                 dll=namespace(prefix="lib", suffix=".dylib"),
354                 lib=namespace(prefix="lib", suffix="a"),
355                 import_lib=namespace(prefix=None, suffix=""),
356                 obj=namespace(prefix="", suffix="o"),
357             )
358         elif so_version:
359             so = ".so.%s" % so_version
360         else:
361             so = ".so"
363         return namespace(
364             dll=namespace(prefix="lib", suffix=so),
365             lib=namespace(prefix="lib", suffix="a"),
366             import_lib=namespace(prefix=None, suffix=""),
367             obj=namespace(prefix="", suffix="o"),
368         )
370     return library_name_info_impl
373 host_library_name_info = library_name_info_template(host)
374 library_name_info = library_name_info_template(target)
376 set_config("DLL_PREFIX", library_name_info.dll.prefix)
377 set_config("DLL_SUFFIX", library_name_info.dll.suffix)
378 set_config("HOST_DLL_PREFIX", host_library_name_info.dll.prefix)
379 set_config("HOST_DLL_SUFFIX", host_library_name_info.dll.suffix)
380 set_config("LIB_PREFIX", library_name_info.lib.prefix)
381 set_config("LIB_SUFFIX", library_name_info.lib.suffix)
382 set_config("OBJ_SUFFIX", library_name_info.obj.suffix)
383 # Lots of compilation tests depend on this variable being present.
384 add_old_configure_assignment("OBJ_SUFFIX", library_name_info.obj.suffix)
385 set_config("IMPORT_LIB_SUFFIX", library_name_info.import_lib.suffix)
386 set_define(
387     "MOZ_DLL_PREFIX", depends(library_name_info.dll.prefix)(lambda s: '"%s"' % s)
389 set_define(
390     "MOZ_DLL_SUFFIX", depends(library_name_info.dll.suffix)(lambda s: '"%s"' % s)
392 set_config("WASM_OBJ_SUFFIX", "wasm")
394 # Make `profiling` available to this file even when js/moz.configure
395 # doesn't end up included.
396 profiling = dependable(False)
397 # Same for js_standalone
398 js_standalone = dependable(False)
399 # Same for fold_libs
400 fold_libs = dependable(False)
402 include(include_project_configure)
405 @depends("--help")
406 @imports(_from="mozbuild.backend", _import="backends")
407 def build_backends_choices(_):
408     return tuple(backends)
411 @deprecated_option("--enable-build-backend", nargs="+", choices=build_backends_choices)
412 def build_backend(backends):
413     if backends:
414         return tuple("+%s" % b for b in backends)
417 imply_option("--build-backends", build_backend)
420 @depends(
421     "--enable-artifact-builds",
422     "--disable-compile-environment",
423     "--enable-build-backend",
424     "--enable-project",
425     "--enable-application",
426     "--help",
428 @imports("sys")
429 def build_backend_defaults(
430     artifact_builds, compile_environment, requested_backends, project, application, _
432     if application:
433         project = application[0]
434     elif project:
435         project = project[0]
437     if "Tup" in requested_backends:
438         # As a special case, if Tup was requested, do not combine it with any
439         # Make based backend by default.
440         all_backends = []
441     elif artifact_builds:
442         all_backends = ["FasterMake+RecursiveMake"]
443     else:
444         all_backends = ["RecursiveMake", "FasterMake"]
445     # Normally, we'd use target.os == 'WINNT', but a dependency on target
446     # would require target to depend on --help, as well as host and shell,
447     # and this is not a can of worms we can open at the moment.
448     if sys.platform == "win32" and compile_environment and project != "mobile/android":
449         all_backends.append("VisualStudio")
450     return tuple(all_backends) or None
453 option(
454     "--build-backends",
455     nargs="+",
456     default=build_backend_defaults,
457     choices=build_backends_choices,
458     help="Build backends to generate",
462 @depends("--build-backends")
463 def build_backends(backends):
464     return backends
467 set_config("BUILD_BACKENDS", build_backends)
470 @depends(check_build_environment, build_backends)
471 @imports("glob")
472 def check_objdir_backend_reuse(build_env, backends):
473     # "Make based" might be RecursiveMake or a hybrid backend, so "Make" is
474     # intentionally vague for use with the substring match below.
475     incompatible_backends = (("Tup", "Make"), ("Make", "Tup"))
476     for backend_file in glob.iglob(
477         os.path.join(build_env.topobjdir, "backend.*Backend")
478     ):
479         for prev, curr in incompatible_backends:
480             if prev in backend_file and any(curr in b for b in backends):
481                 die(
482                     "The active objdir, %s, was previously "
483                     "used to build with a %s based backend. "
484                     "Change objdirs (by setting MOZ_OBJDIR in "
485                     "your mozconfig) or clobber to continue.\n",
486                     build_env.topobjdir,
487                     prev,
488                 )
491 option(
492     "--disable-gtest-in-build",
493     help="Force disable building the gtest libxul during the build.",
494     when="--enable-compile-environment",
497 # Determine whether to build the gtest xul. This happens in automation
498 # on Android and Desktop platforms with the exception of:
499 #  - Windows PGO, where linking xul-gtest.dll takes too long;
500 #  - Android other than x86_64, where gtest is not required.
501 @depends(
502     "MOZ_PGO",
503     build_project,
504     target,
505     "MOZ_AUTOMATION",
506     "--disable-gtest-in-build",
507     enable_tests,
508     when="--enable-compile-environment",
510 def build_gtest(pgo, build_project, target, automation, enabled, enable_tests):
511     if not enable_tests or not enabled:
512         return None
513     if (
514         automation
515         and build_project in ("browser", "comm/mail", "mobile/android")
516         and not (
517             (pgo and target.os == "WINNT")
518             or (target.os == "Android" and target.cpu != "x86_64")
519         )
520     ):
521         return True
524 set_config("LINK_GTEST_DURING_COMPILE", build_gtest)
526 # Localization
527 # ==============================================================
528 option(
529     "--enable-ui-locale",
530     default="en-US",
531     help="Select the user interface locale (default: en-US)",
534 set_config("MOZ_UI_LOCALE", depends("--enable-ui-locale")(lambda x: x))
536 # clang-plugin location
537 # ==============================================================
538 @depends(host_library_name_info, check_build_environment, when="--enable-clang-plugin")
539 def clang_plugin_path(library_name_info, build_env):
540     topobjdir = build_env.topobjdir
541     if topobjdir.endswith("/js/src"):
542         topobjdir = topobjdir[:-7]
543     return os.path.abspath(
544         os.path.join(
545             topobjdir,
546             "build",
547             "clang-plugin",
548             "%sclang-plugin%s"
549             % (library_name_info.dll.prefix, library_name_info.dll.suffix),
550         )
551     )
554 add_old_configure_assignment("CLANG_PLUGIN", clang_plugin_path)
557 # Awk detection
558 # ==============================================================
559 awk = check_prog("AWK", ("gawk", "mawk", "nawk", "awk"))
561 # Until the AWK variable is not necessary in old-configure
562 @depends(awk)
563 def awk_for_old_configure(value):
564     return value
567 add_old_configure_assignment("AWK", awk_for_old_configure)
570 # Perl detection
571 # ==============================================================
572 perl = check_prog("PERL", ("perl5", "perl"))
574 # Until the PERL variable is not necessary in old-configure
575 @depends(perl)
576 def perl_for_old_configure(value):
577     return value
580 add_old_configure_assignment("PERL", perl_for_old_configure)
583 @template
584 def perl_version_check(min_version):
585     @depends(perl)
586     @checking("for minimum required perl version >= %s" % min_version)
587     def get_perl_version(perl):
588         return Version(
589             check_cmd_output(
590                 perl,
591                 "-e",
592                 "print $]",
593                 onerror=lambda: die("Failed to get perl version."),
594             )
595         )
597     @depends(get_perl_version)
598     def check_perl_version(version):
599         if version < min_version:
600             die("Perl %s or higher is required.", min_version)
602     @depends(perl)
603     @checking("for full perl installation")
604     @imports("subprocess")
605     def has_full_perl_installation(perl):
606         ret = subprocess.call([perl, "-e", "use Config; exit(!-d $Config{archlib})"])
607         return ret == 0
609     @depends(has_full_perl_installation)
610     def require_full_perl_installation(has_full_perl_installation):
611         if not has_full_perl_installation:
612             die(
613                 "Cannot find Config.pm or $Config{archlib}. "
614                 "A full perl installation is required."
615             )
618 perl_version_check("5.006")
621 # GNU make detection
622 # ==============================================================
623 option(env="MAKE", nargs=1, help="Path to GNU make")
626 @depends("MAKE", host)
627 def possible_makes(make, host):
628     candidates = []
629     if host.kernel == "WINNT":
630         candidates.append("mingw32-make")
631     if make:
632         candidates.append(make[0])
633     if host.kernel == "WINNT":
634         candidates.extend(("make", "gmake"))
635     else:
636         candidates.extend(("gmake", "make"))
637     return candidates
640 check_prog("GMAKE", possible_makes)
642 # watchman detection
643 # ==============================================================
645 option(env="WATCHMAN", nargs=1, help="Path to the watchman program")
648 @depends(host, "WATCHMAN")
649 @checking("for watchman", callback=lambda w: w.path if w else "not found")
650 def watchman(host, prog):
651     # On Windows, `watchman` is only supported on 64-bit hosts.
652     if host.os == "WINNT" and host.cpu != "x86_64":
653         return
655     if not prog:
656         prog = find_program("watchman")
658     if not prog:
659         return
661     # `watchman version` will talk to the Watchman daemon service.
662     # This can hang due to permissions problems. e.g.
663     # https://github.com/facebook/watchman/issues/376. So use
664     # `watchman --version` to prevent a class of failures.
665     out = check_cmd_output(prog, "--version", onerror=lambda: None)
666     if out is None:
667         return
669     return namespace(path=prog, version=Version(out.strip()))
672 @depends_if(watchman)
673 @checking("for watchman version")
674 def watchman_version(w):
675     return w.version
678 set_config("WATCHMAN", watchman.path)
681 @depends_all(hg_version, hg_config, watchman)
682 @checking("for watchman Mercurial integration")
683 @imports("os")
684 def watchman_hg(hg_version, hg_config, watchman):
685     if hg_version < Version("3.8"):
686         return "no (Mercurial 3.8+ required)"
688     ext_enabled = False
689     mode_disabled = False
691     for k in ("extensions.fsmonitor", "extensions.hgext.fsmonitor"):
692         if k in hg_config and hg_config[k] != "!":
693             ext_enabled = True
695     mode_disabled = hg_config.get("fsmonitor.mode") == "off"
697     if not ext_enabled:
698         return "no (fsmonitor extension not enabled)"
699     if mode_disabled:
700         return "no (fsmonitor.mode=off disables fsmonitor)"
702     return True
705 # Miscellaneous programs
706 # ==============================================================
707 check_prog("XARGS", ("xargs",))
710 @depends(target)
711 def extra_programs(target):
712     if target.kernel == "Darwin":
713         return namespace(
714             DSYMUTIL=("dsymutil", "llvm-dsymutil"),
715             MKFSHFS=("newfs_hfs", "mkfs.hfsplus"),
716             HFS_TOOL=("hfsplus",),
717         )
718     if target.os == "GNU" and target.kernel == "Linux":
719         return namespace(RPMBUILD=("rpmbuild",))
722 check_prog("DSYMUTIL", extra_programs.DSYMUTIL, allow_missing=True)
723 check_prog("MKFSHFS", extra_programs.MKFSHFS, allow_missing=True)
724 check_prog("HFS_TOOL", extra_programs.HFS_TOOL, allow_missing=True)
725 check_prog("RPMBUILD", extra_programs.RPMBUILD, allow_missing=True)
728 @depends(target)
729 @imports("os")
730 def makensis_progs(target):
731     if target.kernel != "WINNT":
732         return
734     candidates = [
735         "makensis-3.01",
736         "makensis-3.0b3",
737         "makensis-3.0b1",
738         "makensis",
739     ]
741     # Look for nsis installed by msys environment. But only the 32-bit version.
742     # We use an absolute path and insert as the first entry so it is preferred
743     # over a 64-bit exe that may be in PATH.
744     if "MSYSTEM_PREFIX" in os.environ:
745         prefix = os.path.dirname(os.environ["MSYSTEM_PREFIX"])
746         candidates.insert(0, os.path.join(prefix, "mingw32", "bin", "makensis.exe"))
748     return tuple(candidates)
751 nsis = check_prog("MAKENSISU", makensis_progs, allow_missing=True)
753 # Make sure the version of makensis is up to date.
754 @depends(nsis, wine)
755 @checking("for NSIS version")
756 @imports("re")
757 def nsis_version(nsis, wine):
758     if not nsis:
759         return None
760     nsis_min_version = "3.0b1"
761     onerror = lambda: die("Failed to get nsis version.")
762     if wine and nsis.lower().endswith(".exe"):
763         out = check_cmd_output(wine, nsis, "-version", onerror=onerror)
764     else:
765         out = check_cmd_output(nsis, "-version", onerror=onerror)
767     m = re.search(r"(?<=v)[0-9]+\.[0-9]+((a|b|rc)[0-9]+)?", out)
769     if not m:
770         raise FatalCheckError("Unknown version of makensis")
771     ver = Version(m.group(0))
773     # Versions comparisons don't quite work well with beta versions, so ensure
774     # it works for the non-beta version.
775     if ver < nsis_min_version and (ver >= "3.0a" or ver < "3"):
776         raise FatalCheckError(
777             "To build the installer you must have NSIS"
778             " version %s or greater in your path" % nsis_min_version
779         )
781     return ver
784 # And that makensis is 32-bit (but only on Windows).
785 @depends_if(nsis, when=depends(host)(lambda h: h.kernel == "WINNT"))
786 @checking("for 32-bit NSIS")
787 def nsis_binary_type(nsis):
788     bin_type = windows_binary_type(nsis)
789     if bin_type != "win32":
790         raise FatalCheckError("%s is not a 32-bit Windows application" % nsis)
792     return "yes"
795 # And any flags we have to give to makensis
796 @depends(host)
797 def nsis_flags(host):
798     if host.kernel != "WINNT":
799         return "-nocd"
800     return ""
803 set_config("MAKENSISU_FLAGS", nsis_flags)
805 check_prog("7Z", ("7z", "7za"), allow_missing=True, when=target_is_windows)
806 check_prog("UPX", ("upx",), allow_missing=True, when=target_is_windows)
809 @depends(host_c_compiler, c_compiler, bindgen_config_paths)
810 def llvm_objdump(host_c_compiler, c_compiler, bindgen_config_paths):
811     clang = None
812     for compiler in (host_c_compiler, c_compiler):
813         if compiler and compiler.type == "clang":
814             clang = compiler.compiler
815             break
816         elif compiler and compiler.type == "clang-cl":
817             clang = os.path.join(os.path.dirname(compiler.compiler), "clang")
818             break
820     if not clang and bindgen_config_paths:
821         clang = bindgen_config_paths.clang_path
822     llvm_objdump = "llvm-objdump"
823     if clang:
824         out = check_cmd_output(
825             clang, "--print-prog-name=llvm-objdump", onerror=lambda: None
826         )
827         if out:
828             llvm_objdump = out.rstrip()
829     return (llvm_objdump,)
832 llvm_objdump = check_prog(
833     "LLVM_OBJDUMP",
834     llvm_objdump,
835     what="llvm-objdump",
836     when="--enable-compile-environment",
837     paths=clang_search_path,
840 add_old_configure_assignment("LLVM_OBJDUMP", llvm_objdump)
843 option("--enable-dtrace", help="Build with dtrace support")
845 dtrace = check_header(
846     "sys/sdt.h",
847     when="--enable-dtrace",
848     onerror=lambda: die("dtrace enabled but sys/sdt.h not found"),
851 set_config("HAVE_DTRACE", True, when=dtrace)
852 set_define("INCLUDE_MOZILLA_DTRACE", True, when=dtrace)
853 add_old_configure_assignment("enable_dtrace", "yes", when=dtrace)
856 option("--disable-icf", help="Disable Identical Code Folding")
858 add_old_configure_assignment(
859     "MOZ_DISABLE_ICF", "1", when=depends("--enable-icf")(lambda x: not x)
863 option(
864     "--enable-strip",
865     when=compile_environment,
866     help="Enable stripping of libs & executables",
869 # This should be handled as a `when` once bug 1617793 is fixed.
870 @depends("--enable-strip", c_compiler, when=compile_environment)
871 def enable_strip(strip, c_compiler):
872     if strip and c_compiler.type != "clang-cl":
873         return True
876 set_config("ENABLE_STRIP", enable_strip)
878 option(
879     "--disable-install-strip",
880     when=compile_environment,
881     help="Enable stripping of libs & executables when packaging",
884 # This should be handled as a `when` once bug 1617793 is fixed.
885 @depends("--enable-install-strip", c_compiler, when=compile_environment)
886 def enable_install_strip(strip, c_compiler):
887     if strip and c_compiler.type != "clang-cl":
888         return True
891 set_config("PKG_STRIP", enable_install_strip)
894 @depends("--enable-strip", "--enable-install-strip", when=compile_environment)
895 def strip(strip, install_strip):
896     return strip or install_strip
899 option(env="STRIP_FLAGS", nargs=1, when=strip, help="Flags for the strip command")
902 @depends("STRIP_FLAGS", profiling, target, when=strip)
903 def strip_flags(flags, profiling, target):
904     if flags:
905         return flags[0].split()
906     if profiling:
907         # Only strip debug info and symbols when profiling is enabled, keeping
908         # local symbols.
909         if target.kernel == "Darwin":
910             return ["-S"]
911         elif target.os == "Android":
912             # The tooling we use with Android supports detached symbols, and the
913             # size increase caused by local symbols are too much for mobile. So,
914             # don't restrict the amount of stripping with a flag.
915             return
916         else:
917             return ["--strip-debug"]
918     # Otherwise strip everything we can, which happens without flags on non-Darwin.
919     # On Darwin, it tries to strip things it can't, so we need to limit its scope.
920     elif target.kernel == "Darwin":
921         return ["-x", "-S"]
924 set_config("STRIP_FLAGS", strip_flags)
927 @depends(js_standalone, target)
928 def system_zlib_default(js_standalone, target):
929     return js_standalone and target.kernel != "WINNT"
932 option(
933     "--with-system-zlib",
934     nargs="?",
935     default=system_zlib_default,
936     help="{Use|Do not use} system libz",
940 @depends("--with-system-zlib")
941 def deprecated_system_zlib_path(value):
942     if len(value) == 1:
943         die(
944             "--with-system-zlib=PATH is not supported anymore. Please use "
945             "--with-system-zlib and set any necessary pkg-config environment variable."
946         )
949 pkg_check_modules("MOZ_ZLIB", "zlib >= 1.2.3", when="--with-system-zlib")
951 set_config("MOZ_SYSTEM_ZLIB", True, when="--with-system-zlib")
952 add_old_configure_assignment("MOZ_SYSTEM_ZLIB", True, when="--with-system-zlib")
955 # Please do not add configure checks from here on.
957 # Fallthrough to autoconf-based configure
958 include("build/moz.configure/old.configure")
960 # JS Subconfigure.
961 include("js/sub.configure", when=compile_environment & toolkit)
964 @depends(check_build_environment, build_project)
965 @imports("__sandbox__")
966 @imports("glob")
967 @imports(_from="os.path", _import="exists")
968 def config_status_deps(build_env, build_project):
970     topsrcdir = build_env.topsrcdir
971     topobjdir = build_env.topobjdir
973     if not topobjdir.endswith("js/src"):
974         extra_deps = [os.path.join(topobjdir, ".mozconfig.json")]
975     else:
976         # mozconfig changes may impact js configure.
977         extra_deps = [os.path.join(topobjdir[:-7], ".mozconfig.json")]
979     confvars = os.path.join(topsrcdir, build_project, "confvars.sh")
980     if exists(confvars):
981         extra_deps.append(confvars)
983     return (
984         list(__sandbox__._all_paths)
985         + extra_deps
986         + [
987             os.path.join(topsrcdir, "CLOBBER"),
988             os.path.join(topsrcdir, "configure.in"),
989             os.path.join(topsrcdir, "js", "src", "configure.in"),
990             os.path.join(topsrcdir, "nsprpub", "configure"),
991             os.path.join(topsrcdir, "config", "milestone.txt"),
992             os.path.join(topsrcdir, "browser", "config", "version.txt"),
993             os.path.join(topsrcdir, "browser", "config", "version_display.txt"),
994             os.path.join(topsrcdir, "build", "build_virtualenv_packages.txt"),
995             os.path.join(topsrcdir, "build", "common_virtualenv_packages.txt"),
996             os.path.join(topsrcdir, "build", "mach_virtualenv_packages.txt"),
997             os.path.join(topsrcdir, "python", "mozbuild", "mozbuild", "virtualenv.py"),
998             os.path.join(topsrcdir, "testing", "mozbase", "packages.txt"),
999             os.path.join(topsrcdir, "aclocal.m4"),
1000             os.path.join(topsrcdir, "old-configure.in"),
1001             os.path.join(topsrcdir, "js", "src", "aclocal.m4"),
1002             os.path.join(topsrcdir, "js", "src", "old-configure.in"),
1003         ]
1004         + glob.glob(os.path.join(topsrcdir, "build", "autoconf", "*.m4"))
1005     )
1008 set_config("CONFIG_STATUS_DEPS", config_status_deps)
1009 # Please do not add anything after setting config_dep_paths.