Bug 1676898 [wpt PR 26509] - Move wpt/css/composite-bgcolor-animation to wpt/css...
[gecko.git] / moz.configure
blob5d0aa5260735d0fbfc346f6211509ef55e14d1ae
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 wine = check_prog(
177     "WINE",
178     ["wine64", "wine"],
179     allow_missing=True,
180     when=depends(target, host)(
181         lambda t, h: t.kernel == "WINNT" and h.kernel != "WINNT"
182     ),
184 check_prog("WGET", ("wget",), allow_missing=True)
187 include("build/moz.configure/toolchain.configure", when="--enable-compile-environment")
189 include("build/moz.configure/pkg.configure")
190 # Make this assignment here rather than in pkg.configure to avoid
191 # requiring this file in unit tests.
192 add_old_configure_assignment("PKG_CONFIG", pkg_config)
194 include("build/moz.configure/memory.configure", when="--enable-compile-environment")
195 include("build/moz.configure/headers.configure", when="--enable-compile-environment")
196 include("build/moz.configure/warnings.configure", when="--enable-compile-environment")
197 include("build/moz.configure/lto-pgo.configure", when="--enable-compile-environment")
198 include("build/moz.configure/flags.configure", when="--enable-compile-environment")
199 # rust.configure is included by js/moz.configure.
201 option("--enable-valgrind", help="Enable Valgrind integration hooks")
203 valgrind_h = check_header("valgrind/valgrind.h", when="--enable-valgrind")
206 @depends("--enable-valgrind", valgrind_h)
207 def check_valgrind(valgrind, valgrind_h):
208     if valgrind:
209         if not valgrind_h:
210             die("--enable-valgrind specified but Valgrind is not installed")
211         return True
214 set_define("MOZ_VALGRIND", check_valgrind)
215 set_config("MOZ_VALGRIND", check_valgrind)
218 @depends(target, host)
219 def is_openbsd(target, host):
220     return target.kernel == "OpenBSD" or host.kernel == "OpenBSD"
223 option(
224     env="SO_VERSION",
225     nargs=1,
226     default="1.0",
227     when=is_openbsd,
228     help="Shared library version for OpenBSD systems",
232 @depends("SO_VERSION", when=is_openbsd)
233 def so_version(value):
234     return value
237 @template
238 def library_name_info_template(host_or_target):
239     assert host_or_target in {host, target}
240     compiler = {
241         host: host_c_compiler,
242         target: c_compiler,
243     }[host_or_target]
245     @depends(host_or_target, compiler, so_version)
246     def library_name_info_impl(host_or_target, compiler, so_version):
247         if host_or_target.kernel == "WINNT":
248             # There aren't artifacts for mingw builds, so it's OK that the
249             # results are inaccurate in that case.
250             if compiler and compiler.type != "clang-cl":
251                 return namespace(
252                     dll=namespace(prefix="", suffix=".dll"),
253                     lib=namespace(prefix="lib", suffix="a"),
254                     import_lib=namespace(prefix="lib", suffix="a"),
255                     obj=namespace(prefix="", suffix="o"),
256                 )
258             return namespace(
259                 dll=namespace(prefix="", suffix=".dll"),
260                 lib=namespace(prefix="", suffix="lib"),
261                 import_lib=namespace(prefix="", suffix="lib"),
262                 obj=namespace(prefix="", suffix="obj"),
263             )
265         elif host_or_target.kernel == "Darwin":
266             return namespace(
267                 dll=namespace(prefix="lib", suffix=".dylib"),
268                 lib=namespace(prefix="lib", suffix="a"),
269                 import_lib=namespace(prefix=None, suffix=""),
270                 obj=namespace(prefix="", suffix="o"),
271             )
272         elif so_version:
273             so = ".so.%s" % so_version
274         else:
275             so = ".so"
277         return namespace(
278             dll=namespace(prefix="lib", suffix=so),
279             lib=namespace(prefix="lib", suffix="a"),
280             import_lib=namespace(prefix=None, suffix=""),
281             obj=namespace(prefix="", suffix="o"),
282         )
284     return library_name_info_impl
287 host_library_name_info = library_name_info_template(host)
288 library_name_info = library_name_info_template(target)
290 set_config("DLL_PREFIX", library_name_info.dll.prefix)
291 set_config("DLL_SUFFIX", library_name_info.dll.suffix)
292 set_config("HOST_DLL_PREFIX", host_library_name_info.dll.prefix)
293 set_config("HOST_DLL_SUFFIX", host_library_name_info.dll.suffix)
294 set_config("LIB_PREFIX", library_name_info.lib.prefix)
295 set_config("LIB_SUFFIX", library_name_info.lib.suffix)
296 set_config("OBJ_SUFFIX", library_name_info.obj.suffix)
297 # Lots of compilation tests depend on this variable being present.
298 add_old_configure_assignment("OBJ_SUFFIX", library_name_info.obj.suffix)
299 set_config("IMPORT_LIB_SUFFIX", library_name_info.import_lib.suffix)
300 set_define(
301     "MOZ_DLL_PREFIX", depends(library_name_info.dll.prefix)(lambda s: '"%s"' % s)
303 set_define(
304     "MOZ_DLL_SUFFIX", depends(library_name_info.dll.suffix)(lambda s: '"%s"' % s)
306 set_config("WASM_OBJ_SUFFIX", "wasm")
308 # Make `profiling` available to this file even when js/moz.configure
309 # doesn't end up included.
310 profiling = dependable(False)
311 # Same for js_standalone
312 js_standalone = dependable(False)
313 # Same for fold_libs
314 fold_libs = dependable(False)
316 include(include_project_configure)
319 @depends("--help")
320 @imports(_from="mozbuild.backend", _import="backends")
321 def build_backends_choices(_):
322     return tuple(backends)
325 @deprecated_option("--enable-build-backend", nargs="+", choices=build_backends_choices)
326 def build_backend(backends):
327     if backends:
328         return tuple("+%s" % b for b in backends)
331 imply_option("--build-backends", build_backend)
334 @depends(
335     "--enable-artifact-builds",
336     "--disable-compile-environment",
337     "--enable-build-backend",
338     "--enable-project",
339     "--enable-application",
340     "--help",
342 @imports("sys")
343 def build_backend_defaults(
344     artifact_builds, compile_environment, requested_backends, project, application, _
346     if application:
347         project = application[0]
348     elif project:
349         project = project[0]
351     if "Tup" in requested_backends:
352         # As a special case, if Tup was requested, do not combine it with any
353         # Make based backend by default.
354         all_backends = []
355     elif artifact_builds:
356         all_backends = ["FasterMake+RecursiveMake"]
357     else:
358         all_backends = ["RecursiveMake", "FasterMake"]
359     # Normally, we'd use target.os == 'WINNT', but a dependency on target
360     # would require target to depend on --help, as well as host and shell,
361     # and this is not a can of worms we can open at the moment.
362     if sys.platform == "win32" and compile_environment and project != "mobile/android":
363         all_backends.append("VisualStudio")
364     return tuple(all_backends) or None
367 option(
368     "--build-backends",
369     nargs="+",
370     default=build_backend_defaults,
371     choices=build_backends_choices,
372     help="Build backends to generate",
376 @depends("--build-backends")
377 def build_backends(backends):
378     return backends
381 set_config("BUILD_BACKENDS", build_backends)
384 @depends(check_build_environment, build_backends)
385 @imports("glob")
386 def check_objdir_backend_reuse(build_env, backends):
387     # "Make based" might be RecursiveMake or a hybrid backend, so "Make" is
388     # intentionally vague for use with the substring match below.
389     incompatible_backends = (("Tup", "Make"), ("Make", "Tup"))
390     for backend_file in glob.iglob(
391         os.path.join(build_env.topobjdir, "backend.*Backend")
392     ):
393         for prev, curr in incompatible_backends:
394             if prev in backend_file and any(curr in b for b in backends):
395                 die(
396                     "The active objdir, %s, was previously "
397                     "used to build with a %s based backend. "
398                     "Change objdirs (by setting MOZ_OBJDIR in "
399                     "your mozconfig) or clobber to continue.\n",
400                     build_env.topobjdir,
401                     prev,
402                 )
405 option(
406     "--disable-gtest-in-build",
407     help="Force disable building the gtest libxul during the build.",
408     when="--enable-compile-environment",
411 # Determine whether to build the gtest xul. This happens in automation
412 # on Android and Desktop platforms with the exception of:
413 #  - Windows PGO, where linking xul-gtest.dll takes too long;
414 #  - Android other than x86_64, where gtest is not required.
415 @depends(
416     "MOZ_PGO",
417     build_project,
418     target,
419     "MOZ_AUTOMATION",
420     "--disable-gtest-in-build",
421     enable_tests,
422     when="--enable-compile-environment",
424 def build_gtest(pgo, build_project, target, automation, enabled, enable_tests):
425     if not enable_tests or not enabled:
426         return None
427     if (
428         automation
429         and build_project in ("browser", "comm/mail", "mobile/android")
430         and not (
431             (pgo and target.os == "WINNT")
432             or (target.os == "Android" and target.cpu != "x86_64")
433         )
434     ):
435         return True
438 set_config("LINK_GTEST_DURING_COMPILE", build_gtest)
440 # Localization
441 # ==============================================================
442 option(
443     "--enable-ui-locale",
444     default="en-US",
445     help="Select the user interface locale (default: en-US)",
448 set_config("MOZ_UI_LOCALE", depends("--enable-ui-locale")(lambda x: x))
450 # clang-plugin location
451 # ==============================================================
452 @depends(host_library_name_info, check_build_environment, when="--enable-clang-plugin")
453 def clang_plugin_path(library_name_info, build_env):
454     topobjdir = build_env.topobjdir
455     if topobjdir.endswith("/js/src"):
456         topobjdir = topobjdir[:-7]
457     return os.path.abspath(
458         os.path.join(
459             topobjdir,
460             "build",
461             "clang-plugin",
462             "%sclang-plugin%s"
463             % (library_name_info.dll.prefix, library_name_info.dll.suffix),
464         )
465     )
468 add_old_configure_assignment("CLANG_PLUGIN", clang_plugin_path)
471 # Awk detection
472 # ==============================================================
473 awk = check_prog("AWK", ("gawk", "mawk", "nawk", "awk"))
475 # Until the AWK variable is not necessary in old-configure
476 @depends(awk)
477 def awk_for_old_configure(value):
478     return value
481 add_old_configure_assignment("AWK", awk_for_old_configure)
484 # Perl detection
485 # ==============================================================
486 perl = check_prog("PERL", ("perl5", "perl"))
488 # Until the PERL variable is not necessary in old-configure
489 @depends(perl)
490 def perl_for_old_configure(value):
491     return value
494 add_old_configure_assignment("PERL", perl_for_old_configure)
497 @template
498 def perl_version_check(min_version):
499     @depends(perl)
500     @checking("for minimum required perl version >= %s" % min_version)
501     def get_perl_version(perl):
502         return Version(
503             check_cmd_output(
504                 perl,
505                 "-e",
506                 "print $]",
507                 onerror=lambda: die("Failed to get perl version."),
508             )
509         )
511     @depends(get_perl_version)
512     def check_perl_version(version):
513         if version < min_version:
514             die("Perl %s or higher is required.", min_version)
516     @depends(perl)
517     @checking("for full perl installation")
518     @imports("subprocess")
519     def has_full_perl_installation(perl):
520         ret = subprocess.call([perl, "-e", "use Config; exit(!-d $Config{archlib})"])
521         return ret == 0
523     @depends(has_full_perl_installation)
524     def require_full_perl_installation(has_full_perl_installation):
525         if not has_full_perl_installation:
526             die(
527                 "Cannot find Config.pm or $Config{archlib}. "
528                 "A full perl installation is required."
529             )
532 perl_version_check("5.006")
535 # GNU make detection
536 # ==============================================================
537 option(env="MAKE", nargs=1, help="Path to GNU make")
540 @depends("MAKE", host)
541 def possible_makes(make, host):
542     candidates = []
543     if host.kernel == "WINNT":
544         candidates.append("mingw32-make")
545     if make:
546         candidates.append(make[0])
547     if host.kernel == "WINNT":
548         candidates.extend(("make", "gmake"))
549     else:
550         candidates.extend(("gmake", "make"))
551     return candidates
554 check_prog("GMAKE", possible_makes)
556 # watchman detection
557 # ==============================================================
559 option(env="WATCHMAN", nargs=1, help="Path to the watchman program")
562 @depends(host, "WATCHMAN")
563 @checking("for watchman", callback=lambda w: w.path if w else "not found")
564 def watchman(host, prog):
565     # On Windows, `watchman` is only supported on 64-bit hosts.
566     if host.os == "WINNT" and host.cpu != "x86_64":
567         return
569     if not prog:
570         prog = find_program("watchman")
572     if not prog:
573         return
575     # `watchman version` will talk to the Watchman daemon service.
576     # This can hang due to permissions problems. e.g.
577     # https://github.com/facebook/watchman/issues/376. So use
578     # `watchman --version` to prevent a class of failures.
579     out = check_cmd_output(prog, "--version", onerror=lambda: None)
580     if out is None:
581         return
583     return namespace(path=prog, version=Version(out.strip()))
586 @depends_if(watchman)
587 @checking("for watchman version")
588 def watchman_version(w):
589     return w.version
592 set_config("WATCHMAN", watchman.path)
595 @depends_all(hg_version, hg_config, watchman)
596 @checking("for watchman Mercurial integration")
597 @imports("os")
598 def watchman_hg(hg_version, hg_config, watchman):
599     if hg_version < Version("3.8"):
600         return "no (Mercurial 3.8+ required)"
602     ext_enabled = False
603     mode_disabled = False
605     for k in ("extensions.fsmonitor", "extensions.hgext.fsmonitor"):
606         if k in hg_config and hg_config[k] != "!":
607             ext_enabled = True
609     mode_disabled = hg_config.get("fsmonitor.mode") == "off"
611     if not ext_enabled:
612         return "no (fsmonitor extension not enabled)"
613     if mode_disabled:
614         return "no (fsmonitor.mode=off disables fsmonitor)"
616     return True
619 # Miscellaneous programs
620 # ==============================================================
621 check_prog("XARGS", ("xargs",))
624 @depends(target)
625 def extra_programs(target):
626     if target.kernel == "Darwin":
627         return namespace(
628             DSYMUTIL=("dsymutil", "llvm-dsymutil"),
629             MKFSHFS=("newfs_hfs", "mkfs.hfsplus"),
630             HFS_TOOL=("hfsplus",),
631         )
632     if target.os == "GNU" and target.kernel == "Linux":
633         return namespace(RPMBUILD=("rpmbuild",))
636 check_prog("DSYMUTIL", extra_programs.DSYMUTIL, allow_missing=True)
637 check_prog("MKFSHFS", extra_programs.MKFSHFS, allow_missing=True)
638 check_prog("HFS_TOOL", extra_programs.HFS_TOOL, allow_missing=True)
639 check_prog("RPMBUILD", extra_programs.RPMBUILD, allow_missing=True)
642 @depends(target)
643 @imports("os")
644 def makensis_progs(target):
645     if target.kernel != "WINNT":
646         return
648     candidates = [
649         "makensis-3.01",
650         "makensis-3.0b3",
651         "makensis-3.0b1",
652         "makensis",
653     ]
655     # Look for nsis installed by msys environment. But only the 32-bit version.
656     # We use an absolute path and insert as the first entry so it is preferred
657     # over a 64-bit exe that may be in PATH.
658     if "MSYSTEM_PREFIX" in os.environ:
659         prefix = os.path.dirname(os.environ["MSYSTEM_PREFIX"])
660         candidates.insert(0, os.path.join(prefix, "mingw32", "bin", "makensis.exe"))
662     return tuple(candidates)
665 nsis = check_prog("MAKENSISU", makensis_progs, allow_missing=True)
667 # Make sure the version of makensis is up to date.
668 @depends(nsis, wine)
669 @checking("for NSIS version")
670 @imports("re")
671 def nsis_version(nsis, wine):
672     if not nsis:
673         return None
674     nsis_min_version = "3.0b1"
675     onerror = lambda: die("Failed to get nsis version.")
676     if wine and nsis.lower().endswith(".exe"):
677         out = check_cmd_output(wine, nsis, "-version", onerror=onerror)
678     else:
679         out = check_cmd_output(nsis, "-version", onerror=onerror)
681     m = re.search(r"(?<=v)[0-9]+\.[0-9]+((a|b|rc)[0-9]+)?", out)
683     if not m:
684         raise FatalCheckError("Unknown version of makensis")
685     ver = Version(m.group(0))
687     # Versions comparisons don't quite work well with beta versions, so ensure
688     # it works for the non-beta version.
689     if ver < nsis_min_version and (ver >= "3.0a" or ver < "3"):
690         raise FatalCheckError(
691             "To build the installer you must have NSIS"
692             " version %s or greater in your path" % nsis_min_version
693         )
695     return ver
698 # And that makensis is 32-bit (but only on Windows).
699 @depends_if(nsis, when=depends(host)(lambda h: h.kernel == "WINNT"))
700 @checking("for 32-bit NSIS")
701 def nsis_binary_type(nsis):
702     bin_type = windows_binary_type(nsis)
703     if bin_type != "win32":
704         raise FatalCheckError("%s is not a 32-bit Windows application" % nsis)
706     return "yes"
709 # And any flags we have to give to makensis
710 @depends(host)
711 def nsis_flags(host):
712     if host.kernel != "WINNT":
713         return "-nocd"
714     return ""
717 set_config("MAKENSISU_FLAGS", nsis_flags)
719 check_prog("7Z", ("7z", "7za"), allow_missing=True, when=target_is_windows)
720 check_prog("UPX", ("upx",), allow_missing=True, when=target_is_windows)
723 @depends(host_c_compiler, c_compiler, bindgen_config_paths)
724 def llvm_objdump(host_c_compiler, c_compiler, bindgen_config_paths):
725     clang = None
726     for compiler in (host_c_compiler, c_compiler):
727         if compiler and compiler.type == "clang":
728             clang = compiler.compiler
729             break
730         elif compiler and compiler.type == "clang-cl":
731             clang = os.path.join(os.path.dirname(compiler.compiler), "clang")
732             break
734     if not clang and bindgen_config_paths:
735         clang = bindgen_config_paths.clang_path
736     llvm_objdump = "llvm-objdump"
737     if clang:
738         out = check_cmd_output(
739             clang, "--print-prog-name=llvm-objdump", onerror=lambda: None
740         )
741         if out:
742             llvm_objdump = out.rstrip()
743     return (llvm_objdump,)
746 llvm_objdump = check_prog(
747     "LLVM_OBJDUMP",
748     llvm_objdump,
749     what="llvm-objdump",
750     when="--enable-compile-environment",
751     paths=toolchain_search_path,
754 add_old_configure_assignment("LLVM_OBJDUMP", llvm_objdump)
757 option("--enable-dtrace", help="Build with dtrace support")
759 dtrace = check_header(
760     "sys/sdt.h",
761     when="--enable-dtrace",
762     onerror=lambda: die("dtrace enabled but sys/sdt.h not found"),
765 set_config("HAVE_DTRACE", True, when=dtrace)
766 set_define("INCLUDE_MOZILLA_DTRACE", True, when=dtrace)
767 add_old_configure_assignment("enable_dtrace", "yes", when=dtrace)
770 option("--disable-icf", help="Disable Identical Code Folding")
772 add_old_configure_assignment(
773     "MOZ_DISABLE_ICF", "1", when=depends("--enable-icf")(lambda x: not x)
777 option(
778     "--enable-strip",
779     when=compile_environment,
780     help="Enable stripping of libs & executables",
783 # This should be handled as a `when` once bug 1617793 is fixed.
784 @depends("--enable-strip", c_compiler, when=compile_environment)
785 def enable_strip(strip, c_compiler):
786     if strip and c_compiler.type != "clang-cl":
787         return True
790 set_config("ENABLE_STRIP", enable_strip)
792 option(
793     "--disable-install-strip",
794     when=compile_environment,
795     help="Enable stripping of libs & executables when packaging",
798 # This should be handled as a `when` once bug 1617793 is fixed.
799 @depends("--enable-install-strip", c_compiler, when=compile_environment)
800 def enable_install_strip(strip, c_compiler):
801     if strip and c_compiler.type != "clang-cl":
802         return True
805 set_config("PKG_STRIP", enable_install_strip)
808 @depends("--enable-strip", "--enable-install-strip", when=compile_environment)
809 def strip(strip, install_strip):
810     return strip or install_strip
813 option(env="STRIP_FLAGS", nargs=1, when=strip, help="Flags for the strip command")
816 @depends("STRIP_FLAGS", target, when=strip)
817 def strip_flags(flags, target):
818     if flags:
819         return flags[0].split()
820     # Strip everything we can, which happens without flags on non-Darwin.
821     # On Darwin, it tries to strip things it can't, so we need to limit its scope.
822     if target.kernel == "Darwin":
823         return ["-x", "-S"]
826 set_config("STRIP_FLAGS", strip_flags)
829 @depends(js_standalone, target)
830 def system_zlib_default(js_standalone, target):
831     return js_standalone and target.kernel != "WINNT"
834 option(
835     "--with-system-zlib",
836     nargs="?",
837     default=system_zlib_default,
838     help="{Use|Do not use} system libz",
842 @depends("--with-system-zlib")
843 def deprecated_system_zlib_path(value):
844     if len(value) == 1:
845         die(
846             "--with-system-zlib=PATH is not supported anymore. Please use "
847             "--with-system-zlib and set any necessary pkg-config environment variable."
848         )
851 pkg_check_modules("MOZ_ZLIB", "zlib >= 1.2.3", when="--with-system-zlib")
853 set_config("MOZ_SYSTEM_ZLIB", True, when="--with-system-zlib")
854 add_old_configure_assignment("MOZ_SYSTEM_ZLIB", True, when="--with-system-zlib")
857 # Please do not add configure checks from here on.
859 # Fallthrough to autoconf-based configure
860 include("build/moz.configure/old.configure")
862 # JS Subconfigure.
863 include("js/sub.configure", when=compile_environment & toolkit)
866 @depends(check_build_environment, build_project)
867 @imports("__sandbox__")
868 @imports("glob")
869 @imports(_from="os.path", _import="exists")
870 def config_status_deps(build_env, build_project):
872     topsrcdir = build_env.topsrcdir
873     topobjdir = build_env.topobjdir
875     if not topobjdir.endswith("js/src"):
876         extra_deps = [os.path.join(topobjdir, ".mozconfig.json")]
877     else:
878         # mozconfig changes may impact js configure.
879         extra_deps = [os.path.join(topobjdir[:-7], ".mozconfig.json")]
881     confvars = os.path.join(topsrcdir, build_project, "confvars.sh")
882     if exists(confvars):
883         extra_deps.append(confvars)
885     return (
886         list(__sandbox__._all_paths)
887         + extra_deps
888         + [
889             os.path.join(topsrcdir, "CLOBBER"),
890             os.path.join(topsrcdir, "configure.in"),
891             os.path.join(topsrcdir, "js", "src", "configure.in"),
892             os.path.join(topsrcdir, "nsprpub", "configure"),
893             os.path.join(topsrcdir, "config", "milestone.txt"),
894             os.path.join(topsrcdir, "browser", "config", "version.txt"),
895             os.path.join(topsrcdir, "browser", "config", "version_display.txt"),
896             os.path.join(topsrcdir, "build", "build_virtualenv_packages.txt"),
897             os.path.join(topsrcdir, "build", "common_virtualenv_packages.txt"),
898             os.path.join(topsrcdir, "build", "mach_virtualenv_packages.txt"),
899             os.path.join(topsrcdir, "python", "mozbuild", "mozbuild", "virtualenv.py"),
900             os.path.join(topsrcdir, "testing", "mozbase", "packages.txt"),
901             os.path.join(topsrcdir, "aclocal.m4"),
902             os.path.join(topsrcdir, "old-configure.in"),
903             os.path.join(topsrcdir, "js", "src", "aclocal.m4"),
904             os.path.join(topsrcdir, "js", "src", "old-configure.in"),
905         ]
906         + glob.glob(os.path.join(topsrcdir, "build", "autoconf", "*.m4"))
907     )
910 set_config("CONFIG_STATUS_DEPS", config_status_deps)
911 # Please do not add anything after setting config_dep_paths.