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):
1188 # third_party/libwebrtc/webrtc/webrtc_gn/moz.build adds those
1189 # manually, ensure they're available.
1197 return " ".join(libs)
1200 pkg_check_modules("MOZ_X11", x11_libs, when=toolkit_gtk)
1203 # ASan Reporter Addon
1204 # ==============================================================
1206 "--enable-address-sanitizer-reporter",
1207 help="Enable Address Sanitizer Reporter Extension",
1211 @depends("--enable-address-sanitizer-reporter")
1212 def enable_asan_reporter(value):
1217 set_config("MOZ_ASAN_REPORTER", enable_asan_reporter)
1218 set_define("MOZ_ASAN_REPORTER", enable_asan_reporter)
1219 add_old_configure_assignment("MOZ_ASAN_REPORTER", enable_asan_reporter)
1222 # ==============================================================
1223 with only_when("--enable-compile-environment"):
1225 @depends(host, target)
1226 def has_elfhack(host, target):
1228 target.kernel == "Linux"
1229 and host.kernel == "Linux"
1230 and target.cpu in ("arm", "x86", "x86_64")
1233 @depends("--enable-release", enable_linker)
1234 def default_elfhack(release, linker):
1235 # Disable elfhack when explicitly building with --enable-linker=lld
1236 if linker and linker.origin != "default" and linker[0] == "lld":
1238 return bool(release)
1240 with only_when(has_elfhack):
1242 "--disable-elf-hack",
1243 default=default_elfhack,
1244 help="{Enable|Disable} elf hacks",
1247 set_config("USE_ELF_HACK", depends_if("--enable-elf-hack")(lambda _: True))
1250 @depends(check_build_environment)
1251 def idl_roots(build_env):
1253 ipdl_root=os.path.join(build_env.topobjdir, "ipc", "ipdl"),
1254 webidl_root=os.path.join(build_env.topobjdir, "dom", "bindings"),
1255 xpcom_root=os.path.join(build_env.topobjdir, "xpcom", "components"),
1259 set_config("WEBIDL_ROOT", idl_roots.webidl_root)
1260 set_config("IPDL_ROOT", idl_roots.ipdl_root)
1261 set_config("XPCOM_ROOT", idl_roots.xpcom_root)
1263 # Proxy bypass protection
1264 # ==============================================================
1267 "--enable-proxy-bypass-protection",
1268 help="Prevent suspected or confirmed proxy bypasses",
1272 @depends_if("--enable-proxy-bypass-protection")
1273 def proxy_bypass_protection(_):
1277 set_config("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1278 set_define("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1280 # Proxy direct failover
1281 # ==============================================================
1284 "--disable-proxy-direct-failover",
1285 help="Disable direct failover for system requests",
1289 @depends_if("--disable-proxy-direct-failover")
1290 def proxy_direct_failover(value):
1295 set_config("MOZ_PROXY_DIRECT_FAILOVER", proxy_direct_failover)
1296 set_define("MOZ_PROXY_DIRECT_FAILOVER", proxy_direct_failover)
1299 # ==============================================================
1302 @depends(c_compiler, toolchain_prefix)
1303 def midl_names(c_compiler, toolchain_prefix):
1304 if c_compiler and c_compiler.type in ["gcc", "clang"]:
1307 if toolchain_prefix:
1308 prefixed = tuple("%s%s" % (p, "widl") for p in toolchain_prefix)
1309 widl = prefixed + widl
1312 return ("midl.exe",)
1315 @depends(target, "--enable-compile-environment")
1316 def check_for_midl(target, compile_environment):
1317 if target.os != "WINNT":
1320 if compile_environment:
1325 "MIDL", midl_names, when=check_for_midl, allow_missing=True, paths=sdk_bin_path
1328 option(env="MIDL_FLAGS", nargs=1, help="Extra flags to pass to MIDL")
1337 when=depends(midl, target)(lambda m, t: m and t.kernel == "WINNT"),
1339 def midl_flags(flags, c_compiler, target, host, midl):
1341 flags = flags[0].split()
1345 if not midl.endswith("widl"):
1351 flags += ["-env", env]
1353 if host.os == "WINNT":
1354 return flags + ["-cpp_cmd", c_compiler.compiler]
1356 # If cross-compiling and using midl instead of widl, for now, we'll
1357 # assume we can find the Windows version of clang-cl in the PATH.
1358 # It is required because while Wine is able to spawn Linux
1359 # processes from Windows programs(!), the calling program doesn't
1360 # have access to the process output and can't wait for it to
1361 # finish. Midl runs clang-cl as a preprocessor and expects to read
1363 clang_cl_exe = find_program("clang-cl.exe")
1364 if not clang_cl_exe:
1365 die("Cannot find clang-cl.exe")
1366 return flags + ["-cpp_cmd", clang_cl_exe]
1370 "x86": ["--win32", "-m32"],
1371 "x86_64": ["--win64", "-m64"],
1375 set_config("MIDL_FLAGS", midl_flags)
1378 # ==============================================================
1380 option("--disable-accessibility", help="Disable accessibility support")
1383 @depends("--enable-accessibility", check_for_midl, midl, c_compiler)
1384 def accessibility(value, check_for_midl, midl, c_compiler):
1385 enabled = bool(value)
1390 if check_for_midl and not midl:
1391 if c_compiler and c_compiler.type in ("gcc", "clang"):
1393 "You have accessibility enabled, but widl could not be found. "
1394 "Add --disable-accessibility to your mozconfig or install widl. "
1395 "See https://developer.mozilla.org/en-US/docs/Cross_Compile_Mozilla_for_Mingw32 for details."
1399 "MIDL could not be found. "
1400 "Building accessibility without MIDL is not supported."
1406 set_config("ACCESSIBILITY", accessibility)
1407 set_define("ACCESSIBILITY", accessibility)
1408 add_old_configure_assignment("ACCESSIBILITY", accessibility)
1412 # ==============================================================
1414 def require_signing(milestone):
1415 return milestone.is_release_or_beta and not milestone.is_esr
1419 env="MOZ_REQUIRE_SIGNING",
1420 default=require_signing,
1421 help="Enforce that add-ons are signed by the trusted root",
1424 set_config("MOZ_REQUIRE_SIGNING", True, when="MOZ_REQUIRE_SIGNING")
1425 set_define("MOZ_REQUIRE_SIGNING", True, when="MOZ_REQUIRE_SIGNING")
1428 "--with-unsigned-addon-scopes",
1430 choices=("app", "system"),
1431 help="Addon scopes where signature is not required",
1435 @depends("--with-unsigned-addon-scopes")
1436 def unsigned_addon_scopes(scopes):
1438 app="app" in scopes or None,
1439 system="system" in scopes or None,
1443 set_config("MOZ_UNSIGNED_APP_SCOPE", unsigned_addon_scopes.app)
1444 set_config("MOZ_UNSIGNED_SYSTEM_SCOPE", unsigned_addon_scopes.system)
1448 # ==============================================================
1450 "--allow-addon-sideload",
1451 default=milestone.is_esr,
1452 help="Addon sideloading is allowed",
1456 set_config("MOZ_ALLOW_ADDON_SIDELOAD", True, when="--allow-addon-sideload")
1458 # WebExtensions API WebIDL bindings
1459 # ==============================================================
1463 def extensions_webidl_bindings_default(milestone):
1464 # Only enable the webidl bindings for the WebExtensions APIs
1466 return milestone.is_nightly
1470 "--enable-extensions-webidl-bindings",
1471 default=extensions_webidl_bindings_default,
1472 help="{Enable|Disable} building experimental WebExtensions WebIDL bindings",
1476 @depends("--enable-extensions-webidl-bindings")
1477 def extensions_webidl_enabled(value):
1481 set_config("MOZ_WEBEXT_WEBIDL_ENABLED", extensions_webidl_enabled)
1483 # Launcher process (Windows only)
1484 # ==============================================================
1488 def launcher_process_default(target):
1489 return target.os == "WINNT"
1493 "--enable-launcher-process",
1494 default=launcher_process_default,
1495 help="{Enable|Disable} launcher process by default",
1499 @depends("--enable-launcher-process", target)
1500 def launcher(value, target):
1501 enabled = bool(value)
1502 if enabled and target.os != "WINNT":
1503 die("Cannot enable launcher process on %s", target.os)
1508 set_config("MOZ_LAUNCHER_PROCESS", launcher)
1509 set_define("MOZ_LAUNCHER_PROCESS", launcher)
1511 # llvm-dlltool (Windows only)
1512 # ==============================================================
1515 @depends(build_project, target, "--enable-compile-environment")
1516 def check_for_llvm_dlltool(build_project, target, compile_environment):
1517 if build_project != "browser":
1520 if target.os != "WINNT":
1523 return compile_environment
1526 llvm_dlltool = check_prog(
1529 what="llvm-dlltool",
1530 when=check_for_llvm_dlltool,
1531 paths=clang_search_path,
1535 @depends(target, when=llvm_dlltool)
1536 def llvm_dlltool_flags(target):
1539 "x86_64": "i386:x86-64",
1546 set_config("LLVM_DLLTOOL_FLAGS", llvm_dlltool_flags)
1548 # BITS download (Windows only)
1549 # ==============================================================
1552 "--enable-bits-download",
1553 when=target_is_windows,
1554 default=target_is_windows,
1555 help="{Enable|Disable} building BITS download support",
1559 "MOZ_BITS_DOWNLOAD",
1560 depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
1563 "MOZ_BITS_DOWNLOAD",
1564 depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
1567 # Bundled fonts on desktop platform
1568 # ==============================================================
1572 def bundled_fonts_default(target):
1573 return target.os == "WINNT" or target.kernel == "Linux"
1576 @depends(build_project)
1577 def allow_bundled_fonts(project):
1578 return project == "browser" or project == "comm/mail"
1582 "--enable-bundled-fonts",
1583 default=bundled_fonts_default,
1584 when=allow_bundled_fonts,
1585 help="{Enable|Disable} support for bundled fonts on desktop platforms",
1589 "MOZ_BUNDLED_FONTS",
1590 depends_if("--enable-bundled-fonts", when=allow_bundled_fonts)(lambda _: True),
1594 # ==============================================================
1598 def reflow_perf(debug):
1604 "--enable-reflow-perf",
1605 default=reflow_perf,
1606 help="{Enable|Disable} reflow performance tracing",
1609 # The difference in conditions here comes from the initial implementation
1610 # in old-configure, which was unexplained there as well.
1611 set_define("MOZ_REFLOW_PERF", depends_if("--enable-reflow-perf")(lambda _: True))
1612 set_define("MOZ_REFLOW_PERF_DSP", reflow_perf)
1615 # ==============================================================
1619 def layout_debugger(debug):
1625 "--enable-layout-debugger",
1626 default=layout_debugger,
1627 help="{Enable|Disable} layout debugger",
1630 set_config("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
1631 set_define("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
1634 # Shader Compiler for Windows (and MinGW Cross Compile)
1635 # ==============================================================
1637 with only_when(compile_environment):
1640 ("fxc.exe", "fxc2.exe"),
1641 when=depends(target)(lambda t: t.kernel == "WINNT"),
1649 with only_when(compile_environment):
1651 "--with-system-libvpx", help="Use system libvpx (located with pkgconfig)"
1654 with only_when("--with-system-libvpx"):
1655 vpx = pkg_check_modules("MOZ_LIBVPX", "vpx >= 1.8.0")
1658 "vpx/vpx_decoder.h",
1660 onerror=lambda: die(
1661 "Couldn't find vpx/vpx_decoder.h, which is required to build "
1662 "with system libvpx. Use --without-system-libvpx to build "
1663 "with in-tree libvpx."
1668 "vpx_codec_dec_init_ver",
1670 onerror=lambda: die(
1671 "--with-system-libvpx requested but symbol vpx_codec_dec_init_ver "
1676 set_config("MOZ_SYSTEM_LIBVPX", True)
1678 @depends("--with-system-libvpx", target)
1679 def in_tree_vpx(system_libvpx, target):
1683 arm_asm = (target.cpu == "arm") or None
1684 return namespace(arm_asm=arm_asm)
1686 @depends(target, when=in_tree_vpx)
1687 def vpx_nasm(target):
1688 if target.cpu in ("x86", "x86_64"):
1689 if target.kernel == "WINNT":
1690 # Version 2.03 is needed for automatic safeseh support.
1691 return namespace(version="2.03", what="VPX")
1692 return namespace(what="VPX")
1694 # Building with -mfpu=neon requires either the "softfp" or the
1695 # "hardfp" ABI. Depending on the compiler's default target, and the
1696 # CFLAGS, the default ABI might be neither, in which case it is the
1698 # The "softfloat" ABI is binary-compatible with the "softfp" ABI, so
1699 # we can safely mix code built with both ABIs. So, if we detect
1700 # that compiling uses the "softfloat" ABI, force the use of the
1701 # "softfp" ABI instead.
1702 # Confusingly, the __SOFTFP__ preprocessor variable indicates the
1703 # "softfloat" ABI, not the "softfp" ABI.
1704 # Note: VPX_ASFLAGS is also used in CFLAGS.
1705 softfp = cxx_compiler.try_compile(
1708 #error "compiler target supports -mfpu=neon, so we don't have to add extra flags"
1710 when=in_tree_vpx.arm_asm,
1713 @depends(in_tree_vpx, vpx_nasm, softfp, target)
1714 def vpx_as_flags(vpx, vpx_nasm, softfp, target):
1716 if vpx and vpx.arm_asm:
1717 # These flags are a lie; they're just used to enable the requisite
1718 # opcodes; actual arch detection is done at runtime.
1719 flags = ["-march=armv7-a", "-mfpu=neon"]
1721 flags.append("-mfloat-abi=softfp")
1722 elif vpx and vpx_nasm and target.os != "WINNT" and target.cpu != "x86_64":
1726 set_config("VPX_USE_NASM", True, when=vpx_nasm)
1727 set_config("VPX_ASFLAGS", vpx_as_flags)
1733 with only_when(compile_environment):
1735 "--with-system-jpeg",
1737 help="Use system libjpeg (installed at given prefix)",
1740 @depends_if("--with-system-jpeg")
1741 def jpeg_flags(value):
1744 cflags=("-I%s/include" % value[0],),
1745 ldflags=("-L%s/lib" % value[0], "-ljpeg"),
1748 ldflags=("-ljpeg",),
1751 with only_when("--with-system-jpeg"):
1753 "jpeg_destroy_compress",
1754 flags=jpeg_flags.ldflags,
1755 onerror=lambda: die(
1756 "--with-system-jpeg requested but symbol "
1757 "jpeg_destroy_compress not found."
1761 c_compiler.try_compile(
1768 #if JPEG_LIB_VERSION < 62
1769 #error Insufficient JPEG library version
1772 flags=jpeg_flags.cflags,
1773 check_msg="for sufficient jpeg library version",
1774 onerror=lambda: die(
1775 "Insufficient JPEG library version for "
1776 "--with-system-jpeg (62 required)"
1780 c_compiler.try_compile(
1787 #ifndef JCS_EXTENSIONS
1788 #error libjpeg-turbo JCS_EXTENSIONS required
1791 flags=jpeg_flags.cflags,
1792 check_msg="for sufficient libjpeg-turbo JCS_EXTENSIONS",
1793 onerror=lambda: die(
1794 "libjpeg-turbo JCS_EXTENSIONS required for " "--with-system-jpeg"
1798 set_config("MOZ_JPEG_CFLAGS", jpeg_flags.cflags)
1799 set_config("MOZ_JPEG_LIBS", jpeg_flags.ldflags)
1801 @depends("--with-system-jpeg", target)
1802 def in_tree_jpeg(system_jpeg, target):
1806 if target.kernel == "Darwin":
1807 if target.cpu == "x86":
1808 return ("-DPIC", "-DMACHO")
1809 elif target.cpu == "x86_64":
1810 return ("-D__x86_64__", "-DPIC", "-DMACHO")
1811 elif target.kernel == "WINNT":
1812 if target.cpu == "x86":
1813 return ("-DPIC", "-DWIN32")
1814 elif target.cpu == "x86_64":
1815 return ("-D__x86_64__", "-DPIC", "-DWIN64", "-DMSVC")
1816 elif target.cpu == "arm":
1817 return ("-march=armv7-a", "-mfpu=neon")
1818 elif target.cpu == "aarch64":
1819 return ("-march=armv8-a",)
1820 elif target.cpu == "mips32":
1822 elif target.cpu == "x86":
1823 return ("-DPIC", "-DELF")
1824 elif target.cpu == "x86_64":
1825 return ("-D__x86_64__", "-DPIC", "-DELF")
1827 @depends(target, when=in_tree_jpeg)
1828 def jpeg_nasm(target):
1829 if target.cpu in ("x86", "x86_64"):
1830 # libjpeg-turbo 2.0.6 requires nasm 2.10.
1831 return namespace(version="2.10", what="JPEG")
1833 set_config("LIBJPEG_TURBO_USE_NASM", True, when=jpeg_nasm)
1834 set_config("LIBJPEG_TURBO_ASFLAGS", in_tree_jpeg)
1837 # FFmpeg's ffvpx configuration
1838 # ==============================================================
1839 with only_when(compile_environment):
1842 def libav_fft(target):
1843 return target.kernel == "WINNT" or target.cpu == "x86_64"
1845 set_config("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
1846 set_define("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
1849 # Artifact builds need MOZ_FFVPX defined as if compilation happened.
1850 with only_when(compile_environment | artifact_builds):
1854 enable = use_nasm = True
1858 if target.kernel == "WINNT":
1859 if target.cpu == "x86":
1860 # 32-bit windows need to prefix symbols with an underscore.
1861 flags = ["-DPIC", "-DWIN32", "-DPREFIX", "-Pconfig_win32.asm"]
1862 elif target.cpu == "x86_64":
1868 "-Pconfig_win64.asm",
1870 elif target.cpu == "aarch64":
1871 flags = ["-DPIC", "-DWIN64"]
1873 elif target.kernel == "Darwin":
1874 if target.cpu == "x86_64":
1875 # 32/64-bit macosx asemblers need to prefix symbols with an
1882 "-Pconfig_darwin64.asm",
1886 elif target.cpu == "x86_64":
1887 flags = ["-D__x86_64__", "-DPIC", "-DELF", "-Pconfig_unix64.asm"]
1888 elif target.cpu in ("x86", "arm", "aarch64"):
1893 if flac_only or not enable:
1897 # default disabled components
1898 flags.append("-Pdefaults_disabled.asm")
1903 flac_only=flac_only,
1907 @depends(when=ffvpx.use_nasm)
1909 # nasm 2.10 for AVX-2 support.
1910 return namespace(version="2.10", what="FFVPX")
1912 # ffvpx_nasm can't indirectly depend on vpx_as_flags, because it depends
1913 # on a compiler test, so we have to do a little bit of dance here.
1914 @depends(ffvpx, vpx_as_flags, target)
1915 def ffvpx(ffvpx, vpx_as_flags, target):
1916 if ffvpx and vpx_as_flags and target.cpu in ("arm", "aarch64"):
1917 ffvpx.flags.extend(vpx_as_flags)
1920 set_config("MOZ_FFVPX", True, when=ffvpx.enable)
1921 set_define("MOZ_FFVPX", True, when=ffvpx.enable)
1922 set_config("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.flac_only)
1923 set_define("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.flac_only)
1924 set_config("FFVPX_ASFLAGS", ffvpx.flags)
1925 set_config("FFVPX_USE_NASM", True, when=ffvpx.use_nasm)
1929 # ==============================================================
1930 @depends(dav1d_nasm, vpx_nasm, jpeg_nasm, ffvpx_nasm, when=compile_environment)
1931 def need_nasm(*requirements):
1933 x.what: x.version if hasattr(x, "version") else True for x in requirements if x
1936 items = sorted(requires.keys())
1938 what = " and ".join((", ".join(items[:-1]), items[-1]))
1941 versioned = {k: v for (k, v) in requires.items() if v is not True}
1942 return namespace(what=what, versioned=versioned)
1954 @depends(nasm, need_nasm.what)
1955 def check_nasm(nasm, what):
1956 if not nasm and what:
1957 die("Nasm is required to build with %s, but it was not found." % what)
1961 @depends_if(check_nasm)
1962 @checking("nasm version")
1963 def nasm_version(nasm):
1965 check_cmd_output(nasm, "-v", onerror=lambda: die("Failed to get nasm version."))
1969 return Version(version)
1972 @depends(nasm_version, need_nasm.versioned, when=need_nasm.versioned)
1973 def check_nasm_version(nasm_version, versioned):
1974 by_version = sorted(versioned.items(), key=lambda x: x[1])
1975 what, version = by_version[-1]
1976 if nasm_version < version:
1978 "Nasm version %s or greater is required to build with %s." % (version, what)
1983 @depends(target, when=check_nasm_version)
1984 def nasm_asflags(target):
1986 ("OSX", "x86"): ["-f", "macho32"],
1987 ("OSX", "x86_64"): ["-f", "macho64"],
1988 ("WINNT", "x86"): ["-f", "win32"],
1989 ("WINNT", "x86_64"): ["-f", "win64"],
1990 }.get((target.os, target.cpu), None)
1992 # We're assuming every x86 platform we support that's
1993 # not Windows or Mac is ELF.
1994 if target.cpu == "x86":
1995 asflags = ["-f", "elf32"]
1996 elif target.cpu == "x86_64":
1997 asflags = ["-f", "elf64"]
2001 set_config("NASM_ASFLAGS", nasm_asflags)
2004 # ANGLE OpenGL->D3D translator for WebGL
2005 # ==============================================================
2007 with only_when(compile_environment & target_is_windows):
2009 def d3d_compiler_dll_result(value):
2011 return "provided by the OS"
2014 @depends(target, valid_windows_sdk_dir, fxc)
2015 @checking("for D3D compiler DLL", d3d_compiler_dll_result)
2017 def d3d_compiler_dll(target, windows_sdk_dir, fxc):
2020 }.get(target.cpu, target.cpu)
2022 name = "d3dcompiler_47.dll"
2024 if target.cpu == "aarch64":
2025 # AArch64 Windows comes with d3dcompiler_47.dll installed
2026 return namespace(name=name, path=None)
2029 path = os.path.join(windows_sdk_dir.path, "Redist", "D3D", suffix, name)
2030 error_extra = "in Windows SDK at {}".format(windows_sdk_dir.path)
2032 path = os.path.join(os.path.dirname(fxc), name)
2033 error_extra = "alongside FXC at {}".format(fxc)
2035 if os.path.exists(path):
2036 return namespace(name=name, path=path)
2037 die("Could not find {} {}".format(name, error_extra))
2039 set_config("MOZ_ANGLE_RENDERER", True)
2041 "MOZ_D3DCOMPILER_VISTA_DLL", d3d_compiler_dll.name, when=d3d_compiler_dll.path
2043 set_config("MOZ_D3DCOMPILER_VISTA_DLL_PATH", d3d_compiler_dll.path)
2045 # Remoting protocol support
2046 # ==============================================================
2050 def has_remote(toolkit):
2051 if toolkit in ("gtk", "windows", "cocoa"):
2055 set_config("MOZ_HAS_REMOTE", has_remote)
2056 set_define("MOZ_HAS_REMOTE", has_remote)
2058 # RLBox Library Sandboxing wasm support
2059 # ==============================================================
2062 def wasm_sandboxing_libraries():
2070 @depends(dependable(wasm_sandboxing_libraries), "MOZ_AUTOMATION")
2071 def default_wasm_sandboxing_libraries(libraries, automation):
2077 "--with-wasm-sandboxed-libraries",
2078 env="WASM_SANDBOXED_LIBRARIES",
2079 help="{Enable wasm sandboxing for the selected libraries|Disable wasm sandboxing}",
2081 choices=dependable(wasm_sandboxing_libraries),
2082 default=default_wasm_sandboxing_libraries,
2086 @depends("--with-wasm-sandboxed-libraries")
2087 def requires_wasm_sandboxing(libraries):
2092 set_config("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
2093 set_define("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
2095 with only_when(requires_wasm_sandboxing & compile_environment):
2097 "--with-wasi-sysroot",
2100 help="Path to wasi sysroot for wasm sandboxing",
2103 @depends("--with-wasi-sysroot", requires_wasm_sandboxing)
2104 def bootstrap_wasi_sysroot(wasi_sysroot, requires_wasm_sandboxing):
2105 return requires_wasm_sandboxing and not wasi_sysroot
2108 "--with-wasi-sysroot",
2109 bootstrap_path("sysroot-wasm32-wasi", when=bootstrap_wasi_sysroot),
2112 def wasi_sysroot(wasi_sysroot, bootstrapped_sysroot):
2113 if not wasi_sysroot:
2114 if not bootstrapped_sysroot:
2116 "Cannot find a wasi sysroot. Please give its location with "
2117 "--with-wasi-sysroot."
2119 return bootstrapped_sysroot
2121 wasi_sysroot = wasi_sysroot[0]
2122 if not os.path.isdir(wasi_sysroot):
2123 die("Argument to --with-wasi-sysroot must be a directory")
2124 if not os.path.isabs(wasi_sysroot):
2125 die("Argument to --with-wasi-sysroot must be an absolute path")
2129 set_config("WASI_SYSROOT", wasi_sysroot)
2131 def wasm_compiler_with_flags(compiler, sysroot):
2137 + [compiler.compiler]
2139 + ["--sysroot=%s" % sysroot]
2142 wasm_cc = compiler("C", wasm, other_compiler=c_compiler)
2144 @depends(wasm_cc, wasi_sysroot)
2145 def wasm_cc_with_flags(wasm_cc, wasi_sysroot):
2146 return wasm_compiler_with_flags(wasm_cc, wasi_sysroot)
2148 set_config("WASM_CC", wasm_cc_with_flags)
2150 wasm_cxx = compiler(
2154 other_compiler=cxx_compiler,
2155 other_c_compiler=c_compiler,
2158 @depends(wasm_cxx, wasi_sysroot)
2159 def wasm_cxx_with_flags(wasm_cxx, wasi_sysroot):
2160 return wasm_compiler_with_flags(wasm_cxx, wasi_sysroot)
2162 set_config("WASM_CXX", wasm_cxx_with_flags)
2164 wasm_compile_flags = dependable(
2165 ["-fno-exceptions", "-fno-strict-aliasing", "-Qunused-arguments"]
2167 option(env="WASM_CFLAGS", nargs=1, help="Options to pass to WASM_CC")
2169 @depends("WASM_CFLAGS", wasm_compile_flags)
2170 def wasm_cflags(value, wasm_compile_flags):
2172 return wasm_compile_flags + value
2174 return wasm_compile_flags
2176 set_config("WASM_CFLAGS", wasm_cflags)
2178 option(env="WASM_CXXFLAGS", nargs=1, help="Options to pass to WASM_CXX")
2180 @depends("WASM_CXXFLAGS", wasm_compile_flags)
2181 def wasm_cxxflags(value, wasm_compile_flags):
2183 return wasm_compile_flags + value
2185 return wasm_compile_flags
2187 set_config("WASM_CXXFLAGS", wasm_cxxflags)
2190 @depends("--with-wasm-sandboxed-libraries")
2191 def wasm_sandboxing(libraries):
2195 return namespace(**{name: True for name in libraries})
2199 def wasm_sandboxing_config_defines():
2200 for lib in wasm_sandboxing_libraries():
2202 "MOZ_WASM_SANDBOXING_%s" % lib.upper(), getattr(wasm_sandboxing, lib)
2205 "MOZ_WASM_SANDBOXING_%s" % lib.upper(), getattr(wasm_sandboxing, lib)
2209 wasm_sandboxing_config_defines()
2212 # new XULStore implementation
2213 # ==============================================================
2217 def new_xulstore(milestone):
2218 if milestone.is_nightly:
2222 set_config("MOZ_NEW_XULSTORE", True, when=new_xulstore)
2223 set_define("MOZ_NEW_XULSTORE", True, when=new_xulstore)
2226 # new Notification Store implementation
2227 # ==============================================================
2231 def new_notification_store(milestone):
2232 if milestone.is_nightly:
2236 set_config("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)
2237 set_define("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)
2240 # Glean SDK Integration Crate
2241 # ==============================================================
2245 def glean_android(target):
2246 return target.os == "Android"
2249 set_config("MOZ_GLEAN_ANDROID", True, when=glean_android)
2250 set_define("MOZ_GLEAN_ANDROID", True, when=glean_android)
2254 # ==============================================================
2260 bootstrap="dump_syms",
2261 when=compile_environment,
2270 when=compile_environment & target_is_windows,
2274 @depends("MOZ_AUTOMATION", c_compiler)
2275 def allow_missing_winchecksec(automation, c_compiler):
2278 if c_compiler and c_compiler.type != "clang-cl":
2284 ["winchecksec.exe", "winchecksec"],
2285 bootstrap="winchecksec",
2286 allow_missing=allow_missing_winchecksec,
2287 when=compile_environment & target_is_windows,
2291 @depends(target, build_project)
2292 def forkserver_default(target, build_project):
2293 return build_project == "browser" and (
2294 (target.os == "GNU" and target.kernel == "Linux")
2295 or target.os == "FreeBSD"
2296 or target.os == "OpenBSD"
2301 "--enable-forkserver",
2302 default=forkserver_default,
2303 env="MOZ_ENABLE_FORKSERVER",
2304 help="{Enable|Disable} fork server",
2308 @depends("--enable-forkserver", target)
2309 def forkserver_flag(value, target):
2311 target.os == "Android"
2312 or (target.os == "GNU" and target.kernel == "Linux")
2313 or target.os == "FreeBSD"
2314 or target.os == "OpenBSD"
2320 set_config("MOZ_ENABLE_FORKSERVER", forkserver_flag)
2321 set_define("MOZ_ENABLE_FORKSERVER", forkserver_flag, forkserver_flag)
2324 # ==============================================================
2326 with only_when(compile_environment & target_is_linux):
2327 # Check if we need to use the breakpad_getcontext fallback.
2328 getcontext = check_symbol("getcontext")
2329 set_config("HAVE_GETCONTEXT", getcontext)
2330 set_define("HAVE_GETCONTEXT", getcontext)
2333 # ==============================================================
2334 include("../build/moz.configure/nss.configure")
2337 # Enable or disable running in background task mode: headless for
2338 # periodic, short-lived, maintenance tasks.
2339 # ==============================================================================
2343 "--disable-backgroundtasks",
2344 help="Disable running in background task mode",
2349 "MOZ_BACKGROUNDTASKS", depends_if("--enable-backgroundtasks")(lambda _: True)
2353 # Update-related programs: updater, maintenance service, update agent,
2354 # default browser agent.
2355 # ==============================================================
2356 include("../build/moz.configure/update-programs.configure")
2359 # Mobile optimizations
2360 # ==============================================================
2362 "--enable-mobile-optimize",
2363 default=target_is_android,
2364 help="{Enable|Disable} mobile optimizations",
2367 set_define("MOZ_GFX_OPTIMIZE_MOBILE", True, when="--enable-mobile-optimize")
2368 # We ignore "paint will resample" on mobile for performance.
2369 # We may want to revisit this later.
2370 set_define("MOZ_IGNORE_PAINT_WILL_RESAMPLE", True, when="--enable-mobile-optimize")
2373 # ==============================================================
2374 option("--disable-pref-extensions", help="Disable pref extensions such as autoconfig")
2375 set_config("MOZ_PREF_EXTENSIONS", True, when="--enable-pref-extensions")
2377 # Offer a way to disable the startup cache
2378 # ==============================================================
2379 option("--disable-startupcache", help="Disable startup cache")
2382 @depends("--enable-startupcache")
2383 def enable_startupcache(value):
2389 "MOZ_DISABLE_STARTUPCACHE", True, when=depends(enable_startupcache)(lambda x: not x)
2394 # ==============================================================
2396 env="MOZ_APP_REMOTINGNAME",
2398 help="Used for the internal program name, which affects profile name "
2399 "and remoting. If not set, defaults to MOZ_APP_NAME.",
2403 @depends("MOZ_APP_REMOTINGNAME", moz_app_name)
2404 def moz_app_remotingname(value, moz_app_name):
2410 set_config("MOZ_APP_REMOTINGNAME", moz_app_remotingname)
2413 env="ANDROID_PACKAGE_NAME",
2415 help="Name of the Android package (default org.mozilla.$MOZ_APP_NAME)",
2419 @depends("ANDROID_PACKAGE_NAME", moz_app_name)
2420 def android_package_name(value, moz_app_name):
2423 if moz_app_name == "fennec":
2424 return "org.mozilla.fennec_aurora"
2425 return "org.mozilla.%s" % moz_app_name
2428 set_config("ANDROID_PACKAGE_NAME", android_package_name)
2431 # Miscellaneous options
2432 # ==============================================================
2433 option(env="MOZ_WINCONSOLE", nargs="?", help="Whether we can create a console window.")
2434 set_define("MOZ_WINCONSOLE", True, when=depends("MOZ_WINCONSOLE")(lambda x: x))
2437 env="MOZ_USE_NATIVE_POPUP_WINDOWS",
2438 default=target_is_android,
2439 help="Whether to use native popup windows",
2442 set_define("MOZ_USE_NATIVE_POPUP_WINDOWS", True, when="MOZ_USE_NATIVE_POPUP_WINDOWS")
2445 # Alternative Crashreporter setting
2447 "--with-crashreporter-url",
2448 env="MOZ_CRASHREPORTER_URL",
2449 default="https://crash-reports.mozilla.com/",
2451 help="Set an alternative crashreporter url",
2455 "MOZ_CRASHREPORTER_URL",
2456 depends("--with-crashreporter-url")(lambda x: x[0].rstrip("/")),
2460 # Crash reporter options
2461 # ==============================================================
2463 def oxidized_breakpad(target):
2464 if target.kernel == "Linux" and target.os != "Android":
2465 return target.cpu in ("x86", "x86_64")
2469 set_config("MOZ_OXIDIZED_BREAKPAD", True, when=oxidized_breakpad)
2470 set_define("MOZ_OXIDIZED_BREAKPAD", True, when=oxidized_breakpad)