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/.
8 # Set the MOZ_CONFIGURE_OPTIONS variable with all the options that
9 # were passed somehow (environment, command line, mozconfig)
11 @imports(_from="mozbuild.shellutil", _import="quote")
12 @imports(_from="mozbuild.util", _import="ensure_unicode")
13 @imports(_from="mozbuild.util", _import="system_encoding")
14 @imports("__sandbox__")
15 def all_configure_options():
18 for option in __sandbox__._options.values():
19 # __sandbox__._options contains items for both option.name and
20 # option.env. But it's also an OrderedDict, meaning both are
22 # Also ignore OLD_CONFIGURE and MOZCONFIG because they're not
24 if option == previous or option.env in ("OLD_CONFIGURE", "MOZCONFIG"):
27 value = __sandbox__._value_for(option)
28 # We only want options that were explicitly given on the command
29 # line, the environment, or mozconfig, and that differ from the
33 and value.origin not in ("default", "implied")
34 and value != option.default
37 ensure_unicode(__sandbox__._raw_options[option], system_encoding)
39 # We however always include options that are sent to old configure
40 # because we don't know their actual defaults. (Keep the conditions
41 # separate for ease of understanding and ease of removal)
43 option.help == "Help missing for old configure options"
44 and option in __sandbox__._raw_options
47 ensure_unicode(__sandbox__._raw_options[option], system_encoding)
50 # We shouldn't need this, but currently, quote will return a byte string
51 # if result is empty, and that's not wanted here.
58 set_config("MOZ_CONFIGURE_OPTIONS", all_configure_options)
62 def fold_libs(target):
63 return target.os in ("WINNT", "OSX", "Android")
66 set_config("MOZ_FOLD_LIBS", fold_libs)
69 # ==============================================================
70 # Some of the options here imply an option from js/moz.configure,
71 # so, need to be declared before the include.
76 help="Enable jprof profiling tool (needs mozilla/tools/jprof)",
80 @depends("--enable-jprof")
86 set_config("MOZ_JPROF", jprof)
87 set_define("MOZ_JPROF", jprof)
88 imply_option("--enable-profiling", jprof)
92 def gecko_profiler(target):
93 if target.os == "Android":
94 return target.cpu in ("aarch64", "arm", "x86", "x86_64")
95 elif target.kernel == "Linux":
96 return target.cpu in ("aarch64", "arm", "x86", "x86_64", "mips64")
97 elif target.kernel == "FreeBSD":
98 return target.cpu in ("aarch64", "x86_64")
99 return target.os in ("OSX", "WINNT")
102 @depends(gecko_profiler)
103 def gecko_profiler_define(value):
108 set_config("MOZ_GECKO_PROFILER", gecko_profiler_define)
109 set_define("MOZ_GECKO_PROFILER", gecko_profiler_define)
112 # Whether code to parse ELF binaries should be compiled for the Gecko profiler
113 # (for symbol table dumping).
114 @depends(gecko_profiler, target)
115 def gecko_profiler_parse_elf(value, target):
116 # Currently we only want to build this code on Linux (including Android) and BSD.
117 # For Android, this is in order to dump symbols from Android system, where
118 # on other platforms there exist alternatives that don't require bloating
119 # up our binary size. For Linux more generally, we use this in profile
120 # pre-symbolication support, since MozDescribeCodeAddress doesn't do
121 # anything useful on that platform. (Ideally, we would update
122 # MozDescribeCodeAddress to call into some Rust crates that parse ELF and
123 # DWARF data, but build system issues currently prevent Rust from being
125 if value and (target.kernel == "Linux" or target.kernel == "FreeBSD"):
129 set_config("MOZ_GECKO_PROFILER_PARSE_ELF", gecko_profiler_parse_elf)
130 set_define("MOZ_GECKO_PROFILER_PARSE_ELF", gecko_profiler_parse_elf)
132 # enable this by default if the profiler is enabled
133 # Note: also requires jemalloc
134 set_config("MOZ_PROFILER_MEMORY", gecko_profiler_define)
135 set_define("MOZ_PROFILER_MEMORY", gecko_profiler_define)
142 # Artifact builds are included because the downloaded artifacts can
144 when=artifact_builds | depends(when="--enable-replace-malloc")(lambda: True),
146 def dmd_default(debug, milestone, build_project):
147 return bool(build_project == "browser" and (debug or milestone.is_nightly))
154 help="{Enable|Disable} Dark Matter Detector (heap profiler). "
155 "Also enables jemalloc, replace-malloc and profiling",
159 @depends("--enable-dmd")
165 set_config("MOZ_DMD", dmd)
166 set_define("MOZ_DMD", dmd)
167 imply_option("--enable-profiling", dmd)
168 imply_option("--enable-jemalloc", dmd, when=compile_environment)
169 imply_option("--enable-replace-malloc", dmd, when=compile_environment)
172 # midir-based Web MIDI support
173 # ==============================================================
175 def midir_linux_support(target):
177 target.kernel == "Linux" and target.os != "Android" and target.cpu != "riscv64"
181 @depends(target, midir_linux_support)
182 def midir_support(target, midir_linux_support):
183 if target.os in ("WINNT", "OSX") or midir_linux_support:
187 set_config("MOZ_WEBMIDI_MIDIR_IMPL", midir_support)
190 # Enable various cubeb backends
191 # ==============================================================
193 def audio_backends_default(target):
194 if target.os == "Android":
199 elif target.os in ("DragonFly", "FreeBSD", "SunOS"):
201 elif target.os == "OpenBSD":
203 elif target.os == "OSX":
204 return ("audiounit",)
205 elif target.os == "NetBSD":
207 elif target.os == "SunOS":
209 elif target.os == "WINNT":
212 return ("pulseaudio",)
216 "--enable-audio-backends",
230 default=audio_backends_default,
231 help="{Enable|Disable} various cubeb backends",
235 @depends("--enable-audio-backends", target)
236 def imply_aaudio(values, target):
237 if any("aaudio" in value for value in values) and target.os != "Android":
238 die("Cannot enable AAudio on %s", target.os)
239 return any("aaudio" in value for value in values) or None
242 @depends("--enable-audio-backends", target)
243 def imply_alsa(values, target):
245 any("alsa" in value for value in values)
246 and target.kernel != "Linux"
247 and target.os != "FreeBSD"
249 die("Cannot enable ALSA on %s", target.os)
250 return any("alsa" in value for value in values) or None
253 @depends("--enable-audio-backends", target)
254 def imply_audiounit(values, target):
256 any("audiounit" in value for value in values)
257 and target.os != "OSX"
258 and target.kernel != "Darwin"
260 die("Cannot enable AudioUnit on %s", target.os)
261 return any("audiounit" in value for value in values) or None
264 @depends("--enable-audio-backends")
265 def imply_jack(values):
266 return any("jack" in value for value in values) or None
269 @depends("--enable-audio-backends", target)
270 def imply_opensl(values, target):
271 if any("opensl" in value for value in values) and target.os != "Android":
272 die("Cannot enable OpenSL on %s", target.os)
273 return any("opensl" in value for value in values) or None
276 @depends("--enable-audio-backends", target)
277 def imply_oss(values, target):
278 if any("oss" in value for value in values) and (
279 target.os == "Android" or target.os == "OSX" or target.os == "WINNT"
281 die("Cannot enable OSS on %s", target.os)
282 return any("oss" in value for value in values) or None
285 @depends("--enable-audio-backends", target)
286 def imply_pulseaudio(values, target):
287 if any("pulseaudio" in value for value in values) and (
288 target.os == "Android" or target.os == "OSX" or target.os == "WINNT"
290 die("Cannot enable PulseAudio on %s", target.os)
291 return any("pulseaudio" in value for value in values) or None
294 @depends("--enable-audio-backends", target)
295 def imply_sndio(values, target):
296 if any("sndio" in value for value in values) and (
297 target.os == "Android" or target.os == "OSX" or target.os == "WINNT"
299 die("Cannot enable sndio on %s", target.os)
300 return any("sndio" in value for value in values) or None
303 @depends("--enable-audio-backends", target)
304 def imply_sunaudio(values, target):
305 if any("sunaudio" in value for value in values) and (
306 target.os != "NetBSD" and target.os != "SunOS"
308 die("Cannot enable sunaudio on %s", target.os)
309 return any("sunaudio" in value for value in values) or None
312 @depends("--enable-audio-backends", target)
313 def imply_wasapi(values, target):
314 if any("wasapi" in value for value in values) and target.os != "WINNT":
315 die("Cannot enable WASAPI on %s", target.os)
316 return any("wasapi" in value for value in values) or None
319 set_config("MOZ_AAUDIO", imply_aaudio, when="--enable-audio-backends")
321 imply_option("--enable-alsa", imply_alsa, reason="--enable-audio-backends")
323 set_config("MOZ_AUDIOUNIT_RUST", imply_audiounit, when="--enable-audio-backends")
325 imply_option("--enable-jack", imply_jack, reason="--enable-audio-backends")
327 set_config("MOZ_OPENSL", imply_opensl, when="--enable-audio-backends")
329 set_config("MOZ_OSS", imply_oss, when="--enable-audio-backends")
331 imply_option("--enable-pulseaudio", imply_pulseaudio, reason="--enable-audio-backends")
333 imply_option("--enable-sndio", imply_sndio, reason="--enable-audio-backends")
335 set_config("MOZ_SUNAUDIO", imply_sunaudio, when="--enable-audio-backends")
337 set_config("MOZ_WASAPI", imply_wasapi, when="--enable-audio-backends")
340 # ==============================================================
341 option("--enable-alsa", env="MOZ_ALSA", help="Enable ALSA audio backend.")
344 @depends("--enable-alsa", midir_linux_support)
345 def enable_alsa_or_midir_linux_support(alsa_enabled, midir_linux_support):
346 return alsa_enabled or midir_linux_support
349 pkg_check_modules("MOZ_ALSA", "alsa", when=enable_alsa_or_midir_linux_support)
351 set_config("MOZ_ALSA", True, when="--enable-alsa")
352 set_define("MOZ_ALSA", True, when="--enable-alsa")
355 # ==============================================================
356 system_lib_option("--enable-jack", env="MOZ_JACK", help="Enable JACK audio backend.")
358 jack = pkg_check_modules("MOZ_JACK", "jack", when="--enable-jack")
360 set_config("MOZ_JACK", depends_if(jack)(lambda _: True))
362 # PulseAudio cubeb backend
363 # ==============================================================
365 "--enable-pulseaudio",
366 env="MOZ_PULSEAUDIO",
367 help="{Enable|Disable} PulseAudio audio backend.",
370 pulseaudio = pkg_check_modules("MOZ_PULSEAUDIO", "libpulse", when="--enable-pulseaudio")
372 set_config("MOZ_PULSEAUDIO", depends_if(pulseaudio)(lambda _: True))
373 set_define("MOZ_PULSEAUDIO", depends_if(pulseaudio)(lambda _: True))
375 # sndio cubeb backend
376 # ==============================================================
377 system_lib_option("--enable-sndio", env="MOZ_SNDIO", help="Enable sndio audio backend.")
379 sndio = pkg_check_modules("MOZ_SNDIO", "sndio", when="--enable-sndio")
381 set_config("MOZ_SNDIO", depends_if(sndio)(lambda _: True))
384 # ==============================================================
385 include("../js/moz.configure")
389 # ==============================================================
390 include("../build/moz.configure/node.configure")
393 # ==============================================================
394 set_define("JSON_USE_EXCEPTION", 0)
397 # ==============================================================
398 option("--with-l10n-base", nargs=1, env="L10NBASEDIR", help="Path to l10n repositories")
401 @depends("--with-l10n-base", "MOZ_AUTOMATION", build_environment)
402 @imports(_from="os.path", _import="isdir")
403 @imports(_from="os.path", _import="expanduser")
404 @imports(_from="os", _import="environ")
405 def l10n_base(value, automation, build_env):
409 die("Invalid value --with-l10n-base, %s doesn't exist", path)
411 path = os.path.join(build_env.topsrcdir, "../l10n-central")
415 "MOZBUILD_STATE_PATH", expanduser(os.path.join("~", ".mozbuild"))
419 return os.path.realpath(os.path.abspath(path))
422 set_config("L10NBASEDIR", l10n_base)
426 # ==============================================================
428 def toolkit_choices(target):
429 if target.os == "WINNT":
430 return ("cairo-windows",)
431 elif target.os == "OSX":
432 return ("cairo-cocoa",)
433 elif target.os == "Android":
434 return ("cairo-android",)
436 # cairo-gtk3 - X11 backend with optional Wayland backend (auto detected)
437 # cairo-gtk3-wayland - Wayland backend with optional X11 backend (auto detected)
438 # cairo-gtk3-x11-wayland - builds explicitly with X11 & Wayland backends
441 "cairo-gtk3-wayland",
442 "cairo-gtk3-x11-wayland",
443 "cairo-gtk3-wayland-only",
444 "cairo-gtk3-x11-only",
448 @depends(toolkit_choices)
449 def toolkit_default(choices):
454 "--enable-default-toolkit",
456 choices=toolkit_choices,
457 default=toolkit_default,
458 help="Select default toolkit",
462 @depends("--enable-default-toolkit")
463 def full_toolkit(value):
468 @depends(full_toolkit)
469 def toolkit(toolkit):
470 if toolkit.startswith("cairo-gtk3"):
471 widget_toolkit = "gtk"
473 widget_toolkit = toolkit.replace("cairo-", "")
474 return widget_toolkit
477 set_config("MOZ_WIDGET_TOOLKIT", toolkit)
478 add_old_configure_assignment("MOZ_WIDGET_TOOLKIT", toolkit)
482 def toolkit_define(toolkit):
483 if toolkit != "windows":
484 return "MOZ_WIDGET_%s" % toolkit.upper()
487 set_define(toolkit_define, True)
491 def toolkit_gtk(toolkit):
492 return toolkit == "gtk"
495 @depends(toolkit_gtk, full_toolkit)
496 def toolkit_gtk_x11(toolkit_gtk, full_toolkit):
497 return toolkit_gtk and full_toolkit != "cairo-gtk3-wayland-only"
500 @depends(full_toolkit)
501 def toolkit_gtk_x11_optional(full_toolkit):
502 return full_toolkit == "cairo-gtk3-wayland"
505 @depends(toolkit_gtk, full_toolkit)
506 def toolkit_gtk_wayland(toolkit_gtk, full_toolkit):
507 return toolkit_gtk and full_toolkit != "cairo-gtk3-x11-only"
510 @depends(full_toolkit)
511 def toolkit_gtk_wayland_optional(full_toolkit):
512 return full_toolkit == "cairo-gtk3"
516 # ==============================================================
517 wayland_headers = pkg_check_modules(
519 "gtk+-wayland-3.0 >= 3.14 xkbcommon >= 0.4.1",
520 allow_missing=toolkit_gtk_wayland_optional,
521 when=toolkit_gtk_wayland,
525 @depends(wayland_headers, toolkit_gtk, artifact_builds, toolkit_gtk_wayland)
526 def wayland_headers(wayland, toolkit_gtk, artifacts, toolkit_gtk_wayland):
527 if not toolkit_gtk_wayland:
529 if toolkit_gtk and artifacts:
534 set_config("MOZ_WAYLAND", depends_if(wayland_headers)(lambda _: True))
535 set_define("MOZ_WAYLAND", depends_if(wayland_headers)(lambda _: True))
538 # Hardware-accelerated video decode with VAAPI and V4L2 on Linux
539 # ==============================================================
540 @depends(target, toolkit_gtk)
541 def vaapi(target, toolkit_gtk):
542 # VAAPI is mostly used on x86(-64) but is sometimes used on ARM/ARM64 SOCs.
543 if target.cpu in ("arm", "aarch64", "x86", "x86_64") and toolkit_gtk:
547 @depends(target, toolkit_gtk)
548 def v4l2(target, toolkit_gtk):
549 # V4L2 decode is only used in GTK/Linux and generally only appears on
551 if target.cpu in ("arm", "aarch64", "riscv64") and toolkit_gtk:
555 set_config("MOZ_ENABLE_VAAPI", True, when=vaapi)
556 set_config("MOZ_ENABLE_V4L2", True, when=v4l2)
557 set_define("MOZ_ENABLE_VAAPI", True, when=vaapi)
558 set_define("MOZ_ENABLE_V4L2", True, when=v4l2)
562 # ==============================================================
563 option("--with-gl-provider", nargs=1, help="Set GL provider backend type")
566 @depends("--with-gl-provider")
567 def gl_provider(value):
572 @depends(gl_provider)
573 def gl_provider_define(provider):
575 return "GLContextProvider%s" % provider
578 set_define("MOZ_GL_PROVIDER", gl_provider_define)
581 @depends(gl_provider, toolkit_gtk)
582 def gl_default_provider(value, toolkit_gtk):
589 set_config("MOZ_GL_PROVIDER", gl_provider)
590 set_config("MOZ_GL_DEFAULT_PROVIDER", gl_default_provider)
593 @depends(gl_default_provider)
594 def gl_provider_define(provider):
596 return "GL_PROVIDER_%s" % provider
599 set_define(gl_provider_define, True)
603 # ==============================================================
605 def pdf_printing(toolkit):
606 if toolkit in ("windows", "gtk", "android"):
610 set_config("MOZ_PDF_PRINTING", pdf_printing)
611 set_define("MOZ_PDF_PRINTING", pdf_printing)
614 # Event loop instrumentation
615 # ==============================================================
616 option(env="MOZ_INSTRUMENT_EVENT_LOOP", help="Force-enable event loop instrumentation")
619 @depends("MOZ_INSTRUMENT_EVENT_LOOP", toolkit)
620 def instrument_event_loop(value, toolkit):
622 toolkit in ("windows", "gtk", "cocoa", "android") and value.origin == "default"
627 set_config("MOZ_INSTRUMENT_EVENT_LOOP", instrument_event_loop)
628 set_define("MOZ_INSTRUMENT_EVENT_LOOP", instrument_event_loop)
631 # Fontconfig Freetype
632 # ==============================================================
633 option(env="USE_FC_FREETYPE", help="Force-enable the use of fontconfig freetype")
636 @depends("USE_FC_FREETYPE", toolkit)
637 def fc_freetype(value, toolkit):
638 if value or (toolkit == "gtk" and value.origin == "default"):
642 set_define("USE_FC_FREETYPE", fc_freetype)
645 # ==============================================================
646 pkg_check_modules("MOZ_PANGO", "pango >= 1.22.0", when=toolkit_gtk)
649 # ==============================================================
650 fontconfig_info = pkg_check_modules(
651 "_FONTCONFIG", "fontconfig >= 2.7.0", when=fc_freetype
655 @depends(fc_freetype)
656 def check_for_freetype2(fc_freetype):
661 # Check for freetype2. Flags are combined with fontconfig flags.
662 freetype2_info = pkg_check_modules(
663 "_FT2", "freetype2 >= 9.10.3", when=check_for_freetype2
667 @depends(fontconfig_info, freetype2_info)
668 def freetype2_combined_info(fontconfig_info, freetype2_info):
669 if not freetype2_info:
671 if not fontconfig_info:
672 return freetype2_info
674 cflags=freetype2_info.cflags + fontconfig_info.cflags,
675 libs=freetype2_info.libs + fontconfig_info.libs,
679 set_define("MOZ_HAVE_FREETYPE2", depends_if(freetype2_info)(lambda _: True))
682 # Apple platform decoder support
683 # ==============================================================
685 def applemedia(toolkit):
686 if toolkit in ("cocoa", "uikit"):
690 set_config("MOZ_APPLEMEDIA", applemedia)
691 set_define("MOZ_APPLEMEDIA", applemedia)
693 # Windows Media Foundation support
694 # ==============================================================
695 option("--disable-wmf", help="Disable support for Windows Media Foundation")
698 @depends("--disable-wmf", target, "--help")
699 def wmf(value, target, _):
700 enabled = bool(value)
701 if value.origin == "default":
702 # Enable Windows Media Foundation support by default.
703 # Note our minimum SDK version is Windows 7 SDK, so we are (currently)
704 # guaranteed to have a recent-enough SDK to build WMF.
705 enabled = target.os == "WINNT"
706 if enabled and target.os != "WINNT":
707 die("Cannot enable Windows Media Foundation support on %s", target.os)
712 @depends(c_compiler, when=wmf)
713 def wmfmediaengine(c_compiler):
714 return c_compiler and c_compiler.type == "clang-cl"
717 set_config("MOZ_WMF", wmf)
718 set_define("MOZ_WMF", wmf)
720 set_config("MOZ_WMF_MEDIA_ENGINE", True, when=wmfmediaengine)
721 set_define("MOZ_WMF_MEDIA_ENGINE", True, when=wmfmediaengine)
723 # FFmpeg H264/AAC Decoding Support
724 # ==============================================================
725 option("--disable-ffmpeg", help="Disable FFmpeg for fragmented H264/AAC decoding")
728 @depends("--disable-ffmpeg", target)
729 def ffmpeg(value, target):
730 enabled = bool(value)
731 if value.origin == "default":
732 enabled = target.os not in ("Android", "WINNT")
737 set_config("MOZ_FFMPEG", ffmpeg)
738 set_define("MOZ_FFMPEG", ffmpeg)
740 # AV1 Video Codec Support
741 # ==============================================================
742 option("--disable-av1", help="Disable av1 video support")
745 @depends("--enable-av1")
751 @depends(target, when=av1 & compile_environment)
752 def dav1d_asm(target):
753 if target.cpu in ("aarch64", "x86", "x86_64"):
757 @depends(target, when=av1 & compile_environment)
758 def dav1d_nasm(target):
759 if target.cpu in ("x86", "x86_64"):
760 return namespace(version="2.14", what="AV1")
763 set_config("MOZ_DAV1D_ASM", dav1d_asm)
764 set_define("MOZ_DAV1D_ASM", dav1d_asm)
765 set_config("MOZ_AV1", av1)
766 set_define("MOZ_AV1", av1)
768 # JXL Image Codec Support
769 # ==============================================================
770 option("--disable-jxl", help="Disable jxl image support")
773 @depends("--disable-jxl", milestone.is_nightly)
774 def jxl(value, is_nightly):
775 if is_nightly and value:
779 set_config("MOZ_JXL", jxl)
780 set_define("MOZ_JXL", jxl)
782 set_config("MOZ_SAMPLE_TYPE_FLOAT32", True)
783 set_define("MOZ_SAMPLE_TYPE_FLOAT32", True)
785 set_define("MOZ_VORBIS", True)
786 set_config("MOZ_VORBIS", True)
789 "--disable-real-time-tracing",
790 help="Disable tracing of real-time audio callbacks",
793 set_config("MOZ_REAL_TIME_TRACING", True, when="--enable-real-time-tracing")
794 set_define("MOZ_REAL_TIME_TRACING", True, when="--enable-real-time-tracing")
796 # OpenMAX IL Decoding Support
797 # ==============================================================
798 option("--enable-openmax", help="Enable OpenMAX IL for video/audio decoding")
801 @depends("--enable-openmax")
803 enabled = bool(value)
808 set_config("MOZ_OMX", openmax)
809 set_define("MOZ_OMX", openmax)
813 # ==============================================================
814 @depends(target, wmf)
815 def eme_choices(target, wmf):
817 target.kernel in ("WINNT", "Linux")
818 and target.os != "Android"
819 and target.cpu in ("x86", "x86_64")
822 return ("widevine", "wmfcdm")
824 if target.kernel == "WINNT" and target.cpu == "aarch64":
826 if target.os in ("OSX"):
830 # Widevine is enabled by default in desktop browser builds.
831 @depends(build_project, eme_choices)
832 def eme_default(build_project, choices):
833 if build_project == "browser":
843 help="{Enable|Disable} support for Encrypted Media Extensions",
847 @depends("--enable-eme", when=eme_choices)
848 def eme_modules(value):
852 # Fallback to an empty list when eme_choices is empty, setting eme_modules to
854 set_config("MOZ_EME_MODULES", eme_modules | dependable([]))
857 # Media Foundation CDM support
858 # ==============================================================
859 @depends(eme_modules, when=wmfmediaengine)
861 if "wmfcdm" in modules:
865 set_config("MOZ_WMF_CDM", True, when=wmfcdm)
866 set_define("MOZ_WMF_CDM", True, when=wmfcdm)
870 name="--enable-chrome-format",
871 help="Select FORMAT of chrome files during packaging.",
873 choices=("omni", "jar", "flat"),
878 @depends("--enable-chrome-format")
879 def packager_format(value):
883 set_config("MOZ_PACKAGER_FORMAT", packager_format)
885 # The packager minifies two different types of files: non-JS (mostly property
886 # files for l10n), and JS. Setting MOZ_PACKAGER_MINIFY only minifies the
887 # former. Firefox doesn't yet minify JS, due to concerns about debuggability.
889 # Also, the JS minification setup really only works correctly on Android:
890 # we need extra setup to use the newly-built shell for Linux and Windows,
891 # and cross-compilation for macOS requires some extra care.
894 @depends(target_is_android, "--enable-debug", milestone.is_nightly)
895 def enable_minify_default(is_android, debug, is_nightly):
896 if is_android and not debug and not is_nightly:
897 return ("properties", "js")
898 return ("properties",)
902 name="--enable-minify",
903 help="Select types of files to minify during packaging.",
905 choices=("properties", "js"),
906 default=enable_minify_default,
910 @depends("--enable-minify")
911 def enable_minify(value):
912 if "js" in value and "properties" not in value:
913 die("--enable-minify=js requires --enable-minify=properties.")
915 properties="properties" in value,
920 set_config("MOZ_PACKAGER_MINIFY", True, when=enable_minify.properties)
921 set_config("MOZ_PACKAGER_MINIFY_JS", True, when=enable_minify.js)
924 @depends(host, build_project)
925 def jar_maker_format(host, build_project):
926 # Multilocales for mobile/android use the same mergedirs for all locales,
927 # so we can't use symlinks for those builds.
928 if host.os == "WINNT" or build_project == "mobile/android":
933 set_config("MOZ_JAR_MAKER_FILE_FORMAT", jar_maker_format)
937 def omnijar_name(toolkit):
938 # Fennec's static resources live in the assets/ folder of the
939 # APK. Adding a path to the name here works because we only
940 # have one omnijar file in the final package (which is not the
942 return "assets/omni.ja" if toolkit == "android" else "omni.ja"
945 set_config("OMNIJAR_NAME", omnijar_name)
947 project_flag("MOZ_PLACES", help="Build Places if required", set_as_define=True)
950 "MOZ_SERVICES_HEALTHREPORT",
951 help="Build Firefox Health Reporter Service",
957 help="Enable Normandy recipe runner",
961 project_flag("MOZ_SERVICES_SYNC", help="Build Sync Services if required")
964 "MOZ_ANDROID_HISTORY",
965 help="Enable Android History instead of Places",
970 "MOZ_DEDICATED_PROFILES",
971 help="Enable dedicated profiles per install",
976 "MOZ_BLOCK_PROFILE_DOWNGRADE",
977 help="Block users from starting profiles last used by a newer build",
982 @depends("MOZ_PLACES", "MOZ_ANDROID_HISTORY")
983 def check_places_and_android_history(places, android_history):
984 if places and android_history:
985 die("Cannot use MOZ_ANDROID_HISTORY alongside MOZ_PLACES.")
989 env="MOZ_TELEMETRY_REPORTING",
990 default=mozilla_official,
991 help="Enable telemetry reporting",
994 set_define("MOZ_TELEMETRY_REPORTING", True, when="MOZ_TELEMETRY_REPORTING")
997 @depends("MOZ_TELEMETRY_REPORTING", milestone.is_nightly)
998 def telemetry_on_by_default(reporting, is_nightly):
999 return reporting and is_nightly
1002 set_define("MOZ_TELEMETRY_ON_BY_DEFAULT", True, when=telemetry_on_by_default)
1006 # ==============================================================
1007 system_lib_option("--enable-gpsd", env="MOZ_GPSD", help="Enable gpsd support")
1010 @depends("--enable-gpsd")
1015 system_gpsd = pkg_check_modules("MOZ_GPSD", "libgps >= 3.11", when=gpsd)
1017 set_config("MOZ_GPSD", depends_if(system_gpsd)(lambda _: True))
1019 # Miscellaneous programs
1020 # ==============================================================
1022 check_prog("TAR", ("gnutar", "gtar", "tar"))
1023 check_prog("UNZIP", ("unzip",))
1026 # ==============================================================
1027 include("../build/moz.configure/keyfiles.configure")
1029 simple_keyfile("Mozilla API")
1031 simple_keyfile("Google Location Service API")
1033 simple_keyfile("Google Safebrowsing API")
1035 id_and_secret_keyfile("Bing API")
1037 simple_keyfile("Adjust SDK")
1039 id_and_secret_keyfile("Leanplum SDK")
1041 simple_keyfile("Pocket API")
1044 # WebRender Debugger integration
1045 # ==============================================================
1048 "--enable-webrender-debugger", help="Build the websocket debug server in WebRender"
1052 "MOZ_WEBRENDER_DEBUGGER", depends_if("--enable-webrender-debugger")(lambda _: True)
1055 # Additional system headers defined at the application level
1056 # ==============================================================
1059 "--enable-app-system-headers",
1060 env="MOZ_APP_SYSTEM_HEADERS",
1061 help="Use additional system headers defined in $MOZ_BUILD_APP/app-system-headers.mozbuild",
1065 @depends("--enable-app-system-headers")
1066 def app_system_headers(value):
1071 set_config("MOZ_APP_SYSTEM_HEADERS", app_system_headers)
1072 set_define("MOZ_APP_SYSTEM_HEADERS", app_system_headers)
1075 # ==============================================================
1076 option("--disable-printing", help="Disable printing support")
1079 @depends("--disable-printing")
1080 def printing(value):
1085 set_config("NS_PRINTING", printing)
1086 set_define("NS_PRINTING", printing)
1087 set_define("NS_PRINT_PREVIEW", printing)
1090 # Speech-dispatcher support
1091 # ==============================================================
1093 def no_speechd_on_non_gtk(toolkit):
1094 if toolkit != "gtk":
1099 "--enable-synth-speechd", no_speechd_on_non_gtk, reason="--enable-default-toolkit"
1102 option("--disable-synth-speechd", help="Disable speech-dispatcher support")
1104 set_config("MOZ_SYNTH_SPEECHD", depends_if("--disable-synth-speechd")(lambda _: True))
1107 # ==============================================================
1108 option("--disable-webspeech", help="Disable support for HTML Speech API")
1111 @depends("--disable-webspeech")
1112 def webspeech(value):
1117 set_config("MOZ_WEBSPEECH", webspeech)
1118 set_define("MOZ_WEBSPEECH", webspeech)
1120 # Speech API test backend
1121 # ==============================================================
1123 "--enable-webspeechtestbackend",
1125 help="{Enable|Disable} support for HTML Speech API Test Backend",
1129 @depends_if("--enable-webspeechtestbackend")
1130 def webspeech_test_backend(value):
1134 set_config("MOZ_WEBSPEECH_TEST_BACKEND", webspeech_test_backend)
1135 set_define("MOZ_WEBSPEECH_TEST_BACKEND", webspeech_test_backend)
1139 # ==============================================================
1140 @depends(target, milestone)
1141 def skia_pdf_default(target, milestone):
1142 return milestone.is_nightly and target.os != "WINNT"
1145 option("--enable-skia-pdf", default=skia_pdf_default, help="{Enable|Disable} Skia PDF")
1147 set_config("MOZ_ENABLE_SKIA_PDF", True, when="--enable-skia-pdf")
1148 set_define("MOZ_ENABLE_SKIA_PDF", True, when="--enable-skia-pdf")
1159 "--with-system-webp", help="Use system libwebp (located with pkgconfig)"
1162 system_webp = pkg_check_modules(
1163 "MOZ_WEBP", "libwebp >= 1.0.2 libwebpdemux >= 1.0.2", when="--with-system-webp"
1166 set_config("MOZ_SYSTEM_WEBP", depends(when=system_webp)(lambda: True))
1169 # Build Freetype in the tree
1170 # ==============================================================
1171 @depends(target, "--enable-skia-pdf")
1172 def tree_freetype(target, skia_pdf):
1173 if target.os == "Android" or (skia_pdf and target.os == "WINNT"):
1177 set_define("MOZ_TREE_FREETYPE", tree_freetype)
1178 set_config("MOZ_TREE_FREETYPE", tree_freetype)
1180 set_define("HAVE_FT_BITMAP_SIZE_Y_PPEM", tree_freetype)
1181 set_define("HAVE_FT_GLYPHSLOT_EMBOLDEN", tree_freetype)
1182 set_define("HAVE_FT_LOAD_SFNT_TABLE", tree_freetype)
1185 @depends(freetype2_combined_info, tree_freetype, build_environment)
1186 def ft2_info(freetype2_combined_info, tree_freetype, build_env):
1189 cflags=("-I%s/modules/freetype2/include" % build_env.topsrcdir,), libs=()
1191 if freetype2_combined_info:
1192 return freetype2_combined_info
1195 set_config("FT2_LIBS", ft2_info.libs)
1198 @depends(target, tree_freetype, freetype2_info)
1199 def enable_cairo_ft(target, tree_freetype, freetype2_info):
1200 # Avoid defining MOZ_ENABLE_CAIRO_FT on Windows platforms because
1201 # "cairo-ft-font.c" includes <dlfcn.h>, which only exists on posix platforms
1202 return freetype2_info or (tree_freetype and target.os != "WINNT")
1205 set_config("MOZ_ENABLE_CAIRO_FT", True, when=enable_cairo_ft)
1206 set_config("CAIRO_FT_CFLAGS", ft2_info.cflags, when=enable_cairo_ft)
1209 # WebDriver (HTTP / BiDi)
1210 # ==============================================================
1212 # WebDriver is a remote control interface that enables introspection and
1213 # control of user agents. It provides a platform- and language-neutral wire
1214 # protocol as a way for out-of-process programs to remotely instruct the
1215 # behavior of web browsers.
1217 # The Gecko implementation is backed by Marionette and Remote Agent.
1218 # Both protocols are not really toolkit features, as much as Gecko engine
1219 # features. But they are enabled based on the toolkit, so here it lives.
1221 # Marionette remote protocol
1222 # -----------------------------------------------------------
1224 # Marionette is the Gecko remote protocol used for various remote control,
1225 # automation, and testing purposes throughout Gecko-based applications like
1226 # Firefox, Thunderbird, and any mobile browser built upon GeckoView.
1228 # It also backs ../testing/geckodriver, which is Mozilla's WebDriver
1231 # The source of Marionette lives in ../remote/marionette.
1233 # For more information, see:
1234 # https://firefox-source-docs.mozilla.org/testing/marionette/index.html
1236 # Remote Agent (WebDriver BiDi / partial CDP)
1237 # -----------------------------------------------------------
1239 # The primary purpose is the implementation of the WebDriver BiDi specification.
1240 # But it also complements the existing Firefox Developer Tools Remote Debugging
1241 # Protocol (RDP) by implementing a subset of the Chrome DevTools Protocol (CDP).
1243 # The source of Remote Agent lives in ../remote.
1245 # For more information, see:
1246 # https://firefox-source-docs.mozilla.org/remote/index.html
1250 "--disable-webdriver",
1251 help="Disable support for WebDriver remote protocols",
1255 @depends("--disable-webdriver")
1256 def webdriver(enabled):
1261 set_config("ENABLE_WEBDRIVER", webdriver)
1262 set_define("ENABLE_WEBDRIVER", webdriver)
1265 # geckodriver WebDriver implementation
1266 # ==============================================================
1268 # Turn off geckodriver for build configs we don't handle yet,
1269 # but allow --enable-geckodriver to override when compile environment is available.
1270 # --disable-tests implies disabling geckodriver.
1271 # Disable building in CI
1275 "--enable-tests", target, cross_compiling, hazard_analysis, asan, "MOZ_AUTOMATION"
1277 def geckodriver_default(enable_tests, target, cross_compile, hazard, asan, automation):
1278 if not enable_tests:
1280 if hazard or target.os == "Android" or (asan and cross_compile):
1288 "--enable-geckodriver",
1289 default=geckodriver_default,
1290 when="--enable-compile-environment",
1291 help="{Build|Do not build} geckodriver",
1295 @depends("--enable-geckodriver", when="--enable-compile-environment")
1296 def geckodriver(enabled):
1301 set_config("MOZ_GECKODRIVER", geckodriver)
1305 # ========================================================
1307 def webrtc_default(target):
1308 # Turn off webrtc for OS's we don't handle yet, but allow
1309 # --enable-webrtc to override.
1310 os_match = target.kernel in (
1321 os_match = target.os in ("OSX",)
1323 cpu_match = target.cpu in (
1336 return os_match and cpu_match and target.endianness == "little"
1341 default=webrtc_default,
1342 help="{Enable|Disable} support for WebRTC",
1346 @depends("--disable-webrtc")
1347 def webrtc(enabled):
1352 set_config("MOZ_WEBRTC", webrtc)
1353 set_define("MOZ_WEBRTC", webrtc)
1354 set_config("MOZ_SCTP", webrtc)
1355 set_define("MOZ_SCTP", webrtc)
1356 set_config("MOZ_SRTP", webrtc)
1357 set_define("MOZ_SRTP", webrtc)
1358 set_config("MOZ_WEBRTC_SIGNALING", webrtc)
1359 set_define("MOZ_WEBRTC_SIGNALING", webrtc)
1360 set_config("MOZ_PEERCONNECTION", webrtc)
1361 set_define("MOZ_PEERCONNECTION", webrtc)
1362 # MOZ_WEBRTC_ASSERT_ALWAYS turns on a number of safety asserts in
1363 # opt/production builds (via MOZ_CRASH())
1364 set_config("MOZ_WEBRTC_ASSERT_ALWAYS", webrtc)
1365 set_define("MOZ_WEBRTC_ASSERT_ALWAYS", webrtc)
1368 # ==============================================================
1371 @depends(target, webrtc)
1372 def raw_media_default(target, webrtc):
1373 if target.os == "Android":
1381 default=raw_media_default,
1382 help="{Enable|Disable} support for RAW media",
1385 set_config("MOZ_RAW", depends_if("--enable-raw")(lambda _: True))
1386 set_define("MOZ_RAW", depends_if("--enable-raw")(lambda _: True))
1390 # ==============================================================
1391 @depends(webrtc, when=toolkit_gtk)
1392 def x11_libs(webrtc):
1402 # third_party/libwebrtc/webrtc/webrtc_gn/moz.build adds those
1403 # manually, ensure they're available.
1414 x11_headers = pkg_check_modules(
1417 allow_missing=toolkit_gtk_x11_optional,
1418 when=toolkit_gtk_x11,
1422 set_config("MOZ_X11", True, when=x11_headers)
1423 set_define("MOZ_X11", True, when=x11_headers)
1429 allow_missing=toolkit_gtk_x11_optional,
1430 when=toolkit_gtk_x11,
1434 # ASan Reporter Addon
1435 # ==============================================================
1437 "--enable-address-sanitizer-reporter",
1438 help="Enable Address Sanitizer Reporter Extension",
1442 @depends("--enable-address-sanitizer-reporter")
1443 def enable_asan_reporter(value):
1448 set_config("MOZ_ASAN_REPORTER", enable_asan_reporter)
1449 set_define("MOZ_ASAN_REPORTER", enable_asan_reporter)
1451 # Checks for library functions
1452 # ==============================================================
1453 with only_when(compile_environment & depends(target.os)(lambda os: os != "WINNT")):
1454 set_define("HAVE_STAT64", check_symbol("stat64"))
1455 set_define("HAVE_LSTAT64", check_symbol("lstat64"))
1456 set_define("HAVE_TRUNCATE64", check_symbol("truncate64"))
1457 set_define("HAVE_STATVFS64", check_symbol("statvfs64"))
1458 set_define("HAVE_STATVFS", check_symbol("statvfs"))
1459 set_define("HAVE_STATFS64", check_symbol("statfs64"))
1460 set_define("HAVE_STATFS", check_symbol("statfs"))
1461 set_define("HAVE_LUTIMES", check_symbol("lutimes"))
1462 set_define("HAVE_POSIX_FADVISE", check_symbol("posix_fadvise"))
1463 set_define("HAVE_POSIX_FALLOCATE", check_symbol("posix_fallocate"))
1464 set_define("HAVE_EVENTFD", check_symbol("eventfd"))
1466 have_arc4random = check_symbol("arc4random")
1467 set_define("HAVE_ARC4RANDOM", have_arc4random)
1468 set_define("HAVE_ARC4RANDOM_BUF", check_symbol("arc4random_buf"))
1469 set_define("HAVE_MALLINFO", check_symbol("mallinfo"))
1471 # Checks for headers
1472 # ==============================================================
1473 with only_when(compile_environment & depends(target.os)(lambda os: os != "WINNT")):
1474 set_define("HAVE_SYSIOCCOM_H", check_header("sys/ioccom.h"))
1477 # ==============================================================
1478 with only_when("--enable-compile-environment"):
1480 @depends(host, target)
1481 def has_elfhack(host, target):
1483 target.kernel == "Linux"
1484 and host.kernel == "Linux"
1485 and target.cpu in ("arm", "aarch64", "x86", "x86_64")
1489 "--disable-elf-hack",
1491 choices=("legacy", "relr"),
1492 help="{Enable|Disable} elf hacks",
1496 @depends("--enable-elf-hack", when=has_elfhack)
1497 def may_enable_legacy_elfhack(enable):
1498 if enable and enable != ("relr",):
1501 @depends("--enable-elf-hack", when=has_elfhack)
1502 def may_enable_relrhack(enable):
1503 if enable and enable != ("legacy",):
1509 when=target_has_linux_kernel,
1511 def may_use_pack_relative_relocs(have_arc4random, android_version):
1512 # Packed relative relocations are only supported on Android since
1513 # version 11 (API 30), and in glibc since version 2.36.
1514 # glibc 2.36 also added the arc4random function, which is our proxy
1515 # to detect this (or newer) version being used.
1516 # When targetting those newer versions, we allow ourselves to use
1517 # packed relative relocations rather than elfhack.
1519 return android_version >= 30
1520 return have_arc4random
1524 extra_toolchain_flags,
1527 when=may_use_pack_relative_relocs | may_enable_relrhack,
1529 @checking("for -z pack-relative-relocs option to ld", bool)
1530 @imports(_from="__builtin__", _import="FileNotFoundError")
1532 @imports(_from="tempfile", _import="mkstemp")
1533 @imports("textwrap")
1534 def has_pack_relative_relocs(
1536 extra_toolchain_flags,
1541 fd, path = mkstemp(prefix="conftest.")
1544 pack_rel_relocs = ["-Wl,-z,pack-relative-relocs"]
1546 try_invoke_compiler(
1547 # No configure_cache because it would not create the
1548 # expected output file.
1550 [c_compiler.compiler] + c_compiler.flags,
1551 c_compiler.language,
1552 # The resulting binary is expected to have relative
1553 # relocations, the `ptr` variable attempts to ensure
1554 # there is at least one. This requires the executable
1555 # being built as position independent.
1556 "int main() { return 0; }\nint (*ptr)() = main;",
1558 + ["-pie", "-o", path]
1559 + (extra_toolchain_flags or [])
1561 wrapper=c_compiler.wrapper,
1562 onerror=lambda: None,
1566 # BFD ld ignores options it doesn't understand. So check
1567 # that we did get packed relative relocations (DT_RELR).
1568 env = os.environ.copy()
1570 dyn = check_cmd_output(readelf, "-d", path, env=env).splitlines()
1572 int(l.split()[0], 16) for l in dyn if l.strip().startswith("0x")
1574 # Older versions of readelf don't know about DT_RELR but will
1575 # still display the tag number.
1577 needed = [l for l in dyn if l.split()[1:2] == ["(NEEDED)"]]
1578 is_glibc = any(l.endswith("[libc.so.6]") for l in needed)
1579 # The mold linker doesn't add a GLIBC_ABI_DT_RELR version
1580 # dependency, which ld.so doesn't like.
1581 # https://github.com/rui314/mold/issues/653#issuecomment-1670274638
1583 versions = check_cmd_output(readelf, "-V", path, env=env)
1584 if "GLIBC_ABI_DT_RELR" in versions.split():
1585 return pack_rel_relocs
1587 return pack_rel_relocs
1591 except FileNotFoundError:
1595 has_pack_relative_relocs,
1596 may_enable_legacy_elfhack,
1597 may_enable_relrhack,
1598 may_use_pack_relative_relocs,
1599 when=has_pack_relative_relocs,
1601 def pack_relative_relocs_flags(
1603 may_enable_legacy_elfhack,
1604 may_enable_relrhack,
1605 may_use_pack_relative_relocs,
1607 # When relrhack is enabled, we don't pass the flag to the linker because
1608 # relrhack will take care of it.
1609 if may_enable_relrhack and may_enable_relrhack.origin != "default":
1611 # if elfhack is explicitly enabled instead of relrhack, we prioritize it
1612 # over packed relative relocs.
1613 if may_enable_legacy_elfhack and may_enable_legacy_elfhack.origin != "default":
1615 if may_use_pack_relative_relocs:
1618 add_old_configure_assignment("PACK_REL_RELOC_FLAGS", pack_relative_relocs_flags)
1622 pack_relative_relocs_flags,
1623 has_pack_relative_relocs,
1624 may_enable_legacy_elfhack,
1625 may_enable_relrhack,
1630 pack_relative_relocs_flags,
1631 has_pack_relative_relocs,
1632 may_enable_legacy_elfhack,
1633 may_enable_relrhack,
1635 if pack_relative_relocs_flags:
1637 if may_enable_relrhack:
1638 if has_pack_relative_relocs:
1641 may_enable_relrhack.origin != "default"
1642 and not may_enable_legacy_elfhack
1645 "Cannot enable relrhack without linker support for -z pack-relative-relocs"
1647 if may_enable_legacy_elfhack:
1648 if linker and linker.KIND in ("lld", "mold"):
1649 if may_enable_legacy_elfhack.origin != "default":
1651 f"Cannot enable elfhack with {linker.KIND}."
1652 " Use --enable-linker=bfd, --enable-linker=gold, or --disable-elf-hack"
1658 "USE_ELF_HACK", True, when=depends(which_elf_hack)(lambda x: x == "legacy")
1661 use_relrhack = depends(which_elf_hack)(lambda x: x == "relr")
1662 set_config("RELRHACK", True, when=use_relrhack)
1664 @depends(c_compiler, linker_ldflags, when=use_relrhack)
1665 def relrhack_real_linker(c_compiler, linker_ldflags):
1667 for flag in linker_ldflags:
1668 if flag.startswith("-fuse-ld="):
1669 ld = "ld." + flag[len("-fuse-ld=") :]
1670 ld = check_cmd_output(
1671 c_compiler.compiler, f"--print-prog-name={ld}", *c_compiler.flags
1675 @depends(relrhack_real_linker, when=use_relrhack)
1676 def relrhack_linker(ld):
1677 return os.path.basename(ld)
1679 set_config("RELRHACK_LINKER", relrhack_linker)
1681 std_filesystem = host_cxx_compiler.try_run(
1682 header="#include <filesystem>",
1683 body='auto foo = std::filesystem::absolute("");',
1684 flags=host_linker_ldflags,
1686 onerror=lambda: None,
1689 stdcxxfs = host_cxx_compiler.try_run(
1690 header="#include <filesystem>",
1691 body='auto foo = std::filesystem::absolute("");',
1692 flags=depends(host_linker_ldflags)(
1693 lambda flags: (flags or []) + ["-lstdc++fs"]
1695 check_msg="whether std::filesystem requires -lstdc++fs",
1696 when=use_relrhack & depends(std_filesystem)(lambda x: not x),
1697 onerror=lambda: None,
1700 set_config("RELRHACK_LIBS", ["stdc++fs"], when=stdcxxfs)
1702 @depends(build_environment, relrhack_real_linker, when=use_relrhack)
1703 def relrhack_ldflags(build_env, ld):
1706 os.path.join(build_env.topobjdir, "build", "unix", "elfhack"),
1708 if os.path.basename(ld) != ld:
1709 flags.append(f"-Wl,--real-linker,{ld}")
1712 set_config("RELRHACK_LDFLAGS", relrhack_ldflags)
1715 @depends(build_environment)
1716 def idl_roots(build_env):
1718 ipdl_root=os.path.join(build_env.topobjdir, "ipc", "ipdl"),
1719 webidl_root=os.path.join(build_env.topobjdir, "dom", "bindings"),
1720 xpcom_root=os.path.join(build_env.topobjdir, "xpcom", "components"),
1724 set_config("WEBIDL_ROOT", idl_roots.webidl_root)
1725 set_config("IPDL_ROOT", idl_roots.ipdl_root)
1726 set_config("XPCOM_ROOT", idl_roots.xpcom_root)
1728 # Proxy bypass protection
1729 # ==============================================================
1732 "--enable-proxy-bypass-protection",
1733 help="Prevent suspected or confirmed proxy bypasses",
1737 @depends_if("--enable-proxy-bypass-protection")
1738 def proxy_bypass_protection(_):
1742 set_config("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1743 set_define("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1745 # Proxy direct failover
1746 # ==============================================================
1749 "--disable-proxy-direct-failover",
1750 help="Disable direct failover for system requests",
1754 @depends_if("--disable-proxy-direct-failover")
1755 def proxy_direct_failover(value):
1760 set_config("MOZ_PROXY_DIRECT_FAILOVER", proxy_direct_failover)
1761 set_define("MOZ_PROXY_DIRECT_FAILOVER", proxy_direct_failover)
1764 # ==============================================================
1767 @depends(c_compiler, toolchain_prefix)
1768 def midl_names(c_compiler, toolchain_prefix):
1769 if c_compiler and c_compiler.type in ["gcc", "clang"]:
1772 if toolchain_prefix:
1773 prefixed = tuple("%s%s" % (p, "widl") for p in toolchain_prefix)
1774 widl = prefixed + widl
1777 return ("midl.exe",)
1780 @depends(target, "--enable-compile-environment")
1781 def check_for_midl(target, compile_environment):
1782 if target.os != "WINNT":
1785 if compile_environment:
1792 when=check_for_midl,
1795 # MIDL being used from a python wrapper script, we can live with it
1800 option(env="MIDL_FLAGS", nargs=1, help="Extra flags to pass to MIDL")
1807 when=depends(midl, target)(lambda m, t: m and t.kernel == "WINNT"),
1809 def midl_flags(flags, target, midl):
1811 flags = flags[0].split()
1815 if not midl.endswith("widl"):
1821 return flags + ["-nologo", "-no_cpp", "-env", env]
1827 "x86": ["--win32", "-m32"],
1828 "x86_64": ["--win64", "-m64"],
1833 set_config("MIDL_FLAGS", midl_flags)
1836 # ==============================================================
1838 option("--disable-accessibility", help="Disable accessibility support")
1841 @depends("--enable-accessibility", check_for_midl, midl, c_compiler)
1842 def accessibility(value, check_for_midl, midl, c_compiler):
1843 enabled = bool(value)
1848 if check_for_midl and not midl:
1849 if c_compiler and c_compiler.type in ("gcc", "clang"):
1851 "You have accessibility enabled, but widl could not be found. "
1852 "Add --disable-accessibility to your mozconfig or install widl. "
1853 "See https://developer.mozilla.org/en-US/docs/Cross_Compile_Mozilla_for_Mingw32 for details."
1857 "MIDL could not be found. "
1858 "Building accessibility without MIDL is not supported."
1864 set_config("ACCESSIBILITY", accessibility)
1865 set_define("ACCESSIBILITY", accessibility)
1868 @depends(moz_debug, developer_options)
1869 def a11y_log(debug, developer_options):
1870 return debug or developer_options
1873 set_config("A11Y_LOG", True, when=a11y_log)
1874 set_define("A11Y_LOG", True, when=a11y_log)
1878 # ==============================================================
1880 def require_signing(milestone):
1881 return milestone.is_release_or_beta and not milestone.is_esr
1885 env="MOZ_REQUIRE_SIGNING",
1886 default=require_signing,
1887 help="Enforce that add-ons are signed by the trusted root",
1890 set_config("MOZ_REQUIRE_SIGNING", True, when="MOZ_REQUIRE_SIGNING")
1891 set_define("MOZ_REQUIRE_SIGNING", True, when="MOZ_REQUIRE_SIGNING")
1894 "--with-unsigned-addon-scopes",
1896 choices=("app", "system"),
1897 help="Addon scopes where signature is not required",
1901 @depends("--with-unsigned-addon-scopes")
1902 def unsigned_addon_scopes(scopes):
1904 app="app" in scopes or None,
1905 system="system" in scopes or None,
1909 set_config("MOZ_UNSIGNED_APP_SCOPE", unsigned_addon_scopes.app)
1910 set_config("MOZ_UNSIGNED_SYSTEM_SCOPE", unsigned_addon_scopes.system)
1914 # ==============================================================
1916 "--allow-addon-sideload",
1917 default=milestone.is_esr,
1918 help="Addon sideloading is allowed",
1922 set_config("MOZ_ALLOW_ADDON_SIDELOAD", True, when="--allow-addon-sideload")
1924 # WebExtensions API WebIDL bindings
1925 # ==============================================================
1929 def extensions_webidl_bindings_default(milestone):
1930 # Only enable the webidl bindings for the WebExtensions APIs
1932 return milestone.is_nightly
1936 "--enable-extensions-webidl-bindings",
1937 default=extensions_webidl_bindings_default,
1938 help="{Enable|Disable} building experimental WebExtensions WebIDL bindings",
1942 @depends("--enable-extensions-webidl-bindings")
1943 def extensions_webidl_enabled(value):
1947 set_config("MOZ_WEBEXT_WEBIDL_ENABLED", extensions_webidl_enabled)
1949 # Launcher process (Windows only)
1950 # ==============================================================
1954 def launcher_process_default(target):
1955 return target.os == "WINNT"
1959 "--enable-launcher-process",
1960 default=launcher_process_default,
1961 help="{Enable|Disable} launcher process by default",
1965 @depends("--enable-launcher-process", target)
1966 def launcher(value, target):
1967 enabled = bool(value)
1968 if enabled and target.os != "WINNT":
1969 die("Cannot enable launcher process on %s", target.os)
1974 set_config("MOZ_LAUNCHER_PROCESS", launcher)
1975 set_define("MOZ_LAUNCHER_PROCESS", launcher)
1977 # llvm-dlltool (Windows only)
1978 # ==============================================================
1981 @depends(build_project, target, "--enable-compile-environment")
1982 def check_for_llvm_dlltool(build_project, target, compile_environment):
1983 if build_project != "browser":
1986 if target.os != "WINNT":
1989 return compile_environment
1992 llvm_dlltool = check_prog(
1995 what="llvm-dlltool",
1996 when=check_for_llvm_dlltool,
1997 paths=clang_search_path,
2001 @depends(target, when=llvm_dlltool)
2002 def llvm_dlltool_flags(target):
2005 "x86_64": "i386:x86-64",
2012 set_config("LLVM_DLLTOOL_FLAGS", llvm_dlltool_flags)
2014 # BITS download (Windows only)
2015 # ==============================================================
2018 "--enable-bits-download",
2019 when=target_is_windows,
2020 default=target_is_windows,
2021 help="{Enable|Disable} building BITS download support",
2025 "MOZ_BITS_DOWNLOAD",
2026 depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
2029 "MOZ_BITS_DOWNLOAD",
2030 depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
2033 # Bundled fonts on desktop platform
2034 # ==============================================================
2038 def bundled_fonts_default(target):
2039 return target.os == "WINNT" or target.kernel == "Linux"
2042 @depends(build_project)
2043 def allow_bundled_fonts(project):
2044 return project == "browser" or project == "comm/mail"
2048 "--enable-bundled-fonts",
2049 default=bundled_fonts_default,
2050 when=allow_bundled_fonts,
2051 help="{Enable|Disable} support for bundled fonts on desktop platforms",
2055 "MOZ_BUNDLED_FONTS",
2056 depends_if("--enable-bundled-fonts", when=allow_bundled_fonts)(lambda _: True),
2060 # ==============================================================
2064 def reflow_perf(debug):
2070 "--enable-reflow-perf",
2071 default=reflow_perf,
2072 help="{Enable|Disable} reflow performance tracing",
2075 # The difference in conditions here comes from the initial implementation
2076 # in old-configure, which was unexplained there as well.
2077 set_define("MOZ_REFLOW_PERF", depends_if("--enable-reflow-perf")(lambda _: True))
2078 set_define("MOZ_REFLOW_PERF_DSP", reflow_perf)
2081 # ==============================================================
2085 def layout_debugger(debug):
2091 "--enable-layout-debugger",
2092 default=layout_debugger,
2093 help="{Enable|Disable} layout debugger",
2096 set_config("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
2097 set_define("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
2100 # Shader Compiler for Windows (and MinGW Cross Compile)
2101 # ==============================================================
2103 with only_when(compile_environment):
2106 ("fxc.exe", "fxc2.exe"),
2107 when=depends(target)(lambda t: t.kernel == "WINNT"),
2109 # FXC being used from a python wrapper script, we can live with it
2118 with only_when(compile_environment):
2120 "--with-system-libvpx", help="Use system libvpx (located with pkgconfig)"
2123 with only_when("--with-system-libvpx"):
2124 vpx = pkg_check_modules("MOZ_LIBVPX", "vpx >= 1.10.0")
2127 "vpx/vpx_decoder.h",
2129 onerror=lambda: die(
2130 "Couldn't find vpx/vpx_decoder.h, which is required to build "
2131 "with system libvpx. Use --without-system-libvpx to build "
2132 "with in-tree libvpx."
2137 "vpx_codec_dec_init_ver",
2139 onerror=lambda: die(
2140 "--with-system-libvpx requested but symbol vpx_codec_dec_init_ver "
2145 set_config("MOZ_SYSTEM_LIBVPX", True)
2147 @depends("--with-system-libvpx", target)
2148 def in_tree_vpx(system_libvpx, target):
2152 arm_asm = (target.cpu == "arm") or None
2153 return namespace(arm_asm=arm_asm)
2155 @depends(target, when=in_tree_vpx)
2156 def vpx_nasm(target):
2157 if target.cpu in ("x86", "x86_64"):
2158 if target.kernel == "WINNT":
2159 # Version 2.03 is needed for automatic safeseh support.
2160 return namespace(version="2.03", what="VPX")
2161 return namespace(what="VPX")
2163 @depends(in_tree_vpx, vpx_nasm, target, neon_flags)
2164 def vpx_as_flags(vpx, vpx_nasm, target, neon_flags):
2165 if vpx and vpx.arm_asm:
2166 # These flags are a lie; they're just used to enable the requisite
2167 # opcodes; actual arch detection is done at runtime.
2169 elif vpx and vpx_nasm and target.os != "WINNT" and target.cpu != "x86_64":
2172 set_config("VPX_USE_NASM", True, when=vpx_nasm)
2173 set_config("VPX_ASFLAGS", vpx_as_flags)
2179 with only_when(compile_environment):
2181 "--with-system-jpeg",
2183 help="Use system libjpeg (installed at given prefix)",
2186 @depends_if("--with-system-jpeg")
2187 def jpeg_flags(value):
2190 cflags=("-I%s/include" % value[0],),
2191 ldflags=("-L%s/lib" % value[0], "-ljpeg"),
2194 ldflags=("-ljpeg",),
2197 with only_when("--with-system-jpeg"):
2199 "jpeg_destroy_compress",
2200 flags=jpeg_flags.ldflags,
2201 onerror=lambda: die(
2202 "--with-system-jpeg requested but symbol "
2203 "jpeg_destroy_compress not found."
2207 c_compiler.try_compile(
2214 #if JPEG_LIB_VERSION < 62
2215 #error Insufficient JPEG library version
2218 flags=jpeg_flags.cflags,
2219 check_msg="for sufficient jpeg library version",
2220 onerror=lambda: die(
2221 "Insufficient JPEG library version for "
2222 "--with-system-jpeg (62 required)"
2226 c_compiler.try_compile(
2233 #ifndef JCS_EXTENSIONS
2234 #error libjpeg-turbo JCS_EXTENSIONS required
2237 flags=jpeg_flags.cflags,
2238 check_msg="for sufficient libjpeg-turbo JCS_EXTENSIONS",
2239 onerror=lambda: die(
2240 "libjpeg-turbo JCS_EXTENSIONS required for " "--with-system-jpeg"
2244 set_config("MOZ_JPEG_CFLAGS", jpeg_flags.cflags)
2245 set_config("MOZ_JPEG_LIBS", jpeg_flags.ldflags)
2247 @depends("--with-system-jpeg", target, neon_flags)
2248 def in_tree_jpeg_arm(system_jpeg, target, neon_flags):
2252 if target.cpu == "arm":
2254 elif target.cpu == "aarch64":
2255 return ("-march=armv8-a",)
2257 @depends("--with-system-jpeg", target)
2258 def in_tree_jpeg_mips64(system_jpeg, target):
2262 if target.cpu == "mips64":
2263 return ("-Wa,-mloongson-mmi", "-mloongson-ext")
2265 # Compiler check from https://github.com/libjpeg-turbo/libjpeg-turbo/blob/57ba02a408a9a55ccff25aae8b164632a3a4f177/simd/CMakeLists.txt#L419
2266 jpeg_mips64_mmi = c_compiler.try_compile(
2267 body='int c = 0, a = 0, b = 0; asm("paddb %0, %1, %2" : "=f" (c) : "f" (a), "f" (b));',
2268 check_msg="for loongson mmi support",
2269 flags=in_tree_jpeg_mips64,
2270 when=in_tree_jpeg_mips64,
2274 "--with-system-jpeg",
2277 in_tree_jpeg_mips64,
2281 system_jpeg, target, in_tree_jpeg_arm, in_tree_jpeg_mips64, jpeg_mips64_mmi
2286 if target.cpu in ("arm", "aarch64"):
2287 return in_tree_jpeg_arm
2288 elif target.kernel == "Darwin":
2289 if target.cpu == "x86":
2290 return ("-DPIC", "-DMACHO")
2291 elif target.cpu == "x86_64":
2292 return ("-D__x86_64__", "-DPIC", "-DMACHO")
2293 elif target.kernel == "WINNT":
2294 if target.cpu == "x86":
2295 return ("-DPIC", "-DWIN32")
2296 elif target.cpu == "x86_64":
2297 return ("-D__x86_64__", "-DPIC", "-DWIN64", "-DMSVC")
2298 elif target.cpu == "mips32":
2300 elif target.cpu == "mips64" and jpeg_mips64_mmi:
2301 return in_tree_jpeg_mips64
2302 elif target.cpu == "x86":
2303 return ("-DPIC", "-DELF")
2304 elif target.cpu == "x86_64":
2305 return ("-D__x86_64__", "-DPIC", "-DELF")
2307 @depends(target, when=depends("--with-system-jpeg")(lambda x: not x))
2308 def jpeg_nasm(target):
2309 if target.cpu in ("x86", "x86_64"):
2310 # libjpeg-turbo 2.0.6 requires nasm 2.10.
2311 return namespace(version="2.10", what="JPEG")
2313 # Compiler checks from https://github.com/libjpeg-turbo/libjpeg-turbo/blob/57ba02a408a9a55ccff25aae8b164632a3a4f177/simd/CMakeLists.txt#L258
2314 jpeg_arm_neon_vld1_s16_x3 = c_compiler.try_compile(
2315 includes=["arm_neon.h"],
2316 body="int16_t input[12] = {}; int16x4x3_t output = vld1_s16_x3(input);",
2317 check_msg="for vld1_s16_x3 in arm_neon.h",
2318 flags=in_tree_jpeg_arm,
2319 when=in_tree_jpeg_arm,
2322 jpeg_arm_neon_vld1_u16_x2 = c_compiler.try_compile(
2323 includes=["arm_neon.h"],
2324 body="uint16_t input[8] = {}; uint16x4x2_t output = vld1_u16_x2(input);",
2325 check_msg="for vld1_u16_x2 in arm_neon.h",
2326 flags=in_tree_jpeg_arm,
2327 when=in_tree_jpeg_arm,
2330 jpeg_arm_neon_vld1q_u8_x4 = c_compiler.try_compile(
2331 includes=["arm_neon.h"],
2332 body="uint8_t input[64] = {}; uint8x16x4_t output = vld1q_u8_x4(input);",
2333 check_msg="for vld1q_u8_x4 in arm_neon.h",
2334 flags=in_tree_jpeg_arm,
2335 when=in_tree_jpeg_arm,
2338 set_config("LIBJPEG_TURBO_USE_NASM", True, when=jpeg_nasm)
2339 set_config("LIBJPEG_TURBO_SIMD_FLAGS", in_tree_jpeg)
2340 set_config("LIBJPEG_TURBO_HAVE_VLD1_S16_X3", jpeg_arm_neon_vld1_s16_x3)
2341 set_config("LIBJPEG_TURBO_HAVE_VLD1_U16_X2", jpeg_arm_neon_vld1_u16_x2)
2342 set_config("LIBJPEG_TURBO_HAVE_VLD1Q_U8_X4", jpeg_arm_neon_vld1q_u8_x4)
2344 "LIBJPEG_TURBO_NEON_INTRINSICS",
2345 jpeg_arm_neon_vld1_s16_x3
2346 & jpeg_arm_neon_vld1_u16_x2
2347 & jpeg_arm_neon_vld1q_u8_x4,
2353 with only_when(compile_environment):
2355 "--with-system-png",
2357 help="Use system libpng",
2360 @depends("--with-system-png")
2361 def deprecated_system_png_path(value):
2364 "--with-system-png=PATH is not supported anymore. Please use "
2365 "--with-system-png and set any necessary pkg-config environment variable."
2368 png = pkg_check_modules("MOZ_PNG", "libpng >= 1.6.35", when="--with-system-png")
2373 onerror=lambda: die(
2374 "--with-system-png won't work because the system's libpng doesn't have APNG support"
2376 when="--with-system-png",
2379 set_config("MOZ_SYSTEM_PNG", True, when="--with-system-png")
2382 # FFmpeg's ffvpx configuration
2383 # ==============================================================
2384 with only_when(compile_environment):
2387 def libav_fft(target):
2388 if target.os == "Android" and target.cpu != "arm":
2390 return target.kernel in ("WINNT", "Darwin") or target.cpu == "x86_64"
2392 set_config("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
2393 set_define("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
2396 # Artifact builds need MOZ_FFVPX defined as if compilation happened.
2397 with only_when(compile_environment | artifact_builds):
2401 enable = use_nasm = True
2405 if target.kernel == "WINNT":
2406 if target.cpu == "x86":
2407 # 32-bit windows need to prefix symbols with an underscore.
2408 flags = ["-DPIC", "-DWIN32", "-DPREFIX", "-Pconfig_win32.asm"]
2409 elif target.cpu == "x86_64":
2415 "-Pconfig_win64.asm",
2417 elif target.cpu == "aarch64":
2418 flags = ["-DPIC", "-DWIN64"]
2420 elif target.kernel == "Darwin":
2421 # 32/64-bit macosx assemblers need to prefix symbols with an
2423 flags = ["-DPIC", "-DMACHO", "-DPREFIX"]
2424 if target.cpu == "x86_64":
2427 "-Pconfig_darwin64.asm",
2429 elif target.cpu == "aarch64":
2431 elif target.cpu == "x86_64":
2432 flags = ["-D__x86_64__", "-DPIC", "-DELF", "-Pconfig_unix64.asm"]
2433 elif target.cpu in ("x86", "arm", "aarch64"):
2438 if flac_only or not enable:
2444 flac_only=flac_only,
2448 @depends(when=ffvpx.use_nasm)
2450 # nasm 2.10 for AVX-2 support.
2451 return namespace(version="2.10", what="FFVPX")
2453 # ffvpx_nasm can't indirectly depend on vpx_as_flags, because it depends
2454 # on a compiler test, so we have to do a little bit of dance here.
2455 @depends(ffvpx, vpx_as_flags, target)
2456 def ffvpx(ffvpx, vpx_as_flags, target):
2457 if ffvpx and vpx_as_flags and target.cpu in ("arm", "aarch64"):
2458 ffvpx.flags.extend(vpx_as_flags)
2461 set_config("MOZ_FFVPX", True, when=ffvpx.enable)
2462 set_define("MOZ_FFVPX", True, when=ffvpx.enable)
2463 set_config("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.flac_only)
2464 set_define("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.flac_only)
2465 set_config("FFVPX_ASFLAGS", ffvpx.flags)
2466 set_config("FFVPX_USE_NASM", True, when=ffvpx.use_nasm)
2470 # ==============================================================
2471 @depends(dav1d_nasm, vpx_nasm, jpeg_nasm, ffvpx_nasm, when=compile_environment)
2472 def need_nasm(*requirements):
2474 x.what: x.version if hasattr(x, "version") else True for x in requirements if x
2477 items = sorted(requires.keys())
2479 what = " and ".join((", ".join(items[:-1]), items[-1]))
2482 versioned = {k: v for (k, v) in requires.items() if v is not True}
2483 return namespace(what=what, versioned=versioned)
2495 @depends(nasm, need_nasm.what)
2496 def check_nasm(nasm, what):
2497 if not nasm and what:
2498 die("Nasm is required to build with %s, but it was not found." % what)
2502 @depends_if(check_nasm)
2503 @checking("nasm version")
2504 def nasm_version(nasm):
2506 check_cmd_output(nasm, "-v", onerror=lambda: die("Failed to get nasm version."))
2510 return Version(version)
2513 @depends(nasm_version, need_nasm.versioned, when=need_nasm.versioned)
2514 def check_nasm_version(nasm_version, versioned):
2515 by_version = sorted(versioned.items(), key=lambda x: x[1])
2516 what, version = by_version[-1]
2517 if nasm_version < version:
2519 "Nasm version %s or greater is required to build with %s." % (version, what)
2524 @depends(target, when=check_nasm_version)
2525 def nasm_asflags(target):
2527 ("OSX", "x86"): ["-f", "macho32"],
2528 ("OSX", "x86_64"): ["-f", "macho64"],
2529 ("WINNT", "x86"): ["-f", "win32"],
2530 ("WINNT", "x86_64"): ["-f", "win64"],
2531 }.get((target.os, target.cpu), None)
2533 # We're assuming every x86 platform we support that's
2534 # not Windows or Mac is ELF.
2535 if target.cpu == "x86":
2536 asflags = ["-f", "elf32"]
2537 elif target.cpu == "x86_64":
2538 asflags = ["-f", "elf64"]
2542 set_config("NASM_ASFLAGS", nasm_asflags)
2545 # ANGLE OpenGL->D3D translator for WebGL
2546 # ==============================================================
2548 with only_when(compile_environment & target_is_windows):
2549 set_config("MOZ_ANGLE_RENDERER", True)
2551 # Remoting protocol support
2552 # ==============================================================
2556 def has_remote(toolkit):
2557 if toolkit in ("gtk", "windows", "cocoa"):
2561 set_config("MOZ_HAS_REMOTE", has_remote)
2562 set_define("MOZ_HAS_REMOTE", has_remote)
2564 # RLBox Library Sandboxing wasm support
2565 # ==============================================================
2568 def wasm_sandboxing_libraries():
2579 @depends(dependable(wasm_sandboxing_libraries), build_project)
2580 def default_wasm_sandboxing_libraries(libraries, build_project):
2581 if build_project != "tools/rusttests":
2582 non_default_libs = {}
2584 return tuple(l for l in libraries if l not in non_default_libs)
2588 "--with-wasm-sandboxed-libraries",
2589 env="WASM_SANDBOXED_LIBRARIES",
2590 help="{Enable wasm sandboxing for the selected libraries|Disable wasm sandboxing}",
2592 choices=dependable(wasm_sandboxing_libraries),
2593 default=default_wasm_sandboxing_libraries,
2597 @depends("--with-wasm-sandboxed-libraries")
2598 def requires_wasm_sandboxing(libraries):
2603 set_config("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
2604 set_define("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
2606 with only_when(requires_wasm_sandboxing & compile_environment):
2608 "--with-wasi-sysroot",
2611 help="Path to wasi sysroot for wasm sandboxing",
2614 @depends("--with-wasi-sysroot", requires_wasm_sandboxing)
2615 def bootstrap_wasi_sysroot(wasi_sysroot, requires_wasm_sandboxing):
2616 return requires_wasm_sandboxing and not wasi_sysroot
2619 "--with-wasi-sysroot",
2620 bootstrap_path("sysroot-wasm32-wasi", when=bootstrap_wasi_sysroot),
2623 def wasi_sysroot(wasi_sysroot, bootstrapped_sysroot):
2624 if not wasi_sysroot:
2625 return bootstrapped_sysroot
2627 wasi_sysroot = wasi_sysroot[0]
2628 if not os.path.isdir(wasi_sysroot):
2629 die("Argument to --with-wasi-sysroot must be a directory")
2630 if not os.path.isabs(wasi_sysroot):
2631 die("Argument to --with-wasi-sysroot must be an absolute path")
2635 @depends(wasi_sysroot)
2636 def wasi_sysroot_flags(wasi_sysroot):
2638 log.info("Using wasi sysroot in %s", wasi_sysroot)
2639 return ["--sysroot=%s" % wasi_sysroot]
2642 set_config("WASI_SYSROOT", wasi_sysroot)
2644 def wasm_compiler_with_flags(compiler, sysroot_flags):
2647 compiler.wrapper + [compiler.compiler] + compiler.flags + sysroot_flags
2651 def wasm_compiler_error(msg):
2652 @depends("--with-wasm-sandboxed-libraries")
2653 def wasm_compiler_error(sandboxed_libs):
2654 suggest_disable = ""
2655 if sandboxed_libs.origin == "default":
2656 suggest_disable = " Or build with --without-wasm-sandboxed-libraries."
2657 return lambda: die(msg + suggest_disable)
2659 return wasm_compiler_error
2662 def check_wasm_compiler(compiler, language):
2663 compiler.try_compile(
2664 includes=["cstring" if language == "C++" else "string.h"],
2665 flags=wasi_sysroot_flags,
2666 check_msg="the wasm %s compiler can find wasi headers" % language,
2667 onerror=wasm_compiler_error(
2668 "Cannot find wasi headers or problem with the wasm compiler. "
2669 "Please fix the problem."
2674 flags=wasi_sysroot_flags,
2675 check_msg="the wasm %s linker can find wasi libraries" % language,
2676 onerror=wasm_compiler_error(
2677 "Cannot find wasi libraries or problem with the wasm linker. "
2678 "Please fix the problem."
2682 wasm_cc = compiler("C", wasm, other_compiler=c_compiler)
2683 check_wasm_compiler(wasm_cc, "C")
2685 @depends(wasm_cc, wasi_sysroot_flags)
2686 def wasm_cc_with_flags(wasm_cc, wasi_sysroot_flags):
2687 return wasm_compiler_with_flags(wasm_cc, wasi_sysroot_flags)
2689 set_config("WASM_CC", wasm_cc_with_flags)
2691 wasm_cxx = compiler(
2695 other_compiler=cxx_compiler,
2696 other_c_compiler=c_compiler,
2698 check_wasm_compiler(wasm_cxx, "C++")
2700 @depends(wasm_cxx, wasi_sysroot_flags)
2701 def wasm_cxx_with_flags(wasm_cxx, wasi_sysroot_flags):
2702 return wasm_compiler_with_flags(wasm_cxx, wasi_sysroot_flags)
2704 set_config("WASM_CXX", wasm_cxx_with_flags)
2706 wasm_compile_flags = dependable(["-fno-exceptions", "-fno-strict-aliasing"])
2707 option(env="WASM_CFLAGS", nargs=1, help="Options to pass to WASM_CC")
2709 @depends("WASM_CFLAGS", wasm_compile_flags)
2710 def wasm_cflags(value, wasm_compile_flags):
2712 return wasm_compile_flags + value
2714 return wasm_compile_flags
2716 set_config("WASM_CFLAGS", wasm_cflags)
2718 option(env="WASM_CXXFLAGS", nargs=1, help="Options to pass to WASM_CXX")
2720 @depends("WASM_CXXFLAGS", wasm_compile_flags)
2721 def wasm_cxxflags(value, wasm_compile_flags):
2723 return wasm_compile_flags + value
2725 return wasm_compile_flags
2727 set_config("WASM_CXXFLAGS", wasm_cxxflags)
2730 @depends("--with-wasm-sandboxed-libraries")
2731 def wasm_sandboxing(libraries):
2735 return namespace(**{name: True for name in libraries})
2739 def wasm_sandboxing_config_defines():
2740 for lib in wasm_sandboxing_libraries():
2742 "MOZ_WASM_SANDBOXING_%s" % lib.upper(), getattr(wasm_sandboxing, lib)
2745 "MOZ_WASM_SANDBOXING_%s" % lib.upper(), getattr(wasm_sandboxing, lib)
2749 wasm_sandboxing_config_defines()
2752 with only_when(compile_environment & wasm_sandboxing.hunspell):
2753 clock_in_wasi_sysroot = wasm_cc.try_run(
2754 header="#include <time.h>",
2756 check_msg="for clock() in wasi sysroot",
2757 flags=depends(wasi_sysroot_flags)(
2758 lambda sysroot_flags: ["-Werror"] + sysroot_flags
2762 wasi_emulated_clock = wasm_cc.try_run(
2763 header="#include <time.h>",
2765 check_msg="for emulated clock() in wasi sysroot",
2766 flags=depends(wasi_sysroot_flags)(
2767 lambda sysroot_flags: [
2769 "-D_WASI_EMULATED_PROCESS_CLOCKS",
2770 "-lwasi-emulated-process-clocks",
2774 when=depends(clock_in_wasi_sysroot)(lambda x: not x),
2775 onerror=lambda: die("Can't find clock() in wasi sysroot."),
2778 set_config("MOZ_WASI_EMULATED_CLOCK", True, when=wasi_emulated_clock)
2781 # new Notification Store implementation
2782 # ==============================================================
2786 def new_notification_store(milestone):
2787 if milestone.is_nightly:
2791 set_config("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)
2792 set_define("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)
2795 # Auxiliary files persistence on application close
2796 # ==============================================================
2799 "--enable-disk-remnant-avoidance",
2800 help="Prevent persistence of auxiliary files on application close",
2805 "MOZ_AVOID_DISK_REMNANT_ON_CLOSE",
2807 when="--enable-disk-remnant-avoidance",
2811 # Glean SDK Integration Crate
2812 # ==============================================================
2816 def glean_android(target):
2817 return target.os == "Android"
2820 set_config("MOZ_GLEAN_ANDROID", True, when=glean_android)
2821 set_define("MOZ_GLEAN_ANDROID", True, when=glean_android)
2825 # ==============================================================
2831 bootstrap="dump_syms",
2832 when=compile_environment,
2836 @depends(valid_windows_sdk_dir, host)
2837 @imports(_from="os", _import="environ")
2838 def pdbstr_paths(valid_windows_sdk_dir, host):
2839 if not valid_windows_sdk_dir:
2849 os.path.join(valid_windows_sdk_dir.path, "Debuggers", vc_host, "srcsrv"),
2857 when=compile_environment & target_is_windows,
2863 @depends("MOZ_AUTOMATION", c_compiler)
2864 def allow_missing_winchecksec(automation, c_compiler):
2867 if c_compiler and c_compiler.type != "clang-cl":
2873 ["winchecksec.exe", "winchecksec"],
2874 bootstrap="winchecksec",
2875 allow_missing=allow_missing_winchecksec,
2876 when=compile_environment & target_is_windows,
2881 @depends(target, build_project)
2882 def forkserver_default(target, build_project):
2883 return build_project == "browser" and (
2884 (target.os == "GNU" and target.kernel == "Linux")
2885 or target.os == "FreeBSD"
2886 or target.os == "OpenBSD"
2891 "--enable-forkserver",
2892 default=forkserver_default,
2893 env="MOZ_ENABLE_FORKSERVER",
2894 help="{Enable|Disable} fork server",
2898 @depends("--enable-forkserver", target)
2899 def forkserver_flag(value, target):
2901 target.os == "Android"
2902 or (target.os == "GNU" and target.kernel == "Linux")
2903 or target.os == "FreeBSD"
2904 or target.os == "OpenBSD"
2910 set_config("MOZ_ENABLE_FORKSERVER", forkserver_flag)
2911 set_define("MOZ_ENABLE_FORKSERVER", forkserver_flag, forkserver_flag)
2914 # ==============================================================
2916 with only_when(compile_environment & target_has_linux_kernel):
2917 # Check if we need to use the breakpad_getcontext fallback.
2918 getcontext = check_symbol("getcontext")
2919 set_config("HAVE_GETCONTEXT", getcontext)
2920 set_define("HAVE_GETCONTEXT", getcontext)
2923 # ==============================================================
2924 include("../build/moz.configure/nss.configure")
2927 # Enable or disable running in background task mode: headless for
2928 # periodic, short-lived, maintenance tasks.
2929 # ==============================================================================
2931 "--disable-backgroundtasks",
2932 help="Disable running in background task mode",
2934 set_config("MOZ_BACKGROUNDTASKS", True, when="--enable-backgroundtasks")
2935 set_define("MOZ_BACKGROUNDTASKS", True, when="--enable-backgroundtasks")
2938 # Update-related programs: updater, maintenance service, update agent,
2939 # default browser agent.
2940 # ==============================================================
2941 include("../build/moz.configure/update-programs.configure")
2944 # Mobile optimizations
2945 # ==============================================================
2947 "--enable-mobile-optimize",
2948 default=target_is_android,
2949 help="{Enable|Disable} mobile optimizations",
2952 set_define("MOZ_GFX_OPTIMIZE_MOBILE", True, when="--enable-mobile-optimize")
2953 # We ignore "paint will resample" on mobile for performance.
2954 # We may want to revisit this later.
2955 set_define("MOZ_IGNORE_PAINT_WILL_RESAMPLE", True, when="--enable-mobile-optimize")
2958 # ==============================================================
2959 option("--disable-pref-extensions", help="Disable pref extensions such as autoconfig")
2960 set_config("MOZ_PREF_EXTENSIONS", True, when="--enable-pref-extensions")
2962 # Offer a way to disable the startup cache
2963 # ==============================================================
2964 option("--disable-startupcache", help="Disable startup cache")
2967 @depends("--enable-startupcache")
2968 def enable_startupcache(value):
2974 "MOZ_DISABLE_STARTUPCACHE", True, when=depends(enable_startupcache)(lambda x: not x)
2979 # ==============================================================
2981 env="MOZ_APP_REMOTINGNAME",
2983 help="Used for the internal program name, which affects profile name "
2984 "and remoting. If not set, defaults to MOZ_APP_NAME if the update channel "
2985 "is release, and MOZ_APP_NAME-MOZ_UPDATE_CHANNEL otherwise.",
2989 @depends("MOZ_APP_REMOTINGNAME", moz_app_name, update_channel)
2990 def moz_app_remotingname(value, moz_app_name, update_channel):
2993 if update_channel == "release":
2995 return moz_app_name + "-" + update_channel
2998 set_config("MOZ_APP_REMOTINGNAME", moz_app_remotingname)
3001 env="ANDROID_PACKAGE_NAME",
3003 help="Name of the Android package (default org.mozilla.$MOZ_APP_NAME)",
3007 @depends("ANDROID_PACKAGE_NAME", moz_app_name)
3008 def android_package_name(value, moz_app_name):
3011 if moz_app_name == "fennec":
3012 return "org.mozilla.fennec_aurora"
3013 return "org.mozilla.%s" % moz_app_name
3016 set_config("ANDROID_PACKAGE_NAME", android_package_name)
3019 # Miscellaneous options
3020 # ==============================================================
3021 option(env="MOZ_WINCONSOLE", nargs="?", help="Whether we can create a console window.")
3022 set_define("MOZ_WINCONSOLE", True, when=depends("MOZ_WINCONSOLE")(lambda x: x))
3025 # Alternative Crashreporter setting
3027 "--with-crashreporter-url",
3028 env="MOZ_CRASHREPORTER_URL",
3029 default="https://crash-reports.mozilla.com/",
3031 help="Set an alternative crashreporter url",
3035 "MOZ_CRASHREPORTER_URL",
3036 depends("--with-crashreporter-url")(lambda x: x[0].rstrip("/")),
3040 # Crash reporter options
3041 # ==============================================================
3043 def oxidized_breakpad(target):
3044 if target.kernel == "Linux":
3045 return target.cpu in ("aarch64", "arm", "x86", "x86_64")
3049 set_config("MOZ_OXIDIZED_BREAKPAD", True, when=oxidized_breakpad)
3050 set_define("MOZ_OXIDIZED_BREAKPAD", True, when=oxidized_breakpad)
3054 # ==============================================================
3055 @depends(target, host)
3056 def want_wine(target, host):
3057 return target.kernel == "WINNT" and host.kernel != "WINNT"
3064 bootstrap="wine/bin",
3068 # ==============================================================
3069 # Set this to true so the JS engine knows we're doing a browser build.
3070 set_config("MOZ_DOM_STREAMS", True)
3071 set_define("MOZ_DOM_STREAMS", True)
3074 # ==============================================================
3075 with only_when(compile_environment):
3077 "--with-system-libevent",
3079 help="Use system libevent",
3082 @depends("--with-system-libevent")
3083 def deprecated_system_libevent_path(value):
3086 "--with-system-libevent=PATH is not supported anymore. Please use "
3087 "--with-system-libevent and set any necessary pkg-config environment variable."
3090 pkg_check_modules("MOZ_LIBEVENT", "libevent", when="--with-system-libevent")
3092 set_config("MOZ_SYSTEM_LIBEVENT", True, when="--with-system-libevent")
3096 # ==============================================================
3097 @depends(target, developer_options, artifact_builds)
3098 def crashreporter_default(target, developer_options, artifacts):
3099 if target.kernel in ("WINNT", "Darwin"):
3101 if target.kernel == "Linux" and target.cpu in ("x86", "x86_64", "arm", "aarch64"):
3102 # The crash reporter prevents crash stacktraces to be logged in the
3103 # logs on Android, so we leave it out by default in developer builds.
3104 return target.os != "Android" or not developer_options or artifacts
3108 "--enable-crashreporter",
3109 default=crashreporter_default,
3110 help="{Enable|Disable} crash reporting",
3114 set_config("MOZ_CRASHREPORTER", True, when="--enable-crashreporter")
3115 set_define("MOZ_CRASHREPORTER", True, when="--enable-crashreporter")
3117 with only_when(compile_environment):
3118 with only_when("--enable-crashreporter"):
3122 when=depends(target)(lambda t: t.os == "GNU" and t.kernel == "Linux"),
3126 "MOZ_CRASHREPORTER_INJECTOR",
3128 when=depends(target)(lambda t: t.os == "WINNT" and t.bitness == 32),
3131 "MOZ_CRASHREPORTER_INJECTOR",
3133 when=depends(target)(lambda t: t.os == "WINNT" and t.bitness == 32),
3137 # If we have any service that uploads data (and requires data submission
3138 # policy alert), set MOZ_DATA_REPORTING.
3139 # ==============================================================
3141 "MOZ_TELEMETRY_REPORTING",
3142 "MOZ_SERVICES_HEALTHREPORT",
3143 "--enable-crashreporter",
3146 def data_reporting(telemetry, healthreport, crashreporter, normandy):
3147 return telemetry or healthreport or crashreporter or normandy
3150 set_config("MOZ_DATA_REPORTING", True, when=data_reporting)
3151 set_define("MOZ_DATA_REPORTING", True, when=data_reporting)
3155 # ==============================================================
3156 with only_when(toolkit_gtk):
3159 "gtk+-3.0 >= 3.14.0 gtk+-unix-print-3.0 glib-2.0 gobject-2.0 gio-unix-2.0",
3162 set_define("GDK_VERSION_MIN_REQUIRED", "GDK_VERSION_3_14")
3163 set_define("GDK_VERSION_MAX_ALLOWED", "GDK_VERSION_3_14")
3165 pkg_check_modules("GLIB", "glib-2.0 >= 2.42 gobject-2.0")
3167 set_define("GLIB_VERSION_MIN_REQUIRED", "GLIB_VERSION_2_42")
3168 set_define("GLIB_VERSION_MAX_ALLOWED", "GLIB_VERSION_2_42")
3170 set_define("MOZ_ACCESSIBILITY_ATK", True, when=accessibility)
3173 # ==============================================================
3174 with only_when(toolkit_gtk):
3175 option("--disable-dbus", help="Disable dbus support")
3177 with only_when("--enable-dbus"):
3178 pkg_check_modules("MOZ_DBUS", "dbus-1 >= 0.60")
3180 set_config("MOZ_ENABLE_DBUS", True)
3181 set_define("MOZ_ENABLE_DBUS", True)
3184 # Necko's wifi scanner
3185 # ==============================================================
3187 def necko_wifi_when(target):
3188 return target.os in ("WINNT", "OSX", "DragonFly", "FreeBSD") or (
3189 target.kernel == "Linux" and target.os == "GNU"
3193 option("--disable-necko-wifi", help="Disable necko wifi scanner", when=necko_wifi_when)
3195 set_config("NECKO_WIFI", True, when="--enable-necko-wifi")
3196 set_define("NECKO_WIFI", True, when="--enable-necko-wifi")
3200 depends("--enable-necko-wifi", when=necko_wifi_when)(lambda x: x),
3201 depends("--enable-dbus", when=toolkit_gtk)(lambda x: x),
3202 when=depends(target)(lambda t: t.os == "GNU" and t.kernel == "Linux"),
3204 def necko_wifi_dbus(necko_wifi, dbus):
3205 if necko_wifi and not dbus:
3207 "Necko WiFi scanning needs DBus on your platform, remove --disable-dbus"
3208 " or use --disable-necko-wifi"
3210 return necko_wifi and dbus
3213 set_config("NECKO_WIFI_DBUS", True, when=necko_wifi_dbus)
3214 set_define("NECKO_WIFI_DBUS", True, when=necko_wifi_dbus)
3217 # Frontend JS debug mode
3218 # ==============================================================
3219 option("--enable-debug-js-modules", help="Enable debug mode for frontend JS libraries")
3221 set_config("DEBUG_JS_MODULES", True, when="--enable-debug-js-modules")
3225 # ==============================================================
3226 option("--enable-dump-painting", help="Enable paint debugging")
3229 "MOZ_DUMP_PAINTING",
3231 when=depends("--enable-dump-painting", "--enable-debug")(
3232 lambda painting, debug: painting or debug
3235 set_define("MOZ_LAYERS_HAVE_LOG", True, when="--enable-dump-painting")
3239 # ==============================================================
3240 with only_when(toolkit_gtk):
3241 system_lib_option("--enable-libproxy", help="Enable libproxy support")
3243 with only_when("--enable-libproxy"):
3244 pkg_check_modules("MOZ_LIBPROXY", "libproxy-1.0")
3246 set_config("MOZ_ENABLE_LIBPROXY", True)
3247 set_define("MOZ_ENABLE_LIBPROXY", True)
3250 # Enable runtime logging
3251 # ==============================================================
3252 set_define("MOZ_LOGGING", True)
3253 set_define("FORCE_PR_LOG", True)
3255 # This will enable logging of addref, release, ctor, dtor.
3256 # ==============================================================
3258 "--enable-logrefcnt",
3260 help="{Enable|Disable} logging of refcounts",
3263 set_define("NS_BUILD_REFCNT_LOGGING", True, when="--enable-logrefcnt")
3267 # ==============================================================
3268 option("--disable-negotiateauth", help="Disable GSS-API negotiation")
3270 set_config("MOZ_AUTH_EXTENSION", True, when="--enable-negotiateauth")
3271 set_define("MOZ_AUTH_EXTENSION", True, when="--enable-negotiateauth")
3275 # ==============================================================
3276 option("--disable-parental-controls", help="Do not build parental controls")
3279 "MOZ_DISABLE_PARENTAL_CONTROLS",
3281 when=depends("--enable-parental-controls")(lambda x: not x),
3284 "MOZ_DISABLE_PARENTAL_CONTROLS",
3286 when=depends("--enable-parental-controls")(lambda x: not x),
3290 # Sandboxing support
3291 # ==============================================================
3292 @depends(target, tsan, asan)
3293 def sandbox_default(target, tsan, asan):
3294 # Only enable the sandbox by default on Linux, OpenBSD, macOS, and Windows
3295 if target.kernel == "Linux" and target.os == "GNU":
3296 # Bug 1182565: TSan conflicts with sandboxing on Linux.
3297 # Bug 1287971: LSan also conflicts with sandboxing on Linux.
3300 # Linux sandbox is only available on x86{,_64} and arm{,64}.
3301 return target.cpu in ("x86", "x86_64", "arm", "aarch64")
3302 return target.kernel in ("WINNT", "Darwin", "OpenBSD")
3307 default=sandbox_default,
3308 help="{Enable|Disable} sandboxing support",
3311 set_config("MOZ_SANDBOX", True, when="--enable-sandbox")
3312 set_define("MOZ_SANDBOX", True, when="--enable-sandbox")
3314 with only_when(depends(target.kernel)(lambda k: k not in ("Darwin", "WINNT"))):
3315 set_define("MOZ_CONTENT_TEMP_DIR", True, when="--enable-sandbox")
3317 # Searching of system directories for extensions.
3318 # ==============================================================
3319 # Note: this switch is meant to be used for test builds whose behavior should
3320 # not depend on what happens to be installed on the local machine.
3322 "--disable-system-extension-dirs",
3323 help="Disable searching system- and account-global directories for extensions"
3324 " of any kind; use only profile-specific extension directories",
3327 set_define("ENABLE_SYSTEM_EXTENSION_DIRS", True, when="--enable-system-extension-dirs")
3331 # ==============================================================
3332 with only_when(compile_environment):
3334 "--enable-system-pixman", help="Use system pixman (located with pkgconfig)"
3337 @depends("--enable-system-pixman")
3338 def in_tree_pixman(pixman):
3341 set_config("MOZ_TREE_PIXMAN", True, when=in_tree_pixman)
3342 set_define("MOZ_TREE_PIXMAN", True, when=in_tree_pixman)
3344 pkg_check_modules("MOZ_PIXMAN", "pixman-1 >= 0.36.0", when="--enable-system-pixman")
3345 # Set MOZ_PIXMAN_CFLAGS to an explicit empty value when --enable-system-pixman is *not* used,
3346 # for layout/style/extra-bindgen-flags
3347 set_config("MOZ_PIXMAN_CFLAGS", [], when=in_tree_pixman)
3351 # ==============================================================
3352 with only_when(compile_environment):
3353 option("--disable-universalchardet", help="Disable universal encoding detection")
3355 set_config("MOZ_UNIVERSALCHARDET", True, when="--enable-universalchardet")
3359 # ==============================================================
3360 with only_when(compile_environment):
3361 option("--disable-zipwriter", help="Disable zipwriter component")
3363 set_config("MOZ_ZIPWRITER", True, when="--enable-zipwriter")
3366 # Location of the mozilla user directory
3367 # ==============================================================
3368 with only_when(compile_environment):
3371 def default_user_appdir(target):
3372 if target.kernel in ("WINNT", "Darwin"):
3377 "--with-user-appdir",
3379 default=default_user_appdir,
3380 help="Set user-specific appdir",
3383 @depends("--with-user-appdir")
3384 def user_appdir(appdir):
3386 die("--without-user-appdir is not a valid option.")
3387 if "/" in appdir[0]:
3388 die("--with-user-appdir must be a single relative path.")
3389 return '"{}"'.format(appdir[0])
3391 set_define("MOZ_USER_DIR", user_appdir)
3394 # Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
3395 # ==============================================================
3396 with only_when(compile_environment):
3397 have_sin_len = c_compiler.try_compile(
3398 includes=["netinet/in.h"],
3399 body="struct sockaddr_in x; void *foo = (void*) &x.sin_len;",
3400 check_msg="for sin_len in struct sockaddr_in",
3402 have_sin6_len = c_compiler.try_compile(
3403 includes=["netinet/in.h"],
3404 body="struct sockaddr_in6 x; void *foo = (void*) &x.sin6_len;",
3405 check_msg="for sin_len6 in struct sockaddr_in6",
3407 set_define("HAVE_SIN_LEN", have_sin_len)
3408 set_define("HAVE_SIN6_LEN", have_sin6_len)
3409 # HAVE_CONN_LEN must be the same as HAVE_SIN_LEN and HAVE_SIN6_LEN
3410 set_define("HAVE_SCONN_LEN", have_sin_len & have_sin6_len)
3413 c_compiler.try_compile(
3414 includes=["netinet/in.h"],
3415 body="struct sockaddr x; void *foo = (void*) &x.sa_len;",
3416 check_msg="for sa_len in struct sockaddr",
3421 # Check for pthread_cond_timedwait_monotonic_np
3422 # ==============================================================
3423 with only_when(compile_environment):
3425 "HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC",
3426 c_compiler.try_compile(
3427 includes=["pthread.h"],
3428 body="pthread_cond_timedwait_monotonic_np(0, 0, 0);",
3429 # -Werror to catch any "implicit declaration" warning that means the function
3431 flags=["-Werror=implicit-function-declaration"],
3432 check_msg="for pthread_cond_timedwait_monotonic_np",
3437 # Custom dynamic linker for Android
3438 # ==============================================================
3439 with only_when(target_has_linux_kernel & compile_environment):
3442 default=depends(target.os, when="--enable-jemalloc")(
3443 lambda os: os == "Android"
3445 help="{Enable|Disable} custom dynamic linker",
3448 set_config("MOZ_LINKER", True, when="MOZ_LINKER")
3449 set_define("MOZ_LINKER", True, when="MOZ_LINKER")
3450 add_old_configure_assignment("MOZ_LINKER", True, when="MOZ_LINKER")
3452 moz_linker = depends(when="MOZ_LINKER")(lambda: True)
3455 # 32-bits ethtool_cmd.speed
3456 # ==============================================================
3457 with only_when(target_has_linux_kernel & compile_environment):
3459 "MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI",
3460 c_compiler.try_compile(
3461 includes=["linux/ethtool.h"],
3462 body="struct ethtool_cmd cmd; cmd.speed_hi = 0;",
3463 check_msg="for 32-bits ethtool_cmd.speed",
3468 # ==============================================================
3471 onerror=lambda: die(
3472 "Can't find header linux/joystick.h, needed for gamepad support."
3473 " Please install Linux kernel headers."
3475 when=target_has_linux_kernel & compile_environment,
3479 # Smart card support
3480 # ==============================================================
3481 @depends(build_project)
3482 def disable_smart_cards(build_project):
3483 return build_project == "mobile/android"
3486 set_config("MOZ_NO_SMART_CARDS", True, when=disable_smart_cards)
3487 set_define("MOZ_NO_SMART_CARDS", True, when=disable_smart_cards)
3489 # Enable UniFFI fixtures
3490 # ==============================================================
3491 # These are used to test the uniffi-bindgen-gecko-js code generation. They
3492 # should not be enabled in release builds.
3495 "--enable-uniffi-fixtures",
3496 help="Enable UniFFI Fixtures/Examples",
3499 set_config("MOZ_UNIFFI_FIXTURES", True, when="--enable-uniffi-fixtures")
3502 # ==============================================================
3505 "--disable-system-policies",
3506 help="Disable reading policies from Windows registry, macOS's file system attributes, and /etc/firefox",
3509 set_config("MOZ_SYSTEM_POLICIES", True, when="--enable-system-policies")
3511 # Allow disabling the creation a legacy profile
3512 # ==============================================================
3515 "--disable-legacy-profile-creation",
3516 help="Disable the creation a legacy profile, to be used by old versions "
3517 "of Firefox, when no profiles exist.",
3520 set_config("MOZ_CREATE_LEGACY_PROFILE", True, when="--enable-legacy-profile-creation")
3524 # ==============================================================
3525 set_config("WRAP_STL_INCLUDES", True)
3528 depends(build_environment.dist)(lambda dist: [f"-I{dist}/stl_wrappers"]),
3533 # ==============================================================
3535 def need_perl(target):
3536 # Ideally, we'd also depend on gnu_as here, but that adds complications.
3537 return target.cpu == "arm"
3540 perl = check_prog("PERL", ("perl5", "perl"), when=need_perl)
3544 def perl_version_check(min_version):
3546 @checking("for minimum required perl version >= %s" % min_version)
3547 def get_perl_version(perl):
3553 onerror=lambda: die("Failed to get perl version."),
3557 @depends(get_perl_version)
3558 def check_perl_version(version):
3559 if version < min_version:
3560 die("Perl %s or higher is required.", min_version)
3563 @checking("for full perl installation")
3564 @imports("subprocess")
3565 def has_full_perl_installation(perl):
3566 ret = subprocess.call([perl, "-e", "use Config; exit(!-d $Config{archlib})"])
3569 @depends(has_full_perl_installation)
3570 def require_full_perl_installation(has_full_perl_installation):
3571 if not has_full_perl_installation:
3573 "Cannot find Config.pm or $Config{archlib}. "
3574 "A full perl installation is required."
3578 with only_when(need_perl):
3579 perl_version_check("5.006")