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(_from="six", _import="itervalues")
14 @imports("__sandbox__")
15 def all_configure_options():
18 for option in itervalues(__sandbox__._options):
19 # __sandbox__._options contains items for both option.name and
20 # option.env. But it's also an OrderedDict, meaning both are
22 # Also ignore OLD_CONFIGURE and MOZCONFIG because they're not
24 if option == previous or option.env in ("OLD_CONFIGURE", "MOZCONFIG"):
27 value = __sandbox__._value_for(option)
28 # We only want options that were explicitly given on the command
29 # line, the environment, or mozconfig, and that differ from the
33 and value.origin not in ("default", "implied")
34 and value != option.default
37 ensure_unicode(__sandbox__._raw_options[option], system_encoding)
39 # We however always include options that are sent to old configure
40 # because we don't know their actual defaults. (Keep the conditions
41 # separate for ease of understanding and ease of removal)
43 option.help == "Help missing for old configure options"
44 and option in __sandbox__._raw_options
47 ensure_unicode(__sandbox__._raw_options[option], system_encoding)
50 # We shouldn't need this, but currently, quote will return a byte string
51 # if result is empty, and that's not wanted here.
58 set_config("MOZ_CONFIGURE_OPTIONS", all_configure_options)
62 def fold_libs(target):
63 return target.os in ("WINNT", "OSX", "Android")
66 set_config("MOZ_FOLD_LIBS", fold_libs)
69 # ==============================================================
70 # Some of the options here imply an option from js/moz.configure,
71 # so, need to be declared before the include.
76 help="Enable jprof profiling tool (needs mozilla/tools/jprof)",
80 @depends("--enable-jprof")
86 set_config("MOZ_JPROF", jprof)
87 set_define("MOZ_JPROF", jprof)
88 imply_option("--enable-profiling", jprof)
92 def gecko_profiler(target):
93 if target.os == "Android":
94 return target.cpu in ("aarch64", "arm", "x86", "x86_64")
95 elif target.kernel == "Linux":
96 return target.cpu in ("aarch64", "arm", "x86", "x86_64", "mips64")
97 elif target.kernel == "FreeBSD":
98 return target.cpu in ("aarch64", "x86_64")
99 return target.os in ("OSX", "WINNT")
102 @depends(gecko_profiler)
103 def gecko_profiler_define(value):
108 set_config("MOZ_GECKO_PROFILER", gecko_profiler_define)
109 set_define("MOZ_GECKO_PROFILER", gecko_profiler_define)
112 # Whether code to parse ELF binaries should be compiled for the Gecko profiler
113 # (for symbol table dumping).
114 @depends(gecko_profiler, target)
115 def gecko_profiler_parse_elf(value, target):
116 # Currently we only want to build this code on Linux (including Android) and BSD.
117 # For Android, this is in order to dump symbols from Android system, where
118 # on other platforms there exist alternatives that don't require bloating
119 # up our binary size. For Linux more generally, we use this in profile
120 # pre-symbolication support, since MozDescribeCodeAddress doesn't do
121 # anything useful on that platform. (Ideally, we would update
122 # MozDescribeCodeAddress to call into some Rust crates that parse ELF and
123 # DWARF data, but build system issues currently prevent Rust from being
125 if value and (target.kernel == "Linux" or target.kernel == "FreeBSD"):
129 set_config("MOZ_GECKO_PROFILER_PARSE_ELF", gecko_profiler_parse_elf)
130 set_define("MOZ_GECKO_PROFILER_PARSE_ELF", gecko_profiler_parse_elf)
132 # enable this by default if the profiler is enabled
133 # Note: also requires jemalloc
134 set_config("MOZ_PROFILER_MEMORY", gecko_profiler_define)
135 set_define("MOZ_PROFILER_MEMORY", gecko_profiler_define)
142 # Artifact builds are included because the downloaded artifacts can
144 when=artifact_builds | depends(when="--enable-replace-malloc")(lambda: True),
146 def dmd_default(debug, milestone, build_project):
147 return bool(build_project == "browser" and (debug or milestone.is_nightly))
154 help="{Enable|Disable} Dark Matter Detector (heap profiler). "
155 "Also enables jemalloc, replace-malloc and profiling",
159 @depends("--enable-dmd")
165 set_config("MOZ_DMD", dmd)
166 set_define("MOZ_DMD", dmd)
167 add_old_configure_assignment("MOZ_DMD", dmd)
168 imply_option("--enable-profiling", dmd)
169 imply_option("--enable-jemalloc", dmd, when=compile_environment)
170 imply_option("--enable-replace-malloc", dmd, when=compile_environment)
173 # ==============================================================
174 system_lib_option("--enable-alsa", env="MOZ_ALSA", help="Enable ALSA audio backend.")
176 alsa = pkg_check_modules("MOZ_ALSA", "alsa", when="--enable-alsa")
178 set_config("MOZ_ALSA", depends_if(alsa)(lambda _: True))
179 set_define("MOZ_ALSA", depends_if(alsa)(lambda _: True))
182 # ==============================================================
183 system_lib_option("--enable-jack", env="MOZ_JACK", help="Enable JACK audio backend.")
185 jack = pkg_check_modules("MOZ_JACK", "jack", when="--enable-jack")
187 set_config("MOZ_JACK", depends_if(jack)(lambda _: True))
188 set_define("MOZ_JACK", depends_if(jack)(lambda _: True))
190 # PulseAudio cubeb backend
191 # ==============================================================
193 def pulseaudio_default(target):
194 return target.os not in ("WINNT", "OSX", "Android", "OpenBSD")
198 "--enable-pulseaudio",
199 env="MOZ_PULSEAUDIO",
200 default=pulseaudio_default,
201 help="{Enable|Disable} PulseAudio audio backend.",
204 pulseaudio = pkg_check_modules("MOZ_PULSEAUDIO", "libpulse", when="--enable-pulseaudio")
206 set_config("MOZ_PULSEAUDIO", depends_if(pulseaudio)(lambda _: True))
207 set_define("MOZ_PULSEAUDIO", depends_if(pulseaudio)(lambda _: True))
209 # AudioUnit cubeb Rust backend
210 # ==============================================================
212 def enable_audiounit_rust(target):
213 return target.os == "OSX" and target.kernel == "Darwin"
216 set_config("MOZ_AUDIOUNIT_RUST", True, when=enable_audiounit_rust)
217 set_define("MOZ_AUDIOUNIT_RUST", True, when=enable_audiounit_rust)
220 # ==============================================================
221 include("../js/moz.configure")
225 # ==============================================================
226 include("../build/moz.configure/node.configure")
229 # ==============================================================
230 option("--with-l10n-base", nargs=1, env="L10NBASEDIR", help="Path to l10n repositories")
233 @depends("--with-l10n-base", "MOZ_AUTOMATION", check_build_environment)
234 @imports(_from="os.path", _import="isdir")
235 @imports(_from="os.path", _import="expanduser")
236 @imports(_from="os", _import="environ")
237 def l10n_base(value, automation, build_env):
241 die("Invalid value --with-l10n-base, %s doesn't exist", path)
243 path = os.path.join(build_env.topsrcdir, "../l10n-central")
247 "MOZBUILD_STATE_PATH", expanduser(os.path.join("~", ".mozbuild"))
251 return os.path.realpath(os.path.abspath(path))
254 set_config("L10NBASEDIR", l10n_base)
258 # ==============================================================
260 def toolkit_choices(target):
261 if target.os == "WINNT":
262 return ("cairo-windows",)
263 elif target.os == "OSX":
264 return ("cairo-cocoa",)
265 elif target.os == "Android":
266 return ("cairo-android",)
268 return ("cairo-gtk3", "cairo-gtk3-wayland")
271 @depends(toolkit_choices)
272 def toolkit_default(choices):
277 "--enable-default-toolkit",
279 choices=toolkit_choices,
280 default=toolkit_default,
281 help="Select default toolkit",
285 @depends_if("--enable-default-toolkit")
286 def full_toolkit(value):
290 @depends(full_toolkit)
291 def toolkit(toolkit):
292 if toolkit.startswith("cairo-gtk3"):
293 widget_toolkit = "gtk"
295 widget_toolkit = toolkit.replace("cairo-", "")
296 return widget_toolkit
299 set_config("MOZ_WIDGET_TOOLKIT", toolkit)
300 add_old_configure_assignment("MOZ_WIDGET_TOOLKIT", toolkit)
304 def toolkit_define(toolkit):
305 if toolkit != "windows":
306 return "MOZ_WIDGET_%s" % toolkit.upper()
309 set_define(toolkit_define, True)
313 def toolkit_gtk(toolkit):
314 return toolkit == "gtk"
318 # ==============================================================
319 wayland_headers = pkg_check_modules(
321 "gtk+-wayland-3.0 >= 3.14 xkbcommon >= 0.4.1 libdrm >= 2.4",
322 allow_missing=depends(full_toolkit)(lambda t: t == "cairo-gtk3"),
323 when=depends(full_toolkit)(lambda t: t in ("cairo-gtk3", "cairo-gtk3-wayland")),
327 @depends(wayland_headers, toolkit_gtk, artifact_builds)
328 def wayland_headers(wayland, toolkit_gtk, artifacts):
329 if toolkit_gtk and artifacts:
334 set_config("MOZ_WAYLAND", depends_if(wayland_headers)(lambda _: True))
335 set_define("MOZ_WAYLAND", depends_if(wayland_headers)(lambda _: True))
338 # ==============================================================
339 option("--with-gl-provider", nargs=1, help="Set GL provider backend type")
342 @depends("--with-gl-provider")
343 def gl_provider(value):
348 @depends(gl_provider)
349 def gl_provider_define(provider):
351 return "GLContextProvider%s" % provider
354 set_define("MOZ_GL_PROVIDER", gl_provider_define)
357 @depends(gl_provider, wayland_headers, toolkit_gtk)
358 def gl_default_provider(value, wayland, toolkit_gtk):
367 set_config("MOZ_GL_PROVIDER", gl_provider)
368 set_config("MOZ_GL_DEFAULT_PROVIDER", gl_default_provider)
371 @depends(gl_default_provider)
372 def gl_provider_define(provider):
374 return "GL_PROVIDER_%s" % provider
377 set_define(gl_provider_define, True)
381 # ==============================================================
383 def pdf_printing(toolkit):
384 if toolkit in ("windows", "gtk", "android"):
388 set_config("MOZ_PDF_PRINTING", pdf_printing)
389 set_define("MOZ_PDF_PRINTING", pdf_printing)
392 # Event loop instrumentation
393 # ==============================================================
394 option(env="MOZ_INSTRUMENT_EVENT_LOOP", help="Force-enable event loop instrumentation")
397 @depends("MOZ_INSTRUMENT_EVENT_LOOP", toolkit)
398 def instrument_event_loop(value, toolkit):
400 toolkit in ("windows", "gtk", "cocoa", "android") and value.origin == "default"
405 set_config("MOZ_INSTRUMENT_EVENT_LOOP", instrument_event_loop)
406 set_define("MOZ_INSTRUMENT_EVENT_LOOP", instrument_event_loop)
409 # Fontconfig Freetype
410 # ==============================================================
411 option(env="USE_FC_FREETYPE", help="Force-enable the use of fontconfig freetype")
414 @depends("USE_FC_FREETYPE", toolkit)
415 def fc_freetype(value, toolkit):
416 if value or (toolkit == "gtk" and value.origin == "default"):
420 add_old_configure_assignment("USE_FC_FREETYPE", fc_freetype)
421 set_define("USE_FC_FREETYPE", fc_freetype)
424 # ==============================================================
425 pkg_check_modules("MOZ_PANGO", "pango >= 1.22.0", when=toolkit_gtk)
428 # ==============================================================
429 fontconfig_info = pkg_check_modules(
430 "_FONTCONFIG", "fontconfig >= 2.7.0", when=fc_freetype
434 @depends(fc_freetype)
435 def check_for_freetype2(fc_freetype):
440 # Check for freetype2. Flags are combined with fontconfig flags.
441 freetype2_info = pkg_check_modules(
442 "_FT2", "freetype2 >= 6.1.0", when=check_for_freetype2
446 @depends(fontconfig_info, freetype2_info)
447 def freetype2_combined_info(fontconfig_info, freetype2_info):
448 if not freetype2_info:
450 if not fontconfig_info:
451 return freetype2_info
453 cflags=freetype2_info.cflags + fontconfig_info.cflags,
454 libs=freetype2_info.libs + fontconfig_info.libs,
458 add_old_configure_assignment(
459 "_HAVE_FREETYPE2", depends_if(freetype2_info)(lambda _: True)
461 set_define("MOZ_HAVE_FREETYPE2", depends_if(freetype2_info)(lambda _: True))
463 # Apple platform decoder support
464 # ==============================================================
466 def applemedia(toolkit):
467 if toolkit in ("cocoa", "uikit"):
471 set_config("MOZ_APPLEMEDIA", applemedia)
472 set_define("MOZ_APPLEMEDIA", applemedia)
473 add_old_configure_assignment("MOZ_APPLEMEDIA", applemedia)
475 # Windows Media Foundation support
476 # ==============================================================
477 option("--disable-wmf", help="Disable support for Windows Media Foundation")
480 @depends("--disable-wmf", target)
481 def wmf(value, target):
482 enabled = bool(value)
483 if value.origin == "default":
484 # Enable Windows Media Foundation support by default.
485 # Note our minimum SDK version is Windows 7 SDK, so we are (currently)
486 # guaranteed to have a recent-enough SDK to build WMF.
487 enabled = target.os == "WINNT"
488 if enabled and target.os != "WINNT":
489 die("Cannot enable Windows Media Foundation support on %s", target.os)
494 set_config("MOZ_WMF", wmf)
495 set_define("MOZ_WMF", wmf)
497 # FFmpeg H264/AAC Decoding Support
498 # ==============================================================
499 option("--disable-ffmpeg", help="Disable FFmpeg for fragmented H264/AAC decoding")
502 @depends("--disable-ffmpeg", target)
503 def ffmpeg(value, target):
504 enabled = bool(value)
505 if value.origin == "default":
506 enabled = target.os not in ("Android", "WINNT")
511 set_config("MOZ_FFMPEG", ffmpeg)
512 set_define("MOZ_FFMPEG", ffmpeg)
513 imply_option("--enable-fmp4", ffmpeg, "--enable-ffmpeg")
515 # AV1 Video Codec Support
516 # ==============================================================
517 option("--disable-av1", help="Disable av1 video support")
520 @depends("--enable-av1")
526 @depends(target, when=av1 & compile_environment)
527 def dav1d_asm(target):
528 if target.cpu in ("aarch64", "x86", "x86_64"):
532 @depends(target, when=av1 & compile_environment)
533 def dav1d_nasm(target):
534 if target.cpu in ("x86", "x86_64"):
535 return namespace(version="2.14", what="AV1")
538 set_config("MOZ_DAV1D_ASM", dav1d_asm)
539 set_define("MOZ_DAV1D_ASM", dav1d_asm)
540 set_config("MOZ_AV1", av1)
541 set_define("MOZ_AV1", av1)
543 # JXL Image Codec Support
544 # ==============================================================
545 option("--disable-jxl", help="Disable jxl image support")
548 @depends("--disable-jxl", milestone.is_nightly)
549 def jxl(value, is_nightly):
550 if is_nightly and value:
554 set_config("MOZ_JXL", jxl)
555 set_define("MOZ_JXL", jxl)
557 # Built-in fragmented MP4 support.
558 # ==============================================================
562 help="Disable support for in built Fragmented MP4 parsing",
566 @depends("--disable-fmp4", target, wmf, applemedia)
567 def fmp4(value, target, wmf, applemedia):
568 enabled = bool(value)
569 if value.origin == "default":
570 # target.os == 'Android' includes all B2G versions
571 enabled = wmf or applemedia or target.os == "Android"
576 set_config("MOZ_FMP4", fmp4)
577 set_define("MOZ_FMP4", fmp4)
578 add_old_configure_assignment("MOZ_FMP4", fmp4)
582 def sample_type_is_s16(target):
583 # Use integers over floats for audio on Android regardless of the CPU
584 # architecture, because audio backends for Android don't support floats.
585 # We also use integers on ARM because it's more efficient.
586 if target.os == "Android" or target.cpu == "arm":
590 @depends(sample_type_is_s16)
591 def sample_type_is_float(t):
596 set_config("MOZ_SAMPLE_TYPE_S16", sample_type_is_s16)
597 set_define("MOZ_SAMPLE_TYPE_S16", sample_type_is_s16)
598 set_config("MOZ_SAMPLE_TYPE_FLOAT32", sample_type_is_float)
599 set_define("MOZ_SAMPLE_TYPE_FLOAT32", sample_type_is_float)
601 set_define("MOZ_VORBIS", sample_type_is_float)
602 set_config("MOZ_VORBIS", sample_type_is_float)
603 set_define("MOZ_TREMOR", sample_type_is_s16)
604 set_config("MOZ_TREMOR", sample_type_is_s16)
606 # OpenMAX IL Decoding Support
607 # ==============================================================
608 option("--enable-openmax", help="Enable OpenMAX IL for video/audio decoding")
611 @depends("--enable-openmax")
613 enabled = bool(value)
618 set_config("MOZ_OMX", openmax)
619 set_define("MOZ_OMX", openmax)
622 # ==============================================================
624 def eme_choices(target):
626 target.kernel in ("WINNT", "Linux")
627 and target.os != "Android"
628 and target.cpu in ("x86", "x86_64")
631 if target.kernel == "WINNT" and target.cpu == "aarch64":
633 if target.os in ("OSX"):
637 # Widevine is enabled by default in desktop browser builds, except
638 # on aarch64 Windows.
639 @depends(build_project, eme_choices, target)
640 def eme_default(build_project, choices, target):
641 if build_project == "browser":
642 if target.kernel != "WINNT" or target.cpu != "aarch64":
652 help="{Enable|Disable} support for Encrypted Media Extensions",
656 @depends("--enable-eme", fmp4, when=eme_choices)
657 def eme(enabled, fmp4):
658 if enabled and enabled.origin != "default" and not fmp4:
659 die("Encrypted Media Extension support requires " "Fragmented MP4 support")
662 @depends("--enable-eme", when=eme_choices)
663 def eme_modules(value):
667 # Fallback to an empty list when eme_choices is empty, setting eme_modules to
669 set_config("MOZ_EME_MODULES", eme_modules | dependable([]))
672 @depends(eme_modules, target, when=eme_modules)
673 def eme_win32_artifact(modules, target):
674 if "widevine" in modules and target.kernel == "WINNT" and target.cpu == "aarch64":
678 set_config("MOZ_EME_WIN32_ARTIFACT", eme_win32_artifact)
681 name="--enable-chrome-format",
682 help="Select FORMAT of chrome files during packaging.",
684 choices=("omni", "jar", "flat"),
689 @depends("--enable-chrome-format")
690 def packager_format(value):
694 set_config("MOZ_PACKAGER_FORMAT", packager_format)
697 @depends(host, build_project)
698 def jar_maker_format(host, build_project):
699 # Multilocales for mobile/android use the same mergedirs for all locales,
700 # so we can't use symlinks for those builds.
701 if host.os == "WINNT" or build_project == "mobile/android":
706 set_config("MOZ_JAR_MAKER_FILE_FORMAT", jar_maker_format)
710 def omnijar_name(toolkit):
711 # Fennec's static resources live in the assets/ folder of the
712 # APK. Adding a path to the name here works because we only
713 # have one omnijar file in the final package (which is not the
715 return "assets/omni.ja" if toolkit == "android" else "omni.ja"
718 set_config("OMNIJAR_NAME", omnijar_name)
720 project_flag("MOZ_PLACES", help="Build Places if required", set_as_define=True)
723 "MOZ_SERVICES_HEALTHREPORT",
724 help="Build Firefox Health Reporter Service",
725 set_for_old_configure=True,
731 help="Enable Normandy recipe runner",
732 set_for_old_configure=True,
736 project_flag("MOZ_SERVICES_SYNC", help="Build Sync Services if required")
739 "MOZ_ANDROID_HISTORY",
740 help="Enable Android History instead of Places",
745 "MOZ_DEDICATED_PROFILES",
746 help="Enable dedicated profiles per install",
751 "MOZ_BLOCK_PROFILE_DOWNGRADE",
752 help="Block users from starting profiles last used by a newer build",
757 @depends("MOZ_PLACES", "MOZ_ANDROID_HISTORY")
758 def check_places_and_android_history(places, android_history):
759 if places and android_history:
760 die("Cannot use MOZ_ANDROID_HISTORY alongside MOZ_PLACES.")
764 env="MOZ_TELEMETRY_REPORTING",
765 default=mozilla_official,
766 help="Enable telemetry reporting",
769 set_define("MOZ_TELEMETRY_REPORTING", True, when="MOZ_TELEMETRY_REPORTING")
770 add_old_configure_assignment(
771 "MOZ_TELEMETRY_REPORTING", True, when="MOZ_TELEMETRY_REPORTING"
775 @depends("MOZ_TELEMETRY_REPORTING", milestone.is_nightly)
776 def telemetry_on_by_default(reporting, is_nightly):
777 return reporting and is_nightly
780 set_define("MOZ_TELEMETRY_ON_BY_DEFAULT", True, when=telemetry_on_by_default)
784 # ==============================================================
785 option("--enable-gpsd", env="MOZ_GPSD", help="Enable gpsd support")
788 @depends("--enable-gpsd")
793 system_gpsd = pkg_check_modules("MOZ_GPSD", "libgps >= 3.11", when=gpsd)
795 set_config("MOZ_GPSD", depends_if(system_gpsd)(lambda _: True))
797 # Miscellaneous programs
798 # ==============================================================
800 check_prog("TAR", ("gnutar", "gtar", "tar"))
801 check_prog("UNZIP", ("unzip",))
802 check_prog("ZIP", ("zip",))
803 check_prog("GN", ("gn",), allow_missing=True)
806 # ==============================================================
807 include("../build/moz.configure/keyfiles.configure")
809 simple_keyfile("Mozilla API")
811 simple_keyfile("Google Location Service API")
813 simple_keyfile("Google Safebrowsing API")
815 id_and_secret_keyfile("Bing API")
817 simple_keyfile("Adjust SDK")
819 id_and_secret_keyfile("Leanplum SDK")
821 simple_keyfile("Pocket API")
824 # WebRender Debugger integration
825 # ==============================================================
828 "--enable-webrender-debugger", help="Build the websocket debug server in WebRender"
832 "MOZ_WEBRENDER_DEBUGGER", depends_if("--enable-webrender-debugger")(lambda _: True)
835 # Additional system headers defined at the application level
836 # ==============================================================
839 "--enable-app-system-headers",
840 env="MOZ_APP_SYSTEM_HEADERS",
841 help="Use additional system headers defined in $MOZ_BUILD_APP/app-system-headers.mozbuild",
845 @depends("--enable-app-system-headers")
846 def app_system_headers(value):
851 set_config("MOZ_APP_SYSTEM_HEADERS", app_system_headers)
852 set_define("MOZ_APP_SYSTEM_HEADERS", app_system_headers)
855 # ==============================================================
856 option("--disable-printing", help="Disable printing support")
859 @depends("--disable-printing")
865 set_config("NS_PRINTING", printing)
866 set_define("NS_PRINTING", printing)
867 set_define("NS_PRINT_PREVIEW", printing)
869 # Speech-dispatcher support
870 # ==============================================================
872 def no_speechd_on_non_gtk(toolkit):
878 "--enable-synth-speechd", no_speechd_on_non_gtk, reason="--enable-default-toolkit"
881 option("--disable-synth-speechd", help="Disable speech-dispatcher support")
883 set_config("MOZ_SYNTH_SPEECHD", depends_if("--disable-synth-speechd")(lambda _: True))
886 # ==============================================================
887 option("--disable-webspeech", help="Disable support for HTML Speech API")
890 @depends("--disable-webspeech")
891 def webspeech(value):
896 set_config("MOZ_WEBSPEECH", webspeech)
897 set_define("MOZ_WEBSPEECH", webspeech)
898 add_old_configure_assignment("MOZ_WEBSPEECH", webspeech)
900 # Speech API test backend
901 # ==============================================================
903 "--enable-webspeechtestbackend",
905 help="{Enable|Disable} support for HTML Speech API Test Backend",
909 @depends_if("--enable-webspeechtestbackend")
910 def webspeech_test_backend(value):
914 set_config("MOZ_WEBSPEECH_TEST_BACKEND", webspeech_test_backend)
915 set_define("MOZ_WEBSPEECH_TEST_BACKEND", webspeech_test_backend)
917 # Enable IPDL's "expensive" unit tests
918 # ==============================================================
919 option("--enable-ipdl-tests", help="Enable expensive IPDL tests")
921 set_config("MOZ_IPDL_TESTS", depends_if("--enable-ipdl-tests")(lambda _: True))
924 # ==============================================================
925 @depends(target, milestone)
926 def skia_pdf_default(target, milestone):
927 return milestone.is_nightly and target.os != "WINNT"
930 option("--enable-skia-pdf", default=skia_pdf_default, help="{Enable|Disable} Skia PDF")
932 set_config("MOZ_ENABLE_SKIA_PDF", True, when="--enable-skia-pdf")
933 set_define("MOZ_ENABLE_SKIA_PDF", True, when="--enable-skia-pdf")
944 "--with-system-webp", help="Use system libwebp (located with pkgconfig)"
947 system_webp = pkg_check_modules(
948 "MOZ_WEBP", "libwebp >= 1.0.2 libwebpdemux >= 1.0.2", when="--with-system-webp"
951 set_config("MOZ_SYSTEM_WEBP", depends(when=system_webp)(lambda: True))
953 # Build Freetype in the tree
954 # ==============================================================
955 @depends(target, "--enable-skia-pdf")
956 def tree_freetype(target, skia_pdf):
957 if target.os == "Android" or (skia_pdf and target.os == "WINNT"):
961 set_define("MOZ_TREE_FREETYPE", tree_freetype)
962 set_config("MOZ_TREE_FREETYPE", tree_freetype)
963 add_old_configure_assignment("MOZ_TREE_FREETYPE", tree_freetype)
965 set_define("HAVE_FT_BITMAP_SIZE_Y_PPEM", tree_freetype)
966 set_define("HAVE_FT_GLYPHSLOT_EMBOLDEN", tree_freetype)
967 set_define("HAVE_FT_LOAD_SFNT_TABLE", tree_freetype)
970 @depends(freetype2_combined_info, tree_freetype, check_build_environment)
971 def ft2_info(freetype2_combined_info, tree_freetype, build_env):
974 cflags=("-I%s/modules/freetype2/include" % build_env.topsrcdir,), libs=()
976 if freetype2_combined_info:
977 return freetype2_combined_info
980 set_config("FT2_LIBS", ft2_info.libs)
981 add_old_configure_assignment("FT2_LIBS", ft2_info.libs)
982 add_old_configure_assignment("FT2_CFLAGS", ft2_info.cflags)
984 # WebDriver (HTTP / BiDi)
985 # ==============================================================
987 # WebDriver is a remote control interface that enables introspection and
988 # control of user agents. It provides a platform- and language-neutral wire
989 # protocol as a way for out-of-process programs to remotely instruct the
990 # behavior of web browsers.
992 # The Gecko implementation is backed by Marionette and Remote Agent.
993 # Both protocols are not really toolkit features, as much as Gecko engine
994 # features. But they are enabled based on the toolkit, so here it lives.
996 # Marionette remote protocol
997 # -----------------------------------------------------------
999 # Marionette is the Gecko remote protocol used for various remote control,
1000 # automation, and testing purposes throughout Gecko-based applications like
1001 # Firefox, Thunderbird, and any mobile browser built upon GeckoView.
1003 # It also backs ../testing/geckodriver, which is Mozilla's WebDriver
1006 # The source of Marionette lives in ../remote/marionette.
1008 # For more information, see:
1009 # https://firefox-source-docs.mozilla.org/testing/marionette/index.html
1011 # Remote Agent (WebDriver BiDi / partial CDP)
1012 # -----------------------------------------------------------
1014 # The primary purpose is the implementation of the WebDriver BiDi specification.
1015 # But it also complements the existing Firefox Developer Tools Remote Debugging
1016 # Protocol (RDP) by implementing a subset of the Chrome DevTools Protocol (CDP).
1018 # The source of Remote Agent lives in ../remote.
1020 # For more information, see:
1021 # https://firefox-source-docs.mozilla.org/remote/index.html
1025 "--disable-webdriver",
1026 help="Disable support for WebDriver remote protocols",
1030 @depends("--disable-webdriver")
1031 def webdriver(enabled):
1036 set_config("ENABLE_WEBDRIVER", webdriver)
1037 set_define("ENABLE_WEBDRIVER", webdriver)
1040 # geckodriver WebDriver implementation
1041 # ==============================================================
1043 # Turn off geckodriver for build configs we don't handle yet,
1044 # but allow --enable-geckodriver to override when compile environment is available.
1045 # --disable-tests implies disabling geckodriver.
1046 # Disable building in CI
1050 "--enable-tests", target, cross_compiling, hazard_analysis, asan, "MOZ_AUTOMATION"
1052 def geckodriver_default(enable_tests, target, cross_compile, hazard, asan, automation):
1053 if not enable_tests:
1055 if hazard or target.os == "Android" or (asan and cross_compile):
1063 "--enable-geckodriver",
1064 default=geckodriver_default,
1065 when="--enable-compile-environment",
1066 help="{Build|Do not build} geckodriver",
1070 @depends("--enable-geckodriver", when="--enable-compile-environment")
1071 def geckodriver(enabled):
1076 set_config("MOZ_GECKODRIVER", geckodriver)
1080 # ========================================================
1082 def webrtc_default(target):
1083 # Turn off webrtc for OS's we don't handle yet, but allow
1084 # --enable-webrtc to override.
1086 for os_fragment in (
1097 if target.raw_os.startswith(os_fragment):
1112 or target.cpu.startswith("ppc")
1116 if os_match and cpu_match:
1123 default=webrtc_default,
1124 help="{Enable|Disable} support for WebRTC",
1128 @depends("--disable-webrtc")
1129 def webrtc(enabled):
1134 set_config("MOZ_WEBRTC", webrtc)
1135 set_define("MOZ_WEBRTC", webrtc)
1136 set_config("MOZ_SCTP", webrtc)
1137 set_define("MOZ_SCTP", webrtc)
1138 set_config("MOZ_SRTP", webrtc)
1139 set_define("MOZ_SRTP", webrtc)
1140 set_config("MOZ_WEBRTC_SIGNALING", webrtc)
1141 set_define("MOZ_WEBRTC_SIGNALING", webrtc)
1142 set_config("MOZ_PEERCONNECTION", webrtc)
1143 set_define("MOZ_PEERCONNECTION", webrtc)
1144 # MOZ_WEBRTC_ASSERT_ALWAYS turns on a number of safety asserts in
1145 # opt/production builds (via MOZ_CRASH())
1146 set_config("MOZ_WEBRTC_ASSERT_ALWAYS", webrtc)
1147 set_define("MOZ_WEBRTC_ASSERT_ALWAYS", webrtc)
1150 # ==============================================================
1153 @depends(target, webrtc)
1154 def raw_media_default(target, webrtc):
1155 if target.os == "Android":
1163 default=raw_media_default,
1164 help="{Enable|Disable} support for RAW media",
1167 set_config("MOZ_RAW", depends_if("--enable-raw")(lambda _: True))
1168 set_define("MOZ_RAW", depends_if("--enable-raw")(lambda _: True))
1172 # ==============================================================
1173 set_config("MOZ_X11", True, when=toolkit_gtk)
1174 set_define("MOZ_X11", True, when=toolkit_gtk)
1177 @depends(webrtc, when=toolkit_gtk)
1178 def x11_libs(webrtc):
1189 # third_party/libwebrtc/webrtc/webrtc_gn/moz.build adds those
1190 # manually, ensure they're available.
1198 return " ".join(libs)
1201 pkg_check_modules("MOZ_X11", x11_libs, when=toolkit_gtk)
1204 # ASan Reporter Addon
1205 # ==============================================================
1207 "--enable-address-sanitizer-reporter",
1208 help="Enable Address Sanitizer Reporter Extension",
1212 @depends("--enable-address-sanitizer-reporter")
1213 def enable_asan_reporter(value):
1218 set_config("MOZ_ASAN_REPORTER", enable_asan_reporter)
1219 set_define("MOZ_ASAN_REPORTER", enable_asan_reporter)
1220 add_old_configure_assignment("MOZ_ASAN_REPORTER", enable_asan_reporter)
1223 # ==============================================================
1224 with only_when("--enable-compile-environment"):
1226 @depends(host, target)
1227 def has_elfhack(host, target):
1229 target.kernel == "Linux"
1230 and host.kernel == "Linux"
1231 and target.cpu in ("arm", "x86", "x86_64")
1234 @depends("--enable-release", enable_linker)
1235 def default_elfhack(release, linker):
1236 # Disable elfhack when explicitly building with --enable-linker=lld
1237 if linker and linker.origin != "default" and linker[0] == "lld":
1239 return bool(release)
1241 with only_when(has_elfhack):
1243 "--disable-elf-hack",
1244 default=default_elfhack,
1245 help="{Enable|Disable} elf hacks",
1248 set_config("USE_ELF_HACK", depends_if("--enable-elf-hack")(lambda _: True))
1251 @depends(check_build_environment)
1252 def idl_roots(build_env):
1254 ipdl_root=os.path.join(build_env.topobjdir, "ipc", "ipdl"),
1255 webidl_root=os.path.join(build_env.topobjdir, "dom", "bindings"),
1256 xpcom_root=os.path.join(build_env.topobjdir, "xpcom", "components"),
1260 set_config("WEBIDL_ROOT", idl_roots.webidl_root)
1261 set_config("IPDL_ROOT", idl_roots.ipdl_root)
1262 set_config("XPCOM_ROOT", idl_roots.xpcom_root)
1264 # Proxy bypass protection
1265 # ==============================================================
1268 "--enable-proxy-bypass-protection",
1269 help="Prevent suspected or confirmed proxy bypasses",
1273 @depends_if("--enable-proxy-bypass-protection")
1274 def proxy_bypass_protection(_):
1278 set_config("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1279 set_define("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1281 # Proxy direct failover
1282 # ==============================================================
1285 "--disable-proxy-direct-failover",
1286 help="Disable direct failover for system requests",
1290 @depends_if("--disable-proxy-direct-failover")
1291 def proxy_direct_failover(value):
1296 set_config("MOZ_PROXY_DIRECT_FAILOVER", proxy_direct_failover)
1297 set_define("MOZ_PROXY_DIRECT_FAILOVER", proxy_direct_failover)
1300 # ==============================================================
1303 @depends(c_compiler, toolchain_prefix)
1304 def midl_names(c_compiler, toolchain_prefix):
1305 if c_compiler and c_compiler.type in ["gcc", "clang"]:
1308 if toolchain_prefix:
1309 prefixed = tuple("%s%s" % (p, "widl") for p in toolchain_prefix)
1310 widl = prefixed + widl
1313 return ("midl.exe",)
1316 @depends(target, "--enable-compile-environment")
1317 def check_for_midl(target, compile_environment):
1318 if target.os != "WINNT":
1321 if compile_environment:
1326 "MIDL", midl_names, when=check_for_midl, allow_missing=True, paths=sdk_bin_path
1329 option(env="MIDL_FLAGS", nargs=1, help="Extra flags to pass to MIDL")
1338 when=depends(midl, target)(lambda m, t: m and t.kernel == "WINNT"),
1340 def midl_flags(flags, c_compiler, target, host, midl):
1342 flags = flags[0].split()
1346 if not midl.endswith("widl"):
1352 flags += ["-env", env]
1354 if host.os == "WINNT":
1355 return flags + ["-cpp_cmd", c_compiler.compiler]
1357 # If cross-compiling and using midl instead of widl, for now, we'll
1358 # assume we can find the Windows version of clang-cl in the PATH.
1359 # It is required because while Wine is able to spawn Linux
1360 # processes from Windows programs(!), the calling program doesn't
1361 # have access to the process output and can't wait for it to
1362 # finish. Midl runs clang-cl as a preprocessor and expects to read
1364 clang_cl_exe = find_program("clang-cl.exe")
1365 if not clang_cl_exe:
1366 die("Cannot find clang-cl.exe")
1367 return flags + ["-cpp_cmd", clang_cl_exe]
1371 "x86": ["--win32", "-m32"],
1372 "x86_64": ["--win64", "-m64"],
1376 set_config("MIDL_FLAGS", midl_flags)
1379 # ==============================================================
1381 option("--disable-accessibility", help="Disable accessibility support")
1384 @depends("--enable-accessibility", check_for_midl, midl, c_compiler)
1385 def accessibility(value, check_for_midl, midl, c_compiler):
1386 enabled = bool(value)
1391 if check_for_midl and not midl:
1392 if c_compiler and c_compiler.type in ("gcc", "clang"):
1394 "You have accessibility enabled, but widl could not be found. "
1395 "Add --disable-accessibility to your mozconfig or install widl. "
1396 "See https://developer.mozilla.org/en-US/docs/Cross_Compile_Mozilla_for_Mingw32 for details."
1400 "MIDL could not be found. "
1401 "Building accessibility without MIDL is not supported."
1407 set_config("ACCESSIBILITY", accessibility)
1408 set_define("ACCESSIBILITY", accessibility)
1409 add_old_configure_assignment("ACCESSIBILITY", accessibility)
1413 # ==============================================================
1415 def require_signing(milestone):
1416 return milestone.is_release_or_beta and not milestone.is_esr
1420 env="MOZ_REQUIRE_SIGNING",
1421 default=require_signing,
1422 help="Enforce that add-ons are signed by the trusted root",
1425 set_config("MOZ_REQUIRE_SIGNING", True, when="MOZ_REQUIRE_SIGNING")
1426 set_define("MOZ_REQUIRE_SIGNING", True, when="MOZ_REQUIRE_SIGNING")
1429 "--with-unsigned-addon-scopes",
1431 choices=("app", "system"),
1432 help="Addon scopes where signature is not required",
1436 @depends("--with-unsigned-addon-scopes")
1437 def unsigned_addon_scopes(scopes):
1439 app="app" in scopes or None,
1440 system="system" in scopes or None,
1444 set_config("MOZ_UNSIGNED_APP_SCOPE", unsigned_addon_scopes.app)
1445 set_config("MOZ_UNSIGNED_SYSTEM_SCOPE", unsigned_addon_scopes.system)
1449 # ==============================================================
1451 "--allow-addon-sideload",
1452 default=milestone.is_esr,
1453 help="Addon sideloading is allowed",
1457 set_config("MOZ_ALLOW_ADDON_SIDELOAD", True, when="--allow-addon-sideload")
1459 # WebExtensions API WebIDL bindings
1460 # ==============================================================
1464 def extensions_webidl_bindings_default(milestone):
1465 # Only enable the webidl bindings for the WebExtensions APIs
1467 return milestone.is_nightly
1471 "--enable-extensions-webidl-bindings",
1472 default=extensions_webidl_bindings_default,
1473 help="{Enable|Disable} building experimental WebExtensions WebIDL bindings",
1477 @depends("--enable-extensions-webidl-bindings")
1478 def extensions_webidl_enabled(value):
1482 set_config("MOZ_WEBEXT_WEBIDL_ENABLED", extensions_webidl_enabled)
1484 # Launcher process (Windows only)
1485 # ==============================================================
1489 def launcher_process_default(target):
1490 return target.os == "WINNT"
1494 "--enable-launcher-process",
1495 default=launcher_process_default,
1496 help="{Enable|Disable} launcher process by default",
1500 @depends("--enable-launcher-process", target)
1501 def launcher(value, target):
1502 enabled = bool(value)
1503 if enabled and target.os != "WINNT":
1504 die("Cannot enable launcher process on %s", target.os)
1509 set_config("MOZ_LAUNCHER_PROCESS", launcher)
1510 set_define("MOZ_LAUNCHER_PROCESS", launcher)
1512 # llvm-dlltool (Windows only)
1513 # ==============================================================
1516 @depends(build_project, target, "--enable-compile-environment")
1517 def check_for_llvm_dlltool(build_project, target, compile_environment):
1518 if build_project != "browser":
1521 if target.os != "WINNT":
1524 return compile_environment
1527 llvm_dlltool = check_prog(
1530 what="llvm-dlltool",
1531 when=check_for_llvm_dlltool,
1532 paths=clang_search_path,
1536 @depends(target, when=llvm_dlltool)
1537 def llvm_dlltool_flags(target):
1540 "x86_64": "i386:x86-64",
1547 set_config("LLVM_DLLTOOL_FLAGS", llvm_dlltool_flags)
1549 # BITS download (Windows only)
1550 # ==============================================================
1553 "--enable-bits-download",
1554 when=target_is_windows,
1555 default=target_is_windows,
1556 help="{Enable|Disable} building BITS download support",
1560 "MOZ_BITS_DOWNLOAD",
1561 depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
1564 "MOZ_BITS_DOWNLOAD",
1565 depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
1568 # Bundled fonts on desktop platform
1569 # ==============================================================
1573 def bundled_fonts_default(target):
1574 return target.os == "WINNT" or target.kernel == "Linux"
1577 @depends(build_project)
1578 def allow_bundled_fonts(project):
1579 return project == "browser" or project == "comm/mail"
1583 "--enable-bundled-fonts",
1584 default=bundled_fonts_default,
1585 when=allow_bundled_fonts,
1586 help="{Enable|Disable} support for bundled fonts on desktop platforms",
1590 "MOZ_BUNDLED_FONTS",
1591 depends_if("--enable-bundled-fonts", when=allow_bundled_fonts)(lambda _: True),
1595 # ==============================================================
1599 def reflow_perf(debug):
1605 "--enable-reflow-perf",
1606 default=reflow_perf,
1607 help="{Enable|Disable} reflow performance tracing",
1610 # The difference in conditions here comes from the initial implementation
1611 # in old-configure, which was unexplained there as well.
1612 set_define("MOZ_REFLOW_PERF", depends_if("--enable-reflow-perf")(lambda _: True))
1613 set_define("MOZ_REFLOW_PERF_DSP", reflow_perf)
1616 # ==============================================================
1620 def layout_debugger(debug):
1626 "--enable-layout-debugger",
1627 default=layout_debugger,
1628 help="{Enable|Disable} layout debugger",
1631 set_config("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
1632 set_define("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
1635 # Shader Compiler for Windows (and MinGW Cross Compile)
1636 # ==============================================================
1638 with only_when(compile_environment):
1641 ("fxc.exe", "fxc2.exe"),
1642 when=depends(target)(lambda t: t.kernel == "WINNT"),
1650 with only_when(compile_environment):
1652 "--with-system-libvpx", help="Use system libvpx (located with pkgconfig)"
1655 with only_when("--with-system-libvpx"):
1656 vpx = pkg_check_modules("MOZ_LIBVPX", "vpx >= 1.8.0")
1659 "vpx/vpx_decoder.h",
1661 onerror=lambda: die(
1662 "Couldn't find vpx/vpx_decoder.h, which is required to build "
1663 "with system libvpx. Use --without-system-libvpx to build "
1664 "with in-tree libvpx."
1669 "vpx_codec_dec_init_ver",
1671 onerror=lambda: die(
1672 "--with-system-libvpx requested but symbol vpx_codec_dec_init_ver "
1677 set_config("MOZ_SYSTEM_LIBVPX", True)
1679 @depends("--with-system-libvpx", target)
1680 def in_tree_vpx(system_libvpx, target):
1684 arm_asm = (target.cpu == "arm") or None
1685 return namespace(arm_asm=arm_asm)
1687 @depends(target, when=in_tree_vpx)
1688 def vpx_nasm(target):
1689 if target.cpu in ("x86", "x86_64"):
1690 if target.kernel == "WINNT":
1691 # Version 2.03 is needed for automatic safeseh support.
1692 return namespace(version="2.03", what="VPX")
1693 return namespace(what="VPX")
1695 # Building with -mfpu=neon requires either the "softfp" or the
1696 # "hardfp" ABI. Depending on the compiler's default target, and the
1697 # CFLAGS, the default ABI might be neither, in which case it is the
1699 # The "softfloat" ABI is binary-compatible with the "softfp" ABI, so
1700 # we can safely mix code built with both ABIs. So, if we detect
1701 # that compiling uses the "softfloat" ABI, force the use of the
1702 # "softfp" ABI instead.
1703 # Confusingly, the __SOFTFP__ preprocessor variable indicates the
1704 # "softfloat" ABI, not the "softfp" ABI.
1705 # Note: VPX_ASFLAGS is also used in CFLAGS.
1706 softfp = cxx_compiler.try_compile(
1709 #error "compiler target supports -mfpu=neon, so we don't have to add extra flags"
1711 when=in_tree_vpx.arm_asm,
1714 @depends(in_tree_vpx, vpx_nasm, softfp, target)
1715 def vpx_as_flags(vpx, vpx_nasm, softfp, target):
1717 if vpx and vpx.arm_asm:
1718 # These flags are a lie; they're just used to enable the requisite
1719 # opcodes; actual arch detection is done at runtime.
1720 flags = ["-march=armv7-a", "-mfpu=neon"]
1722 flags.append("-mfloat-abi=softfp")
1723 elif vpx and vpx_nasm and target.os != "WINNT" and target.cpu != "x86_64":
1727 set_config("VPX_USE_NASM", True, when=vpx_nasm)
1728 set_config("VPX_ASFLAGS", vpx_as_flags)
1734 with only_when(compile_environment):
1736 "--with-system-jpeg",
1738 help="Use system libjpeg (installed at given prefix)",
1741 @depends_if("--with-system-jpeg")
1742 def jpeg_flags(value):
1745 cflags=("-I%s/include" % value[0],),
1746 ldflags=("-L%s/lib" % value[0], "-ljpeg"),
1749 ldflags=("-ljpeg",),
1752 with only_when("--with-system-jpeg"):
1754 "jpeg_destroy_compress",
1755 flags=jpeg_flags.ldflags,
1756 onerror=lambda: die(
1757 "--with-system-jpeg requested but symbol "
1758 "jpeg_destroy_compress not found."
1762 c_compiler.try_compile(
1769 #if JPEG_LIB_VERSION < 62
1770 #error Insufficient JPEG library version
1773 flags=jpeg_flags.cflags,
1774 check_msg="for sufficient jpeg library version",
1775 onerror=lambda: die(
1776 "Insufficient JPEG library version for "
1777 "--with-system-jpeg (62 required)"
1781 c_compiler.try_compile(
1788 #ifndef JCS_EXTENSIONS
1789 #error libjpeg-turbo JCS_EXTENSIONS required
1792 flags=jpeg_flags.cflags,
1793 check_msg="for sufficient libjpeg-turbo JCS_EXTENSIONS",
1794 onerror=lambda: die(
1795 "libjpeg-turbo JCS_EXTENSIONS required for " "--with-system-jpeg"
1799 set_config("MOZ_JPEG_CFLAGS", jpeg_flags.cflags)
1800 set_config("MOZ_JPEG_LIBS", jpeg_flags.ldflags)
1802 @depends("--with-system-jpeg", target)
1803 def in_tree_jpeg_arm(system_jpeg, target):
1807 if target.cpu == "arm":
1808 return ("-march=armv7-a", "-mfpu=neon")
1809 elif target.cpu == "aarch64":
1810 return ("-march=armv8-a",)
1812 @depends("--with-system-jpeg", target)
1813 def in_tree_jpeg(system_jpeg, target):
1817 if target.cpu == "arm":
1818 return ("-march=armv7-a", "-mfpu=neon")
1819 elif target.cpu == "aarch64":
1820 return ("-march=armv8-a",)
1821 elif target.kernel == "Darwin":
1822 if target.cpu == "x86":
1823 return ("-DPIC", "-DMACHO")
1824 elif target.cpu == "x86_64":
1825 return ("-D__x86_64__", "-DPIC", "-DMACHO")
1826 elif target.kernel == "WINNT":
1827 if target.cpu == "x86":
1828 return ("-DPIC", "-DWIN32")
1829 elif target.cpu == "x86_64":
1830 return ("-D__x86_64__", "-DPIC", "-DWIN64", "-DMSVC")
1831 elif target.cpu == "mips32":
1833 elif target.cpu == "mips64":
1834 return ("-Wa,-mloongson-mmi", "-mloongson-ext")
1835 elif target.cpu == "x86":
1836 return ("-DPIC", "-DELF")
1837 elif target.cpu == "x86_64":
1838 return ("-D__x86_64__", "-DPIC", "-DELF")
1840 @depends(target, when=in_tree_jpeg)
1841 def jpeg_nasm(target):
1842 if target.cpu in ("x86", "x86_64"):
1843 # libjpeg-turbo 2.0.6 requires nasm 2.10.
1844 return namespace(version="2.10", what="JPEG")
1846 jpeg_arm_neon_vld1_s16_x3 = c_compiler.try_compile(
1847 includes=["arm_neon.h"],
1848 body="int16_t input[12] = {}; int16x4x3_t output = vld1_s16_x3(input);",
1849 check_msg="for vld1_s16_x3 in arm_neon.h",
1850 flags=in_tree_jpeg_arm,
1851 when=in_tree_jpeg_arm,
1854 jpeg_arm_neon_vld1_u16_x2 = c_compiler.try_compile(
1855 includes=["arm_neon.h"],
1856 body="uint16_t input[8] = {}; uint16x4x2_t output = vld1_u16_x2(input);",
1857 check_msg="for vld1_u16_x2 in arm_neon.h",
1858 flags=in_tree_jpeg_arm,
1859 when=in_tree_jpeg_arm,
1862 jpeg_arm_neon_vld1q_u8_x4 = c_compiler.try_compile(
1863 includes=["arm_neon.h"],
1864 body="uint8_t input[64] = {}; uint8x16x4_t output = vld1q_u8_x4(input);",
1865 check_msg="for vld1q_u8_x4 in arm_neon.h",
1866 flags=in_tree_jpeg_arm,
1867 when=in_tree_jpeg_arm,
1870 set_config("LIBJPEG_TURBO_USE_NASM", True, when=jpeg_nasm)
1871 set_config("LIBJPEG_TURBO_SIMD_FLAGS", in_tree_jpeg)
1872 set_config("LIBJPEG_TURBO_HAVE_VLD1_S16_X3", jpeg_arm_neon_vld1_s16_x3)
1873 set_config("LIBJPEG_TURBO_HAVE_VLD1_U16_X2", jpeg_arm_neon_vld1_u16_x2)
1874 set_config("LIBJPEG_TURBO_HAVE_VLD1Q_U8_X4", jpeg_arm_neon_vld1q_u8_x4)
1876 "LIBJPEG_TURBO_NEON_INTRINSICS",
1877 jpeg_arm_neon_vld1_s16_x3
1878 & jpeg_arm_neon_vld1_u16_x2
1879 & jpeg_arm_neon_vld1q_u8_x4,
1883 # FFmpeg's ffvpx configuration
1884 # ==============================================================
1885 with only_when(compile_environment):
1888 def libav_fft(target):
1889 return target.kernel == "WINNT" or target.cpu == "x86_64"
1891 set_config("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
1892 set_define("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
1895 # Artifact builds need MOZ_FFVPX defined as if compilation happened.
1896 with only_when(compile_environment | artifact_builds):
1900 enable = use_nasm = True
1904 if target.kernel == "WINNT":
1905 if target.cpu == "x86":
1906 # 32-bit windows need to prefix symbols with an underscore.
1907 flags = ["-DPIC", "-DWIN32", "-DPREFIX", "-Pconfig_win32.asm"]
1908 elif target.cpu == "x86_64":
1914 "-Pconfig_win64.asm",
1916 elif target.cpu == "aarch64":
1917 flags = ["-DPIC", "-DWIN64"]
1919 elif target.kernel == "Darwin":
1920 if target.cpu == "x86_64":
1921 # 32/64-bit macosx asemblers need to prefix symbols with an
1928 "-Pconfig_darwin64.asm",
1932 elif target.cpu == "x86_64":
1933 flags = ["-D__x86_64__", "-DPIC", "-DELF", "-Pconfig_unix64.asm"]
1934 elif target.cpu in ("x86", "arm", "aarch64"):
1939 if flac_only or not enable:
1943 # default disabled components
1944 flags.append("-Pdefaults_disabled.asm")
1949 flac_only=flac_only,
1953 @depends(when=ffvpx.use_nasm)
1955 # nasm 2.10 for AVX-2 support.
1956 return namespace(version="2.10", what="FFVPX")
1958 # ffvpx_nasm can't indirectly depend on vpx_as_flags, because it depends
1959 # on a compiler test, so we have to do a little bit of dance here.
1960 @depends(ffvpx, vpx_as_flags, target)
1961 def ffvpx(ffvpx, vpx_as_flags, target):
1962 if ffvpx and vpx_as_flags and target.cpu in ("arm", "aarch64"):
1963 ffvpx.flags.extend(vpx_as_flags)
1966 set_config("MOZ_FFVPX", True, when=ffvpx.enable)
1967 set_define("MOZ_FFVPX", True, when=ffvpx.enable)
1968 set_config("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.flac_only)
1969 set_define("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.flac_only)
1970 set_config("FFVPX_ASFLAGS", ffvpx.flags)
1971 set_config("FFVPX_USE_NASM", True, when=ffvpx.use_nasm)
1975 # ==============================================================
1976 @depends(dav1d_nasm, vpx_nasm, jpeg_nasm, ffvpx_nasm, when=compile_environment)
1977 def need_nasm(*requirements):
1979 x.what: x.version if hasattr(x, "version") else True for x in requirements if x
1982 items = sorted(requires.keys())
1984 what = " and ".join((", ".join(items[:-1]), items[-1]))
1987 versioned = {k: v for (k, v) in requires.items() if v is not True}
1988 return namespace(what=what, versioned=versioned)
2000 @depends(nasm, need_nasm.what)
2001 def check_nasm(nasm, what):
2002 if not nasm and what:
2003 die("Nasm is required to build with %s, but it was not found." % what)
2007 @depends_if(check_nasm)
2008 @checking("nasm version")
2009 def nasm_version(nasm):
2011 check_cmd_output(nasm, "-v", onerror=lambda: die("Failed to get nasm version."))
2015 return Version(version)
2018 @depends(nasm_version, need_nasm.versioned, when=need_nasm.versioned)
2019 def check_nasm_version(nasm_version, versioned):
2020 by_version = sorted(versioned.items(), key=lambda x: x[1])
2021 what, version = by_version[-1]
2022 if nasm_version < version:
2024 "Nasm version %s or greater is required to build with %s." % (version, what)
2029 @depends(target, when=check_nasm_version)
2030 def nasm_asflags(target):
2032 ("OSX", "x86"): ["-f", "macho32"],
2033 ("OSX", "x86_64"): ["-f", "macho64"],
2034 ("WINNT", "x86"): ["-f", "win32"],
2035 ("WINNT", "x86_64"): ["-f", "win64"],
2036 }.get((target.os, target.cpu), None)
2038 # We're assuming every x86 platform we support that's
2039 # not Windows or Mac is ELF.
2040 if target.cpu == "x86":
2041 asflags = ["-f", "elf32"]
2042 elif target.cpu == "x86_64":
2043 asflags = ["-f", "elf64"]
2047 set_config("NASM_ASFLAGS", nasm_asflags)
2050 # ANGLE OpenGL->D3D translator for WebGL
2051 # ==============================================================
2053 with only_when(compile_environment & target_is_windows):
2055 def d3d_compiler_dll_result(value):
2057 return "provided by the OS"
2060 @depends(target, valid_windows_sdk_dir, fxc)
2061 @checking("for D3D compiler DLL", d3d_compiler_dll_result)
2063 def d3d_compiler_dll(target, windows_sdk_dir, fxc):
2066 }.get(target.cpu, target.cpu)
2068 name = "d3dcompiler_47.dll"
2070 if target.cpu == "aarch64":
2071 # AArch64 Windows comes with d3dcompiler_47.dll installed
2072 return namespace(name=name, path=None)
2075 path = os.path.join(windows_sdk_dir.path, "Redist", "D3D", suffix, name)
2076 error_extra = "in Windows SDK at {}".format(windows_sdk_dir.path)
2078 path = os.path.join(os.path.dirname(fxc), name)
2079 error_extra = "alongside FXC at {}".format(fxc)
2081 if os.path.exists(path):
2082 return namespace(name=name, path=path)
2083 die("Could not find {} {}".format(name, error_extra))
2085 set_config("MOZ_ANGLE_RENDERER", True)
2087 "MOZ_D3DCOMPILER_VISTA_DLL", d3d_compiler_dll.name, when=d3d_compiler_dll.path
2089 set_config("MOZ_D3DCOMPILER_VISTA_DLL_PATH", d3d_compiler_dll.path)
2091 # Remoting protocol support
2092 # ==============================================================
2096 def has_remote(toolkit):
2097 if toolkit in ("gtk", "windows", "cocoa"):
2101 set_config("MOZ_HAS_REMOTE", has_remote)
2102 set_define("MOZ_HAS_REMOTE", has_remote)
2104 # RLBox Library Sandboxing wasm support
2105 # ==============================================================
2108 def wasm_sandboxing_libraries():
2116 @depends(dependable(wasm_sandboxing_libraries), target, "MOZ_AUTOMATION")
2117 def default_wasm_sandboxing_libraries(libraries, target, automation):
2118 non_default_libs = set()
2119 if target.bitness == 32:
2120 non_default_libs.add("ogg")
2123 return tuple(l for l in libraries if l not in non_default_libs)
2127 "--with-wasm-sandboxed-libraries",
2128 env="WASM_SANDBOXED_LIBRARIES",
2129 help="{Enable wasm sandboxing for the selected libraries|Disable wasm sandboxing}",
2131 choices=dependable(wasm_sandboxing_libraries),
2132 default=default_wasm_sandboxing_libraries,
2136 @depends("--with-wasm-sandboxed-libraries")
2137 def requires_wasm_sandboxing(libraries):
2142 set_config("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
2143 set_define("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
2145 with only_when(requires_wasm_sandboxing & compile_environment):
2147 "--with-wasi-sysroot",
2150 help="Path to wasi sysroot for wasm sandboxing",
2153 @depends("--with-wasi-sysroot", requires_wasm_sandboxing)
2154 def bootstrap_wasi_sysroot(wasi_sysroot, requires_wasm_sandboxing):
2155 return requires_wasm_sandboxing and not wasi_sysroot
2158 "--with-wasi-sysroot",
2159 bootstrap_path("sysroot-wasm32-wasi", when=bootstrap_wasi_sysroot),
2162 def wasi_sysroot(wasi_sysroot, bootstrapped_sysroot):
2163 if not wasi_sysroot:
2164 if not bootstrapped_sysroot:
2166 "Cannot find a wasi sysroot. Please give its location with "
2167 "--with-wasi-sysroot."
2169 return bootstrapped_sysroot
2171 wasi_sysroot = wasi_sysroot[0]
2172 if not os.path.isdir(wasi_sysroot):
2173 die("Argument to --with-wasi-sysroot must be a directory")
2174 if not os.path.isabs(wasi_sysroot):
2175 die("Argument to --with-wasi-sysroot must be an absolute path")
2179 set_config("WASI_SYSROOT", wasi_sysroot)
2181 def wasm_compiler_with_flags(compiler, sysroot):
2187 + [compiler.compiler]
2189 + ["--sysroot=%s" % sysroot]
2192 wasm_cc = compiler("C", wasm, other_compiler=c_compiler)
2194 @depends(wasm_cc, wasi_sysroot)
2195 def wasm_cc_with_flags(wasm_cc, wasi_sysroot):
2196 return wasm_compiler_with_flags(wasm_cc, wasi_sysroot)
2198 set_config("WASM_CC", wasm_cc_with_flags)
2200 wasm_cxx = compiler(
2204 other_compiler=cxx_compiler,
2205 other_c_compiler=c_compiler,
2208 @depends(wasm_cxx, wasi_sysroot)
2209 def wasm_cxx_with_flags(wasm_cxx, wasi_sysroot):
2210 return wasm_compiler_with_flags(wasm_cxx, wasi_sysroot)
2212 set_config("WASM_CXX", wasm_cxx_with_flags)
2214 wasm_compile_flags = dependable(
2215 ["-fno-exceptions", "-fno-strict-aliasing", "-Qunused-arguments"]
2217 option(env="WASM_CFLAGS", nargs=1, help="Options to pass to WASM_CC")
2219 @depends("WASM_CFLAGS", wasm_compile_flags)
2220 def wasm_cflags(value, wasm_compile_flags):
2222 return wasm_compile_flags + value
2224 return wasm_compile_flags
2226 set_config("WASM_CFLAGS", wasm_cflags)
2228 option(env="WASM_CXXFLAGS", nargs=1, help="Options to pass to WASM_CXX")
2230 @depends("WASM_CXXFLAGS", wasm_compile_flags)
2231 def wasm_cxxflags(value, wasm_compile_flags):
2233 return wasm_compile_flags + value
2235 return wasm_compile_flags
2237 set_config("WASM_CXXFLAGS", wasm_cxxflags)
2240 @depends("--with-wasm-sandboxed-libraries")
2241 def wasm_sandboxing(libraries):
2245 return namespace(**{name: True for name in libraries})
2249 def wasm_sandboxing_config_defines():
2250 for lib in wasm_sandboxing_libraries():
2252 "MOZ_WASM_SANDBOXING_%s" % lib.upper(), getattr(wasm_sandboxing, lib)
2255 "MOZ_WASM_SANDBOXING_%s" % lib.upper(), getattr(wasm_sandboxing, lib)
2259 wasm_sandboxing_config_defines()
2262 # new XULStore implementation
2263 # ==============================================================
2267 def new_xulstore(milestone):
2268 if milestone.is_nightly:
2272 set_config("MOZ_NEW_XULSTORE", True, when=new_xulstore)
2273 set_define("MOZ_NEW_XULSTORE", True, when=new_xulstore)
2276 # new Notification Store implementation
2277 # ==============================================================
2281 def new_notification_store(milestone):
2282 if milestone.is_nightly:
2286 set_config("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)
2287 set_define("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)
2290 # Glean SDK Integration Crate
2291 # ==============================================================
2295 def glean_android(target):
2296 return target.os == "Android"
2299 set_config("MOZ_GLEAN_ANDROID", True, when=glean_android)
2300 set_define("MOZ_GLEAN_ANDROID", True, when=glean_android)
2304 # ==============================================================
2310 bootstrap="dump_syms",
2311 when=compile_environment,
2320 when=compile_environment & target_is_windows,
2324 @depends("MOZ_AUTOMATION", c_compiler)
2325 def allow_missing_winchecksec(automation, c_compiler):
2328 if c_compiler and c_compiler.type != "clang-cl":
2334 ["winchecksec.exe", "winchecksec"],
2335 bootstrap="winchecksec",
2336 allow_missing=allow_missing_winchecksec,
2337 when=compile_environment & target_is_windows,
2341 @depends(target, build_project)
2342 def forkserver_default(target, build_project):
2343 return build_project == "browser" and (
2344 (target.os == "GNU" and target.kernel == "Linux")
2345 or target.os == "FreeBSD"
2346 or target.os == "OpenBSD"
2351 "--enable-forkserver",
2352 default=forkserver_default,
2353 env="MOZ_ENABLE_FORKSERVER",
2354 help="{Enable|Disable} fork server",
2358 @depends("--enable-forkserver", target)
2359 def forkserver_flag(value, target):
2361 target.os == "Android"
2362 or (target.os == "GNU" and target.kernel == "Linux")
2363 or target.os == "FreeBSD"
2364 or target.os == "OpenBSD"
2370 set_config("MOZ_ENABLE_FORKSERVER", forkserver_flag)
2371 set_define("MOZ_ENABLE_FORKSERVER", forkserver_flag, forkserver_flag)
2374 # ==============================================================
2376 with only_when(compile_environment & target_is_linux):
2377 # Check if we need to use the breakpad_getcontext fallback.
2378 getcontext = check_symbol("getcontext")
2379 set_config("HAVE_GETCONTEXT", getcontext)
2380 set_define("HAVE_GETCONTEXT", getcontext)
2383 # ==============================================================
2384 include("../build/moz.configure/nss.configure")
2387 # Enable or disable running in background task mode: headless for
2388 # periodic, short-lived, maintenance tasks.
2389 # ==============================================================================
2393 "--disable-backgroundtasks",
2394 help="Disable running in background task mode",
2399 "MOZ_BACKGROUNDTASKS", depends_if("--enable-backgroundtasks")(lambda _: True)
2403 # Update-related programs: updater, maintenance service, update agent,
2404 # default browser agent.
2405 # ==============================================================
2406 include("../build/moz.configure/update-programs.configure")
2409 # Mobile optimizations
2410 # ==============================================================
2412 "--enable-mobile-optimize",
2413 default=target_is_android,
2414 help="{Enable|Disable} mobile optimizations",
2417 set_define("MOZ_GFX_OPTIMIZE_MOBILE", True, when="--enable-mobile-optimize")
2418 # We ignore "paint will resample" on mobile for performance.
2419 # We may want to revisit this later.
2420 set_define("MOZ_IGNORE_PAINT_WILL_RESAMPLE", True, when="--enable-mobile-optimize")
2423 # ==============================================================
2424 option("--disable-pref-extensions", help="Disable pref extensions such as autoconfig")
2425 set_config("MOZ_PREF_EXTENSIONS", True, when="--enable-pref-extensions")
2427 # Offer a way to disable the startup cache
2428 # ==============================================================
2429 option("--disable-startupcache", help="Disable startup cache")
2432 @depends("--enable-startupcache")
2433 def enable_startupcache(value):
2439 "MOZ_DISABLE_STARTUPCACHE", True, when=depends(enable_startupcache)(lambda x: not x)
2444 # ==============================================================
2446 env="MOZ_APP_REMOTINGNAME",
2448 help="Used for the internal program name, which affects profile name "
2449 "and remoting. If not set, defaults to MOZ_APP_NAME.",
2453 @depends("MOZ_APP_REMOTINGNAME", moz_app_name)
2454 def moz_app_remotingname(value, moz_app_name):
2460 set_config("MOZ_APP_REMOTINGNAME", moz_app_remotingname)
2463 env="ANDROID_PACKAGE_NAME",
2465 help="Name of the Android package (default org.mozilla.$MOZ_APP_NAME)",
2469 @depends("ANDROID_PACKAGE_NAME", moz_app_name)
2470 def android_package_name(value, moz_app_name):
2473 if moz_app_name == "fennec":
2474 return "org.mozilla.fennec_aurora"
2475 return "org.mozilla.%s" % moz_app_name
2478 set_config("ANDROID_PACKAGE_NAME", android_package_name)
2481 # Miscellaneous options
2482 # ==============================================================
2483 option(env="MOZ_WINCONSOLE", nargs="?", help="Whether we can create a console window.")
2484 set_define("MOZ_WINCONSOLE", True, when=depends("MOZ_WINCONSOLE")(lambda x: x))
2487 env="MOZ_USE_NATIVE_POPUP_WINDOWS",
2488 default=target_is_android,
2489 help="Whether to use native popup windows",
2492 set_define("MOZ_USE_NATIVE_POPUP_WINDOWS", True, when="MOZ_USE_NATIVE_POPUP_WINDOWS")
2495 # Alternative Crashreporter setting
2497 "--with-crashreporter-url",
2498 env="MOZ_CRASHREPORTER_URL",
2499 default="https://crash-reports.mozilla.com/",
2501 help="Set an alternative crashreporter url",
2505 "MOZ_CRASHREPORTER_URL",
2506 depends("--with-crashreporter-url")(lambda x: x[0].rstrip("/")),
2510 # Crash reporter options
2511 # ==============================================================
2513 def oxidized_breakpad(target):
2514 if target.kernel == "Linux" and target.os != "Android":
2515 return target.cpu in ("x86", "x86_64")
2519 set_config("MOZ_OXIDIZED_BREAKPAD", True, when=oxidized_breakpad)
2520 set_define("MOZ_OXIDIZED_BREAKPAD", True, when=oxidized_breakpad)
2524 # ==============================================================
2525 @depends(target, host)
2526 def want_wine(target, host):
2527 return target.kernel == "WINNT" and host.kernel != "WINNT"
2534 bootstrap="wine/bin",