1 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
2 # vim: set filetype=python:
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 # Set the MOZ_CONFIGURE_OPTIONS variable with all the options that
8 # were passed somehow (environment, command line, mozconfig)
10 @imports(_from="mozbuild.shellutil", _import="quote")
11 @imports(_from="mozbuild.util", _import="ensure_unicode")
12 @imports(_from="mozbuild.util", _import="system_encoding")
13 @imports("__sandbox__")
14 def all_configure_options():
17 for option in __sandbox__._options.values():
18 # __sandbox__._options contains items for both option.name and
19 # option.env. But it's also an OrderedDict, meaning both are
21 # Also ignore OLD_CONFIGURE and MOZCONFIG because they're not
23 if option == previous or option.env in ("OLD_CONFIGURE", "MOZCONFIG"):
26 value = __sandbox__._value_for(option)
27 # We only want options that were explicitly given on the command
28 # line, the environment, or mozconfig, and that differ from the
32 and value.origin not in ("default", "implied")
33 and value != option.default
36 ensure_unicode(__sandbox__._raw_options[option], system_encoding)
38 # We however always include options that are sent to old configure
39 # because we don't know their actual defaults. (Keep the conditions
40 # separate for ease of understanding and ease of removal)
42 option.help == "Help missing for old configure options"
43 and option in __sandbox__._raw_options
46 ensure_unicode(__sandbox__._raw_options[option], system_encoding)
49 # We shouldn't need this, but currently, quote will return a byte string
50 # if result is empty, and that's not wanted here.
57 set_config("MOZ_CONFIGURE_OPTIONS", all_configure_options)
61 def fold_libs(target):
62 return target.os in ("WINNT", "OSX", "Android")
65 set_config("MOZ_FOLD_LIBS", fold_libs)
68 # ==============================================================
69 # Some of the options here imply an option from js/moz.configure,
70 # so, need to be declared before the include.
75 help="Enable jprof profiling tool (needs mozilla/tools/jprof)",
79 @depends("--enable-jprof")
85 set_config("MOZ_JPROF", jprof)
86 set_define("MOZ_JPROF", jprof)
87 imply_option("--enable-profiling", jprof)
91 def gecko_profiler(target):
92 if target.os == "Android":
93 return target.cpu in ("aarch64", "arm", "x86", "x86_64")
94 elif target.kernel == "Linux":
95 return target.cpu in ("aarch64", "arm", "x86", "x86_64", "mips64")
96 elif target.kernel == "FreeBSD":
97 return target.cpu in ("aarch64", "x86_64")
98 return target.os in ("OSX", "WINNT")
101 @depends(gecko_profiler)
102 def gecko_profiler_define(value):
107 set_config("MOZ_GECKO_PROFILER", gecko_profiler_define)
108 set_define("MOZ_GECKO_PROFILER", gecko_profiler_define)
111 # Whether code to parse ELF binaries should be compiled for the Gecko profiler
112 # (for symbol table dumping).
113 @depends(gecko_profiler, target)
114 def gecko_profiler_parse_elf(value, target):
115 # Currently we only want to build this code on Linux (including Android) and BSD.
116 # For Android, this is in order to dump symbols from Android system, where
117 # on other platforms there exist alternatives that don't require bloating
118 # up our binary size. For Linux more generally, we use this in profile
119 # pre-symbolication support, since MozDescribeCodeAddress doesn't do
120 # anything useful on that platform. (Ideally, we would update
121 # MozDescribeCodeAddress to call into some Rust crates that parse ELF and
122 # DWARF data, but build system issues currently prevent Rust from being
124 if value and (target.kernel == "Linux" or target.kernel == "FreeBSD"):
128 set_config("MOZ_GECKO_PROFILER_PARSE_ELF", gecko_profiler_parse_elf)
129 set_define("MOZ_GECKO_PROFILER_PARSE_ELF", gecko_profiler_parse_elf)
131 # enable this by default if the profiler is enabled
132 # Note: also requires jemalloc
133 set_config("MOZ_PROFILER_MEMORY", gecko_profiler_define)
134 set_define("MOZ_PROFILER_MEMORY", gecko_profiler_define)
141 # Artifact builds are included because the downloaded artifacts can
143 when=artifact_builds | depends(when="--enable-replace-malloc")(lambda: True),
145 def dmd_default(debug, milestone, build_project):
146 return bool(build_project == "browser" and (debug or milestone.is_nightly))
153 help="{Enable|Disable} Dark Matter Detector (heap profiler). "
154 "Also enables jemalloc, replace-malloc and profiling",
158 @depends("--enable-dmd")
164 set_config("MOZ_DMD", dmd)
165 set_define("MOZ_DMD", dmd)
166 imply_option("--enable-profiling", dmd)
167 imply_option("--enable-jemalloc", dmd, when=compile_environment)
168 imply_option("--enable-replace-malloc", dmd, when=compile_environment)
170 # midir-based Web MIDI support
171 # ==============================================================
173 def midir_linux_support(target):
175 target.kernel == "Linux" and target.os != "Android" and target.cpu != "riscv64"
179 @depends(target, midir_linux_support)
180 def midir_support(target, midir_linux_support):
181 if target.os in ("WINNT", "OSX") or midir_linux_support:
185 set_config("MOZ_WEBMIDI_MIDIR_IMPL", midir_support)
187 # Enable various cubeb backends
188 # ==============================================================
190 def audio_backends_default(target):
191 if target.os == "Android":
196 elif target.os in ("DragonFly", "FreeBSD", "SunOS"):
198 elif target.os == "OpenBSD":
200 elif target.os == "OSX":
201 return ("audiounit",)
202 elif target.os == "NetBSD":
204 elif target.os == "SunOS":
206 elif target.os == "WINNT":
209 return ("pulseaudio",)
213 "--enable-audio-backends",
227 default=audio_backends_default,
228 help="{Enable|Disable} various cubeb backends",
232 @depends("--enable-audio-backends", target)
233 def imply_aaudio(values, target):
234 if any("aaudio" in value for value in values) and target.os != "Android":
235 die("Cannot enable AAudio on %s", target.os)
236 return any("aaudio" in value for value in values) or None
239 @depends("--enable-audio-backends", target)
240 def imply_alsa(values, target):
242 any("alsa" in value for value in values)
243 and target.kernel != "Linux"
244 and target.os != "FreeBSD"
246 die("Cannot enable ALSA on %s", target.os)
247 return any("alsa" in value for value in values) or None
250 @depends("--enable-audio-backends", target)
251 def imply_audiounit(values, target):
253 any("audiounit" in value for value in values)
254 and target.os != "OSX"
255 and target.kernel != "Darwin"
257 die("Cannot enable AudioUnit on %s", target.os)
258 return any("audiounit" in value for value in values) or None
261 @depends("--enable-audio-backends")
262 def imply_jack(values):
263 return any("jack" in value for value in values) or None
266 @depends("--enable-audio-backends", target)
267 def imply_opensl(values, target):
268 if any("opensl" in value for value in values) and target.os != "Android":
269 die("Cannot enable OpenSL on %s", target.os)
270 return any("opensl" in value for value in values) or None
273 @depends("--enable-audio-backends", target)
274 def imply_oss(values, target):
275 if any("oss" in value for value in values) and (
276 target.os == "Android" or target.os == "OSX" or target.os == "WINNT"
278 die("Cannot enable OSS on %s", target.os)
279 return any("oss" in value for value in values) or None
282 @depends("--enable-audio-backends", target)
283 def imply_pulseaudio(values, target):
284 if any("pulseaudio" in value for value in values) and (
285 target.os == "Android" or target.os == "OSX" or target.os == "WINNT"
287 die("Cannot enable PulseAudio on %s", target.os)
288 return any("pulseaudio" in value for value in values) or None
291 @depends("--enable-audio-backends", target)
292 def imply_sndio(values, target):
293 if any("sndio" in value for value in values) and (
294 target.os == "Android" or target.os == "OSX" or target.os == "WINNT"
296 die("Cannot enable sndio on %s", target.os)
297 return any("sndio" in value for value in values) or None
300 @depends("--enable-audio-backends", target)
301 def imply_sunaudio(values, target):
302 if any("sunaudio" in value for value in values) and (
303 target.os != "NetBSD" and target.os != "SunOS"
305 die("Cannot enable sunaudio on %s", target.os)
306 return any("sunaudio" in value for value in values) or None
309 @depends("--enable-audio-backends", target)
310 def imply_wasapi(values, target):
311 if any("wasapi" in value for value in values) and target.os != "WINNT":
312 die("Cannot enable WASAPI on %s", target.os)
313 return any("wasapi" in value for value in values) or None
316 set_config("MOZ_AAUDIO", imply_aaudio, when="--enable-audio-backends")
318 imply_option("--enable-alsa", imply_alsa, reason="--enable-audio-backends")
320 set_config("MOZ_AUDIOUNIT_RUST", imply_audiounit, when="--enable-audio-backends")
322 imply_option("--enable-jack", imply_jack, reason="--enable-audio-backends")
324 set_config("MOZ_OPENSL", imply_opensl, when="--enable-audio-backends")
326 set_config("MOZ_OSS", imply_oss, when="--enable-audio-backends")
328 imply_option("--enable-pulseaudio", imply_pulseaudio, reason="--enable-audio-backends")
330 imply_option("--enable-sndio", imply_sndio, reason="--enable-audio-backends")
332 set_config("MOZ_SUNAUDIO", imply_sunaudio, when="--enable-audio-backends")
334 set_config("MOZ_WASAPI", imply_wasapi, when="--enable-audio-backends")
337 # ==============================================================
338 option("--enable-alsa", env="MOZ_ALSA", help="Enable ALSA audio backend.")
341 @depends("--enable-alsa", midir_linux_support)
342 def enable_alsa_or_midir_linux_support(alsa_enabled, midir_linux_support):
343 return alsa_enabled or midir_linux_support
346 pkg_check_modules("MOZ_ALSA", "alsa", when=enable_alsa_or_midir_linux_support)
348 set_config("MOZ_ALSA", True, when="--enable-alsa")
349 set_define("MOZ_ALSA", True, when="--enable-alsa")
352 # ==============================================================
353 system_lib_option("--enable-jack", env="MOZ_JACK", help="Enable JACK audio backend.")
355 jack = pkg_check_modules("MOZ_JACK", "jack", when="--enable-jack")
357 set_config("MOZ_JACK", depends_if(jack)(lambda _: True))
359 # PulseAudio cubeb backend
360 # ==============================================================
362 "--enable-pulseaudio",
363 env="MOZ_PULSEAUDIO",
364 help="{Enable|Disable} PulseAudio audio backend.",
367 pulseaudio = pkg_check_modules("MOZ_PULSEAUDIO", "libpulse", when="--enable-pulseaudio")
369 set_config("MOZ_PULSEAUDIO", depends_if(pulseaudio)(lambda _: True))
370 set_define("MOZ_PULSEAUDIO", depends_if(pulseaudio)(lambda _: True))
372 # sndio cubeb backend
373 # ==============================================================
374 system_lib_option("--enable-sndio", env="MOZ_SNDIO", help="Enable sndio audio backend.")
376 sndio = pkg_check_modules("MOZ_SNDIO", "sndio", when="--enable-sndio")
378 set_config("MOZ_SNDIO", depends_if(sndio)(lambda _: True))
381 # ==============================================================
382 include("../js/moz.configure")
386 # ==============================================================
387 include("../build/moz.configure/node.configure")
390 # ==============================================================
391 set_define("JSON_USE_EXCEPTION", 0)
394 # ==============================================================
395 option("--with-l10n-base", nargs=1, env="L10NBASEDIR", help="Path to l10n repositories")
398 @depends("--with-l10n-base", "MOZ_AUTOMATION", build_environment)
399 @imports(_from="os.path", _import="isdir")
400 @imports(_from="os.path", _import="expanduser")
401 @imports(_from="os", _import="environ")
402 def l10n_base(value, automation, build_env):
406 die("Invalid value --with-l10n-base, %s doesn't exist", path)
408 path = os.path.join(build_env.topsrcdir, "../l10n-central")
412 "MOZBUILD_STATE_PATH", expanduser(os.path.join("~", ".mozbuild"))
416 return os.path.realpath(os.path.abspath(path))
419 set_config("L10NBASEDIR", l10n_base)
423 # ==============================================================
425 def toolkit_choices(target):
426 if target.os == "WINNT":
427 return ("cairo-windows",)
428 elif target.os == "OSX":
429 return ("cairo-cocoa",)
430 elif target.os == "Android":
431 return ("cairo-android",)
435 "cairo-gtk3-wayland",
436 "cairo-gtk3-wayland-only",
437 "cairo-gtk3-x11-wayland",
441 @depends(toolkit_choices)
442 def toolkit_default(choices):
447 "--enable-default-toolkit",
449 choices=toolkit_choices,
450 default=toolkit_default,
451 help="Select default toolkit",
455 @depends("--enable-default-toolkit")
456 def full_toolkit(value):
461 @depends(full_toolkit)
462 def toolkit(toolkit):
463 if toolkit.startswith("cairo-gtk3"):
464 widget_toolkit = "gtk"
466 widget_toolkit = toolkit.replace("cairo-", "")
467 return widget_toolkit
470 set_config("MOZ_WIDGET_TOOLKIT", toolkit)
471 add_old_configure_assignment("MOZ_WIDGET_TOOLKIT", toolkit)
475 def toolkit_define(toolkit):
476 if toolkit != "windows":
477 return "MOZ_WIDGET_%s" % toolkit.upper()
480 set_define(toolkit_define, True)
484 def toolkit_gtk(toolkit):
485 return toolkit == "gtk"
489 # ==============================================================
490 wayland_headers = pkg_check_modules(
492 "gtk+-wayland-3.0 >= 3.14 xkbcommon >= 0.4.1",
493 allow_missing=depends(full_toolkit)(lambda t: t == "cairo-gtk3"),
498 @depends(wayland_headers, toolkit_gtk, artifact_builds)
499 def wayland_headers(wayland, toolkit_gtk, artifacts):
500 if toolkit_gtk and artifacts:
505 set_config("MOZ_WAYLAND", depends_if(wayland_headers)(lambda _: True))
506 set_define("MOZ_WAYLAND", depends_if(wayland_headers)(lambda _: True))
508 # Hardware-accelerated video decode with VAAPI and V4L2
509 # ==============================================================
512 @depends(target, wayland_headers)
513 def vaapi(target, wayland_headers):
514 # VAAPI is only used in Wayland. It's mostly used on x86(-64) but is
515 # sometimes used on ARM/ARM64 SOCs. Wayland implies GTK and Linux.
516 if target.cpu in ("arm", "aarch64", "x86", "x86_64") and wayland_headers:
520 @depends(target, wayland_headers)
521 def v4l2(target, wayland_headers):
522 # V4L2 decode is only used in Wayland, and generally only appears on
523 # embedded SOCs. Wayland implies GTK and Linux.
524 if target.cpu in ("arm", "aarch64", "riscv64") and wayland_headers:
528 set_config("MOZ_ENABLE_VAAPI", True, when=vaapi)
529 set_config("MOZ_ENABLE_V4L2", True, when=v4l2)
530 set_define("MOZ_ENABLE_VAAPI", True, when=vaapi)
531 set_define("MOZ_ENABLE_V4L2", True, when=v4l2)
534 # ==============================================================
535 option("--with-gl-provider", nargs=1, help="Set GL provider backend type")
538 @depends("--with-gl-provider")
539 def gl_provider(value):
544 @depends(gl_provider)
545 def gl_provider_define(provider):
547 return "GLContextProvider%s" % provider
550 set_define("MOZ_GL_PROVIDER", gl_provider_define)
553 @depends(gl_provider, toolkit_gtk)
554 def gl_default_provider(value, toolkit_gtk):
561 set_config("MOZ_GL_PROVIDER", gl_provider)
562 set_config("MOZ_GL_DEFAULT_PROVIDER", gl_default_provider)
565 @depends(gl_default_provider)
566 def gl_provider_define(provider):
568 return "GL_PROVIDER_%s" % provider
571 set_define(gl_provider_define, True)
575 # ==============================================================
577 def pdf_printing(toolkit):
578 if toolkit in ("windows", "gtk", "android"):
582 set_config("MOZ_PDF_PRINTING", pdf_printing)
583 set_define("MOZ_PDF_PRINTING", pdf_printing)
586 # Event loop instrumentation
587 # ==============================================================
588 option(env="MOZ_INSTRUMENT_EVENT_LOOP", help="Force-enable event loop instrumentation")
591 @depends("MOZ_INSTRUMENT_EVENT_LOOP", toolkit)
592 def instrument_event_loop(value, toolkit):
594 toolkit in ("windows", "gtk", "cocoa", "android") and value.origin == "default"
599 set_config("MOZ_INSTRUMENT_EVENT_LOOP", instrument_event_loop)
600 set_define("MOZ_INSTRUMENT_EVENT_LOOP", instrument_event_loop)
603 # Fontconfig Freetype
604 # ==============================================================
605 option(env="USE_FC_FREETYPE", help="Force-enable the use of fontconfig freetype")
608 @depends("USE_FC_FREETYPE", toolkit)
609 def fc_freetype(value, toolkit):
610 if value or (toolkit == "gtk" and value.origin == "default"):
614 set_define("USE_FC_FREETYPE", fc_freetype)
617 # ==============================================================
618 pkg_check_modules("MOZ_PANGO", "pango >= 1.22.0", when=toolkit_gtk)
621 # ==============================================================
622 fontconfig_info = pkg_check_modules(
623 "_FONTCONFIG", "fontconfig >= 2.7.0", when=fc_freetype
627 @depends(fc_freetype)
628 def check_for_freetype2(fc_freetype):
633 # Check for freetype2. Flags are combined with fontconfig flags.
634 freetype2_info = pkg_check_modules(
635 "_FT2", "freetype2 >= 9.10.3", when=check_for_freetype2
639 @depends(fontconfig_info, freetype2_info)
640 def freetype2_combined_info(fontconfig_info, freetype2_info):
641 if not freetype2_info:
643 if not fontconfig_info:
644 return freetype2_info
646 cflags=freetype2_info.cflags + fontconfig_info.cflags,
647 libs=freetype2_info.libs + fontconfig_info.libs,
651 set_define("MOZ_HAVE_FREETYPE2", depends_if(freetype2_info)(lambda _: True))
653 # Apple platform decoder support
654 # ==============================================================
656 def applemedia(toolkit):
657 if toolkit in ("cocoa", "uikit"):
661 set_config("MOZ_APPLEMEDIA", applemedia)
662 set_define("MOZ_APPLEMEDIA", applemedia)
664 # Windows Media Foundation support
665 # ==============================================================
666 option("--disable-wmf", help="Disable support for Windows Media Foundation")
669 @depends("--disable-wmf", target, "--help")
670 def wmf(value, target, _):
671 enabled = bool(value)
672 if value.origin == "default":
673 # Enable Windows Media Foundation support by default.
674 # Note our minimum SDK version is Windows 7 SDK, so we are (currently)
675 # guaranteed to have a recent-enough SDK to build WMF.
676 enabled = target.os == "WINNT"
677 if enabled and target.os != "WINNT":
678 die("Cannot enable Windows Media Foundation support on %s", target.os)
683 @depends(c_compiler, when=wmf)
684 def wmfmediaengine(c_compiler):
685 return c_compiler and c_compiler.type == "clang-cl"
688 set_config("MOZ_WMF", wmf)
689 set_define("MOZ_WMF", wmf)
691 set_config("MOZ_WMF_MEDIA_ENGINE", True, when=wmfmediaengine)
692 set_define("MOZ_WMF_MEDIA_ENGINE", True, when=wmfmediaengine)
694 # FFmpeg H264/AAC Decoding Support
695 # ==============================================================
696 option("--disable-ffmpeg", help="Disable FFmpeg for fragmented H264/AAC decoding")
699 @depends("--disable-ffmpeg", target)
700 def ffmpeg(value, target):
701 enabled = bool(value)
702 if value.origin == "default":
703 enabled = target.os not in ("Android", "WINNT")
708 set_config("MOZ_FFMPEG", ffmpeg)
709 set_define("MOZ_FFMPEG", ffmpeg)
710 imply_option("--enable-fmp4", ffmpeg, "--enable-ffmpeg")
712 # AV1 Video Codec Support
713 # ==============================================================
714 option("--disable-av1", help="Disable av1 video support")
717 @depends("--enable-av1")
723 @depends(target, when=av1 & compile_environment)
724 def dav1d_asm(target):
725 if target.cpu in ("aarch64", "x86", "x86_64"):
729 @depends(target, when=av1 & compile_environment)
730 def dav1d_nasm(target):
731 if target.cpu in ("x86", "x86_64"):
732 return namespace(version="2.14", what="AV1")
735 set_config("MOZ_DAV1D_ASM", dav1d_asm)
736 set_define("MOZ_DAV1D_ASM", dav1d_asm)
737 set_config("MOZ_AV1", av1)
738 set_define("MOZ_AV1", av1)
740 # JXL Image Codec Support
741 # ==============================================================
742 option("--disable-jxl", help="Disable jxl image support")
745 @depends("--disable-jxl", milestone.is_nightly)
746 def jxl(value, is_nightly):
747 if is_nightly and value:
751 set_config("MOZ_JXL", jxl)
752 set_define("MOZ_JXL", jxl)
754 # Built-in fragmented MP4 support.
755 # ==============================================================
759 help="Disable support for in built Fragmented MP4 parsing",
763 @depends("--disable-fmp4", target, wmf, applemedia)
764 def fmp4(value, target, wmf, applemedia):
765 enabled = bool(value)
766 if value.origin == "default":
767 # target.os == 'Android' includes all B2G versions
768 enabled = wmf or applemedia or target.os == "Android"
773 set_config("MOZ_FMP4", fmp4)
774 set_define("MOZ_FMP4", fmp4)
778 def sample_type_is_s16(target):
779 # Use integers over floats for audio on Android regardless of the CPU
780 # architecture, because audio backends for Android don't support floats.
781 # We also use integers on ARM because it's more efficient.
782 if target.os == "Android" or target.cpu == "arm":
786 @depends(sample_type_is_s16)
787 def sample_type_is_float(t):
792 set_config("MOZ_SAMPLE_TYPE_S16", sample_type_is_s16)
793 set_define("MOZ_SAMPLE_TYPE_S16", sample_type_is_s16)
794 set_config("MOZ_SAMPLE_TYPE_FLOAT32", sample_type_is_float)
795 set_define("MOZ_SAMPLE_TYPE_FLOAT32", sample_type_is_float)
797 set_define("MOZ_VORBIS", sample_type_is_float)
798 set_config("MOZ_VORBIS", sample_type_is_float)
799 set_define("MOZ_TREMOR", sample_type_is_s16)
800 set_config("MOZ_TREMOR", sample_type_is_s16)
803 "--disable-real-time-tracing",
804 help="Disable tracing of real-time audio callbacks",
807 set_config("MOZ_REAL_TIME_TRACING", True, when="--enable-real-time-tracing")
808 set_define("MOZ_REAL_TIME_TRACING", True, when="--enable-real-time-tracing")
810 # OpenMAX IL Decoding Support
811 # ==============================================================
812 option("--enable-openmax", help="Enable OpenMAX IL for video/audio decoding")
815 @depends("--enable-openmax")
817 enabled = bool(value)
822 set_config("MOZ_OMX", openmax)
823 set_define("MOZ_OMX", openmax)
826 # ==============================================================
827 @depends(target, wmf)
828 def eme_choices(target, wmf):
830 target.kernel in ("WINNT", "Linux")
831 and target.os != "Android"
832 and target.cpu in ("x86", "x86_64")
835 return ("widevine", "wmfcdm")
837 if target.kernel == "WINNT" and target.cpu == "aarch64":
839 if target.os in ("OSX"):
843 # Widevine is enabled by default in desktop browser builds, except
844 # on aarch64 Windows.
845 @depends(build_project, eme_choices, target)
846 def eme_default(build_project, choices, target):
847 if build_project == "browser":
848 if target.kernel != "WINNT" or target.cpu != "aarch64":
858 help="{Enable|Disable} support for Encrypted Media Extensions",
862 @depends("--enable-eme", fmp4, when=eme_choices)
863 def eme(enabled, fmp4):
864 if enabled and enabled.origin != "default" and not fmp4:
865 die("Encrypted Media Extension support requires " "Fragmented MP4 support")
868 @depends("--enable-eme", when=eme_choices)
869 def eme_modules(value):
873 # Fallback to an empty list when eme_choices is empty, setting eme_modules to
875 set_config("MOZ_EME_MODULES", eme_modules | dependable([]))
878 @depends(eme_modules, target, when=eme_modules)
879 def eme_win32_artifact(modules, target):
880 if "widevine" in modules and target.kernel == "WINNT" and target.cpu == "aarch64":
884 set_config("MOZ_EME_WIN32_ARTIFACT", eme_win32_artifact)
887 # Media Foundation CDM support
888 # ==============================================================
889 @depends(eme_modules, when=wmfmediaengine)
891 if "wmfcdm" in modules:
895 set_config("MOZ_WMF_CDM", True, when=wmfcdm)
896 set_define("MOZ_WMF_CDM", True, when=wmfcdm)
900 name="--enable-chrome-format",
901 help="Select FORMAT of chrome files during packaging.",
903 choices=("omni", "jar", "flat"),
908 @depends("--enable-chrome-format")
909 def packager_format(value):
913 set_config("MOZ_PACKAGER_FORMAT", packager_format)
915 # The packager minifies two different types of files: non-JS (mostly property
916 # files for l10n), and JS. Setting MOZ_PACKAGER_MINIFY only minifies the
917 # former. Firefox doesn't yet minify JS, due to concerns about debuggability.
919 # Also, the JS minification setup really only works correctly on Android:
920 # we need extra setup to use the newly-built shell for Linux and Windows,
921 # and cross-compilation for macOS requires some extra care.
924 @depends(target_is_android, "--enable-debug", milestone.is_nightly)
925 def enable_minify_default(is_android, debug, is_nightly):
926 if is_android and not debug and not is_nightly:
927 return ("properties", "js")
928 return ("properties",)
932 name="--enable-minify",
933 help="Select types of files to minify during packaging.",
935 choices=("properties", "js"),
936 default=enable_minify_default,
940 @depends("--enable-minify")
941 def enable_minify(value):
942 if "js" in value and "properties" not in value:
943 die("--enable-minify=js requires --enable-minify=properties.")
945 properties="properties" in value,
950 set_config("MOZ_PACKAGER_MINIFY", True, when=enable_minify.properties)
951 set_config("MOZ_PACKAGER_MINIFY_JS", True, when=enable_minify.js)
954 @depends(host, build_project)
955 def jar_maker_format(host, build_project):
956 # Multilocales for mobile/android use the same mergedirs for all locales,
957 # so we can't use symlinks for those builds.
958 if host.os == "WINNT" or build_project == "mobile/android":
963 set_config("MOZ_JAR_MAKER_FILE_FORMAT", jar_maker_format)
967 def omnijar_name(toolkit):
968 # Fennec's static resources live in the assets/ folder of the
969 # APK. Adding a path to the name here works because we only
970 # have one omnijar file in the final package (which is not the
972 return "assets/omni.ja" if toolkit == "android" else "omni.ja"
975 set_config("OMNIJAR_NAME", omnijar_name)
977 project_flag("MOZ_PLACES", help="Build Places if required", set_as_define=True)
980 "MOZ_SERVICES_HEALTHREPORT",
981 help="Build Firefox Health Reporter Service",
987 help="Enable Normandy recipe runner",
991 project_flag("MOZ_SERVICES_SYNC", help="Build Sync Services if required")
994 "MOZ_ANDROID_HISTORY",
995 help="Enable Android History instead of Places",
1000 "MOZ_DEDICATED_PROFILES",
1001 help="Enable dedicated profiles per install",
1006 "MOZ_BLOCK_PROFILE_DOWNGRADE",
1007 help="Block users from starting profiles last used by a newer build",
1012 @depends("MOZ_PLACES", "MOZ_ANDROID_HISTORY")
1013 def check_places_and_android_history(places, android_history):
1014 if places and android_history:
1015 die("Cannot use MOZ_ANDROID_HISTORY alongside MOZ_PLACES.")
1019 env="MOZ_TELEMETRY_REPORTING",
1020 default=mozilla_official,
1021 help="Enable telemetry reporting",
1024 set_define("MOZ_TELEMETRY_REPORTING", True, when="MOZ_TELEMETRY_REPORTING")
1027 @depends("MOZ_TELEMETRY_REPORTING", milestone.is_nightly)
1028 def telemetry_on_by_default(reporting, is_nightly):
1029 return reporting and is_nightly
1032 set_define("MOZ_TELEMETRY_ON_BY_DEFAULT", True, when=telemetry_on_by_default)
1036 # ==============================================================
1037 system_lib_option("--enable-gpsd", env="MOZ_GPSD", help="Enable gpsd support")
1040 @depends("--enable-gpsd")
1045 system_gpsd = pkg_check_modules("MOZ_GPSD", "libgps >= 3.11", when=gpsd)
1047 set_config("MOZ_GPSD", depends_if(system_gpsd)(lambda _: True))
1049 # Miscellaneous programs
1050 # ==============================================================
1052 check_prog("TAR", ("gnutar", "gtar", "tar"))
1053 check_prog("UNZIP", ("unzip",))
1056 # ==============================================================
1057 include("../build/moz.configure/keyfiles.configure")
1059 simple_keyfile("Mozilla API")
1061 simple_keyfile("Google Location Service API")
1063 simple_keyfile("Google Safebrowsing API")
1065 id_and_secret_keyfile("Bing API")
1067 simple_keyfile("Adjust SDK")
1069 id_and_secret_keyfile("Leanplum SDK")
1071 simple_keyfile("Pocket API")
1074 # WebRender Debugger integration
1075 # ==============================================================
1078 "--enable-webrender-debugger", help="Build the websocket debug server in WebRender"
1082 "MOZ_WEBRENDER_DEBUGGER", depends_if("--enable-webrender-debugger")(lambda _: True)
1085 # Additional system headers defined at the application level
1086 # ==============================================================
1089 "--enable-app-system-headers",
1090 env="MOZ_APP_SYSTEM_HEADERS",
1091 help="Use additional system headers defined in $MOZ_BUILD_APP/app-system-headers.mozbuild",
1095 @depends("--enable-app-system-headers")
1096 def app_system_headers(value):
1101 set_config("MOZ_APP_SYSTEM_HEADERS", app_system_headers)
1102 set_define("MOZ_APP_SYSTEM_HEADERS", app_system_headers)
1105 # ==============================================================
1106 option("--disable-printing", help="Disable printing support")
1109 @depends("--disable-printing")
1110 def printing(value):
1115 set_config("NS_PRINTING", printing)
1116 set_define("NS_PRINTING", printing)
1117 set_define("NS_PRINT_PREVIEW", printing)
1119 # Speech-dispatcher support
1120 # ==============================================================
1122 def no_speechd_on_non_gtk(toolkit):
1123 if toolkit != "gtk":
1128 "--enable-synth-speechd", no_speechd_on_non_gtk, reason="--enable-default-toolkit"
1131 option("--disable-synth-speechd", help="Disable speech-dispatcher support")
1133 set_config("MOZ_SYNTH_SPEECHD", depends_if("--disable-synth-speechd")(lambda _: True))
1136 # ==============================================================
1137 option("--disable-webspeech", help="Disable support for HTML Speech API")
1140 @depends("--disable-webspeech")
1141 def webspeech(value):
1146 set_config("MOZ_WEBSPEECH", webspeech)
1147 set_define("MOZ_WEBSPEECH", webspeech)
1149 # Speech API test backend
1150 # ==============================================================
1152 "--enable-webspeechtestbackend",
1154 help="{Enable|Disable} support for HTML Speech API Test Backend",
1158 @depends_if("--enable-webspeechtestbackend")
1159 def webspeech_test_backend(value):
1163 set_config("MOZ_WEBSPEECH_TEST_BACKEND", webspeech_test_backend)
1164 set_define("MOZ_WEBSPEECH_TEST_BACKEND", webspeech_test_backend)
1167 # ==============================================================
1168 @depends(target, milestone)
1169 def skia_pdf_default(target, milestone):
1170 return milestone.is_nightly and target.os != "WINNT"
1173 option("--enable-skia-pdf", default=skia_pdf_default, help="{Enable|Disable} Skia PDF")
1175 set_config("MOZ_ENABLE_SKIA_PDF", True, when="--enable-skia-pdf")
1176 set_define("MOZ_ENABLE_SKIA_PDF", True, when="--enable-skia-pdf")
1187 "--with-system-webp", help="Use system libwebp (located with pkgconfig)"
1190 system_webp = pkg_check_modules(
1191 "MOZ_WEBP", "libwebp >= 1.0.2 libwebpdemux >= 1.0.2", when="--with-system-webp"
1194 set_config("MOZ_SYSTEM_WEBP", depends(when=system_webp)(lambda: True))
1196 # Build Freetype in the tree
1197 # ==============================================================
1198 @depends(target, "--enable-skia-pdf")
1199 def tree_freetype(target, skia_pdf):
1200 if target.os == "Android" or (skia_pdf and target.os == "WINNT"):
1204 set_define("MOZ_TREE_FREETYPE", tree_freetype)
1205 set_config("MOZ_TREE_FREETYPE", tree_freetype)
1207 set_define("HAVE_FT_BITMAP_SIZE_Y_PPEM", tree_freetype)
1208 set_define("HAVE_FT_GLYPHSLOT_EMBOLDEN", tree_freetype)
1209 set_define("HAVE_FT_LOAD_SFNT_TABLE", tree_freetype)
1212 @depends(freetype2_combined_info, tree_freetype, build_environment)
1213 def ft2_info(freetype2_combined_info, tree_freetype, build_env):
1216 cflags=("-I%s/modules/freetype2/include" % build_env.topsrcdir,), libs=()
1218 if freetype2_combined_info:
1219 return freetype2_combined_info
1222 set_config("FT2_LIBS", ft2_info.libs)
1225 @depends(target, tree_freetype, freetype2_info)
1226 def enable_cairo_ft(target, tree_freetype, freetype2_info):
1227 # Avoid defining MOZ_ENABLE_CAIRO_FT on Windows platforms because
1228 # "cairo-ft-font.c" includes <dlfcn.h>, which only exists on posix platforms
1229 return freetype2_info or (tree_freetype and target.os != "WINNT")
1232 set_config("MOZ_ENABLE_CAIRO_FT", True, when=enable_cairo_ft)
1233 set_config("CAIRO_FT_CFLAGS", ft2_info.cflags, when=enable_cairo_ft)
1236 # WebDriver (HTTP / BiDi)
1237 # ==============================================================
1239 # WebDriver is a remote control interface that enables introspection and
1240 # control of user agents. It provides a platform- and language-neutral wire
1241 # protocol as a way for out-of-process programs to remotely instruct the
1242 # behavior of web browsers.
1244 # The Gecko implementation is backed by Marionette and Remote Agent.
1245 # Both protocols are not really toolkit features, as much as Gecko engine
1246 # features. But they are enabled based on the toolkit, so here it lives.
1248 # Marionette remote protocol
1249 # -----------------------------------------------------------
1251 # Marionette is the Gecko remote protocol used for various remote control,
1252 # automation, and testing purposes throughout Gecko-based applications like
1253 # Firefox, Thunderbird, and any mobile browser built upon GeckoView.
1255 # It also backs ../testing/geckodriver, which is Mozilla's WebDriver
1258 # The source of Marionette lives in ../remote/marionette.
1260 # For more information, see:
1261 # https://firefox-source-docs.mozilla.org/testing/marionette/index.html
1263 # Remote Agent (WebDriver BiDi / partial CDP)
1264 # -----------------------------------------------------------
1266 # The primary purpose is the implementation of the WebDriver BiDi specification.
1267 # But it also complements the existing Firefox Developer Tools Remote Debugging
1268 # Protocol (RDP) by implementing a subset of the Chrome DevTools Protocol (CDP).
1270 # The source of Remote Agent lives in ../remote.
1272 # For more information, see:
1273 # https://firefox-source-docs.mozilla.org/remote/index.html
1277 "--disable-webdriver",
1278 help="Disable support for WebDriver remote protocols",
1282 @depends("--disable-webdriver")
1283 def webdriver(enabled):
1288 set_config("ENABLE_WEBDRIVER", webdriver)
1289 set_define("ENABLE_WEBDRIVER", webdriver)
1292 # geckodriver WebDriver implementation
1293 # ==============================================================
1295 # Turn off geckodriver for build configs we don't handle yet,
1296 # but allow --enable-geckodriver to override when compile environment is available.
1297 # --disable-tests implies disabling geckodriver.
1298 # Disable building in CI
1302 "--enable-tests", target, cross_compiling, hazard_analysis, asan, "MOZ_AUTOMATION"
1304 def geckodriver_default(enable_tests, target, cross_compile, hazard, asan, automation):
1305 if not enable_tests:
1307 if hazard or target.os == "Android" or (asan and cross_compile):
1315 "--enable-geckodriver",
1316 default=geckodriver_default,
1317 when="--enable-compile-environment",
1318 help="{Build|Do not build} geckodriver",
1322 @depends("--enable-geckodriver", when="--enable-compile-environment")
1323 def geckodriver(enabled):
1328 set_config("MOZ_GECKODRIVER", geckodriver)
1332 # ========================================================
1334 def webrtc_default(target):
1335 # Turn off webrtc for OS's we don't handle yet, but allow
1336 # --enable-webrtc to override.
1338 for os_fragment in (
1349 if target.raw_os.startswith(os_fragment):
1364 or target.cpu.startswith("ppc")
1368 if os_match and cpu_match:
1375 default=webrtc_default,
1376 help="{Enable|Disable} support for WebRTC",
1380 @depends("--disable-webrtc")
1381 def webrtc(enabled):
1386 set_config("MOZ_WEBRTC", webrtc)
1387 set_define("MOZ_WEBRTC", webrtc)
1388 set_config("MOZ_SCTP", webrtc)
1389 set_define("MOZ_SCTP", webrtc)
1390 set_config("MOZ_SRTP", webrtc)
1391 set_define("MOZ_SRTP", webrtc)
1392 set_config("MOZ_WEBRTC_SIGNALING", webrtc)
1393 set_define("MOZ_WEBRTC_SIGNALING", webrtc)
1394 set_config("MOZ_PEERCONNECTION", webrtc)
1395 set_define("MOZ_PEERCONNECTION", webrtc)
1396 # MOZ_WEBRTC_ASSERT_ALWAYS turns on a number of safety asserts in
1397 # opt/production builds (via MOZ_CRASH())
1398 set_config("MOZ_WEBRTC_ASSERT_ALWAYS", webrtc)
1399 set_define("MOZ_WEBRTC_ASSERT_ALWAYS", webrtc)
1402 # ==============================================================
1405 @depends(target, webrtc)
1406 def raw_media_default(target, webrtc):
1407 if target.os == "Android":
1415 default=raw_media_default,
1416 help="{Enable|Disable} support for RAW media",
1419 set_config("MOZ_RAW", depends_if("--enable-raw")(lambda _: True))
1420 set_define("MOZ_RAW", depends_if("--enable-raw")(lambda _: True))
1424 # ==============================================================
1425 @depends(webrtc, when=toolkit_gtk)
1426 def x11_libs(webrtc):
1436 # third_party/libwebrtc/webrtc/webrtc_gn/moz.build adds those
1437 # manually, ensure they're available.
1449 x11_headers = pkg_check_modules(
1452 allow_missing=depends(full_toolkit)(lambda t: t == "cairo-gtk3-wayland"),
1453 when=depends(full_toolkit)(
1454 lambda t: t in ("cairo-gtk3", "cairo-gtk3-wayland", "cairo-gtk3-x11-wayland")
1459 set_config("MOZ_X11", True, when=x11_headers)
1460 set_define("MOZ_X11", True, when=x11_headers)
1466 allow_missing=depends(full_toolkit)(lambda t: t == "cairo-gtk3-wayland"),
1467 when=depends(full_toolkit)(
1468 lambda t: t in ("cairo-gtk3", "cairo-gtk3-wayland", "cairo-gtk3-x11-wayland")
1473 # ASan Reporter Addon
1474 # ==============================================================
1476 "--enable-address-sanitizer-reporter",
1477 help="Enable Address Sanitizer Reporter Extension",
1481 @depends("--enable-address-sanitizer-reporter")
1482 def enable_asan_reporter(value):
1487 set_config("MOZ_ASAN_REPORTER", enable_asan_reporter)
1488 set_define("MOZ_ASAN_REPORTER", enable_asan_reporter)
1491 # ==============================================================
1492 with only_when("--enable-compile-environment"):
1494 @depends(host, target)
1495 def has_elfhack(host, target):
1497 target.kernel == "Linux"
1498 and host.kernel == "Linux"
1499 and target.cpu in ("arm", "aarch64", "x86", "x86_64")
1502 @depends("--enable-release", enable_linker)
1503 def default_elfhack(release, linker):
1504 # Disable elfhack when explicitly building with --enable-linker=lld
1505 if linker and linker.origin != "default" and linker[0] in ("lld", "mold"):
1507 return bool(release)
1509 with only_when(has_elfhack):
1511 "--disable-elf-hack",
1512 default=default_elfhack,
1513 help="{Enable|Disable} elf hacks",
1516 @depends(select_linker, when="--enable-elf-hack")
1517 def use_elf_hack(linker):
1518 if linker and linker.KIND == "lld":
1520 "Cannot enable elfhack with lld."
1521 " Use --enable-linker=bfd, --enable-linker=gold, or --disable-elf-hack"
1525 set_config("USE_ELF_HACK", use_elf_hack)
1528 @depends(build_environment)
1529 def idl_roots(build_env):
1531 ipdl_root=os.path.join(build_env.topobjdir, "ipc", "ipdl"),
1532 webidl_root=os.path.join(build_env.topobjdir, "dom", "bindings"),
1533 xpcom_root=os.path.join(build_env.topobjdir, "xpcom", "components"),
1537 set_config("WEBIDL_ROOT", idl_roots.webidl_root)
1538 set_config("IPDL_ROOT", idl_roots.ipdl_root)
1539 set_config("XPCOM_ROOT", idl_roots.xpcom_root)
1541 # Proxy bypass protection
1542 # ==============================================================
1545 "--enable-proxy-bypass-protection",
1546 help="Prevent suspected or confirmed proxy bypasses",
1550 @depends_if("--enable-proxy-bypass-protection")
1551 def proxy_bypass_protection(_):
1555 set_config("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1556 set_define("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1558 # Proxy direct failover
1559 # ==============================================================
1562 "--disable-proxy-direct-failover",
1563 help="Disable direct failover for system requests",
1567 @depends_if("--disable-proxy-direct-failover")
1568 def proxy_direct_failover(value):
1573 set_config("MOZ_PROXY_DIRECT_FAILOVER", proxy_direct_failover)
1574 set_define("MOZ_PROXY_DIRECT_FAILOVER", proxy_direct_failover)
1577 # ==============================================================
1580 @depends(c_compiler, toolchain_prefix)
1581 def midl_names(c_compiler, toolchain_prefix):
1582 if c_compiler and c_compiler.type in ["gcc", "clang"]:
1585 if toolchain_prefix:
1586 prefixed = tuple("%s%s" % (p, "widl") for p in toolchain_prefix)
1587 widl = prefixed + widl
1590 return ("midl.exe",)
1593 @depends(target, "--enable-compile-environment")
1594 def check_for_midl(target, compile_environment):
1595 if target.os != "WINNT":
1598 if compile_environment:
1605 when=check_for_midl,
1608 # MIDL being used from a python wrapper script, we can live with it
1613 option(env="MIDL_FLAGS", nargs=1, help="Extra flags to pass to MIDL")
1620 when=depends(midl, target)(lambda m, t: m and t.kernel == "WINNT"),
1622 def midl_flags(flags, target, midl):
1624 flags = flags[0].split()
1628 if not midl.endswith("widl"):
1634 return flags + ["-nologo", "-no_cpp", "-env", env]
1638 "x86": ["--win32", "-m32"],
1639 "x86_64": ["--win64", "-m64"],
1643 set_config("MIDL_FLAGS", midl_flags)
1646 # ==============================================================
1648 option("--disable-accessibility", help="Disable accessibility support")
1651 @depends("--enable-accessibility", check_for_midl, midl, c_compiler)
1652 def accessibility(value, check_for_midl, midl, c_compiler):
1653 enabled = bool(value)
1658 if check_for_midl and not midl:
1659 if c_compiler and c_compiler.type in ("gcc", "clang"):
1661 "You have accessibility enabled, but widl could not be found. "
1662 "Add --disable-accessibility to your mozconfig or install widl. "
1663 "See https://developer.mozilla.org/en-US/docs/Cross_Compile_Mozilla_for_Mingw32 for details."
1667 "MIDL could not be found. "
1668 "Building accessibility without MIDL is not supported."
1674 set_config("ACCESSIBILITY", accessibility)
1675 set_define("ACCESSIBILITY", accessibility)
1678 @depends(moz_debug, developer_options)
1679 def a11y_log(debug, developer_options):
1680 return debug or developer_options
1683 set_config("A11Y_LOG", True, when=a11y_log)
1684 set_define("A11Y_LOG", True, when=a11y_log)
1688 # ==============================================================
1690 def require_signing(milestone):
1691 return milestone.is_release_or_beta and not milestone.is_esr
1695 env="MOZ_REQUIRE_SIGNING",
1696 default=require_signing,
1697 help="Enforce that add-ons are signed by the trusted root",
1700 set_config("MOZ_REQUIRE_SIGNING", True, when="MOZ_REQUIRE_SIGNING")
1701 set_define("MOZ_REQUIRE_SIGNING", True, when="MOZ_REQUIRE_SIGNING")
1704 "--with-unsigned-addon-scopes",
1706 choices=("app", "system"),
1707 help="Addon scopes where signature is not required",
1711 @depends("--with-unsigned-addon-scopes")
1712 def unsigned_addon_scopes(scopes):
1714 app="app" in scopes or None,
1715 system="system" in scopes or None,
1719 set_config("MOZ_UNSIGNED_APP_SCOPE", unsigned_addon_scopes.app)
1720 set_config("MOZ_UNSIGNED_SYSTEM_SCOPE", unsigned_addon_scopes.system)
1724 # ==============================================================
1726 "--allow-addon-sideload",
1727 default=milestone.is_esr,
1728 help="Addon sideloading is allowed",
1732 set_config("MOZ_ALLOW_ADDON_SIDELOAD", True, when="--allow-addon-sideload")
1734 # WebExtensions API WebIDL bindings
1735 # ==============================================================
1739 def extensions_webidl_bindings_default(milestone):
1740 # Only enable the webidl bindings for the WebExtensions APIs
1742 return milestone.is_nightly
1746 "--enable-extensions-webidl-bindings",
1747 default=extensions_webidl_bindings_default,
1748 help="{Enable|Disable} building experimental WebExtensions WebIDL bindings",
1752 @depends("--enable-extensions-webidl-bindings")
1753 def extensions_webidl_enabled(value):
1757 set_config("MOZ_WEBEXT_WEBIDL_ENABLED", extensions_webidl_enabled)
1759 # Launcher process (Windows only)
1760 # ==============================================================
1764 def launcher_process_default(target):
1765 return target.os == "WINNT"
1769 "--enable-launcher-process",
1770 default=launcher_process_default,
1771 help="{Enable|Disable} launcher process by default",
1775 @depends("--enable-launcher-process", target)
1776 def launcher(value, target):
1777 enabled = bool(value)
1778 if enabled and target.os != "WINNT":
1779 die("Cannot enable launcher process on %s", target.os)
1784 set_config("MOZ_LAUNCHER_PROCESS", launcher)
1785 set_define("MOZ_LAUNCHER_PROCESS", launcher)
1787 # llvm-dlltool (Windows only)
1788 # ==============================================================
1791 @depends(build_project, target, "--enable-compile-environment")
1792 def check_for_llvm_dlltool(build_project, target, compile_environment):
1793 if build_project != "browser":
1796 if target.os != "WINNT":
1799 return compile_environment
1802 llvm_dlltool = check_prog(
1805 what="llvm-dlltool",
1806 when=check_for_llvm_dlltool,
1807 paths=clang_search_path,
1811 @depends(target, when=llvm_dlltool)
1812 def llvm_dlltool_flags(target):
1815 "x86_64": "i386:x86-64",
1822 set_config("LLVM_DLLTOOL_FLAGS", llvm_dlltool_flags)
1824 # BITS download (Windows only)
1825 # ==============================================================
1828 "--enable-bits-download",
1829 when=target_is_windows,
1830 default=target_is_windows,
1831 help="{Enable|Disable} building BITS download support",
1835 "MOZ_BITS_DOWNLOAD",
1836 depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
1839 "MOZ_BITS_DOWNLOAD",
1840 depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
1843 # Bundled fonts on desktop platform
1844 # ==============================================================
1848 def bundled_fonts_default(target):
1849 return target.os == "WINNT" or target.kernel == "Linux"
1852 @depends(build_project)
1853 def allow_bundled_fonts(project):
1854 return project == "browser" or project == "comm/mail"
1858 "--enable-bundled-fonts",
1859 default=bundled_fonts_default,
1860 when=allow_bundled_fonts,
1861 help="{Enable|Disable} support for bundled fonts on desktop platforms",
1865 "MOZ_BUNDLED_FONTS",
1866 depends_if("--enable-bundled-fonts", when=allow_bundled_fonts)(lambda _: True),
1870 # ==============================================================
1874 def reflow_perf(debug):
1880 "--enable-reflow-perf",
1881 default=reflow_perf,
1882 help="{Enable|Disable} reflow performance tracing",
1885 # The difference in conditions here comes from the initial implementation
1886 # in old-configure, which was unexplained there as well.
1887 set_define("MOZ_REFLOW_PERF", depends_if("--enable-reflow-perf")(lambda _: True))
1888 set_define("MOZ_REFLOW_PERF_DSP", reflow_perf)
1891 # ==============================================================
1895 def layout_debugger(debug):
1901 "--enable-layout-debugger",
1902 default=layout_debugger,
1903 help="{Enable|Disable} layout debugger",
1906 set_config("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
1907 set_define("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
1910 # Shader Compiler for Windows (and MinGW Cross Compile)
1911 # ==============================================================
1913 with only_when(compile_environment):
1916 ("fxc.exe", "fxc2.exe"),
1917 when=depends(target)(lambda t: t.kernel == "WINNT"),
1919 # FXC being used from a python wrapper script, we can live with it
1928 with only_when(compile_environment):
1930 "--with-system-libvpx", help="Use system libvpx (located with pkgconfig)"
1933 with only_when("--with-system-libvpx"):
1934 vpx = pkg_check_modules("MOZ_LIBVPX", "vpx >= 1.10.0")
1937 "vpx/vpx_decoder.h",
1939 onerror=lambda: die(
1940 "Couldn't find vpx/vpx_decoder.h, which is required to build "
1941 "with system libvpx. Use --without-system-libvpx to build "
1942 "with in-tree libvpx."
1947 "vpx_codec_dec_init_ver",
1949 onerror=lambda: die(
1950 "--with-system-libvpx requested but symbol vpx_codec_dec_init_ver "
1955 set_config("MOZ_SYSTEM_LIBVPX", True)
1957 @depends("--with-system-libvpx", target)
1958 def in_tree_vpx(system_libvpx, target):
1962 arm_asm = (target.cpu == "arm") or None
1963 return namespace(arm_asm=arm_asm)
1965 @depends(target, when=in_tree_vpx)
1966 def vpx_nasm(target):
1967 if target.cpu in ("x86", "x86_64"):
1968 if target.kernel == "WINNT":
1969 # Version 2.03 is needed for automatic safeseh support.
1970 return namespace(version="2.03", what="VPX")
1971 return namespace(what="VPX")
1973 @depends(in_tree_vpx, vpx_nasm, target, neon_flags)
1974 def vpx_as_flags(vpx, vpx_nasm, target, neon_flags):
1975 if vpx and vpx.arm_asm:
1976 # These flags are a lie; they're just used to enable the requisite
1977 # opcodes; actual arch detection is done at runtime.
1979 elif vpx and vpx_nasm and target.os != "WINNT" and target.cpu != "x86_64":
1982 set_config("VPX_USE_NASM", True, when=vpx_nasm)
1983 set_config("VPX_ASFLAGS", vpx_as_flags)
1989 with only_when(compile_environment):
1991 "--with-system-jpeg",
1993 help="Use system libjpeg (installed at given prefix)",
1996 @depends_if("--with-system-jpeg")
1997 def jpeg_flags(value):
2000 cflags=("-I%s/include" % value[0],),
2001 ldflags=("-L%s/lib" % value[0], "-ljpeg"),
2004 ldflags=("-ljpeg",),
2007 with only_when("--with-system-jpeg"):
2009 "jpeg_destroy_compress",
2010 flags=jpeg_flags.ldflags,
2011 onerror=lambda: die(
2012 "--with-system-jpeg requested but symbol "
2013 "jpeg_destroy_compress not found."
2017 c_compiler.try_compile(
2024 #if JPEG_LIB_VERSION < 62
2025 #error Insufficient JPEG library version
2028 flags=jpeg_flags.cflags,
2029 check_msg="for sufficient jpeg library version",
2030 onerror=lambda: die(
2031 "Insufficient JPEG library version for "
2032 "--with-system-jpeg (62 required)"
2036 c_compiler.try_compile(
2043 #ifndef JCS_EXTENSIONS
2044 #error libjpeg-turbo JCS_EXTENSIONS required
2047 flags=jpeg_flags.cflags,
2048 check_msg="for sufficient libjpeg-turbo JCS_EXTENSIONS",
2049 onerror=lambda: die(
2050 "libjpeg-turbo JCS_EXTENSIONS required for " "--with-system-jpeg"
2054 set_config("MOZ_JPEG_CFLAGS", jpeg_flags.cflags)
2055 set_config("MOZ_JPEG_LIBS", jpeg_flags.ldflags)
2057 @depends("--with-system-jpeg", target, neon_flags)
2058 def in_tree_jpeg_arm(system_jpeg, target, neon_flags):
2062 if target.cpu == "arm":
2064 elif target.cpu == "aarch64":
2065 return ("-march=armv8-a",)
2067 @depends("--with-system-jpeg", target)
2068 def in_tree_jpeg_mips64(system_jpeg, target):
2072 if target.cpu == "mips64":
2073 return ("-Wa,-mloongson-mmi", "-mloongson-ext")
2075 # Compiler check from https://github.com/libjpeg-turbo/libjpeg-turbo/blob/57ba02a408a9a55ccff25aae8b164632a3a4f177/simd/CMakeLists.txt#L419
2076 jpeg_mips64_mmi = c_compiler.try_compile(
2077 body='int c = 0, a = 0, b = 0; asm("paddb %0, %1, %2" : "=f" (c) : "f" (a), "f" (b));',
2078 check_msg="for loongson mmi support",
2079 flags=in_tree_jpeg_mips64,
2080 when=in_tree_jpeg_mips64,
2084 "--with-system-jpeg",
2087 in_tree_jpeg_mips64,
2091 system_jpeg, target, in_tree_jpeg_arm, in_tree_jpeg_mips64, jpeg_mips64_mmi
2096 if target.cpu in ("arm", "aarch64"):
2097 return in_tree_jpeg_arm
2098 elif target.kernel == "Darwin":
2099 if target.cpu == "x86":
2100 return ("-DPIC", "-DMACHO")
2101 elif target.cpu == "x86_64":
2102 return ("-D__x86_64__", "-DPIC", "-DMACHO")
2103 elif target.kernel == "WINNT":
2104 if target.cpu == "x86":
2105 return ("-DPIC", "-DWIN32")
2106 elif target.cpu == "x86_64":
2107 return ("-D__x86_64__", "-DPIC", "-DWIN64", "-DMSVC")
2108 elif target.cpu == "mips32":
2110 elif target.cpu == "mips64" and jpeg_mips64_mmi:
2111 return in_tree_jpeg_mips64
2112 elif target.cpu == "x86":
2113 return ("-DPIC", "-DELF")
2114 elif target.cpu == "x86_64":
2115 return ("-D__x86_64__", "-DPIC", "-DELF")
2117 @depends(target, when=depends("--with-system-jpeg")(lambda x: not x))
2118 def jpeg_nasm(target):
2119 if target.cpu in ("x86", "x86_64"):
2120 # libjpeg-turbo 2.0.6 requires nasm 2.10.
2121 return namespace(version="2.10", what="JPEG")
2123 # Compiler checks from https://github.com/libjpeg-turbo/libjpeg-turbo/blob/57ba02a408a9a55ccff25aae8b164632a3a4f177/simd/CMakeLists.txt#L258
2124 jpeg_arm_neon_vld1_s16_x3 = c_compiler.try_compile(
2125 includes=["arm_neon.h"],
2126 body="int16_t input[12] = {}; int16x4x3_t output = vld1_s16_x3(input);",
2127 check_msg="for vld1_s16_x3 in arm_neon.h",
2128 flags=in_tree_jpeg_arm,
2129 when=in_tree_jpeg_arm,
2132 jpeg_arm_neon_vld1_u16_x2 = c_compiler.try_compile(
2133 includes=["arm_neon.h"],
2134 body="uint16_t input[8] = {}; uint16x4x2_t output = vld1_u16_x2(input);",
2135 check_msg="for vld1_u16_x2 in arm_neon.h",
2136 flags=in_tree_jpeg_arm,
2137 when=in_tree_jpeg_arm,
2140 jpeg_arm_neon_vld1q_u8_x4 = c_compiler.try_compile(
2141 includes=["arm_neon.h"],
2142 body="uint8_t input[64] = {}; uint8x16x4_t output = vld1q_u8_x4(input);",
2143 check_msg="for vld1q_u8_x4 in arm_neon.h",
2144 flags=in_tree_jpeg_arm,
2145 when=in_tree_jpeg_arm,
2148 set_config("LIBJPEG_TURBO_USE_NASM", True, when=jpeg_nasm)
2149 set_config("LIBJPEG_TURBO_SIMD_FLAGS", in_tree_jpeg)
2150 set_config("LIBJPEG_TURBO_HAVE_VLD1_S16_X3", jpeg_arm_neon_vld1_s16_x3)
2151 set_config("LIBJPEG_TURBO_HAVE_VLD1_U16_X2", jpeg_arm_neon_vld1_u16_x2)
2152 set_config("LIBJPEG_TURBO_HAVE_VLD1Q_U8_X4", jpeg_arm_neon_vld1q_u8_x4)
2154 "LIBJPEG_TURBO_NEON_INTRINSICS",
2155 jpeg_arm_neon_vld1_s16_x3
2156 & jpeg_arm_neon_vld1_u16_x2
2157 & jpeg_arm_neon_vld1q_u8_x4,
2163 with only_when(compile_environment):
2165 "--with-system-png",
2167 help="Use system libpng",
2170 @depends("--with-system-png")
2171 def deprecated_system_png_path(value):
2174 "--with-system-png=PATH is not supported anymore. Please use "
2175 "--with-system-png and set any necessary pkg-config environment variable."
2178 png = pkg_check_modules("MOZ_PNG", "libpng >= 1.6.35", when="--with-system-png")
2183 onerror=lambda: die(
2184 "--with-system-png won't work because the system's libpng doesn't have APNG support"
2186 when="--with-system-png",
2189 set_config("MOZ_SYSTEM_PNG", True, when="--with-system-png")
2192 # FFmpeg's ffvpx configuration
2193 # ==============================================================
2194 with only_when(compile_environment):
2197 def libav_fft(target):
2198 if target.os == "Android" and target.cpu != "arm":
2200 return target.kernel in ("WINNT", "Darwin") or target.cpu == "x86_64"
2202 set_config("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
2203 set_define("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
2206 # Artifact builds need MOZ_FFVPX defined as if compilation happened.
2207 with only_when(compile_environment | artifact_builds):
2211 enable = use_nasm = True
2215 if target.kernel == "WINNT":
2216 if target.cpu == "x86":
2217 # 32-bit windows need to prefix symbols with an underscore.
2218 flags = ["-DPIC", "-DWIN32", "-DPREFIX", "-Pconfig_win32.asm"]
2219 elif target.cpu == "x86_64":
2225 "-Pconfig_win64.asm",
2227 elif target.cpu == "aarch64":
2228 flags = ["-DPIC", "-DWIN64"]
2230 elif target.kernel == "Darwin":
2231 # 32/64-bit macosx assemblers need to prefix symbols with an
2233 flags = ["-DPIC", "-DMACHO", "-DPREFIX"]
2234 if target.cpu == "x86_64":
2237 "-Pconfig_darwin64.asm",
2239 elif target.cpu == "aarch64":
2241 elif target.cpu == "x86_64":
2242 flags = ["-D__x86_64__", "-DPIC", "-DELF", "-Pconfig_unix64.asm"]
2243 elif target.cpu in ("x86", "arm", "aarch64"):
2248 if flac_only or not enable:
2254 flac_only=flac_only,
2258 @depends(when=ffvpx.use_nasm)
2260 # nasm 2.10 for AVX-2 support.
2261 return namespace(version="2.10", what="FFVPX")
2263 # ffvpx_nasm can't indirectly depend on vpx_as_flags, because it depends
2264 # on a compiler test, so we have to do a little bit of dance here.
2265 @depends(ffvpx, vpx_as_flags, target)
2266 def ffvpx(ffvpx, vpx_as_flags, target):
2267 if ffvpx and vpx_as_flags and target.cpu in ("arm", "aarch64"):
2268 ffvpx.flags.extend(vpx_as_flags)
2271 set_config("MOZ_FFVPX", True, when=ffvpx.enable)
2272 set_define("MOZ_FFVPX", True, when=ffvpx.enable)
2273 set_config("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.flac_only)
2274 set_define("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.flac_only)
2275 set_config("FFVPX_ASFLAGS", ffvpx.flags)
2276 set_config("FFVPX_USE_NASM", True, when=ffvpx.use_nasm)
2280 # ==============================================================
2281 @depends(dav1d_nasm, vpx_nasm, jpeg_nasm, ffvpx_nasm, when=compile_environment)
2282 def need_nasm(*requirements):
2284 x.what: x.version if hasattr(x, "version") else True for x in requirements if x
2287 items = sorted(requires.keys())
2289 what = " and ".join((", ".join(items[:-1]), items[-1]))
2292 versioned = {k: v for (k, v) in requires.items() if v is not True}
2293 return namespace(what=what, versioned=versioned)
2305 @depends(nasm, need_nasm.what)
2306 def check_nasm(nasm, what):
2307 if not nasm and what:
2308 die("Nasm is required to build with %s, but it was not found." % what)
2312 @depends_if(check_nasm)
2313 @checking("nasm version")
2314 def nasm_version(nasm):
2316 check_cmd_output(nasm, "-v", onerror=lambda: die("Failed to get nasm version."))
2320 return Version(version)
2323 @depends(nasm_version, need_nasm.versioned, when=need_nasm.versioned)
2324 def check_nasm_version(nasm_version, versioned):
2325 by_version = sorted(versioned.items(), key=lambda x: x[1])
2326 what, version = by_version[-1]
2327 if nasm_version < version:
2329 "Nasm version %s or greater is required to build with %s." % (version, what)
2334 @depends(target, when=check_nasm_version)
2335 def nasm_asflags(target):
2337 ("OSX", "x86"): ["-f", "macho32"],
2338 ("OSX", "x86_64"): ["-f", "macho64"],
2339 ("WINNT", "x86"): ["-f", "win32"],
2340 ("WINNT", "x86_64"): ["-f", "win64"],
2341 }.get((target.os, target.cpu), None)
2343 # We're assuming every x86 platform we support that's
2344 # not Windows or Mac is ELF.
2345 if target.cpu == "x86":
2346 asflags = ["-f", "elf32"]
2347 elif target.cpu == "x86_64":
2348 asflags = ["-f", "elf64"]
2352 set_config("NASM_ASFLAGS", nasm_asflags)
2355 # ANGLE OpenGL->D3D translator for WebGL
2356 # ==============================================================
2358 with only_when(compile_environment & target_is_windows):
2360 def d3d_compiler_dll_result(value):
2362 return "provided by the OS"
2365 @depends(target, valid_windows_sdk_dir, fxc)
2366 @checking("for D3D compiler DLL", d3d_compiler_dll_result)
2368 def d3d_compiler_dll(target, windows_sdk_dir, fxc):
2371 }.get(target.cpu, target.cpu)
2373 name = "d3dcompiler_47.dll"
2375 if target.cpu == "aarch64":
2376 # AArch64 Windows comes with d3dcompiler_47.dll installed
2377 return namespace(name=name, path=None)
2380 path = os.path.join(windows_sdk_dir.path, "Redist", "D3D", suffix, name)
2381 error_extra = "in Windows SDK at {}".format(windows_sdk_dir.path)
2383 path = os.path.join(os.path.dirname(fxc), name)
2384 error_extra = "alongside FXC at {}".format(fxc)
2386 if os.path.exists(path):
2387 return namespace(name=name, path=path)
2388 die("Could not find {} {}".format(name, error_extra))
2390 set_config("MOZ_ANGLE_RENDERER", True)
2392 "MOZ_D3DCOMPILER_VISTA_DLL", d3d_compiler_dll.name, when=d3d_compiler_dll.path
2394 set_config("MOZ_D3DCOMPILER_VISTA_DLL_PATH", d3d_compiler_dll.path)
2396 # Remoting protocol support
2397 # ==============================================================
2401 def has_remote(toolkit):
2402 if toolkit in ("gtk", "windows", "cocoa"):
2406 set_config("MOZ_HAS_REMOTE", has_remote)
2407 set_define("MOZ_HAS_REMOTE", has_remote)
2409 # RLBox Library Sandboxing wasm support
2410 # ==============================================================
2413 def wasm_sandboxing_libraries():
2423 @depends(dependable(wasm_sandboxing_libraries), build_project)
2424 def default_wasm_sandboxing_libraries(libraries, build_project):
2425 if build_project != "tools/rusttests":
2426 non_default_libs = set()
2428 return tuple(l for l in libraries if l not in non_default_libs)
2432 "--with-wasm-sandboxed-libraries",
2433 env="WASM_SANDBOXED_LIBRARIES",
2434 help="{Enable wasm sandboxing for the selected libraries|Disable wasm sandboxing}",
2436 choices=dependable(wasm_sandboxing_libraries),
2437 default=default_wasm_sandboxing_libraries,
2441 @depends("--with-wasm-sandboxed-libraries")
2442 def requires_wasm_sandboxing(libraries):
2447 set_config("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
2448 set_define("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
2450 with only_when(requires_wasm_sandboxing & compile_environment):
2452 "--with-wasi-sysroot",
2455 help="Path to wasi sysroot for wasm sandboxing",
2458 @depends("--with-wasi-sysroot", requires_wasm_sandboxing)
2459 def bootstrap_wasi_sysroot(wasi_sysroot, requires_wasm_sandboxing):
2460 return requires_wasm_sandboxing and not wasi_sysroot
2463 "--with-wasi-sysroot",
2464 bootstrap_path("sysroot-wasm32-wasi", when=bootstrap_wasi_sysroot),
2467 def wasi_sysroot(wasi_sysroot, bootstrapped_sysroot):
2468 if not wasi_sysroot:
2469 return bootstrapped_sysroot
2471 wasi_sysroot = wasi_sysroot[0]
2472 if not os.path.isdir(wasi_sysroot):
2473 die("Argument to --with-wasi-sysroot must be a directory")
2474 if not os.path.isabs(wasi_sysroot):
2475 die("Argument to --with-wasi-sysroot must be an absolute path")
2479 @depends(wasi_sysroot)
2480 def wasi_sysroot_flags(wasi_sysroot):
2482 log.info("Using wasi sysroot in %s", wasi_sysroot)
2483 return ["--sysroot=%s" % wasi_sysroot]
2486 set_config("WASI_SYSROOT", wasi_sysroot)
2488 def wasm_compiler_with_flags(compiler, sysroot_flags):
2491 compiler.wrapper + [compiler.compiler] + compiler.flags + sysroot_flags
2495 def wasm_compiler_error(msg):
2496 @depends("--with-wasm-sandboxed-libraries")
2497 def wasm_compiler_error(sandboxed_libs):
2498 suggest_disable = ""
2499 if sandboxed_libs.origin == "default":
2500 suggest_disable = " Or build with --without-wasm-sandboxed-libraries."
2501 return lambda: die(msg + suggest_disable)
2503 return wasm_compiler_error
2506 def check_wasm_compiler(compiler, language):
2507 compiler.try_compile(
2508 includes=["cstring" if language == "C++" else "string.h"],
2509 flags=wasi_sysroot_flags,
2510 check_msg="the wasm %s compiler can find wasi headers" % language,
2511 onerror=wasm_compiler_error(
2512 "Cannot find wasi headers or problem with the wasm compiler. "
2513 "Please fix the problem."
2518 flags=wasi_sysroot_flags,
2519 check_msg="the wasm %s linker can find wasi libraries" % language,
2520 onerror=wasm_compiler_error(
2521 "Cannot find wasi libraries or problem with the wasm linker. "
2522 "Please fix the problem."
2526 wasm_cc = compiler("C", wasm, other_compiler=c_compiler)
2527 check_wasm_compiler(wasm_cc, "C")
2529 @depends(wasm_cc, wasi_sysroot_flags)
2530 def wasm_cc_with_flags(wasm_cc, wasi_sysroot_flags):
2531 return wasm_compiler_with_flags(wasm_cc, wasi_sysroot_flags)
2533 set_config("WASM_CC", wasm_cc_with_flags)
2535 wasm_cxx = compiler(
2539 other_compiler=cxx_compiler,
2540 other_c_compiler=c_compiler,
2542 check_wasm_compiler(wasm_cxx, "C++")
2544 @depends(wasm_cxx, wasi_sysroot_flags)
2545 def wasm_cxx_with_flags(wasm_cxx, wasi_sysroot_flags):
2546 return wasm_compiler_with_flags(wasm_cxx, wasi_sysroot_flags)
2548 set_config("WASM_CXX", wasm_cxx_with_flags)
2550 wasm_compile_flags = dependable(["-fno-exceptions", "-fno-strict-aliasing"])
2551 option(env="WASM_CFLAGS", nargs=1, help="Options to pass to WASM_CC")
2553 @depends("WASM_CFLAGS", wasm_compile_flags)
2554 def wasm_cflags(value, wasm_compile_flags):
2556 return wasm_compile_flags + value
2558 return wasm_compile_flags
2560 set_config("WASM_CFLAGS", wasm_cflags)
2562 option(env="WASM_CXXFLAGS", nargs=1, help="Options to pass to WASM_CXX")
2564 @depends("WASM_CXXFLAGS", wasm_compile_flags)
2565 def wasm_cxxflags(value, wasm_compile_flags):
2567 return wasm_compile_flags + value
2569 return wasm_compile_flags
2571 set_config("WASM_CXXFLAGS", wasm_cxxflags)
2574 @depends("--with-wasm-sandboxed-libraries")
2575 def wasm_sandboxing(libraries):
2579 return namespace(**{name: True for name in libraries})
2583 def wasm_sandboxing_config_defines():
2584 for lib in wasm_sandboxing_libraries():
2586 "MOZ_WASM_SANDBOXING_%s" % lib.upper(), getattr(wasm_sandboxing, lib)
2589 "MOZ_WASM_SANDBOXING_%s" % lib.upper(), getattr(wasm_sandboxing, lib)
2593 wasm_sandboxing_config_defines()
2596 # new Notification Store implementation
2597 # ==============================================================
2601 def new_notification_store(milestone):
2602 if milestone.is_nightly:
2606 set_config("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)
2607 set_define("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)
2610 # Glean SDK Integration Crate
2611 # ==============================================================
2615 def glean_android(target):
2616 return target.os == "Android"
2619 set_config("MOZ_GLEAN_ANDROID", True, when=glean_android)
2620 set_define("MOZ_GLEAN_ANDROID", True, when=glean_android)
2624 # ==============================================================
2630 bootstrap="dump_syms",
2631 when=compile_environment,
2635 @depends(valid_windows_sdk_dir, host)
2636 @imports(_from="os", _import="environ")
2637 def pdbstr_paths(valid_windows_sdk_dir, host):
2638 if not valid_windows_sdk_dir:
2648 os.path.join(valid_windows_sdk_dir.path, "Debuggers", vc_host, "srcsrv"),
2656 when=compile_environment & target_is_windows,
2662 @depends("MOZ_AUTOMATION", c_compiler)
2663 def allow_missing_winchecksec(automation, c_compiler):
2666 if c_compiler and c_compiler.type != "clang-cl":
2672 ["winchecksec.exe", "winchecksec"],
2673 bootstrap="winchecksec",
2674 allow_missing=allow_missing_winchecksec,
2675 when=compile_environment & target_is_windows,
2679 @depends(target, build_project)
2680 def forkserver_default(target, build_project):
2681 return build_project == "browser" and (
2682 (target.os == "GNU" and target.kernel == "Linux")
2683 or target.os == "FreeBSD"
2684 or target.os == "OpenBSD"
2689 "--enable-forkserver",
2690 default=forkserver_default,
2691 env="MOZ_ENABLE_FORKSERVER",
2692 help="{Enable|Disable} fork server",
2696 @depends("--enable-forkserver", target)
2697 def forkserver_flag(value, target):
2699 target.os == "Android"
2700 or (target.os == "GNU" and target.kernel == "Linux")
2701 or target.os == "FreeBSD"
2702 or target.os == "OpenBSD"
2708 set_config("MOZ_ENABLE_FORKSERVER", forkserver_flag)
2709 set_define("MOZ_ENABLE_FORKSERVER", forkserver_flag, forkserver_flag)
2712 # ==============================================================
2714 with only_when(compile_environment & target_has_linux_kernel):
2715 # Check if we need to use the breakpad_getcontext fallback.
2716 getcontext = check_symbol("getcontext")
2717 set_config("HAVE_GETCONTEXT", getcontext)
2718 set_define("HAVE_GETCONTEXT", getcontext)
2721 # ==============================================================
2722 include("../build/moz.configure/nss.configure")
2725 # Enable or disable running in background task mode: headless for
2726 # periodic, short-lived, maintenance tasks.
2727 # ==============================================================================
2729 "--disable-backgroundtasks",
2730 help="Disable running in background task mode",
2732 set_config("MOZ_BACKGROUNDTASKS", True, when="--enable-backgroundtasks")
2733 set_define("MOZ_BACKGROUNDTASKS", True, when="--enable-backgroundtasks")
2736 # Update-related programs: updater, maintenance service, update agent,
2737 # default browser agent.
2738 # ==============================================================
2739 include("../build/moz.configure/update-programs.configure")
2742 # Mobile optimizations
2743 # ==============================================================
2745 "--enable-mobile-optimize",
2746 default=target_is_android,
2747 help="{Enable|Disable} mobile optimizations",
2750 set_define("MOZ_GFX_OPTIMIZE_MOBILE", True, when="--enable-mobile-optimize")
2751 # We ignore "paint will resample" on mobile for performance.
2752 # We may want to revisit this later.
2753 set_define("MOZ_IGNORE_PAINT_WILL_RESAMPLE", True, when="--enable-mobile-optimize")
2756 # ==============================================================
2757 option("--disable-pref-extensions", help="Disable pref extensions such as autoconfig")
2758 set_config("MOZ_PREF_EXTENSIONS", True, when="--enable-pref-extensions")
2760 # Offer a way to disable the startup cache
2761 # ==============================================================
2762 option("--disable-startupcache", help="Disable startup cache")
2765 @depends("--enable-startupcache")
2766 def enable_startupcache(value):
2772 "MOZ_DISABLE_STARTUPCACHE", True, when=depends(enable_startupcache)(lambda x: not x)
2777 # ==============================================================
2779 env="MOZ_APP_REMOTINGNAME",
2781 help="Used for the internal program name, which affects profile name "
2782 "and remoting. If not set, defaults to MOZ_APP_NAME if the update channel "
2783 "is release, and MOZ_APP_NAME-MOZ_UPDATE_CHANNEL otherwise.",
2787 @depends("MOZ_APP_REMOTINGNAME", moz_app_name, update_channel)
2788 def moz_app_remotingname(value, moz_app_name, update_channel):
2791 if update_channel == "release":
2793 return moz_app_name + "-" + update_channel
2796 set_config("MOZ_APP_REMOTINGNAME", moz_app_remotingname)
2799 env="ANDROID_PACKAGE_NAME",
2801 help="Name of the Android package (default org.mozilla.$MOZ_APP_NAME)",
2805 @depends("ANDROID_PACKAGE_NAME", moz_app_name)
2806 def android_package_name(value, moz_app_name):
2809 if moz_app_name == "fennec":
2810 return "org.mozilla.fennec_aurora"
2811 return "org.mozilla.%s" % moz_app_name
2814 set_config("ANDROID_PACKAGE_NAME", android_package_name)
2817 # Miscellaneous options
2818 # ==============================================================
2819 option(env="MOZ_WINCONSOLE", nargs="?", help="Whether we can create a console window.")
2820 set_define("MOZ_WINCONSOLE", True, when=depends("MOZ_WINCONSOLE")(lambda x: x))
2823 # Alternative Crashreporter setting
2825 "--with-crashreporter-url",
2826 env="MOZ_CRASHREPORTER_URL",
2827 default="https://crash-reports.mozilla.com/",
2829 help="Set an alternative crashreporter url",
2833 "MOZ_CRASHREPORTER_URL",
2834 depends("--with-crashreporter-url")(lambda x: x[0].rstrip("/")),
2838 # Crash reporter options
2839 # ==============================================================
2841 def oxidized_breakpad(target):
2842 if target.kernel == "Linux" and target.os != "Android":
2843 return target.cpu in ("x86", "x86_64")
2847 set_config("MOZ_OXIDIZED_BREAKPAD", True, when=oxidized_breakpad)
2848 set_define("MOZ_OXIDIZED_BREAKPAD", True, when=oxidized_breakpad)
2852 # ==============================================================
2853 @depends(target, host)
2854 def want_wine(target, host):
2855 return target.kernel == "WINNT" and host.kernel != "WINNT"
2862 bootstrap="wine/bin",
2866 # ==============================================================
2867 # Set this to true so the JS engine knows we're doing a browser build.
2868 set_config("MOZ_DOM_STREAMS", True)
2869 set_define("MOZ_DOM_STREAMS", True)
2872 # ==============================================================
2873 with only_when(compile_environment):
2875 "--with-system-libevent",
2877 help="Use system libevent",
2880 @depends("--with-system-libevent")
2881 def deprecated_system_libevent_path(value):
2884 "--with-system-libevent=PATH is not supported anymore. Please use "
2885 "--with-system-libevent and set any necessary pkg-config environment variable."
2888 pkg_check_modules("MOZ_LIBEVENT", "libevent", when="--with-system-libevent")
2890 set_config("MOZ_SYSTEM_LIBEVENT", True, when="--with-system-libevent")
2894 # ==============================================================
2895 @depends(target, developer_options, artifact_builds)
2896 def crashreporter_default(target, developer_options, artifacts):
2897 if target.kernel in ("WINNT", "Darwin"):
2899 if target.kernel == "Linux" and target.cpu in ("x86", "x86_64", "arm", "aarch64"):
2900 # The crash reporter prevents crash stacktraces to be logged in the
2901 # logs on Android, so we leave it out by default in developer builds.
2902 return target.os != "Android" or not developer_options or artifacts
2906 "--enable-crashreporter",
2907 default=crashreporter_default,
2908 help="{Enable|Disable} crash reporting",
2912 set_config("MOZ_CRASHREPORTER", True, when="--enable-crashreporter")
2913 set_define("MOZ_CRASHREPORTER", True, when="--enable-crashreporter")
2915 with only_when(compile_environment):
2916 with only_when("--enable-crashreporter"):
2920 when=depends(target)(lambda t: t.os == "GNU" and t.kernel == "Linux"),
2924 "MOZ_CRASHREPORTER_INJECTOR",
2926 when=depends(target)(lambda t: t.os == "WINNT" and t.bitness == 32),
2929 "MOZ_CRASHREPORTER_INJECTOR",
2931 when=depends(target)(lambda t: t.os == "WINNT" and t.bitness == 32),
2935 # If we have any service that uploads data (and requires data submission
2936 # policy alert), set MOZ_DATA_REPORTING.
2937 # ==============================================================
2939 "MOZ_TELEMETRY_REPORTING",
2940 "MOZ_SERVICES_HEALTHREPORT",
2941 "--enable-crashreporter",
2944 def data_reporting(telemetry, healthreport, crashreporter, normandy):
2945 return telemetry or healthreport or crashreporter or normandy
2948 set_config("MOZ_DATA_REPORTING", True, when=data_reporting)
2949 set_define("MOZ_DATA_REPORTING", True, when=data_reporting)
2953 # ==============================================================
2954 with only_when(toolkit_gtk):
2957 "gtk+-3.0 >= 3.14.0 gtk+-unix-print-3.0 glib-2.0 gobject-2.0 gio-unix-2.0",
2960 set_define("GDK_VERSION_MIN_REQUIRED", "GDK_VERSION_3_14")
2961 set_define("GDK_VERSION_MAX_ALLOWED", "GDK_VERSION_3_14")
2963 pkg_check_modules("GLIB", "glib-2.0 >= 2.42 gobject-2.0")
2965 set_define("GLIB_VERSION_MIN_REQUIRED", "GLIB_VERSION_2_42")
2966 set_define("GLIB_VERSION_MAX_ALLOWED", "GLIB_VERSION_2_42")
2968 set_define("MOZ_ACCESSIBILITY_ATK", True, when=accessibility)
2971 # ==============================================================
2972 with only_when(toolkit_gtk):
2973 option("--disable-dbus", help="Disable dbus support")
2975 with only_when("--enable-dbus"):
2976 pkg_check_modules("MOZ_DBUS", "dbus-1 >= 0.60")
2977 pkg_check_modules("MOZ_DBUS_GLIB", "dbus-glib-1 >= 0.60")
2979 set_config("MOZ_ENABLE_DBUS", True)
2980 set_define("MOZ_ENABLE_DBUS", True)
2983 # Necko's wifi scanner
2984 # ==============================================================
2986 def necko_wifi_when(target):
2987 return target.os in ("WINNT", "OSX", "DragonFly", "FreeBSD") or (
2988 target.kernel == "Linux" and target.os == "GNU"
2992 option("--disable-necko-wifi", help="Disable necko wifi scanner", when=necko_wifi_when)
2994 set_config("NECKO_WIFI", True, when="--enable-necko-wifi")
2995 set_define("NECKO_WIFI", True, when="--enable-necko-wifi")
2999 depends("--enable-necko-wifi", when=necko_wifi_when)(lambda x: x),
3000 depends("--enable-dbus", when=toolkit_gtk)(lambda x: x),
3001 when=depends(target)(lambda t: t.os == "GNU" and t.kernel == "Linux"),
3003 def necko_wifi_dbus(necko_wifi, dbus):
3004 if necko_wifi and not dbus:
3006 "Necko WiFi scanning needs DBus on your platform, remove --disable-dbus"
3007 " or use --disable-necko-wifi"
3009 return necko_wifi and dbus
3012 set_config("NECKO_WIFI_DBUS", True, when=necko_wifi_dbus)
3013 set_define("NECKO_WIFI_DBUS", True, when=necko_wifi_dbus)
3016 # Frontend JS debug mode
3017 # ==============================================================
3018 option("--enable-debug-js-modules", help="Enable debug mode for frontend JS libraries")
3020 set_config("DEBUG_JS_MODULES", True, when="--enable-debug-js-modules")
3024 # ==============================================================
3025 option("--enable-dump-painting", help="Enable paint debugging")
3028 "MOZ_DUMP_PAINTING",
3030 when=depends("--enable-dump-painting", "--enable-debug")(
3031 lambda painting, debug: painting or debug
3034 set_define("MOZ_LAYERS_HAVE_LOG", True, when="--enable-dump-painting")
3038 # ==============================================================
3039 with only_when(toolkit_gtk):
3040 system_lib_option("--enable-libproxy", help="Enable libproxy support")
3042 with only_when("--enable-libproxy"):
3043 pkg_check_modules("MOZ_LIBPROXY", "libproxy-1.0")
3045 set_config("MOZ_ENABLE_LIBPROXY", True)
3046 set_define("MOZ_ENABLE_LIBPROXY", True)
3049 # Enable runtime logging
3050 # ==============================================================
3051 set_define("MOZ_LOGGING", True)
3052 set_define("FORCE_PR_LOG", True)
3054 # This will enable logging of addref, release, ctor, dtor.
3055 # ==============================================================
3057 "--enable-logrefcnt",
3059 help="{Enable|Disable} logging of refcounts",
3062 set_define("NS_BUILD_REFCNT_LOGGING", True, when="--enable-logrefcnt")
3066 # ==============================================================
3067 option("--disable-negotiateauth", help="Disable GSS-API negotiation")
3069 set_config("MOZ_AUTH_EXTENSION", True, when="--enable-negotiateauth")
3070 set_define("MOZ_AUTH_EXTENSION", True, when="--enable-negotiateauth")
3074 # ==============================================================
3075 option("--disable-parental-controls", help="Do not build parental controls")
3078 "MOZ_DISABLE_PARENTAL_CONTROLS",
3080 when=depends("--enable-parental-controls")(lambda x: not x),
3083 "MOZ_DISABLE_PARENTAL_CONTROLS",
3085 when=depends("--enable-parental-controls")(lambda x: not x),
3089 # Sandboxing support
3090 # ==============================================================
3091 @depends(target, tsan, asan)
3092 def sandbox_default(target, tsan, asan):
3093 # Only enable the sandbox by default on Linux, OpenBSD, macOS, and Windows
3094 if target.kernel == "Linux" and target.os == "GNU":
3095 # Bug 1182565: TSan conflicts with sandboxing on Linux.
3096 # Bug 1287971: LSan also conflicts with sandboxing on Linux.
3099 # Linux sandbox is only available on x86{,_64} and arm{,64}.
3100 return target.cpu in ("x86", "x86_64", "arm", "aarch64")
3101 return target.kernel in ("WINNT", "Darwin", "OpenBSD")
3106 default=sandbox_default,
3107 help="{Enable|Disable} sandboxing support",
3110 set_config("MOZ_SANDBOX", True, when="--enable-sandbox")
3111 set_define("MOZ_SANDBOX", True, when="--enable-sandbox")
3113 with only_when(depends(target.kernel)(lambda k: k not in ("Darwin", "WINNT"))):
3114 set_define("MOZ_CONTENT_TEMP_DIR", True, when="--enable-sandbox")
3116 # Searching of system directories for extensions.
3117 # ==============================================================
3118 # Note: this switch is meant to be used for test builds whose behavior should
3119 # not depend on what happens to be installed on the local machine.
3121 "--disable-system-extension-dirs",
3122 help="Disable searching system- and account-global directories for extensions"
3123 " of any kind; use only profile-specific extension directories",
3126 set_define("ENABLE_SYSTEM_EXTENSION_DIRS", True, when="--enable-system-extension-dirs")
3130 # ==============================================================
3131 with only_when(compile_environment):
3133 "--enable-system-pixman", help="Use system pixman (located with pkgconfig)"
3136 @depends("--enable-system-pixman")
3137 def in_tree_pixman(pixman):
3140 set_config("MOZ_TREE_PIXMAN", True, when=in_tree_pixman)
3141 set_define("MOZ_TREE_PIXMAN", True, when=in_tree_pixman)
3143 pkg_check_modules("MOZ_PIXMAN", "pixman-1 >= 0.36.0", when="--enable-system-pixman")
3144 # Set MOZ_PIXMAN_CFLAGS to an explicit empty value when --enable-system-pixman is *not* used,
3145 # for layout/style/extra-bindgen-flags
3146 set_config("MOZ_PIXMAN_CFLAGS", [], when=in_tree_pixman)
3150 # ==============================================================
3151 with only_when(compile_environment):
3152 option("--disable-universalchardet", help="Disable universal encoding detection")
3154 set_config("MOZ_UNIVERSALCHARDET", True, when="--enable-universalchardet")
3158 # ==============================================================
3159 with only_when(compile_environment):
3160 option("--disable-zipwriter", help="Disable zipwriter component")
3162 set_config("MOZ_ZIPWRITER", True, when="--enable-zipwriter")
3165 # Location of the mozilla user directory
3166 # ==============================================================
3167 with only_when(compile_environment):
3170 def default_user_appdir(target):
3171 if target.kernel in ("WINNT", "Darwin"):
3176 "--with-user-appdir",
3178 default=default_user_appdir,
3179 help="Set user-specific appdir",
3182 @depends("--with-user-appdir")
3183 def user_appdir(appdir):
3185 die("--without-user-appdir is not a valid option.")
3186 if "/" in appdir[0]:
3187 die("--with-user-appdir must be a single relative path.")
3188 return '"{}"'.format(appdir[0])
3190 set_define("MOZ_USER_DIR", user_appdir)
3193 # Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
3194 # ==============================================================
3195 with only_when(compile_environment):
3196 have_sin_len = c_compiler.try_compile(
3197 includes=["netinet/in.h"],
3198 body="struct sockaddr_in x; void *foo = (void*) &x.sin_len;",
3199 check_msg="for sin_len in struct sockaddr_in",
3201 have_sin6_len = c_compiler.try_compile(
3202 includes=["netinet/in.h"],
3203 body="struct sockaddr_in6 x; void *foo = (void*) &x.sin6_len;",
3204 check_msg="for sin_len6 in struct sockaddr_in6",
3206 set_define("HAVE_SIN_LEN", have_sin_len)
3207 set_define("HAVE_SIN6_LEN", have_sin6_len)
3208 # HAVE_CONN_LEN must be the same as HAVE_SIN_LEN and HAVE_SIN6_LEN
3209 set_define("HAVE_SCONN_LEN", have_sin_len & have_sin6_len)
3212 c_compiler.try_compile(
3213 includes=["netinet/in.h"],
3214 body="struct sockaddr x; void *foo = (void*) &x.sa_len;",
3215 check_msg="for sa_len in struct sockaddr",
3220 # Check for pthread_cond_timedwait_monotonic_np
3221 # ==============================================================
3222 with only_when(compile_environment):
3224 "HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC",
3225 c_compiler.try_compile(
3226 includes=["pthread.h"],
3227 body="pthread_cond_timedwait_monotonic_np(0, 0, 0);",
3228 # -Werror to catch any "implicit declaration" warning that means the function
3230 flags=["-Werror=implicit-function-declaration"],
3231 check_msg="for pthread_cond_timedwait_monotonic_np",
3236 # Custom dynamic linker for Android
3237 # ==============================================================
3238 with only_when(target_has_linux_kernel & compile_environment):
3241 default=depends(target.os, when="--enable-jemalloc")(
3242 lambda os: os == "Android"
3244 help="{Enable|Disable} custom dynamic linker",
3247 set_config("MOZ_LINKER", True, when="MOZ_LINKER")
3248 set_define("MOZ_LINKER", True, when="MOZ_LINKER")
3249 add_old_configure_assignment("MOZ_LINKER", True, when="MOZ_LINKER")
3251 moz_linker = depends(when="MOZ_LINKER")(lambda: True)
3254 # 32-bits ethtool_cmd.speed
3255 # ==============================================================
3256 with only_when(target_has_linux_kernel & compile_environment):
3258 "MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI",
3259 c_compiler.try_compile(
3260 includes=["linux/ethtool.h"],
3261 body="struct ethtool_cmd cmd; cmd.speed_hi = 0;",
3262 check_msg="for 32-bits ethtool_cmd.speed",
3267 # ==============================================================
3270 onerror=lambda: die(
3271 "Can't find header linux/joystick.h, needed for gamepad support."
3272 " Please install Linux kernel headers."
3274 when=target_has_linux_kernel & compile_environment,
3277 # Smart card support
3278 # ==============================================================
3279 @depends(build_project)
3280 def disable_smart_cards(build_project):
3281 return build_project == "mobile/android"
3284 set_config("MOZ_NO_SMART_CARDS", True, when=disable_smart_cards)
3285 set_define("MOZ_NO_SMART_CARDS", True, when=disable_smart_cards)
3287 # Enable UniFFI fixtures
3288 # ==============================================================
3289 # These are used to test the uniffi-bindgen-gecko-js code generation. They
3290 # should not be enabled in release builds.
3293 "--enable-uniffi-fixtures",
3294 help="Enable UniFFI Fixtures/Examples",
3297 set_config("MOZ_UNIFFI_FIXTURES", True, when="--enable-uniffi-fixtures")
3299 # Checks for library functions
3300 # ==============================================================
3301 with only_when(compile_environment & depends(target.os)(lambda os: os != "WINNT")):
3302 set_define("HAVE_STAT64", check_symbol("stat64"))
3303 set_define("HAVE_LSTAT64", check_symbol("lstat64"))
3304 set_define("HAVE_TRUNCATE64", check_symbol("truncate64"))
3305 set_define("HAVE_STATVFS64", check_symbol("statvfs64"))
3306 set_define("HAVE_STATVFS", check_symbol("statvfs"))
3307 set_define("HAVE_STATFS64", check_symbol("statfs64"))
3308 set_define("HAVE_STATFS", check_symbol("statfs"))
3309 set_define("HAVE_LUTIMES", check_symbol("lutimes"))
3310 set_define("HAVE_POSIX_FADVISE", check_symbol("posix_fadvise"))
3311 set_define("HAVE_POSIX_FALLOCATE", check_symbol("posix_fallocate"))
3313 set_define("HAVE_ARC4RANDOM", check_symbol("arc4random"))
3314 set_define("HAVE_ARC4RANDOM_BUF", check_symbol("arc4random_buf"))
3315 set_define("HAVE_MALLINFO", check_symbol("mallinfo"))
3318 # ==============================================================
3321 "--disable-system-policies",
3322 help="Disable reading policies from Windows registry, macOS's file system attributes, and /etc/firefox",
3325 set_config("MOZ_SYSTEM_POLICIES", True, when="--enable-system-policies")
3327 # Allow disabling the creation a legacy profile
3328 # ==============================================================
3331 "--disable-legacy-profile-creation",
3332 help="Disable the creation a legacy profile, to be used by old versions "
3333 "of Firefox, when no profiles exist.",
3336 set_config("MOZ_CREATE_LEGACY_PROFILE", True, when="--enable-legacy-profile-creation")
3340 # ==============================================================
3341 set_config("WRAP_STL_INCLUDES", True)
3344 depends(build_environment.dist)(lambda dist: [f"-I{dist}/stl_wrappers"]),
3349 # ==============================================================
3351 def need_perl(target):
3352 # Ideally, we'd also depend on gnu_as here, but that adds complications.
3353 return target.cpu == "arm"
3356 perl = check_prog("PERL", ("perl5", "perl"), when=need_perl)
3360 def perl_version_check(min_version):
3362 @checking("for minimum required perl version >= %s" % min_version)
3363 def get_perl_version(perl):
3369 onerror=lambda: die("Failed to get perl version."),
3373 @depends(get_perl_version)
3374 def check_perl_version(version):
3375 if version < min_version:
3376 die("Perl %s or higher is required.", min_version)
3379 @checking("for full perl installation")
3380 @imports("subprocess")
3381 def has_full_perl_installation(perl):
3382 ret = subprocess.call([perl, "-e", "use Config; exit(!-d $Config{archlib})"])
3385 @depends(has_full_perl_installation)
3386 def require_full_perl_installation(has_full_perl_installation):
3387 if not has_full_perl_installation:
3389 "Cannot find Config.pm or $Config{archlib}. "
3390 "A full perl installation is required."
3394 with only_when(need_perl):
3395 perl_version_check("5.006")