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 set_config("USE_ELF_HACK", depends_if("--enable-elf-hack")(lambda _: True))
1465 @depends(build_environment)
1466 def idl_roots(build_env):
1468 ipdl_root=os.path.join(build_env.topobjdir, "ipc", "ipdl"),
1469 webidl_root=os.path.join(build_env.topobjdir, "dom", "bindings"),
1470 xpcom_root=os.path.join(build_env.topobjdir, "xpcom", "components"),
1474 set_config("WEBIDL_ROOT", idl_roots.webidl_root)
1475 set_config("IPDL_ROOT", idl_roots.ipdl_root)
1476 set_config("XPCOM_ROOT", idl_roots.xpcom_root)
1478 # Proxy bypass protection
1479 # ==============================================================
1482 "--enable-proxy-bypass-protection",
1483 help="Prevent suspected or confirmed proxy bypasses",
1487 @depends_if("--enable-proxy-bypass-protection")
1488 def proxy_bypass_protection(_):
1492 set_config("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1493 set_define("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1495 # Proxy direct failover
1496 # ==============================================================
1499 "--disable-proxy-direct-failover",
1500 help="Disable direct failover for system requests",
1504 @depends_if("--disable-proxy-direct-failover")
1505 def proxy_direct_failover(value):
1510 set_config("MOZ_PROXY_DIRECT_FAILOVER", proxy_direct_failover)
1511 set_define("MOZ_PROXY_DIRECT_FAILOVER", proxy_direct_failover)
1514 # ==============================================================
1517 @depends(c_compiler, toolchain_prefix)
1518 def midl_names(c_compiler, toolchain_prefix):
1519 if c_compiler and c_compiler.type in ["gcc", "clang"]:
1522 if toolchain_prefix:
1523 prefixed = tuple("%s%s" % (p, "widl") for p in toolchain_prefix)
1524 widl = prefixed + widl
1527 return ("midl.exe",)
1530 @depends(target, "--enable-compile-environment")
1531 def check_for_midl(target, compile_environment):
1532 if target.os != "WINNT":
1535 if compile_environment:
1542 when=check_for_midl,
1545 # MIDL being used from a python wrapper script, we can live with it
1550 option(env="MIDL_FLAGS", nargs=1, help="Extra flags to pass to MIDL")
1557 when=depends(midl, target)(lambda m, t: m and t.kernel == "WINNT"),
1559 def midl_flags(flags, target, midl):
1561 flags = flags[0].split()
1565 if not midl.endswith("widl"):
1571 return flags + ["-nologo", "-no_cpp", "-env", env]
1575 "x86": ["--win32", "-m32"],
1576 "x86_64": ["--win64", "-m64"],
1580 set_config("MIDL_FLAGS", midl_flags)
1583 # ==============================================================
1585 option("--disable-accessibility", help="Disable accessibility support")
1588 @depends("--enable-accessibility", check_for_midl, midl, c_compiler)
1589 def accessibility(value, check_for_midl, midl, c_compiler):
1590 enabled = bool(value)
1595 if check_for_midl and not midl:
1596 if c_compiler and c_compiler.type in ("gcc", "clang"):
1598 "You have accessibility enabled, but widl could not be found. "
1599 "Add --disable-accessibility to your mozconfig or install widl. "
1600 "See https://developer.mozilla.org/en-US/docs/Cross_Compile_Mozilla_for_Mingw32 for details."
1604 "MIDL could not be found. "
1605 "Building accessibility without MIDL is not supported."
1611 set_config("ACCESSIBILITY", accessibility)
1612 set_define("ACCESSIBILITY", accessibility)
1615 @depends(moz_debug, developer_options)
1616 def a11y_log(debug, developer_options):
1617 return debug or developer_options
1620 set_config("A11Y_LOG", True, when=a11y_log)
1621 set_define("A11Y_LOG", True, when=a11y_log)
1625 # ==============================================================
1627 def require_signing(milestone):
1628 return milestone.is_release_or_beta and not milestone.is_esr
1632 env="MOZ_REQUIRE_SIGNING",
1633 default=require_signing,
1634 help="Enforce that add-ons are signed by the trusted root",
1637 set_config("MOZ_REQUIRE_SIGNING", True, when="MOZ_REQUIRE_SIGNING")
1638 set_define("MOZ_REQUIRE_SIGNING", True, when="MOZ_REQUIRE_SIGNING")
1641 "--with-unsigned-addon-scopes",
1643 choices=("app", "system"),
1644 help="Addon scopes where signature is not required",
1648 @depends("--with-unsigned-addon-scopes")
1649 def unsigned_addon_scopes(scopes):
1651 app="app" in scopes or None,
1652 system="system" in scopes or None,
1656 set_config("MOZ_UNSIGNED_APP_SCOPE", unsigned_addon_scopes.app)
1657 set_config("MOZ_UNSIGNED_SYSTEM_SCOPE", unsigned_addon_scopes.system)
1661 # ==============================================================
1663 "--allow-addon-sideload",
1664 default=milestone.is_esr,
1665 help="Addon sideloading is allowed",
1669 set_config("MOZ_ALLOW_ADDON_SIDELOAD", True, when="--allow-addon-sideload")
1671 # WebExtensions API WebIDL bindings
1672 # ==============================================================
1676 def extensions_webidl_bindings_default(milestone):
1677 # Only enable the webidl bindings for the WebExtensions APIs
1679 return milestone.is_nightly
1683 "--enable-extensions-webidl-bindings",
1684 default=extensions_webidl_bindings_default,
1685 help="{Enable|Disable} building experimental WebExtensions WebIDL bindings",
1689 @depends("--enable-extensions-webidl-bindings")
1690 def extensions_webidl_enabled(value):
1694 set_config("MOZ_WEBEXT_WEBIDL_ENABLED", extensions_webidl_enabled)
1696 # Launcher process (Windows only)
1697 # ==============================================================
1701 def launcher_process_default(target):
1702 return target.os == "WINNT"
1706 "--enable-launcher-process",
1707 default=launcher_process_default,
1708 help="{Enable|Disable} launcher process by default",
1712 @depends("--enable-launcher-process", target)
1713 def launcher(value, target):
1714 enabled = bool(value)
1715 if enabled and target.os != "WINNT":
1716 die("Cannot enable launcher process on %s", target.os)
1721 set_config("MOZ_LAUNCHER_PROCESS", launcher)
1722 set_define("MOZ_LAUNCHER_PROCESS", launcher)
1724 # llvm-dlltool (Windows only)
1725 # ==============================================================
1728 @depends(build_project, target, "--enable-compile-environment")
1729 def check_for_llvm_dlltool(build_project, target, compile_environment):
1730 if build_project != "browser":
1733 if target.os != "WINNT":
1736 return compile_environment
1739 llvm_dlltool = check_prog(
1742 what="llvm-dlltool",
1743 when=check_for_llvm_dlltool,
1744 paths=clang_search_path,
1748 @depends(target, when=llvm_dlltool)
1749 def llvm_dlltool_flags(target):
1752 "x86_64": "i386:x86-64",
1759 set_config("LLVM_DLLTOOL_FLAGS", llvm_dlltool_flags)
1761 # BITS download (Windows only)
1762 # ==============================================================
1765 "--enable-bits-download",
1766 when=target_is_windows,
1767 default=target_is_windows,
1768 help="{Enable|Disable} building BITS download support",
1772 "MOZ_BITS_DOWNLOAD",
1773 depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
1776 "MOZ_BITS_DOWNLOAD",
1777 depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
1780 # Bundled fonts on desktop platform
1781 # ==============================================================
1785 def bundled_fonts_default(target):
1786 return target.os == "WINNT" or target.kernel == "Linux"
1789 @depends(build_project)
1790 def allow_bundled_fonts(project):
1791 return project == "browser" or project == "comm/mail"
1795 "--enable-bundled-fonts",
1796 default=bundled_fonts_default,
1797 when=allow_bundled_fonts,
1798 help="{Enable|Disable} support for bundled fonts on desktop platforms",
1802 "MOZ_BUNDLED_FONTS",
1803 depends_if("--enable-bundled-fonts", when=allow_bundled_fonts)(lambda _: True),
1807 # ==============================================================
1811 def reflow_perf(debug):
1817 "--enable-reflow-perf",
1818 default=reflow_perf,
1819 help="{Enable|Disable} reflow performance tracing",
1822 # The difference in conditions here comes from the initial implementation
1823 # in old-configure, which was unexplained there as well.
1824 set_define("MOZ_REFLOW_PERF", depends_if("--enable-reflow-perf")(lambda _: True))
1825 set_define("MOZ_REFLOW_PERF_DSP", reflow_perf)
1828 # ==============================================================
1832 def layout_debugger(debug):
1838 "--enable-layout-debugger",
1839 default=layout_debugger,
1840 help="{Enable|Disable} layout debugger",
1843 set_config("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
1844 set_define("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
1847 # Shader Compiler for Windows (and MinGW Cross Compile)
1848 # ==============================================================
1850 with only_when(compile_environment):
1853 ("fxc.exe", "fxc2.exe"),
1854 when=depends(target)(lambda t: t.kernel == "WINNT"),
1856 # FXC being used from a python wrapper script, we can live with it
1865 with only_when(compile_environment):
1867 "--with-system-libvpx", help="Use system libvpx (located with pkgconfig)"
1870 with only_when("--with-system-libvpx"):
1871 vpx = pkg_check_modules("MOZ_LIBVPX", "vpx >= 1.8.0")
1874 "vpx/vpx_decoder.h",
1876 onerror=lambda: die(
1877 "Couldn't find vpx/vpx_decoder.h, which is required to build "
1878 "with system libvpx. Use --without-system-libvpx to build "
1879 "with in-tree libvpx."
1884 "vpx_codec_dec_init_ver",
1886 onerror=lambda: die(
1887 "--with-system-libvpx requested but symbol vpx_codec_dec_init_ver "
1892 set_config("MOZ_SYSTEM_LIBVPX", True)
1894 @depends("--with-system-libvpx", target)
1895 def in_tree_vpx(system_libvpx, target):
1899 arm_asm = (target.cpu == "arm") or None
1900 return namespace(arm_asm=arm_asm)
1902 @depends(target, when=in_tree_vpx)
1903 def vpx_nasm(target):
1904 if target.cpu in ("x86", "x86_64"):
1905 if target.kernel == "WINNT":
1906 # Version 2.03 is needed for automatic safeseh support.
1907 return namespace(version="2.03", what="VPX")
1908 return namespace(what="VPX")
1910 @depends(in_tree_vpx, vpx_nasm, target, neon_flags)
1911 def vpx_as_flags(vpx, vpx_nasm, target, neon_flags):
1912 if vpx and vpx.arm_asm:
1913 # These flags are a lie; they're just used to enable the requisite
1914 # opcodes; actual arch detection is done at runtime.
1916 elif vpx and vpx_nasm and target.os != "WINNT" and target.cpu != "x86_64":
1919 set_config("VPX_USE_NASM", True, when=vpx_nasm)
1920 set_config("VPX_ASFLAGS", vpx_as_flags)
1926 with only_when(compile_environment):
1928 "--with-system-jpeg",
1930 help="Use system libjpeg (installed at given prefix)",
1933 @depends_if("--with-system-jpeg")
1934 def jpeg_flags(value):
1937 cflags=("-I%s/include" % value[0],),
1938 ldflags=("-L%s/lib" % value[0], "-ljpeg"),
1941 ldflags=("-ljpeg",),
1944 with only_when("--with-system-jpeg"):
1946 "jpeg_destroy_compress",
1947 flags=jpeg_flags.ldflags,
1948 onerror=lambda: die(
1949 "--with-system-jpeg requested but symbol "
1950 "jpeg_destroy_compress not found."
1954 c_compiler.try_compile(
1961 #if JPEG_LIB_VERSION < 62
1962 #error Insufficient JPEG library version
1965 flags=jpeg_flags.cflags,
1966 check_msg="for sufficient jpeg library version",
1967 onerror=lambda: die(
1968 "Insufficient JPEG library version for "
1969 "--with-system-jpeg (62 required)"
1973 c_compiler.try_compile(
1980 #ifndef JCS_EXTENSIONS
1981 #error libjpeg-turbo JCS_EXTENSIONS required
1984 flags=jpeg_flags.cflags,
1985 check_msg="for sufficient libjpeg-turbo JCS_EXTENSIONS",
1986 onerror=lambda: die(
1987 "libjpeg-turbo JCS_EXTENSIONS required for " "--with-system-jpeg"
1991 set_config("MOZ_JPEG_CFLAGS", jpeg_flags.cflags)
1992 set_config("MOZ_JPEG_LIBS", jpeg_flags.ldflags)
1994 @depends("--with-system-jpeg", target, neon_flags)
1995 def in_tree_jpeg_arm(system_jpeg, target, neon_flags):
1999 if target.cpu == "arm":
2001 elif target.cpu == "aarch64":
2002 return ("-march=armv8-a",)
2004 @depends("--with-system-jpeg", target)
2005 def in_tree_jpeg_mips64(system_jpeg, target):
2009 if target.cpu == "mips64":
2010 return ("-Wa,-mloongson-mmi", "-mloongson-ext")
2012 # Compiler check from https://github.com/libjpeg-turbo/libjpeg-turbo/blob/57ba02a408a9a55ccff25aae8b164632a3a4f177/simd/CMakeLists.txt#L419
2013 jpeg_mips64_mmi = c_compiler.try_compile(
2014 body='int c = 0, a = 0, b = 0; asm("paddb %0, %1, %2" : "=f" (c) : "f" (a), "f" (b));',
2015 check_msg="for loongson mmi support",
2016 flags=in_tree_jpeg_mips64,
2017 when=in_tree_jpeg_mips64,
2021 "--with-system-jpeg",
2024 in_tree_jpeg_mips64,
2028 system_jpeg, target, in_tree_jpeg_arm, in_tree_jpeg_mips64, jpeg_mips64_mmi
2033 if target.cpu in ("arm", "aarch64"):
2034 return in_tree_jpeg_arm
2035 elif target.kernel == "Darwin":
2036 if target.cpu == "x86":
2037 return ("-DPIC", "-DMACHO")
2038 elif target.cpu == "x86_64":
2039 return ("-D__x86_64__", "-DPIC", "-DMACHO")
2040 elif target.kernel == "WINNT":
2041 if target.cpu == "x86":
2042 return ("-DPIC", "-DWIN32")
2043 elif target.cpu == "x86_64":
2044 return ("-D__x86_64__", "-DPIC", "-DWIN64", "-DMSVC")
2045 elif target.cpu == "mips32":
2047 elif target.cpu == "mips64" and jpeg_mips64_mmi:
2048 return in_tree_jpeg_mips64
2049 elif target.cpu == "x86":
2050 return ("-DPIC", "-DELF")
2051 elif target.cpu == "x86_64":
2052 return ("-D__x86_64__", "-DPIC", "-DELF")
2054 @depends(target, when=depends("--with-system-jpeg")(lambda x: not x))
2055 def jpeg_nasm(target):
2056 if target.cpu in ("x86", "x86_64"):
2057 # libjpeg-turbo 2.0.6 requires nasm 2.10.
2058 return namespace(version="2.10", what="JPEG")
2060 # Compiler checks from https://github.com/libjpeg-turbo/libjpeg-turbo/blob/57ba02a408a9a55ccff25aae8b164632a3a4f177/simd/CMakeLists.txt#L258
2061 jpeg_arm_neon_vld1_s16_x3 = c_compiler.try_compile(
2062 includes=["arm_neon.h"],
2063 body="int16_t input[12] = {}; int16x4x3_t output = vld1_s16_x3(input);",
2064 check_msg="for vld1_s16_x3 in arm_neon.h",
2065 flags=in_tree_jpeg_arm,
2066 when=in_tree_jpeg_arm,
2069 jpeg_arm_neon_vld1_u16_x2 = c_compiler.try_compile(
2070 includes=["arm_neon.h"],
2071 body="uint16_t input[8] = {}; uint16x4x2_t output = vld1_u16_x2(input);",
2072 check_msg="for vld1_u16_x2 in arm_neon.h",
2073 flags=in_tree_jpeg_arm,
2074 when=in_tree_jpeg_arm,
2077 jpeg_arm_neon_vld1q_u8_x4 = c_compiler.try_compile(
2078 includes=["arm_neon.h"],
2079 body="uint8_t input[64] = {}; uint8x16x4_t output = vld1q_u8_x4(input);",
2080 check_msg="for vld1q_u8_x4 in arm_neon.h",
2081 flags=in_tree_jpeg_arm,
2082 when=in_tree_jpeg_arm,
2085 set_config("LIBJPEG_TURBO_USE_NASM", True, when=jpeg_nasm)
2086 set_config("LIBJPEG_TURBO_SIMD_FLAGS", in_tree_jpeg)
2087 set_config("LIBJPEG_TURBO_HAVE_VLD1_S16_X3", jpeg_arm_neon_vld1_s16_x3)
2088 set_config("LIBJPEG_TURBO_HAVE_VLD1_U16_X2", jpeg_arm_neon_vld1_u16_x2)
2089 set_config("LIBJPEG_TURBO_HAVE_VLD1Q_U8_X4", jpeg_arm_neon_vld1q_u8_x4)
2091 "LIBJPEG_TURBO_NEON_INTRINSICS",
2092 jpeg_arm_neon_vld1_s16_x3
2093 & jpeg_arm_neon_vld1_u16_x2
2094 & jpeg_arm_neon_vld1q_u8_x4,
2100 with only_when(compile_environment):
2102 "--with-system-png",
2104 help="Use system libpng",
2107 @depends("--with-system-png")
2108 def deprecated_system_png_path(value):
2111 "--with-system-png=PATH is not supported anymore. Please use "
2112 "--with-system-png and set any necessary pkg-config environment variable."
2115 png = pkg_check_modules("MOZ_PNG", "libpng >= 1.6.35", when="--with-system-png")
2120 onerror=lambda: die(
2121 "--with-system-png won't work because the system's libpng doesn't have APNG support"
2123 when="--with-system-png",
2126 set_config("MOZ_SYSTEM_PNG", True, when="--with-system-png")
2129 # FFmpeg's ffvpx configuration
2130 # ==============================================================
2131 with only_when(compile_environment):
2134 def libav_fft(target):
2135 return target.kernel in ("WINNT", "Darwin") or target.cpu == "x86_64"
2137 set_config("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
2138 set_define("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
2141 # Artifact builds need MOZ_FFVPX defined as if compilation happened.
2142 with only_when(compile_environment | artifact_builds):
2146 enable = use_nasm = True
2150 if target.kernel == "WINNT":
2151 if target.cpu == "x86":
2152 # 32-bit windows need to prefix symbols with an underscore.
2153 flags = ["-DPIC", "-DWIN32", "-DPREFIX", "-Pconfig_win32.asm"]
2154 elif target.cpu == "x86_64":
2160 "-Pconfig_win64.asm",
2162 elif target.cpu == "aarch64":
2163 flags = ["-DPIC", "-DWIN64"]
2165 elif target.kernel == "Darwin":
2166 # 32/64-bit macosx assemblers need to prefix symbols with an
2168 flags = ["-DPIC", "-DMACHO", "-DPREFIX"]
2169 if target.cpu == "x86_64":
2172 "-Pconfig_darwin64.asm",
2174 elif target.cpu == "aarch64":
2176 elif target.cpu == "x86_64":
2177 flags = ["-D__x86_64__", "-DPIC", "-DELF", "-Pconfig_unix64.asm"]
2178 elif target.cpu in ("x86", "arm", "aarch64"):
2183 if flac_only or not enable:
2189 flac_only=flac_only,
2193 @depends(when=ffvpx.use_nasm)
2195 # nasm 2.10 for AVX-2 support.
2196 return namespace(version="2.10", what="FFVPX")
2198 # ffvpx_nasm can't indirectly depend on vpx_as_flags, because it depends
2199 # on a compiler test, so we have to do a little bit of dance here.
2200 @depends(ffvpx, vpx_as_flags, target)
2201 def ffvpx(ffvpx, vpx_as_flags, target):
2202 if ffvpx and vpx_as_flags and target.cpu in ("arm", "aarch64"):
2203 ffvpx.flags.extend(vpx_as_flags)
2206 set_config("MOZ_FFVPX", True, when=ffvpx.enable)
2207 set_define("MOZ_FFVPX", True, when=ffvpx.enable)
2208 set_config("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.flac_only)
2209 set_define("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.flac_only)
2210 set_config("FFVPX_ASFLAGS", ffvpx.flags)
2211 set_config("FFVPX_USE_NASM", True, when=ffvpx.use_nasm)
2215 # ==============================================================
2216 @depends(dav1d_nasm, vpx_nasm, jpeg_nasm, ffvpx_nasm, when=compile_environment)
2217 def need_nasm(*requirements):
2219 x.what: x.version if hasattr(x, "version") else True for x in requirements if x
2222 items = sorted(requires.keys())
2224 what = " and ".join((", ".join(items[:-1]), items[-1]))
2227 versioned = {k: v for (k, v) in requires.items() if v is not True}
2228 return namespace(what=what, versioned=versioned)
2240 @depends(nasm, need_nasm.what)
2241 def check_nasm(nasm, what):
2242 if not nasm and what:
2243 die("Nasm is required to build with %s, but it was not found." % what)
2247 @depends_if(check_nasm)
2248 @checking("nasm version")
2249 def nasm_version(nasm):
2251 check_cmd_output(nasm, "-v", onerror=lambda: die("Failed to get nasm version."))
2255 return Version(version)
2258 @depends(nasm_version, need_nasm.versioned, when=need_nasm.versioned)
2259 def check_nasm_version(nasm_version, versioned):
2260 by_version = sorted(versioned.items(), key=lambda x: x[1])
2261 what, version = by_version[-1]
2262 if nasm_version < version:
2264 "Nasm version %s or greater is required to build with %s." % (version, what)
2269 @depends(target, when=check_nasm_version)
2270 def nasm_asflags(target):
2272 ("OSX", "x86"): ["-f", "macho32"],
2273 ("OSX", "x86_64"): ["-f", "macho64"],
2274 ("WINNT", "x86"): ["-f", "win32"],
2275 ("WINNT", "x86_64"): ["-f", "win64"],
2276 }.get((target.os, target.cpu), None)
2278 # We're assuming every x86 platform we support that's
2279 # not Windows or Mac is ELF.
2280 if target.cpu == "x86":
2281 asflags = ["-f", "elf32"]
2282 elif target.cpu == "x86_64":
2283 asflags = ["-f", "elf64"]
2287 set_config("NASM_ASFLAGS", nasm_asflags)
2290 # ANGLE OpenGL->D3D translator for WebGL
2291 # ==============================================================
2293 with only_when(compile_environment & target_is_windows):
2295 def d3d_compiler_dll_result(value):
2297 return "provided by the OS"
2300 @depends(target, valid_windows_sdk_dir, fxc)
2301 @checking("for D3D compiler DLL", d3d_compiler_dll_result)
2303 def d3d_compiler_dll(target, windows_sdk_dir, fxc):
2306 }.get(target.cpu, target.cpu)
2308 name = "d3dcompiler_47.dll"
2310 if target.cpu == "aarch64":
2311 # AArch64 Windows comes with d3dcompiler_47.dll installed
2312 return namespace(name=name, path=None)
2315 path = os.path.join(windows_sdk_dir.path, "Redist", "D3D", suffix, name)
2316 error_extra = "in Windows SDK at {}".format(windows_sdk_dir.path)
2318 path = os.path.join(os.path.dirname(fxc), name)
2319 error_extra = "alongside FXC at {}".format(fxc)
2321 if os.path.exists(path):
2322 return namespace(name=name, path=path)
2323 die("Could not find {} {}".format(name, error_extra))
2325 set_config("MOZ_ANGLE_RENDERER", True)
2327 "MOZ_D3DCOMPILER_VISTA_DLL", d3d_compiler_dll.name, when=d3d_compiler_dll.path
2329 set_config("MOZ_D3DCOMPILER_VISTA_DLL_PATH", d3d_compiler_dll.path)
2331 # Remoting protocol support
2332 # ==============================================================
2336 def has_remote(toolkit):
2337 if toolkit in ("gtk", "windows", "cocoa"):
2341 set_config("MOZ_HAS_REMOTE", has_remote)
2342 set_define("MOZ_HAS_REMOTE", has_remote)
2344 # RLBox Library Sandboxing wasm support
2345 # ==============================================================
2348 def wasm_sandboxing_libraries():
2358 @depends(dependable(wasm_sandboxing_libraries))
2359 def default_wasm_sandboxing_libraries(libraries):
2360 non_default_libs = set()
2362 return tuple(l for l in libraries if l not in non_default_libs)
2366 "--with-wasm-sandboxed-libraries",
2367 env="WASM_SANDBOXED_LIBRARIES",
2368 help="{Enable wasm sandboxing for the selected libraries|Disable wasm sandboxing}",
2370 choices=dependable(wasm_sandboxing_libraries),
2371 default=default_wasm_sandboxing_libraries,
2375 @depends("--with-wasm-sandboxed-libraries")
2376 def requires_wasm_sandboxing(libraries):
2381 set_config("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
2382 set_define("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
2384 with only_when(requires_wasm_sandboxing & compile_environment):
2386 "--with-wasi-sysroot",
2389 help="Path to wasi sysroot for wasm sandboxing",
2392 @depends("--with-wasi-sysroot", requires_wasm_sandboxing)
2393 def bootstrap_wasi_sysroot(wasi_sysroot, requires_wasm_sandboxing):
2394 return requires_wasm_sandboxing and not wasi_sysroot
2397 "--with-wasi-sysroot",
2398 bootstrap_path("sysroot-wasm32-wasi", when=bootstrap_wasi_sysroot),
2399 "--with-wasm-sandboxed-libraries",
2402 def wasi_sysroot(wasi_sysroot, bootstrapped_sysroot, sandboxed_libs):
2403 if not wasi_sysroot:
2404 if not bootstrapped_sysroot:
2405 suggest_disable = ""
2406 if sandboxed_libs.origin == "default":
2408 " Or build with --without-wasm-sandboxed-libraries."
2411 "Cannot find a wasi sysroot. Please give its location with "
2412 "--with-wasi-sysroot." + suggest_disable
2414 return bootstrapped_sysroot
2416 wasi_sysroot = wasi_sysroot[0]
2417 if not os.path.isdir(wasi_sysroot):
2418 die("Argument to --with-wasi-sysroot must be a directory")
2419 if not os.path.isabs(wasi_sysroot):
2420 die("Argument to --with-wasi-sysroot must be an absolute path")
2424 set_config("WASI_SYSROOT", wasi_sysroot)
2426 def wasm_compiler_with_flags(compiler, sysroot):
2432 + [compiler.compiler]
2434 + ["--sysroot=%s" % sysroot]
2437 wasm_cc = compiler("C", wasm, other_compiler=c_compiler)
2439 @depends(wasm_cc, wasi_sysroot)
2440 def wasm_cc_with_flags(wasm_cc, wasi_sysroot):
2441 return wasm_compiler_with_flags(wasm_cc, wasi_sysroot)
2443 set_config("WASM_CC", wasm_cc_with_flags)
2445 wasm_cxx = compiler(
2449 other_compiler=cxx_compiler,
2450 other_c_compiler=c_compiler,
2453 @depends(wasm_cxx, wasi_sysroot)
2454 def wasm_cxx_with_flags(wasm_cxx, wasi_sysroot):
2455 return wasm_compiler_with_flags(wasm_cxx, wasi_sysroot)
2457 set_config("WASM_CXX", wasm_cxx_with_flags)
2459 wasm_compile_flags = dependable(
2460 ["-fno-exceptions", "-fno-strict-aliasing", "-Qunused-arguments"]
2462 option(env="WASM_CFLAGS", nargs=1, help="Options to pass to WASM_CC")
2464 @depends("WASM_CFLAGS", wasm_compile_flags)
2465 def wasm_cflags(value, wasm_compile_flags):
2467 return wasm_compile_flags + value
2469 return wasm_compile_flags
2471 set_config("WASM_CFLAGS", wasm_cflags)
2473 option(env="WASM_CXXFLAGS", nargs=1, help="Options to pass to WASM_CXX")
2475 @depends("WASM_CXXFLAGS", wasm_compile_flags)
2476 def wasm_cxxflags(value, wasm_compile_flags):
2478 return wasm_compile_flags + value
2480 return wasm_compile_flags
2482 set_config("WASM_CXXFLAGS", wasm_cxxflags)
2485 @depends("--with-wasm-sandboxed-libraries")
2486 def wasm_sandboxing(libraries):
2490 return namespace(**{name: True for name in libraries})
2494 def wasm_sandboxing_config_defines():
2495 for lib in wasm_sandboxing_libraries():
2497 "MOZ_WASM_SANDBOXING_%s" % lib.upper(), getattr(wasm_sandboxing, lib)
2500 "MOZ_WASM_SANDBOXING_%s" % lib.upper(), getattr(wasm_sandboxing, lib)
2504 wasm_sandboxing_config_defines()
2507 # new XULStore implementation
2508 # ==============================================================
2512 def new_xulstore(milestone):
2513 if milestone.is_nightly:
2517 set_config("MOZ_NEW_XULSTORE", True, when=new_xulstore)
2518 set_define("MOZ_NEW_XULSTORE", True, when=new_xulstore)
2521 # new Notification Store implementation
2522 # ==============================================================
2526 def new_notification_store(milestone):
2527 if milestone.is_nightly:
2531 set_config("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)
2532 set_define("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)
2535 # Glean SDK Integration Crate
2536 # ==============================================================
2540 def glean_android(target):
2541 return target.os == "Android"
2544 set_config("MOZ_GLEAN_ANDROID", True, when=glean_android)
2545 set_define("MOZ_GLEAN_ANDROID", True, when=glean_android)
2549 # ==============================================================
2555 bootstrap="dump_syms",
2556 when=compile_environment,
2565 when=compile_environment & target_is_windows,
2569 @depends("MOZ_AUTOMATION", c_compiler)
2570 def allow_missing_winchecksec(automation, c_compiler):
2573 if c_compiler and c_compiler.type != "clang-cl":
2579 ["winchecksec.exe", "winchecksec"],
2580 bootstrap="winchecksec",
2581 allow_missing=allow_missing_winchecksec,
2582 when=compile_environment & target_is_windows,
2586 @depends(target, build_project)
2587 def forkserver_default(target, build_project):
2588 return build_project == "browser" and (
2589 (target.os == "GNU" and target.kernel == "Linux")
2590 or target.os == "FreeBSD"
2591 or target.os == "OpenBSD"
2596 "--enable-forkserver",
2597 default=forkserver_default,
2598 env="MOZ_ENABLE_FORKSERVER",
2599 help="{Enable|Disable} fork server",
2603 @depends("--enable-forkserver", target)
2604 def forkserver_flag(value, target):
2606 target.os == "Android"
2607 or (target.os == "GNU" and target.kernel == "Linux")
2608 or target.os == "FreeBSD"
2609 or target.os == "OpenBSD"
2615 set_config("MOZ_ENABLE_FORKSERVER", forkserver_flag)
2616 set_define("MOZ_ENABLE_FORKSERVER", forkserver_flag, forkserver_flag)
2619 # ==============================================================
2621 with only_when(compile_environment & target_is_linux):
2622 # Check if we need to use the breakpad_getcontext fallback.
2623 getcontext = check_symbol("getcontext")
2624 set_config("HAVE_GETCONTEXT", getcontext)
2625 set_define("HAVE_GETCONTEXT", getcontext)
2628 # ==============================================================
2629 include("../build/moz.configure/nss.configure")
2632 # Enable or disable running in background task mode: headless for
2633 # periodic, short-lived, maintenance tasks.
2634 # ==============================================================================
2638 "--disable-backgroundtasks",
2639 help="Disable running in background task mode",
2644 "MOZ_BACKGROUNDTASKS", depends_if("--enable-backgroundtasks")(lambda _: True)
2648 # Update-related programs: updater, maintenance service, update agent,
2649 # default browser agent.
2650 # ==============================================================
2651 include("../build/moz.configure/update-programs.configure")
2654 # Mobile optimizations
2655 # ==============================================================
2657 "--enable-mobile-optimize",
2658 default=target_is_android,
2659 help="{Enable|Disable} mobile optimizations",
2662 set_define("MOZ_GFX_OPTIMIZE_MOBILE", True, when="--enable-mobile-optimize")
2663 # We ignore "paint will resample" on mobile for performance.
2664 # We may want to revisit this later.
2665 set_define("MOZ_IGNORE_PAINT_WILL_RESAMPLE", True, when="--enable-mobile-optimize")
2668 # ==============================================================
2669 option("--disable-pref-extensions", help="Disable pref extensions such as autoconfig")
2670 set_config("MOZ_PREF_EXTENSIONS", True, when="--enable-pref-extensions")
2672 # Offer a way to disable the startup cache
2673 # ==============================================================
2674 option("--disable-startupcache", help="Disable startup cache")
2677 @depends("--enable-startupcache")
2678 def enable_startupcache(value):
2684 "MOZ_DISABLE_STARTUPCACHE", True, when=depends(enable_startupcache)(lambda x: not x)
2689 # ==============================================================
2691 env="MOZ_APP_REMOTINGNAME",
2693 help="Used for the internal program name, which affects profile name "
2694 "and remoting. If not set, defaults to MOZ_APP_NAME if the update channel "
2695 "is release, and MOZ_APP_NAME-MOZ_UPDATE_CHANNEL otherwise.",
2699 @depends("MOZ_APP_REMOTINGNAME", moz_app_name, update_channel)
2700 def moz_app_remotingname(value, moz_app_name, update_channel):
2703 if update_channel == "release":
2705 return moz_app_name + "-" + update_channel
2708 set_config("MOZ_APP_REMOTINGNAME", moz_app_remotingname)
2711 env="ANDROID_PACKAGE_NAME",
2713 help="Name of the Android package (default org.mozilla.$MOZ_APP_NAME)",
2717 @depends("ANDROID_PACKAGE_NAME", moz_app_name)
2718 def android_package_name(value, moz_app_name):
2721 if moz_app_name == "fennec":
2722 return "org.mozilla.fennec_aurora"
2723 return "org.mozilla.%s" % moz_app_name
2726 set_config("ANDROID_PACKAGE_NAME", android_package_name)
2729 # Miscellaneous options
2730 # ==============================================================
2731 option(env="MOZ_WINCONSOLE", nargs="?", help="Whether we can create a console window.")
2732 set_define("MOZ_WINCONSOLE", True, when=depends("MOZ_WINCONSOLE")(lambda x: x))
2735 # Alternative Crashreporter setting
2737 "--with-crashreporter-url",
2738 env="MOZ_CRASHREPORTER_URL",
2739 default="https://crash-reports.mozilla.com/",
2741 help="Set an alternative crashreporter url",
2745 "MOZ_CRASHREPORTER_URL",
2746 depends("--with-crashreporter-url")(lambda x: x[0].rstrip("/")),
2750 # Crash reporter options
2751 # ==============================================================
2753 def oxidized_breakpad(target):
2754 if target.kernel == "Linux" and target.os != "Android":
2755 return target.cpu in ("x86", "x86_64")
2759 set_config("MOZ_OXIDIZED_BREAKPAD", True, when=oxidized_breakpad)
2760 set_define("MOZ_OXIDIZED_BREAKPAD", True, when=oxidized_breakpad)
2764 # ==============================================================
2765 @depends(target, host)
2766 def want_wine(target, host):
2767 return target.kernel == "WINNT" and host.kernel != "WINNT"
2774 bootstrap="wine/bin",
2778 # ==============================================================
2779 # Set this to true so the JS engine knows we're doing a browser build.
2780 set_config("MOZ_DOM_STREAMS", True)
2781 set_define("MOZ_DOM_STREAMS", True)
2784 # ==============================================================
2785 with only_when(compile_environment):
2787 "--with-system-libevent",
2789 help="Use system libevent",
2792 @depends("--with-system-libevent")
2793 def deprecated_system_libevent_path(value):
2796 "--with-system-libevent=PATH is not supported anymore. Please use "
2797 "--with-system-libevent and set any necessary pkg-config environment variable."
2800 pkg_check_modules("MOZ_LIBEVENT", "libevent", when="--with-system-libevent")
2802 set_config("MOZ_SYSTEM_LIBEVENT", True, when="--with-system-libevent")
2806 # ==============================================================
2807 @depends(target, developer_options, artifact_builds)
2808 def crashreporter_default(target, developer_options, artifacts):
2809 if target.kernel in ("WINNT", "Darwin"):
2811 if target.kernel == "Linux" and target.cpu in ("x86", "x86_64", "arm", "aarch64"):
2812 # The crash reporter prevents crash stacktraces to be logged in the
2813 # logs on Android, so we leave it out by default in developer builds.
2814 return target.os != "Android" or not developer_options or artifacts
2818 "--enable-crashreporter",
2819 default=crashreporter_default,
2820 help="{Enable|Disable} crash reporting",
2824 set_config("MOZ_CRASHREPORTER", True, when="--enable-crashreporter")
2825 set_define("MOZ_CRASHREPORTER", True, when="--enable-crashreporter")
2826 add_old_configure_assignment("MOZ_CRASHREPORTER", True, when="--enable-crashreporter")
2828 with only_when(compile_environment):
2829 with only_when("--enable-crashreporter"):
2833 when=depends(target)(lambda t: t.os == "GNU" and t.kernel == "Linux"),
2837 "MOZ_CRASHREPORTER_INJECTOR",
2839 when=depends(target)(lambda t: t.os == "WINNT" and t.bitness == 32),
2842 "MOZ_CRASHREPORTER_INJECTOR",
2844 when=depends(target)(lambda t: t.os == "WINNT" and t.bitness == 32),
2849 # ==============================================================
2850 with only_when(toolkit_gtk):
2853 "gtk+-3.0 >= 3.14.0 gtk+-unix-print-3.0 glib-2.0 gobject-2.0 gio-unix-2.0",
2856 set_define("GDK_VERSION_MIN_REQUIRED", "GDK_VERSION_3_14")
2857 set_define("GDK_VERSION_MAX_ALLOWED", "GDK_VERSION_3_14")
2859 pkg_check_modules("GLIB", "glib-2.0 >= 2.42 gobject-2.0")
2861 set_define("GLIB_VERSION_MIN_REQUIRED", "GLIB_VERSION_2_42")
2862 set_define("GLIB_VERSION_MAX_ALLOWED", "GLIB_VERSION_2_42")
2864 set_define("MOZ_ACCESSIBILITY_ATK", True, when=accessibility)
2867 # ==============================================================
2868 with only_when(toolkit_gtk):
2869 option("--disable-dbus", help="Disable dbus support")
2871 with only_when("--enable-dbus"):
2872 pkg_check_modules("MOZ_DBUS", "dbus-1 >= 0.60")
2873 pkg_check_modules("MOZ_DBUS_GLIB", "dbus-glib-1 >= 0.60")
2875 set_config("MOZ_ENABLE_DBUS", True)
2876 set_define("MOZ_ENABLE_DBUS", True)
2879 # Necko's wifi scanner
2880 # ==============================================================
2882 def necko_wifi_when(target):
2883 return target.os in ("WINNT", "OSX", "DragonFly", "FreeBSD") or (
2884 target.kernel == "Linux" and target.os == "GNU"
2888 option("--disable-necko-wifi", help="Disable necko wifi scanner", when=necko_wifi_when)
2890 set_config("NECKO_WIFI", True, when="--enable-necko-wifi")
2891 set_define("NECKO_WIFI", True, when="--enable-necko-wifi")
2895 depends("--enable-necko-wifi", when=necko_wifi_when)(lambda x: x),
2896 depends("--enable-dbus", when=toolkit_gtk)(lambda x: x),
2897 when=depends(target)(lambda t: t.os == "GNU" and t.kernel == "Linux"),
2899 def necko_wifi_dbus(necko_wifi, dbus):
2900 if necko_wifi and not dbus:
2902 "Necko WiFi scanning needs DBus on your platform, remove --disable-dbus"
2903 " or use --disable-necko-wifi"
2905 return necko_wifi and dbus
2908 set_config("NECKO_WIFI_DBUS", True, when=necko_wifi_dbus)
2911 # Frontend JS debug mode
2912 # ==============================================================
2913 option("--enable-debug-js-modules", help="Enable debug mode for frontend JS libraries")
2915 set_config("DEBUG_JS_MODULES", True, when="--enable-debug-js-modules")
2919 # ==============================================================
2920 option("--enable-dump-painting", help="Enable paint debugging")
2923 "MOZ_DUMP_PAINTING",
2925 when=depends("--enable-dump-painting", "--enable-debug")(
2926 lambda painting, debug: painting or debug
2929 set_define("MOZ_LAYERS_HAVE_LOG", True, when="--enable-dump-painting")
2933 # ==============================================================
2934 with only_when(toolkit_gtk):
2935 system_lib_option("--enable-libproxy", help="Enable libproxy support")
2937 with only_when("--enable-libproxy"):
2938 pkg_check_modules("MOZ_LIBPROXY", "libproxy-1.0")
2940 set_config("MOZ_ENABLE_LIBPROXY", True)
2941 set_define("MOZ_ENABLE_LIBPROXY", True)
2944 # Enable runtime logging
2945 # ==============================================================
2946 set_define("MOZ_LOGGING", True)
2947 set_define("FORCE_PR_LOG", True)
2949 # This will enable logging of addref, release, ctor, dtor.
2950 # ==============================================================
2952 "--enable-logrefcnt",
2954 help="{Enable|Disable} logging of refcounts",
2957 set_define("NS_BUILD_REFCNT_LOGGING", True, when="--enable-logrefcnt")
2961 # ==============================================================
2962 option("--disable-negotiateauth", help="Disable GSS-API negotiation")
2964 set_config("MOZ_AUTH_EXTENSION", True, when="--enable-negotiateauth")
2965 set_define("MOZ_AUTH_EXTENSION", True, when="--enable-negotiateauth")
2969 # ==============================================================
2970 option("--disable-parental-controls", help="Do not build parental controls")
2973 "MOZ_DISABLE_PARENTAL_CONTROLS",
2975 when=depends("--enable-parental-controls")(lambda x: not x),
2978 "MOZ_DISABLE_PARENTAL_CONTROLS",
2980 when=depends("--enable-parental-controls")(lambda x: not x),
2984 # Sandboxing support
2985 # ==============================================================
2986 @depends(target, tsan, asan)
2987 def sandbox_default(target, tsan, asan):
2988 # Only enable the sandbox by default on Linux, OpenBSD, macOS, and Windows
2989 if target.kernel == "Linux" and target.os == "GNU":
2990 # Bug 1182565: TSan conflicts with sandboxing on Linux.
2991 # Bug 1287971: LSan also conflicts with sandboxing on Linux.
2994 # Linux sandbox is only available on x86{,_64} and arm{,64}.
2995 return target.cpu in ("x86", "x86_64", "arm", "aarch64")
2996 return target.kernel in ("WINNT", "Darwin", "OpenBSD")
3001 default=sandbox_default,
3002 help="{Enable|Disable} sandboxing support",
3005 set_config("MOZ_SANDBOX", True, when="--enable-sandbox")
3006 set_define("MOZ_SANDBOX", True, when="--enable-sandbox")
3009 # Searching of system directories for extensions.
3010 # ==============================================================
3011 # Note: this switch is meant to be used for test builds whose behavior should
3012 # not depend on what happens to be installed on the local machine.
3014 "--disable-system-extension-dirs",
3015 help="Disable searching system- and account-global directories for extensions"
3016 " of any kind; use only profile-specific extension directories",
3019 set_define("ENABLE_SYSTEM_EXTENSION_DIRS", True, when="--enable-system-extension-dirs")
3023 # ==============================================================
3024 with only_when(compile_environment):
3026 "--enable-system-pixman", help="Use system pixman (located with pkgconfig)"
3029 @depends("--enable-system-pixman")
3030 def in_tree_pixman(pixman):
3033 set_config("MOZ_TREE_PIXMAN", True, when=in_tree_pixman)
3034 set_define("MOZ_TREE_PIXMAN", True, when=in_tree_pixman)
3036 pkg_check_modules("MOZ_PIXMAN", "pixman-1 >= 0.36.0", when="--enable-system-pixman")
3037 # Set MOZ_PIXMAN_CFLAGS to an explicit empty value when --enable-system-pixman is *not* used,
3038 # for layout/style/extra-bindgen-flags
3039 set_config("MOZ_PIXMAN_CFLAGS", [], when=in_tree_pixman)
3043 # ==============================================================
3044 with only_when(compile_environment):
3045 option("--disable-universalchardet", help="Disable universal encoding detection")
3047 set_config("MOZ_UNIVERSALCHARDET", True, when="--enable-universalchardet")
3051 # ==============================================================
3052 with only_when(compile_environment):
3053 option("--disable-zipwriter", help="Disable zipwriter component")
3055 set_config("MOZ_ZIPWRITER", True, when="--enable-zipwriter")
3058 # Location of the mozilla user directory
3059 # ==============================================================
3060 with only_when(compile_environment):
3063 def default_user_appdir(target):
3064 if target.kernel in ("WINNT", "Darwin"):
3069 "--with-user-appdir",
3071 default=default_user_appdir,
3072 help="Set user-specific appdir",
3075 @depends("--with-user-appdir")
3076 def user_appdir(appdir):
3078 die("--without-user-appdir is not a valid option.")
3079 if "/" in appdir[0]:
3080 die("--with-user-appdir must be a single relative path.")
3081 return '"{}"'.format(appdir[0])
3083 set_define("MOZ_USER_DIR", user_appdir)
3086 # Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
3087 # ==============================================================
3088 with only_when(compile_environment):
3089 have_sin_len = c_compiler.try_compile(
3090 includes=["netinet/in.h"],
3091 body="struct sockaddr_in x; void *foo = (void*) &x.sin_len;",
3092 check_msg="for sin_len in struct sockaddr_in",
3094 have_sin6_len = c_compiler.try_compile(
3095 includes=["netinet/in.h"],
3096 body="struct sockaddr_in6 x; void *foo = (void*) &x.sin6_len;",
3097 check_msg="for sin_len6 in struct sockaddr_in6",
3099 set_define("HAVE_SIN_LEN", have_sin_len)
3100 set_define("HAVE_SIN6_LEN", have_sin6_len)
3101 # HAVE_CONN_LEN must be the same as HAVE_SIN_LEN and HAVE_SIN6_LEN
3102 set_define("HAVE_SCONN_LEN", have_sin_len & have_sin6_len)
3105 c_compiler.try_compile(
3106 includes=["netinet/in.h"],
3107 body="struct sockaddr x; void *foo = (void*) &x.sa_len;",
3108 check_msg="for sa_len in struct sockaddr",
3113 # Check for pthread_cond_timedwait_monotonic_np
3114 # ==============================================================
3115 with only_when(compile_environment):
3117 "HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC",
3118 c_compiler.try_compile(
3119 includes=["pthread.h"],
3120 body="pthread_cond_timedwait_monotonic_np(0, 0, 0);",
3121 # -Werror to catch any "implicit declaration" warning that means the function
3123 flags=["-Werror=implicit-function-declaration"],
3124 check_msg="for pthread_cond_timedwait_monotonic_np",
3129 # Custom dynamic linker for Android
3130 # ==============================================================
3131 with only_when(target_is_linux & compile_environment):
3134 default=depends(target.os, when="--enable-jemalloc")(
3135 lambda os: os == "Android"
3137 help="{Enable|Disable} custom dynamic linker",
3140 set_config("MOZ_LINKER", True, when="MOZ_LINKER")
3141 set_define("MOZ_LINKER", True, when="MOZ_LINKER")
3142 add_old_configure_assignment("MOZ_LINKER", True, when="MOZ_LINKER")
3144 moz_linker = depends(when="MOZ_LINKER")(lambda: True)
3147 # 32-bits ethtool_cmd.speed
3148 # ==============================================================
3149 with only_when(target_is_linux & compile_environment):
3151 "MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI",
3152 c_compiler.try_compile(
3153 includes=["linux/ethtool.h"],
3154 body="struct ethtool_cmd cmd; cmd.speed_hi = 0;",
3155 check_msg="for 32-bits ethtool_cmd.speed",
3160 # ==============================================================
3163 onerror=lambda: die(
3164 "Can't find header linux/joystick.h, needed for gamepad support."
3165 " Please install Linux kernel headers."
3167 when=target_is_linux & compile_environment,
3170 # Smart card support
3171 # ==============================================================
3172 @depends(build_project)
3173 def disable_smart_cards(build_project):
3174 return build_project == "mobile/android"
3177 set_config("MOZ_NO_SMART_CARDS", True, when=disable_smart_cards)
3178 set_define("MOZ_NO_SMART_CARDS", True, when=disable_smart_cards)
3180 # Enable UniFFI fixtures
3181 # ==============================================================
3182 # These are used to test the uniffi-bindgen-gecko-js code generation. They
3183 # should not be enabled in release builds.
3186 "--enable-uniffi-fixtures",
3187 help="Enable UniFFI Fixtures/Examples",
3190 set_config("MOZ_UNIFFI_FIXTURES", True, when="--enable-uniffi-fixtures")
3192 # Checks for library functions
3193 # ==============================================================
3194 with only_when(compile_environment & depends(target.os)(lambda os: os != "WINNT")):
3195 set_define("HAVE_STAT64", check_symbol("stat64"))
3196 set_define("HAVE_LSTAT64", check_symbol("lstat64"))
3197 set_define("HAVE_TRUNCATE64", check_symbol("truncate64"))
3198 set_define("HAVE_STATVFS64", check_symbol("statvfs64"))
3199 set_define("HAVE_STATVFS", check_symbol("statvfs"))
3200 set_define("HAVE_STATFS64", check_symbol("statfs64"))
3201 set_define("HAVE_STATFS", check_symbol("statfs"))
3202 set_define("HAVE_LUTIMES", check_symbol("lutimes"))
3203 set_define("HAVE_POSIX_FADVISE", check_symbol("posix_fadvise"))
3204 set_define("HAVE_POSIX_FALLOCATE", check_symbol("posix_fallocate"))
3206 set_define("HAVE_ARC4RANDOM", check_symbol("arc4random"))
3207 set_define("HAVE_ARC4RANDOM_BUF", check_symbol("arc4random_buf"))
3208 set_define("HAVE_MALLINFO", check_symbol("mallinfo"))
3211 # ==============================================================
3214 "--disable-system-policies",
3215 help="Disable reading policies from Windows registry, macOS's file system attributes, and /etc/firefox",
3218 set_config("MOZ_SYSTEM_POLICIES", True, when="--enable-system-policies")