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 add_old_configure_assignment("MOZ_DMD", dmd)
167 imply_option("--enable-profiling", dmd)
168 imply_option("--enable-jemalloc", dmd, when=compile_environment)
169 imply_option("--enable-replace-malloc", dmd, when=compile_environment)
171 # midir-based Web MIDI support
172 # ==============================================================
174 def midir_linux_support(target):
176 target.kernel == "Linux" and target.os != "Android" and target.cpu != "riscv64"
180 @depends(target, midir_linux_support)
181 def midir_support(target, midir_linux_support):
182 if target.os in ("WINNT", "OSX") or midir_linux_support:
186 set_config("MOZ_WEBMIDI_MIDIR_IMPL", midir_support)
188 # Enable various cubeb backends
189 # ==============================================================
191 def audio_backends_default(target):
192 if target.os == "Android":
197 elif target.os in ("DragonFly", "FreeBSD", "SunOS"):
199 elif target.os == "OpenBSD":
201 elif target.os == "OSX":
202 return ("audiounit",)
203 elif target.os == "WINNT":
206 return ("pulseaudio",)
210 "--enable-audio-backends",
223 default=audio_backends_default,
224 help="{Enable|Disable} various cubeb backends",
228 @depends("--enable-audio-backends", target)
229 def imply_aaudio(values, target):
230 if any("aaudio" in value for value in values) and target.os != "Android":
231 die("Cannot enable AAudio on %s", target.os)
232 return any("aaudio" in value for value in values) or None
235 @depends("--enable-audio-backends", target)
236 def imply_alsa(values, target):
238 any("alsa" in value for value in values)
239 and target.kernel != "Linux"
240 and target.os != "FreeBSD"
242 die("Cannot enable ALSA on %s", target.os)
243 return any("alsa" in value for value in values) or None
246 @depends("--enable-audio-backends", target)
247 def imply_audiounit(values, target):
249 any("audiounit" in value for value in values)
250 and target.os != "OSX"
251 and target.kernel != "Darwin"
253 die("Cannot enable AudioUnit on %s", target.os)
254 return any("audiounit" in value for value in values) or None
257 @depends("--enable-audio-backends")
258 def imply_jack(values):
259 return any("jack" in value for value in values) or None
262 @depends("--enable-audio-backends", target)
263 def imply_opensl(values, target):
264 if any("opensl" in value for value in values) and target.os != "Android":
265 die("Cannot enable OpenSL on %s", target.os)
266 return any("opensl" in value for value in values) or None
269 @depends("--enable-audio-backends", target)
270 def imply_oss(values, target):
271 if any("oss" in value for value in values) and (
272 target.os == "Android" or target.os == "OSX" or target.os == "WINNT"
274 die("Cannot enable OSS on %s", target.os)
275 return any("oss" in value for value in values) or None
278 @depends("--enable-audio-backends", target)
279 def imply_pulseaudio(values, target):
280 if any("pulseaudio" in value for value in values) and (
281 target.os == "Android" or target.os == "OSX" or target.os == "WINNT"
283 die("Cannot enable PulseAudio on %s", target.os)
284 return any("pulseaudio" in value for value in values) or None
287 @depends("--enable-audio-backends", target)
288 def imply_sndio(values, target):
289 if any("sndio" in value for value in values) and (
290 target.os == "Android" or target.os == "OSX" or target.os == "WINNT"
292 die("Cannot enable sndio on %s", target.os)
293 return any("sndio" in value for value in values) or None
296 @depends("--enable-audio-backends", target)
297 def imply_wasapi(values, target):
298 if any("wasapi" in value for value in values) and target.os != "WINNT":
299 die("Cannot enable WASAPI on %s", target.os)
300 return any("wasapi" in value for value in values) or None
303 set_config("MOZ_AAUDIO", imply_aaudio, when="--enable-audio-backends")
305 imply_option("--enable-alsa", imply_alsa, reason="--enable-audio-backends")
307 set_config("MOZ_AUDIOUNIT_RUST", imply_audiounit, when="--enable-audio-backends")
309 imply_option("--enable-jack", imply_jack, reason="--enable-audio-backends")
311 set_config("MOZ_OPENSL", imply_opensl, when="--enable-audio-backends")
313 set_config("MOZ_OSS", imply_oss, when="--enable-audio-backends")
315 imply_option("--enable-pulseaudio", imply_pulseaudio, reason="--enable-audio-backends")
317 imply_option("--enable-sndio", imply_sndio, reason="--enable-audio-backends")
319 set_config("MOZ_WASAPI", imply_wasapi, when="--enable-audio-backends")
322 # ==============================================================
323 option("--enable-alsa", env="MOZ_ALSA", help="Enable ALSA audio backend.")
326 @depends("--enable-alsa", midir_linux_support)
327 def enable_alsa_or_midir_linux_support(alsa_enabled, midir_linux_support):
328 return alsa_enabled or midir_linux_support
331 pkg_check_modules("MOZ_ALSA", "alsa", when=enable_alsa_or_midir_linux_support)
333 set_config("MOZ_ALSA", True, when="--enable-alsa")
336 # ==============================================================
337 system_lib_option("--enable-jack", env="MOZ_JACK", help="Enable JACK audio backend.")
339 jack = pkg_check_modules("MOZ_JACK", "jack", when="--enable-jack")
341 set_config("MOZ_JACK", depends_if(jack)(lambda _: True))
343 # PulseAudio cubeb backend
344 # ==============================================================
346 "--enable-pulseaudio",
347 env="MOZ_PULSEAUDIO",
348 help="{Enable|Disable} PulseAudio audio backend.",
351 pulseaudio = pkg_check_modules("MOZ_PULSEAUDIO", "libpulse", when="--enable-pulseaudio")
353 set_config("MOZ_PULSEAUDIO", depends_if(pulseaudio)(lambda _: True))
355 # sndio cubeb backend
356 # ==============================================================
357 system_lib_option("--enable-sndio", env="MOZ_SNDIO", help="Enable sndio audio backend.")
359 sndio = pkg_check_modules("MOZ_SNDIO", "sndio", when="--enable-sndio")
361 set_config("MOZ_SNDIO", depends_if(sndio)(lambda _: True))
364 # ==============================================================
365 include("../js/moz.configure")
369 # ==============================================================
370 include("../build/moz.configure/node.configure")
373 # ==============================================================
374 set_define("JSON_USE_EXCEPTION", 0)
377 # ==============================================================
378 option("--with-l10n-base", nargs=1, env="L10NBASEDIR", help="Path to l10n repositories")
381 @depends("--with-l10n-base", "MOZ_AUTOMATION", build_environment)
382 @imports(_from="os.path", _import="isdir")
383 @imports(_from="os.path", _import="expanduser")
384 @imports(_from="os", _import="environ")
385 def l10n_base(value, automation, build_env):
389 die("Invalid value --with-l10n-base, %s doesn't exist", path)
391 path = os.path.join(build_env.topsrcdir, "../l10n-central")
395 "MOZBUILD_STATE_PATH", expanduser(os.path.join("~", ".mozbuild"))
399 return os.path.realpath(os.path.abspath(path))
402 set_config("L10NBASEDIR", l10n_base)
406 # ==============================================================
408 def toolkit_choices(target):
409 if target.os == "WINNT":
410 return ("cairo-windows",)
411 elif target.os == "OSX":
412 return ("cairo-cocoa",)
413 elif target.os == "Android":
414 return ("cairo-android",)
418 "cairo-gtk3-wayland",
419 "cairo-gtk3-wayland-only",
420 "cairo-gtk3-x11-wayland",
424 @depends(toolkit_choices)
425 def toolkit_default(choices):
430 "--enable-default-toolkit",
432 choices=toolkit_choices,
433 default=toolkit_default,
434 help="Select default toolkit",
438 @depends("--enable-default-toolkit")
439 def full_toolkit(value):
444 @depends(full_toolkit)
445 def toolkit(toolkit):
446 if toolkit.startswith("cairo-gtk3"):
447 widget_toolkit = "gtk"
449 widget_toolkit = toolkit.replace("cairo-", "")
450 return widget_toolkit
453 set_config("MOZ_WIDGET_TOOLKIT", toolkit)
454 add_old_configure_assignment("MOZ_WIDGET_TOOLKIT", toolkit)
458 def toolkit_define(toolkit):
459 if toolkit != "windows":
460 return "MOZ_WIDGET_%s" % toolkit.upper()
463 set_define(toolkit_define, True)
467 def toolkit_gtk(toolkit):
468 return toolkit == "gtk"
472 # ==============================================================
473 wayland_headers = pkg_check_modules(
475 "gtk+-wayland-3.0 >= 3.14 xkbcommon >= 0.4.1 libdrm >= 2.4",
476 allow_missing=depends(full_toolkit)(lambda t: t == "cairo-gtk3"),
481 @depends(wayland_headers, toolkit_gtk, artifact_builds)
482 def wayland_headers(wayland, toolkit_gtk, artifacts):
483 if toolkit_gtk and artifacts:
488 set_config("MOZ_WAYLAND", depends_if(wayland_headers)(lambda _: True))
489 set_define("MOZ_WAYLAND", depends_if(wayland_headers)(lambda _: True))
492 # ==============================================================
493 option("--with-gl-provider", nargs=1, help="Set GL provider backend type")
496 @depends("--with-gl-provider")
497 def gl_provider(value):
502 @depends(gl_provider)
503 def gl_provider_define(provider):
505 return "GLContextProvider%s" % provider
508 set_define("MOZ_GL_PROVIDER", gl_provider_define)
511 @depends(gl_provider, wayland_headers, toolkit_gtk)
512 def gl_default_provider(value, wayland, toolkit_gtk):
521 set_config("MOZ_GL_PROVIDER", gl_provider)
522 set_config("MOZ_GL_DEFAULT_PROVIDER", gl_default_provider)
525 @depends(gl_default_provider)
526 def gl_provider_define(provider):
528 return "GL_PROVIDER_%s" % provider
531 set_define(gl_provider_define, True)
535 # ==============================================================
537 def pdf_printing(toolkit):
538 if toolkit in ("windows", "gtk", "android"):
542 set_config("MOZ_PDF_PRINTING", pdf_printing)
543 set_define("MOZ_PDF_PRINTING", pdf_printing)
546 # Event loop instrumentation
547 # ==============================================================
548 option(env="MOZ_INSTRUMENT_EVENT_LOOP", help="Force-enable event loop instrumentation")
551 @depends("MOZ_INSTRUMENT_EVENT_LOOP", toolkit)
552 def instrument_event_loop(value, toolkit):
554 toolkit in ("windows", "gtk", "cocoa", "android") and value.origin == "default"
559 set_config("MOZ_INSTRUMENT_EVENT_LOOP", instrument_event_loop)
560 set_define("MOZ_INSTRUMENT_EVENT_LOOP", instrument_event_loop)
563 # Fontconfig Freetype
564 # ==============================================================
565 option(env="USE_FC_FREETYPE", help="Force-enable the use of fontconfig freetype")
568 @depends("USE_FC_FREETYPE", toolkit)
569 def fc_freetype(value, toolkit):
570 if value or (toolkit == "gtk" and value.origin == "default"):
574 add_old_configure_assignment("USE_FC_FREETYPE", fc_freetype)
575 set_define("USE_FC_FREETYPE", fc_freetype)
578 # ==============================================================
579 pkg_check_modules("MOZ_PANGO", "pango >= 1.22.0", when=toolkit_gtk)
582 # ==============================================================
583 fontconfig_info = pkg_check_modules(
584 "_FONTCONFIG", "fontconfig >= 2.7.0", when=fc_freetype
588 @depends(fc_freetype)
589 def check_for_freetype2(fc_freetype):
594 # Check for freetype2. Flags are combined with fontconfig flags.
595 freetype2_info = pkg_check_modules(
596 "_FT2", "freetype2 >= 9.10.3", when=check_for_freetype2
600 @depends(fontconfig_info, freetype2_info)
601 def freetype2_combined_info(fontconfig_info, freetype2_info):
602 if not freetype2_info:
604 if not fontconfig_info:
605 return freetype2_info
607 cflags=freetype2_info.cflags + fontconfig_info.cflags,
608 libs=freetype2_info.libs + fontconfig_info.libs,
612 set_define("MOZ_HAVE_FREETYPE2", depends_if(freetype2_info)(lambda _: True))
614 # Apple platform decoder support
615 # ==============================================================
617 def applemedia(toolkit):
618 if toolkit in ("cocoa", "uikit"):
622 set_config("MOZ_APPLEMEDIA", applemedia)
623 set_define("MOZ_APPLEMEDIA", applemedia)
625 # Windows Media Foundation support
626 # ==============================================================
627 option("--disable-wmf", help="Disable support for Windows Media Foundation")
630 @depends("--disable-wmf", target)
631 def wmf(value, target):
632 enabled = bool(value)
633 if value.origin == "default":
634 # Enable Windows Media Foundation support by default.
635 # Note our minimum SDK version is Windows 7 SDK, so we are (currently)
636 # guaranteed to have a recent-enough SDK to build WMF.
637 enabled = target.os == "WINNT"
638 if enabled and target.os != "WINNT":
639 die("Cannot enable Windows Media Foundation support on %s", target.os)
644 @depends(c_compiler, when=wmf)
645 def wmfmediaengine(c_compiler):
646 return c_compiler and c_compiler.type == "clang-cl"
649 set_config("MOZ_WMF", wmf)
650 set_define("MOZ_WMF", wmf)
652 set_config("MOZ_WMF_MEDIA_ENGINE", True, when=wmfmediaengine)
653 set_define("MOZ_WMF_MEDIA_ENGINE", True, when=wmfmediaengine)
655 # FFmpeg H264/AAC Decoding Support
656 # ==============================================================
657 option("--disable-ffmpeg", help="Disable FFmpeg for fragmented H264/AAC decoding")
660 @depends("--disable-ffmpeg", target)
661 def ffmpeg(value, target):
662 enabled = bool(value)
663 if value.origin == "default":
664 enabled = target.os not in ("Android", "WINNT")
669 set_config("MOZ_FFMPEG", ffmpeg)
670 set_define("MOZ_FFMPEG", ffmpeg)
671 imply_option("--enable-fmp4", ffmpeg, "--enable-ffmpeg")
673 # AV1 Video Codec Support
674 # ==============================================================
675 option("--disable-av1", help="Disable av1 video support")
678 @depends("--enable-av1")
684 @depends(target, when=av1 & compile_environment)
685 def dav1d_asm(target):
686 if target.cpu in ("aarch64", "x86", "x86_64"):
690 @depends(target, when=av1 & compile_environment)
691 def dav1d_nasm(target):
692 if target.cpu in ("x86", "x86_64"):
693 return namespace(version="2.14", what="AV1")
696 set_config("MOZ_DAV1D_ASM", dav1d_asm)
697 set_define("MOZ_DAV1D_ASM", dav1d_asm)
698 set_config("MOZ_AV1", av1)
699 set_define("MOZ_AV1", av1)
701 # JXL Image Codec Support
702 # ==============================================================
703 option("--disable-jxl", help="Disable jxl image support")
706 @depends("--disable-jxl", milestone.is_nightly)
707 def jxl(value, is_nightly):
708 if is_nightly and value:
712 set_config("MOZ_JXL", jxl)
713 set_define("MOZ_JXL", jxl)
715 # Built-in fragmented MP4 support.
716 # ==============================================================
720 help="Disable support for in built Fragmented MP4 parsing",
724 @depends("--disable-fmp4", target, wmf, applemedia)
725 def fmp4(value, target, wmf, applemedia):
726 enabled = bool(value)
727 if value.origin == "default":
728 # target.os == 'Android' includes all B2G versions
729 enabled = wmf or applemedia or target.os == "Android"
734 set_config("MOZ_FMP4", fmp4)
735 set_define("MOZ_FMP4", fmp4)
736 add_old_configure_assignment("MOZ_FMP4", fmp4)
740 def sample_type_is_s16(target):
741 # Use integers over floats for audio on Android regardless of the CPU
742 # architecture, because audio backends for Android don't support floats.
743 # We also use integers on ARM because it's more efficient.
744 if target.os == "Android" or target.cpu == "arm":
748 @depends(sample_type_is_s16)
749 def sample_type_is_float(t):
754 set_config("MOZ_SAMPLE_TYPE_S16", sample_type_is_s16)
755 set_define("MOZ_SAMPLE_TYPE_S16", sample_type_is_s16)
756 set_config("MOZ_SAMPLE_TYPE_FLOAT32", sample_type_is_float)
757 set_define("MOZ_SAMPLE_TYPE_FLOAT32", sample_type_is_float)
759 set_define("MOZ_VORBIS", sample_type_is_float)
760 set_config("MOZ_VORBIS", sample_type_is_float)
761 set_define("MOZ_TREMOR", sample_type_is_s16)
762 set_config("MOZ_TREMOR", sample_type_is_s16)
764 # OpenMAX IL Decoding Support
765 # ==============================================================
766 option("--enable-openmax", help="Enable OpenMAX IL for video/audio decoding")
769 @depends("--enable-openmax")
771 enabled = bool(value)
776 set_config("MOZ_OMX", openmax)
777 set_define("MOZ_OMX", openmax)
780 # ==============================================================
782 def eme_choices(target):
784 target.kernel in ("WINNT", "Linux")
785 and target.os != "Android"
786 and target.cpu in ("x86", "x86_64")
789 if target.kernel == "WINNT" and target.cpu == "aarch64":
791 if target.os in ("OSX"):
795 # Widevine is enabled by default in desktop browser builds, except
796 # on aarch64 Windows.
797 @depends(build_project, eme_choices, target)
798 def eme_default(build_project, choices, target):
799 if build_project == "browser":
800 if target.kernel != "WINNT" or target.cpu != "aarch64":
810 help="{Enable|Disable} support for Encrypted Media Extensions",
814 @depends("--enable-eme", fmp4, when=eme_choices)
815 def eme(enabled, fmp4):
816 if enabled and enabled.origin != "default" and not fmp4:
817 die("Encrypted Media Extension support requires " "Fragmented MP4 support")
820 @depends("--enable-eme", when=eme_choices)
821 def eme_modules(value):
825 # Fallback to an empty list when eme_choices is empty, setting eme_modules to
827 set_config("MOZ_EME_MODULES", eme_modules | dependable([]))
830 @depends(eme_modules, target, when=eme_modules)
831 def eme_win32_artifact(modules, target):
832 if "widevine" in modules and target.kernel == "WINNT" and target.cpu == "aarch64":
836 set_config("MOZ_EME_WIN32_ARTIFACT", eme_win32_artifact)
839 name="--enable-chrome-format",
840 help="Select FORMAT of chrome files during packaging.",
842 choices=("omni", "jar", "flat"),
847 @depends("--enable-chrome-format")
848 def packager_format(value):
852 set_config("MOZ_PACKAGER_FORMAT", packager_format)
854 # The packager minifies two different types of files: non-JS (mostly property
855 # files for l10n), and JS. Setting MOZ_PACKAGER_MINIFY only minifies the
856 # former. Firefox doesn't yet minify JS, due to concerns about debuggability.
858 # Also, the JS minification setup really only works correctly on Android:
859 # we need extra setup to use the newly-built shell for Linux and Windows,
860 # and cross-compilation for macOS requires some extra care.
863 @depends(target_is_android, "--enable-debug", milestone.is_nightly)
864 def enable_minify_default(is_android, debug, is_nightly):
865 if is_android and not debug and not is_nightly:
866 return ("properties", "js")
867 return ("properties",)
871 name="--enable-minify",
872 help="Select types of files to minify during packaging.",
874 choices=("properties", "js"),
875 default=enable_minify_default,
879 @depends("--enable-minify")
880 def enable_minify(value):
881 if "js" in value and "properties" not in value:
882 die("--enable-minify=js requires --enable-minify=properties.")
884 properties="properties" in value,
889 set_config("MOZ_PACKAGER_MINIFY", True, when=enable_minify.properties)
890 set_config("MOZ_PACKAGER_MINIFY_JS", True, when=enable_minify.js)
893 @depends(host, build_project)
894 def jar_maker_format(host, build_project):
895 # Multilocales for mobile/android use the same mergedirs for all locales,
896 # so we can't use symlinks for those builds.
897 if host.os == "WINNT" or build_project == "mobile/android":
902 set_config("MOZ_JAR_MAKER_FILE_FORMAT", jar_maker_format)
906 def omnijar_name(toolkit):
907 # Fennec's static resources live in the assets/ folder of the
908 # APK. Adding a path to the name here works because we only
909 # have one omnijar file in the final package (which is not the
911 return "assets/omni.ja" if toolkit == "android" else "omni.ja"
914 set_config("OMNIJAR_NAME", omnijar_name)
916 project_flag("MOZ_PLACES", help="Build Places if required", set_as_define=True)
919 "MOZ_SERVICES_HEALTHREPORT",
920 help="Build Firefox Health Reporter Service",
921 set_for_old_configure=True,
927 help="Enable Normandy recipe runner",
928 set_for_old_configure=True,
932 project_flag("MOZ_SERVICES_SYNC", help="Build Sync Services if required")
935 "MOZ_ANDROID_HISTORY",
936 help="Enable Android History instead of Places",
941 "MOZ_DEDICATED_PROFILES",
942 help="Enable dedicated profiles per install",
947 "MOZ_BLOCK_PROFILE_DOWNGRADE",
948 help="Block users from starting profiles last used by a newer build",
953 @depends("MOZ_PLACES", "MOZ_ANDROID_HISTORY")
954 def check_places_and_android_history(places, android_history):
955 if places and android_history:
956 die("Cannot use MOZ_ANDROID_HISTORY alongside MOZ_PLACES.")
960 env="MOZ_TELEMETRY_REPORTING",
961 default=mozilla_official,
962 help="Enable telemetry reporting",
965 set_define("MOZ_TELEMETRY_REPORTING", True, when="MOZ_TELEMETRY_REPORTING")
966 add_old_configure_assignment(
967 "MOZ_TELEMETRY_REPORTING", True, when="MOZ_TELEMETRY_REPORTING"
971 @depends("MOZ_TELEMETRY_REPORTING", milestone.is_nightly)
972 def telemetry_on_by_default(reporting, is_nightly):
973 return reporting and is_nightly
976 set_define("MOZ_TELEMETRY_ON_BY_DEFAULT", True, when=telemetry_on_by_default)
980 # ==============================================================
981 system_lib_option("--enable-gpsd", env="MOZ_GPSD", help="Enable gpsd support")
984 @depends("--enable-gpsd")
989 system_gpsd = pkg_check_modules("MOZ_GPSD", "libgps >= 3.11", when=gpsd)
991 set_config("MOZ_GPSD", depends_if(system_gpsd)(lambda _: True))
993 # Miscellaneous programs
994 # ==============================================================
996 check_prog("TAR", ("gnutar", "gtar", "tar"))
997 check_prog("UNZIP", ("unzip",))
1000 # ==============================================================
1001 include("../build/moz.configure/keyfiles.configure")
1003 simple_keyfile("Mozilla API")
1005 simple_keyfile("Google Location Service API")
1007 simple_keyfile("Google Safebrowsing API")
1009 id_and_secret_keyfile("Bing API")
1011 simple_keyfile("Adjust SDK")
1013 id_and_secret_keyfile("Leanplum SDK")
1015 simple_keyfile("Pocket API")
1018 # WebRender Debugger integration
1019 # ==============================================================
1022 "--enable-webrender-debugger", help="Build the websocket debug server in WebRender"
1026 "MOZ_WEBRENDER_DEBUGGER", depends_if("--enable-webrender-debugger")(lambda _: True)
1029 # Additional system headers defined at the application level
1030 # ==============================================================
1033 "--enable-app-system-headers",
1034 env="MOZ_APP_SYSTEM_HEADERS",
1035 help="Use additional system headers defined in $MOZ_BUILD_APP/app-system-headers.mozbuild",
1039 @depends("--enable-app-system-headers")
1040 def app_system_headers(value):
1045 set_config("MOZ_APP_SYSTEM_HEADERS", app_system_headers)
1046 set_define("MOZ_APP_SYSTEM_HEADERS", app_system_headers)
1049 # ==============================================================
1050 option("--disable-printing", help="Disable printing support")
1053 @depends("--disable-printing")
1054 def printing(value):
1059 set_config("NS_PRINTING", printing)
1060 set_define("NS_PRINTING", printing)
1061 set_define("NS_PRINT_PREVIEW", printing)
1063 # Speech-dispatcher support
1064 # ==============================================================
1066 def no_speechd_on_non_gtk(toolkit):
1067 if toolkit != "gtk":
1072 "--enable-synth-speechd", no_speechd_on_non_gtk, reason="--enable-default-toolkit"
1075 option("--disable-synth-speechd", help="Disable speech-dispatcher support")
1077 set_config("MOZ_SYNTH_SPEECHD", depends_if("--disable-synth-speechd")(lambda _: True))
1080 # ==============================================================
1081 option("--disable-webspeech", help="Disable support for HTML Speech API")
1084 @depends("--disable-webspeech")
1085 def webspeech(value):
1090 set_config("MOZ_WEBSPEECH", webspeech)
1091 set_define("MOZ_WEBSPEECH", webspeech)
1092 add_old_configure_assignment("MOZ_WEBSPEECH", webspeech)
1094 # Speech API test backend
1095 # ==============================================================
1097 "--enable-webspeechtestbackend",
1099 help="{Enable|Disable} support for HTML Speech API Test Backend",
1103 @depends_if("--enable-webspeechtestbackend")
1104 def webspeech_test_backend(value):
1108 set_config("MOZ_WEBSPEECH_TEST_BACKEND", webspeech_test_backend)
1109 set_define("MOZ_WEBSPEECH_TEST_BACKEND", webspeech_test_backend)
1112 # ==============================================================
1113 @depends(target, milestone)
1114 def skia_pdf_default(target, milestone):
1115 return milestone.is_nightly and target.os != "WINNT"
1118 option("--enable-skia-pdf", default=skia_pdf_default, help="{Enable|Disable} Skia PDF")
1120 set_config("MOZ_ENABLE_SKIA_PDF", True, when="--enable-skia-pdf")
1121 set_define("MOZ_ENABLE_SKIA_PDF", True, when="--enable-skia-pdf")
1132 "--with-system-webp", help="Use system libwebp (located with pkgconfig)"
1135 system_webp = pkg_check_modules(
1136 "MOZ_WEBP", "libwebp >= 1.0.2 libwebpdemux >= 1.0.2", when="--with-system-webp"
1139 set_config("MOZ_SYSTEM_WEBP", depends(when=system_webp)(lambda: True))
1141 # Build Freetype in the tree
1142 # ==============================================================
1143 @depends(target, "--enable-skia-pdf")
1144 def tree_freetype(target, skia_pdf):
1145 if target.os == "Android" or (skia_pdf and target.os == "WINNT"):
1149 set_define("MOZ_TREE_FREETYPE", tree_freetype)
1150 set_config("MOZ_TREE_FREETYPE", tree_freetype)
1152 set_define("HAVE_FT_BITMAP_SIZE_Y_PPEM", tree_freetype)
1153 set_define("HAVE_FT_GLYPHSLOT_EMBOLDEN", tree_freetype)
1154 set_define("HAVE_FT_LOAD_SFNT_TABLE", tree_freetype)
1157 @depends(freetype2_combined_info, tree_freetype, build_environment)
1158 def ft2_info(freetype2_combined_info, tree_freetype, build_env):
1161 cflags=("-I%s/modules/freetype2/include" % build_env.topsrcdir,), libs=()
1163 if freetype2_combined_info:
1164 return freetype2_combined_info
1167 set_config("FT2_LIBS", ft2_info.libs)
1170 @depends(target, tree_freetype, freetype2_info)
1171 def enable_cairo_ft(target, tree_freetype, freetype2_info):
1172 # Avoid defining MOZ_ENABLE_CAIRO_FT on Windows platforms because
1173 # "cairo-ft-font.c" includes <dlfcn.h>, which only exists on posix platforms
1174 return freetype2_info or (tree_freetype and target.os != "WINNT")
1177 set_config("MOZ_ENABLE_CAIRO_FT", True, when=enable_cairo_ft)
1178 set_config("CAIRO_FT_CFLAGS", ft2_info.cflags, when=enable_cairo_ft)
1181 # WebDriver (HTTP / BiDi)
1182 # ==============================================================
1184 # WebDriver is a remote control interface that enables introspection and
1185 # control of user agents. It provides a platform- and language-neutral wire
1186 # protocol as a way for out-of-process programs to remotely instruct the
1187 # behavior of web browsers.
1189 # The Gecko implementation is backed by Marionette and Remote Agent.
1190 # Both protocols are not really toolkit features, as much as Gecko engine
1191 # features. But they are enabled based on the toolkit, so here it lives.
1193 # Marionette remote protocol
1194 # -----------------------------------------------------------
1196 # Marionette is the Gecko remote protocol used for various remote control,
1197 # automation, and testing purposes throughout Gecko-based applications like
1198 # Firefox, Thunderbird, and any mobile browser built upon GeckoView.
1200 # It also backs ../testing/geckodriver, which is Mozilla's WebDriver
1203 # The source of Marionette lives in ../remote/marionette.
1205 # For more information, see:
1206 # https://firefox-source-docs.mozilla.org/testing/marionette/index.html
1208 # Remote Agent (WebDriver BiDi / partial CDP)
1209 # -----------------------------------------------------------
1211 # The primary purpose is the implementation of the WebDriver BiDi specification.
1212 # But it also complements the existing Firefox Developer Tools Remote Debugging
1213 # Protocol (RDP) by implementing a subset of the Chrome DevTools Protocol (CDP).
1215 # The source of Remote Agent lives in ../remote.
1217 # For more information, see:
1218 # https://firefox-source-docs.mozilla.org/remote/index.html
1222 "--disable-webdriver",
1223 help="Disable support for WebDriver remote protocols",
1227 @depends("--disable-webdriver")
1228 def webdriver(enabled):
1233 set_config("ENABLE_WEBDRIVER", webdriver)
1234 set_define("ENABLE_WEBDRIVER", webdriver)
1237 # geckodriver WebDriver implementation
1238 # ==============================================================
1240 # Turn off geckodriver for build configs we don't handle yet,
1241 # but allow --enable-geckodriver to override when compile environment is available.
1242 # --disable-tests implies disabling geckodriver.
1243 # Disable building in CI
1247 "--enable-tests", target, cross_compiling, hazard_analysis, asan, "MOZ_AUTOMATION"
1249 def geckodriver_default(enable_tests, target, cross_compile, hazard, asan, automation):
1250 if not enable_tests:
1252 if hazard or target.os == "Android" or (asan and cross_compile):
1260 "--enable-geckodriver",
1261 default=geckodriver_default,
1262 when="--enable-compile-environment",
1263 help="{Build|Do not build} geckodriver",
1267 @depends("--enable-geckodriver", when="--enable-compile-environment")
1268 def geckodriver(enabled):
1273 set_config("MOZ_GECKODRIVER", geckodriver)
1277 # ========================================================
1279 def webrtc_default(target):
1280 # Turn off webrtc for OS's we don't handle yet, but allow
1281 # --enable-webrtc to override.
1283 for os_fragment in (
1294 if target.raw_os.startswith(os_fragment):
1309 or target.cpu.startswith("ppc")
1313 if os_match and cpu_match:
1320 default=webrtc_default,
1321 help="{Enable|Disable} support for WebRTC",
1325 @depends("--disable-webrtc")
1326 def webrtc(enabled):
1331 set_config("MOZ_WEBRTC", webrtc)
1332 set_define("MOZ_WEBRTC", webrtc)
1333 set_config("MOZ_SCTP", webrtc)
1334 set_define("MOZ_SCTP", webrtc)
1335 set_config("MOZ_SRTP", webrtc)
1336 set_define("MOZ_SRTP", webrtc)
1337 set_config("MOZ_WEBRTC_SIGNALING", webrtc)
1338 set_define("MOZ_WEBRTC_SIGNALING", webrtc)
1339 set_config("MOZ_PEERCONNECTION", webrtc)
1340 set_define("MOZ_PEERCONNECTION", webrtc)
1341 # MOZ_WEBRTC_ASSERT_ALWAYS turns on a number of safety asserts in
1342 # opt/production builds (via MOZ_CRASH())
1343 set_config("MOZ_WEBRTC_ASSERT_ALWAYS", webrtc)
1344 set_define("MOZ_WEBRTC_ASSERT_ALWAYS", webrtc)
1347 # ==============================================================
1350 @depends(target, webrtc)
1351 def raw_media_default(target, webrtc):
1352 if target.os == "Android":
1360 default=raw_media_default,
1361 help="{Enable|Disable} support for RAW media",
1364 set_config("MOZ_RAW", depends_if("--enable-raw")(lambda _: True))
1365 set_define("MOZ_RAW", depends_if("--enable-raw")(lambda _: True))
1369 # ==============================================================
1370 @depends(webrtc, when=toolkit_gtk)
1371 def x11_libs(webrtc):
1381 # third_party/libwebrtc/webrtc/webrtc_gn/moz.build adds those
1382 # manually, ensure they're available.
1394 x11_headers = pkg_check_modules(
1397 allow_missing=depends(full_toolkit)(lambda t: t == "cairo-gtk3-wayland"),
1398 when=depends(full_toolkit)(
1399 lambda t: t in ("cairo-gtk3", "cairo-gtk3-wayland", "cairo-gtk3-x11-wayland")
1404 set_config("MOZ_X11", True, when=x11_headers)
1405 set_define("MOZ_X11", True, when=x11_headers)
1411 allow_missing=depends(full_toolkit)(lambda t: t == "cairo-gtk3-wayland"),
1412 when=depends(full_toolkit)(
1413 lambda t: t in ("cairo-gtk3", "cairo-gtk3-wayland", "cairo-gtk3-x11-wayland")
1418 # ASan Reporter Addon
1419 # ==============================================================
1421 "--enable-address-sanitizer-reporter",
1422 help="Enable Address Sanitizer Reporter Extension",
1426 @depends("--enable-address-sanitizer-reporter")
1427 def enable_asan_reporter(value):
1432 set_config("MOZ_ASAN_REPORTER", enable_asan_reporter)
1433 set_define("MOZ_ASAN_REPORTER", enable_asan_reporter)
1434 add_old_configure_assignment("MOZ_ASAN_REPORTER", enable_asan_reporter)
1437 # ==============================================================
1438 with only_when("--enable-compile-environment"):
1440 @depends(host, target)
1441 def has_elfhack(host, target):
1443 target.kernel == "Linux"
1444 and host.kernel == "Linux"
1445 and target.cpu in ("arm", "aarch64", "x86", "x86_64")
1448 @depends("--enable-release", enable_linker)
1449 def default_elfhack(release, linker):
1450 # Disable elfhack when explicitly building with --enable-linker=lld
1451 if linker and linker.origin != "default" and linker[0] in ("lld", "mold"):
1453 return bool(release)
1455 with only_when(has_elfhack):
1457 "--disable-elf-hack",
1458 default=default_elfhack,
1459 help="{Enable|Disable} elf hacks",
1462 @depends(select_linker, when="--enable-elf-hack")
1463 def use_elf_hack(linker):
1464 if linker and linker.KIND == "lld":
1466 "Cannot enable elfhack with lld."
1467 " Use --enable-linker=bfd, --enable-linker=gold, or --disable-elf-hack"
1471 set_config("USE_ELF_HACK", use_elf_hack)
1474 @depends(build_environment)
1475 def idl_roots(build_env):
1477 ipdl_root=os.path.join(build_env.topobjdir, "ipc", "ipdl"),
1478 webidl_root=os.path.join(build_env.topobjdir, "dom", "bindings"),
1479 xpcom_root=os.path.join(build_env.topobjdir, "xpcom", "components"),
1483 set_config("WEBIDL_ROOT", idl_roots.webidl_root)
1484 set_config("IPDL_ROOT", idl_roots.ipdl_root)
1485 set_config("XPCOM_ROOT", idl_roots.xpcom_root)
1487 # Proxy bypass protection
1488 # ==============================================================
1491 "--enable-proxy-bypass-protection",
1492 help="Prevent suspected or confirmed proxy bypasses",
1496 @depends_if("--enable-proxy-bypass-protection")
1497 def proxy_bypass_protection(_):
1501 set_config("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1502 set_define("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1504 # Proxy direct failover
1505 # ==============================================================
1508 "--disable-proxy-direct-failover",
1509 help="Disable direct failover for system requests",
1513 @depends_if("--disable-proxy-direct-failover")
1514 def proxy_direct_failover(value):
1519 set_config("MOZ_PROXY_DIRECT_FAILOVER", proxy_direct_failover)
1520 set_define("MOZ_PROXY_DIRECT_FAILOVER", proxy_direct_failover)
1523 # ==============================================================
1526 @depends(c_compiler, toolchain_prefix)
1527 def midl_names(c_compiler, toolchain_prefix):
1528 if c_compiler and c_compiler.type in ["gcc", "clang"]:
1531 if toolchain_prefix:
1532 prefixed = tuple("%s%s" % (p, "widl") for p in toolchain_prefix)
1533 widl = prefixed + widl
1536 return ("midl.exe",)
1539 @depends(target, "--enable-compile-environment")
1540 def check_for_midl(target, compile_environment):
1541 if target.os != "WINNT":
1544 if compile_environment:
1551 when=check_for_midl,
1554 # MIDL being used from a python wrapper script, we can live with it
1559 option(env="MIDL_FLAGS", nargs=1, help="Extra flags to pass to MIDL")
1566 when=depends(midl, target)(lambda m, t: m and t.kernel == "WINNT"),
1568 def midl_flags(flags, target, midl):
1570 flags = flags[0].split()
1574 if not midl.endswith("widl"):
1580 return flags + ["-nologo", "-no_cpp", "-env", env]
1584 "x86": ["--win32", "-m32"],
1585 "x86_64": ["--win64", "-m64"],
1589 set_config("MIDL_FLAGS", midl_flags)
1592 # ==============================================================
1594 option("--disable-accessibility", help="Disable accessibility support")
1597 @depends("--enable-accessibility", check_for_midl, midl, c_compiler)
1598 def accessibility(value, check_for_midl, midl, c_compiler):
1599 enabled = bool(value)
1604 if check_for_midl and not midl:
1605 if c_compiler and c_compiler.type in ("gcc", "clang"):
1607 "You have accessibility enabled, but widl could not be found. "
1608 "Add --disable-accessibility to your mozconfig or install widl. "
1609 "See https://developer.mozilla.org/en-US/docs/Cross_Compile_Mozilla_for_Mingw32 for details."
1613 "MIDL could not be found. "
1614 "Building accessibility without MIDL is not supported."
1620 set_config("ACCESSIBILITY", accessibility)
1621 set_define("ACCESSIBILITY", accessibility)
1624 @depends(moz_debug, developer_options)
1625 def a11y_log(debug, developer_options):
1626 return debug or developer_options
1629 set_config("A11Y_LOG", True, when=a11y_log)
1630 set_define("A11Y_LOG", True, when=a11y_log)
1634 # ==============================================================
1636 def require_signing(milestone):
1637 return milestone.is_release_or_beta and not milestone.is_esr
1641 env="MOZ_REQUIRE_SIGNING",
1642 default=require_signing,
1643 help="Enforce that add-ons are signed by the trusted root",
1646 set_config("MOZ_REQUIRE_SIGNING", True, when="MOZ_REQUIRE_SIGNING")
1647 set_define("MOZ_REQUIRE_SIGNING", True, when="MOZ_REQUIRE_SIGNING")
1650 "--with-unsigned-addon-scopes",
1652 choices=("app", "system"),
1653 help="Addon scopes where signature is not required",
1657 @depends("--with-unsigned-addon-scopes")
1658 def unsigned_addon_scopes(scopes):
1660 app="app" in scopes or None,
1661 system="system" in scopes or None,
1665 set_config("MOZ_UNSIGNED_APP_SCOPE", unsigned_addon_scopes.app)
1666 set_config("MOZ_UNSIGNED_SYSTEM_SCOPE", unsigned_addon_scopes.system)
1670 # ==============================================================
1672 "--allow-addon-sideload",
1673 default=milestone.is_esr,
1674 help="Addon sideloading is allowed",
1678 set_config("MOZ_ALLOW_ADDON_SIDELOAD", True, when="--allow-addon-sideload")
1680 # WebExtensions API WebIDL bindings
1681 # ==============================================================
1685 def extensions_webidl_bindings_default(milestone):
1686 # Only enable the webidl bindings for the WebExtensions APIs
1688 return milestone.is_nightly
1692 "--enable-extensions-webidl-bindings",
1693 default=extensions_webidl_bindings_default,
1694 help="{Enable|Disable} building experimental WebExtensions WebIDL bindings",
1698 @depends("--enable-extensions-webidl-bindings")
1699 def extensions_webidl_enabled(value):
1703 set_config("MOZ_WEBEXT_WEBIDL_ENABLED", extensions_webidl_enabled)
1705 # Launcher process (Windows only)
1706 # ==============================================================
1710 def launcher_process_default(target):
1711 return target.os == "WINNT"
1715 "--enable-launcher-process",
1716 default=launcher_process_default,
1717 help="{Enable|Disable} launcher process by default",
1721 @depends("--enable-launcher-process", target)
1722 def launcher(value, target):
1723 enabled = bool(value)
1724 if enabled and target.os != "WINNT":
1725 die("Cannot enable launcher process on %s", target.os)
1730 set_config("MOZ_LAUNCHER_PROCESS", launcher)
1731 set_define("MOZ_LAUNCHER_PROCESS", launcher)
1733 # llvm-dlltool (Windows only)
1734 # ==============================================================
1737 @depends(build_project, target, "--enable-compile-environment")
1738 def check_for_llvm_dlltool(build_project, target, compile_environment):
1739 if build_project != "browser":
1742 if target.os != "WINNT":
1745 return compile_environment
1748 llvm_dlltool = check_prog(
1751 what="llvm-dlltool",
1752 when=check_for_llvm_dlltool,
1753 paths=clang_search_path,
1757 @depends(target, when=llvm_dlltool)
1758 def llvm_dlltool_flags(target):
1761 "x86_64": "i386:x86-64",
1768 set_config("LLVM_DLLTOOL_FLAGS", llvm_dlltool_flags)
1770 # BITS download (Windows only)
1771 # ==============================================================
1774 "--enable-bits-download",
1775 when=target_is_windows,
1776 default=target_is_windows,
1777 help="{Enable|Disable} building BITS download support",
1781 "MOZ_BITS_DOWNLOAD",
1782 depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
1785 "MOZ_BITS_DOWNLOAD",
1786 depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
1789 # Bundled fonts on desktop platform
1790 # ==============================================================
1794 def bundled_fonts_default(target):
1795 return target.os == "WINNT" or target.kernel == "Linux"
1798 @depends(build_project)
1799 def allow_bundled_fonts(project):
1800 return project == "browser" or project == "comm/mail"
1804 "--enable-bundled-fonts",
1805 default=bundled_fonts_default,
1806 when=allow_bundled_fonts,
1807 help="{Enable|Disable} support for bundled fonts on desktop platforms",
1811 "MOZ_BUNDLED_FONTS",
1812 depends_if("--enable-bundled-fonts", when=allow_bundled_fonts)(lambda _: True),
1816 # ==============================================================
1820 def reflow_perf(debug):
1826 "--enable-reflow-perf",
1827 default=reflow_perf,
1828 help="{Enable|Disable} reflow performance tracing",
1831 # The difference in conditions here comes from the initial implementation
1832 # in old-configure, which was unexplained there as well.
1833 set_define("MOZ_REFLOW_PERF", depends_if("--enable-reflow-perf")(lambda _: True))
1834 set_define("MOZ_REFLOW_PERF_DSP", reflow_perf)
1837 # ==============================================================
1841 def layout_debugger(debug):
1847 "--enable-layout-debugger",
1848 default=layout_debugger,
1849 help="{Enable|Disable} layout debugger",
1852 set_config("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
1853 set_define("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
1856 # Shader Compiler for Windows (and MinGW Cross Compile)
1857 # ==============================================================
1859 with only_when(compile_environment):
1862 ("fxc.exe", "fxc2.exe"),
1863 when=depends(target)(lambda t: t.kernel == "WINNT"),
1865 # FXC being used from a python wrapper script, we can live with it
1874 with only_when(compile_environment):
1876 "--with-system-libvpx", help="Use system libvpx (located with pkgconfig)"
1879 with only_when("--with-system-libvpx"):
1880 vpx = pkg_check_modules("MOZ_LIBVPX", "vpx >= 1.10.0")
1883 "vpx/vpx_decoder.h",
1885 onerror=lambda: die(
1886 "Couldn't find vpx/vpx_decoder.h, which is required to build "
1887 "with system libvpx. Use --without-system-libvpx to build "
1888 "with in-tree libvpx."
1893 "vpx_codec_dec_init_ver",
1895 onerror=lambda: die(
1896 "--with-system-libvpx requested but symbol vpx_codec_dec_init_ver "
1901 set_config("MOZ_SYSTEM_LIBVPX", True)
1903 @depends("--with-system-libvpx", target)
1904 def in_tree_vpx(system_libvpx, target):
1908 arm_asm = (target.cpu == "arm") or None
1909 return namespace(arm_asm=arm_asm)
1911 @depends(target, when=in_tree_vpx)
1912 def vpx_nasm(target):
1913 if target.cpu in ("x86", "x86_64"):
1914 if target.kernel == "WINNT":
1915 # Version 2.03 is needed for automatic safeseh support.
1916 return namespace(version="2.03", what="VPX")
1917 return namespace(what="VPX")
1919 @depends(in_tree_vpx, vpx_nasm, target, neon_flags)
1920 def vpx_as_flags(vpx, vpx_nasm, target, neon_flags):
1921 if vpx and vpx.arm_asm:
1922 # These flags are a lie; they're just used to enable the requisite
1923 # opcodes; actual arch detection is done at runtime.
1925 elif vpx and vpx_nasm and target.os != "WINNT" and target.cpu != "x86_64":
1928 set_config("VPX_USE_NASM", True, when=vpx_nasm)
1929 set_config("VPX_ASFLAGS", vpx_as_flags)
1935 with only_when(compile_environment):
1937 "--with-system-jpeg",
1939 help="Use system libjpeg (installed at given prefix)",
1942 @depends_if("--with-system-jpeg")
1943 def jpeg_flags(value):
1946 cflags=("-I%s/include" % value[0],),
1947 ldflags=("-L%s/lib" % value[0], "-ljpeg"),
1950 ldflags=("-ljpeg",),
1953 with only_when("--with-system-jpeg"):
1955 "jpeg_destroy_compress",
1956 flags=jpeg_flags.ldflags,
1957 onerror=lambda: die(
1958 "--with-system-jpeg requested but symbol "
1959 "jpeg_destroy_compress not found."
1963 c_compiler.try_compile(
1970 #if JPEG_LIB_VERSION < 62
1971 #error Insufficient JPEG library version
1974 flags=jpeg_flags.cflags,
1975 check_msg="for sufficient jpeg library version",
1976 onerror=lambda: die(
1977 "Insufficient JPEG library version for "
1978 "--with-system-jpeg (62 required)"
1982 c_compiler.try_compile(
1989 #ifndef JCS_EXTENSIONS
1990 #error libjpeg-turbo JCS_EXTENSIONS required
1993 flags=jpeg_flags.cflags,
1994 check_msg="for sufficient libjpeg-turbo JCS_EXTENSIONS",
1995 onerror=lambda: die(
1996 "libjpeg-turbo JCS_EXTENSIONS required for " "--with-system-jpeg"
2000 set_config("MOZ_JPEG_CFLAGS", jpeg_flags.cflags)
2001 set_config("MOZ_JPEG_LIBS", jpeg_flags.ldflags)
2003 @depends("--with-system-jpeg", target, neon_flags)
2004 def in_tree_jpeg_arm(system_jpeg, target, neon_flags):
2008 if target.cpu == "arm":
2010 elif target.cpu == "aarch64":
2011 return ("-march=armv8-a",)
2013 @depends("--with-system-jpeg", target)
2014 def in_tree_jpeg_mips64(system_jpeg, target):
2018 if target.cpu == "mips64":
2019 return ("-Wa,-mloongson-mmi", "-mloongson-ext")
2021 # Compiler check from https://github.com/libjpeg-turbo/libjpeg-turbo/blob/57ba02a408a9a55ccff25aae8b164632a3a4f177/simd/CMakeLists.txt#L419
2022 jpeg_mips64_mmi = c_compiler.try_compile(
2023 body='int c = 0, a = 0, b = 0; asm("paddb %0, %1, %2" : "=f" (c) : "f" (a), "f" (b));',
2024 check_msg="for loongson mmi support",
2025 flags=in_tree_jpeg_mips64,
2026 when=in_tree_jpeg_mips64,
2030 "--with-system-jpeg",
2033 in_tree_jpeg_mips64,
2037 system_jpeg, target, in_tree_jpeg_arm, in_tree_jpeg_mips64, jpeg_mips64_mmi
2042 if target.cpu in ("arm", "aarch64"):
2043 return in_tree_jpeg_arm
2044 elif target.kernel == "Darwin":
2045 if target.cpu == "x86":
2046 return ("-DPIC", "-DMACHO")
2047 elif target.cpu == "x86_64":
2048 return ("-D__x86_64__", "-DPIC", "-DMACHO")
2049 elif target.kernel == "WINNT":
2050 if target.cpu == "x86":
2051 return ("-DPIC", "-DWIN32")
2052 elif target.cpu == "x86_64":
2053 return ("-D__x86_64__", "-DPIC", "-DWIN64", "-DMSVC")
2054 elif target.cpu == "mips32":
2056 elif target.cpu == "mips64" and jpeg_mips64_mmi:
2057 return in_tree_jpeg_mips64
2058 elif target.cpu == "x86":
2059 return ("-DPIC", "-DELF")
2060 elif target.cpu == "x86_64":
2061 return ("-D__x86_64__", "-DPIC", "-DELF")
2063 @depends(target, when=depends("--with-system-jpeg")(lambda x: not x))
2064 def jpeg_nasm(target):
2065 if target.cpu in ("x86", "x86_64"):
2066 # libjpeg-turbo 2.0.6 requires nasm 2.10.
2067 return namespace(version="2.10", what="JPEG")
2069 # Compiler checks from https://github.com/libjpeg-turbo/libjpeg-turbo/blob/57ba02a408a9a55ccff25aae8b164632a3a4f177/simd/CMakeLists.txt#L258
2070 jpeg_arm_neon_vld1_s16_x3 = c_compiler.try_compile(
2071 includes=["arm_neon.h"],
2072 body="int16_t input[12] = {}; int16x4x3_t output = vld1_s16_x3(input);",
2073 check_msg="for vld1_s16_x3 in arm_neon.h",
2074 flags=in_tree_jpeg_arm,
2075 when=in_tree_jpeg_arm,
2078 jpeg_arm_neon_vld1_u16_x2 = c_compiler.try_compile(
2079 includes=["arm_neon.h"],
2080 body="uint16_t input[8] = {}; uint16x4x2_t output = vld1_u16_x2(input);",
2081 check_msg="for vld1_u16_x2 in arm_neon.h",
2082 flags=in_tree_jpeg_arm,
2083 when=in_tree_jpeg_arm,
2086 jpeg_arm_neon_vld1q_u8_x4 = c_compiler.try_compile(
2087 includes=["arm_neon.h"],
2088 body="uint8_t input[64] = {}; uint8x16x4_t output = vld1q_u8_x4(input);",
2089 check_msg="for vld1q_u8_x4 in arm_neon.h",
2090 flags=in_tree_jpeg_arm,
2091 when=in_tree_jpeg_arm,
2094 set_config("LIBJPEG_TURBO_USE_NASM", True, when=jpeg_nasm)
2095 set_config("LIBJPEG_TURBO_SIMD_FLAGS", in_tree_jpeg)
2096 set_config("LIBJPEG_TURBO_HAVE_VLD1_S16_X3", jpeg_arm_neon_vld1_s16_x3)
2097 set_config("LIBJPEG_TURBO_HAVE_VLD1_U16_X2", jpeg_arm_neon_vld1_u16_x2)
2098 set_config("LIBJPEG_TURBO_HAVE_VLD1Q_U8_X4", jpeg_arm_neon_vld1q_u8_x4)
2100 "LIBJPEG_TURBO_NEON_INTRINSICS",
2101 jpeg_arm_neon_vld1_s16_x3
2102 & jpeg_arm_neon_vld1_u16_x2
2103 & jpeg_arm_neon_vld1q_u8_x4,
2109 with only_when(compile_environment):
2111 "--with-system-png",
2113 help="Use system libpng",
2116 @depends("--with-system-png")
2117 def deprecated_system_png_path(value):
2120 "--with-system-png=PATH is not supported anymore. Please use "
2121 "--with-system-png and set any necessary pkg-config environment variable."
2124 png = pkg_check_modules("MOZ_PNG", "libpng >= 1.6.35", when="--with-system-png")
2129 onerror=lambda: die(
2130 "--with-system-png won't work because the system's libpng doesn't have APNG support"
2132 when="--with-system-png",
2135 set_config("MOZ_SYSTEM_PNG", True, when="--with-system-png")
2138 # FFmpeg's ffvpx configuration
2139 # ==============================================================
2140 with only_when(compile_environment):
2143 def libav_fft(target):
2144 return target.kernel in ("WINNT", "Darwin") or target.cpu == "x86_64"
2146 set_config("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
2147 set_define("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
2150 # Artifact builds need MOZ_FFVPX defined as if compilation happened.
2151 with only_when(compile_environment | artifact_builds):
2155 enable = use_nasm = True
2159 if target.kernel == "WINNT":
2160 if target.cpu == "x86":
2161 # 32-bit windows need to prefix symbols with an underscore.
2162 flags = ["-DPIC", "-DWIN32", "-DPREFIX", "-Pconfig_win32.asm"]
2163 elif target.cpu == "x86_64":
2169 "-Pconfig_win64.asm",
2171 elif target.cpu == "aarch64":
2172 flags = ["-DPIC", "-DWIN64"]
2174 elif target.kernel == "Darwin":
2175 # 32/64-bit macosx assemblers need to prefix symbols with an
2177 flags = ["-DPIC", "-DMACHO", "-DPREFIX"]
2178 if target.cpu == "x86_64":
2181 "-Pconfig_darwin64.asm",
2183 elif target.cpu == "aarch64":
2185 elif target.cpu == "x86_64":
2186 flags = ["-D__x86_64__", "-DPIC", "-DELF", "-Pconfig_unix64.asm"]
2187 elif target.cpu in ("x86", "arm", "aarch64"):
2192 if flac_only or not enable:
2198 flac_only=flac_only,
2202 @depends(when=ffvpx.use_nasm)
2204 # nasm 2.10 for AVX-2 support.
2205 return namespace(version="2.10", what="FFVPX")
2207 # ffvpx_nasm can't indirectly depend on vpx_as_flags, because it depends
2208 # on a compiler test, so we have to do a little bit of dance here.
2209 @depends(ffvpx, vpx_as_flags, target)
2210 def ffvpx(ffvpx, vpx_as_flags, target):
2211 if ffvpx and vpx_as_flags and target.cpu in ("arm", "aarch64"):
2212 ffvpx.flags.extend(vpx_as_flags)
2215 set_config("MOZ_FFVPX", True, when=ffvpx.enable)
2216 set_define("MOZ_FFVPX", True, when=ffvpx.enable)
2217 set_config("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.flac_only)
2218 set_define("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.flac_only)
2219 set_config("FFVPX_ASFLAGS", ffvpx.flags)
2220 set_config("FFVPX_USE_NASM", True, when=ffvpx.use_nasm)
2224 # ==============================================================
2225 @depends(dav1d_nasm, vpx_nasm, jpeg_nasm, ffvpx_nasm, when=compile_environment)
2226 def need_nasm(*requirements):
2228 x.what: x.version if hasattr(x, "version") else True for x in requirements if x
2231 items = sorted(requires.keys())
2233 what = " and ".join((", ".join(items[:-1]), items[-1]))
2236 versioned = {k: v for (k, v) in requires.items() if v is not True}
2237 return namespace(what=what, versioned=versioned)
2249 @depends(nasm, need_nasm.what)
2250 def check_nasm(nasm, what):
2251 if not nasm and what:
2252 die("Nasm is required to build with %s, but it was not found." % what)
2256 @depends_if(check_nasm)
2257 @checking("nasm version")
2258 def nasm_version(nasm):
2260 check_cmd_output(nasm, "-v", onerror=lambda: die("Failed to get nasm version."))
2264 return Version(version)
2267 @depends(nasm_version, need_nasm.versioned, when=need_nasm.versioned)
2268 def check_nasm_version(nasm_version, versioned):
2269 by_version = sorted(versioned.items(), key=lambda x: x[1])
2270 what, version = by_version[-1]
2271 if nasm_version < version:
2273 "Nasm version %s or greater is required to build with %s." % (version, what)
2278 @depends(target, when=check_nasm_version)
2279 def nasm_asflags(target):
2281 ("OSX", "x86"): ["-f", "macho32"],
2282 ("OSX", "x86_64"): ["-f", "macho64"],
2283 ("WINNT", "x86"): ["-f", "win32"],
2284 ("WINNT", "x86_64"): ["-f", "win64"],
2285 }.get((target.os, target.cpu), None)
2287 # We're assuming every x86 platform we support that's
2288 # not Windows or Mac is ELF.
2289 if target.cpu == "x86":
2290 asflags = ["-f", "elf32"]
2291 elif target.cpu == "x86_64":
2292 asflags = ["-f", "elf64"]
2296 set_config("NASM_ASFLAGS", nasm_asflags)
2299 # ANGLE OpenGL->D3D translator for WebGL
2300 # ==============================================================
2302 with only_when(compile_environment & target_is_windows):
2304 def d3d_compiler_dll_result(value):
2306 return "provided by the OS"
2309 @depends(target, valid_windows_sdk_dir, fxc)
2310 @checking("for D3D compiler DLL", d3d_compiler_dll_result)
2312 def d3d_compiler_dll(target, windows_sdk_dir, fxc):
2315 }.get(target.cpu, target.cpu)
2317 name = "d3dcompiler_47.dll"
2319 if target.cpu == "aarch64":
2320 # AArch64 Windows comes with d3dcompiler_47.dll installed
2321 return namespace(name=name, path=None)
2324 path = os.path.join(windows_sdk_dir.path, "Redist", "D3D", suffix, name)
2325 error_extra = "in Windows SDK at {}".format(windows_sdk_dir.path)
2327 path = os.path.join(os.path.dirname(fxc), name)
2328 error_extra = "alongside FXC at {}".format(fxc)
2330 if os.path.exists(path):
2331 return namespace(name=name, path=path)
2332 die("Could not find {} {}".format(name, error_extra))
2334 set_config("MOZ_ANGLE_RENDERER", True)
2336 "MOZ_D3DCOMPILER_VISTA_DLL", d3d_compiler_dll.name, when=d3d_compiler_dll.path
2338 set_config("MOZ_D3DCOMPILER_VISTA_DLL_PATH", d3d_compiler_dll.path)
2340 # Remoting protocol support
2341 # ==============================================================
2345 def has_remote(toolkit):
2346 if toolkit in ("gtk", "windows", "cocoa"):
2350 set_config("MOZ_HAS_REMOTE", has_remote)
2351 set_define("MOZ_HAS_REMOTE", has_remote)
2353 # RLBox Library Sandboxing wasm support
2354 # ==============================================================
2357 def wasm_sandboxing_libraries():
2367 @depends(dependable(wasm_sandboxing_libraries))
2368 def default_wasm_sandboxing_libraries(libraries):
2369 non_default_libs = set()
2371 return tuple(l for l in libraries if l not in non_default_libs)
2375 "--with-wasm-sandboxed-libraries",
2376 env="WASM_SANDBOXED_LIBRARIES",
2377 help="{Enable wasm sandboxing for the selected libraries|Disable wasm sandboxing}",
2379 choices=dependable(wasm_sandboxing_libraries),
2380 default=default_wasm_sandboxing_libraries,
2384 @depends("--with-wasm-sandboxed-libraries")
2385 def requires_wasm_sandboxing(libraries):
2390 set_config("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
2391 set_define("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
2393 with only_when(requires_wasm_sandboxing & compile_environment):
2395 "--with-wasi-sysroot",
2398 help="Path to wasi sysroot for wasm sandboxing",
2401 @depends("--with-wasi-sysroot", requires_wasm_sandboxing)
2402 def bootstrap_wasi_sysroot(wasi_sysroot, requires_wasm_sandboxing):
2403 return requires_wasm_sandboxing and not wasi_sysroot
2406 "--with-wasi-sysroot",
2407 bootstrap_path("sysroot-wasm32-wasi", when=bootstrap_wasi_sysroot),
2408 "--with-wasm-sandboxed-libraries",
2411 def wasi_sysroot(wasi_sysroot, bootstrapped_sysroot, sandboxed_libs):
2412 if not wasi_sysroot:
2413 if not bootstrapped_sysroot:
2414 suggest_disable = ""
2415 if sandboxed_libs.origin == "default":
2417 " Or build with --without-wasm-sandboxed-libraries."
2420 "Cannot find a wasi sysroot. Please give its location with "
2421 "--with-wasi-sysroot." + suggest_disable
2423 return bootstrapped_sysroot
2425 wasi_sysroot = wasi_sysroot[0]
2426 if not os.path.isdir(wasi_sysroot):
2427 die("Argument to --with-wasi-sysroot must be a directory")
2428 if not os.path.isabs(wasi_sysroot):
2429 die("Argument to --with-wasi-sysroot must be an absolute path")
2433 set_config("WASI_SYSROOT", wasi_sysroot)
2435 def wasm_compiler_with_flags(compiler, sysroot):
2441 + [compiler.compiler]
2443 + ["--sysroot=%s" % sysroot]
2446 wasm_cc = compiler("C", wasm, other_compiler=c_compiler)
2448 @depends(wasm_cc, wasi_sysroot)
2449 def wasm_cc_with_flags(wasm_cc, wasi_sysroot):
2450 return wasm_compiler_with_flags(wasm_cc, wasi_sysroot)
2452 set_config("WASM_CC", wasm_cc_with_flags)
2454 wasm_cxx = compiler(
2458 other_compiler=cxx_compiler,
2459 other_c_compiler=c_compiler,
2462 @depends(wasm_cxx, wasi_sysroot)
2463 def wasm_cxx_with_flags(wasm_cxx, wasi_sysroot):
2464 return wasm_compiler_with_flags(wasm_cxx, wasi_sysroot)
2466 set_config("WASM_CXX", wasm_cxx_with_flags)
2468 wasm_compile_flags = dependable(["-fno-exceptions", "-fno-strict-aliasing"])
2469 option(env="WASM_CFLAGS", nargs=1, help="Options to pass to WASM_CC")
2471 @depends("WASM_CFLAGS", wasm_compile_flags)
2472 def wasm_cflags(value, wasm_compile_flags):
2474 return wasm_compile_flags + value
2476 return wasm_compile_flags
2478 set_config("WASM_CFLAGS", wasm_cflags)
2480 option(env="WASM_CXXFLAGS", nargs=1, help="Options to pass to WASM_CXX")
2482 @depends("WASM_CXXFLAGS", wasm_compile_flags)
2483 def wasm_cxxflags(value, wasm_compile_flags):
2485 return wasm_compile_flags + value
2487 return wasm_compile_flags
2489 set_config("WASM_CXXFLAGS", wasm_cxxflags)
2492 @depends("--with-wasm-sandboxed-libraries")
2493 def wasm_sandboxing(libraries):
2497 return namespace(**{name: True for name in libraries})
2501 def wasm_sandboxing_config_defines():
2502 for lib in wasm_sandboxing_libraries():
2504 "MOZ_WASM_SANDBOXING_%s" % lib.upper(), getattr(wasm_sandboxing, lib)
2507 "MOZ_WASM_SANDBOXING_%s" % lib.upper(), getattr(wasm_sandboxing, lib)
2511 wasm_sandboxing_config_defines()
2514 # new XULStore implementation
2515 # ==============================================================
2519 def new_xulstore(milestone):
2520 if milestone.is_nightly:
2524 set_config("MOZ_NEW_XULSTORE", True, when=new_xulstore)
2525 set_define("MOZ_NEW_XULSTORE", True, when=new_xulstore)
2528 # new Notification Store implementation
2529 # ==============================================================
2533 def new_notification_store(milestone):
2534 if milestone.is_nightly:
2538 set_config("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)
2539 set_define("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)
2542 # Glean SDK Integration Crate
2543 # ==============================================================
2547 def glean_android(target):
2548 return target.os == "Android"
2551 set_config("MOZ_GLEAN_ANDROID", True, when=glean_android)
2552 set_define("MOZ_GLEAN_ANDROID", True, when=glean_android)
2556 # ==============================================================
2562 bootstrap="dump_syms",
2563 when=compile_environment,
2567 @depends(valid_windows_sdk_dir, host)
2568 @imports(_from="os", _import="environ")
2569 def pdbstr_paths(valid_windows_sdk_dir, host):
2570 if not valid_windows_sdk_dir:
2580 os.path.join(valid_windows_sdk_dir.path, "Debuggers", vc_host, "srcsrv"),
2588 when=compile_environment & target_is_windows,
2594 @depends("MOZ_AUTOMATION", c_compiler)
2595 def allow_missing_winchecksec(automation, c_compiler):
2598 if c_compiler and c_compiler.type != "clang-cl":
2604 ["winchecksec.exe", "winchecksec"],
2605 bootstrap="winchecksec",
2606 allow_missing=allow_missing_winchecksec,
2607 when=compile_environment & target_is_windows,
2611 @depends(target, build_project)
2612 def forkserver_default(target, build_project):
2613 return build_project == "browser" and (
2614 (target.os == "GNU" and target.kernel == "Linux")
2615 or target.os == "FreeBSD"
2616 or target.os == "OpenBSD"
2621 "--enable-forkserver",
2622 default=forkserver_default,
2623 env="MOZ_ENABLE_FORKSERVER",
2624 help="{Enable|Disable} fork server",
2628 @depends("--enable-forkserver", target)
2629 def forkserver_flag(value, target):
2631 target.os == "Android"
2632 or (target.os == "GNU" and target.kernel == "Linux")
2633 or target.os == "FreeBSD"
2634 or target.os == "OpenBSD"
2640 set_config("MOZ_ENABLE_FORKSERVER", forkserver_flag)
2641 set_define("MOZ_ENABLE_FORKSERVER", forkserver_flag, forkserver_flag)
2644 # ==============================================================
2646 with only_when(compile_environment & target_is_linux):
2647 # Check if we need to use the breakpad_getcontext fallback.
2648 getcontext = check_symbol("getcontext")
2649 set_config("HAVE_GETCONTEXT", getcontext)
2650 set_define("HAVE_GETCONTEXT", getcontext)
2653 # ==============================================================
2654 include("../build/moz.configure/nss.configure")
2657 # Enable or disable running in background task mode: headless for
2658 # periodic, short-lived, maintenance tasks.
2659 # ==============================================================================
2663 "--disable-backgroundtasks",
2664 help="Disable running in background task mode",
2668 @depends("--enable-backgroundtasks")
2669 def background_tasks(value):
2673 set_config("MOZ_BACKGROUNDTASKS", background_tasks)
2674 set_define("MOZ_BACKGROUNDTASKS", background_tasks)
2677 # Update-related programs: updater, maintenance service, update agent,
2678 # default browser agent.
2679 # ==============================================================
2680 include("../build/moz.configure/update-programs.configure")
2683 # Mobile optimizations
2684 # ==============================================================
2686 "--enable-mobile-optimize",
2687 default=target_is_android,
2688 help="{Enable|Disable} mobile optimizations",
2691 set_define("MOZ_GFX_OPTIMIZE_MOBILE", True, when="--enable-mobile-optimize")
2692 # We ignore "paint will resample" on mobile for performance.
2693 # We may want to revisit this later.
2694 set_define("MOZ_IGNORE_PAINT_WILL_RESAMPLE", True, when="--enable-mobile-optimize")
2697 # ==============================================================
2698 option("--disable-pref-extensions", help="Disable pref extensions such as autoconfig")
2699 set_config("MOZ_PREF_EXTENSIONS", True, when="--enable-pref-extensions")
2701 # Offer a way to disable the startup cache
2702 # ==============================================================
2703 option("--disable-startupcache", help="Disable startup cache")
2706 @depends("--enable-startupcache")
2707 def enable_startupcache(value):
2713 "MOZ_DISABLE_STARTUPCACHE", True, when=depends(enable_startupcache)(lambda x: not x)
2718 # ==============================================================
2720 env="MOZ_APP_REMOTINGNAME",
2722 help="Used for the internal program name, which affects profile name "
2723 "and remoting. If not set, defaults to MOZ_APP_NAME if the update channel "
2724 "is release, and MOZ_APP_NAME-MOZ_UPDATE_CHANNEL otherwise.",
2728 @depends("MOZ_APP_REMOTINGNAME", moz_app_name, update_channel)
2729 def moz_app_remotingname(value, moz_app_name, update_channel):
2732 if update_channel == "release":
2734 return moz_app_name + "-" + update_channel
2737 set_config("MOZ_APP_REMOTINGNAME", moz_app_remotingname)
2740 env="ANDROID_PACKAGE_NAME",
2742 help="Name of the Android package (default org.mozilla.$MOZ_APP_NAME)",
2746 @depends("ANDROID_PACKAGE_NAME", moz_app_name)
2747 def android_package_name(value, moz_app_name):
2750 if moz_app_name == "fennec":
2751 return "org.mozilla.fennec_aurora"
2752 return "org.mozilla.%s" % moz_app_name
2755 set_config("ANDROID_PACKAGE_NAME", android_package_name)
2758 # Miscellaneous options
2759 # ==============================================================
2760 option(env="MOZ_WINCONSOLE", nargs="?", help="Whether we can create a console window.")
2761 set_define("MOZ_WINCONSOLE", True, when=depends("MOZ_WINCONSOLE")(lambda x: x))
2764 # Alternative Crashreporter setting
2766 "--with-crashreporter-url",
2767 env="MOZ_CRASHREPORTER_URL",
2768 default="https://crash-reports.mozilla.com/",
2770 help="Set an alternative crashreporter url",
2774 "MOZ_CRASHREPORTER_URL",
2775 depends("--with-crashreporter-url")(lambda x: x[0].rstrip("/")),
2779 # Crash reporter options
2780 # ==============================================================
2782 def oxidized_breakpad(target):
2783 if target.kernel == "Linux" and target.os != "Android":
2784 return target.cpu in ("x86", "x86_64")
2788 set_config("MOZ_OXIDIZED_BREAKPAD", True, when=oxidized_breakpad)
2789 set_define("MOZ_OXIDIZED_BREAKPAD", True, when=oxidized_breakpad)
2793 # ==============================================================
2794 @depends(target, host)
2795 def want_wine(target, host):
2796 return target.kernel == "WINNT" and host.kernel != "WINNT"
2803 bootstrap="wine/bin",
2807 # ==============================================================
2808 # Set this to true so the JS engine knows we're doing a browser build.
2809 set_config("MOZ_DOM_STREAMS", True)
2810 set_define("MOZ_DOM_STREAMS", True)
2813 # ==============================================================
2814 with only_when(compile_environment):
2816 "--with-system-libevent",
2818 help="Use system libevent",
2821 @depends("--with-system-libevent")
2822 def deprecated_system_libevent_path(value):
2825 "--with-system-libevent=PATH is not supported anymore. Please use "
2826 "--with-system-libevent and set any necessary pkg-config environment variable."
2829 pkg_check_modules("MOZ_LIBEVENT", "libevent", when="--with-system-libevent")
2831 set_config("MOZ_SYSTEM_LIBEVENT", True, when="--with-system-libevent")
2835 # ==============================================================
2836 @depends(target, developer_options, artifact_builds)
2837 def crashreporter_default(target, developer_options, artifacts):
2838 if target.kernel in ("WINNT", "Darwin"):
2840 if target.kernel == "Linux" and target.cpu in ("x86", "x86_64", "arm", "aarch64"):
2841 # The crash reporter prevents crash stacktraces to be logged in the
2842 # logs on Android, so we leave it out by default in developer builds.
2843 return target.os != "Android" or not developer_options or artifacts
2847 "--enable-crashreporter",
2848 default=crashreporter_default,
2849 help="{Enable|Disable} crash reporting",
2853 set_config("MOZ_CRASHREPORTER", True, when="--enable-crashreporter")
2854 set_define("MOZ_CRASHREPORTER", True, when="--enable-crashreporter")
2855 add_old_configure_assignment("MOZ_CRASHREPORTER", True, when="--enable-crashreporter")
2857 with only_when(compile_environment):
2858 with only_when("--enable-crashreporter"):
2862 when=depends(target)(lambda t: t.os == "GNU" and t.kernel == "Linux"),
2866 "MOZ_CRASHREPORTER_INJECTOR",
2868 when=depends(target)(lambda t: t.os == "WINNT" and t.bitness == 32),
2871 "MOZ_CRASHREPORTER_INJECTOR",
2873 when=depends(target)(lambda t: t.os == "WINNT" and t.bitness == 32),
2878 # ==============================================================
2879 with only_when(toolkit_gtk):
2882 "gtk+-3.0 >= 3.14.0 gtk+-unix-print-3.0 glib-2.0 gobject-2.0 gio-unix-2.0",
2885 set_define("GDK_VERSION_MIN_REQUIRED", "GDK_VERSION_3_14")
2886 set_define("GDK_VERSION_MAX_ALLOWED", "GDK_VERSION_3_14")
2888 pkg_check_modules("GLIB", "glib-2.0 >= 2.42 gobject-2.0")
2890 set_define("GLIB_VERSION_MIN_REQUIRED", "GLIB_VERSION_2_42")
2891 set_define("GLIB_VERSION_MAX_ALLOWED", "GLIB_VERSION_2_42")
2893 set_define("MOZ_ACCESSIBILITY_ATK", True, when=accessibility)
2896 # ==============================================================
2897 with only_when(toolkit_gtk):
2898 option("--disable-dbus", help="Disable dbus support")
2900 with only_when("--enable-dbus"):
2901 pkg_check_modules("MOZ_DBUS", "dbus-1 >= 0.60")
2902 pkg_check_modules("MOZ_DBUS_GLIB", "dbus-glib-1 >= 0.60")
2904 set_config("MOZ_ENABLE_DBUS", True)
2905 set_define("MOZ_ENABLE_DBUS", True)
2908 # Necko's wifi scanner
2909 # ==============================================================
2911 def necko_wifi_when(target):
2912 return target.os in ("WINNT", "OSX", "DragonFly", "FreeBSD") or (
2913 target.kernel == "Linux" and target.os == "GNU"
2917 option("--disable-necko-wifi", help="Disable necko wifi scanner", when=necko_wifi_when)
2919 set_config("NECKO_WIFI", True, when="--enable-necko-wifi")
2920 set_define("NECKO_WIFI", True, when="--enable-necko-wifi")
2924 depends("--enable-necko-wifi", when=necko_wifi_when)(lambda x: x),
2925 depends("--enable-dbus", when=toolkit_gtk)(lambda x: x),
2926 when=depends(target)(lambda t: t.os == "GNU" and t.kernel == "Linux"),
2928 def necko_wifi_dbus(necko_wifi, dbus):
2929 if necko_wifi and not dbus:
2931 "Necko WiFi scanning needs DBus on your platform, remove --disable-dbus"
2932 " or use --disable-necko-wifi"
2934 return necko_wifi and dbus
2937 set_config("NECKO_WIFI_DBUS", True, when=necko_wifi_dbus)
2940 # Frontend JS debug mode
2941 # ==============================================================
2942 option("--enable-debug-js-modules", help="Enable debug mode for frontend JS libraries")
2944 set_config("DEBUG_JS_MODULES", True, when="--enable-debug-js-modules")
2948 # ==============================================================
2949 option("--enable-dump-painting", help="Enable paint debugging")
2952 "MOZ_DUMP_PAINTING",
2954 when=depends("--enable-dump-painting", "--enable-debug")(
2955 lambda painting, debug: painting or debug
2958 set_define("MOZ_LAYERS_HAVE_LOG", True, when="--enable-dump-painting")
2962 # ==============================================================
2963 with only_when(toolkit_gtk):
2964 system_lib_option("--enable-libproxy", help="Enable libproxy support")
2966 with only_when("--enable-libproxy"):
2967 pkg_check_modules("MOZ_LIBPROXY", "libproxy-1.0")
2969 set_config("MOZ_ENABLE_LIBPROXY", True)
2970 set_define("MOZ_ENABLE_LIBPROXY", True)
2973 # Enable runtime logging
2974 # ==============================================================
2975 set_define("MOZ_LOGGING", True)
2976 set_define("FORCE_PR_LOG", True)
2978 # This will enable logging of addref, release, ctor, dtor.
2979 # ==============================================================
2981 "--enable-logrefcnt",
2983 help="{Enable|Disable} logging of refcounts",
2986 set_define("NS_BUILD_REFCNT_LOGGING", True, when="--enable-logrefcnt")
2990 # ==============================================================
2991 option("--disable-negotiateauth", help="Disable GSS-API negotiation")
2993 set_config("MOZ_AUTH_EXTENSION", True, when="--enable-negotiateauth")
2994 set_define("MOZ_AUTH_EXTENSION", True, when="--enable-negotiateauth")
2998 # ==============================================================
2999 option("--disable-parental-controls", help="Do not build parental controls")
3002 "MOZ_DISABLE_PARENTAL_CONTROLS",
3004 when=depends("--enable-parental-controls")(lambda x: not x),
3007 "MOZ_DISABLE_PARENTAL_CONTROLS",
3009 when=depends("--enable-parental-controls")(lambda x: not x),
3013 # Sandboxing support
3014 # ==============================================================
3015 @depends(target, tsan, asan)
3016 def sandbox_default(target, tsan, asan):
3017 # Only enable the sandbox by default on Linux, OpenBSD, macOS, and Windows
3018 if target.kernel == "Linux" and target.os == "GNU":
3019 # Bug 1182565: TSan conflicts with sandboxing on Linux.
3020 # Bug 1287971: LSan also conflicts with sandboxing on Linux.
3023 # Linux sandbox is only available on x86{,_64} and arm{,64}.
3024 return target.cpu in ("x86", "x86_64", "arm", "aarch64")
3025 return target.kernel in ("WINNT", "Darwin", "OpenBSD")
3030 default=sandbox_default,
3031 help="{Enable|Disable} sandboxing support",
3034 set_config("MOZ_SANDBOX", True, when="--enable-sandbox")
3035 set_define("MOZ_SANDBOX", True, when="--enable-sandbox")
3038 # Searching of system directories for extensions.
3039 # ==============================================================
3040 # Note: this switch is meant to be used for test builds whose behavior should
3041 # not depend on what happens to be installed on the local machine.
3043 "--disable-system-extension-dirs",
3044 help="Disable searching system- and account-global directories for extensions"
3045 " of any kind; use only profile-specific extension directories",
3048 set_define("ENABLE_SYSTEM_EXTENSION_DIRS", True, when="--enable-system-extension-dirs")
3052 # ==============================================================
3053 with only_when(compile_environment):
3055 "--enable-system-pixman", help="Use system pixman (located with pkgconfig)"
3058 @depends("--enable-system-pixman")
3059 def in_tree_pixman(pixman):
3062 set_config("MOZ_TREE_PIXMAN", True, when=in_tree_pixman)
3063 set_define("MOZ_TREE_PIXMAN", True, when=in_tree_pixman)
3065 pkg_check_modules("MOZ_PIXMAN", "pixman-1 >= 0.36.0", when="--enable-system-pixman")
3066 # Set MOZ_PIXMAN_CFLAGS to an explicit empty value when --enable-system-pixman is *not* used,
3067 # for layout/style/extra-bindgen-flags
3068 set_config("MOZ_PIXMAN_CFLAGS", [], when=in_tree_pixman)
3072 # ==============================================================
3073 with only_when(compile_environment):
3074 option("--disable-universalchardet", help="Disable universal encoding detection")
3076 set_config("MOZ_UNIVERSALCHARDET", True, when="--enable-universalchardet")
3080 # ==============================================================
3081 with only_when(compile_environment):
3082 option("--disable-zipwriter", help="Disable zipwriter component")
3084 set_config("MOZ_ZIPWRITER", True, when="--enable-zipwriter")
3087 # Location of the mozilla user directory
3088 # ==============================================================
3089 with only_when(compile_environment):
3092 def default_user_appdir(target):
3093 if target.kernel in ("WINNT", "Darwin"):
3098 "--with-user-appdir",
3100 default=default_user_appdir,
3101 help="Set user-specific appdir",
3104 @depends("--with-user-appdir")
3105 def user_appdir(appdir):
3107 die("--without-user-appdir is not a valid option.")
3108 if "/" in appdir[0]:
3109 die("--with-user-appdir must be a single relative path.")
3110 return '"{}"'.format(appdir[0])
3112 set_define("MOZ_USER_DIR", user_appdir)
3115 # Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
3116 # ==============================================================
3117 with only_when(compile_environment):
3118 have_sin_len = c_compiler.try_compile(
3119 includes=["netinet/in.h"],
3120 body="struct sockaddr_in x; void *foo = (void*) &x.sin_len;",
3121 check_msg="for sin_len in struct sockaddr_in",
3123 have_sin6_len = c_compiler.try_compile(
3124 includes=["netinet/in.h"],
3125 body="struct sockaddr_in6 x; void *foo = (void*) &x.sin6_len;",
3126 check_msg="for sin_len6 in struct sockaddr_in6",
3128 set_define("HAVE_SIN_LEN", have_sin_len)
3129 set_define("HAVE_SIN6_LEN", have_sin6_len)
3130 # HAVE_CONN_LEN must be the same as HAVE_SIN_LEN and HAVE_SIN6_LEN
3131 set_define("HAVE_SCONN_LEN", have_sin_len & have_sin6_len)
3134 c_compiler.try_compile(
3135 includes=["netinet/in.h"],
3136 body="struct sockaddr x; void *foo = (void*) &x.sa_len;",
3137 check_msg="for sa_len in struct sockaddr",
3142 # Check for pthread_cond_timedwait_monotonic_np
3143 # ==============================================================
3144 with only_when(compile_environment):
3146 "HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC",
3147 c_compiler.try_compile(
3148 includes=["pthread.h"],
3149 body="pthread_cond_timedwait_monotonic_np(0, 0, 0);",
3150 # -Werror to catch any "implicit declaration" warning that means the function
3152 flags=["-Werror=implicit-function-declaration"],
3153 check_msg="for pthread_cond_timedwait_monotonic_np",
3158 # Custom dynamic linker for Android
3159 # ==============================================================
3160 with only_when(target_is_linux & compile_environment):
3163 default=depends(target.os, when="--enable-jemalloc")(
3164 lambda os: os == "Android"
3166 help="{Enable|Disable} custom dynamic linker",
3169 set_config("MOZ_LINKER", True, when="MOZ_LINKER")
3170 set_define("MOZ_LINKER", True, when="MOZ_LINKER")
3171 add_old_configure_assignment("MOZ_LINKER", True, when="MOZ_LINKER")
3173 moz_linker = depends(when="MOZ_LINKER")(lambda: True)
3176 # 32-bits ethtool_cmd.speed
3177 # ==============================================================
3178 with only_when(target_is_linux & compile_environment):
3180 "MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI",
3181 c_compiler.try_compile(
3182 includes=["linux/ethtool.h"],
3183 body="struct ethtool_cmd cmd; cmd.speed_hi = 0;",
3184 check_msg="for 32-bits ethtool_cmd.speed",
3189 # ==============================================================
3192 onerror=lambda: die(
3193 "Can't find header linux/joystick.h, needed for gamepad support."
3194 " Please install Linux kernel headers."
3196 when=target_is_linux & compile_environment,
3199 # Smart card support
3200 # ==============================================================
3201 @depends(build_project)
3202 def disable_smart_cards(build_project):
3203 return build_project == "mobile/android"
3206 set_config("MOZ_NO_SMART_CARDS", True, when=disable_smart_cards)
3207 set_define("MOZ_NO_SMART_CARDS", True, when=disable_smart_cards)
3209 # Enable UniFFI fixtures
3210 # ==============================================================
3211 # These are used to test the uniffi-bindgen-gecko-js code generation. They
3212 # should not be enabled in release builds.
3215 "--enable-uniffi-fixtures",
3216 help="Enable UniFFI Fixtures/Examples",
3219 set_config("MOZ_UNIFFI_FIXTURES", True, when="--enable-uniffi-fixtures")
3221 # Checks for library functions
3222 # ==============================================================
3223 with only_when(compile_environment & depends(target.os)(lambda os: os != "WINNT")):
3224 set_define("HAVE_STAT64", check_symbol("stat64"))
3225 set_define("HAVE_LSTAT64", check_symbol("lstat64"))
3226 set_define("HAVE_TRUNCATE64", check_symbol("truncate64"))
3227 set_define("HAVE_STATVFS64", check_symbol("statvfs64"))
3228 set_define("HAVE_STATVFS", check_symbol("statvfs"))
3229 set_define("HAVE_STATFS64", check_symbol("statfs64"))
3230 set_define("HAVE_STATFS", check_symbol("statfs"))
3231 set_define("HAVE_LUTIMES", check_symbol("lutimes"))
3232 set_define("HAVE_POSIX_FADVISE", check_symbol("posix_fadvise"))
3233 set_define("HAVE_POSIX_FALLOCATE", check_symbol("posix_fallocate"))
3235 set_define("HAVE_ARC4RANDOM", check_symbol("arc4random"))
3236 set_define("HAVE_ARC4RANDOM_BUF", check_symbol("arc4random_buf"))
3237 set_define("HAVE_MALLINFO", check_symbol("mallinfo"))
3240 # ==============================================================
3243 "--disable-system-policies",
3244 help="Disable reading policies from Windows registry, macOS's file system attributes, and /etc/firefox",
3247 set_config("MOZ_SYSTEM_POLICIES", True, when="--enable-system-policies")