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 libdrm >= 2.4",
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))
509 # ==============================================================
510 option("--with-gl-provider", nargs=1, help="Set GL provider backend type")
513 @depends("--with-gl-provider")
514 def gl_provider(value):
519 @depends(gl_provider)
520 def gl_provider_define(provider):
522 return "GLContextProvider%s" % provider
525 set_define("MOZ_GL_PROVIDER", gl_provider_define)
528 @depends(gl_provider, wayland_headers, toolkit_gtk)
529 def gl_default_provider(value, wayland, toolkit_gtk):
538 set_config("MOZ_GL_PROVIDER", gl_provider)
539 set_config("MOZ_GL_DEFAULT_PROVIDER", gl_default_provider)
542 @depends(gl_default_provider)
543 def gl_provider_define(provider):
545 return "GL_PROVIDER_%s" % provider
548 set_define(gl_provider_define, True)
552 # ==============================================================
554 def pdf_printing(toolkit):
555 if toolkit in ("windows", "gtk", "android"):
559 set_config("MOZ_PDF_PRINTING", pdf_printing)
560 set_define("MOZ_PDF_PRINTING", pdf_printing)
563 # Event loop instrumentation
564 # ==============================================================
565 option(env="MOZ_INSTRUMENT_EVENT_LOOP", help="Force-enable event loop instrumentation")
568 @depends("MOZ_INSTRUMENT_EVENT_LOOP", toolkit)
569 def instrument_event_loop(value, toolkit):
571 toolkit in ("windows", "gtk", "cocoa", "android") and value.origin == "default"
576 set_config("MOZ_INSTRUMENT_EVENT_LOOP", instrument_event_loop)
577 set_define("MOZ_INSTRUMENT_EVENT_LOOP", instrument_event_loop)
580 # Fontconfig Freetype
581 # ==============================================================
582 option(env="USE_FC_FREETYPE", help="Force-enable the use of fontconfig freetype")
585 @depends("USE_FC_FREETYPE", toolkit)
586 def fc_freetype(value, toolkit):
587 if value or (toolkit == "gtk" and value.origin == "default"):
591 set_define("USE_FC_FREETYPE", fc_freetype)
594 # ==============================================================
595 pkg_check_modules("MOZ_PANGO", "pango >= 1.22.0", when=toolkit_gtk)
598 # ==============================================================
599 fontconfig_info = pkg_check_modules(
600 "_FONTCONFIG", "fontconfig >= 2.7.0", when=fc_freetype
604 @depends(fc_freetype)
605 def check_for_freetype2(fc_freetype):
610 # Check for freetype2. Flags are combined with fontconfig flags.
611 freetype2_info = pkg_check_modules(
612 "_FT2", "freetype2 >= 9.10.3", when=check_for_freetype2
616 @depends(fontconfig_info, freetype2_info)
617 def freetype2_combined_info(fontconfig_info, freetype2_info):
618 if not freetype2_info:
620 if not fontconfig_info:
621 return freetype2_info
623 cflags=freetype2_info.cflags + fontconfig_info.cflags,
624 libs=freetype2_info.libs + fontconfig_info.libs,
628 set_define("MOZ_HAVE_FREETYPE2", depends_if(freetype2_info)(lambda _: True))
630 # Apple platform decoder support
631 # ==============================================================
633 def applemedia(toolkit):
634 if toolkit in ("cocoa", "uikit"):
638 set_config("MOZ_APPLEMEDIA", applemedia)
639 set_define("MOZ_APPLEMEDIA", applemedia)
641 # Windows Media Foundation support
642 # ==============================================================
643 option("--disable-wmf", help="Disable support for Windows Media Foundation")
646 @depends("--disable-wmf", target, "--help")
647 def wmf(value, target, _):
648 enabled = bool(value)
649 if value.origin == "default":
650 # Enable Windows Media Foundation support by default.
651 # Note our minimum SDK version is Windows 7 SDK, so we are (currently)
652 # guaranteed to have a recent-enough SDK to build WMF.
653 enabled = target.os == "WINNT"
654 if enabled and target.os != "WINNT":
655 die("Cannot enable Windows Media Foundation support on %s", target.os)
660 @depends(c_compiler, when=wmf)
661 def wmfmediaengine(c_compiler):
662 return c_compiler and c_compiler.type == "clang-cl"
665 set_config("MOZ_WMF", wmf)
666 set_define("MOZ_WMF", wmf)
668 set_config("MOZ_WMF_MEDIA_ENGINE", True, when=wmfmediaengine)
669 set_define("MOZ_WMF_MEDIA_ENGINE", True, when=wmfmediaengine)
671 # FFmpeg H264/AAC Decoding Support
672 # ==============================================================
673 option("--disable-ffmpeg", help="Disable FFmpeg for fragmented H264/AAC decoding")
676 @depends("--disable-ffmpeg", target)
677 def ffmpeg(value, target):
678 enabled = bool(value)
679 if value.origin == "default":
680 enabled = target.os not in ("Android", "WINNT")
685 set_config("MOZ_FFMPEG", ffmpeg)
686 set_define("MOZ_FFMPEG", ffmpeg)
687 imply_option("--enable-fmp4", ffmpeg, "--enable-ffmpeg")
689 # AV1 Video Codec Support
690 # ==============================================================
691 option("--disable-av1", help="Disable av1 video support")
694 @depends("--enable-av1")
700 @depends(target, when=av1 & compile_environment)
701 def dav1d_asm(target):
702 if target.cpu in ("aarch64", "x86", "x86_64"):
706 @depends(target, when=av1 & compile_environment)
707 def dav1d_nasm(target):
708 if target.cpu in ("x86", "x86_64"):
709 return namespace(version="2.14", what="AV1")
712 set_config("MOZ_DAV1D_ASM", dav1d_asm)
713 set_define("MOZ_DAV1D_ASM", dav1d_asm)
714 set_config("MOZ_AV1", av1)
715 set_define("MOZ_AV1", av1)
717 # JXL Image Codec Support
718 # ==============================================================
719 option("--disable-jxl", help="Disable jxl image support")
722 @depends("--disable-jxl", milestone.is_nightly)
723 def jxl(value, is_nightly):
724 if is_nightly and value:
728 set_config("MOZ_JXL", jxl)
729 set_define("MOZ_JXL", jxl)
731 # Built-in fragmented MP4 support.
732 # ==============================================================
736 help="Disable support for in built Fragmented MP4 parsing",
740 @depends("--disable-fmp4", target, wmf, applemedia)
741 def fmp4(value, target, wmf, applemedia):
742 enabled = bool(value)
743 if value.origin == "default":
744 # target.os == 'Android' includes all B2G versions
745 enabled = wmf or applemedia or target.os == "Android"
750 set_config("MOZ_FMP4", fmp4)
751 set_define("MOZ_FMP4", fmp4)
755 def sample_type_is_s16(target):
756 # Use integers over floats for audio on Android regardless of the CPU
757 # architecture, because audio backends for Android don't support floats.
758 # We also use integers on ARM because it's more efficient.
759 if target.os == "Android" or target.cpu == "arm":
763 @depends(sample_type_is_s16)
764 def sample_type_is_float(t):
769 set_config("MOZ_SAMPLE_TYPE_S16", sample_type_is_s16)
770 set_define("MOZ_SAMPLE_TYPE_S16", sample_type_is_s16)
771 set_config("MOZ_SAMPLE_TYPE_FLOAT32", sample_type_is_float)
772 set_define("MOZ_SAMPLE_TYPE_FLOAT32", sample_type_is_float)
774 set_define("MOZ_VORBIS", sample_type_is_float)
775 set_config("MOZ_VORBIS", sample_type_is_float)
776 set_define("MOZ_TREMOR", sample_type_is_s16)
777 set_config("MOZ_TREMOR", sample_type_is_s16)
780 "--disable-real-time-tracing",
781 help="Disable tracing of real-time audio callbacks",
784 set_config("MOZ_REAL_TIME_TRACING", True, when="--enable-real-time-tracing")
785 set_define("MOZ_REAL_TIME_TRACING", True, when="--enable-real-time-tracing")
787 # OpenMAX IL Decoding Support
788 # ==============================================================
789 option("--enable-openmax", help="Enable OpenMAX IL for video/audio decoding")
792 @depends("--enable-openmax")
794 enabled = bool(value)
799 set_config("MOZ_OMX", openmax)
800 set_define("MOZ_OMX", openmax)
803 # ==============================================================
804 @depends(target, wmf)
805 def eme_choices(target, wmf):
807 target.kernel in ("WINNT", "Linux")
808 and target.os != "Android"
809 and target.cpu in ("x86", "x86_64")
812 return ("widevine", "wmfcdm")
814 if target.kernel == "WINNT" and target.cpu == "aarch64":
816 if target.os in ("OSX"):
820 # Widevine is enabled by default in desktop browser builds, except
821 # on aarch64 Windows.
822 @depends(build_project, eme_choices, target)
823 def eme_default(build_project, choices, target):
824 if build_project == "browser":
825 if target.kernel != "WINNT" or target.cpu != "aarch64":
835 help="{Enable|Disable} support for Encrypted Media Extensions",
839 @depends("--enable-eme", fmp4, when=eme_choices)
840 def eme(enabled, fmp4):
841 if enabled and enabled.origin != "default" and not fmp4:
842 die("Encrypted Media Extension support requires " "Fragmented MP4 support")
845 @depends("--enable-eme", when=eme_choices)
846 def eme_modules(value):
850 # Fallback to an empty list when eme_choices is empty, setting eme_modules to
852 set_config("MOZ_EME_MODULES", eme_modules | dependable([]))
855 @depends(eme_modules, target, when=eme_modules)
856 def eme_win32_artifact(modules, target):
857 if "widevine" in modules and target.kernel == "WINNT" and target.cpu == "aarch64":
861 set_config("MOZ_EME_WIN32_ARTIFACT", eme_win32_artifact)
864 # Media Foundation CDM support
865 # ==============================================================
866 @depends(eme_modules, when=wmfmediaengine)
868 if "wmfcdm" in modules:
872 set_config("MOZ_WMF_CDM", True, when=wmfcdm)
873 set_define("MOZ_WMF_CDM", True, when=wmfcdm)
877 name="--enable-chrome-format",
878 help="Select FORMAT of chrome files during packaging.",
880 choices=("omni", "jar", "flat"),
885 @depends("--enable-chrome-format")
886 def packager_format(value):
890 set_config("MOZ_PACKAGER_FORMAT", packager_format)
892 # The packager minifies two different types of files: non-JS (mostly property
893 # files for l10n), and JS. Setting MOZ_PACKAGER_MINIFY only minifies the
894 # former. Firefox doesn't yet minify JS, due to concerns about debuggability.
896 # Also, the JS minification setup really only works correctly on Android:
897 # we need extra setup to use the newly-built shell for Linux and Windows,
898 # and cross-compilation for macOS requires some extra care.
901 @depends(target_is_android, "--enable-debug", milestone.is_nightly)
902 def enable_minify_default(is_android, debug, is_nightly):
903 if is_android and not debug and not is_nightly:
904 return ("properties", "js")
905 return ("properties",)
909 name="--enable-minify",
910 help="Select types of files to minify during packaging.",
912 choices=("properties", "js"),
913 default=enable_minify_default,
917 @depends("--enable-minify")
918 def enable_minify(value):
919 if "js" in value and "properties" not in value:
920 die("--enable-minify=js requires --enable-minify=properties.")
922 properties="properties" in value,
927 set_config("MOZ_PACKAGER_MINIFY", True, when=enable_minify.properties)
928 set_config("MOZ_PACKAGER_MINIFY_JS", True, when=enable_minify.js)
931 @depends(host, build_project)
932 def jar_maker_format(host, build_project):
933 # Multilocales for mobile/android use the same mergedirs for all locales,
934 # so we can't use symlinks for those builds.
935 if host.os == "WINNT" or build_project == "mobile/android":
940 set_config("MOZ_JAR_MAKER_FILE_FORMAT", jar_maker_format)
944 def omnijar_name(toolkit):
945 # Fennec's static resources live in the assets/ folder of the
946 # APK. Adding a path to the name here works because we only
947 # have one omnijar file in the final package (which is not the
949 return "assets/omni.ja" if toolkit == "android" else "omni.ja"
952 set_config("OMNIJAR_NAME", omnijar_name)
954 project_flag("MOZ_PLACES", help="Build Places if required", set_as_define=True)
957 "MOZ_SERVICES_HEALTHREPORT",
958 help="Build Firefox Health Reporter Service",
964 help="Enable Normandy recipe runner",
968 project_flag("MOZ_SERVICES_SYNC", help="Build Sync Services if required")
971 "MOZ_ANDROID_HISTORY",
972 help="Enable Android History instead of Places",
977 "MOZ_DEDICATED_PROFILES",
978 help="Enable dedicated profiles per install",
983 "MOZ_BLOCK_PROFILE_DOWNGRADE",
984 help="Block users from starting profiles last used by a newer build",
989 @depends("MOZ_PLACES", "MOZ_ANDROID_HISTORY")
990 def check_places_and_android_history(places, android_history):
991 if places and android_history:
992 die("Cannot use MOZ_ANDROID_HISTORY alongside MOZ_PLACES.")
996 env="MOZ_TELEMETRY_REPORTING",
997 default=mozilla_official,
998 help="Enable telemetry reporting",
1001 set_define("MOZ_TELEMETRY_REPORTING", True, when="MOZ_TELEMETRY_REPORTING")
1004 @depends("MOZ_TELEMETRY_REPORTING", milestone.is_nightly)
1005 def telemetry_on_by_default(reporting, is_nightly):
1006 return reporting and is_nightly
1009 set_define("MOZ_TELEMETRY_ON_BY_DEFAULT", True, when=telemetry_on_by_default)
1013 # ==============================================================
1014 system_lib_option("--enable-gpsd", env="MOZ_GPSD", help="Enable gpsd support")
1017 @depends("--enable-gpsd")
1022 system_gpsd = pkg_check_modules("MOZ_GPSD", "libgps >= 3.11", when=gpsd)
1024 set_config("MOZ_GPSD", depends_if(system_gpsd)(lambda _: True))
1026 # Miscellaneous programs
1027 # ==============================================================
1029 check_prog("TAR", ("gnutar", "gtar", "tar"))
1030 check_prog("UNZIP", ("unzip",))
1033 # ==============================================================
1034 include("../build/moz.configure/keyfiles.configure")
1036 simple_keyfile("Mozilla API")
1038 simple_keyfile("Google Location Service API")
1040 simple_keyfile("Google Safebrowsing API")
1042 id_and_secret_keyfile("Bing API")
1044 simple_keyfile("Adjust SDK")
1046 id_and_secret_keyfile("Leanplum SDK")
1048 simple_keyfile("Pocket API")
1051 # WebRender Debugger integration
1052 # ==============================================================
1055 "--enable-webrender-debugger", help="Build the websocket debug server in WebRender"
1059 "MOZ_WEBRENDER_DEBUGGER", depends_if("--enable-webrender-debugger")(lambda _: True)
1062 # Additional system headers defined at the application level
1063 # ==============================================================
1066 "--enable-app-system-headers",
1067 env="MOZ_APP_SYSTEM_HEADERS",
1068 help="Use additional system headers defined in $MOZ_BUILD_APP/app-system-headers.mozbuild",
1072 @depends("--enable-app-system-headers")
1073 def app_system_headers(value):
1078 set_config("MOZ_APP_SYSTEM_HEADERS", app_system_headers)
1079 set_define("MOZ_APP_SYSTEM_HEADERS", app_system_headers)
1082 # ==============================================================
1083 option("--disable-printing", help="Disable printing support")
1086 @depends("--disable-printing")
1087 def printing(value):
1092 set_config("NS_PRINTING", printing)
1093 set_define("NS_PRINTING", printing)
1094 set_define("NS_PRINT_PREVIEW", printing)
1096 # Speech-dispatcher support
1097 # ==============================================================
1099 def no_speechd_on_non_gtk(toolkit):
1100 if toolkit != "gtk":
1105 "--enable-synth-speechd", no_speechd_on_non_gtk, reason="--enable-default-toolkit"
1108 option("--disable-synth-speechd", help="Disable speech-dispatcher support")
1110 set_config("MOZ_SYNTH_SPEECHD", depends_if("--disable-synth-speechd")(lambda _: True))
1113 # ==============================================================
1114 option("--disable-webspeech", help="Disable support for HTML Speech API")
1117 @depends("--disable-webspeech")
1118 def webspeech(value):
1123 set_config("MOZ_WEBSPEECH", webspeech)
1124 set_define("MOZ_WEBSPEECH", webspeech)
1126 # Speech API test backend
1127 # ==============================================================
1129 "--enable-webspeechtestbackend",
1131 help="{Enable|Disable} support for HTML Speech API Test Backend",
1135 @depends_if("--enable-webspeechtestbackend")
1136 def webspeech_test_backend(value):
1140 set_config("MOZ_WEBSPEECH_TEST_BACKEND", webspeech_test_backend)
1141 set_define("MOZ_WEBSPEECH_TEST_BACKEND", webspeech_test_backend)
1144 # ==============================================================
1145 @depends(target, milestone)
1146 def skia_pdf_default(target, milestone):
1147 return milestone.is_nightly and target.os != "WINNT"
1150 option("--enable-skia-pdf", default=skia_pdf_default, help="{Enable|Disable} Skia PDF")
1152 set_config("MOZ_ENABLE_SKIA_PDF", True, when="--enable-skia-pdf")
1153 set_define("MOZ_ENABLE_SKIA_PDF", True, when="--enable-skia-pdf")
1164 "--with-system-webp", help="Use system libwebp (located with pkgconfig)"
1167 system_webp = pkg_check_modules(
1168 "MOZ_WEBP", "libwebp >= 1.0.2 libwebpdemux >= 1.0.2", when="--with-system-webp"
1171 set_config("MOZ_SYSTEM_WEBP", depends(when=system_webp)(lambda: True))
1173 # Build Freetype in the tree
1174 # ==============================================================
1175 @depends(target, "--enable-skia-pdf")
1176 def tree_freetype(target, skia_pdf):
1177 if target.os == "Android" or (skia_pdf and target.os == "WINNT"):
1181 set_define("MOZ_TREE_FREETYPE", tree_freetype)
1182 set_config("MOZ_TREE_FREETYPE", tree_freetype)
1184 set_define("HAVE_FT_BITMAP_SIZE_Y_PPEM", tree_freetype)
1185 set_define("HAVE_FT_GLYPHSLOT_EMBOLDEN", tree_freetype)
1186 set_define("HAVE_FT_LOAD_SFNT_TABLE", tree_freetype)
1189 @depends(freetype2_combined_info, tree_freetype, build_environment)
1190 def ft2_info(freetype2_combined_info, tree_freetype, build_env):
1193 cflags=("-I%s/modules/freetype2/include" % build_env.topsrcdir,), libs=()
1195 if freetype2_combined_info:
1196 return freetype2_combined_info
1199 set_config("FT2_LIBS", ft2_info.libs)
1202 @depends(target, tree_freetype, freetype2_info)
1203 def enable_cairo_ft(target, tree_freetype, freetype2_info):
1204 # Avoid defining MOZ_ENABLE_CAIRO_FT on Windows platforms because
1205 # "cairo-ft-font.c" includes <dlfcn.h>, which only exists on posix platforms
1206 return freetype2_info or (tree_freetype and target.os != "WINNT")
1209 set_config("MOZ_ENABLE_CAIRO_FT", True, when=enable_cairo_ft)
1210 set_config("CAIRO_FT_CFLAGS", ft2_info.cflags, when=enable_cairo_ft)
1213 # WebDriver (HTTP / BiDi)
1214 # ==============================================================
1216 # WebDriver is a remote control interface that enables introspection and
1217 # control of user agents. It provides a platform- and language-neutral wire
1218 # protocol as a way for out-of-process programs to remotely instruct the
1219 # behavior of web browsers.
1221 # The Gecko implementation is backed by Marionette and Remote Agent.
1222 # Both protocols are not really toolkit features, as much as Gecko engine
1223 # features. But they are enabled based on the toolkit, so here it lives.
1225 # Marionette remote protocol
1226 # -----------------------------------------------------------
1228 # Marionette is the Gecko remote protocol used for various remote control,
1229 # automation, and testing purposes throughout Gecko-based applications like
1230 # Firefox, Thunderbird, and any mobile browser built upon GeckoView.
1232 # It also backs ../testing/geckodriver, which is Mozilla's WebDriver
1235 # The source of Marionette lives in ../remote/marionette.
1237 # For more information, see:
1238 # https://firefox-source-docs.mozilla.org/testing/marionette/index.html
1240 # Remote Agent (WebDriver BiDi / partial CDP)
1241 # -----------------------------------------------------------
1243 # The primary purpose is the implementation of the WebDriver BiDi specification.
1244 # But it also complements the existing Firefox Developer Tools Remote Debugging
1245 # Protocol (RDP) by implementing a subset of the Chrome DevTools Protocol (CDP).
1247 # The source of Remote Agent lives in ../remote.
1249 # For more information, see:
1250 # https://firefox-source-docs.mozilla.org/remote/index.html
1254 "--disable-webdriver",
1255 help="Disable support for WebDriver remote protocols",
1259 @depends("--disable-webdriver")
1260 def webdriver(enabled):
1265 set_config("ENABLE_WEBDRIVER", webdriver)
1266 set_define("ENABLE_WEBDRIVER", webdriver)
1269 # geckodriver WebDriver implementation
1270 # ==============================================================
1272 # Turn off geckodriver for build configs we don't handle yet,
1273 # but allow --enable-geckodriver to override when compile environment is available.
1274 # --disable-tests implies disabling geckodriver.
1275 # Disable building in CI
1279 "--enable-tests", target, cross_compiling, hazard_analysis, asan, "MOZ_AUTOMATION"
1281 def geckodriver_default(enable_tests, target, cross_compile, hazard, asan, automation):
1282 if not enable_tests:
1284 if hazard or target.os == "Android" or (asan and cross_compile):
1292 "--enable-geckodriver",
1293 default=geckodriver_default,
1294 when="--enable-compile-environment",
1295 help="{Build|Do not build} geckodriver",
1299 @depends("--enable-geckodriver", when="--enable-compile-environment")
1300 def geckodriver(enabled):
1305 set_config("MOZ_GECKODRIVER", geckodriver)
1309 # ========================================================
1311 def webrtc_default(target):
1312 # Turn off webrtc for OS's we don't handle yet, but allow
1313 # --enable-webrtc to override.
1315 for os_fragment in (
1326 if target.raw_os.startswith(os_fragment):
1341 or target.cpu.startswith("ppc")
1345 if os_match and cpu_match:
1352 default=webrtc_default,
1353 help="{Enable|Disable} support for WebRTC",
1357 @depends("--disable-webrtc")
1358 def webrtc(enabled):
1363 set_config("MOZ_WEBRTC", webrtc)
1364 set_define("MOZ_WEBRTC", webrtc)
1365 set_config("MOZ_SCTP", webrtc)
1366 set_define("MOZ_SCTP", webrtc)
1367 set_config("MOZ_SRTP", webrtc)
1368 set_define("MOZ_SRTP", webrtc)
1369 set_config("MOZ_WEBRTC_SIGNALING", webrtc)
1370 set_define("MOZ_WEBRTC_SIGNALING", webrtc)
1371 set_config("MOZ_PEERCONNECTION", webrtc)
1372 set_define("MOZ_PEERCONNECTION", webrtc)
1373 # MOZ_WEBRTC_ASSERT_ALWAYS turns on a number of safety asserts in
1374 # opt/production builds (via MOZ_CRASH())
1375 set_config("MOZ_WEBRTC_ASSERT_ALWAYS", webrtc)
1376 set_define("MOZ_WEBRTC_ASSERT_ALWAYS", webrtc)
1379 # ==============================================================
1382 @depends(target, webrtc)
1383 def raw_media_default(target, webrtc):
1384 if target.os == "Android":
1392 default=raw_media_default,
1393 help="{Enable|Disable} support for RAW media",
1396 set_config("MOZ_RAW", depends_if("--enable-raw")(lambda _: True))
1397 set_define("MOZ_RAW", depends_if("--enable-raw")(lambda _: True))
1401 # ==============================================================
1402 @depends(webrtc, when=toolkit_gtk)
1403 def x11_libs(webrtc):
1413 # third_party/libwebrtc/webrtc/webrtc_gn/moz.build adds those
1414 # manually, ensure they're available.
1426 x11_headers = pkg_check_modules(
1429 allow_missing=depends(full_toolkit)(lambda t: t == "cairo-gtk3-wayland"),
1430 when=depends(full_toolkit)(
1431 lambda t: t in ("cairo-gtk3", "cairo-gtk3-wayland", "cairo-gtk3-x11-wayland")
1436 set_config("MOZ_X11", True, when=x11_headers)
1437 set_define("MOZ_X11", True, when=x11_headers)
1443 allow_missing=depends(full_toolkit)(lambda t: t == "cairo-gtk3-wayland"),
1444 when=depends(full_toolkit)(
1445 lambda t: t in ("cairo-gtk3", "cairo-gtk3-wayland", "cairo-gtk3-x11-wayland")
1450 # ASan Reporter Addon
1451 # ==============================================================
1453 "--enable-address-sanitizer-reporter",
1454 help="Enable Address Sanitizer Reporter Extension",
1458 @depends("--enable-address-sanitizer-reporter")
1459 def enable_asan_reporter(value):
1464 set_config("MOZ_ASAN_REPORTER", enable_asan_reporter)
1465 set_define("MOZ_ASAN_REPORTER", enable_asan_reporter)
1468 # ==============================================================
1469 with only_when("--enable-compile-environment"):
1471 @depends(host, target)
1472 def has_elfhack(host, target):
1474 target.kernel == "Linux"
1475 and host.kernel == "Linux"
1476 and target.cpu in ("arm", "aarch64", "x86", "x86_64")
1479 @depends("--enable-release", enable_linker)
1480 def default_elfhack(release, linker):
1481 # Disable elfhack when explicitly building with --enable-linker=lld
1482 if linker and linker.origin != "default" and linker[0] in ("lld", "mold"):
1484 return bool(release)
1486 with only_when(has_elfhack):
1488 "--disable-elf-hack",
1489 default=default_elfhack,
1490 help="{Enable|Disable} elf hacks",
1493 @depends(select_linker, when="--enable-elf-hack")
1494 def use_elf_hack(linker):
1495 if linker and linker.KIND == "lld":
1497 "Cannot enable elfhack with lld."
1498 " Use --enable-linker=bfd, --enable-linker=gold, or --disable-elf-hack"
1502 set_config("USE_ELF_HACK", use_elf_hack)
1505 @depends(build_environment)
1506 def idl_roots(build_env):
1508 ipdl_root=os.path.join(build_env.topobjdir, "ipc", "ipdl"),
1509 webidl_root=os.path.join(build_env.topobjdir, "dom", "bindings"),
1510 xpcom_root=os.path.join(build_env.topobjdir, "xpcom", "components"),
1514 set_config("WEBIDL_ROOT", idl_roots.webidl_root)
1515 set_config("IPDL_ROOT", idl_roots.ipdl_root)
1516 set_config("XPCOM_ROOT", idl_roots.xpcom_root)
1518 # Proxy bypass protection
1519 # ==============================================================
1522 "--enable-proxy-bypass-protection",
1523 help="Prevent suspected or confirmed proxy bypasses",
1527 @depends_if("--enable-proxy-bypass-protection")
1528 def proxy_bypass_protection(_):
1532 set_config("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1533 set_define("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1535 # Proxy direct failover
1536 # ==============================================================
1539 "--disable-proxy-direct-failover",
1540 help="Disable direct failover for system requests",
1544 @depends_if("--disable-proxy-direct-failover")
1545 def proxy_direct_failover(value):
1550 set_config("MOZ_PROXY_DIRECT_FAILOVER", proxy_direct_failover)
1551 set_define("MOZ_PROXY_DIRECT_FAILOVER", proxy_direct_failover)
1554 # ==============================================================
1557 @depends(c_compiler, toolchain_prefix)
1558 def midl_names(c_compiler, toolchain_prefix):
1559 if c_compiler and c_compiler.type in ["gcc", "clang"]:
1562 if toolchain_prefix:
1563 prefixed = tuple("%s%s" % (p, "widl") for p in toolchain_prefix)
1564 widl = prefixed + widl
1567 return ("midl.exe",)
1570 @depends(target, "--enable-compile-environment")
1571 def check_for_midl(target, compile_environment):
1572 if target.os != "WINNT":
1575 if compile_environment:
1582 when=check_for_midl,
1585 # MIDL being used from a python wrapper script, we can live with it
1590 option(env="MIDL_FLAGS", nargs=1, help="Extra flags to pass to MIDL")
1597 when=depends(midl, target)(lambda m, t: m and t.kernel == "WINNT"),
1599 def midl_flags(flags, target, midl):
1601 flags = flags[0].split()
1605 if not midl.endswith("widl"):
1611 return flags + ["-nologo", "-no_cpp", "-env", env]
1615 "x86": ["--win32", "-m32"],
1616 "x86_64": ["--win64", "-m64"],
1620 set_config("MIDL_FLAGS", midl_flags)
1623 # ==============================================================
1625 option("--disable-accessibility", help="Disable accessibility support")
1628 @depends("--enable-accessibility", check_for_midl, midl, c_compiler)
1629 def accessibility(value, check_for_midl, midl, c_compiler):
1630 enabled = bool(value)
1635 if check_for_midl and not midl:
1636 if c_compiler and c_compiler.type in ("gcc", "clang"):
1638 "You have accessibility enabled, but widl could not be found. "
1639 "Add --disable-accessibility to your mozconfig or install widl. "
1640 "See https://developer.mozilla.org/en-US/docs/Cross_Compile_Mozilla_for_Mingw32 for details."
1644 "MIDL could not be found. "
1645 "Building accessibility without MIDL is not supported."
1651 set_config("ACCESSIBILITY", accessibility)
1652 set_define("ACCESSIBILITY", accessibility)
1655 @depends(moz_debug, developer_options)
1656 def a11y_log(debug, developer_options):
1657 return debug or developer_options
1660 set_config("A11Y_LOG", True, when=a11y_log)
1661 set_define("A11Y_LOG", True, when=a11y_log)
1665 # ==============================================================
1667 def require_signing(milestone):
1668 return milestone.is_release_or_beta and not milestone.is_esr
1672 env="MOZ_REQUIRE_SIGNING",
1673 default=require_signing,
1674 help="Enforce that add-ons are signed by the trusted root",
1677 set_config("MOZ_REQUIRE_SIGNING", True, when="MOZ_REQUIRE_SIGNING")
1678 set_define("MOZ_REQUIRE_SIGNING", True, when="MOZ_REQUIRE_SIGNING")
1681 "--with-unsigned-addon-scopes",
1683 choices=("app", "system"),
1684 help="Addon scopes where signature is not required",
1688 @depends("--with-unsigned-addon-scopes")
1689 def unsigned_addon_scopes(scopes):
1691 app="app" in scopes or None,
1692 system="system" in scopes or None,
1696 set_config("MOZ_UNSIGNED_APP_SCOPE", unsigned_addon_scopes.app)
1697 set_config("MOZ_UNSIGNED_SYSTEM_SCOPE", unsigned_addon_scopes.system)
1701 # ==============================================================
1703 "--allow-addon-sideload",
1704 default=milestone.is_esr,
1705 help="Addon sideloading is allowed",
1709 set_config("MOZ_ALLOW_ADDON_SIDELOAD", True, when="--allow-addon-sideload")
1711 # WebExtensions API WebIDL bindings
1712 # ==============================================================
1716 def extensions_webidl_bindings_default(milestone):
1717 # Only enable the webidl bindings for the WebExtensions APIs
1719 return milestone.is_nightly
1723 "--enable-extensions-webidl-bindings",
1724 default=extensions_webidl_bindings_default,
1725 help="{Enable|Disable} building experimental WebExtensions WebIDL bindings",
1729 @depends("--enable-extensions-webidl-bindings")
1730 def extensions_webidl_enabled(value):
1734 set_config("MOZ_WEBEXT_WEBIDL_ENABLED", extensions_webidl_enabled)
1736 # Launcher process (Windows only)
1737 # ==============================================================
1741 def launcher_process_default(target):
1742 return target.os == "WINNT"
1746 "--enable-launcher-process",
1747 default=launcher_process_default,
1748 help="{Enable|Disable} launcher process by default",
1752 @depends("--enable-launcher-process", target)
1753 def launcher(value, target):
1754 enabled = bool(value)
1755 if enabled and target.os != "WINNT":
1756 die("Cannot enable launcher process on %s", target.os)
1761 set_config("MOZ_LAUNCHER_PROCESS", launcher)
1762 set_define("MOZ_LAUNCHER_PROCESS", launcher)
1764 # llvm-dlltool (Windows only)
1765 # ==============================================================
1768 @depends(build_project, target, "--enable-compile-environment")
1769 def check_for_llvm_dlltool(build_project, target, compile_environment):
1770 if build_project != "browser":
1773 if target.os != "WINNT":
1776 return compile_environment
1779 llvm_dlltool = check_prog(
1782 what="llvm-dlltool",
1783 when=check_for_llvm_dlltool,
1784 paths=clang_search_path,
1788 @depends(target, when=llvm_dlltool)
1789 def llvm_dlltool_flags(target):
1792 "x86_64": "i386:x86-64",
1799 set_config("LLVM_DLLTOOL_FLAGS", llvm_dlltool_flags)
1801 # BITS download (Windows only)
1802 # ==============================================================
1805 "--enable-bits-download",
1806 when=target_is_windows,
1807 default=target_is_windows,
1808 help="{Enable|Disable} building BITS download support",
1812 "MOZ_BITS_DOWNLOAD",
1813 depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
1816 "MOZ_BITS_DOWNLOAD",
1817 depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
1820 # Bundled fonts on desktop platform
1821 # ==============================================================
1825 def bundled_fonts_default(target):
1826 return target.os == "WINNT" or target.kernel == "Linux"
1829 @depends(build_project)
1830 def allow_bundled_fonts(project):
1831 return project == "browser" or project == "comm/mail"
1835 "--enable-bundled-fonts",
1836 default=bundled_fonts_default,
1837 when=allow_bundled_fonts,
1838 help="{Enable|Disable} support for bundled fonts on desktop platforms",
1842 "MOZ_BUNDLED_FONTS",
1843 depends_if("--enable-bundled-fonts", when=allow_bundled_fonts)(lambda _: True),
1847 # ==============================================================
1851 def reflow_perf(debug):
1857 "--enable-reflow-perf",
1858 default=reflow_perf,
1859 help="{Enable|Disable} reflow performance tracing",
1862 # The difference in conditions here comes from the initial implementation
1863 # in old-configure, which was unexplained there as well.
1864 set_define("MOZ_REFLOW_PERF", depends_if("--enable-reflow-perf")(lambda _: True))
1865 set_define("MOZ_REFLOW_PERF_DSP", reflow_perf)
1868 # ==============================================================
1872 def layout_debugger(debug):
1878 "--enable-layout-debugger",
1879 default=layout_debugger,
1880 help="{Enable|Disable} layout debugger",
1883 set_config("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
1884 set_define("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
1887 # Shader Compiler for Windows (and MinGW Cross Compile)
1888 # ==============================================================
1890 with only_when(compile_environment):
1893 ("fxc.exe", "fxc2.exe"),
1894 when=depends(target)(lambda t: t.kernel == "WINNT"),
1896 # FXC being used from a python wrapper script, we can live with it
1905 with only_when(compile_environment):
1907 "--with-system-libvpx", help="Use system libvpx (located with pkgconfig)"
1910 with only_when("--with-system-libvpx"):
1911 vpx = pkg_check_modules("MOZ_LIBVPX", "vpx >= 1.10.0")
1914 "vpx/vpx_decoder.h",
1916 onerror=lambda: die(
1917 "Couldn't find vpx/vpx_decoder.h, which is required to build "
1918 "with system libvpx. Use --without-system-libvpx to build "
1919 "with in-tree libvpx."
1924 "vpx_codec_dec_init_ver",
1926 onerror=lambda: die(
1927 "--with-system-libvpx requested but symbol vpx_codec_dec_init_ver "
1932 set_config("MOZ_SYSTEM_LIBVPX", True)
1934 @depends("--with-system-libvpx", target)
1935 def in_tree_vpx(system_libvpx, target):
1939 arm_asm = (target.cpu == "arm") or None
1940 return namespace(arm_asm=arm_asm)
1942 @depends(target, when=in_tree_vpx)
1943 def vpx_nasm(target):
1944 if target.cpu in ("x86", "x86_64"):
1945 if target.kernel == "WINNT":
1946 # Version 2.03 is needed for automatic safeseh support.
1947 return namespace(version="2.03", what="VPX")
1948 return namespace(what="VPX")
1950 @depends(in_tree_vpx, vpx_nasm, target, neon_flags)
1951 def vpx_as_flags(vpx, vpx_nasm, target, neon_flags):
1952 if vpx and vpx.arm_asm:
1953 # These flags are a lie; they're just used to enable the requisite
1954 # opcodes; actual arch detection is done at runtime.
1956 elif vpx and vpx_nasm and target.os != "WINNT" and target.cpu != "x86_64":
1959 set_config("VPX_USE_NASM", True, when=vpx_nasm)
1960 set_config("VPX_ASFLAGS", vpx_as_flags)
1966 with only_when(compile_environment):
1968 "--with-system-jpeg",
1970 help="Use system libjpeg (installed at given prefix)",
1973 @depends_if("--with-system-jpeg")
1974 def jpeg_flags(value):
1977 cflags=("-I%s/include" % value[0],),
1978 ldflags=("-L%s/lib" % value[0], "-ljpeg"),
1981 ldflags=("-ljpeg",),
1984 with only_when("--with-system-jpeg"):
1986 "jpeg_destroy_compress",
1987 flags=jpeg_flags.ldflags,
1988 onerror=lambda: die(
1989 "--with-system-jpeg requested but symbol "
1990 "jpeg_destroy_compress not found."
1994 c_compiler.try_compile(
2001 #if JPEG_LIB_VERSION < 62
2002 #error Insufficient JPEG library version
2005 flags=jpeg_flags.cflags,
2006 check_msg="for sufficient jpeg library version",
2007 onerror=lambda: die(
2008 "Insufficient JPEG library version for "
2009 "--with-system-jpeg (62 required)"
2013 c_compiler.try_compile(
2020 #ifndef JCS_EXTENSIONS
2021 #error libjpeg-turbo JCS_EXTENSIONS required
2024 flags=jpeg_flags.cflags,
2025 check_msg="for sufficient libjpeg-turbo JCS_EXTENSIONS",
2026 onerror=lambda: die(
2027 "libjpeg-turbo JCS_EXTENSIONS required for " "--with-system-jpeg"
2031 set_config("MOZ_JPEG_CFLAGS", jpeg_flags.cflags)
2032 set_config("MOZ_JPEG_LIBS", jpeg_flags.ldflags)
2034 @depends("--with-system-jpeg", target, neon_flags)
2035 def in_tree_jpeg_arm(system_jpeg, target, neon_flags):
2039 if target.cpu == "arm":
2041 elif target.cpu == "aarch64":
2042 return ("-march=armv8-a",)
2044 @depends("--with-system-jpeg", target)
2045 def in_tree_jpeg_mips64(system_jpeg, target):
2049 if target.cpu == "mips64":
2050 return ("-Wa,-mloongson-mmi", "-mloongson-ext")
2052 # Compiler check from https://github.com/libjpeg-turbo/libjpeg-turbo/blob/57ba02a408a9a55ccff25aae8b164632a3a4f177/simd/CMakeLists.txt#L419
2053 jpeg_mips64_mmi = c_compiler.try_compile(
2054 body='int c = 0, a = 0, b = 0; asm("paddb %0, %1, %2" : "=f" (c) : "f" (a), "f" (b));',
2055 check_msg="for loongson mmi support",
2056 flags=in_tree_jpeg_mips64,
2057 when=in_tree_jpeg_mips64,
2061 "--with-system-jpeg",
2064 in_tree_jpeg_mips64,
2068 system_jpeg, target, in_tree_jpeg_arm, in_tree_jpeg_mips64, jpeg_mips64_mmi
2073 if target.cpu in ("arm", "aarch64"):
2074 return in_tree_jpeg_arm
2075 elif target.kernel == "Darwin":
2076 if target.cpu == "x86":
2077 return ("-DPIC", "-DMACHO")
2078 elif target.cpu == "x86_64":
2079 return ("-D__x86_64__", "-DPIC", "-DMACHO")
2080 elif target.kernel == "WINNT":
2081 if target.cpu == "x86":
2082 return ("-DPIC", "-DWIN32")
2083 elif target.cpu == "x86_64":
2084 return ("-D__x86_64__", "-DPIC", "-DWIN64", "-DMSVC")
2085 elif target.cpu == "mips32":
2087 elif target.cpu == "mips64" and jpeg_mips64_mmi:
2088 return in_tree_jpeg_mips64
2089 elif target.cpu == "x86":
2090 return ("-DPIC", "-DELF")
2091 elif target.cpu == "x86_64":
2092 return ("-D__x86_64__", "-DPIC", "-DELF")
2094 @depends(target, when=depends("--with-system-jpeg")(lambda x: not x))
2095 def jpeg_nasm(target):
2096 if target.cpu in ("x86", "x86_64"):
2097 # libjpeg-turbo 2.0.6 requires nasm 2.10.
2098 return namespace(version="2.10", what="JPEG")
2100 # Compiler checks from https://github.com/libjpeg-turbo/libjpeg-turbo/blob/57ba02a408a9a55ccff25aae8b164632a3a4f177/simd/CMakeLists.txt#L258
2101 jpeg_arm_neon_vld1_s16_x3 = c_compiler.try_compile(
2102 includes=["arm_neon.h"],
2103 body="int16_t input[12] = {}; int16x4x3_t output = vld1_s16_x3(input);",
2104 check_msg="for vld1_s16_x3 in arm_neon.h",
2105 flags=in_tree_jpeg_arm,
2106 when=in_tree_jpeg_arm,
2109 jpeg_arm_neon_vld1_u16_x2 = c_compiler.try_compile(
2110 includes=["arm_neon.h"],
2111 body="uint16_t input[8] = {}; uint16x4x2_t output = vld1_u16_x2(input);",
2112 check_msg="for vld1_u16_x2 in arm_neon.h",
2113 flags=in_tree_jpeg_arm,
2114 when=in_tree_jpeg_arm,
2117 jpeg_arm_neon_vld1q_u8_x4 = c_compiler.try_compile(
2118 includes=["arm_neon.h"],
2119 body="uint8_t input[64] = {}; uint8x16x4_t output = vld1q_u8_x4(input);",
2120 check_msg="for vld1q_u8_x4 in arm_neon.h",
2121 flags=in_tree_jpeg_arm,
2122 when=in_tree_jpeg_arm,
2125 set_config("LIBJPEG_TURBO_USE_NASM", True, when=jpeg_nasm)
2126 set_config("LIBJPEG_TURBO_SIMD_FLAGS", in_tree_jpeg)
2127 set_config("LIBJPEG_TURBO_HAVE_VLD1_S16_X3", jpeg_arm_neon_vld1_s16_x3)
2128 set_config("LIBJPEG_TURBO_HAVE_VLD1_U16_X2", jpeg_arm_neon_vld1_u16_x2)
2129 set_config("LIBJPEG_TURBO_HAVE_VLD1Q_U8_X4", jpeg_arm_neon_vld1q_u8_x4)
2131 "LIBJPEG_TURBO_NEON_INTRINSICS",
2132 jpeg_arm_neon_vld1_s16_x3
2133 & jpeg_arm_neon_vld1_u16_x2
2134 & jpeg_arm_neon_vld1q_u8_x4,
2140 with only_when(compile_environment):
2142 "--with-system-png",
2144 help="Use system libpng",
2147 @depends("--with-system-png")
2148 def deprecated_system_png_path(value):
2151 "--with-system-png=PATH is not supported anymore. Please use "
2152 "--with-system-png and set any necessary pkg-config environment variable."
2155 png = pkg_check_modules("MOZ_PNG", "libpng >= 1.6.35", when="--with-system-png")
2160 onerror=lambda: die(
2161 "--with-system-png won't work because the system's libpng doesn't have APNG support"
2163 when="--with-system-png",
2166 set_config("MOZ_SYSTEM_PNG", True, when="--with-system-png")
2169 # FFmpeg's ffvpx configuration
2170 # ==============================================================
2171 with only_when(compile_environment):
2174 def libav_fft(target):
2175 if target.os == "Android" and target.cpu != "arm":
2177 return target.kernel in ("WINNT", "Darwin") or target.cpu == "x86_64"
2179 set_config("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
2180 set_define("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
2183 # Artifact builds need MOZ_FFVPX defined as if compilation happened.
2184 with only_when(compile_environment | artifact_builds):
2188 enable = use_nasm = True
2192 if target.kernel == "WINNT":
2193 if target.cpu == "x86":
2194 # 32-bit windows need to prefix symbols with an underscore.
2195 flags = ["-DPIC", "-DWIN32", "-DPREFIX", "-Pconfig_win32.asm"]
2196 elif target.cpu == "x86_64":
2202 "-Pconfig_win64.asm",
2204 elif target.cpu == "aarch64":
2205 flags = ["-DPIC", "-DWIN64"]
2207 elif target.kernel == "Darwin":
2208 # 32/64-bit macosx assemblers need to prefix symbols with an
2210 flags = ["-DPIC", "-DMACHO", "-DPREFIX"]
2211 if target.cpu == "x86_64":
2214 "-Pconfig_darwin64.asm",
2216 elif target.cpu == "aarch64":
2218 elif target.cpu == "x86_64":
2219 flags = ["-D__x86_64__", "-DPIC", "-DELF", "-Pconfig_unix64.asm"]
2220 elif target.cpu in ("x86", "arm", "aarch64"):
2225 if flac_only or not enable:
2231 flac_only=flac_only,
2235 @depends(when=ffvpx.use_nasm)
2237 # nasm 2.10 for AVX-2 support.
2238 return namespace(version="2.10", what="FFVPX")
2240 # ffvpx_nasm can't indirectly depend on vpx_as_flags, because it depends
2241 # on a compiler test, so we have to do a little bit of dance here.
2242 @depends(ffvpx, vpx_as_flags, target)
2243 def ffvpx(ffvpx, vpx_as_flags, target):
2244 if ffvpx and vpx_as_flags and target.cpu in ("arm", "aarch64"):
2245 ffvpx.flags.extend(vpx_as_flags)
2248 set_config("MOZ_FFVPX", True, when=ffvpx.enable)
2249 set_define("MOZ_FFVPX", True, when=ffvpx.enable)
2250 set_config("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.flac_only)
2251 set_define("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.flac_only)
2252 set_config("FFVPX_ASFLAGS", ffvpx.flags)
2253 set_config("FFVPX_USE_NASM", True, when=ffvpx.use_nasm)
2257 # ==============================================================
2258 @depends(dav1d_nasm, vpx_nasm, jpeg_nasm, ffvpx_nasm, when=compile_environment)
2259 def need_nasm(*requirements):
2261 x.what: x.version if hasattr(x, "version") else True for x in requirements if x
2264 items = sorted(requires.keys())
2266 what = " and ".join((", ".join(items[:-1]), items[-1]))
2269 versioned = {k: v for (k, v) in requires.items() if v is not True}
2270 return namespace(what=what, versioned=versioned)
2282 @depends(nasm, need_nasm.what)
2283 def check_nasm(nasm, what):
2284 if not nasm and what:
2285 die("Nasm is required to build with %s, but it was not found." % what)
2289 @depends_if(check_nasm)
2290 @checking("nasm version")
2291 def nasm_version(nasm):
2293 check_cmd_output(nasm, "-v", onerror=lambda: die("Failed to get nasm version."))
2297 return Version(version)
2300 @depends(nasm_version, need_nasm.versioned, when=need_nasm.versioned)
2301 def check_nasm_version(nasm_version, versioned):
2302 by_version = sorted(versioned.items(), key=lambda x: x[1])
2303 what, version = by_version[-1]
2304 if nasm_version < version:
2306 "Nasm version %s or greater is required to build with %s." % (version, what)
2311 @depends(target, when=check_nasm_version)
2312 def nasm_asflags(target):
2314 ("OSX", "x86"): ["-f", "macho32"],
2315 ("OSX", "x86_64"): ["-f", "macho64"],
2316 ("WINNT", "x86"): ["-f", "win32"],
2317 ("WINNT", "x86_64"): ["-f", "win64"],
2318 }.get((target.os, target.cpu), None)
2320 # We're assuming every x86 platform we support that's
2321 # not Windows or Mac is ELF.
2322 if target.cpu == "x86":
2323 asflags = ["-f", "elf32"]
2324 elif target.cpu == "x86_64":
2325 asflags = ["-f", "elf64"]
2329 set_config("NASM_ASFLAGS", nasm_asflags)
2332 # ANGLE OpenGL->D3D translator for WebGL
2333 # ==============================================================
2335 with only_when(compile_environment & target_is_windows):
2337 def d3d_compiler_dll_result(value):
2339 return "provided by the OS"
2342 @depends(target, valid_windows_sdk_dir, fxc)
2343 @checking("for D3D compiler DLL", d3d_compiler_dll_result)
2345 def d3d_compiler_dll(target, windows_sdk_dir, fxc):
2348 }.get(target.cpu, target.cpu)
2350 name = "d3dcompiler_47.dll"
2352 if target.cpu == "aarch64":
2353 # AArch64 Windows comes with d3dcompiler_47.dll installed
2354 return namespace(name=name, path=None)
2357 path = os.path.join(windows_sdk_dir.path, "Redist", "D3D", suffix, name)
2358 error_extra = "in Windows SDK at {}".format(windows_sdk_dir.path)
2360 path = os.path.join(os.path.dirname(fxc), name)
2361 error_extra = "alongside FXC at {}".format(fxc)
2363 if os.path.exists(path):
2364 return namespace(name=name, path=path)
2365 die("Could not find {} {}".format(name, error_extra))
2367 set_config("MOZ_ANGLE_RENDERER", True)
2369 "MOZ_D3DCOMPILER_VISTA_DLL", d3d_compiler_dll.name, when=d3d_compiler_dll.path
2371 set_config("MOZ_D3DCOMPILER_VISTA_DLL_PATH", d3d_compiler_dll.path)
2373 # Remoting protocol support
2374 # ==============================================================
2378 def has_remote(toolkit):
2379 if toolkit in ("gtk", "windows", "cocoa"):
2383 set_config("MOZ_HAS_REMOTE", has_remote)
2384 set_define("MOZ_HAS_REMOTE", has_remote)
2386 # RLBox Library Sandboxing wasm support
2387 # ==============================================================
2390 def wasm_sandboxing_libraries():
2400 @depends(dependable(wasm_sandboxing_libraries), build_project)
2401 def default_wasm_sandboxing_libraries(libraries, build_project):
2402 if build_project != "tools/rusttests":
2403 non_default_libs = set()
2405 return tuple(l for l in libraries if l not in non_default_libs)
2409 "--with-wasm-sandboxed-libraries",
2410 env="WASM_SANDBOXED_LIBRARIES",
2411 help="{Enable wasm sandboxing for the selected libraries|Disable wasm sandboxing}",
2413 choices=dependable(wasm_sandboxing_libraries),
2414 default=default_wasm_sandboxing_libraries,
2418 @depends("--with-wasm-sandboxed-libraries")
2419 def requires_wasm_sandboxing(libraries):
2424 set_config("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
2425 set_define("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
2427 with only_when(requires_wasm_sandboxing & compile_environment):
2429 "--with-wasi-sysroot",
2432 help="Path to wasi sysroot for wasm sandboxing",
2435 @depends("--with-wasi-sysroot", requires_wasm_sandboxing)
2436 def bootstrap_wasi_sysroot(wasi_sysroot, requires_wasm_sandboxing):
2437 return requires_wasm_sandboxing and not wasi_sysroot
2440 "--with-wasi-sysroot",
2441 bootstrap_path("sysroot-wasm32-wasi", when=bootstrap_wasi_sysroot),
2444 def wasi_sysroot(wasi_sysroot, bootstrapped_sysroot):
2445 if not wasi_sysroot:
2446 return bootstrapped_sysroot
2448 wasi_sysroot = wasi_sysroot[0]
2449 if not os.path.isdir(wasi_sysroot):
2450 die("Argument to --with-wasi-sysroot must be a directory")
2451 if not os.path.isabs(wasi_sysroot):
2452 die("Argument to --with-wasi-sysroot must be an absolute path")
2456 @depends(wasi_sysroot)
2457 def wasi_sysroot_flags(wasi_sysroot):
2459 log.info("Using wasi sysroot in %s", wasi_sysroot)
2460 return ["--sysroot=%s" % wasi_sysroot]
2463 set_config("WASI_SYSROOT", wasi_sysroot)
2465 def wasm_compiler_with_flags(compiler, sysroot_flags):
2468 compiler.wrapper + [compiler.compiler] + compiler.flags + sysroot_flags
2472 def wasm_compiler_error(msg):
2473 @depends("--with-wasm-sandboxed-libraries")
2474 def wasm_compiler_error(sandboxed_libs):
2475 suggest_disable = ""
2476 if sandboxed_libs.origin == "default":
2477 suggest_disable = " Or build with --without-wasm-sandboxed-libraries."
2478 return lambda: die(msg + suggest_disable)
2480 return wasm_compiler_error
2483 def check_wasm_compiler(compiler, language):
2484 compiler.try_compile(
2485 includes=["cstring" if language == "C++" else "string.h"],
2486 flags=wasi_sysroot_flags,
2487 check_msg="the wasm %s compiler can find wasi headers" % language,
2488 onerror=wasm_compiler_error(
2489 "Cannot find wasi headers or problem with the wasm compiler. "
2490 "Please fix the problem."
2495 flags=wasi_sysroot_flags,
2496 check_msg="the wasm %s linker can find wasi libraries" % language,
2497 onerror=wasm_compiler_error(
2498 "Cannot find wasi libraries or problem with the wasm linker. "
2499 "Please fix the problem."
2503 wasm_cc = compiler("C", wasm, other_compiler=c_compiler)
2504 check_wasm_compiler(wasm_cc, "C")
2506 @depends(wasm_cc, wasi_sysroot_flags)
2507 def wasm_cc_with_flags(wasm_cc, wasi_sysroot_flags):
2508 return wasm_compiler_with_flags(wasm_cc, wasi_sysroot_flags)
2510 set_config("WASM_CC", wasm_cc_with_flags)
2512 wasm_cxx = compiler(
2516 other_compiler=cxx_compiler,
2517 other_c_compiler=c_compiler,
2519 check_wasm_compiler(wasm_cxx, "C++")
2521 @depends(wasm_cxx, wasi_sysroot_flags)
2522 def wasm_cxx_with_flags(wasm_cxx, wasi_sysroot_flags):
2523 return wasm_compiler_with_flags(wasm_cxx, wasi_sysroot_flags)
2525 set_config("WASM_CXX", wasm_cxx_with_flags)
2527 wasm_compile_flags = dependable(["-fno-exceptions", "-fno-strict-aliasing"])
2528 option(env="WASM_CFLAGS", nargs=1, help="Options to pass to WASM_CC")
2530 @depends("WASM_CFLAGS", wasm_compile_flags)
2531 def wasm_cflags(value, wasm_compile_flags):
2533 return wasm_compile_flags + value
2535 return wasm_compile_flags
2537 set_config("WASM_CFLAGS", wasm_cflags)
2539 option(env="WASM_CXXFLAGS", nargs=1, help="Options to pass to WASM_CXX")
2541 @depends("WASM_CXXFLAGS", wasm_compile_flags)
2542 def wasm_cxxflags(value, wasm_compile_flags):
2544 return wasm_compile_flags + value
2546 return wasm_compile_flags
2548 set_config("WASM_CXXFLAGS", wasm_cxxflags)
2551 @depends("--with-wasm-sandboxed-libraries")
2552 def wasm_sandboxing(libraries):
2556 return namespace(**{name: True for name in libraries})
2560 def wasm_sandboxing_config_defines():
2561 for lib in wasm_sandboxing_libraries():
2563 "MOZ_WASM_SANDBOXING_%s" % lib.upper(), getattr(wasm_sandboxing, lib)
2566 "MOZ_WASM_SANDBOXING_%s" % lib.upper(), getattr(wasm_sandboxing, lib)
2570 wasm_sandboxing_config_defines()
2573 # new Notification Store implementation
2574 # ==============================================================
2578 def new_notification_store(milestone):
2579 if milestone.is_nightly:
2583 set_config("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)
2584 set_define("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)
2587 # Glean SDK Integration Crate
2588 # ==============================================================
2592 def glean_android(target):
2593 return target.os == "Android"
2596 set_config("MOZ_GLEAN_ANDROID", True, when=glean_android)
2597 set_define("MOZ_GLEAN_ANDROID", True, when=glean_android)
2601 # ==============================================================
2607 bootstrap="dump_syms",
2608 when=compile_environment,
2612 @depends(valid_windows_sdk_dir, host)
2613 @imports(_from="os", _import="environ")
2614 def pdbstr_paths(valid_windows_sdk_dir, host):
2615 if not valid_windows_sdk_dir:
2625 os.path.join(valid_windows_sdk_dir.path, "Debuggers", vc_host, "srcsrv"),
2633 when=compile_environment & target_is_windows,
2639 @depends("MOZ_AUTOMATION", c_compiler)
2640 def allow_missing_winchecksec(automation, c_compiler):
2643 if c_compiler and c_compiler.type != "clang-cl":
2649 ["winchecksec.exe", "winchecksec"],
2650 bootstrap="winchecksec",
2651 allow_missing=allow_missing_winchecksec,
2652 when=compile_environment & target_is_windows,
2656 @depends(target, build_project)
2657 def forkserver_default(target, build_project):
2658 return build_project == "browser" and (
2659 (target.os == "GNU" and target.kernel == "Linux")
2660 or target.os == "FreeBSD"
2661 or target.os == "OpenBSD"
2666 "--enable-forkserver",
2667 default=forkserver_default,
2668 env="MOZ_ENABLE_FORKSERVER",
2669 help="{Enable|Disable} fork server",
2673 @depends("--enable-forkserver", target)
2674 def forkserver_flag(value, target):
2676 target.os == "Android"
2677 or (target.os == "GNU" and target.kernel == "Linux")
2678 or target.os == "FreeBSD"
2679 or target.os == "OpenBSD"
2685 set_config("MOZ_ENABLE_FORKSERVER", forkserver_flag)
2686 set_define("MOZ_ENABLE_FORKSERVER", forkserver_flag, forkserver_flag)
2689 # ==============================================================
2691 with only_when(compile_environment & target_has_linux_kernel):
2692 # Check if we need to use the breakpad_getcontext fallback.
2693 getcontext = check_symbol("getcontext")
2694 set_config("HAVE_GETCONTEXT", getcontext)
2695 set_define("HAVE_GETCONTEXT", getcontext)
2698 # ==============================================================
2699 include("../build/moz.configure/nss.configure")
2702 # Enable or disable running in background task mode: headless for
2703 # periodic, short-lived, maintenance tasks.
2704 # ==============================================================================
2706 "--disable-backgroundtasks",
2707 help="Disable running in background task mode",
2709 set_config("MOZ_BACKGROUNDTASKS", True, when="--enable-backgroundtasks")
2710 set_define("MOZ_BACKGROUNDTASKS", True, when="--enable-backgroundtasks")
2713 # Update-related programs: updater, maintenance service, update agent,
2714 # default browser agent.
2715 # ==============================================================
2716 include("../build/moz.configure/update-programs.configure")
2719 # Mobile optimizations
2720 # ==============================================================
2722 "--enable-mobile-optimize",
2723 default=target_is_android,
2724 help="{Enable|Disable} mobile optimizations",
2727 set_define("MOZ_GFX_OPTIMIZE_MOBILE", True, when="--enable-mobile-optimize")
2728 # We ignore "paint will resample" on mobile for performance.
2729 # We may want to revisit this later.
2730 set_define("MOZ_IGNORE_PAINT_WILL_RESAMPLE", True, when="--enable-mobile-optimize")
2733 # ==============================================================
2734 option("--disable-pref-extensions", help="Disable pref extensions such as autoconfig")
2735 set_config("MOZ_PREF_EXTENSIONS", True, when="--enable-pref-extensions")
2737 # Offer a way to disable the startup cache
2738 # ==============================================================
2739 option("--disable-startupcache", help="Disable startup cache")
2742 @depends("--enable-startupcache")
2743 def enable_startupcache(value):
2749 "MOZ_DISABLE_STARTUPCACHE", True, when=depends(enable_startupcache)(lambda x: not x)
2754 # ==============================================================
2756 env="MOZ_APP_REMOTINGNAME",
2758 help="Used for the internal program name, which affects profile name "
2759 "and remoting. If not set, defaults to MOZ_APP_NAME if the update channel "
2760 "is release, and MOZ_APP_NAME-MOZ_UPDATE_CHANNEL otherwise.",
2764 @depends("MOZ_APP_REMOTINGNAME", moz_app_name, update_channel)
2765 def moz_app_remotingname(value, moz_app_name, update_channel):
2768 if update_channel == "release":
2770 return moz_app_name + "-" + update_channel
2773 set_config("MOZ_APP_REMOTINGNAME", moz_app_remotingname)
2776 env="ANDROID_PACKAGE_NAME",
2778 help="Name of the Android package (default org.mozilla.$MOZ_APP_NAME)",
2782 @depends("ANDROID_PACKAGE_NAME", moz_app_name)
2783 def android_package_name(value, moz_app_name):
2786 if moz_app_name == "fennec":
2787 return "org.mozilla.fennec_aurora"
2788 return "org.mozilla.%s" % moz_app_name
2791 set_config("ANDROID_PACKAGE_NAME", android_package_name)
2794 # Miscellaneous options
2795 # ==============================================================
2796 option(env="MOZ_WINCONSOLE", nargs="?", help="Whether we can create a console window.")
2797 set_define("MOZ_WINCONSOLE", True, when=depends("MOZ_WINCONSOLE")(lambda x: x))
2800 # Alternative Crashreporter setting
2802 "--with-crashreporter-url",
2803 env="MOZ_CRASHREPORTER_URL",
2804 default="https://crash-reports.mozilla.com/",
2806 help="Set an alternative crashreporter url",
2810 "MOZ_CRASHREPORTER_URL",
2811 depends("--with-crashreporter-url")(lambda x: x[0].rstrip("/")),
2815 # Crash reporter options
2816 # ==============================================================
2818 def oxidized_breakpad(target):
2819 if target.kernel == "Linux" and target.os != "Android":
2820 return target.cpu in ("x86", "x86_64")
2824 set_config("MOZ_OXIDIZED_BREAKPAD", True, when=oxidized_breakpad)
2825 set_define("MOZ_OXIDIZED_BREAKPAD", True, when=oxidized_breakpad)
2829 # ==============================================================
2830 @depends(target, host)
2831 def want_wine(target, host):
2832 return target.kernel == "WINNT" and host.kernel != "WINNT"
2839 bootstrap="wine/bin",
2843 # ==============================================================
2844 # Set this to true so the JS engine knows we're doing a browser build.
2845 set_config("MOZ_DOM_STREAMS", True)
2846 set_define("MOZ_DOM_STREAMS", True)
2849 # ==============================================================
2850 with only_when(compile_environment):
2852 "--with-system-libevent",
2854 help="Use system libevent",
2857 @depends("--with-system-libevent")
2858 def deprecated_system_libevent_path(value):
2861 "--with-system-libevent=PATH is not supported anymore. Please use "
2862 "--with-system-libevent and set any necessary pkg-config environment variable."
2865 pkg_check_modules("MOZ_LIBEVENT", "libevent", when="--with-system-libevent")
2867 set_config("MOZ_SYSTEM_LIBEVENT", True, when="--with-system-libevent")
2871 # ==============================================================
2872 @depends(target, developer_options, artifact_builds)
2873 def crashreporter_default(target, developer_options, artifacts):
2874 if target.kernel in ("WINNT", "Darwin"):
2876 if target.kernel == "Linux" and target.cpu in ("x86", "x86_64", "arm", "aarch64"):
2877 # The crash reporter prevents crash stacktraces to be logged in the
2878 # logs on Android, so we leave it out by default in developer builds.
2879 return target.os != "Android" or not developer_options or artifacts
2883 "--enable-crashreporter",
2884 default=crashreporter_default,
2885 help="{Enable|Disable} crash reporting",
2889 set_config("MOZ_CRASHREPORTER", True, when="--enable-crashreporter")
2890 set_define("MOZ_CRASHREPORTER", True, when="--enable-crashreporter")
2892 with only_when(compile_environment):
2893 with only_when("--enable-crashreporter"):
2897 when=depends(target)(lambda t: t.os == "GNU" and t.kernel == "Linux"),
2901 "MOZ_CRASHREPORTER_INJECTOR",
2903 when=depends(target)(lambda t: t.os == "WINNT" and t.bitness == 32),
2906 "MOZ_CRASHREPORTER_INJECTOR",
2908 when=depends(target)(lambda t: t.os == "WINNT" and t.bitness == 32),
2912 # If we have any service that uploads data (and requires data submission
2913 # policy alert), set MOZ_DATA_REPORTING.
2914 # ==============================================================
2916 "MOZ_TELEMETRY_REPORTING",
2917 "MOZ_SERVICES_HEALTHREPORT",
2918 "--enable-crashreporter",
2921 def data_reporting(telemetry, healthreport, crashreporter, normandy):
2922 return telemetry or healthreport or crashreporter or normandy
2925 set_config("MOZ_DATA_REPORTING", True, when=data_reporting)
2926 set_define("MOZ_DATA_REPORTING", True, when=data_reporting)
2930 # ==============================================================
2931 with only_when(toolkit_gtk):
2934 "gtk+-3.0 >= 3.14.0 gtk+-unix-print-3.0 glib-2.0 gobject-2.0 gio-unix-2.0",
2937 set_define("GDK_VERSION_MIN_REQUIRED", "GDK_VERSION_3_14")
2938 set_define("GDK_VERSION_MAX_ALLOWED", "GDK_VERSION_3_14")
2940 pkg_check_modules("GLIB", "glib-2.0 >= 2.42 gobject-2.0")
2942 set_define("GLIB_VERSION_MIN_REQUIRED", "GLIB_VERSION_2_42")
2943 set_define("GLIB_VERSION_MAX_ALLOWED", "GLIB_VERSION_2_42")
2945 set_define("MOZ_ACCESSIBILITY_ATK", True, when=accessibility)
2948 # ==============================================================
2949 with only_when(toolkit_gtk):
2950 option("--disable-dbus", help="Disable dbus support")
2952 with only_when("--enable-dbus"):
2953 pkg_check_modules("MOZ_DBUS", "dbus-1 >= 0.60")
2954 pkg_check_modules("MOZ_DBUS_GLIB", "dbus-glib-1 >= 0.60")
2956 set_config("MOZ_ENABLE_DBUS", True)
2957 set_define("MOZ_ENABLE_DBUS", True)
2960 # Necko's wifi scanner
2961 # ==============================================================
2963 def necko_wifi_when(target):
2964 return target.os in ("WINNT", "OSX", "DragonFly", "FreeBSD") or (
2965 target.kernel == "Linux" and target.os == "GNU"
2969 option("--disable-necko-wifi", help="Disable necko wifi scanner", when=necko_wifi_when)
2971 set_config("NECKO_WIFI", True, when="--enable-necko-wifi")
2972 set_define("NECKO_WIFI", True, when="--enable-necko-wifi")
2976 depends("--enable-necko-wifi", when=necko_wifi_when)(lambda x: x),
2977 depends("--enable-dbus", when=toolkit_gtk)(lambda x: x),
2978 when=depends(target)(lambda t: t.os == "GNU" and t.kernel == "Linux"),
2980 def necko_wifi_dbus(necko_wifi, dbus):
2981 if necko_wifi and not dbus:
2983 "Necko WiFi scanning needs DBus on your platform, remove --disable-dbus"
2984 " or use --disable-necko-wifi"
2986 return necko_wifi and dbus
2989 set_config("NECKO_WIFI_DBUS", True, when=necko_wifi_dbus)
2990 set_define("NECKO_WIFI_DBUS", True, when=necko_wifi_dbus)
2993 # Frontend JS debug mode
2994 # ==============================================================
2995 option("--enable-debug-js-modules", help="Enable debug mode for frontend JS libraries")
2997 set_config("DEBUG_JS_MODULES", True, when="--enable-debug-js-modules")
3001 # ==============================================================
3002 option("--enable-dump-painting", help="Enable paint debugging")
3005 "MOZ_DUMP_PAINTING",
3007 when=depends("--enable-dump-painting", "--enable-debug")(
3008 lambda painting, debug: painting or debug
3011 set_define("MOZ_LAYERS_HAVE_LOG", True, when="--enable-dump-painting")
3015 # ==============================================================
3016 with only_when(toolkit_gtk):
3017 system_lib_option("--enable-libproxy", help="Enable libproxy support")
3019 with only_when("--enable-libproxy"):
3020 pkg_check_modules("MOZ_LIBPROXY", "libproxy-1.0")
3022 set_config("MOZ_ENABLE_LIBPROXY", True)
3023 set_define("MOZ_ENABLE_LIBPROXY", True)
3026 # Enable runtime logging
3027 # ==============================================================
3028 set_define("MOZ_LOGGING", True)
3029 set_define("FORCE_PR_LOG", True)
3031 # This will enable logging of addref, release, ctor, dtor.
3032 # ==============================================================
3034 "--enable-logrefcnt",
3036 help="{Enable|Disable} logging of refcounts",
3039 set_define("NS_BUILD_REFCNT_LOGGING", True, when="--enable-logrefcnt")
3043 # ==============================================================
3044 option("--disable-negotiateauth", help="Disable GSS-API negotiation")
3046 set_config("MOZ_AUTH_EXTENSION", True, when="--enable-negotiateauth")
3047 set_define("MOZ_AUTH_EXTENSION", True, when="--enable-negotiateauth")
3051 # ==============================================================
3052 option("--disable-parental-controls", help="Do not build parental controls")
3055 "MOZ_DISABLE_PARENTAL_CONTROLS",
3057 when=depends("--enable-parental-controls")(lambda x: not x),
3060 "MOZ_DISABLE_PARENTAL_CONTROLS",
3062 when=depends("--enable-parental-controls")(lambda x: not x),
3066 # Sandboxing support
3067 # ==============================================================
3068 @depends(target, tsan, asan)
3069 def sandbox_default(target, tsan, asan):
3070 # Only enable the sandbox by default on Linux, OpenBSD, macOS, and Windows
3071 if target.kernel == "Linux" and target.os == "GNU":
3072 # Bug 1182565: TSan conflicts with sandboxing on Linux.
3073 # Bug 1287971: LSan also conflicts with sandboxing on Linux.
3076 # Linux sandbox is only available on x86{,_64} and arm{,64}.
3077 return target.cpu in ("x86", "x86_64", "arm", "aarch64")
3078 return target.kernel in ("WINNT", "Darwin", "OpenBSD")
3083 default=sandbox_default,
3084 help="{Enable|Disable} sandboxing support",
3087 set_config("MOZ_SANDBOX", True, when="--enable-sandbox")
3088 set_define("MOZ_SANDBOX", True, when="--enable-sandbox")
3090 with only_when(depends(target.kernel)(lambda k: k not in ("Darwin", "WINNT"))):
3091 set_define("MOZ_CONTENT_TEMP_DIR", True, when="--enable-sandbox")
3093 # Searching of system directories for extensions.
3094 # ==============================================================
3095 # Note: this switch is meant to be used for test builds whose behavior should
3096 # not depend on what happens to be installed on the local machine.
3098 "--disable-system-extension-dirs",
3099 help="Disable searching system- and account-global directories for extensions"
3100 " of any kind; use only profile-specific extension directories",
3103 set_define("ENABLE_SYSTEM_EXTENSION_DIRS", True, when="--enable-system-extension-dirs")
3107 # ==============================================================
3108 with only_when(compile_environment):
3110 "--enable-system-pixman", help="Use system pixman (located with pkgconfig)"
3113 @depends("--enable-system-pixman")
3114 def in_tree_pixman(pixman):
3117 set_config("MOZ_TREE_PIXMAN", True, when=in_tree_pixman)
3118 set_define("MOZ_TREE_PIXMAN", True, when=in_tree_pixman)
3120 pkg_check_modules("MOZ_PIXMAN", "pixman-1 >= 0.36.0", when="--enable-system-pixman")
3121 # Set MOZ_PIXMAN_CFLAGS to an explicit empty value when --enable-system-pixman is *not* used,
3122 # for layout/style/extra-bindgen-flags
3123 set_config("MOZ_PIXMAN_CFLAGS", [], when=in_tree_pixman)
3127 # ==============================================================
3128 with only_when(compile_environment):
3129 option("--disable-universalchardet", help="Disable universal encoding detection")
3131 set_config("MOZ_UNIVERSALCHARDET", True, when="--enable-universalchardet")
3135 # ==============================================================
3136 with only_when(compile_environment):
3137 option("--disable-zipwriter", help="Disable zipwriter component")
3139 set_config("MOZ_ZIPWRITER", True, when="--enable-zipwriter")
3142 # Location of the mozilla user directory
3143 # ==============================================================
3144 with only_when(compile_environment):
3147 def default_user_appdir(target):
3148 if target.kernel in ("WINNT", "Darwin"):
3153 "--with-user-appdir",
3155 default=default_user_appdir,
3156 help="Set user-specific appdir",
3159 @depends("--with-user-appdir")
3160 def user_appdir(appdir):
3162 die("--without-user-appdir is not a valid option.")
3163 if "/" in appdir[0]:
3164 die("--with-user-appdir must be a single relative path.")
3165 return '"{}"'.format(appdir[0])
3167 set_define("MOZ_USER_DIR", user_appdir)
3170 # Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
3171 # ==============================================================
3172 with only_when(compile_environment):
3173 have_sin_len = c_compiler.try_compile(
3174 includes=["netinet/in.h"],
3175 body="struct sockaddr_in x; void *foo = (void*) &x.sin_len;",
3176 check_msg="for sin_len in struct sockaddr_in",
3178 have_sin6_len = c_compiler.try_compile(
3179 includes=["netinet/in.h"],
3180 body="struct sockaddr_in6 x; void *foo = (void*) &x.sin6_len;",
3181 check_msg="for sin_len6 in struct sockaddr_in6",
3183 set_define("HAVE_SIN_LEN", have_sin_len)
3184 set_define("HAVE_SIN6_LEN", have_sin6_len)
3185 # HAVE_CONN_LEN must be the same as HAVE_SIN_LEN and HAVE_SIN6_LEN
3186 set_define("HAVE_SCONN_LEN", have_sin_len & have_sin6_len)
3189 c_compiler.try_compile(
3190 includes=["netinet/in.h"],
3191 body="struct sockaddr x; void *foo = (void*) &x.sa_len;",
3192 check_msg="for sa_len in struct sockaddr",
3197 # Check for pthread_cond_timedwait_monotonic_np
3198 # ==============================================================
3199 with only_when(compile_environment):
3201 "HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC",
3202 c_compiler.try_compile(
3203 includes=["pthread.h"],
3204 body="pthread_cond_timedwait_monotonic_np(0, 0, 0);",
3205 # -Werror to catch any "implicit declaration" warning that means the function
3207 flags=["-Werror=implicit-function-declaration"],
3208 check_msg="for pthread_cond_timedwait_monotonic_np",
3213 # Custom dynamic linker for Android
3214 # ==============================================================
3215 with only_when(target_has_linux_kernel & compile_environment):
3218 default=depends(target.os, when="--enable-jemalloc")(
3219 lambda os: os == "Android"
3221 help="{Enable|Disable} custom dynamic linker",
3224 set_config("MOZ_LINKER", True, when="MOZ_LINKER")
3225 set_define("MOZ_LINKER", True, when="MOZ_LINKER")
3226 add_old_configure_assignment("MOZ_LINKER", True, when="MOZ_LINKER")
3228 moz_linker = depends(when="MOZ_LINKER")(lambda: True)
3231 # 32-bits ethtool_cmd.speed
3232 # ==============================================================
3233 with only_when(target_has_linux_kernel & compile_environment):
3235 "MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI",
3236 c_compiler.try_compile(
3237 includes=["linux/ethtool.h"],
3238 body="struct ethtool_cmd cmd; cmd.speed_hi = 0;",
3239 check_msg="for 32-bits ethtool_cmd.speed",
3244 # ==============================================================
3247 onerror=lambda: die(
3248 "Can't find header linux/joystick.h, needed for gamepad support."
3249 " Please install Linux kernel headers."
3251 when=target_has_linux_kernel & compile_environment,
3254 # Smart card support
3255 # ==============================================================
3256 @depends(build_project)
3257 def disable_smart_cards(build_project):
3258 return build_project == "mobile/android"
3261 set_config("MOZ_NO_SMART_CARDS", True, when=disable_smart_cards)
3262 set_define("MOZ_NO_SMART_CARDS", True, when=disable_smart_cards)
3264 # Enable UniFFI fixtures
3265 # ==============================================================
3266 # These are used to test the uniffi-bindgen-gecko-js code generation. They
3267 # should not be enabled in release builds.
3270 "--enable-uniffi-fixtures",
3271 help="Enable UniFFI Fixtures/Examples",
3274 set_config("MOZ_UNIFFI_FIXTURES", True, when="--enable-uniffi-fixtures")
3276 # Checks for library functions
3277 # ==============================================================
3278 with only_when(compile_environment & depends(target.os)(lambda os: os != "WINNT")):
3279 set_define("HAVE_STAT64", check_symbol("stat64"))
3280 set_define("HAVE_LSTAT64", check_symbol("lstat64"))
3281 set_define("HAVE_TRUNCATE64", check_symbol("truncate64"))
3282 set_define("HAVE_STATVFS64", check_symbol("statvfs64"))
3283 set_define("HAVE_STATVFS", check_symbol("statvfs"))
3284 set_define("HAVE_STATFS64", check_symbol("statfs64"))
3285 set_define("HAVE_STATFS", check_symbol("statfs"))
3286 set_define("HAVE_LUTIMES", check_symbol("lutimes"))
3287 set_define("HAVE_POSIX_FADVISE", check_symbol("posix_fadvise"))
3288 set_define("HAVE_POSIX_FALLOCATE", check_symbol("posix_fallocate"))
3290 set_define("HAVE_ARC4RANDOM", check_symbol("arc4random"))
3291 set_define("HAVE_ARC4RANDOM_BUF", check_symbol("arc4random_buf"))
3292 set_define("HAVE_MALLINFO", check_symbol("mallinfo"))
3295 # ==============================================================
3298 "--disable-system-policies",
3299 help="Disable reading policies from Windows registry, macOS's file system attributes, and /etc/firefox",
3302 set_config("MOZ_SYSTEM_POLICIES", True, when="--enable-system-policies")
3304 # Allow disabling the creation a legacy profile
3305 # ==============================================================
3308 "--disable-legacy-profile-creation",
3309 help="Disable the creation a legacy profile, to be used by old versions "
3310 "of Firefox, when no profiles exist.",
3313 set_config("MOZ_CREATE_LEGACY_PROFILE", True, when="--enable-legacy-profile-creation")
3317 # ==============================================================
3318 set_config("WRAP_STL_INCLUDES", True)
3321 depends(build_environment.dist)(lambda dist: [f"-I{dist}/stl_wrappers"]),
3326 # ==============================================================
3328 def need_perl(target):
3329 # Ideally, we'd also depend on gnu_as here, but that adds complications.
3330 return target.cpu == "arm"
3333 perl = check_prog("PERL", ("perl5", "perl"), when=need_perl)
3337 def perl_version_check(min_version):
3339 @checking("for minimum required perl version >= %s" % min_version)
3340 def get_perl_version(perl):
3346 onerror=lambda: die("Failed to get perl version."),
3350 @depends(get_perl_version)
3351 def check_perl_version(version):
3352 if version < min_version:
3353 die("Perl %s or higher is required.", min_version)
3356 @checking("for full perl installation")
3357 @imports("subprocess")
3358 def has_full_perl_installation(perl):
3359 ret = subprocess.call([perl, "-e", "use Config; exit(!-d $Config{archlib})"])
3362 @depends(has_full_perl_installation)
3363 def require_full_perl_installation(has_full_perl_installation):
3364 if not has_full_perl_installation:
3366 "Cannot find Config.pm or $Config{archlib}. "
3367 "A full perl installation is required."
3371 with only_when(need_perl):
3372 perl_version_check("5.006")