1 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
2 # vim: set filetype=python:
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # Set the MOZ_CONFIGURE_OPTIONS variable with all the options that
9 # were passed somehow (environment, command line, mozconfig)
11 @imports(_from="mozbuild.shellutil", _import="quote")
12 @imports(_from="mozbuild.util", _import="ensure_unicode")
13 @imports(_from="mozbuild.util", _import="system_encoding")
14 @imports("__sandbox__")
15 def all_configure_options():
18 for option in __sandbox__._options.values():
19 # __sandbox__._options contains items for both option.name and
20 # option.env. But it's also an OrderedDict, meaning both are
22 # Also ignore OLD_CONFIGURE and MOZCONFIG because they're not
24 if option == previous or option.env in ("OLD_CONFIGURE", "MOZCONFIG"):
27 value = __sandbox__._value_for(option)
28 # We only want options that were explicitly given on the command
29 # line, the environment, or mozconfig, and that differ from the
33 and value.origin not in ("default", "implied")
34 and value != option.default
37 ensure_unicode(__sandbox__._raw_options[option], system_encoding)
39 # We however always include options that are sent to old configure
40 # because we don't know their actual defaults. (Keep the conditions
41 # separate for ease of understanding and ease of removal)
43 option.help == "Help missing for old configure options"
44 and option in __sandbox__._raw_options
47 ensure_unicode(__sandbox__._raw_options[option], system_encoding)
50 # We shouldn't need this, but currently, quote will return a byte string
51 # if result is empty, and that's not wanted here.
58 set_config("MOZ_CONFIGURE_OPTIONS", all_configure_options)
62 def fold_libs(target):
63 return target.os in ("WINNT", "OSX", "Android")
66 set_config("MOZ_FOLD_LIBS", fold_libs)
69 # ==============================================================
70 # Some of the options here imply an option from js/moz.configure,
71 # so, need to be declared before the include.
76 help="Enable jprof profiling tool (needs mozilla/tools/jprof)",
80 @depends("--enable-jprof")
86 set_config("MOZ_JPROF", jprof)
87 set_define("MOZ_JPROF", jprof)
88 imply_option("--enable-profiling", jprof)
92 def gecko_profiler(target):
93 if target.os == "Android":
94 return target.cpu in ("aarch64", "arm", "x86", "x86_64")
95 elif target.kernel == "Linux":
96 return target.cpu in ("aarch64", "arm", "x86", "x86_64", "mips64")
97 elif target.kernel == "FreeBSD":
98 return target.cpu in ("aarch64", "x86_64")
99 return target.os in ("OSX", "WINNT")
102 @depends(gecko_profiler)
103 def gecko_profiler_define(value):
108 set_config("MOZ_GECKO_PROFILER", gecko_profiler_define)
109 set_define("MOZ_GECKO_PROFILER", gecko_profiler_define)
112 # Whether code to parse ELF binaries should be compiled for the Gecko profiler
113 # (for symbol table dumping).
114 @depends(gecko_profiler, target)
115 def gecko_profiler_parse_elf(value, target):
116 # Currently we only want to build this code on Linux (including Android) and BSD.
117 # For Android, this is in order to dump symbols from Android system, where
118 # on other platforms there exist alternatives that don't require bloating
119 # up our binary size. For Linux more generally, we use this in profile
120 # pre-symbolication support, since MozDescribeCodeAddress doesn't do
121 # anything useful on that platform. (Ideally, we would update
122 # MozDescribeCodeAddress to call into some Rust crates that parse ELF and
123 # DWARF data, but build system issues currently prevent Rust from being
125 if value and (target.kernel == "Linux" or target.kernel == "FreeBSD"):
129 set_config("MOZ_GECKO_PROFILER_PARSE_ELF", gecko_profiler_parse_elf)
130 set_define("MOZ_GECKO_PROFILER_PARSE_ELF", gecko_profiler_parse_elf)
132 # enable this by default if the profiler is enabled
133 # Note: also requires jemalloc
134 set_config("MOZ_PROFILER_MEMORY", gecko_profiler_define)
135 set_define("MOZ_PROFILER_MEMORY", gecko_profiler_define)
142 # Artifact builds are included because the downloaded artifacts can
144 when=artifact_builds | depends(when="--enable-replace-malloc")(lambda: True),
146 def dmd_default(debug, milestone, build_project):
147 return bool(build_project == "browser" and (debug or milestone.is_nightly))
154 help="{Enable|Disable} Dark Matter Detector (heap profiler). "
155 "Also enables jemalloc, replace-malloc and profiling",
159 @depends("--enable-dmd")
165 set_config("MOZ_DMD", dmd)
166 set_define("MOZ_DMD", dmd)
167 imply_option("--enable-profiling", dmd)
168 imply_option("--enable-jemalloc", dmd, when=compile_environment)
169 imply_option("--enable-replace-malloc", dmd, when=compile_environment)
172 # midir-based Web MIDI support
173 # ==============================================================
175 def midir_linux_support(target):
177 target.kernel == "Linux" and target.os != "Android" and target.cpu != "riscv64"
181 @depends(target, midir_linux_support)
182 def midir_support(target, midir_linux_support):
183 if target.os in ("WINNT", "OSX") or midir_linux_support:
187 set_config("MOZ_WEBMIDI_MIDIR_IMPL", midir_support)
190 # Enable various cubeb backends
191 # ==============================================================
193 def audio_backends_default(target):
194 if target.os == "Android":
199 elif target.os in ("DragonFly", "FreeBSD", "SunOS"):
201 elif target.os == "OpenBSD":
203 elif target.os == "OSX":
204 return ("audiounit",)
205 elif target.os == "NetBSD":
207 elif target.os == "SunOS":
209 elif target.os == "WINNT":
212 return ("pulseaudio",)
216 "--enable-audio-backends",
230 default=audio_backends_default,
231 help="{Enable|Disable} various cubeb backends",
235 @depends("--enable-audio-backends", target)
236 def imply_aaudio(values, target):
237 if any("aaudio" in value for value in values) and target.os != "Android":
238 die("Cannot enable AAudio on %s", target.os)
239 return any("aaudio" in value for value in values) or None
242 @depends("--enable-audio-backends", target)
243 def imply_alsa(values, target):
245 any("alsa" in value for value in values)
246 and target.kernel != "Linux"
247 and target.os != "FreeBSD"
249 die("Cannot enable ALSA on %s", target.os)
250 return any("alsa" in value for value in values) or None
253 @depends("--enable-audio-backends", target)
254 def imply_audiounit(values, target):
256 any("audiounit" in value for value in values)
257 and target.os != "OSX"
258 and target.kernel != "Darwin"
260 die("Cannot enable AudioUnit on %s", target.os)
261 return any("audiounit" in value for value in values) or None
264 @depends("--enable-audio-backends")
265 def imply_jack(values):
266 return any("jack" in value for value in values) or None
269 @depends("--enable-audio-backends", target)
270 def imply_opensl(values, target):
271 if any("opensl" in value for value in values) and target.os != "Android":
272 die("Cannot enable OpenSL on %s", target.os)
273 return any("opensl" in value for value in values) or None
276 @depends("--enable-audio-backends", target)
277 def imply_oss(values, target):
278 if any("oss" in value for value in values) and (
279 target.os == "Android" or target.os == "OSX" or target.os == "WINNT"
281 die("Cannot enable OSS on %s", target.os)
282 return any("oss" in value for value in values) or None
285 @depends("--enable-audio-backends", target)
286 def imply_pulseaudio(values, target):
287 if any("pulseaudio" in value for value in values) and (
288 target.os == "Android" or target.os == "OSX" or target.os == "WINNT"
290 die("Cannot enable PulseAudio on %s", target.os)
291 return any("pulseaudio" in value for value in values) or None
294 @depends("--enable-audio-backends", target)
295 def imply_sndio(values, target):
296 if any("sndio" in value for value in values) and (
297 target.os == "Android" or target.os == "OSX" or target.os == "WINNT"
299 die("Cannot enable sndio on %s", target.os)
300 return any("sndio" in value for value in values) or None
303 @depends("--enable-audio-backends", target)
304 def imply_sunaudio(values, target):
305 if any("sunaudio" in value for value in values) and (
306 target.os != "NetBSD" and target.os != "SunOS"
308 die("Cannot enable sunaudio on %s", target.os)
309 return any("sunaudio" in value for value in values) or None
312 @depends("--enable-audio-backends", target)
313 def imply_wasapi(values, target):
314 if any("wasapi" in value for value in values) and target.os != "WINNT":
315 die("Cannot enable WASAPI on %s", target.os)
316 return any("wasapi" in value for value in values) or None
319 set_config("MOZ_AAUDIO", imply_aaudio, when="--enable-audio-backends")
321 imply_option("--enable-alsa", imply_alsa, reason="--enable-audio-backends")
323 set_config("MOZ_AUDIOUNIT_RUST", imply_audiounit, when="--enable-audio-backends")
325 imply_option("--enable-jack", imply_jack, reason="--enable-audio-backends")
327 set_config("MOZ_OPENSL", imply_opensl, when="--enable-audio-backends")
329 set_config("MOZ_OSS", imply_oss, when="--enable-audio-backends")
331 imply_option("--enable-pulseaudio", imply_pulseaudio, reason="--enable-audio-backends")
333 imply_option("--enable-sndio", imply_sndio, reason="--enable-audio-backends")
335 set_config("MOZ_SUNAUDIO", imply_sunaudio, when="--enable-audio-backends")
337 set_config("MOZ_WASAPI", imply_wasapi, when="--enable-audio-backends")
340 # ==============================================================
341 option("--enable-alsa", env="MOZ_ALSA", help="Enable ALSA audio backend.")
344 @depends("--enable-alsa", midir_linux_support)
345 def enable_alsa_or_midir_linux_support(alsa_enabled, midir_linux_support):
346 return alsa_enabled or midir_linux_support
349 pkg_check_modules("MOZ_ALSA", "alsa", when=enable_alsa_or_midir_linux_support)
351 set_config("MOZ_ALSA", True, when="--enable-alsa")
352 set_define("MOZ_ALSA", True, when="--enable-alsa")
355 # ==============================================================
356 system_lib_option("--enable-jack", env="MOZ_JACK", help="Enable JACK audio backend.")
358 jack = pkg_check_modules("MOZ_JACK", "jack", when="--enable-jack")
360 set_config("MOZ_JACK", depends_if(jack)(lambda _: True))
362 # PulseAudio cubeb backend
363 # ==============================================================
365 "--enable-pulseaudio",
366 env="MOZ_PULSEAUDIO",
367 help="{Enable|Disable} PulseAudio audio backend.",
370 pulseaudio = pkg_check_modules("MOZ_PULSEAUDIO", "libpulse", when="--enable-pulseaudio")
372 set_config("MOZ_PULSEAUDIO", depends_if(pulseaudio)(lambda _: True))
373 set_define("MOZ_PULSEAUDIO", depends_if(pulseaudio)(lambda _: True))
375 # sndio cubeb backend
376 # ==============================================================
377 system_lib_option("--enable-sndio", env="MOZ_SNDIO", help="Enable sndio audio backend.")
379 sndio = pkg_check_modules("MOZ_SNDIO", "sndio", when="--enable-sndio")
381 set_config("MOZ_SNDIO", depends_if(sndio)(lambda _: True))
384 # ==============================================================
385 include("../js/moz.configure")
389 # ==============================================================
390 include("../build/moz.configure/node.configure")
393 # ==============================================================
394 set_define("JSON_USE_EXCEPTION", 0)
397 # ==============================================================
398 option("--with-l10n-base", nargs=1, env="L10NBASEDIR", help="Path to l10n repositories")
401 @depends("--with-l10n-base", "MOZ_AUTOMATION", build_environment)
402 @imports(_from="os.path", _import="isdir")
403 @imports(_from="os.path", _import="expanduser")
404 @imports(_from="os", _import="environ")
405 def l10n_base(value, automation, build_env):
409 die("Invalid value --with-l10n-base, %s doesn't exist", path)
411 path = os.path.join(build_env.topsrcdir, "../l10n-central")
415 "MOZBUILD_STATE_PATH", expanduser(os.path.join("~", ".mozbuild"))
419 return os.path.realpath(os.path.abspath(path))
422 set_config("L10NBASEDIR", l10n_base)
426 # ==============================================================
428 def toolkit_choices(target):
429 if target.os == "WINNT":
430 return ("cairo-windows",)
431 elif target.os == "OSX":
432 return ("cairo-cocoa",)
433 elif target.os == "Android":
434 return ("cairo-android",)
436 # cairo-gtk3 - X11 backend with optional Wayland backend (auto detected)
437 # cairo-gtk3-wayland - Wayland backend with optional X11 backend (auto detected)
438 # cairo-gtk3-x11-wayland - builds explicitly with X11 & Wayland backends
441 "cairo-gtk3-wayland",
442 "cairo-gtk3-x11-wayland",
443 "cairo-gtk3-wayland-only",
444 "cairo-gtk3-x11-only",
448 @depends(toolkit_choices)
449 def toolkit_default(choices):
454 "--enable-default-toolkit",
456 choices=toolkit_choices,
457 default=toolkit_default,
458 help="Select default toolkit",
462 @depends("--enable-default-toolkit")
463 def full_toolkit(value):
468 @depends(full_toolkit)
469 def toolkit(toolkit):
470 if toolkit.startswith("cairo-gtk3"):
471 widget_toolkit = "gtk"
473 widget_toolkit = toolkit.replace("cairo-", "")
474 return widget_toolkit
477 set_config("MOZ_WIDGET_TOOLKIT", toolkit)
478 add_old_configure_assignment("MOZ_WIDGET_TOOLKIT", toolkit)
482 def toolkit_define(toolkit):
483 if toolkit != "windows":
484 return "MOZ_WIDGET_%s" % toolkit.upper()
487 set_define(toolkit_define, True)
491 def toolkit_gtk(toolkit):
492 return toolkit == "gtk"
495 @depends(toolkit_gtk, full_toolkit)
496 def toolkit_gtk_x11(toolkit_gtk, full_toolkit):
497 return toolkit_gtk and full_toolkit != "cairo-gtk3-wayland-only"
500 @depends(full_toolkit)
501 def toolkit_gtk_x11_optional(full_toolkit):
502 return full_toolkit == "cairo-gtk3-wayland"
505 @depends(toolkit_gtk, full_toolkit)
506 def toolkit_gtk_wayland(toolkit_gtk, full_toolkit):
507 return toolkit_gtk and full_toolkit != "cairo-gtk3-x11-only"
510 @depends(full_toolkit)
511 def toolkit_gtk_wayland_optional(full_toolkit):
512 return full_toolkit == "cairo-gtk3"
516 # ==============================================================
517 wayland_headers = pkg_check_modules(
519 "gtk+-wayland-3.0 >= 3.14 xkbcommon >= 0.4.1",
520 allow_missing=toolkit_gtk_wayland_optional,
521 when=toolkit_gtk_wayland,
525 @depends(wayland_headers, toolkit_gtk, artifact_builds, toolkit_gtk_wayland)
526 def wayland_headers(wayland, toolkit_gtk, artifacts, toolkit_gtk_wayland):
527 if not toolkit_gtk_wayland:
529 if toolkit_gtk and artifacts:
534 set_config("MOZ_WAYLAND", depends_if(wayland_headers)(lambda _: True))
535 set_define("MOZ_WAYLAND", depends_if(wayland_headers)(lambda _: True))
538 # Hardware-accelerated video decode with VAAPI and V4L2 on Linux
539 # ==============================================================
540 @depends(target, toolkit_gtk)
541 def vaapi(target, toolkit_gtk):
542 # VAAPI is mostly used on x86(-64) but is sometimes used on ARM/ARM64 SOCs.
543 if target.cpu in ("arm", "aarch64", "x86", "x86_64") and toolkit_gtk:
547 @depends(target, toolkit_gtk)
548 def v4l2(target, toolkit_gtk):
549 # V4L2 decode is only used in GTK/Linux and generally only appears on
551 if target.cpu in ("arm", "aarch64", "riscv64") and toolkit_gtk:
555 set_config("MOZ_ENABLE_VAAPI", True, when=vaapi)
556 set_config("MOZ_ENABLE_V4L2", True, when=v4l2)
557 set_define("MOZ_ENABLE_VAAPI", True, when=vaapi)
558 set_define("MOZ_ENABLE_V4L2", True, when=v4l2)
562 # ==============================================================
563 option("--with-gl-provider", nargs=1, help="Set GL provider backend type")
566 @depends("--with-gl-provider")
567 def gl_provider(value):
572 @depends(gl_provider)
573 def gl_provider_define(provider):
575 return "GLContextProvider%s" % provider
578 set_define("MOZ_GL_PROVIDER", gl_provider_define)
581 @depends(gl_provider, toolkit_gtk)
582 def gl_default_provider(value, toolkit_gtk):
589 set_config("MOZ_GL_PROVIDER", gl_provider)
590 set_config("MOZ_GL_DEFAULT_PROVIDER", gl_default_provider)
593 @depends(gl_default_provider)
594 def gl_provider_define(provider):
596 return "GL_PROVIDER_%s" % provider
599 set_define(gl_provider_define, True)
603 # ==============================================================
605 def pdf_printing(toolkit):
606 if toolkit in ("windows", "gtk", "android"):
610 set_config("MOZ_PDF_PRINTING", pdf_printing)
611 set_define("MOZ_PDF_PRINTING", pdf_printing)
614 # Event loop instrumentation
615 # ==============================================================
616 option(env="MOZ_INSTRUMENT_EVENT_LOOP", help="Force-enable event loop instrumentation")
619 @depends("MOZ_INSTRUMENT_EVENT_LOOP", toolkit)
620 def instrument_event_loop(value, toolkit):
622 toolkit in ("windows", "gtk", "cocoa", "android") and value.origin == "default"
627 set_config("MOZ_INSTRUMENT_EVENT_LOOP", instrument_event_loop)
628 set_define("MOZ_INSTRUMENT_EVENT_LOOP", instrument_event_loop)
631 # Fontconfig Freetype
632 # ==============================================================
633 option(env="USE_FC_FREETYPE", help="Force-enable the use of fontconfig freetype")
636 @depends("USE_FC_FREETYPE", toolkit)
637 def fc_freetype(value, toolkit):
638 if value or (toolkit == "gtk" and value.origin == "default"):
642 set_define("USE_FC_FREETYPE", fc_freetype)
645 # ==============================================================
646 pkg_check_modules("MOZ_PANGO", "pango >= 1.22.0", when=toolkit_gtk)
649 # ==============================================================
650 fontconfig_info = pkg_check_modules(
651 "_FONTCONFIG", "fontconfig >= 2.7.0", when=fc_freetype
655 @depends(fc_freetype)
656 def check_for_freetype2(fc_freetype):
661 # Check for freetype2. Flags are combined with fontconfig flags.
662 freetype2_info = pkg_check_modules(
663 "_FT2", "freetype2 >= 9.10.3", when=check_for_freetype2
667 @depends(fontconfig_info, freetype2_info)
668 def freetype2_combined_info(fontconfig_info, freetype2_info):
669 if not freetype2_info:
671 if not fontconfig_info:
672 return freetype2_info
674 cflags=freetype2_info.cflags + fontconfig_info.cflags,
675 libs=freetype2_info.libs + fontconfig_info.libs,
679 set_define("MOZ_HAVE_FREETYPE2", depends_if(freetype2_info)(lambda _: True))
682 # Apple platform decoder support
683 # ==============================================================
685 def applemedia(toolkit):
686 if toolkit in ("cocoa", "uikit"):
690 set_config("MOZ_APPLEMEDIA", applemedia)
691 set_define("MOZ_APPLEMEDIA", applemedia)
693 # Windows Media Foundation support
694 # ==============================================================
695 option("--disable-wmf", help="Disable support for Windows Media Foundation")
698 @depends("--disable-wmf", target, "--help")
699 def wmf(value, target, _):
700 enabled = bool(value)
701 if value.origin == "default":
702 # Enable Windows Media Foundation support by default.
703 # Note our minimum SDK version is Windows 7 SDK, so we are (currently)
704 # guaranteed to have a recent-enough SDK to build WMF.
705 enabled = target.os == "WINNT"
706 if enabled and target.os != "WINNT":
707 die("Cannot enable Windows Media Foundation support on %s", target.os)
712 @depends(c_compiler, when=wmf)
713 def wmfmediaengine(c_compiler):
714 return c_compiler and c_compiler.type == "clang-cl"
717 set_config("MOZ_WMF", wmf)
718 set_define("MOZ_WMF", wmf)
720 set_config("MOZ_WMF_MEDIA_ENGINE", True, when=wmfmediaengine)
721 set_define("MOZ_WMF_MEDIA_ENGINE", True, when=wmfmediaengine)
723 # FFmpeg H264/AAC Decoding Support
724 # ==============================================================
725 option("--disable-ffmpeg", help="Disable FFmpeg for fragmented H264/AAC decoding")
728 @depends("--disable-ffmpeg", target)
729 def ffmpeg(value, target):
730 enabled = bool(value)
731 if value.origin == "default":
732 enabled = target.os not in ("Android", "WINNT")
737 set_config("MOZ_FFMPEG", ffmpeg)
738 set_define("MOZ_FFMPEG", ffmpeg)
740 # AV1 Video Codec Support
741 # ==============================================================
742 option("--disable-av1", help="Disable av1 video support")
745 @depends("--enable-av1")
751 @depends(target, when=av1 & compile_environment)
752 def dav1d_asm(target):
753 if target.cpu in ("aarch64", "x86", "x86_64"):
757 @depends(target, when=av1 & compile_environment)
758 def dav1d_nasm(target):
759 if target.cpu in ("x86", "x86_64"):
760 return namespace(version="2.14", what="AV1")
763 set_config("MOZ_DAV1D_ASM", dav1d_asm)
764 set_define("MOZ_DAV1D_ASM", dav1d_asm)
765 set_config("MOZ_AV1", av1)
766 set_define("MOZ_AV1", av1)
768 # JXL Image Codec Support
769 # ==============================================================
770 option("--disable-jxl", help="Disable jxl image support")
773 @depends("--disable-jxl", milestone.is_nightly)
774 def jxl(value, is_nightly):
775 if is_nightly and value:
779 set_config("MOZ_JXL", jxl)
780 set_define("MOZ_JXL", jxl)
782 set_config("MOZ_SAMPLE_TYPE_FLOAT32", True)
783 set_define("MOZ_SAMPLE_TYPE_FLOAT32", True)
785 set_define("MOZ_VORBIS", True)
786 set_config("MOZ_VORBIS", True)
789 "--disable-real-time-tracing",
790 help="Disable tracing of real-time audio callbacks",
793 set_config("MOZ_REAL_TIME_TRACING", True, when="--enable-real-time-tracing")
794 set_define("MOZ_REAL_TIME_TRACING", True, when="--enable-real-time-tracing")
796 # OpenMAX IL Decoding Support
797 # ==============================================================
798 option("--enable-openmax", help="Enable OpenMAX IL for video/audio decoding")
801 @depends("--enable-openmax")
803 enabled = bool(value)
808 set_config("MOZ_OMX", openmax)
809 set_define("MOZ_OMX", openmax)
813 # ==============================================================
814 @depends(target, wmf)
815 def eme_choices(target, wmf):
817 target.kernel in ("WINNT", "Linux")
818 and target.os != "Android"
819 and target.cpu in ("x86", "x86_64")
822 return ("widevine", "wmfcdm")
824 if target.kernel == "WINNT" and target.cpu == "aarch64":
826 if target.os in ("OSX"):
830 # Widevine is enabled by default in desktop browser builds.
831 @depends(build_project, eme_choices)
832 def eme_default(build_project, choices):
833 if build_project == "browser":
843 help="{Enable|Disable} support for Encrypted Media Extensions",
847 @depends("--enable-eme", when=eme_choices)
848 def eme_modules(value):
852 # Fallback to an empty list when eme_choices is empty, setting eme_modules to
854 set_config("MOZ_EME_MODULES", eme_modules | dependable([]))
857 # Media Foundation CDM support
858 # ==============================================================
859 @depends(eme_modules, when=wmfmediaengine)
861 if "wmfcdm" in modules:
865 set_config("MOZ_WMF_CDM", True, when=wmfcdm)
866 set_define("MOZ_WMF_CDM", True, when=wmfcdm)
870 name="--enable-chrome-format",
871 help="Select FORMAT of chrome files during packaging.",
873 choices=("omni", "jar", "flat"),
878 @depends("--enable-chrome-format")
879 def packager_format(value):
883 set_config("MOZ_PACKAGER_FORMAT", packager_format)
885 # The packager minifies two different types of files: non-JS (mostly property
886 # files for l10n), and JS. Setting MOZ_PACKAGER_MINIFY only minifies the
887 # former. Firefox doesn't yet minify JS, due to concerns about debuggability.
889 # Also, the JS minification setup really only works correctly on Android:
890 # we need extra setup to use the newly-built shell for Linux and Windows,
891 # and cross-compilation for macOS requires some extra care.
894 @depends(target_is_android, "--enable-debug", milestone.is_nightly)
895 def enable_minify_default(is_android, debug, is_nightly):
896 if is_android and not debug and not is_nightly:
897 return ("properties", "js")
898 return ("properties",)
902 name="--enable-minify",
903 help="Select types of files to minify during packaging.",
905 choices=("properties", "js"),
906 default=enable_minify_default,
910 @depends("--enable-minify")
911 def enable_minify(value):
912 if "js" in value and "properties" not in value:
913 die("--enable-minify=js requires --enable-minify=properties.")
915 properties="properties" in value,
920 set_config("MOZ_PACKAGER_MINIFY", True, when=enable_minify.properties)
921 set_config("MOZ_PACKAGER_MINIFY_JS", True, when=enable_minify.js)
924 @depends(host, build_project)
925 def jar_maker_format(host, build_project):
926 # Multilocales for mobile/android use the same mergedirs for all locales,
927 # so we can't use symlinks for those builds.
928 if host.os == "WINNT" or build_project == "mobile/android":
933 set_config("MOZ_JAR_MAKER_FILE_FORMAT", jar_maker_format)
937 def omnijar_name(toolkit):
938 # Fennec's static resources live in the assets/ folder of the
939 # APK. Adding a path to the name here works because we only
940 # have one omnijar file in the final package (which is not the
942 return "assets/omni.ja" if toolkit == "android" else "omni.ja"
945 set_config("OMNIJAR_NAME", omnijar_name)
947 project_flag("MOZ_PLACES", help="Build Places if required", set_as_define=True)
950 "MOZ_SERVICES_HEALTHREPORT",
951 help="Build Firefox Health Reporter Service",
957 help="Enable Normandy recipe runner",
961 project_flag("MOZ_SERVICES_SYNC", help="Build Sync Services if required")
964 "MOZ_ANDROID_HISTORY",
965 help="Enable Android History instead of Places",
970 "MOZ_DEDICATED_PROFILES",
971 help="Enable dedicated profiles per install",
976 "MOZ_BLOCK_PROFILE_DOWNGRADE",
977 help="Block users from starting profiles last used by a newer build",
982 @depends("MOZ_PLACES", "MOZ_ANDROID_HISTORY")
983 def check_places_and_android_history(places, android_history):
984 if places and android_history:
985 die("Cannot use MOZ_ANDROID_HISTORY alongside MOZ_PLACES.")
989 env="MOZ_TELEMETRY_REPORTING",
990 default=mozilla_official,
991 help="Enable telemetry reporting",
994 set_define("MOZ_TELEMETRY_REPORTING", True, when="MOZ_TELEMETRY_REPORTING")
997 @depends("MOZ_TELEMETRY_REPORTING", milestone.is_nightly)
998 def telemetry_on_by_default(reporting, is_nightly):
999 return reporting and is_nightly
1002 set_define("MOZ_TELEMETRY_ON_BY_DEFAULT", True, when=telemetry_on_by_default)
1006 # ==============================================================
1007 system_lib_option("--enable-gpsd", env="MOZ_GPSD", help="Enable gpsd support")
1010 @depends("--enable-gpsd")
1015 system_gpsd = pkg_check_modules("MOZ_GPSD", "libgps >= 3.11", when=gpsd)
1017 set_config("MOZ_GPSD", depends_if(system_gpsd)(lambda _: True))
1019 # Miscellaneous programs
1020 # ==============================================================
1022 check_prog("TAR", ("gnutar", "gtar", "tar"))
1023 check_prog("UNZIP", ("unzip",))
1026 # ==============================================================
1027 include("../build/moz.configure/keyfiles.configure")
1029 simple_keyfile("Mozilla API")
1031 simple_keyfile("Google Location Service API")
1033 simple_keyfile("Google Safebrowsing API")
1035 id_and_secret_keyfile("Bing API")
1037 simple_keyfile("Adjust SDK")
1039 id_and_secret_keyfile("Leanplum SDK")
1041 simple_keyfile("Pocket API")
1044 # WebRender Debugger integration
1045 # ==============================================================
1048 "--enable-webrender-debugger", help="Build the websocket debug server in WebRender"
1052 "MOZ_WEBRENDER_DEBUGGER", depends_if("--enable-webrender-debugger")(lambda _: True)
1055 # Additional system headers defined at the application level
1056 # ==============================================================
1059 "--enable-app-system-headers",
1060 env="MOZ_APP_SYSTEM_HEADERS",
1061 help="Use additional system headers defined in $MOZ_BUILD_APP/app-system-headers.mozbuild",
1065 @depends("--enable-app-system-headers")
1066 def app_system_headers(value):
1071 set_config("MOZ_APP_SYSTEM_HEADERS", app_system_headers)
1072 set_define("MOZ_APP_SYSTEM_HEADERS", app_system_headers)
1075 # ==============================================================
1076 option("--disable-printing", help="Disable printing support")
1079 @depends("--disable-printing")
1080 def printing(value):
1085 set_config("NS_PRINTING", printing)
1086 set_define("NS_PRINTING", printing)
1087 set_define("NS_PRINT_PREVIEW", printing)
1090 # Speech-dispatcher support
1091 # ==============================================================
1093 def no_speechd_on_non_gtk(toolkit):
1094 if toolkit != "gtk":
1099 "--enable-synth-speechd", no_speechd_on_non_gtk, reason="--enable-default-toolkit"
1102 option("--disable-synth-speechd", help="Disable speech-dispatcher support")
1104 set_config("MOZ_SYNTH_SPEECHD", depends_if("--disable-synth-speechd")(lambda _: True))
1107 # ==============================================================
1108 option("--disable-webspeech", help="Disable support for HTML Speech API")
1111 @depends("--disable-webspeech")
1112 def webspeech(value):
1117 set_config("MOZ_WEBSPEECH", webspeech)
1118 set_define("MOZ_WEBSPEECH", webspeech)
1120 # Speech API test backend
1121 # ==============================================================
1123 "--enable-webspeechtestbackend",
1125 help="{Enable|Disable} support for HTML Speech API Test Backend",
1129 @depends_if("--enable-webspeechtestbackend")
1130 def webspeech_test_backend(value):
1134 set_config("MOZ_WEBSPEECH_TEST_BACKEND", webspeech_test_backend)
1135 set_define("MOZ_WEBSPEECH_TEST_BACKEND", webspeech_test_backend)
1139 # ==============================================================
1140 @depends(target, milestone)
1141 def skia_pdf_default(target, milestone):
1142 return milestone.is_nightly and target.os != "WINNT"
1145 option("--enable-skia-pdf", default=skia_pdf_default, help="{Enable|Disable} Skia PDF")
1147 set_config("MOZ_ENABLE_SKIA_PDF", True, when="--enable-skia-pdf")
1148 set_define("MOZ_ENABLE_SKIA_PDF", True, when="--enable-skia-pdf")
1159 "--with-system-webp", help="Use system libwebp (located with pkgconfig)"
1162 system_webp = pkg_check_modules(
1163 "MOZ_WEBP", "libwebp >= 1.0.2 libwebpdemux >= 1.0.2", when="--with-system-webp"
1166 set_config("MOZ_SYSTEM_WEBP", depends(when=system_webp)(lambda: True))
1169 # Build Freetype in the tree
1170 # ==============================================================
1171 @depends(target, "--enable-skia-pdf")
1172 def tree_freetype(target, skia_pdf):
1173 if target.os == "Android" or (skia_pdf and target.os == "WINNT"):
1177 set_define("MOZ_TREE_FREETYPE", tree_freetype)
1178 set_config("MOZ_TREE_FREETYPE", tree_freetype)
1180 set_define("HAVE_FT_BITMAP_SIZE_Y_PPEM", tree_freetype)
1181 set_define("HAVE_FT_GLYPHSLOT_EMBOLDEN", tree_freetype)
1182 set_define("HAVE_FT_LOAD_SFNT_TABLE", tree_freetype)
1185 @depends(freetype2_combined_info, tree_freetype, build_environment)
1186 def ft2_info(freetype2_combined_info, tree_freetype, build_env):
1189 cflags=("-I%s/modules/freetype2/include" % build_env.topsrcdir,), libs=()
1191 if freetype2_combined_info:
1192 return freetype2_combined_info
1195 set_config("FT2_LIBS", ft2_info.libs)
1198 @depends(target, tree_freetype, freetype2_info)
1199 def enable_cairo_ft(target, tree_freetype, freetype2_info):
1200 # Avoid defining MOZ_ENABLE_CAIRO_FT on Windows platforms because
1201 # "cairo-ft-font.c" includes <dlfcn.h>, which only exists on posix platforms
1202 return freetype2_info or (tree_freetype and target.os != "WINNT")
1205 set_config("MOZ_ENABLE_CAIRO_FT", True, when=enable_cairo_ft)
1206 set_config("CAIRO_FT_CFLAGS", ft2_info.cflags, when=enable_cairo_ft)
1209 # WebDriver (HTTP / BiDi)
1210 # ==============================================================
1212 # WebDriver is a remote control interface that enables introspection and
1213 # control of user agents. It provides a platform- and language-neutral wire
1214 # protocol as a way for out-of-process programs to remotely instruct the
1215 # behavior of web browsers.
1217 # The Gecko implementation is backed by Marionette and Remote Agent.
1218 # Both protocols are not really toolkit features, as much as Gecko engine
1219 # features. But they are enabled based on the toolkit, so here it lives.
1221 # Marionette remote protocol
1222 # -----------------------------------------------------------
1224 # Marionette is the Gecko remote protocol used for various remote control,
1225 # automation, and testing purposes throughout Gecko-based applications like
1226 # Firefox, Thunderbird, and any mobile browser built upon GeckoView.
1228 # It also backs ../testing/geckodriver, which is Mozilla's WebDriver
1231 # The source of Marionette lives in ../remote/marionette.
1233 # For more information, see:
1234 # https://firefox-source-docs.mozilla.org/testing/marionette/index.html
1236 # Remote Agent (WebDriver BiDi / partial CDP)
1237 # -----------------------------------------------------------
1239 # The primary purpose is the implementation of the WebDriver BiDi specification.
1240 # But it also complements the existing Firefox Developer Tools Remote Debugging
1241 # Protocol (RDP) by implementing a subset of the Chrome DevTools Protocol (CDP).
1243 # The source of Remote Agent lives in ../remote.
1245 # For more information, see:
1246 # https://firefox-source-docs.mozilla.org/remote/index.html
1250 "--disable-webdriver",
1251 help="Disable support for WebDriver remote protocols",
1255 @depends("--disable-webdriver")
1256 def webdriver(enabled):
1261 set_config("ENABLE_WEBDRIVER", webdriver)
1262 set_define("ENABLE_WEBDRIVER", webdriver)
1265 # geckodriver WebDriver implementation
1266 # ==============================================================
1268 # Turn off geckodriver for build configs we don't handle yet,
1269 # but allow --enable-geckodriver to override when compile environment is available.
1270 # --disable-tests implies disabling geckodriver.
1271 # Disable building in CI
1275 "--enable-tests", target, cross_compiling, hazard_analysis, asan, "MOZ_AUTOMATION"
1277 def geckodriver_default(enable_tests, target, cross_compile, hazard, asan, automation):
1278 if not enable_tests:
1280 if hazard or target.os == "Android" or (asan and cross_compile):
1288 "--enable-geckodriver",
1289 default=geckodriver_default,
1290 when="--enable-compile-environment",
1291 help="{Build|Do not build} geckodriver",
1295 @depends("--enable-geckodriver", when="--enable-compile-environment")
1296 def geckodriver(enabled):
1301 set_config("MOZ_GECKODRIVER", geckodriver)
1305 # ========================================================
1307 def webrtc_default(target):
1308 # Turn off webrtc for OS's we don't handle yet, but allow
1309 # --enable-webrtc to override.
1310 os_match = target.kernel in (
1321 os_match = target.os in ("OSX",)
1323 cpu_match = target.cpu in (
1336 return os_match and cpu_match and target.endianness == "little"
1341 default=webrtc_default,
1342 help="{Enable|Disable} support for WebRTC",
1346 @depends("--disable-webrtc")
1347 def webrtc(enabled):
1352 set_config("MOZ_WEBRTC", webrtc)
1353 set_define("MOZ_WEBRTC", webrtc)
1354 set_config("MOZ_SCTP", webrtc)
1355 set_define("MOZ_SCTP", webrtc)
1356 set_config("MOZ_SRTP", webrtc)
1357 set_define("MOZ_SRTP", webrtc)
1358 set_config("MOZ_WEBRTC_SIGNALING", webrtc)
1359 set_define("MOZ_WEBRTC_SIGNALING", webrtc)
1360 set_config("MOZ_PEERCONNECTION", webrtc)
1361 set_define("MOZ_PEERCONNECTION", webrtc)
1362 # MOZ_WEBRTC_ASSERT_ALWAYS turns on a number of safety asserts in
1363 # opt/production builds (via MOZ_CRASH())
1364 set_config("MOZ_WEBRTC_ASSERT_ALWAYS", webrtc)
1365 set_define("MOZ_WEBRTC_ASSERT_ALWAYS", webrtc)
1368 # ==============================================================
1371 @depends(target, webrtc)
1372 def raw_media_default(target, webrtc):
1373 if target.os == "Android":
1381 default=raw_media_default,
1382 help="{Enable|Disable} support for RAW media",
1385 set_config("MOZ_RAW", depends_if("--enable-raw")(lambda _: True))
1386 set_define("MOZ_RAW", depends_if("--enable-raw")(lambda _: True))
1390 # ==============================================================
1391 @depends(webrtc, when=toolkit_gtk)
1392 def x11_libs(webrtc):
1402 # third_party/libwebrtc/webrtc/webrtc_gn/moz.build adds those
1403 # manually, ensure they're available.
1414 x11_headers = pkg_check_modules(
1417 allow_missing=toolkit_gtk_x11_optional,
1418 when=toolkit_gtk_x11,
1422 set_config("MOZ_X11", True, when=x11_headers)
1423 set_define("MOZ_X11", True, when=x11_headers)
1429 allow_missing=toolkit_gtk_x11_optional,
1430 when=toolkit_gtk_x11,
1434 # ASan Reporter Addon
1435 # ==============================================================
1437 "--enable-address-sanitizer-reporter",
1438 help="Enable Address Sanitizer Reporter Extension",
1442 @depends("--enable-address-sanitizer-reporter")
1443 def enable_asan_reporter(value):
1448 set_config("MOZ_ASAN_REPORTER", enable_asan_reporter)
1449 set_define("MOZ_ASAN_REPORTER", enable_asan_reporter)
1451 # Checks for library functions
1452 # ==============================================================
1453 with only_when(compile_environment & depends(target.os)(lambda os: os != "WINNT")):
1454 set_define("HAVE_STAT64", check_symbol("stat64"))
1455 set_define("HAVE_LSTAT64", check_symbol("lstat64"))
1456 set_define("HAVE_TRUNCATE64", check_symbol("truncate64"))
1457 set_define("HAVE_STATVFS64", check_symbol("statvfs64"))
1458 set_define("HAVE_STATVFS", check_symbol("statvfs"))
1459 set_define("HAVE_STATFS64", check_symbol("statfs64"))
1460 set_define("HAVE_STATFS", check_symbol("statfs"))
1461 set_define("HAVE_LUTIMES", check_symbol("lutimes"))
1462 set_define("HAVE_POSIX_FADVISE", check_symbol("posix_fadvise"))
1463 set_define("HAVE_POSIX_FALLOCATE", check_symbol("posix_fallocate"))
1464 set_define("HAVE_EVENTFD", check_symbol("eventfd"))
1466 have_arc4random = check_symbol("arc4random")
1467 set_define("HAVE_ARC4RANDOM", have_arc4random)
1468 set_define("HAVE_ARC4RANDOM_BUF", check_symbol("arc4random_buf"))
1469 set_define("HAVE_MALLINFO", check_symbol("mallinfo"))
1471 # Checks for headers
1472 # ==============================================================
1473 with only_when(compile_environment & depends(target.os)(lambda os: os != "WINNT")):
1474 set_define("HAVE_SYSIOCCOM_H", check_header("sys/ioccom.h"))
1477 # ==============================================================
1478 with only_when("--enable-compile-environment"):
1480 @depends(host, target)
1481 def has_elfhack(host, target):
1483 target.kernel == "Linux"
1484 and host.kernel == "Linux"
1485 and target.cpu in ("arm", "aarch64", "x86", "x86_64")
1489 "--disable-elf-hack",
1491 choices=("legacy", "relr"),
1492 help="{Enable|Disable} elf hacks",
1496 @depends("--enable-elf-hack", when=has_elfhack)
1497 def may_enable_legacy_elfhack(enable):
1498 if enable and enable != ("relr",):
1501 @depends("--enable-elf-hack", "MOZ_AUTOMATION", when=has_elfhack)
1502 def may_enable_relrhack(enable, automation):
1503 # For now, only enable relrhack when explicitly given with
1504 # --enable-elf-hack=relr. On automation, we automatically
1505 # enable it when possible.
1506 if automation and enable and enable != ("legacy",):
1508 if enable == ("relr",):
1514 when=target_has_linux_kernel,
1516 def may_use_pack_relative_relocs(have_arc4random, android_version):
1517 # Packed relative relocations are only supported on Android since
1518 # version 11 (API 30), and in glibc since version 2.36.
1519 # glibc 2.36 also added the arc4random function, which is our proxy
1520 # to detect this (or newer) version being used.
1521 # When targetting those newer versions, we allow ourselves to use
1522 # packed relative relocations rather than elfhack.
1524 return android_version >= 30
1525 return have_arc4random
1529 extra_toolchain_flags,
1532 when=may_use_pack_relative_relocs | may_enable_relrhack,
1534 @checking("for -z pack-relative-relocs option to ld", bool)
1535 @imports(_from="__builtin__", _import="FileNotFoundError")
1537 @imports(_from="tempfile", _import="mkstemp")
1538 @imports("textwrap")
1539 def has_pack_relative_relocs(
1541 extra_toolchain_flags,
1546 fd, path = mkstemp(prefix="conftest.")
1549 pack_rel_relocs = ["-Wl,-z,pack-relative-relocs"]
1551 try_invoke_compiler(
1552 # No configure_cache because it would not create the
1553 # expected output file.
1555 [c_compiler.compiler] + c_compiler.flags,
1556 c_compiler.language,
1557 # The resulting binary is expected to have relative
1558 # relocations, the `ptr` variable attempts to ensure
1559 # there is at least one. This requires the executable
1560 # being built as position independent.
1561 "int main() { return 0; }\nint (*ptr)() = main;",
1563 + ["-pie", "-o", path]
1564 + (extra_toolchain_flags or [])
1566 wrapper=c_compiler.wrapper,
1567 onerror=lambda: None,
1571 # BFD ld ignores options it doesn't understand. So check
1572 # that we did get packed relative relocations (DT_RELR).
1573 env = os.environ.copy()
1575 dyn = check_cmd_output(readelf, "-d", path, env=env).splitlines()
1577 int(l.split()[0], 16) for l in dyn if l.strip().startswith("0x")
1579 # Older versions of readelf don't know about DT_RELR but will
1580 # still display the tag number.
1582 needed = [l for l in dyn if l.split()[1:2] == ["(NEEDED)"]]
1583 is_glibc = any(l.endswith("[libc.so.6]") for l in needed)
1584 # The mold linker doesn't add a GLIBC_ABI_DT_RELR version
1585 # dependency, which ld.so doesn't like.
1586 # https://github.com/rui314/mold/issues/653#issuecomment-1670274638
1588 versions = check_cmd_output(readelf, "-V", path, env=env)
1589 if "GLIBC_ABI_DT_RELR" in versions.split():
1590 return pack_rel_relocs
1592 return pack_rel_relocs
1596 except FileNotFoundError:
1600 has_pack_relative_relocs,
1601 may_enable_legacy_elfhack,
1602 may_enable_relrhack,
1603 may_use_pack_relative_relocs,
1604 when=has_pack_relative_relocs,
1606 def pack_relative_relocs_flags(
1608 may_enable_legacy_elfhack,
1609 may_enable_relrhack,
1610 may_use_pack_relative_relocs,
1612 # When relrhack is enabled, we don't pass the flag to the linker because
1613 # relrhack will take care of it.
1614 if may_enable_relrhack and may_enable_relrhack.origin != "default":
1616 # if elfhack is explicitly enabled instead of relrhack, we prioritize it
1617 # over packed relative relocs.
1618 if may_enable_legacy_elfhack and may_enable_legacy_elfhack.origin != "default":
1620 if may_use_pack_relative_relocs:
1623 add_old_configure_assignment("PACK_REL_RELOC_FLAGS", pack_relative_relocs_flags)
1627 pack_relative_relocs_flags,
1628 has_pack_relative_relocs,
1629 may_enable_legacy_elfhack,
1630 may_enable_relrhack,
1635 pack_relative_relocs_flags,
1636 has_pack_relative_relocs,
1637 may_enable_legacy_elfhack,
1638 may_enable_relrhack,
1640 if pack_relative_relocs_flags:
1642 if may_enable_relrhack:
1643 if has_pack_relative_relocs:
1646 may_enable_relrhack.origin != "default"
1647 and not may_enable_legacy_elfhack
1650 "Cannot enable relrhack without linker support for -z pack-relative-relocs"
1652 if may_enable_legacy_elfhack:
1653 if linker and linker.KIND in ("lld", "mold"):
1654 if may_enable_legacy_elfhack.origin != "default":
1656 f"Cannot enable elfhack with {linker.KIND}."
1657 " Use --enable-linker=bfd, --enable-linker=gold, or --disable-elf-hack"
1663 "USE_ELF_HACK", True, when=depends(which_elf_hack)(lambda x: x == "legacy")
1666 use_relrhack = depends(which_elf_hack)(lambda x: x == "relr")
1667 set_config("RELRHACK", True, when=use_relrhack)
1669 @depends(c_compiler, linker_ldflags, when=use_relrhack)
1670 def relrhack_real_linker(c_compiler, linker_ldflags):
1672 for flag in linker_ldflags:
1673 if flag.startswith("-fuse-ld="):
1674 ld = "ld." + flag[len("-fuse-ld=") :]
1675 ld = check_cmd_output(
1676 c_compiler.compiler, f"--print-prog-name={ld}", *c_compiler.flags
1680 @depends(relrhack_real_linker, when=use_relrhack)
1681 def relrhack_linker(ld):
1682 return os.path.basename(ld)
1684 set_config("RELRHACK_LINKER", relrhack_linker)
1686 std_filesystem = host_cxx_compiler.try_run(
1687 header="#include <filesystem>",
1688 body='auto foo = std::filesystem::absolute("");',
1689 flags=host_linker_ldflags,
1691 onerror=lambda: None,
1694 stdcxxfs = host_cxx_compiler.try_run(
1695 header="#include <filesystem>",
1696 body='auto foo = std::filesystem::absolute("");',
1697 flags=depends(host_linker_ldflags)(
1698 lambda flags: (flags or []) + ["-lstdc++fs"]
1700 check_msg="whether std::filesystem requires -lstdc++fs",
1701 when=use_relrhack & depends(std_filesystem)(lambda x: not x),
1702 onerror=lambda: None,
1705 set_config("RELRHACK_LIBS", ["stdc++fs"], when=stdcxxfs)
1707 @depends(build_environment, relrhack_real_linker, when=use_relrhack)
1708 def relrhack_ldflags(build_env, ld):
1711 os.path.join(build_env.topobjdir, "build", "unix", "elfhack"),
1713 if os.path.basename(ld) != ld:
1714 flags.append(f"-Wl,--real-linker,{ld}")
1717 set_config("RELRHACK_LDFLAGS", relrhack_ldflags)
1720 @depends(build_environment)
1721 def idl_roots(build_env):
1723 ipdl_root=os.path.join(build_env.topobjdir, "ipc", "ipdl"),
1724 webidl_root=os.path.join(build_env.topobjdir, "dom", "bindings"),
1725 xpcom_root=os.path.join(build_env.topobjdir, "xpcom", "components"),
1729 set_config("WEBIDL_ROOT", idl_roots.webidl_root)
1730 set_config("IPDL_ROOT", idl_roots.ipdl_root)
1731 set_config("XPCOM_ROOT", idl_roots.xpcom_root)
1733 # Proxy bypass protection
1734 # ==============================================================
1737 "--enable-proxy-bypass-protection",
1738 help="Prevent suspected or confirmed proxy bypasses",
1742 @depends_if("--enable-proxy-bypass-protection")
1743 def proxy_bypass_protection(_):
1747 set_config("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1748 set_define("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1750 # Proxy direct failover
1751 # ==============================================================
1754 "--disable-proxy-direct-failover",
1755 help="Disable direct failover for system requests",
1759 @depends_if("--disable-proxy-direct-failover")
1760 def proxy_direct_failover(value):
1765 set_config("MOZ_PROXY_DIRECT_FAILOVER", proxy_direct_failover)
1766 set_define("MOZ_PROXY_DIRECT_FAILOVER", proxy_direct_failover)
1769 # ==============================================================
1772 @depends(c_compiler, toolchain_prefix)
1773 def midl_names(c_compiler, toolchain_prefix):
1774 if c_compiler and c_compiler.type in ["gcc", "clang"]:
1777 if toolchain_prefix:
1778 prefixed = tuple("%s%s" % (p, "widl") for p in toolchain_prefix)
1779 widl = prefixed + widl
1782 return ("midl.exe",)
1785 @depends(target, "--enable-compile-environment")
1786 def check_for_midl(target, compile_environment):
1787 if target.os != "WINNT":
1790 if compile_environment:
1797 when=check_for_midl,
1800 # MIDL being used from a python wrapper script, we can live with it
1805 option(env="MIDL_FLAGS", nargs=1, help="Extra flags to pass to MIDL")
1812 when=depends(midl, target)(lambda m, t: m and t.kernel == "WINNT"),
1814 def midl_flags(flags, target, midl):
1816 flags = flags[0].split()
1820 if not midl.endswith("widl"):
1826 return flags + ["-nologo", "-no_cpp", "-env", env]
1832 "x86": ["--win32", "-m32"],
1833 "x86_64": ["--win64", "-m64"],
1838 set_config("MIDL_FLAGS", midl_flags)
1841 # ==============================================================
1843 option("--disable-accessibility", help="Disable accessibility support")
1846 @depends("--enable-accessibility", check_for_midl, midl, c_compiler)
1847 def accessibility(value, check_for_midl, midl, c_compiler):
1848 enabled = bool(value)
1853 if check_for_midl and not midl:
1854 if c_compiler and c_compiler.type in ("gcc", "clang"):
1856 "You have accessibility enabled, but widl could not be found. "
1857 "Add --disable-accessibility to your mozconfig or install widl. "
1858 "See https://developer.mozilla.org/en-US/docs/Cross_Compile_Mozilla_for_Mingw32 for details."
1862 "MIDL could not be found. "
1863 "Building accessibility without MIDL is not supported."
1869 set_config("ACCESSIBILITY", accessibility)
1870 set_define("ACCESSIBILITY", accessibility)
1873 @depends(moz_debug, developer_options)
1874 def a11y_log(debug, developer_options):
1875 return debug or developer_options
1878 set_config("A11Y_LOG", True, when=a11y_log)
1879 set_define("A11Y_LOG", True, when=a11y_log)
1883 # ==============================================================
1885 def require_signing(milestone):
1886 return milestone.is_release_or_beta and not milestone.is_esr
1890 env="MOZ_REQUIRE_SIGNING",
1891 default=require_signing,
1892 help="Enforce that add-ons are signed by the trusted root",
1895 set_config("MOZ_REQUIRE_SIGNING", True, when="MOZ_REQUIRE_SIGNING")
1896 set_define("MOZ_REQUIRE_SIGNING", True, when="MOZ_REQUIRE_SIGNING")
1899 "--with-unsigned-addon-scopes",
1901 choices=("app", "system"),
1902 help="Addon scopes where signature is not required",
1906 @depends("--with-unsigned-addon-scopes")
1907 def unsigned_addon_scopes(scopes):
1909 app="app" in scopes or None,
1910 system="system" in scopes or None,
1914 set_config("MOZ_UNSIGNED_APP_SCOPE", unsigned_addon_scopes.app)
1915 set_config("MOZ_UNSIGNED_SYSTEM_SCOPE", unsigned_addon_scopes.system)
1919 # ==============================================================
1921 "--allow-addon-sideload",
1922 default=milestone.is_esr,
1923 help="Addon sideloading is allowed",
1927 set_config("MOZ_ALLOW_ADDON_SIDELOAD", True, when="--allow-addon-sideload")
1929 # WebExtensions API WebIDL bindings
1930 # ==============================================================
1934 def extensions_webidl_bindings_default(milestone):
1935 # Only enable the webidl bindings for the WebExtensions APIs
1937 return milestone.is_nightly
1941 "--enable-extensions-webidl-bindings",
1942 default=extensions_webidl_bindings_default,
1943 help="{Enable|Disable} building experimental WebExtensions WebIDL bindings",
1947 @depends("--enable-extensions-webidl-bindings")
1948 def extensions_webidl_enabled(value):
1952 set_config("MOZ_WEBEXT_WEBIDL_ENABLED", extensions_webidl_enabled)
1954 # Launcher process (Windows only)
1955 # ==============================================================
1959 def launcher_process_default(target):
1960 return target.os == "WINNT"
1964 "--enable-launcher-process",
1965 default=launcher_process_default,
1966 help="{Enable|Disable} launcher process by default",
1970 @depends("--enable-launcher-process", target)
1971 def launcher(value, target):
1972 enabled = bool(value)
1973 if enabled and target.os != "WINNT":
1974 die("Cannot enable launcher process on %s", target.os)
1979 set_config("MOZ_LAUNCHER_PROCESS", launcher)
1980 set_define("MOZ_LAUNCHER_PROCESS", launcher)
1982 # llvm-dlltool (Windows only)
1983 # ==============================================================
1986 @depends(build_project, target, "--enable-compile-environment")
1987 def check_for_llvm_dlltool(build_project, target, compile_environment):
1988 if build_project != "browser":
1991 if target.os != "WINNT":
1994 return compile_environment
1997 llvm_dlltool = check_prog(
2000 what="llvm-dlltool",
2001 when=check_for_llvm_dlltool,
2002 paths=clang_search_path,
2006 @depends(target, when=llvm_dlltool)
2007 def llvm_dlltool_flags(target):
2010 "x86_64": "i386:x86-64",
2017 set_config("LLVM_DLLTOOL_FLAGS", llvm_dlltool_flags)
2019 # BITS download (Windows only)
2020 # ==============================================================
2023 "--enable-bits-download",
2024 when=target_is_windows,
2025 default=target_is_windows,
2026 help="{Enable|Disable} building BITS download support",
2030 "MOZ_BITS_DOWNLOAD",
2031 depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
2034 "MOZ_BITS_DOWNLOAD",
2035 depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
2038 # Bundled fonts on desktop platform
2039 # ==============================================================
2043 def bundled_fonts_default(target):
2044 return target.os == "WINNT" or target.kernel == "Linux"
2047 @depends(build_project)
2048 def allow_bundled_fonts(project):
2049 return project == "browser" or project == "comm/mail"
2053 "--enable-bundled-fonts",
2054 default=bundled_fonts_default,
2055 when=allow_bundled_fonts,
2056 help="{Enable|Disable} support for bundled fonts on desktop platforms",
2060 "MOZ_BUNDLED_FONTS",
2061 depends_if("--enable-bundled-fonts", when=allow_bundled_fonts)(lambda _: True),
2065 # ==============================================================
2069 def reflow_perf(debug):
2075 "--enable-reflow-perf",
2076 default=reflow_perf,
2077 help="{Enable|Disable} reflow performance tracing",
2080 # The difference in conditions here comes from the initial implementation
2081 # in old-configure, which was unexplained there as well.
2082 set_define("MOZ_REFLOW_PERF", depends_if("--enable-reflow-perf")(lambda _: True))
2083 set_define("MOZ_REFLOW_PERF_DSP", reflow_perf)
2086 # ==============================================================
2090 def layout_debugger(debug):
2096 "--enable-layout-debugger",
2097 default=layout_debugger,
2098 help="{Enable|Disable} layout debugger",
2101 set_config("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
2102 set_define("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
2105 # Shader Compiler for Windows (and MinGW Cross Compile)
2106 # ==============================================================
2108 with only_when(compile_environment):
2111 ("fxc.exe", "fxc2.exe"),
2112 when=depends(target)(lambda t: t.kernel == "WINNT"),
2114 # FXC being used from a python wrapper script, we can live with it
2123 with only_when(compile_environment):
2125 "--with-system-libvpx", help="Use system libvpx (located with pkgconfig)"
2128 with only_when("--with-system-libvpx"):
2129 vpx = pkg_check_modules("MOZ_LIBVPX", "vpx >= 1.10.0")
2132 "vpx/vpx_decoder.h",
2134 onerror=lambda: die(
2135 "Couldn't find vpx/vpx_decoder.h, which is required to build "
2136 "with system libvpx. Use --without-system-libvpx to build "
2137 "with in-tree libvpx."
2142 "vpx_codec_dec_init_ver",
2144 onerror=lambda: die(
2145 "--with-system-libvpx requested but symbol vpx_codec_dec_init_ver "
2150 set_config("MOZ_SYSTEM_LIBVPX", True)
2152 @depends("--with-system-libvpx", target)
2153 def in_tree_vpx(system_libvpx, target):
2157 arm_asm = (target.cpu == "arm") or None
2158 return namespace(arm_asm=arm_asm)
2160 @depends(target, when=in_tree_vpx)
2161 def vpx_nasm(target):
2162 if target.cpu in ("x86", "x86_64"):
2163 if target.kernel == "WINNT":
2164 # Version 2.03 is needed for automatic safeseh support.
2165 return namespace(version="2.03", what="VPX")
2166 return namespace(what="VPX")
2168 @depends(in_tree_vpx, vpx_nasm, target, neon_flags)
2169 def vpx_as_flags(vpx, vpx_nasm, target, neon_flags):
2170 if vpx and vpx.arm_asm:
2171 # These flags are a lie; they're just used to enable the requisite
2172 # opcodes; actual arch detection is done at runtime.
2174 elif vpx and vpx_nasm and target.os != "WINNT" and target.cpu != "x86_64":
2177 set_config("VPX_USE_NASM", True, when=vpx_nasm)
2178 set_config("VPX_ASFLAGS", vpx_as_flags)
2184 with only_when(compile_environment):
2186 "--with-system-jpeg",
2188 help="Use system libjpeg (installed at given prefix)",
2191 @depends_if("--with-system-jpeg")
2192 def jpeg_flags(value):
2195 cflags=("-I%s/include" % value[0],),
2196 ldflags=("-L%s/lib" % value[0], "-ljpeg"),
2199 ldflags=("-ljpeg",),
2202 with only_when("--with-system-jpeg"):
2204 "jpeg_destroy_compress",
2205 flags=jpeg_flags.ldflags,
2206 onerror=lambda: die(
2207 "--with-system-jpeg requested but symbol "
2208 "jpeg_destroy_compress not found."
2212 c_compiler.try_compile(
2219 #if JPEG_LIB_VERSION < 62
2220 #error Insufficient JPEG library version
2223 flags=jpeg_flags.cflags,
2224 check_msg="for sufficient jpeg library version",
2225 onerror=lambda: die(
2226 "Insufficient JPEG library version for "
2227 "--with-system-jpeg (62 required)"
2231 c_compiler.try_compile(
2238 #ifndef JCS_EXTENSIONS
2239 #error libjpeg-turbo JCS_EXTENSIONS required
2242 flags=jpeg_flags.cflags,
2243 check_msg="for sufficient libjpeg-turbo JCS_EXTENSIONS",
2244 onerror=lambda: die(
2245 "libjpeg-turbo JCS_EXTENSIONS required for " "--with-system-jpeg"
2249 set_config("MOZ_JPEG_CFLAGS", jpeg_flags.cflags)
2250 set_config("MOZ_JPEG_LIBS", jpeg_flags.ldflags)
2252 @depends("--with-system-jpeg", target, neon_flags)
2253 def in_tree_jpeg_arm(system_jpeg, target, neon_flags):
2257 if target.cpu == "arm":
2259 elif target.cpu == "aarch64":
2260 return ("-march=armv8-a",)
2262 @depends("--with-system-jpeg", target)
2263 def in_tree_jpeg_mips64(system_jpeg, target):
2267 if target.cpu == "mips64":
2268 return ("-Wa,-mloongson-mmi", "-mloongson-ext")
2270 # Compiler check from https://github.com/libjpeg-turbo/libjpeg-turbo/blob/57ba02a408a9a55ccff25aae8b164632a3a4f177/simd/CMakeLists.txt#L419
2271 jpeg_mips64_mmi = c_compiler.try_compile(
2272 body='int c = 0, a = 0, b = 0; asm("paddb %0, %1, %2" : "=f" (c) : "f" (a), "f" (b));',
2273 check_msg="for loongson mmi support",
2274 flags=in_tree_jpeg_mips64,
2275 when=in_tree_jpeg_mips64,
2279 "--with-system-jpeg",
2282 in_tree_jpeg_mips64,
2286 system_jpeg, target, in_tree_jpeg_arm, in_tree_jpeg_mips64, jpeg_mips64_mmi
2291 if target.cpu in ("arm", "aarch64"):
2292 return in_tree_jpeg_arm
2293 elif target.kernel == "Darwin":
2294 if target.cpu == "x86":
2295 return ("-DPIC", "-DMACHO")
2296 elif target.cpu == "x86_64":
2297 return ("-D__x86_64__", "-DPIC", "-DMACHO")
2298 elif target.kernel == "WINNT":
2299 if target.cpu == "x86":
2300 return ("-DPIC", "-DWIN32")
2301 elif target.cpu == "x86_64":
2302 return ("-D__x86_64__", "-DPIC", "-DWIN64", "-DMSVC")
2303 elif target.cpu == "mips32":
2305 elif target.cpu == "mips64" and jpeg_mips64_mmi:
2306 return in_tree_jpeg_mips64
2307 elif target.cpu == "x86":
2308 return ("-DPIC", "-DELF")
2309 elif target.cpu == "x86_64":
2310 return ("-D__x86_64__", "-DPIC", "-DELF")
2312 @depends(target, when=depends("--with-system-jpeg")(lambda x: not x))
2313 def jpeg_nasm(target):
2314 if target.cpu in ("x86", "x86_64"):
2315 # libjpeg-turbo 2.0.6 requires nasm 2.10.
2316 return namespace(version="2.10", what="JPEG")
2318 # Compiler checks from https://github.com/libjpeg-turbo/libjpeg-turbo/blob/57ba02a408a9a55ccff25aae8b164632a3a4f177/simd/CMakeLists.txt#L258
2319 jpeg_arm_neon_vld1_s16_x3 = c_compiler.try_compile(
2320 includes=["arm_neon.h"],
2321 body="int16_t input[12] = {}; int16x4x3_t output = vld1_s16_x3(input);",
2322 check_msg="for vld1_s16_x3 in arm_neon.h",
2323 flags=in_tree_jpeg_arm,
2324 when=in_tree_jpeg_arm,
2327 jpeg_arm_neon_vld1_u16_x2 = c_compiler.try_compile(
2328 includes=["arm_neon.h"],
2329 body="uint16_t input[8] = {}; uint16x4x2_t output = vld1_u16_x2(input);",
2330 check_msg="for vld1_u16_x2 in arm_neon.h",
2331 flags=in_tree_jpeg_arm,
2332 when=in_tree_jpeg_arm,
2335 jpeg_arm_neon_vld1q_u8_x4 = c_compiler.try_compile(
2336 includes=["arm_neon.h"],
2337 body="uint8_t input[64] = {}; uint8x16x4_t output = vld1q_u8_x4(input);",
2338 check_msg="for vld1q_u8_x4 in arm_neon.h",
2339 flags=in_tree_jpeg_arm,
2340 when=in_tree_jpeg_arm,
2343 set_config("LIBJPEG_TURBO_USE_NASM", True, when=jpeg_nasm)
2344 set_config("LIBJPEG_TURBO_SIMD_FLAGS", in_tree_jpeg)
2345 set_config("LIBJPEG_TURBO_HAVE_VLD1_S16_X3", jpeg_arm_neon_vld1_s16_x3)
2346 set_config("LIBJPEG_TURBO_HAVE_VLD1_U16_X2", jpeg_arm_neon_vld1_u16_x2)
2347 set_config("LIBJPEG_TURBO_HAVE_VLD1Q_U8_X4", jpeg_arm_neon_vld1q_u8_x4)
2349 "LIBJPEG_TURBO_NEON_INTRINSICS",
2350 jpeg_arm_neon_vld1_s16_x3
2351 & jpeg_arm_neon_vld1_u16_x2
2352 & jpeg_arm_neon_vld1q_u8_x4,
2358 with only_when(compile_environment):
2360 "--with-system-png",
2362 help="Use system libpng",
2365 @depends("--with-system-png")
2366 def deprecated_system_png_path(value):
2369 "--with-system-png=PATH is not supported anymore. Please use "
2370 "--with-system-png and set any necessary pkg-config environment variable."
2373 png = pkg_check_modules("MOZ_PNG", "libpng >= 1.6.35", when="--with-system-png")
2378 onerror=lambda: die(
2379 "--with-system-png won't work because the system's libpng doesn't have APNG support"
2381 when="--with-system-png",
2384 set_config("MOZ_SYSTEM_PNG", True, when="--with-system-png")
2387 # FFmpeg's ffvpx configuration
2388 # ==============================================================
2389 with only_when(compile_environment):
2392 def libav_fft(target):
2393 if target.os == "Android" and target.cpu != "arm":
2395 return target.kernel in ("WINNT", "Darwin") or target.cpu == "x86_64"
2397 set_config("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
2398 set_define("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
2401 # Artifact builds need MOZ_FFVPX defined as if compilation happened.
2402 with only_when(compile_environment | artifact_builds):
2406 enable = use_nasm = True
2410 if target.kernel == "WINNT":
2411 if target.cpu == "x86":
2412 # 32-bit windows need to prefix symbols with an underscore.
2413 flags = ["-DPIC", "-DWIN32", "-DPREFIX", "-Pconfig_win32.asm"]
2414 elif target.cpu == "x86_64":
2420 "-Pconfig_win64.asm",
2422 elif target.cpu == "aarch64":
2423 flags = ["-DPIC", "-DWIN64"]
2425 elif target.kernel == "Darwin":
2426 # 32/64-bit macosx assemblers need to prefix symbols with an
2428 flags = ["-DPIC", "-DMACHO", "-DPREFIX"]
2429 if target.cpu == "x86_64":
2432 "-Pconfig_darwin64.asm",
2434 elif target.cpu == "aarch64":
2436 elif target.cpu == "x86_64":
2437 flags = ["-D__x86_64__", "-DPIC", "-DELF", "-Pconfig_unix64.asm"]
2438 elif target.cpu in ("x86", "arm", "aarch64"):
2443 if flac_only or not enable:
2449 flac_only=flac_only,
2453 @depends(when=ffvpx.use_nasm)
2455 # nasm 2.10 for AVX-2 support.
2456 return namespace(version="2.10", what="FFVPX")
2458 # ffvpx_nasm can't indirectly depend on vpx_as_flags, because it depends
2459 # on a compiler test, so we have to do a little bit of dance here.
2460 @depends(ffvpx, vpx_as_flags, target)
2461 def ffvpx(ffvpx, vpx_as_flags, target):
2462 if ffvpx and vpx_as_flags and target.cpu in ("arm", "aarch64"):
2463 ffvpx.flags.extend(vpx_as_flags)
2466 set_config("MOZ_FFVPX", True, when=ffvpx.enable)
2467 set_define("MOZ_FFVPX", True, when=ffvpx.enable)
2468 set_config("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.flac_only)
2469 set_define("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.flac_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 ("OSX", "x86"): ["-f", "macho32"],
2533 ("OSX", "x86_64"): ["-f", "macho64"],
2534 ("WINNT", "x86"): ["-f", "win32"],
2535 ("WINNT", "x86_64"): ["-f", "win64"],
2536 }.get((target.os, 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.kernel in ("WINNT", "Darwin"):
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")
3184 pkg_check_modules("MOZ_DBUS_GLIB", "dbus-glib-1 >= 0.60")
3186 set_config("MOZ_ENABLE_DBUS", True)
3187 set_define("MOZ_ENABLE_DBUS", True)
3190 # Necko's wifi scanner
3191 # ==============================================================
3193 def necko_wifi_when(target):
3194 return target.os in ("WINNT", "OSX", "DragonFly", "FreeBSD") or (
3195 target.kernel == "Linux" and target.os == "GNU"
3199 option("--disable-necko-wifi", help="Disable necko wifi scanner", when=necko_wifi_when)
3201 set_config("NECKO_WIFI", True, when="--enable-necko-wifi")
3202 set_define("NECKO_WIFI", True, when="--enable-necko-wifi")
3206 depends("--enable-necko-wifi", when=necko_wifi_when)(lambda x: x),
3207 depends("--enable-dbus", when=toolkit_gtk)(lambda x: x),
3208 when=depends(target)(lambda t: t.os == "GNU" and t.kernel == "Linux"),
3210 def necko_wifi_dbus(necko_wifi, dbus):
3211 if necko_wifi and not dbus:
3213 "Necko WiFi scanning needs DBus on your platform, remove --disable-dbus"
3214 " or use --disable-necko-wifi"
3216 return necko_wifi and dbus
3219 set_config("NECKO_WIFI_DBUS", True, when=necko_wifi_dbus)
3220 set_define("NECKO_WIFI_DBUS", True, when=necko_wifi_dbus)
3223 # Frontend JS debug mode
3224 # ==============================================================
3225 option("--enable-debug-js-modules", help="Enable debug mode for frontend JS libraries")
3227 set_config("DEBUG_JS_MODULES", True, when="--enable-debug-js-modules")
3231 # ==============================================================
3232 option("--enable-dump-painting", help="Enable paint debugging")
3235 "MOZ_DUMP_PAINTING",
3237 when=depends("--enable-dump-painting", "--enable-debug")(
3238 lambda painting, debug: painting or debug
3241 set_define("MOZ_LAYERS_HAVE_LOG", True, when="--enable-dump-painting")
3245 # ==============================================================
3246 with only_when(toolkit_gtk):
3247 system_lib_option("--enable-libproxy", help="Enable libproxy support")
3249 with only_when("--enable-libproxy"):
3250 pkg_check_modules("MOZ_LIBPROXY", "libproxy-1.0")
3252 set_config("MOZ_ENABLE_LIBPROXY", True)
3253 set_define("MOZ_ENABLE_LIBPROXY", True)
3256 # Enable runtime logging
3257 # ==============================================================
3258 set_define("MOZ_LOGGING", True)
3259 set_define("FORCE_PR_LOG", True)
3261 # This will enable logging of addref, release, ctor, dtor.
3262 # ==============================================================
3264 "--enable-logrefcnt",
3266 help="{Enable|Disable} logging of refcounts",
3269 set_define("NS_BUILD_REFCNT_LOGGING", True, when="--enable-logrefcnt")
3273 # ==============================================================
3274 option("--disable-negotiateauth", help="Disable GSS-API negotiation")
3276 set_config("MOZ_AUTH_EXTENSION", True, when="--enable-negotiateauth")
3277 set_define("MOZ_AUTH_EXTENSION", True, when="--enable-negotiateauth")
3281 # ==============================================================
3282 option("--disable-parental-controls", help="Do not build parental controls")
3285 "MOZ_DISABLE_PARENTAL_CONTROLS",
3287 when=depends("--enable-parental-controls")(lambda x: not x),
3290 "MOZ_DISABLE_PARENTAL_CONTROLS",
3292 when=depends("--enable-parental-controls")(lambda x: not x),
3296 # Sandboxing support
3297 # ==============================================================
3298 @depends(target, tsan, asan)
3299 def sandbox_default(target, tsan, asan):
3300 # Only enable the sandbox by default on Linux, OpenBSD, macOS, and Windows
3301 if target.kernel == "Linux" and target.os == "GNU":
3302 # Bug 1182565: TSan conflicts with sandboxing on Linux.
3303 # Bug 1287971: LSan also conflicts with sandboxing on Linux.
3306 # Linux sandbox is only available on x86{,_64} and arm{,64}.
3307 return target.cpu in ("x86", "x86_64", "arm", "aarch64")
3308 return target.kernel in ("WINNT", "Darwin", "OpenBSD")
3313 default=sandbox_default,
3314 help="{Enable|Disable} sandboxing support",
3317 set_config("MOZ_SANDBOX", True, when="--enable-sandbox")
3318 set_define("MOZ_SANDBOX", True, when="--enable-sandbox")
3320 with only_when(depends(target.kernel)(lambda k: k not in ("Darwin", "WINNT"))):
3321 set_define("MOZ_CONTENT_TEMP_DIR", True, when="--enable-sandbox")
3323 # Searching of system directories for extensions.
3324 # ==============================================================
3325 # Note: this switch is meant to be used for test builds whose behavior should
3326 # not depend on what happens to be installed on the local machine.
3328 "--disable-system-extension-dirs",
3329 help="Disable searching system- and account-global directories for extensions"
3330 " of any kind; use only profile-specific extension directories",
3333 set_define("ENABLE_SYSTEM_EXTENSION_DIRS", True, when="--enable-system-extension-dirs")
3337 # ==============================================================
3338 with only_when(compile_environment):
3340 "--enable-system-pixman", help="Use system pixman (located with pkgconfig)"
3343 @depends("--enable-system-pixman")
3344 def in_tree_pixman(pixman):
3347 set_config("MOZ_TREE_PIXMAN", True, when=in_tree_pixman)
3348 set_define("MOZ_TREE_PIXMAN", True, when=in_tree_pixman)
3350 pkg_check_modules("MOZ_PIXMAN", "pixman-1 >= 0.36.0", when="--enable-system-pixman")
3351 # Set MOZ_PIXMAN_CFLAGS to an explicit empty value when --enable-system-pixman is *not* used,
3352 # for layout/style/extra-bindgen-flags
3353 set_config("MOZ_PIXMAN_CFLAGS", [], when=in_tree_pixman)
3357 # ==============================================================
3358 with only_when(compile_environment):
3359 option("--disable-universalchardet", help="Disable universal encoding detection")
3361 set_config("MOZ_UNIVERSALCHARDET", True, when="--enable-universalchardet")
3365 # ==============================================================
3366 with only_when(compile_environment):
3367 option("--disable-zipwriter", help="Disable zipwriter component")
3369 set_config("MOZ_ZIPWRITER", True, when="--enable-zipwriter")
3372 # Location of the mozilla user directory
3373 # ==============================================================
3374 with only_when(compile_environment):
3377 def default_user_appdir(target):
3378 if target.kernel in ("WINNT", "Darwin"):
3383 "--with-user-appdir",
3385 default=default_user_appdir,
3386 help="Set user-specific appdir",
3389 @depends("--with-user-appdir")
3390 def user_appdir(appdir):
3392 die("--without-user-appdir is not a valid option.")
3393 if "/" in appdir[0]:
3394 die("--with-user-appdir must be a single relative path.")
3395 return '"{}"'.format(appdir[0])
3397 set_define("MOZ_USER_DIR", user_appdir)
3400 # Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
3401 # ==============================================================
3402 with only_when(compile_environment):
3403 have_sin_len = c_compiler.try_compile(
3404 includes=["netinet/in.h"],
3405 body="struct sockaddr_in x; void *foo = (void*) &x.sin_len;",
3406 check_msg="for sin_len in struct sockaddr_in",
3408 have_sin6_len = c_compiler.try_compile(
3409 includes=["netinet/in.h"],
3410 body="struct sockaddr_in6 x; void *foo = (void*) &x.sin6_len;",
3411 check_msg="for sin_len6 in struct sockaddr_in6",
3413 set_define("HAVE_SIN_LEN", have_sin_len)
3414 set_define("HAVE_SIN6_LEN", have_sin6_len)
3415 # HAVE_CONN_LEN must be the same as HAVE_SIN_LEN and HAVE_SIN6_LEN
3416 set_define("HAVE_SCONN_LEN", have_sin_len & have_sin6_len)
3419 c_compiler.try_compile(
3420 includes=["netinet/in.h"],
3421 body="struct sockaddr x; void *foo = (void*) &x.sa_len;",
3422 check_msg="for sa_len in struct sockaddr",
3427 # Check for pthread_cond_timedwait_monotonic_np
3428 # ==============================================================
3429 with only_when(compile_environment):
3431 "HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC",
3432 c_compiler.try_compile(
3433 includes=["pthread.h"],
3434 body="pthread_cond_timedwait_monotonic_np(0, 0, 0);",
3435 # -Werror to catch any "implicit declaration" warning that means the function
3437 flags=["-Werror=implicit-function-declaration"],
3438 check_msg="for pthread_cond_timedwait_monotonic_np",
3443 # Custom dynamic linker for Android
3444 # ==============================================================
3445 with only_when(target_has_linux_kernel & compile_environment):
3448 default=depends(target.os, when="--enable-jemalloc")(
3449 lambda os: os == "Android"
3451 help="{Enable|Disable} custom dynamic linker",
3454 set_config("MOZ_LINKER", True, when="MOZ_LINKER")
3455 set_define("MOZ_LINKER", True, when="MOZ_LINKER")
3456 add_old_configure_assignment("MOZ_LINKER", True, when="MOZ_LINKER")
3458 moz_linker = depends(when="MOZ_LINKER")(lambda: True)
3461 # 32-bits ethtool_cmd.speed
3462 # ==============================================================
3463 with only_when(target_has_linux_kernel & compile_environment):
3465 "MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI",
3466 c_compiler.try_compile(
3467 includes=["linux/ethtool.h"],
3468 body="struct ethtool_cmd cmd; cmd.speed_hi = 0;",
3469 check_msg="for 32-bits ethtool_cmd.speed",
3474 # ==============================================================
3477 onerror=lambda: die(
3478 "Can't find header linux/joystick.h, needed for gamepad support."
3479 " Please install Linux kernel headers."
3481 when=target_has_linux_kernel & compile_environment,
3485 # Smart card support
3486 # ==============================================================
3487 @depends(build_project)
3488 def disable_smart_cards(build_project):
3489 return build_project == "mobile/android"
3492 set_config("MOZ_NO_SMART_CARDS", True, when=disable_smart_cards)
3493 set_define("MOZ_NO_SMART_CARDS", True, when=disable_smart_cards)
3495 # Enable UniFFI fixtures
3496 # ==============================================================
3497 # These are used to test the uniffi-bindgen-gecko-js code generation. They
3498 # should not be enabled in release builds.
3501 "--enable-uniffi-fixtures",
3502 help="Enable UniFFI Fixtures/Examples",
3505 set_config("MOZ_UNIFFI_FIXTURES", True, when="--enable-uniffi-fixtures")
3508 # ==============================================================
3511 "--disable-system-policies",
3512 help="Disable reading policies from Windows registry, macOS's file system attributes, and /etc/firefox",
3515 set_config("MOZ_SYSTEM_POLICIES", True, when="--enable-system-policies")
3517 # Allow disabling the creation a legacy profile
3518 # ==============================================================
3521 "--disable-legacy-profile-creation",
3522 help="Disable the creation a legacy profile, to be used by old versions "
3523 "of Firefox, when no profiles exist.",
3526 set_config("MOZ_CREATE_LEGACY_PROFILE", True, when="--enable-legacy-profile-creation")
3530 # ==============================================================
3531 set_config("WRAP_STL_INCLUDES", True)
3534 depends(build_environment.dist)(lambda dist: [f"-I{dist}/stl_wrappers"]),
3539 # ==============================================================
3541 def need_perl(target):
3542 # Ideally, we'd also depend on gnu_as here, but that adds complications.
3543 return target.cpu == "arm"
3546 perl = check_prog("PERL", ("perl5", "perl"), when=need_perl)
3550 def perl_version_check(min_version):
3552 @checking("for minimum required perl version >= %s" % min_version)
3553 def get_perl_version(perl):
3559 onerror=lambda: die("Failed to get perl version."),
3563 @depends(get_perl_version)
3564 def check_perl_version(version):
3565 if version < min_version:
3566 die("Perl %s or higher is required.", min_version)
3569 @checking("for full perl installation")
3570 @imports("subprocess")
3571 def has_full_perl_installation(perl):
3572 ret = subprocess.call([perl, "-e", "use Config; exit(!-d $Config{archlib})"])
3575 @depends(has_full_perl_installation)
3576 def require_full_perl_installation(has_full_perl_installation):
3577 if not has_full_perl_installation:
3579 "Cannot find Config.pm or $Config{archlib}. "
3580 "A full perl installation is required."
3584 with only_when(need_perl):
3585 perl_version_check("5.006")