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", "iOS", "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)
90 option("--disable-gecko-profiler", help="Disable the Gecko profiler")
93 @depends("--disable-gecko-profiler", target)
94 def gecko_profiler(enable_gecko_profiler, target):
95 if not enable_gecko_profiler:
98 if target.os == "Android":
99 return target.cpu in ("aarch64", "arm", "x86", "x86_64")
100 elif target.kernel == "Linux":
101 return target.cpu in ("aarch64", "arm", "x86", "x86_64", "mips64")
102 elif target.kernel == "FreeBSD":
103 return target.cpu in ("aarch64", "x86_64")
104 return target.os in ("OSX", "WINNT")
107 @depends(gecko_profiler)
108 def gecko_profiler_define(value):
113 set_config("MOZ_GECKO_PROFILER", gecko_profiler_define)
114 set_define("MOZ_GECKO_PROFILER", gecko_profiler_define)
117 # Whether code to parse ELF binaries should be compiled for the Gecko profiler
118 # (for symbol table dumping).
119 @depends(gecko_profiler, target)
120 def gecko_profiler_parse_elf(value, target):
121 # Currently we only want to build this code on Linux (including Android) and BSD.
122 # For Android, this is in order to dump symbols from Android system, where
123 # on other platforms there exist alternatives that don't require bloating
124 # up our binary size. For Linux more generally, we use this in profile
125 # pre-symbolication support, since MozDescribeCodeAddress doesn't do
126 # anything useful on that platform. (Ideally, we would update
127 # MozDescribeCodeAddress to call into some Rust crates that parse ELF and
128 # DWARF data, but build system issues currently prevent Rust from being
130 if value and (target.kernel == "Linux" or target.kernel == "FreeBSD"):
134 set_config("MOZ_GECKO_PROFILER_PARSE_ELF", gecko_profiler_parse_elf)
135 set_define("MOZ_GECKO_PROFILER_PARSE_ELF", gecko_profiler_parse_elf)
137 # enable this by default if the profiler is enabled
138 # Note: also requires jemalloc
139 set_config("MOZ_PROFILER_MEMORY", gecko_profiler_define)
140 set_define("MOZ_PROFILER_MEMORY", gecko_profiler_define)
147 # Artifact builds are included because the downloaded artifacts can
149 when=artifact_builds | depends(when="--enable-replace-malloc")(lambda: True),
151 def dmd_default(debug, milestone, build_project):
152 return bool(build_project == "browser" and (debug or milestone.is_nightly))
159 help="{Enable|Disable} Dark Matter Detector (heap profiler). "
160 "Also enables jemalloc, replace-malloc and profiling",
164 @depends("--enable-dmd")
170 set_config("MOZ_DMD", dmd)
171 set_define("MOZ_DMD", dmd)
172 imply_option("--enable-profiling", dmd)
173 imply_option("--enable-jemalloc", dmd, when=compile_environment)
174 imply_option("--enable-replace-malloc", dmd, when=compile_environment)
177 # midir-based Web MIDI support
178 # ==============================================================
180 def midir_linux_support(target):
182 target.kernel == "Linux" and target.os != "Android" and target.cpu != "riscv64"
186 @depends(target, midir_linux_support)
187 def midir_support(target, midir_linux_support):
188 if target.os in ("WINNT", "OSX") or midir_linux_support:
192 set_config("MOZ_WEBMIDI_MIDIR_IMPL", midir_support)
195 # Enable various cubeb backends
196 # ==============================================================
198 def audio_backends_default(target):
199 if target.os == "Android":
204 elif target.os in ("DragonFly", "FreeBSD", "SunOS"):
206 elif target.os == "OpenBSD":
208 elif target.os == "OSX":
209 return ("audiounit",)
210 elif target.os == "iOS":
212 elif target.os == "NetBSD":
214 elif target.os == "SunOS":
216 elif target.os == "WINNT":
219 return ("pulseaudio",)
223 "--enable-audio-backends",
237 default=audio_backends_default,
238 help="{Enable|Disable} various cubeb backends",
242 @depends("--enable-audio-backends", target)
243 def imply_aaudio(values, target):
244 if any("aaudio" in value for value in values) and target.os != "Android":
245 die("Cannot enable AAudio on %s", target.os)
246 return any("aaudio" in value for value in values) or None
249 @depends("--enable-audio-backends", target)
250 def imply_alsa(values, target):
252 any("alsa" in value for value in values)
253 and target.kernel != "Linux"
254 and target.os != "FreeBSD"
256 die("Cannot enable ALSA on %s", target.os)
257 return any("alsa" in value for value in values) or None
260 @depends("--enable-audio-backends", target)
261 def imply_audiounit(values, target):
263 any("audiounit" in value for value in values)
264 and target.os != "OSX"
265 and target.kernel != "Darwin"
267 die("Cannot enable AudioUnit on %s", target.os)
268 return any("audiounit" in value for value in values) or None
271 @depends("--enable-audio-backends")
272 def imply_jack(values):
273 return any("jack" in value for value in values) or None
276 @depends("--enable-audio-backends", target)
277 def imply_opensl(values, target):
278 if any("opensl" in value for value in values) and target.os != "Android":
279 die("Cannot enable OpenSL on %s", target.os)
280 return any("opensl" in value for value in values) or None
283 @depends("--enable-audio-backends", target)
284 def imply_oss(values, target):
285 if any("oss" in value for value in values) and (
286 target.os in ("Android", "OSX", "iOS", "WINNT")
288 die("Cannot enable OSS on %s", target.os)
289 return any("oss" in value for value in values) or None
292 @depends("--enable-audio-backends", target)
293 def imply_pulseaudio(values, target):
294 if any("pulseaudio" in value for value in values) and (
295 target.os in ("Android", "OSX", "iOS", "WINNT")
297 die("Cannot enable PulseAudio on %s", target.os)
298 return any("pulseaudio" in value for value in values) or None
301 @depends("--enable-audio-backends", target)
302 def imply_sndio(values, target):
303 if any("sndio" in value for value in values) and (
304 target.os in ("Android", "OSX", "iOS", "WINNT")
306 die("Cannot enable sndio on %s", target.os)
307 return any("sndio" in value for value in values) or None
310 @depends("--enable-audio-backends", target)
311 def imply_sunaudio(values, target):
312 if any("sunaudio" in value for value in values) and (
313 target.os != "NetBSD" and target.os != "SunOS"
315 die("Cannot enable sunaudio on %s", target.os)
316 return any("sunaudio" in value for value in values) or None
319 @depends("--enable-audio-backends", target)
320 def imply_wasapi(values, target):
321 if any("wasapi" in value for value in values) and target.os != "WINNT":
322 die("Cannot enable WASAPI on %s", target.os)
323 return any("wasapi" in value for value in values) or None
326 set_config("MOZ_AAUDIO", imply_aaudio, when="--enable-audio-backends")
328 imply_option("--enable-alsa", imply_alsa, reason="--enable-audio-backends")
330 set_config("MOZ_AUDIOUNIT_RUST", imply_audiounit, when="--enable-audio-backends")
332 imply_option("--enable-jack", imply_jack, reason="--enable-audio-backends")
334 set_config("MOZ_OPENSL", imply_opensl, when="--enable-audio-backends")
336 set_config("MOZ_OSS", imply_oss, when="--enable-audio-backends")
338 imply_option("--enable-pulseaudio", imply_pulseaudio, reason="--enable-audio-backends")
340 imply_option("--enable-sndio", imply_sndio, reason="--enable-audio-backends")
342 set_config("MOZ_SUNAUDIO", imply_sunaudio, when="--enable-audio-backends")
344 set_config("MOZ_WASAPI", imply_wasapi, when="--enable-audio-backends")
347 # ==============================================================
348 option("--enable-alsa", env="MOZ_ALSA", help="Enable ALSA audio backend.")
351 @depends("--enable-alsa", midir_linux_support)
352 def enable_alsa_or_midir_linux_support(alsa_enabled, midir_linux_support):
353 return alsa_enabled or midir_linux_support
356 pkg_check_modules("MOZ_ALSA", "alsa", when=enable_alsa_or_midir_linux_support)
358 set_config("MOZ_ALSA", True, when="--enable-alsa")
359 set_define("MOZ_ALSA", True, when="--enable-alsa")
362 # ==============================================================
363 system_lib_option("--enable-jack", env="MOZ_JACK", help="Enable JACK audio backend.")
365 jack = pkg_check_modules("MOZ_JACK", "jack", when="--enable-jack")
367 set_config("MOZ_JACK", depends_if(jack)(lambda _: True))
369 # PulseAudio cubeb backend
370 # ==============================================================
372 "--enable-pulseaudio",
373 env="MOZ_PULSEAUDIO",
374 help="{Enable|Disable} PulseAudio audio backend.",
377 pulseaudio = pkg_check_modules("MOZ_PULSEAUDIO", "libpulse", when="--enable-pulseaudio")
379 set_config("MOZ_PULSEAUDIO", depends_if(pulseaudio)(lambda _: True))
380 set_define("MOZ_PULSEAUDIO", depends_if(pulseaudio)(lambda _: True))
382 # sndio cubeb backend
383 # ==============================================================
384 system_lib_option("--enable-sndio", env="MOZ_SNDIO", help="Enable sndio audio backend.")
386 sndio = pkg_check_modules("MOZ_SNDIO", "sndio", when="--enable-sndio")
388 set_config("MOZ_SNDIO", depends_if(sndio)(lambda _: True))
391 # ==============================================================
392 include("../js/moz.configure")
396 # ==============================================================
397 include("../build/moz.configure/node.configure")
400 # ==============================================================
401 set_define("JSON_USE_EXCEPTION", 0)
404 # ==============================================================
405 option("--with-l10n-base", nargs=1, env="L10NBASEDIR", help="Path to l10n repositories")
408 @depends("--with-l10n-base", "MOZ_AUTOMATION", build_environment)
409 @imports(_from="os.path", _import="isdir")
410 @imports(_from="os.path", _import="expanduser")
411 @imports(_from="os", _import="environ")
412 def l10n_base(value, automation, build_env):
416 die("Invalid value --with-l10n-base, %s doesn't exist", path)
418 path = os.path.join(build_env.topsrcdir, "../l10n-central")
422 "MOZBUILD_STATE_PATH", expanduser(os.path.join("~", ".mozbuild"))
426 return os.path.realpath(os.path.abspath(path))
429 set_config("L10NBASEDIR", l10n_base)
433 # ==============================================================
435 def toolkit_choices(target):
436 if target.os == "WINNT":
437 return ("cairo-windows",)
438 elif target.os == "OSX":
439 return ("cairo-cocoa",)
440 elif target.os == "iOS":
441 return ("cairo-uikit",)
442 elif target.os == "Android":
443 return ("cairo-android",)
445 # cairo-gtk3 - X11 backend with optional Wayland backend (auto detected)
446 # cairo-gtk3-wayland - Wayland backend with optional X11 backend (auto detected)
447 # cairo-gtk3-x11-wayland - builds explicitly with X11 & Wayland backends
450 "cairo-gtk3-wayland",
451 "cairo-gtk3-x11-wayland",
452 "cairo-gtk3-wayland-only",
453 "cairo-gtk3-x11-only",
457 @depends(toolkit_choices)
458 def toolkit_default(choices):
463 "--enable-default-toolkit",
465 choices=toolkit_choices,
466 default=toolkit_default,
467 help="Select default toolkit",
471 @depends("--enable-default-toolkit")
472 def full_toolkit(value):
477 @depends(full_toolkit)
478 def toolkit(toolkit):
479 if toolkit.startswith("cairo-gtk3"):
480 widget_toolkit = "gtk"
482 widget_toolkit = toolkit.replace("cairo-", "")
483 return widget_toolkit
486 set_config("MOZ_WIDGET_TOOLKIT", toolkit)
487 add_old_configure_assignment("MOZ_WIDGET_TOOLKIT", toolkit)
491 def toolkit_define(toolkit):
492 if toolkit != "windows":
493 return "MOZ_WIDGET_%s" % toolkit.upper()
496 set_define(toolkit_define, True)
500 def toolkit_gtk(toolkit):
501 return toolkit == "gtk"
504 @depends(toolkit_gtk, full_toolkit)
505 def toolkit_gtk_x11(toolkit_gtk, full_toolkit):
506 return toolkit_gtk and full_toolkit != "cairo-gtk3-wayland-only"
509 @depends(full_toolkit)
510 def toolkit_gtk_x11_optional(full_toolkit):
511 return full_toolkit == "cairo-gtk3-wayland"
514 @depends(toolkit_gtk, full_toolkit)
515 def toolkit_gtk_wayland(toolkit_gtk, full_toolkit):
516 return toolkit_gtk and full_toolkit != "cairo-gtk3-x11-only"
519 @depends(full_toolkit)
520 def toolkit_gtk_wayland_optional(full_toolkit):
521 return full_toolkit == "cairo-gtk3"
525 # ==============================================================
526 wayland_headers = pkg_check_modules(
528 "gtk+-wayland-3.0 >= 3.14 xkbcommon >= 0.4.1",
529 allow_missing=toolkit_gtk_wayland_optional,
530 when=toolkit_gtk_wayland,
534 @depends(wayland_headers, toolkit_gtk, artifact_builds, toolkit_gtk_wayland)
535 def wayland_headers(wayland, toolkit_gtk, artifacts, toolkit_gtk_wayland):
536 if not toolkit_gtk_wayland:
538 if toolkit_gtk and artifacts:
543 set_config("MOZ_WAYLAND", depends_if(wayland_headers)(lambda _: True))
544 set_define("MOZ_WAYLAND", depends_if(wayland_headers)(lambda _: True))
547 # Hardware-accelerated video decode with VAAPI and V4L2 on Linux
548 # ==============================================================
549 set_config("MOZ_ENABLE_VAAPI", True, when=toolkit_gtk)
550 set_define("MOZ_ENABLE_VAAPI", True, when=toolkit_gtk)
553 @depends(target, toolkit_gtk)
554 def v4l2(target, toolkit_gtk):
555 # V4L2 decode is only used in GTK/Linux and generally only appears on
557 if target.cpu in ("arm", "aarch64", "riscv64") and toolkit_gtk:
561 set_config("MOZ_ENABLE_V4L2", True, when=v4l2)
562 set_define("MOZ_ENABLE_V4L2", True, when=v4l2)
565 # ==============================================================
566 option("--with-gl-provider", nargs=1, help="Set GL provider backend type")
569 @depends("--with-gl-provider")
570 def gl_provider(value):
575 @depends(gl_provider)
576 def gl_provider_define(provider):
578 return "GLContextProvider%s" % provider
581 set_define("MOZ_GL_PROVIDER", gl_provider_define)
584 @depends(gl_provider, toolkit_gtk)
585 def gl_default_provider(value, toolkit_gtk):
592 set_config("MOZ_GL_PROVIDER", gl_provider)
593 set_config("MOZ_GL_DEFAULT_PROVIDER", gl_default_provider)
596 @depends(gl_default_provider)
597 def gl_provider_define(provider):
599 return "GL_PROVIDER_%s" % provider
602 set_define(gl_provider_define, True)
606 # ==============================================================
608 def pdf_printing(toolkit):
609 if toolkit in ("windows", "gtk", "android"):
613 set_config("MOZ_PDF_PRINTING", pdf_printing)
614 set_define("MOZ_PDF_PRINTING", pdf_printing)
617 # Event loop instrumentation
618 # ==============================================================
619 option(env="MOZ_INSTRUMENT_EVENT_LOOP", help="Force-enable event loop instrumentation")
622 @depends("MOZ_INSTRUMENT_EVENT_LOOP", toolkit)
623 def instrument_event_loop(value, toolkit):
625 toolkit in ("windows", "gtk", "cocoa", "android") and value.origin == "default"
630 set_config("MOZ_INSTRUMENT_EVENT_LOOP", instrument_event_loop)
631 set_define("MOZ_INSTRUMENT_EVENT_LOOP", instrument_event_loop)
634 # Fontconfig Freetype
635 # ==============================================================
636 option(env="USE_FC_FREETYPE", help="Force-enable the use of fontconfig freetype")
639 @depends("USE_FC_FREETYPE", toolkit)
640 def fc_freetype(value, toolkit):
641 if value or (toolkit == "gtk" and value.origin == "default"):
645 set_define("USE_FC_FREETYPE", fc_freetype)
648 # ==============================================================
649 pkg_check_modules("MOZ_PANGO", "pango >= 1.22.0", when=toolkit_gtk)
652 # ==============================================================
653 fontconfig_info = pkg_check_modules(
654 "_FONTCONFIG", "fontconfig >= 2.7.0", when=fc_freetype
658 @depends(fc_freetype)
659 def check_for_freetype2(fc_freetype):
664 # Check for freetype2. Flags are combined with fontconfig flags.
665 freetype2_info = pkg_check_modules(
666 "_FT2", "freetype2 >= 9.10.3", when=check_for_freetype2
670 @depends(fontconfig_info, freetype2_info)
671 def freetype2_combined_info(fontconfig_info, freetype2_info):
672 if not freetype2_info:
674 if not fontconfig_info:
675 return freetype2_info
677 cflags=freetype2_info.cflags + fontconfig_info.cflags,
678 libs=freetype2_info.libs + fontconfig_info.libs,
682 set_define("MOZ_HAVE_FREETYPE2", depends_if(freetype2_info)(lambda _: True))
685 # Apple platform decoder support
686 # ==============================================================
688 def applemedia(toolkit):
689 if toolkit == "cocoa":
693 set_config("MOZ_APPLEMEDIA", applemedia)
694 set_define("MOZ_APPLEMEDIA", applemedia)
696 # Windows Media Foundation support
697 # ==============================================================
698 option("--disable-wmf", help="Disable support for Windows Media Foundation")
701 @depends("--disable-wmf", target, "--help")
702 def wmf(value, target, _):
703 enabled = bool(value)
704 if value.origin == "default":
705 # Enable Windows Media Foundation support by default.
706 # Note our minimum SDK version is Windows 7 SDK, so we are (currently)
707 # guaranteed to have a recent-enough SDK to build WMF.
708 enabled = target.os == "WINNT"
709 if enabled and target.os != "WINNT":
710 die("Cannot enable Windows Media Foundation support on %s", target.os)
715 @depends(artifact_builds, c_compiler, when=wmf)
716 def wmfmediaengine(artifact_builds, c_compiler):
718 return c_compiler.type == "clang-cl"
719 return bool(artifact_builds)
722 set_config("MOZ_WMF", wmf)
723 set_define("MOZ_WMF", wmf)
725 set_config("MOZ_WMF_MEDIA_ENGINE", True, when=wmfmediaengine)
726 set_define("MOZ_WMF_MEDIA_ENGINE", True, when=wmfmediaengine)
728 # FFmpeg H264/AAC Decoding Support
729 # ==============================================================
730 option("--disable-ffmpeg", help="Disable FFmpeg for fragmented H264/AAC decoding")
733 @depends("--disable-ffmpeg", target)
734 def ffmpeg(value, target):
735 enabled = bool(value)
736 if value.origin == "default":
737 enabled = target.os not in ("Android", "WINNT")
742 set_config("MOZ_FFMPEG", ffmpeg)
743 set_define("MOZ_FFMPEG", ffmpeg)
745 # AV1 Video Codec Support
746 # ==============================================================
747 option("--disable-av1", help="Disable av1 video support")
750 @depends("--enable-av1")
756 @depends(target, when=av1 & compile_environment)
757 def dav1d_asm(target):
758 if target.cpu in ("aarch64", "x86", "x86_64"):
762 @depends(target, when=av1 & compile_environment)
763 def dav1d_nasm(target):
764 if target.cpu in ("x86", "x86_64"):
765 return namespace(version="2.14", what="AV1")
768 set_config("MOZ_DAV1D_ASM", dav1d_asm)
769 set_define("MOZ_DAV1D_ASM", dav1d_asm)
770 set_config("MOZ_AV1", av1)
771 set_define("MOZ_AV1", av1)
773 # JXL Image Codec Support
774 # ==============================================================
775 option("--disable-jxl", help="Disable jxl image support")
778 @depends("--disable-jxl", milestone.is_nightly)
779 def jxl(value, is_nightly):
780 if is_nightly and value:
784 set_config("MOZ_JXL", jxl)
785 set_define("MOZ_JXL", jxl)
787 set_config("MOZ_SAMPLE_TYPE_FLOAT32", True)
788 set_define("MOZ_SAMPLE_TYPE_FLOAT32", True)
790 set_define("MOZ_VORBIS", True)
791 set_config("MOZ_VORBIS", True)
794 "--disable-real-time-tracing",
795 help="Disable tracing of real-time audio callbacks",
798 set_config("MOZ_REAL_TIME_TRACING", True, when="--enable-real-time-tracing")
799 set_define("MOZ_REAL_TIME_TRACING", True, when="--enable-real-time-tracing")
801 # OpenMAX IL Decoding Support
802 # ==============================================================
803 option("--enable-openmax", help="Enable OpenMAX IL for video/audio decoding")
806 @depends("--enable-openmax")
808 enabled = bool(value)
813 set_config("MOZ_OMX", openmax)
814 set_define("MOZ_OMX", openmax)
818 # ==============================================================
819 @depends(target, wmf)
820 def eme_choices(target, wmf):
822 target.kernel in ("WINNT", "Linux")
823 and target.os != "Android"
824 and target.cpu in ("x86", "x86_64")
827 return ("widevine", "wmfcdm")
829 if target.kernel == "WINNT" and target.cpu == "aarch64":
831 if target.os in ("OSX"):
835 # Widevine is enabled by default in desktop browser builds.
836 @depends(build_project, eme_choices)
837 def eme_default(build_project, choices):
838 if build_project == "browser":
848 help="{Enable|Disable} support for Encrypted Media Extensions",
852 @depends("--enable-eme", when=eme_choices)
853 def eme_modules(value):
857 # Fallback to an empty list when eme_choices is empty, setting eme_modules to
859 set_config("MOZ_EME_MODULES", eme_modules | dependable([]))
862 # Media Foundation CDM support
863 # ==============================================================
864 @depends(eme_modules, when=wmfmediaengine)
866 if "wmfcdm" in modules:
870 set_config("MOZ_WMF_CDM", True, when=wmfcdm)
871 set_define("MOZ_WMF_CDM", True, when=wmfcdm)
875 name="--enable-chrome-format",
876 help="Select FORMAT of chrome files during packaging.",
878 choices=("omni", "jar", "flat"),
883 @depends("--enable-chrome-format")
884 def packager_format(value):
888 set_config("MOZ_PACKAGER_FORMAT", packager_format)
890 # The packager minifies two different types of files: non-JS (mostly property
891 # files for l10n), and JS. Setting MOZ_PACKAGER_MINIFY only minifies the
892 # former. Firefox doesn't yet minify JS, due to concerns about debuggability.
894 # Also, the JS minification setup really only works correctly on Android:
895 # we need extra setup to use the newly-built shell for Linux and Windows,
896 # and cross-compilation for macOS requires some extra care.
899 @depends(target_is_android, "--enable-debug", milestone.is_nightly)
900 def enable_minify_default(is_android, debug, is_nightly):
901 if is_android and not debug and not is_nightly:
902 return ("properties", "js")
903 return ("properties",)
907 name="--enable-minify",
908 help="Select types of files to minify during packaging.",
910 choices=("properties", "js"),
911 default=enable_minify_default,
915 @depends("--enable-minify")
916 def enable_minify(value):
917 if "js" in value and "properties" not in value:
918 die("--enable-minify=js requires --enable-minify=properties.")
920 properties="properties" in value,
925 set_config("MOZ_PACKAGER_MINIFY", True, when=enable_minify.properties)
926 set_config("MOZ_PACKAGER_MINIFY_JS", True, when=enable_minify.js)
929 @depends(host, build_project)
930 def jar_maker_format(host, build_project):
931 # Multilocales for mobile/android use the same mergedirs for all locales,
932 # so we can't use symlinks for those builds.
933 if host.os == "WINNT" or build_project == "mobile/android":
938 set_config("MOZ_JAR_MAKER_FILE_FORMAT", jar_maker_format)
942 def omnijar_name(toolkit):
943 # Fennec's static resources live in the assets/ folder of the
944 # APK. Adding a path to the name here works because we only
945 # have one omnijar file in the final package (which is not the
947 return "assets/omni.ja" if toolkit == "android" else "omni.ja"
950 set_config("OMNIJAR_NAME", omnijar_name)
952 project_flag("MOZ_PLACES", help="Build Places if required", set_as_define=True)
955 "MOZ_SERVICES_HEALTHREPORT",
956 help="Build Firefox Health Reporter Service",
962 help="Enable Normandy recipe runner",
966 project_flag("MOZ_SERVICES_SYNC", help="Build Sync Services if required")
969 "MOZ_ANDROID_HISTORY",
970 help="Enable Android History instead of Places",
975 "MOZ_DEDICATED_PROFILES",
976 help="Enable dedicated profiles per install",
981 "MOZ_BLOCK_PROFILE_DOWNGRADE",
982 help="Block users from starting profiles last used by a newer build",
987 @depends("MOZ_PLACES", "MOZ_ANDROID_HISTORY")
988 def check_places_and_android_history(places, android_history):
989 if places and android_history:
990 die("Cannot use MOZ_ANDROID_HISTORY alongside MOZ_PLACES.")
991 if not places and not android_history:
992 die("One of MOZ_ANDROID_HISTORY or MOZ_PLACES must be set.")
996 env="MOZ_TELEMETRY_REPORTING",
997 default=mozilla_official,
998 help="Enable telemetry reporting",
1001 set_define("MOZ_TELEMETRY_REPORTING", True, when="MOZ_TELEMETRY_REPORTING")
1004 @depends("MOZ_TELEMETRY_REPORTING", milestone.is_nightly)
1005 def telemetry_on_by_default(reporting, is_nightly):
1006 return reporting and is_nightly
1009 set_define("MOZ_TELEMETRY_ON_BY_DEFAULT", True, when=telemetry_on_by_default)
1013 # ==============================================================
1014 system_lib_option("--enable-gpsd", env="MOZ_GPSD", help="Enable gpsd support")
1017 @depends("--enable-gpsd")
1022 system_gpsd = pkg_check_modules("MOZ_GPSD", "libgps >= 3.11", when=gpsd)
1024 set_config("MOZ_GPSD", depends_if(system_gpsd)(lambda _: True))
1026 # Miscellaneous programs
1027 # ==============================================================
1029 check_prog("TAR", ("gnutar", "gtar", "tar"))
1030 check_prog("UNZIP", ("unzip",))
1033 # ==============================================================
1034 include("../build/moz.configure/keyfiles.configure")
1036 simple_keyfile("Mozilla API")
1038 simple_keyfile("Google Location Service API")
1040 simple_keyfile("Google Safebrowsing API")
1042 id_and_secret_keyfile("Bing API")
1044 simple_keyfile("Adjust SDK")
1046 id_and_secret_keyfile("Leanplum SDK")
1048 simple_keyfile("Pocket API")
1051 # WebRender Debugger integration
1052 # ==============================================================
1055 "--enable-webrender-debugger", help="Build the websocket debug server in WebRender"
1059 "MOZ_WEBRENDER_DEBUGGER", depends_if("--enable-webrender-debugger")(lambda _: True)
1062 # Additional system headers defined at the application level
1063 # ==============================================================
1066 "--enable-app-system-headers",
1067 env="MOZ_APP_SYSTEM_HEADERS",
1068 help="Use additional system headers defined in $MOZ_BUILD_APP/app-system-headers.mozbuild",
1072 @depends("--enable-app-system-headers")
1073 def app_system_headers(value):
1078 set_config("MOZ_APP_SYSTEM_HEADERS", app_system_headers)
1079 set_define("MOZ_APP_SYSTEM_HEADERS", app_system_headers)
1083 # ==============================================================
1085 def printing_default(target):
1086 return target.os != "iOS"
1090 "--disable-printing",
1091 default=printing_default,
1092 help="{Enable|Disable} printing support",
1096 @depends("--disable-printing")
1097 def printing(value):
1102 set_config("NS_PRINTING", printing)
1103 set_define("NS_PRINTING", printing)
1104 set_define("NS_PRINT_PREVIEW", printing)
1107 # Speech-dispatcher support
1108 # ==============================================================
1110 def no_speechd_on_non_gtk(toolkit):
1111 if toolkit != "gtk":
1116 "--enable-synth-speechd", no_speechd_on_non_gtk, reason="--enable-default-toolkit"
1119 option("--disable-synth-speechd", help="Disable speech-dispatcher support")
1121 set_config("MOZ_SYNTH_SPEECHD", depends_if("--disable-synth-speechd")(lambda _: True))
1124 # ==============================================================
1125 option("--disable-webspeech", help="Disable support for HTML Speech API")
1128 @depends("--disable-webspeech")
1129 def webspeech(value):
1134 set_config("MOZ_WEBSPEECH", webspeech)
1135 set_define("MOZ_WEBSPEECH", webspeech)
1137 # Speech API test backend
1138 # ==============================================================
1140 "--enable-webspeechtestbackend",
1142 help="{Enable|Disable} support for HTML Speech API Test Backend",
1146 @depends_if("--enable-webspeechtestbackend")
1147 def webspeech_test_backend(value):
1151 set_config("MOZ_WEBSPEECH_TEST_BACKEND", webspeech_test_backend)
1152 set_define("MOZ_WEBSPEECH_TEST_BACKEND", webspeech_test_backend)
1156 # ==============================================================
1157 @depends(target, milestone)
1158 def skia_pdf_default(target, milestone):
1159 return milestone.is_nightly and target.os != "WINNT"
1162 option("--enable-skia-pdf", default=skia_pdf_default, help="{Enable|Disable} Skia PDF")
1164 set_config("MOZ_ENABLE_SKIA_PDF", True, when="--enable-skia-pdf")
1165 set_define("MOZ_ENABLE_SKIA_PDF", True, when="--enable-skia-pdf")
1176 "--with-system-webp", help="Use system libwebp (located with pkgconfig)"
1179 system_webp = pkg_check_modules(
1180 "MOZ_WEBP", "libwebp >= 1.0.2 libwebpdemux >= 1.0.2", when="--with-system-webp"
1183 set_config("MOZ_SYSTEM_WEBP", depends(when=system_webp)(lambda: True))
1186 # Build Freetype in the tree
1187 # ==============================================================
1188 @depends(target, "--enable-skia-pdf")
1189 def tree_freetype(target, skia_pdf):
1190 if target.os == "Android" or (skia_pdf and target.os == "WINNT"):
1194 set_define("MOZ_TREE_FREETYPE", tree_freetype)
1195 set_config("MOZ_TREE_FREETYPE", tree_freetype)
1197 set_define("HAVE_FT_BITMAP_SIZE_Y_PPEM", tree_freetype)
1198 set_define("HAVE_FT_GLYPHSLOT_EMBOLDEN", tree_freetype)
1199 set_define("HAVE_FT_LOAD_SFNT_TABLE", tree_freetype)
1202 @depends(freetype2_combined_info, tree_freetype, build_environment)
1203 def ft2_info(freetype2_combined_info, tree_freetype, build_env):
1206 cflags=("-I%s/modules/freetype2/include" % build_env.topsrcdir,), libs=()
1208 if freetype2_combined_info:
1209 return freetype2_combined_info
1212 set_config("FT2_LIBS", ft2_info.libs)
1215 @depends(target, tree_freetype, freetype2_info)
1216 def enable_cairo_ft(target, tree_freetype, freetype2_info):
1217 # Avoid defining MOZ_ENABLE_CAIRO_FT on Windows platforms because
1218 # "cairo-ft-font.c" includes <dlfcn.h>, which only exists on posix platforms
1219 return freetype2_info or (tree_freetype and target.os != "WINNT")
1222 set_config("MOZ_ENABLE_CAIRO_FT", True, when=enable_cairo_ft)
1223 set_config("CAIRO_FT_CFLAGS", ft2_info.cflags, when=enable_cairo_ft)
1226 # WebDriver (HTTP / BiDi)
1227 # ==============================================================
1229 # WebDriver is a remote control interface that enables introspection and
1230 # control of user agents. It provides a platform- and language-neutral wire
1231 # protocol as a way for out-of-process programs to remotely instruct the
1232 # behavior of web browsers.
1234 # The Gecko implementation is backed by Marionette and Remote Agent.
1235 # Both protocols are not really toolkit features, as much as Gecko engine
1236 # features. But they are enabled based on the toolkit, so here it lives.
1238 # Marionette remote protocol
1239 # -----------------------------------------------------------
1241 # Marionette is the Gecko remote protocol used for various remote control,
1242 # automation, and testing purposes throughout Gecko-based applications like
1243 # Firefox, Thunderbird, and any mobile browser built upon GeckoView.
1245 # It also backs ../testing/geckodriver, which is Mozilla's WebDriver
1248 # The source of Marionette lives in ../remote/marionette.
1250 # For more information, see:
1251 # https://firefox-source-docs.mozilla.org/testing/marionette/index.html
1253 # Remote Agent (WebDriver BiDi / partial CDP)
1254 # -----------------------------------------------------------
1256 # The primary purpose is the implementation of the WebDriver BiDi specification.
1257 # But it also complements the existing Firefox Developer Tools Remote Debugging
1258 # Protocol (RDP) by implementing a subset of the Chrome DevTools Protocol (CDP).
1260 # The source of Remote Agent lives in ../remote.
1262 # For more information, see:
1263 # https://firefox-source-docs.mozilla.org/remote/index.html
1267 "--disable-webdriver",
1268 help="Disable support for WebDriver remote protocols",
1272 @depends("--disable-webdriver")
1273 def webdriver(enabled):
1278 set_config("ENABLE_WEBDRIVER", webdriver)
1279 set_define("ENABLE_WEBDRIVER", webdriver)
1282 # geckodriver WebDriver implementation
1283 # ==============================================================
1285 # Turn off geckodriver for build configs we don't handle yet,
1286 # but allow --enable-geckodriver to override when compile environment is available.
1287 # --disable-tests implies disabling geckodriver.
1288 # Disable building in CI
1292 "--enable-tests", target, cross_compiling, hazard_analysis, asan, "MOZ_AUTOMATION"
1294 def geckodriver_default(enable_tests, target, cross_compile, hazard, asan, automation):
1295 if not enable_tests:
1297 if hazard or target.os == "Android" or (asan and cross_compile):
1305 "--enable-geckodriver",
1306 default=geckodriver_default,
1307 when="--enable-compile-environment",
1308 help="{Build|Do not build} geckodriver",
1312 @depends("--enable-geckodriver", when="--enable-compile-environment")
1313 def geckodriver(enabled):
1318 set_config("MOZ_GECKODRIVER", geckodriver)
1322 # ========================================================
1324 def webrtc_default(target):
1325 # Turn off webrtc for OS's we don't handle yet, but allow
1326 # --enable-webrtc to override.
1327 os_match = target.kernel in (
1338 os_match = target.os in ("OSX",)
1340 cpu_match = target.cpu in (
1353 return os_match and cpu_match and target.endianness == "little"
1358 default=webrtc_default,
1359 help="{Enable|Disable} support for WebRTC",
1363 @depends("--disable-webrtc")
1364 def webrtc(enabled):
1369 set_config("MOZ_WEBRTC", webrtc)
1370 set_define("MOZ_WEBRTC", webrtc)
1371 set_config("MOZ_SCTP", webrtc)
1372 set_define("MOZ_SCTP", webrtc)
1373 set_config("MOZ_SRTP", webrtc)
1374 set_define("MOZ_SRTP", webrtc)
1375 set_config("MOZ_WEBRTC_SIGNALING", webrtc)
1376 set_define("MOZ_WEBRTC_SIGNALING", webrtc)
1377 set_config("MOZ_PEERCONNECTION", webrtc)
1378 set_define("MOZ_PEERCONNECTION", webrtc)
1379 # MOZ_WEBRTC_ASSERT_ALWAYS turns on a number of safety asserts in
1380 # opt/production builds (via MOZ_CRASH())
1381 set_config("MOZ_WEBRTC_ASSERT_ALWAYS", webrtc)
1382 set_define("MOZ_WEBRTC_ASSERT_ALWAYS", webrtc)
1385 # ==============================================================
1388 @depends(target, webrtc)
1389 def raw_media_default(target, webrtc):
1390 if target.os == "Android":
1398 default=raw_media_default,
1399 help="{Enable|Disable} support for RAW media",
1402 set_config("MOZ_RAW", depends_if("--enable-raw")(lambda _: True))
1403 set_define("MOZ_RAW", depends_if("--enable-raw")(lambda _: True))
1407 # ==============================================================
1408 @depends(webrtc, when=toolkit_gtk)
1409 def x11_libs(webrtc):
1419 # third_party/libwebrtc/webrtc/webrtc_gn/moz.build adds those
1420 # manually, ensure they're available.
1431 x11_headers = pkg_check_modules(
1434 allow_missing=toolkit_gtk_x11_optional,
1435 when=toolkit_gtk_x11,
1439 set_config("MOZ_X11", True, when=x11_headers)
1440 set_define("MOZ_X11", True, when=x11_headers)
1446 allow_missing=toolkit_gtk_x11_optional,
1447 when=toolkit_gtk_x11,
1451 # ASan Reporter Addon
1452 # ==============================================================
1454 "--enable-address-sanitizer-reporter",
1455 help="Enable Address Sanitizer Reporter Extension",
1459 @depends("--enable-address-sanitizer-reporter")
1460 def enable_asan_reporter(value):
1465 set_config("MOZ_ASAN_REPORTER", enable_asan_reporter)
1466 set_define("MOZ_ASAN_REPORTER", enable_asan_reporter)
1468 # Checks for library functions
1469 # ==============================================================
1470 with only_when(compile_environment & depends(target.os)(lambda os: os != "WINNT")):
1471 set_define("HAVE_STAT64", check_symbol("stat64"))
1472 set_define("HAVE_LSTAT64", check_symbol("lstat64"))
1473 set_define("HAVE_TRUNCATE64", check_symbol("truncate64"))
1474 set_define("HAVE_STATVFS64", check_symbol("statvfs64"))
1475 set_define("HAVE_STATVFS", check_symbol("statvfs"))
1476 set_define("HAVE_STATFS64", check_symbol("statfs64"))
1477 set_define("HAVE_STATFS", check_symbol("statfs"))
1478 set_define("HAVE_LUTIMES", check_symbol("lutimes"))
1479 set_define("HAVE_POSIX_FADVISE", check_symbol("posix_fadvise"))
1480 set_define("HAVE_POSIX_FALLOCATE", check_symbol("posix_fallocate"))
1481 set_define("HAVE_EVENTFD", check_symbol("eventfd"))
1483 have_arc4random = check_symbol("arc4random")
1484 set_define("HAVE_ARC4RANDOM", have_arc4random)
1485 set_define("HAVE_ARC4RANDOM_BUF", check_symbol("arc4random_buf"))
1486 set_define("HAVE_MALLINFO", check_symbol("mallinfo"))
1488 # Checks for headers
1489 # ==============================================================
1490 with only_when(compile_environment & depends(target.os)(lambda os: os != "WINNT")):
1491 set_define("HAVE_SYSIOCCOM_H", check_header("sys/ioccom.h"))
1494 # ==============================================================
1495 with only_when("--enable-compile-environment"):
1497 @depends(host, target)
1498 def has_elfhack(host, target):
1500 target.kernel == "Linux"
1501 and host.kernel == "Linux"
1502 and target.cpu in ("arm", "aarch64", "x86", "x86_64")
1506 "--disable-elf-hack",
1508 choices=("legacy", "relr"),
1509 help="{Enable|Disable} elf hacks",
1513 @depends("--enable-elf-hack", when=has_elfhack)
1514 def may_enable_legacy_elfhack(enable):
1515 if enable and enable != ("relr",):
1518 @depends("--enable-elf-hack", when=has_elfhack)
1519 def may_enable_relrhack(enable):
1520 if enable and enable != ("legacy",):
1526 when=target_has_linux_kernel,
1528 def may_use_pack_relative_relocs(have_arc4random, android_version):
1529 # Packed relative relocations are only supported on Android since
1530 # version 11 (API 30), and in glibc since version 2.36.
1531 # glibc 2.36 also added the arc4random function, which is our proxy
1532 # to detect this (or newer) version being used.
1533 # When targetting those newer versions, we allow ourselves to use
1534 # packed relative relocations rather than elfhack.
1536 return android_version >= 30
1537 return have_arc4random
1541 extra_toolchain_flags,
1544 when=may_use_pack_relative_relocs | may_enable_relrhack,
1546 @checking("for -z pack-relative-relocs option to ld", bool)
1547 @imports(_from="__builtin__", _import="FileNotFoundError")
1549 @imports(_from="tempfile", _import="mkstemp")
1550 @imports("textwrap")
1551 def has_pack_relative_relocs(
1553 extra_toolchain_flags,
1558 fd, path = mkstemp(prefix="conftest.")
1561 pack_rel_relocs = ["-Wl,-z,pack-relative-relocs"]
1563 try_invoke_compiler(
1564 # No configure_cache because it would not create the
1565 # expected output file.
1567 [c_compiler.compiler] + c_compiler.flags,
1568 c_compiler.language,
1569 # The resulting binary is expected to have relative
1570 # relocations, the `ptr` variable attempts to ensure
1571 # there is at least one. This requires the executable
1572 # being built as position independent.
1573 "int main() { return 0; }\nint (*ptr)() = main;",
1575 + ["-pie", "-o", path]
1576 + (extra_toolchain_flags or [])
1578 wrapper=c_compiler.wrapper,
1579 onerror=lambda: None,
1583 # BFD ld ignores options it doesn't understand. So check
1584 # that we did get packed relative relocations (DT_RELR).
1585 env = os.environ.copy()
1587 dyn = check_cmd_output(readelf, "-d", path, env=env).splitlines()
1589 int(l.split()[0], 16) for l in dyn if l.strip().startswith("0x")
1591 # Older versions of readelf don't know about DT_RELR but will
1592 # still display the tag number.
1594 needed = [l for l in dyn if l.split()[1:2] == ["(NEEDED)"]]
1595 is_glibc = any(l.endswith("[libc.so.6]") for l in needed)
1596 # The mold linker doesn't add a GLIBC_ABI_DT_RELR version
1597 # dependency, which ld.so doesn't like.
1598 # https://github.com/rui314/mold/issues/653#issuecomment-1670274638
1600 versions = check_cmd_output(readelf, "-V", path, env=env)
1601 if "GLIBC_ABI_DT_RELR" in versions.split():
1602 return pack_rel_relocs
1604 return pack_rel_relocs
1608 except FileNotFoundError:
1612 has_pack_relative_relocs,
1613 may_enable_legacy_elfhack,
1614 may_enable_relrhack,
1615 may_use_pack_relative_relocs,
1616 when=has_pack_relative_relocs,
1618 def pack_relative_relocs_flags(
1620 may_enable_legacy_elfhack,
1621 may_enable_relrhack,
1622 may_use_pack_relative_relocs,
1624 # When relrhack is enabled, we don't pass the flag to the linker because
1625 # relrhack will take care of it.
1626 if may_enable_relrhack and may_enable_relrhack.origin != "default":
1628 # if elfhack is explicitly enabled instead of relrhack, we prioritize it
1629 # over packed relative relocs.
1630 if may_enable_legacy_elfhack and may_enable_legacy_elfhack.origin != "default":
1632 if may_use_pack_relative_relocs:
1635 add_old_configure_assignment("PACK_REL_RELOC_FLAGS", pack_relative_relocs_flags)
1639 pack_relative_relocs_flags,
1640 has_pack_relative_relocs,
1641 may_enable_legacy_elfhack,
1642 may_enable_relrhack,
1647 pack_relative_relocs_flags,
1648 has_pack_relative_relocs,
1649 may_enable_legacy_elfhack,
1650 may_enable_relrhack,
1652 if pack_relative_relocs_flags:
1654 if may_enable_relrhack:
1655 if has_pack_relative_relocs:
1658 may_enable_relrhack.origin != "default"
1659 and not may_enable_legacy_elfhack
1662 "Cannot enable relrhack without linker support for -z pack-relative-relocs"
1664 if may_enable_legacy_elfhack:
1665 if linker and linker.KIND in ("lld", "mold"):
1666 if may_enable_legacy_elfhack.origin != "default":
1668 f"Cannot enable elfhack with {linker.KIND}."
1669 " Use --enable-linker=bfd, --enable-linker=gold, or --disable-elf-hack"
1675 "USE_ELF_HACK", True, when=depends(which_elf_hack)(lambda x: x == "legacy")
1678 use_relrhack = depends(which_elf_hack)(lambda x: x == "relr")
1679 set_config("RELRHACK", True, when=use_relrhack)
1681 @depends(c_compiler, linker_ldflags, when=use_relrhack)
1682 def relrhack_real_linker(c_compiler, linker_ldflags):
1684 for flag in linker_ldflags:
1685 if flag.startswith("-fuse-ld="):
1686 ld = "ld." + flag[len("-fuse-ld=") :]
1687 ld = check_cmd_output(
1688 c_compiler.compiler, f"--print-prog-name={ld}", *c_compiler.flags
1692 @depends(relrhack_real_linker, when=use_relrhack)
1693 def relrhack_linker(ld):
1694 return os.path.basename(ld)
1696 set_config("RELRHACK_LINKER", relrhack_linker)
1698 std_filesystem = host_cxx_compiler.try_run(
1699 header="#include <filesystem>",
1700 body='auto foo = std::filesystem::absolute("");',
1701 flags=host_linker_ldflags,
1703 onerror=lambda: None,
1706 stdcxxfs = host_cxx_compiler.try_run(
1707 header="#include <filesystem>",
1708 body='auto foo = std::filesystem::absolute("");',
1709 flags=depends(host_linker_ldflags)(
1710 lambda flags: (flags or []) + ["-lstdc++fs"]
1712 check_msg="whether std::filesystem requires -lstdc++fs",
1713 when=use_relrhack & depends(std_filesystem)(lambda x: not x),
1714 onerror=lambda: None,
1717 set_config("RELRHACK_LIBS", ["stdc++fs"], when=stdcxxfs)
1719 @depends(build_environment, relrhack_real_linker, when=use_relrhack)
1720 def relrhack_ldflags(build_env, ld):
1723 os.path.join(build_env.topobjdir, "build", "unix", "elfhack"),
1725 if os.path.basename(ld) != ld:
1726 flags.append(f"-Wl,--real-linker,{ld}")
1729 set_config("RELRHACK_LDFLAGS", relrhack_ldflags)
1732 @depends(build_environment)
1733 def idl_roots(build_env):
1735 ipdl_root=os.path.join(build_env.topobjdir, "ipc", "ipdl"),
1736 webidl_root=os.path.join(build_env.topobjdir, "dom", "bindings"),
1737 xpcom_root=os.path.join(build_env.topobjdir, "xpcom", "components"),
1741 set_config("WEBIDL_ROOT", idl_roots.webidl_root)
1742 set_config("IPDL_ROOT", idl_roots.ipdl_root)
1743 set_config("XPCOM_ROOT", idl_roots.xpcom_root)
1745 # Proxy bypass protection
1746 # ==============================================================
1749 "--enable-proxy-bypass-protection",
1750 help="Prevent suspected or confirmed proxy bypasses",
1754 @depends_if("--enable-proxy-bypass-protection")
1755 def proxy_bypass_protection(_):
1759 set_config("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1760 set_define("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1762 # Proxy direct failover
1763 # ==============================================================
1766 "--disable-proxy-direct-failover",
1767 help="Disable direct failover for system requests",
1771 @depends_if("--disable-proxy-direct-failover")
1772 def proxy_direct_failover(value):
1777 set_config("MOZ_PROXY_DIRECT_FAILOVER", proxy_direct_failover)
1778 set_define("MOZ_PROXY_DIRECT_FAILOVER", proxy_direct_failover)
1781 # ==============================================================
1784 @depends(c_compiler, toolchain_prefix)
1785 def midl_names(c_compiler, toolchain_prefix):
1786 if c_compiler and c_compiler.type in ["gcc", "clang"]:
1789 if toolchain_prefix:
1790 prefixed = tuple("%s%s" % (p, "widl") for p in toolchain_prefix)
1791 widl = prefixed + widl
1794 return ("midl.exe",)
1797 @depends(target, "--enable-compile-environment")
1798 def check_for_midl(target, compile_environment):
1799 if target.os != "WINNT":
1802 if compile_environment:
1809 when=check_for_midl,
1812 # MIDL being used from a python wrapper script, we can live with it
1817 option(env="MIDL_FLAGS", nargs=1, help="Extra flags to pass to MIDL")
1824 when=depends(midl, target)(lambda m, t: m and t.kernel == "WINNT"),
1826 def midl_flags(flags, target, midl):
1828 flags = flags[0].split()
1832 if not midl.endswith("widl"):
1838 return flags + ["-nologo", "-no_cpp", "-env", env]
1844 "x86": ["--win32", "-m32"],
1845 "x86_64": ["--win64", "-m64"],
1850 set_config("MIDL_FLAGS", midl_flags)
1853 # ==============================================================
1855 option("--disable-accessibility", help="Disable accessibility support")
1858 @depends("--enable-accessibility", check_for_midl, midl, c_compiler)
1859 def accessibility(value, check_for_midl, midl, c_compiler):
1860 enabled = bool(value)
1865 if check_for_midl and not midl:
1866 if c_compiler and c_compiler.type in ("gcc", "clang"):
1868 "You have accessibility enabled, but widl could not be found. "
1869 "Add --disable-accessibility to your mozconfig or install widl. "
1870 "See https://developer.mozilla.org/en-US/docs/Cross_Compile_Mozilla_for_Mingw32 for details."
1874 "MIDL could not be found. "
1875 "Building accessibility without MIDL is not supported."
1881 set_config("ACCESSIBILITY", accessibility)
1882 set_define("ACCESSIBILITY", accessibility)
1885 @depends(moz_debug, developer_options)
1886 def a11y_log(debug, developer_options):
1887 return debug or developer_options
1890 set_config("A11Y_LOG", True, when=a11y_log)
1891 set_define("A11Y_LOG", True, when=a11y_log)
1895 # ==============================================================
1897 def require_signing(milestone):
1898 return milestone.is_release_or_beta and not milestone.is_esr
1902 env="MOZ_REQUIRE_SIGNING",
1903 default=require_signing,
1904 help="Enforce that add-ons are signed by the trusted root",
1907 set_config("MOZ_REQUIRE_SIGNING", True, when="MOZ_REQUIRE_SIGNING")
1908 set_define("MOZ_REQUIRE_SIGNING", True, when="MOZ_REQUIRE_SIGNING")
1911 "--with-unsigned-addon-scopes",
1913 choices=("app", "system"),
1914 help="Addon scopes where signature is not required",
1918 @depends("--with-unsigned-addon-scopes")
1919 def unsigned_addon_scopes(scopes):
1921 app="app" in scopes or None,
1922 system="system" in scopes or None,
1926 set_config("MOZ_UNSIGNED_APP_SCOPE", unsigned_addon_scopes.app)
1927 set_config("MOZ_UNSIGNED_SYSTEM_SCOPE", unsigned_addon_scopes.system)
1931 # ==============================================================
1933 "--allow-addon-sideload",
1934 default=milestone.is_esr,
1935 help="Addon sideloading is allowed",
1939 set_config("MOZ_ALLOW_ADDON_SIDELOAD", True, when="--allow-addon-sideload")
1941 # WebExtensions API WebIDL bindings
1942 # ==============================================================
1946 def extensions_webidl_bindings_default(milestone):
1947 # Only enable the webidl bindings for the WebExtensions APIs
1949 return milestone.is_nightly
1953 "--enable-extensions-webidl-bindings",
1954 default=extensions_webidl_bindings_default,
1955 help="{Enable|Disable} building experimental WebExtensions WebIDL bindings",
1959 @depends("--enable-extensions-webidl-bindings")
1960 def extensions_webidl_enabled(value):
1964 set_config("MOZ_WEBEXT_WEBIDL_ENABLED", extensions_webidl_enabled)
1966 # Launcher process (Windows only)
1967 # ==============================================================
1971 def launcher_process_default(target):
1972 return target.os == "WINNT"
1976 "--enable-launcher-process",
1977 default=launcher_process_default,
1978 help="{Enable|Disable} launcher process by default",
1982 @depends("--enable-launcher-process", target)
1983 def launcher(value, target):
1984 enabled = bool(value)
1985 if enabled and target.os != "WINNT":
1986 die("Cannot enable launcher process on %s", target.os)
1991 set_config("MOZ_LAUNCHER_PROCESS", launcher)
1992 set_define("MOZ_LAUNCHER_PROCESS", launcher)
1994 # llvm-dlltool (Windows only)
1995 # ==============================================================
1998 @depends(build_project, target, "--enable-compile-environment")
1999 def check_for_llvm_dlltool(build_project, target, compile_environment):
2000 if build_project != "browser":
2003 if target.os != "WINNT":
2006 return compile_environment
2009 llvm_dlltool = check_prog(
2012 what="llvm-dlltool",
2013 when=check_for_llvm_dlltool,
2014 paths=clang_search_path,
2018 @depends(target, when=llvm_dlltool)
2019 def llvm_dlltool_flags(target):
2022 "x86_64": "i386:x86-64",
2029 set_config("LLVM_DLLTOOL_FLAGS", llvm_dlltool_flags)
2031 # BITS download (Windows only)
2032 # ==============================================================
2035 "--enable-bits-download",
2036 when=target_is_windows,
2037 default=target_is_windows,
2038 help="{Enable|Disable} building BITS download support",
2042 "MOZ_BITS_DOWNLOAD",
2043 depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
2046 "MOZ_BITS_DOWNLOAD",
2047 depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
2050 # Bundled fonts on desktop platform
2051 # ==============================================================
2055 def bundled_fonts_default(target):
2056 return target.os == "WINNT" or target.kernel == "Linux"
2059 @depends(build_project)
2060 def allow_bundled_fonts(project):
2061 return project == "browser" or project == "comm/mail"
2065 "--enable-bundled-fonts",
2066 default=bundled_fonts_default,
2067 when=allow_bundled_fonts,
2068 help="{Enable|Disable} support for bundled fonts on desktop platforms",
2072 "MOZ_BUNDLED_FONTS",
2073 depends_if("--enable-bundled-fonts", when=allow_bundled_fonts)(lambda _: True),
2077 # ==============================================================
2081 def reflow_perf(debug):
2087 "--enable-reflow-perf",
2088 default=reflow_perf,
2089 help="{Enable|Disable} reflow performance tracing",
2092 # The difference in conditions here comes from the initial implementation
2093 # in old-configure, which was unexplained there as well.
2094 set_define("MOZ_REFLOW_PERF", depends_if("--enable-reflow-perf")(lambda _: True))
2095 set_define("MOZ_REFLOW_PERF_DSP", reflow_perf)
2098 # ==============================================================
2102 def layout_debugger(debug):
2108 "--enable-layout-debugger",
2109 default=layout_debugger,
2110 help="{Enable|Disable} layout debugger",
2113 set_config("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
2114 set_define("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
2117 # Shader Compiler for Windows (and MinGW Cross Compile)
2118 # ==============================================================
2120 with only_when(compile_environment):
2123 ("fxc.exe", "fxc2.exe"),
2124 when=depends(target)(lambda t: t.kernel == "WINNT"),
2126 # FXC being used from a python wrapper script, we can live with it
2135 with only_when(compile_environment):
2137 "--with-system-libvpx", help="Use system libvpx (located with pkgconfig)"
2140 with only_when("--with-system-libvpx"):
2141 vpx = pkg_check_modules("MOZ_LIBVPX", "vpx >= 1.10.0")
2144 "vpx/vpx_decoder.h",
2146 onerror=lambda: die(
2147 "Couldn't find vpx/vpx_decoder.h, which is required to build "
2148 "with system libvpx. Use --without-system-libvpx to build "
2149 "with in-tree libvpx."
2154 "vpx_codec_dec_init_ver",
2156 onerror=lambda: die(
2157 "--with-system-libvpx requested but symbol vpx_codec_dec_init_ver "
2162 set_config("MOZ_SYSTEM_LIBVPX", True)
2164 @depends("--with-system-libvpx", target)
2165 def in_tree_vpx(system_libvpx, target):
2169 arm_asm = (target.cpu == "arm") or None
2170 return namespace(arm_asm=arm_asm)
2172 @depends(target, when=in_tree_vpx)
2173 def vpx_nasm(target):
2174 if target.cpu in ("x86", "x86_64"):
2175 if target.kernel == "WINNT":
2176 # Version 2.03 is needed for automatic safeseh support.
2177 return namespace(version="2.03", what="VPX")
2178 return namespace(what="VPX")
2180 @depends(in_tree_vpx, vpx_nasm, target, neon_flags)
2181 def vpx_as_flags(vpx, vpx_nasm, target, neon_flags):
2182 if vpx and vpx.arm_asm:
2183 # These flags are a lie; they're just used to enable the requisite
2184 # opcodes; actual arch detection is done at runtime.
2186 elif vpx and vpx_nasm and target.os != "WINNT" and target.cpu != "x86_64":
2189 set_config("VPX_USE_NASM", True, when=vpx_nasm)
2190 set_config("VPX_ASFLAGS", vpx_as_flags)
2196 with only_when(compile_environment):
2198 "--with-system-jpeg",
2200 help="Use system libjpeg (installed at given prefix)",
2203 @depends_if("--with-system-jpeg")
2204 def jpeg_flags(value):
2207 cflags=("-I%s/include" % value[0],),
2208 ldflags=("-L%s/lib" % value[0], "-ljpeg"),
2211 ldflags=("-ljpeg",),
2214 with only_when("--with-system-jpeg"):
2216 "jpeg_destroy_compress",
2217 flags=jpeg_flags.ldflags,
2218 onerror=lambda: die(
2219 "--with-system-jpeg requested but symbol "
2220 "jpeg_destroy_compress not found."
2224 c_compiler.try_compile(
2231 #if JPEG_LIB_VERSION < 62
2232 #error Insufficient JPEG library version
2235 flags=jpeg_flags.cflags,
2236 check_msg="for sufficient jpeg library version",
2237 onerror=lambda: die(
2238 "Insufficient JPEG library version for "
2239 "--with-system-jpeg (62 required)"
2243 c_compiler.try_compile(
2250 #ifndef JCS_EXTENSIONS
2251 #error libjpeg-turbo JCS_EXTENSIONS required
2254 flags=jpeg_flags.cflags,
2255 check_msg="for sufficient libjpeg-turbo JCS_EXTENSIONS",
2256 onerror=lambda: die(
2257 "libjpeg-turbo JCS_EXTENSIONS required for " "--with-system-jpeg"
2261 set_config("MOZ_JPEG_CFLAGS", jpeg_flags.cflags)
2262 set_config("MOZ_JPEG_LIBS", jpeg_flags.ldflags)
2264 @depends("--with-system-jpeg", target, neon_flags)
2265 def in_tree_jpeg_arm(system_jpeg, target, neon_flags):
2269 if target.cpu == "arm":
2271 elif target.cpu == "aarch64":
2272 return ("-march=armv8-a",)
2274 @depends("--with-system-jpeg", target)
2275 def in_tree_jpeg_mips64(system_jpeg, target):
2279 if target.cpu == "mips64":
2280 return ("-Wa,-mloongson-mmi", "-mloongson-ext")
2282 # Compiler check from https://github.com/libjpeg-turbo/libjpeg-turbo/blob/57ba02a408a9a55ccff25aae8b164632a3a4f177/simd/CMakeLists.txt#L419
2283 jpeg_mips64_mmi = c_compiler.try_compile(
2284 body='int c = 0, a = 0, b = 0; asm("paddb %0, %1, %2" : "=f" (c) : "f" (a), "f" (b));',
2285 check_msg="for loongson mmi support",
2286 flags=in_tree_jpeg_mips64,
2287 when=in_tree_jpeg_mips64,
2291 "--with-system-jpeg",
2294 in_tree_jpeg_mips64,
2298 system_jpeg, target, in_tree_jpeg_arm, in_tree_jpeg_mips64, jpeg_mips64_mmi
2303 if target.cpu in ("arm", "aarch64"):
2304 return in_tree_jpeg_arm
2305 elif target.kernel == "Darwin":
2306 if target.cpu == "x86":
2307 return ("-DPIC", "-DMACHO")
2308 elif target.cpu == "x86_64":
2309 return ("-D__x86_64__", "-DPIC", "-DMACHO")
2310 elif target.kernel == "WINNT":
2311 if target.cpu == "x86":
2312 return ("-DPIC", "-DWIN32")
2313 elif target.cpu == "x86_64":
2314 return ("-D__x86_64__", "-DPIC", "-DWIN64", "-DMSVC")
2315 elif target.cpu == "mips32":
2317 elif target.cpu == "mips64" and jpeg_mips64_mmi:
2318 return in_tree_jpeg_mips64
2319 elif target.cpu == "x86":
2320 return ("-DPIC", "-DELF")
2321 elif target.cpu == "x86_64":
2322 return ("-D__x86_64__", "-DPIC", "-DELF")
2324 @depends(target, when=depends("--with-system-jpeg")(lambda x: not x))
2325 def jpeg_nasm(target):
2326 if target.cpu in ("x86", "x86_64"):
2327 # libjpeg-turbo 2.0.6 requires nasm 2.10.
2328 return namespace(version="2.10", what="JPEG")
2330 # Compiler checks from https://github.com/libjpeg-turbo/libjpeg-turbo/blob/57ba02a408a9a55ccff25aae8b164632a3a4f177/simd/CMakeLists.txt#L258
2331 jpeg_arm_neon_vld1_s16_x3 = c_compiler.try_compile(
2332 includes=["arm_neon.h"],
2333 body="int16_t input[12] = {}; int16x4x3_t output = vld1_s16_x3(input);",
2334 check_msg="for vld1_s16_x3 in arm_neon.h",
2335 flags=in_tree_jpeg_arm,
2336 when=in_tree_jpeg_arm,
2339 jpeg_arm_neon_vld1_u16_x2 = c_compiler.try_compile(
2340 includes=["arm_neon.h"],
2341 body="uint16_t input[8] = {}; uint16x4x2_t output = vld1_u16_x2(input);",
2342 check_msg="for vld1_u16_x2 in arm_neon.h",
2343 flags=in_tree_jpeg_arm,
2344 when=in_tree_jpeg_arm,
2347 jpeg_arm_neon_vld1q_u8_x4 = c_compiler.try_compile(
2348 includes=["arm_neon.h"],
2349 body="uint8_t input[64] = {}; uint8x16x4_t output = vld1q_u8_x4(input);",
2350 check_msg="for vld1q_u8_x4 in arm_neon.h",
2351 flags=in_tree_jpeg_arm,
2352 when=in_tree_jpeg_arm,
2355 set_config("LIBJPEG_TURBO_USE_NASM", True, when=jpeg_nasm)
2356 set_config("LIBJPEG_TURBO_SIMD_FLAGS", in_tree_jpeg)
2357 set_config("LIBJPEG_TURBO_HAVE_VLD1_S16_X3", jpeg_arm_neon_vld1_s16_x3)
2358 set_config("LIBJPEG_TURBO_HAVE_VLD1_U16_X2", jpeg_arm_neon_vld1_u16_x2)
2359 set_config("LIBJPEG_TURBO_HAVE_VLD1Q_U8_X4", jpeg_arm_neon_vld1q_u8_x4)
2361 "LIBJPEG_TURBO_NEON_INTRINSICS",
2362 jpeg_arm_neon_vld1_s16_x3
2363 & jpeg_arm_neon_vld1_u16_x2
2364 & jpeg_arm_neon_vld1q_u8_x4,
2370 with only_when(compile_environment):
2372 "--with-system-png",
2374 help="Use system libpng",
2377 @depends("--with-system-png")
2378 def deprecated_system_png_path(value):
2381 "--with-system-png=PATH is not supported anymore. Please use "
2382 "--with-system-png and set any necessary pkg-config environment variable."
2385 png = pkg_check_modules("MOZ_PNG", "libpng >= 1.6.35", when="--with-system-png")
2390 onerror=lambda: die(
2391 "--with-system-png won't work because the system's libpng doesn't have APNG support"
2393 when="--with-system-png",
2396 set_config("MOZ_SYSTEM_PNG", True, when="--with-system-png")
2399 # FFmpeg's ffvpx configuration
2400 # ==============================================================
2409 # This enables audio and video codecs paths on Windows x86 and x86_64,
2410 # macOS (all arch), and Linux x86_64. On other arch / OS combinations,
2411 # only audio codecs are enabled.
2412 if target.kernel == "WINNT":
2413 if target.cpu == "x86":
2414 # 32-bit windows need to prefix symbols with an underscore.
2415 flags = ["-DPIC", "-DWIN32", "-DPREFIX", "-Pconfig_win32.asm"]
2416 elif target.cpu == "x86_64":
2422 "-Pconfig_win64.asm",
2424 elif target.cpu == "aarch64":
2425 flags = ["-DPIC", "-DWIN64"]
2427 elif target.kernel == "Darwin":
2428 # 32/64-bit macosx assemblers need to prefix symbols with an
2430 flags = ["-DPIC", "-DMACHO", "-DPREFIX"]
2431 if target.cpu == "x86_64":
2434 "-Pconfig_darwin64.asm",
2436 elif target.cpu == "aarch64":
2438 elif target.cpu == "x86_64":
2439 flags = ["-D__x86_64__", "-DPIC", "-DELF", "-Pconfig_unix64.asm"]
2448 audio_only=audio_only,
2453 @depends(when=ffvpx.use_nasm)
2455 # nasm 2.10 for AVX-2 support.
2456 return namespace(version="2.10", what="FFVPX")
2459 # ffvpx_nasm can't indirectly depend on vpx_as_flags, because it depends
2460 # on a compiler test, so we have to do a little bit of dance here.
2461 @depends(ffvpx, vpx_as_flags, target)
2462 def ffvpx(ffvpx, vpx_as_flags, target):
2463 if ffvpx and vpx_as_flags and target.cpu in ("arm", "aarch64"):
2464 ffvpx.flags.extend(vpx_as_flags)
2468 set_config("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.audio_only)
2469 set_define("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.audio_only)
2470 set_config("FFVPX_ASFLAGS", ffvpx.flags)
2471 set_config("FFVPX_USE_NASM", True, when=ffvpx.use_nasm)
2475 # ==============================================================
2476 @depends(dav1d_nasm, vpx_nasm, jpeg_nasm, ffvpx_nasm, when=compile_environment)
2477 def need_nasm(*requirements):
2479 x.what: x.version if hasattr(x, "version") else True for x in requirements if x
2482 items = sorted(requires.keys())
2484 what = " and ".join((", ".join(items[:-1]), items[-1]))
2487 versioned = {k: v for (k, v) in requires.items() if v is not True}
2488 return namespace(what=what, versioned=versioned)
2500 @depends(nasm, need_nasm.what)
2501 def check_nasm(nasm, what):
2502 if not nasm and what:
2503 die("Nasm is required to build with %s, but it was not found." % what)
2507 @depends_if(check_nasm)
2508 @checking("nasm version")
2509 def nasm_version(nasm):
2511 check_cmd_output(nasm, "-v", onerror=lambda: die("Failed to get nasm version."))
2515 return Version(version)
2518 @depends(nasm_version, need_nasm.versioned, when=need_nasm.versioned)
2519 def check_nasm_version(nasm_version, versioned):
2520 by_version = sorted(versioned.items(), key=lambda x: x[1])
2521 what, version = by_version[-1]
2522 if nasm_version < version:
2524 "Nasm version %s or greater is required to build with %s." % (version, what)
2529 @depends(target, when=check_nasm_version)
2530 def nasm_asflags(target):
2532 ("Darwin", "x86"): ["-f", "macho32"],
2533 ("Darwin", "x86_64"): ["-f", "macho64"],
2534 ("WINNT", "x86"): ["-f", "win32"],
2535 ("WINNT", "x86_64"): ["-f", "win64"],
2536 }.get((target.kernel, target.cpu), None)
2538 # We're assuming every x86 platform we support that's
2539 # not Windows or Mac is ELF.
2540 if target.cpu == "x86":
2541 asflags = ["-f", "elf32"]
2542 elif target.cpu == "x86_64":
2543 asflags = ["-f", "elf64"]
2547 set_config("NASM_ASFLAGS", nasm_asflags)
2550 # ANGLE OpenGL->D3D translator for WebGL
2551 # ==============================================================
2553 with only_when(compile_environment & target_is_windows):
2554 set_config("MOZ_ANGLE_RENDERER", True)
2556 # Remoting protocol support
2557 # ==============================================================
2561 def has_remote(toolkit):
2562 if toolkit in ("gtk", "windows", "cocoa"):
2566 set_config("MOZ_HAS_REMOTE", has_remote)
2567 set_define("MOZ_HAS_REMOTE", has_remote)
2569 # RLBox Library Sandboxing wasm support
2570 # ==============================================================
2573 def wasm_sandboxing_libraries():
2584 @depends(dependable(wasm_sandboxing_libraries), build_project)
2585 def default_wasm_sandboxing_libraries(libraries, build_project):
2586 if build_project != "tools/rusttests":
2587 non_default_libs = {}
2589 return tuple(l for l in libraries if l not in non_default_libs)
2593 "--with-wasm-sandboxed-libraries",
2594 env="WASM_SANDBOXED_LIBRARIES",
2595 help="{Enable wasm sandboxing for the selected libraries|Disable wasm sandboxing}",
2597 choices=dependable(wasm_sandboxing_libraries),
2598 default=default_wasm_sandboxing_libraries,
2602 @depends("--with-wasm-sandboxed-libraries")
2603 def requires_wasm_sandboxing(libraries):
2608 set_config("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
2609 set_define("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
2611 with only_when(requires_wasm_sandboxing & compile_environment):
2613 "--with-wasi-sysroot",
2616 help="Path to wasi sysroot for wasm sandboxing",
2619 @depends("--with-wasi-sysroot", requires_wasm_sandboxing)
2620 def bootstrap_wasi_sysroot(wasi_sysroot, requires_wasm_sandboxing):
2621 return requires_wasm_sandboxing and not wasi_sysroot
2624 "--with-wasi-sysroot",
2625 bootstrap_path("sysroot-wasm32-wasi", when=bootstrap_wasi_sysroot),
2628 def wasi_sysroot(wasi_sysroot, bootstrapped_sysroot):
2629 if not wasi_sysroot:
2630 return bootstrapped_sysroot
2632 wasi_sysroot = wasi_sysroot[0]
2633 if not os.path.isdir(wasi_sysroot):
2634 die("Argument to --with-wasi-sysroot must be a directory")
2635 if not os.path.isabs(wasi_sysroot):
2636 die("Argument to --with-wasi-sysroot must be an absolute path")
2640 @depends(wasi_sysroot)
2641 def wasi_sysroot_flags(wasi_sysroot):
2643 log.info("Using wasi sysroot in %s", wasi_sysroot)
2644 return ["--sysroot=%s" % wasi_sysroot]
2647 set_config("WASI_SYSROOT", wasi_sysroot)
2649 def wasm_compiler_with_flags(compiler, sysroot_flags):
2652 compiler.wrapper + [compiler.compiler] + compiler.flags + sysroot_flags
2656 def wasm_compiler_error(msg):
2657 @depends("--with-wasm-sandboxed-libraries")
2658 def wasm_compiler_error(sandboxed_libs):
2659 suggest_disable = ""
2660 if sandboxed_libs.origin == "default":
2661 suggest_disable = " Or build with --without-wasm-sandboxed-libraries."
2662 return lambda: die(msg + suggest_disable)
2664 return wasm_compiler_error
2667 def check_wasm_compiler(compiler, language):
2668 compiler.try_compile(
2669 includes=["cstring" if language == "C++" else "string.h"],
2670 flags=wasi_sysroot_flags,
2671 check_msg="the wasm %s compiler can find wasi headers" % language,
2672 onerror=wasm_compiler_error(
2673 "Cannot find wasi headers or problem with the wasm compiler. "
2674 "Please fix the problem."
2679 flags=wasi_sysroot_flags,
2680 check_msg="the wasm %s linker can find wasi libraries" % language,
2681 onerror=wasm_compiler_error(
2682 "Cannot find wasi libraries or problem with the wasm linker. "
2683 "Please fix the problem."
2687 wasm_cc = compiler("C", wasm, other_compiler=c_compiler)
2688 check_wasm_compiler(wasm_cc, "C")
2690 @depends(wasm_cc, wasi_sysroot_flags)
2691 def wasm_cc_with_flags(wasm_cc, wasi_sysroot_flags):
2692 return wasm_compiler_with_flags(wasm_cc, wasi_sysroot_flags)
2694 set_config("WASM_CC", wasm_cc_with_flags)
2696 wasm_cxx = compiler(
2700 other_compiler=cxx_compiler,
2701 other_c_compiler=c_compiler,
2703 check_wasm_compiler(wasm_cxx, "C++")
2705 @depends(wasm_cxx, wasi_sysroot_flags)
2706 def wasm_cxx_with_flags(wasm_cxx, wasi_sysroot_flags):
2707 return wasm_compiler_with_flags(wasm_cxx, wasi_sysroot_flags)
2709 set_config("WASM_CXX", wasm_cxx_with_flags)
2711 wasm_compile_flags = dependable(["-fno-exceptions", "-fno-strict-aliasing"])
2712 option(env="WASM_CFLAGS", nargs=1, help="Options to pass to WASM_CC")
2714 @depends("WASM_CFLAGS", wasm_compile_flags)
2715 def wasm_cflags(value, wasm_compile_flags):
2717 return wasm_compile_flags + value
2719 return wasm_compile_flags
2721 set_config("WASM_CFLAGS", wasm_cflags)
2723 option(env="WASM_CXXFLAGS", nargs=1, help="Options to pass to WASM_CXX")
2725 @depends("WASM_CXXFLAGS", wasm_compile_flags)
2726 def wasm_cxxflags(value, wasm_compile_flags):
2728 return wasm_compile_flags + value
2730 return wasm_compile_flags
2732 set_config("WASM_CXXFLAGS", wasm_cxxflags)
2735 @depends("--with-wasm-sandboxed-libraries")
2736 def wasm_sandboxing(libraries):
2740 return namespace(**{name: True for name in libraries})
2744 def wasm_sandboxing_config_defines():
2745 for lib in wasm_sandboxing_libraries():
2747 "MOZ_WASM_SANDBOXING_%s" % lib.upper(), getattr(wasm_sandboxing, lib)
2750 "MOZ_WASM_SANDBOXING_%s" % lib.upper(), getattr(wasm_sandboxing, lib)
2754 wasm_sandboxing_config_defines()
2757 with only_when(compile_environment & wasm_sandboxing.hunspell):
2758 clock_in_wasi_sysroot = wasm_cc.try_run(
2759 header="#include <time.h>",
2761 check_msg="for clock() in wasi sysroot",
2762 flags=depends(wasi_sysroot_flags)(
2763 lambda sysroot_flags: ["-Werror"] + sysroot_flags
2767 wasi_emulated_clock = wasm_cc.try_run(
2768 header="#include <time.h>",
2770 check_msg="for emulated clock() in wasi sysroot",
2771 flags=depends(wasi_sysroot_flags)(
2772 lambda sysroot_flags: [
2774 "-D_WASI_EMULATED_PROCESS_CLOCKS",
2775 "-lwasi-emulated-process-clocks",
2779 when=depends(clock_in_wasi_sysroot)(lambda x: not x),
2780 onerror=lambda: die("Can't find clock() in wasi sysroot."),
2783 set_config("MOZ_WASI_EMULATED_CLOCK", True, when=wasi_emulated_clock)
2786 # new Notification Store implementation
2787 # ==============================================================
2791 def new_notification_store(milestone):
2792 if milestone.is_nightly:
2796 set_config("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)
2797 set_define("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)
2800 # Auxiliary files persistence on application close
2801 # ==============================================================
2804 "--enable-disk-remnant-avoidance",
2805 help="Prevent persistence of auxiliary files on application close",
2810 "MOZ_AVOID_DISK_REMNANT_ON_CLOSE",
2812 when="--enable-disk-remnant-avoidance",
2816 # Glean SDK Integration Crate
2817 # ==============================================================
2821 def glean_android(target):
2822 return target.os == "Android"
2825 set_config("MOZ_GLEAN_ANDROID", True, when=glean_android)
2826 set_define("MOZ_GLEAN_ANDROID", True, when=glean_android)
2830 # ==============================================================
2836 bootstrap="dump_syms",
2837 when=compile_environment,
2841 @depends(valid_windows_sdk_dir, host)
2842 @imports(_from="os", _import="environ")
2843 def pdbstr_paths(valid_windows_sdk_dir, host):
2844 if not valid_windows_sdk_dir:
2854 os.path.join(valid_windows_sdk_dir.path, "Debuggers", vc_host, "srcsrv"),
2862 when=compile_environment & target_is_windows,
2868 @depends("MOZ_AUTOMATION", c_compiler)
2869 def allow_missing_winchecksec(automation, c_compiler):
2872 if c_compiler and c_compiler.type != "clang-cl":
2878 ["winchecksec.exe", "winchecksec"],
2879 bootstrap="winchecksec",
2880 allow_missing=allow_missing_winchecksec,
2881 when=compile_environment & target_is_windows,
2886 @depends(target, build_project)
2887 def forkserver_default(target, build_project):
2888 return build_project == "browser" and (
2889 (target.os == "GNU" and target.kernel == "Linux")
2890 or target.os == "FreeBSD"
2891 or target.os == "OpenBSD"
2896 "--enable-forkserver",
2897 default=forkserver_default,
2898 env="MOZ_ENABLE_FORKSERVER",
2899 help="{Enable|Disable} fork server",
2903 @depends("--enable-forkserver", target)
2904 def forkserver_flag(value, target):
2906 target.os == "Android"
2907 or (target.os == "GNU" and target.kernel == "Linux")
2908 or target.os == "FreeBSD"
2909 or target.os == "OpenBSD"
2915 set_config("MOZ_ENABLE_FORKSERVER", forkserver_flag)
2916 set_define("MOZ_ENABLE_FORKSERVER", forkserver_flag, forkserver_flag)
2919 # ==============================================================
2921 with only_when(compile_environment & target_has_linux_kernel):
2922 # Check if we need to use the breakpad_getcontext fallback.
2923 getcontext = check_symbol("getcontext")
2924 set_config("HAVE_GETCONTEXT", getcontext)
2925 set_define("HAVE_GETCONTEXT", getcontext)
2928 # ==============================================================
2929 include("../build/moz.configure/nss.configure")
2932 # Enable or disable running in background task mode: headless for
2933 # periodic, short-lived, maintenance tasks.
2934 # ==============================================================================
2936 "--disable-backgroundtasks",
2937 help="Disable running in background task mode",
2939 set_config("MOZ_BACKGROUNDTASKS", True, when="--enable-backgroundtasks")
2940 set_define("MOZ_BACKGROUNDTASKS", True, when="--enable-backgroundtasks")
2943 # Update-related programs: updater, maintenance service, update agent,
2944 # default browser agent.
2945 # ==============================================================
2946 include("../build/moz.configure/update-programs.configure")
2949 # Mobile optimizations
2950 # ==============================================================
2952 "--enable-mobile-optimize",
2953 default=target_is_android,
2954 help="{Enable|Disable} mobile optimizations",
2957 set_define("MOZ_GFX_OPTIMIZE_MOBILE", True, when="--enable-mobile-optimize")
2958 # We ignore "paint will resample" on mobile for performance.
2959 # We may want to revisit this later.
2960 set_define("MOZ_IGNORE_PAINT_WILL_RESAMPLE", True, when="--enable-mobile-optimize")
2963 # ==============================================================
2964 option("--disable-pref-extensions", help="Disable pref extensions such as autoconfig")
2965 set_config("MOZ_PREF_EXTENSIONS", True, when="--enable-pref-extensions")
2967 # Offer a way to disable the startup cache
2968 # ==============================================================
2969 option("--disable-startupcache", help="Disable startup cache")
2972 @depends("--enable-startupcache")
2973 def enable_startupcache(value):
2979 "MOZ_DISABLE_STARTUPCACHE", True, when=depends(enable_startupcache)(lambda x: not x)
2984 # ==============================================================
2986 env="MOZ_APP_REMOTINGNAME",
2988 help="Used for the internal program name, which affects profile name "
2989 "and remoting. If not set, defaults to MOZ_APP_NAME if the update channel "
2990 "is release, and MOZ_APP_NAME-MOZ_UPDATE_CHANNEL otherwise.",
2994 @depends("MOZ_APP_REMOTINGNAME", moz_app_name, update_channel)
2995 def moz_app_remotingname(value, moz_app_name, update_channel):
2998 if update_channel == "release":
3000 return moz_app_name + "-" + update_channel
3003 set_config("MOZ_APP_REMOTINGNAME", moz_app_remotingname)
3006 env="ANDROID_PACKAGE_NAME",
3008 help="Name of the Android package (default org.mozilla.$MOZ_APP_NAME)",
3012 @depends("ANDROID_PACKAGE_NAME", moz_app_name)
3013 def android_package_name(value, moz_app_name):
3016 if moz_app_name == "fennec":
3017 return "org.mozilla.fennec_aurora"
3018 return "org.mozilla.%s" % moz_app_name
3021 set_config("ANDROID_PACKAGE_NAME", android_package_name)
3024 # Miscellaneous options
3025 # ==============================================================
3026 option(env="MOZ_WINCONSOLE", nargs="?", help="Whether we can create a console window.")
3027 set_define("MOZ_WINCONSOLE", True, when=depends("MOZ_WINCONSOLE")(lambda x: x))
3030 # Alternative Crashreporter setting
3032 "--with-crashreporter-url",
3033 env="MOZ_CRASHREPORTER_URL",
3034 default="https://crash-reports.mozilla.com/",
3036 help="Set an alternative crashreporter url",
3040 "MOZ_CRASHREPORTER_URL",
3041 depends("--with-crashreporter-url")(lambda x: x[0].rstrip("/")),
3045 # Crash reporter options
3046 # ==============================================================
3048 def oxidized_breakpad(target):
3049 if target.kernel == "Linux":
3050 return target.cpu in ("aarch64", "arm", "x86", "x86_64")
3054 set_config("MOZ_OXIDIZED_BREAKPAD", True, when=oxidized_breakpad)
3055 set_define("MOZ_OXIDIZED_BREAKPAD", True, when=oxidized_breakpad)
3059 # ==============================================================
3060 @depends(target, host)
3061 def want_wine(target, host):
3062 return target.kernel == "WINNT" and host.kernel != "WINNT"
3069 bootstrap="wine/bin",
3073 # ==============================================================
3074 # Set this to true so the JS engine knows we're doing a browser build.
3075 set_config("MOZ_DOM_STREAMS", True)
3076 set_define("MOZ_DOM_STREAMS", True)
3079 # ==============================================================
3080 with only_when(compile_environment):
3082 "--with-system-libevent",
3084 help="Use system libevent",
3087 @depends("--with-system-libevent")
3088 def deprecated_system_libevent_path(value):
3091 "--with-system-libevent=PATH is not supported anymore. Please use "
3092 "--with-system-libevent and set any necessary pkg-config environment variable."
3095 pkg_check_modules("MOZ_LIBEVENT", "libevent", when="--with-system-libevent")
3097 set_config("MOZ_SYSTEM_LIBEVENT", True, when="--with-system-libevent")
3101 # ==============================================================
3102 @depends(target, developer_options, artifact_builds)
3103 def crashreporter_default(target, developer_options, artifacts):
3104 if target.os in ("WINNT", "OSX"):
3106 if target.kernel == "Linux" and target.cpu in ("x86", "x86_64", "arm", "aarch64"):
3107 # The crash reporter prevents crash stacktraces to be logged in the
3108 # logs on Android, so we leave it out by default in developer builds.
3109 return target.os != "Android" or not developer_options or artifacts
3113 "--enable-crashreporter",
3114 default=crashreporter_default,
3115 help="{Enable|Disable} crash reporting",
3119 set_config("MOZ_CRASHREPORTER", True, when="--enable-crashreporter")
3120 set_define("MOZ_CRASHREPORTER", True, when="--enable-crashreporter")
3122 with only_when(compile_environment):
3123 with only_when("--enable-crashreporter"):
3127 when=depends(target)(lambda t: t.os == "GNU" and t.kernel == "Linux"),
3131 "MOZ_CRASHREPORTER_INJECTOR",
3133 when=depends(target)(lambda t: t.os == "WINNT" and t.bitness == 32),
3136 "MOZ_CRASHREPORTER_INJECTOR",
3138 when=depends(target)(lambda t: t.os == "WINNT" and t.bitness == 32),
3142 # If we have any service that uploads data (and requires data submission
3143 # policy alert), set MOZ_DATA_REPORTING.
3144 # ==============================================================
3146 "MOZ_TELEMETRY_REPORTING",
3147 "MOZ_SERVICES_HEALTHREPORT",
3148 "--enable-crashreporter",
3151 def data_reporting(telemetry, healthreport, crashreporter, normandy):
3152 return telemetry or healthreport or crashreporter or normandy
3155 set_config("MOZ_DATA_REPORTING", True, when=data_reporting)
3156 set_define("MOZ_DATA_REPORTING", True, when=data_reporting)
3160 # ==============================================================
3161 with only_when(toolkit_gtk):
3164 "gtk+-3.0 >= 3.14.0 gtk+-unix-print-3.0 glib-2.0 gobject-2.0 gio-unix-2.0",
3167 set_define("GDK_VERSION_MIN_REQUIRED", "GDK_VERSION_3_14")
3168 set_define("GDK_VERSION_MAX_ALLOWED", "GDK_VERSION_3_14")
3170 pkg_check_modules("GLIB", "glib-2.0 >= 2.42 gobject-2.0")
3172 set_define("GLIB_VERSION_MIN_REQUIRED", "GLIB_VERSION_2_42")
3173 set_define("GLIB_VERSION_MAX_ALLOWED", "GLIB_VERSION_2_42")
3175 set_define("MOZ_ACCESSIBILITY_ATK", True, when=accessibility)
3178 # ==============================================================
3179 with only_when(toolkit_gtk):
3180 option("--disable-dbus", help="Disable dbus support")
3182 with only_when("--enable-dbus"):
3183 pkg_check_modules("MOZ_DBUS", "dbus-1 >= 0.60")
3185 set_config("MOZ_ENABLE_DBUS", True)
3186 set_define("MOZ_ENABLE_DBUS", True)
3189 # Necko's wifi scanner
3190 # ==============================================================
3192 def necko_wifi_when(target):
3193 return target.os in ("WINNT", "OSX", "DragonFly", "FreeBSD") or (
3194 target.kernel == "Linux" and target.os == "GNU"
3198 option("--disable-necko-wifi", help="Disable necko wifi scanner", when=necko_wifi_when)
3200 set_config("NECKO_WIFI", True, when="--enable-necko-wifi")
3201 set_define("NECKO_WIFI", True, when="--enable-necko-wifi")
3205 depends("--enable-necko-wifi", when=necko_wifi_when)(lambda x: x),
3206 depends("--enable-dbus", when=toolkit_gtk)(lambda x: x),
3207 when=depends(target)(lambda t: t.os == "GNU" and t.kernel == "Linux"),
3209 def necko_wifi_dbus(necko_wifi, dbus):
3210 if necko_wifi and not dbus:
3212 "Necko WiFi scanning needs DBus on your platform, remove --disable-dbus"
3213 " or use --disable-necko-wifi"
3215 return necko_wifi and dbus
3218 set_config("NECKO_WIFI_DBUS", True, when=necko_wifi_dbus)
3219 set_define("NECKO_WIFI_DBUS", True, when=necko_wifi_dbus)
3222 # Frontend JS debug mode
3223 # ==============================================================
3224 option("--enable-debug-js-modules", help="Enable debug mode for frontend JS libraries")
3226 set_config("DEBUG_JS_MODULES", True, when="--enable-debug-js-modules")
3230 # ==============================================================
3231 option("--enable-dump-painting", help="Enable paint debugging")
3234 "MOZ_DUMP_PAINTING",
3236 when=depends("--enable-dump-painting", "--enable-debug")(
3237 lambda painting, debug: painting or debug
3240 set_define("MOZ_LAYERS_HAVE_LOG", True, when="--enable-dump-painting")
3244 # ==============================================================
3245 with only_when(toolkit_gtk):
3246 system_lib_option("--enable-libproxy", help="Enable libproxy support")
3248 with only_when("--enable-libproxy"):
3249 pkg_check_modules("MOZ_LIBPROXY", "libproxy-1.0")
3251 set_config("MOZ_ENABLE_LIBPROXY", True)
3252 set_define("MOZ_ENABLE_LIBPROXY", True)
3255 # Enable runtime logging
3256 # ==============================================================
3257 set_define("MOZ_LOGGING", True)
3258 set_define("FORCE_PR_LOG", True)
3260 # This will enable logging of addref, release, ctor, dtor.
3261 # ==============================================================
3263 "--enable-logrefcnt",
3265 help="{Enable|Disable} logging of refcounts",
3268 set_define("NS_BUILD_REFCNT_LOGGING", True, when="--enable-logrefcnt")
3272 # ==============================================================
3273 option("--disable-negotiateauth", help="Disable GSS-API negotiation")
3275 set_config("MOZ_AUTH_EXTENSION", True, when="--enable-negotiateauth")
3276 set_define("MOZ_AUTH_EXTENSION", True, when="--enable-negotiateauth")
3280 # ==============================================================
3281 option("--disable-parental-controls", help="Do not build parental controls")
3284 "MOZ_DISABLE_PARENTAL_CONTROLS",
3286 when=depends("--enable-parental-controls")(lambda x: not x),
3289 "MOZ_DISABLE_PARENTAL_CONTROLS",
3291 when=depends("--enable-parental-controls")(lambda x: not x),
3295 # Sandboxing support
3296 # ==============================================================
3297 @depends(target, tsan, asan)
3298 def sandbox_default(target, tsan, asan):
3299 # Only enable the sandbox by default on Linux, OpenBSD, macOS, and Windows
3300 if target.kernel == "Linux" and target.os == "GNU":
3301 # Bug 1182565: TSan conflicts with sandboxing on Linux.
3302 # Bug 1287971: LSan also conflicts with sandboxing on Linux.
3305 # Linux sandbox is only available on x86{,_64} and arm{,64}.
3306 return target.cpu in ("x86", "x86_64", "arm", "aarch64")
3307 return target.kernel in ("WINNT", "Darwin", "OpenBSD")
3312 default=sandbox_default,
3313 help="{Enable|Disable} sandboxing support",
3316 set_config("MOZ_SANDBOX", True, when="--enable-sandbox")
3317 set_define("MOZ_SANDBOX", True, when="--enable-sandbox")
3319 with only_when(depends(target.kernel)(lambda k: k not in ("Darwin", "WINNT"))):
3320 set_define("MOZ_CONTENT_TEMP_DIR", True, when="--enable-sandbox")
3322 # Searching of system directories for extensions.
3323 # ==============================================================
3324 # Note: this switch is meant to be used for test builds whose behavior should
3325 # not depend on what happens to be installed on the local machine.
3327 "--disable-system-extension-dirs",
3328 help="Disable searching system- and account-global directories for extensions"
3329 " of any kind; use only profile-specific extension directories",
3332 set_define("ENABLE_SYSTEM_EXTENSION_DIRS", True, when="--enable-system-extension-dirs")
3336 # ==============================================================
3337 with only_when(compile_environment):
3339 "--enable-system-pixman", help="Use system pixman (located with pkgconfig)"
3342 @depends("--enable-system-pixman")
3343 def in_tree_pixman(pixman):
3346 set_config("MOZ_TREE_PIXMAN", True, when=in_tree_pixman)
3347 set_define("MOZ_TREE_PIXMAN", True, when=in_tree_pixman)
3349 pkg_check_modules("MOZ_PIXMAN", "pixman-1 >= 0.36.0", when="--enable-system-pixman")
3350 # Set MOZ_PIXMAN_CFLAGS to an explicit empty value when --enable-system-pixman is *not* used,
3351 # for layout/style/extra-bindgen-flags
3352 set_config("MOZ_PIXMAN_CFLAGS", [], when=in_tree_pixman)
3356 # ==============================================================
3357 with only_when(compile_environment):
3358 option("--disable-universalchardet", help="Disable universal encoding detection")
3360 set_config("MOZ_UNIVERSALCHARDET", True, when="--enable-universalchardet")
3364 # ==============================================================
3365 with only_when(compile_environment):
3366 option("--disable-zipwriter", help="Disable zipwriter component")
3368 set_config("MOZ_ZIPWRITER", True, when="--enable-zipwriter")
3371 # Location of the mozilla user directory
3372 # ==============================================================
3373 with only_when(compile_environment):
3376 def default_user_appdir(target):
3377 if target.kernel in ("WINNT", "Darwin"):
3382 "--with-user-appdir",
3384 default=default_user_appdir,
3385 help="Set user-specific appdir",
3388 @depends("--with-user-appdir")
3389 def user_appdir(appdir):
3391 die("--without-user-appdir is not a valid option.")
3392 if "/" in appdir[0]:
3393 die("--with-user-appdir must be a single relative path.")
3394 return '"{}"'.format(appdir[0])
3396 set_define("MOZ_USER_DIR", user_appdir)
3399 # Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
3400 # ==============================================================
3401 with only_when(compile_environment):
3402 have_sin_len = c_compiler.try_compile(
3403 includes=["netinet/in.h"],
3404 body="struct sockaddr_in x; void *foo = (void*) &x.sin_len;",
3405 check_msg="for sin_len in struct sockaddr_in",
3407 have_sin6_len = c_compiler.try_compile(
3408 includes=["netinet/in.h"],
3409 body="struct sockaddr_in6 x; void *foo = (void*) &x.sin6_len;",
3410 check_msg="for sin_len6 in struct sockaddr_in6",
3412 set_define("HAVE_SIN_LEN", have_sin_len)
3413 set_define("HAVE_SIN6_LEN", have_sin6_len)
3414 # HAVE_CONN_LEN must be the same as HAVE_SIN_LEN and HAVE_SIN6_LEN
3415 set_define("HAVE_SCONN_LEN", have_sin_len & have_sin6_len)
3418 c_compiler.try_compile(
3419 includes=["netinet/in.h"],
3420 body="struct sockaddr x; void *foo = (void*) &x.sa_len;",
3421 check_msg="for sa_len in struct sockaddr",
3426 # Check for pthread_cond_timedwait_monotonic_np
3427 # ==============================================================
3428 with only_when(compile_environment):
3430 "HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC",
3431 c_compiler.try_compile(
3432 includes=["pthread.h"],
3433 body="pthread_cond_timedwait_monotonic_np(0, 0, 0);",
3434 # -Werror to catch any "implicit declaration" warning that means the function
3436 flags=["-Werror=implicit-function-declaration"],
3437 check_msg="for pthread_cond_timedwait_monotonic_np",
3442 # Custom dynamic linker for Android
3443 # ==============================================================
3444 with only_when(target_has_linux_kernel & compile_environment):
3447 default=depends(target.os, when="--enable-jemalloc")(
3448 lambda os: os == "Android"
3450 help="{Enable|Disable} custom dynamic linker",
3453 set_config("MOZ_LINKER", True, when="MOZ_LINKER")
3454 set_define("MOZ_LINKER", True, when="MOZ_LINKER")
3455 add_old_configure_assignment("MOZ_LINKER", True, when="MOZ_LINKER")
3457 moz_linker = depends(when="MOZ_LINKER")(lambda: True)
3460 # 32-bits ethtool_cmd.speed
3461 # ==============================================================
3462 with only_when(target_has_linux_kernel & compile_environment):
3464 "MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI",
3465 c_compiler.try_compile(
3466 includes=["linux/ethtool.h"],
3467 body="struct ethtool_cmd cmd; cmd.speed_hi = 0;",
3468 check_msg="for 32-bits ethtool_cmd.speed",
3473 # ==============================================================
3476 onerror=lambda: die(
3477 "Can't find header linux/joystick.h, needed for gamepad support."
3478 " Please install Linux kernel headers."
3480 when=target_has_linux_kernel & compile_environment,
3484 # Smart card support
3485 # ==============================================================
3486 @depends(build_project)
3487 def disable_smart_cards(build_project):
3488 return build_project == "mobile/android"
3491 set_config("MOZ_NO_SMART_CARDS", True, when=disable_smart_cards)
3492 set_define("MOZ_NO_SMART_CARDS", True, when=disable_smart_cards)
3494 # Enable UniFFI fixtures
3495 # ==============================================================
3496 # These are used to test the uniffi-bindgen-gecko-js code generation. They
3497 # should not be enabled in release builds.
3500 "--enable-uniffi-fixtures",
3501 help="Enable UniFFI Fixtures/Examples",
3504 set_config("MOZ_UNIFFI_FIXTURES", True, when="--enable-uniffi-fixtures")
3507 # ==============================================================
3510 "--disable-system-policies",
3511 help="Disable reading policies from Windows registry, macOS's file system attributes, and /etc/firefox",
3514 set_config("MOZ_SYSTEM_POLICIES", True, when="--enable-system-policies")
3516 # Allow disabling the creation a legacy profile
3517 # ==============================================================
3520 "--disable-legacy-profile-creation",
3521 help="Disable the creation a legacy profile, to be used by old versions "
3522 "of Firefox, when no profiles exist.",
3525 set_config("MOZ_CREATE_LEGACY_PROFILE", True, when="--enable-legacy-profile-creation")
3529 # ==============================================================
3530 set_config("WRAP_STL_INCLUDES", True)
3533 depends(build_environment.dist)(lambda dist: [f"-I{dist}/stl_wrappers"]),
3538 # ==============================================================
3540 def need_perl(target):
3541 # Ideally, we'd also depend on gnu_as here, but that adds complications.
3542 return target.cpu == "arm"
3545 perl = check_prog("PERL", ("perl5", "perl"), when=need_perl)
3549 def perl_version_check(min_version):
3551 @checking("for minimum required perl version >= %s" % min_version)
3552 def get_perl_version(perl):
3558 onerror=lambda: die("Failed to get perl version."),
3562 @depends(get_perl_version)
3563 def check_perl_version(version):
3564 if version < min_version:
3565 die("Perl %s or higher is required.", min_version)
3568 @checking("for full perl installation")
3569 @imports("subprocess")
3570 def has_full_perl_installation(perl):
3571 ret = subprocess.call([perl, "-e", "use Config; exit(!-d $Config{archlib})"])
3574 @depends(has_full_perl_installation)
3575 def require_full_perl_installation(has_full_perl_installation):
3576 if not has_full_perl_installation:
3578 "Cannot find Config.pm or $Config{archlib}. "
3579 "A full perl installation is required."
3583 with only_when(need_perl):
3584 perl_version_check("5.006")
3587 # windows-rs as bootstrappable toolchain
3588 # ==============================================================
3589 # The in-tree windows crate's purpose is to avoid vendoring the
3590 # original windows crate, which is too large.
3591 # The ideal solution would be for cargo to allow exceptions to
3592 # vendoring, but it doesn't.
3593 # The adopted solution is to somehow use the crate contents from
3594 # a directory given via the mozbuild config, or bootstrapped.
3596 # Unfortunately, doing `include!(mozbuild::windows_rs_path!("src/lib.rs"))`
3597 # in the crate's lib.rs doesn't work because of
3598 # https://github.com/rust-lang/rust/issues/66920.
3600 # Previous versions of the windows crate had submodules declared
3601 # directly in lib.rs. Annotating each of them with
3602 # `#[path = concat!(mozbuild::windows_rs_path!("path/to/mod.rs"))]`
3603 # unfortunately also didn't work, because of
3604 # https://github.com/rust-lang/rust/issues/48250.
3606 # Thankfully, newer versions of the windows crate now only have an
3607 # `include!` at the end of lib.rs, so we can get away with simply
3608 # replacing it with an `include!` that uses `mozbuild::windows_rs_path!`.
3610 # We ensure that the in-tree contents match what we expect based on
3611 # the original crate.
3612 # The expectations are as such:
3613 # - Cargo.toml is identical to the original one with the addition of the
3614 # following two lines at the end (after an empty line):
3615 # [dependencies.mozbuild]
3617 # - src/lib.rs is mostly identical to the original one, with two notable
3619 # - the addition of `#![allow(warnings)]` on the first line, because if
3620 # the crate had been vendored normally, it would not be affected by
3621 # `-D warnings`, and `#![allow(warnings)]` mimicks that.
3622 # - the replacement of any
3623 # `include!("path/file.rs")`
3625 # `include!(mozbuild::windows_rs_path!("src/path/file.rs"))`
3626 with only_when(target_is_windows & compile_environment):
3628 env="MOZ_WINDOWS_RS_DIR",
3630 help="Path to the source of the 'windows' Rust crate",
3634 "MOZ_WINDOWS_RS_DIR",
3637 when=depends("MOZ_WINDOWS_RS_DIR")(lambda x: not x),
3639 build_environment.topsrcdir,
3641 @checking("for the windows rust crate source")
3642 @imports(_from="__builtin__", _import="open")
3645 def windows_rs_dir(dir, bootstrapped, topsrcdir):
3651 raw_cargo_toml = open(
3652 os.path.join(topsrcdir, "build/rust/windows/Cargo.toml")
3654 cargo_toml = toml.loads(raw_cargo_toml)
3655 expected_version = cargo_toml["package"]["version"]
3658 raise FatalCheckError(
3659 "Cannot find the windows rust crate source.\n"
3660 f"Try downloading it with `cargo download -x windows={expected_version}`\n"
3661 "(you may need to `cargo install cargo-download` first)\n"
3662 f"and set `MOZ_WINDOWS_RS_DIR` to location of the `windows-{expected_version}`"
3666 raw_cargo_toml_orig = open(os.path.join(dir, "Cargo.toml")).read()
3667 cargo_toml = toml.loads(raw_cargo_toml_orig)
3668 version = cargo_toml["package"]["version"]
3669 if version != expected_version:
3670 raise FatalCheckError(
3671 f"The windows rust crate source in {dir} contains version "
3672 f"{version}, but expected {expected_version}."
3674 # Now that we've done the basic sanity check, let's go deeper.
3675 DEPENDENCIES = '\n[dependencies.mozbuild]\nversion = "0.1"\n'
3676 if not raw_cargo_toml.endswith(DEPENDENCIES):
3677 configure_error("In-tree windows crate is missing dependency on mozbuild")
3678 if raw_cargo_toml[: -len(DEPENDENCIES)] != raw_cargo_toml_orig:
3679 configure_error("In-tree windows crate Cargo.toml doesn't match original")
3681 lib_rs = open(os.path.join(topsrcdir, "build/rust/windows/src/lib.rs")).read()
3682 lib_rs_orig = open(os.path.join(dir, "src/lib.rs")).read()
3683 lib_rs_expected = "#![allow(warnings)]\n" + re.sub(
3684 r'include!\("([^"]*)"\)',
3685 r'include!(mozbuild::windows_rs_path!("src/\1"))',
3688 if lib_rs != lib_rs_expected:
3689 configure_error("In-tree windows crate lib.rs doesn't match original")
3693 set_config("MOZ_WINDOWS_RS_DIR", windows_rs_dir)