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 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 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"
317 set_config("MOZ_X11", True, when=toolkit_gtk)
318 set_define("MOZ_X11", True, when=toolkit_gtk)
319 add_old_configure_assignment("MOZ_X11", True, when=toolkit_gtk)
322 # ==============================================================
323 wayland_headers = pkg_check_modules(
325 "gtk+-wayland-3.0 >= 3.14 xkbcommon >= 0.4.1 libdrm >= 2.4",
326 allow_missing=depends(full_toolkit)(lambda t: t == "cairo-gtk3"),
327 when=depends(full_toolkit)(lambda t: t in ("cairo-gtk3", "cairo-gtk3-wayland")),
331 @depends(wayland_headers, toolkit_gtk, artifact_builds)
332 def wayland_headers(wayland, toolkit_gtk, artifacts):
333 if toolkit_gtk and artifacts:
338 set_config("MOZ_WAYLAND", depends_if(wayland_headers)(lambda _: True))
339 set_define("MOZ_WAYLAND", depends_if(wayland_headers)(lambda _: True))
342 # ==============================================================
343 option("--with-gl-provider", nargs=1, help="Set GL provider backend type")
346 @depends("--with-gl-provider")
347 def gl_provider(value):
352 @depends(gl_provider)
353 def gl_provider_define(provider):
355 return "GLContextProvider%s" % provider
358 set_define("MOZ_GL_PROVIDER", gl_provider_define)
361 @depends(gl_provider, wayland_headers, toolkit_gtk)
362 def gl_default_provider(value, wayland, toolkit_gtk):
371 set_config("MOZ_GL_PROVIDER", gl_provider)
372 set_config("MOZ_GL_DEFAULT_PROVIDER", gl_default_provider)
375 @depends(gl_default_provider)
376 def gl_provider_define(provider):
378 return "GL_PROVIDER_%s" % provider
381 set_define(gl_provider_define, True)
385 # ==============================================================
387 def pdf_printing(toolkit):
388 if toolkit in ("windows", "gtk", "android"):
392 @depends(pdf_printing)
393 def pdf_surface_feature(pdf_printing):
395 return "#define CAIRO_HAS_PDF_SURFACE 1"
397 # CONFIGURE_SUBST_FILES need explicit empty values.
401 set_config("MOZ_PDF_PRINTING", pdf_printing)
402 set_config("PDF_SURFACE_FEATURE", pdf_surface_feature)
405 # Event loop instrumentation
406 # ==============================================================
407 option(env="MOZ_INSTRUMENT_EVENT_LOOP", help="Force-enable event loop instrumentation")
410 @depends("MOZ_INSTRUMENT_EVENT_LOOP", toolkit)
411 def instrument_event_loop(value, toolkit):
413 toolkit in ("windows", "gtk", "cocoa", "android") and value.origin == "default"
418 set_config("MOZ_INSTRUMENT_EVENT_LOOP", instrument_event_loop)
419 set_define("MOZ_INSTRUMENT_EVENT_LOOP", instrument_event_loop)
422 # Fontconfig Freetype
423 # ==============================================================
424 option(env="USE_FC_FREETYPE", help="Force-enable the use of fontconfig freetype")
427 @depends("USE_FC_FREETYPE", toolkit)
428 def fc_freetype(value, toolkit):
429 if value or (toolkit == "gtk" and value.origin == "default"):
433 add_old_configure_assignment("USE_FC_FREETYPE", fc_freetype)
436 # ==============================================================
439 "pango >= 1.22.0 pangoft2 >= 1.22.0 pangocairo >= 1.22.0",
444 # ==============================================================
445 fontconfig_info = pkg_check_modules(
446 "_FONTCONFIG", "fontconfig >= 2.7.0", when=fc_freetype
450 @depends(fc_freetype)
451 def check_for_freetype2(fc_freetype):
456 # Check for freetype2. Flags are combined with fontconfig flags.
457 freetype2_info = pkg_check_modules(
458 "_FT2", "freetype2 >= 6.1.0", when=check_for_freetype2
462 @depends(fontconfig_info, freetype2_info)
463 def freetype2_combined_info(fontconfig_info, freetype2_info):
464 if not freetype2_info:
466 if not fontconfig_info:
467 return freetype2_info
469 cflags=freetype2_info.cflags + fontconfig_info.cflags,
470 libs=freetype2_info.libs + fontconfig_info.libs,
474 add_old_configure_assignment(
475 "_HAVE_FREETYPE2", depends_if(freetype2_info)(lambda _: True)
478 # Apple platform decoder support
479 # ==============================================================
481 def applemedia(toolkit):
482 if toolkit in ("cocoa", "uikit"):
486 set_config("MOZ_APPLEMEDIA", applemedia)
487 set_define("MOZ_APPLEMEDIA", applemedia)
488 add_old_configure_assignment("MOZ_APPLEMEDIA", applemedia)
490 # Windows Media Foundation support
491 # ==============================================================
492 option("--disable-wmf", help="Disable support for Windows Media Foundation")
495 @depends("--disable-wmf", target)
496 def wmf(value, target):
497 enabled = bool(value)
498 if value.origin == "default":
499 # Enable Windows Media Foundation support by default.
500 # Note our minimum SDK version is Windows 7 SDK, so we are (currently)
501 # guaranteed to have a recent-enough SDK to build WMF.
502 enabled = target.os == "WINNT"
503 if enabled and target.os != "WINNT":
504 die("Cannot enable Windows Media Foundation support on %s", target.os)
509 set_config("MOZ_WMF", wmf)
510 set_define("MOZ_WMF", wmf)
512 # FFmpeg H264/AAC Decoding Support
513 # ==============================================================
514 option("--disable-ffmpeg", help="Disable FFmpeg for fragmented H264/AAC decoding")
517 @depends("--disable-ffmpeg", target)
518 def ffmpeg(value, target):
519 enabled = bool(value)
520 if value.origin == "default":
521 enabled = target.os not in ("Android", "WINNT")
526 set_config("MOZ_FFMPEG", ffmpeg)
527 set_define("MOZ_FFMPEG", ffmpeg)
528 imply_option("--enable-fmp4", ffmpeg, "--enable-ffmpeg")
530 # AV1 Video Codec Support
531 # ==============================================================
532 option("--disable-av1", help="Disable av1 video support")
535 @depends("--enable-av1")
541 @depends(target, when=av1 & compile_environment)
542 def dav1d_asm(target):
543 if target.cpu in ("aarch64", "x86", "x86_64"):
547 @depends(target, when=av1 & compile_environment)
548 def dav1d_nasm(target):
549 if target.cpu in ("x86", "x86_64"):
550 return namespace(version="2.14", what="AV1")
553 set_config("MOZ_DAV1D_ASM", dav1d_asm)
554 set_define("MOZ_DAV1D_ASM", dav1d_asm)
555 set_config("MOZ_AV1", av1)
556 set_define("MOZ_AV1", av1)
558 # Built-in fragmented MP4 support.
559 # ==============================================================
563 help="Disable support for in built Fragmented MP4 parsing",
567 @depends("--disable-fmp4", target, wmf, applemedia)
568 def fmp4(value, target, wmf, applemedia):
569 enabled = bool(value)
570 if value.origin == "default":
571 # target.os == 'Android' includes all B2G versions
572 enabled = wmf or applemedia or target.os == "Android"
577 set_config("MOZ_FMP4", fmp4)
578 set_define("MOZ_FMP4", fmp4)
579 add_old_configure_assignment("MOZ_FMP4", fmp4)
583 def sample_type_is_s16(target):
584 # Use integers over floats for audio on Android regardless of the CPU
585 # architecture, because audio backends for Android don't support floats.
586 # We also use integers on ARM because it's more efficient.
587 if target.os == "Android" or target.cpu == "arm":
591 @depends(sample_type_is_s16)
592 def sample_type_is_float(t):
597 set_config("MOZ_SAMPLE_TYPE_S16", sample_type_is_s16)
598 set_define("MOZ_SAMPLE_TYPE_S16", sample_type_is_s16)
599 set_config("MOZ_SAMPLE_TYPE_FLOAT32", sample_type_is_float)
600 set_define("MOZ_SAMPLE_TYPE_FLOAT32", sample_type_is_float)
602 set_define("MOZ_VORBIS", sample_type_is_float)
603 set_config("MOZ_VORBIS", sample_type_is_float)
604 set_define("MOZ_TREMOR", sample_type_is_s16)
605 set_config("MOZ_TREMOR", sample_type_is_s16)
607 # OpenMAX IL Decoding Support
608 # ==============================================================
609 option("--enable-openmax", help="Enable OpenMAX IL for video/audio decoding")
612 @depends("--enable-openmax")
614 enabled = bool(value)
619 set_config("MOZ_OMX", openmax)
620 set_define("MOZ_OMX", openmax)
623 # ==============================================================
625 def eme_choices(target):
627 target.kernel in ("WINNT", "Linux")
628 and target.os != "Android"
629 and target.cpu in ("x86", "x86_64")
632 if target.kernel == "WINNT" and target.cpu == "aarch64":
634 if target.os in ("OSX"):
638 # Widevine is enabled by default in desktop browser builds, except
639 # on aarch64 Windows.
640 @depends(build_project, eme_choices, target)
641 def eme_default(build_project, choices, target):
642 if build_project == "browser":
643 if target.kernel != "WINNT" or target.cpu != "aarch64":
653 help="{Enable|Disable} support for Encrypted Media Extensions",
657 @depends("--enable-eme", fmp4, when=eme_choices)
658 def eme(enabled, fmp4):
659 if enabled and enabled.origin != "default" and not fmp4:
660 die("Encrypted Media Extension support requires " "Fragmented MP4 support")
663 @depends("--enable-eme", when=eme_choices)
664 def eme_modules(value):
668 # Fallback to an empty list when eme_choices is empty, setting eme_modules to
670 set_config("MOZ_EME_MODULES", eme_modules | dependable([]))
673 @depends(eme_modules, target, when=eme_modules)
674 def eme_win32_artifact(modules, target):
675 if "widevine" in modules and target.kernel == "WINNT" and target.cpu == "aarch64":
679 set_config("MOZ_EME_WIN32_ARTIFACT", eme_win32_artifact)
682 name="--enable-chrome-format",
683 help="Select FORMAT of chrome files during packaging.",
685 choices=("omni", "jar", "flat"),
690 @depends("--enable-chrome-format")
691 def packager_format(value):
695 set_config("MOZ_PACKAGER_FORMAT", packager_format)
698 @depends(host, build_project)
699 def jar_maker_format(host, build_project):
700 # Multilocales for mobile/android use the same mergedirs for all locales,
701 # so we can't use symlinks for those builds.
702 if host.os == "WINNT" or build_project == "mobile/android":
707 set_config("MOZ_JAR_MAKER_FILE_FORMAT", jar_maker_format)
711 def omnijar_name(toolkit):
712 # Fennec's static resources live in the assets/ folder of the
713 # APK. Adding a path to the name here works because we only
714 # have one omnijar file in the final package (which is not the
716 return "assets/omni.ja" if toolkit == "android" else "omni.ja"
719 set_config("OMNIJAR_NAME", omnijar_name)
721 project_flag("MOZ_PLACES", help="Build Places if required", set_as_define=True)
724 "MOZ_SERVICES_HEALTHREPORT",
725 help="Build Firefox Health Reporter Service",
726 set_for_old_configure=True,
732 help="Enable Normandy recipe runner",
733 set_for_old_configure=True,
737 project_flag("MOZ_SERVICES_SYNC", help="Build Sync Services if required")
740 "MOZ_ANDROID_HISTORY",
741 help="Enable Android History instead of Places",
746 "MOZ_DEDICATED_PROFILES",
747 help="Enable dedicated profiles per install",
752 "MOZ_BLOCK_PROFILE_DOWNGRADE",
753 help="Block users from starting profiles last used by a newer build",
758 @depends("MOZ_PLACES", "MOZ_ANDROID_HISTORY")
759 def check_places_and_android_history(places, android_history):
760 if places and android_history:
761 die("Cannot use MOZ_ANDROID_HISTORY alongside MOZ_PLACES.")
765 env="MOZ_TELEMETRY_REPORTING",
766 default=mozilla_official,
767 help="Enable telemetry reporting",
770 set_define("MOZ_TELEMETRY_REPORTING", True, when="MOZ_TELEMETRY_REPORTING")
771 add_old_configure_assignment(
772 "MOZ_TELEMETRY_REPORTING", True, when="MOZ_TELEMETRY_REPORTING"
776 @depends("MOZ_TELEMETRY_REPORTING", milestone.is_nightly)
777 def telemetry_on_by_default(reporting, is_nightly):
778 return reporting and is_nightly
781 set_define("MOZ_TELEMETRY_ON_BY_DEFAULT", True, when=telemetry_on_by_default)
785 # ==============================================================
786 option("--enable-gpsd", env="MOZ_GPSD", help="Enable gpsd support")
789 @depends("--enable-gpsd")
794 system_gpsd = pkg_check_modules("MOZ_GPSD", "libgps >= 3.11", when=gpsd)
796 set_config("MOZ_GPSD", depends_if(system_gpsd)(lambda _: True))
798 # Miscellaneous programs
799 # ==============================================================
801 check_prog("TAR", ("gnutar", "gtar", "tar"))
802 check_prog("UNZIP", ("unzip",))
803 check_prog("ZIP", ("zip",))
804 check_prog("GN", ("gn",), allow_missing=True)
807 # ==============================================================
808 include("../build/moz.configure/keyfiles.configure")
810 simple_keyfile("Mozilla API")
812 simple_keyfile("Google Location Service API")
814 simple_keyfile("Google Safebrowsing API")
816 id_and_secret_keyfile("Bing API")
818 simple_keyfile("Adjust SDK")
820 id_and_secret_keyfile("Leanplum SDK")
822 simple_keyfile("Pocket API")
825 # WebRender Debugger integration
826 # ==============================================================
829 "--enable-webrender-debugger", help="Build the websocket debug server in WebRender"
833 "MOZ_WEBRENDER_DEBUGGER", depends_if("--enable-webrender-debugger")(lambda _: True)
836 # Additional system headers defined at the application level
837 # ==============================================================
840 "--enable-app-system-headers",
841 env="MOZ_APP_SYSTEM_HEADERS",
842 help="Use additional system headers defined in $MOZ_BUILD_APP/app-system-headers.mozbuild",
846 @depends("--enable-app-system-headers")
847 def app_system_headers(value):
852 set_config("MOZ_APP_SYSTEM_HEADERS", app_system_headers)
853 set_define("MOZ_APP_SYSTEM_HEADERS", app_system_headers)
856 # ==============================================================
857 option("--disable-printing", help="Disable printing support")
860 @depends("--disable-printing")
866 set_config("NS_PRINTING", printing)
867 set_define("NS_PRINTING", printing)
868 set_define("NS_PRINT_PREVIEW", printing)
870 # Speech-dispatcher support
871 # ==============================================================
873 def no_speechd_on_non_gtk(toolkit):
879 "--enable-synth-speechd", no_speechd_on_non_gtk, reason="--enable-default-toolkit"
882 option("--disable-synth-speechd", help="Disable speech-dispatcher support")
884 set_config("MOZ_SYNTH_SPEECHD", depends_if("--disable-synth-speechd")(lambda _: True))
887 # ==============================================================
888 option("--disable-webspeech", help="Disable support for HTML Speech API")
891 @depends("--disable-webspeech")
892 def webspeech(value):
897 set_config("MOZ_WEBSPEECH", webspeech)
898 set_define("MOZ_WEBSPEECH", webspeech)
899 add_old_configure_assignment("MOZ_WEBSPEECH", webspeech)
901 # Speech API test backend
902 # ==============================================================
904 "--enable-webspeechtestbackend",
906 help="{Enable|Disable} support for HTML Speech API Test Backend",
910 @depends_if("--enable-webspeechtestbackend")
911 def webspeech_test_backend(value):
915 set_config("MOZ_WEBSPEECH_TEST_BACKEND", webspeech_test_backend)
916 set_define("MOZ_WEBSPEECH_TEST_BACKEND", webspeech_test_backend)
918 # Enable IPDL's "expensive" unit tests
919 # ==============================================================
920 option("--enable-ipdl-tests", help="Enable expensive IPDL tests")
922 set_config("MOZ_IPDL_TESTS", depends_if("--enable-ipdl-tests")(lambda _: True))
925 # ==============================================================
926 option("--disable-skia", help="Disable use of Skia")
929 @depends("--disable-skia")
932 die("--disable-skia is not supported anymore")
937 set_config("MOZ_ENABLE_SKIA", skia)
938 set_define("MOZ_ENABLE_SKIA", skia)
939 set_define("USE_SKIA", skia)
941 option("--enable-skia-pdf", help="Enable Skia PDF")
944 @depends("--enable-skia-pdf", skia, target, milestone)
945 def skia_pdf(value, skia, target, milestone):
946 if value.origin == "default":
949 if milestone.is_nightly and target.os != "WINNT":
951 elif value and not skia:
952 die("Cannot enable Skia PDF without enabling Skia")
957 set_config("MOZ_ENABLE_SKIA_PDF", skia_pdf)
958 set_define("MOZ_ENABLE_SKIA_PDF", skia_pdf)
960 option("--enable-skia-pdf-sfntly", help="Enable SFNTLY font subsetting in Skia PDF")
963 @depends("--enable-skia-pdf-sfntly", skia_pdf)
964 def skia_pdf_sfntly(value, skia_pdf):
965 if value.origin == "default":
967 if value and not skia_pdf:
968 die("Cannot enable SFNTLY subsetting without enabling Skia PDF")
969 if skia_pdf and value:
973 set_config("MOZ_ENABLE_SKIA_PDF_SFNTLY", skia_pdf_sfntly)
974 set_define("MOZ_ENABLE_SKIA_PDF_SFNTLY", skia_pdf_sfntly)
977 @depends(skia_pdf_sfntly)
978 def sfntly_includes(skia_pdf_sfntly):
982 "/gfx/sfntly/cpp/src",
987 set_config("SFNTLY_INCLUDES", sfntly_includes)
991 def skia_includes(skia):
1001 set_config("SKIA_INCLUDES", skia_includes)
1003 option("--with-system-webp", help="Use system libwebp (located with pkgconfig)")
1005 system_webp = pkg_check_modules(
1006 "MOZ_WEBP", "libwebp >= 1.0.2 libwebpdemux >= 1.0.2", when="--with-system-webp"
1009 set_config("MOZ_SYSTEM_WEBP", depends(when=system_webp)(lambda: True))
1011 # Build Freetype in the tree
1012 # ==============================================================
1013 @depends(target, skia_pdf)
1014 def tree_freetype(target, skia_pdf):
1015 if target.os == "Android" or (skia_pdf and target.os == "WINNT"):
1019 set_define("MOZ_TREE_FREETYPE", tree_freetype)
1020 set_config("MOZ_TREE_FREETYPE", tree_freetype)
1021 add_old_configure_assignment("MOZ_TREE_FREETYPE", tree_freetype)
1023 set_define("HAVE_FT_BITMAP_SIZE_Y_PPEM", tree_freetype)
1024 set_define("HAVE_FT_GLYPHSLOT_EMBOLDEN", tree_freetype)
1025 set_define("HAVE_FT_LOAD_SFNT_TABLE", tree_freetype)
1028 @depends(freetype2_combined_info, tree_freetype, check_build_environment)
1029 def ft2_info(freetype2_combined_info, tree_freetype, build_env):
1032 cflags=("-I%s/modules/freetype2/include" % build_env.topsrcdir,), libs=()
1034 if freetype2_combined_info:
1035 return freetype2_combined_info
1038 set_config("FT2_LIBS", ft2_info.libs)
1039 add_old_configure_assignment("FT2_LIBS", ft2_info.libs)
1040 add_old_configure_assignment("FT2_CFLAGS", ft2_info.cflags)
1044 # (partial implementation of Chromium Remote Debugging Protocol)
1045 # ==============================================================
1047 # See https://firefox-source-docs.mozilla.org/remote/ for more.
1048 # The source code lives under ../remote.
1051 @depends(target, build_project)
1052 def remote_default(target, project):
1053 # no support for Android
1054 if target.os == "Android":
1057 # enable for Firefox Desktop only
1058 return project == "browser"
1061 option("--enable-cdp", default=remote_default, help="{Enable|Disable} remote agent")
1064 @depends("--enable-cdp")
1070 set_config("ENABLE_REMOTE_AGENT", remote)
1071 set_define("ENABLE_REMOTE_AGENT", remote)
1074 # Marionette remote protocol
1075 # ==============================================================
1077 # Marionette is the Gecko remote protocol used for various remote control,
1078 # automation, and testing purposes throughout Gecko, Firefox, and Fennec.
1079 # Marionette lives in ../testing/marionette.
1081 # Marionette is not really a toolkit feature, as much as a Gecko
1082 # engine feature. But it is enabled based on the toolkit, so here it
1085 # It also backs ../testing/geckodriver, which is Mozilla's WebDriver
1088 # For more information, see
1089 # https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette.
1091 option("--disable-marionette", help="Disable Marionette remote protocol")
1094 @depends("--disable-marionette")
1095 def marionette(value):
1100 set_config("ENABLE_MARIONETTE", marionette)
1101 set_define("ENABLE_MARIONETTE", marionette)
1103 # geckodriver WebDriver implementation
1104 # ==============================================================
1106 # Turn off geckodriver for build configs we don't handle yet,
1107 # but allow --enable-geckodriver to override when compile environment is available.
1108 # --disable-tests implies disabling geckodriver.
1109 # Disable building in CI
1113 "--enable-tests", target, cross_compiling, hazard_analysis, asan, "MOZ_AUTOMATION"
1115 def geckodriver_default(enable_tests, target, cross_compile, hazard, asan, automation):
1116 if not enable_tests:
1118 # geckodriver depends on winapi 0.2.8, which doesn't work with AArch64.
1119 if target.os == "WINNT" and target.cpu == "aarch64":
1121 if hazard or target.os == "Android" or (asan and cross_compile):
1129 "--enable-geckodriver",
1130 default=geckodriver_default,
1131 when="--enable-compile-environment",
1132 help="{Build|Do not build} geckodriver",
1136 @depends("--enable-geckodriver", when="--enable-compile-environment")
1137 def geckodriver(enabled):
1142 set_config("MOZ_GECKODRIVER", geckodriver)
1146 # ========================================================
1148 def webrtc_default(target):
1149 # Turn off webrtc for OS's we don't handle yet, but allow
1150 # --enable-webrtc to override.
1152 for os_fragment in (
1163 if target.raw_os.startswith(os_fragment):
1178 or target.cpu.startswith("ppc")
1182 if os_match and cpu_match:
1189 default=webrtc_default,
1190 help="{Enable|Disable} support for WebRTC",
1194 @depends("--disable-webrtc")
1195 def webrtc(enabled):
1200 set_config("MOZ_WEBRTC", webrtc)
1201 set_define("MOZ_WEBRTC", webrtc)
1202 add_old_configure_assignment("MOZ_WEBRTC", webrtc)
1203 set_config("MOZ_SCTP", webrtc)
1204 set_define("MOZ_SCTP", webrtc)
1205 set_config("MOZ_SRTP", webrtc)
1206 set_define("MOZ_SRTP", webrtc)
1207 set_config("MOZ_WEBRTC_SIGNALING", webrtc)
1208 set_define("MOZ_WEBRTC_SIGNALING", webrtc)
1209 set_config("MOZ_PEERCONNECTION", webrtc)
1210 set_define("MOZ_PEERCONNECTION", webrtc)
1211 # MOZ_WEBRTC_ASSERT_ALWAYS turns on a number of safety asserts in
1212 # opt/production builds (via MOZ_CRASH())
1213 set_config("MOZ_WEBRTC_ASSERT_ALWAYS", webrtc)
1214 set_define("MOZ_WEBRTC_ASSERT_ALWAYS", webrtc)
1217 # ==============================================================
1220 @depends(target, webrtc)
1221 def raw_media_default(target, webrtc):
1222 if target.os == "Android":
1230 default=raw_media_default,
1231 help="{Enable|Disable} support for RAW media",
1234 set_config("MOZ_RAW", depends_if("--enable-raw")(lambda _: True))
1235 set_define("MOZ_RAW", depends_if("--enable-raw")(lambda _: True))
1237 # ASan Reporter Addon
1238 # ==============================================================
1240 "--enable-address-sanitizer-reporter",
1241 help="Enable Address Sanitizer Reporter Extension",
1245 @depends("--enable-address-sanitizer-reporter")
1246 def enable_asan_reporter(value):
1251 set_config("MOZ_ASAN_REPORTER", enable_asan_reporter)
1252 set_define("MOZ_ASAN_REPORTER", enable_asan_reporter)
1253 add_old_configure_assignment("MOZ_ASAN_REPORTER", enable_asan_reporter)
1256 # ==============================================================
1257 with only_when("--enable-compile-environment"):
1259 @depends(host, target)
1260 def has_elfhack(host, target):
1262 target.kernel == "Linux"
1263 and host.kernel == "Linux"
1264 and target.cpu in ("arm", "x86", "x86_64")
1267 @depends("--enable-release", enable_linker)
1268 def default_elfhack(release, linker):
1269 # Disable elfhack when explicitly building with --enable-linker=lld
1270 if linker and linker.origin != "default" and linker[0] == "lld":
1272 return bool(release)
1274 with only_when(has_elfhack):
1276 "--disable-elf-hack",
1277 default=default_elfhack,
1278 help="{Enable|Disable} elf hacks",
1281 set_config("USE_ELF_HACK", depends_if("--enable-elf-hack")(lambda _: True))
1284 @depends(check_build_environment)
1285 def idl_roots(build_env):
1287 ipdl_root=os.path.join(build_env.topobjdir, "ipc", "ipdl"),
1288 webidl_root=os.path.join(build_env.topobjdir, "dom", "bindings"),
1289 xpcom_root=os.path.join(build_env.topobjdir, "xpcom", "components"),
1293 set_config("WEBIDL_ROOT", idl_roots.webidl_root)
1294 set_config("IPDL_ROOT", idl_roots.ipdl_root)
1295 set_config("XPCOM_ROOT", idl_roots.xpcom_root)
1297 # Proxy bypass protection
1298 # ==============================================================
1301 "--enable-proxy-bypass-protection",
1302 help="Prevent suspected or confirmed proxy bypasses",
1306 @depends_if("--enable-proxy-bypass-protection")
1307 def proxy_bypass_protection(_):
1311 set_config("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1312 set_define("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1315 # ==============================================================
1318 @depends(c_compiler, toolchain_prefix)
1319 def midl_names(c_compiler, toolchain_prefix):
1320 if c_compiler and c_compiler.type in ["gcc", "clang"]:
1323 if toolchain_prefix:
1324 prefixed = tuple("%s%s" % (p, "widl") for p in toolchain_prefix)
1325 widl = prefixed + widl
1328 return ("midl.exe",)
1331 @depends(target, "--enable-compile-environment")
1332 def check_for_midl(target, compile_environment):
1333 if target.os != "WINNT":
1336 if compile_environment:
1341 "MIDL", midl_names, when=check_for_midl, allow_missing=True, paths=sdk_bin_path
1344 option(env="MIDL_FLAGS", nargs=1, help="Extra flags to pass to MIDL")
1353 when=depends(midl, target)(lambda m, t: m and t.kernel == "WINNT"),
1355 def midl_flags(flags, c_compiler, target, host, midl):
1357 flags = flags[0].split()
1361 if not midl.endswith("widl"):
1367 flags += ["-env", env]
1369 if host.os == "WINNT":
1370 return flags + ["-cpp_cmd", c_compiler.compiler]
1372 # If cross-compiling and using midl instead of widl, for now, we'll
1373 # assume we can find the Windows version of clang-cl in the PATH.
1374 # It is required because while Wine is able to spawn Linux
1375 # processes from Windows programs(!), the calling program doesn't
1376 # have access to the process output and can't wait for it to
1377 # finish. Midl runs clang-cl as a preprocessor and expects to read
1379 clang_cl_exe = find_program("clang-cl.exe")
1380 if not clang_cl_exe:
1381 die("Cannot find clang-cl.exe")
1382 return flags + ["-cpp_cmd", clang_cl_exe]
1386 "x86": ["--win32", "-m32"],
1387 "x86_64": ["--win64", "-m64"],
1391 set_config("MIDL_FLAGS", midl_flags)
1394 # ==============================================================
1396 option("--disable-accessibility", help="Disable accessibility support")
1399 @depends("--enable-accessibility", check_for_midl, midl, c_compiler)
1400 def accessibility(value, check_for_midl, midl, c_compiler):
1401 enabled = bool(value)
1406 if check_for_midl and not midl:
1407 if c_compiler and c_compiler.type in ("gcc", "clang"):
1409 "You have accessibility enabled, but widl could not be found. "
1410 "Add --disable-accessibility to your mozconfig or install widl. "
1411 "See https://developer.mozilla.org/en-US/docs/Cross_Compile_Mozilla_for_Mingw32 for details."
1415 "MIDL could not be found. "
1416 "Building accessibility without MIDL is not supported."
1422 set_config("ACCESSIBILITY", accessibility)
1423 set_define("ACCESSIBILITY", accessibility)
1424 add_old_configure_assignment("ACCESSIBILITY", accessibility)
1427 # ==============================================================
1430 "--with-unsigned-addon-scopes",
1432 choices=("app", "system"),
1433 help="Addon scopes where signature is not required",
1437 @depends("--with-unsigned-addon-scopes")
1438 def unsigned_addon_scopes(scopes):
1440 app="app" in scopes or None,
1441 system="system" in scopes or None,
1445 set_config("MOZ_UNSIGNED_APP_SCOPE", unsigned_addon_scopes.app)
1446 set_config("MOZ_UNSIGNED_SYSTEM_SCOPE", unsigned_addon_scopes.system)
1449 # ==============================================================
1452 @depends(update_channel)
1453 def addon_sideload_allowed_default(update_channel):
1454 if update_channel == "esr":
1459 "--allow-addon-sideload",
1460 default=addon_sideload_allowed_default,
1461 help="Addon sideloading is allowed",
1465 @depends("--allow-addon-sideload")
1466 def addon_sideload_allowed(value):
1467 allowed = bool(value)
1472 set_config("MOZ_ALLOW_ADDON_SIDELOAD", addon_sideload_allowed)
1474 # Launcher process (Windows only)
1475 # ==============================================================
1479 def launcher_process_default(target):
1480 return target.os == "WINNT"
1484 "--enable-launcher-process",
1485 default=launcher_process_default,
1486 help="{Enable|Disable} launcher process by default",
1490 @depends("--enable-launcher-process", target)
1491 def launcher(value, target):
1492 enabled = bool(value)
1493 if enabled and target.os != "WINNT":
1494 die("Cannot enable launcher process on %s", target.os)
1499 set_config("MOZ_LAUNCHER_PROCESS", launcher)
1500 set_define("MOZ_LAUNCHER_PROCESS", launcher)
1502 # llvm-dlltool (Windows only)
1503 # ==============================================================
1506 @depends(build_project, target, "--enable-compile-environment")
1507 def check_for_llvm_dlltool(build_project, target, compile_environment):
1508 if build_project != "browser":
1511 if target.os != "WINNT":
1514 return compile_environment
1517 llvm_dlltool = check_prog(
1520 what="llvm-dlltool",
1521 when=check_for_llvm_dlltool,
1522 paths=clang_search_path,
1526 @depends(target, when=llvm_dlltool)
1527 def llvm_dlltool_flags(target):
1530 "x86_64": "i386:x86-64",
1537 set_config("LLVM_DLLTOOL_FLAGS", llvm_dlltool_flags)
1539 # BITS download (Windows only)
1540 # ==============================================================
1543 "--enable-bits-download",
1544 when=target_is_windows,
1545 default=target_is_windows,
1546 help="{Enable|Disable} building BITS download support",
1550 "MOZ_BITS_DOWNLOAD",
1551 depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
1554 "MOZ_BITS_DOWNLOAD",
1555 depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
1558 # Bundled fonts on desktop platform
1559 # ==============================================================
1563 def bundled_fonts_default(target):
1564 return target.os == "WINNT" or target.kernel == "Linux"
1567 @depends(build_project)
1568 def allow_bundled_fonts(project):
1569 return project == "browser" or project == "comm/mail"
1573 "--enable-bundled-fonts",
1574 default=bundled_fonts_default,
1575 when=allow_bundled_fonts,
1576 help="{Enable|Disable} support for bundled fonts on desktop platforms",
1580 "MOZ_BUNDLED_FONTS",
1581 depends_if("--enable-bundled-fonts", when=allow_bundled_fonts)(lambda _: True),
1585 # ==============================================================
1587 option("--enable-tasktracer", help="Enable TaskTracer")
1589 set_define("MOZ_TASK_TRACER", depends_if("--enable-tasktracer")(lambda _: True))
1590 set_config("MOZ_TASK_TRACER", depends_if("--enable-tasktracer")(lambda _: True))
1593 # ==============================================================
1597 def reflow_perf(debug):
1603 "--enable-reflow-perf",
1604 default=reflow_perf,
1605 help="{Enable|Disable} reflow performance tracing",
1608 # The difference in conditions here comes from the initial implementation
1609 # in old-configure, which was unexplained there as well.
1610 set_define("MOZ_REFLOW_PERF", depends_if("--enable-reflow-perf")(lambda _: True))
1611 set_define("MOZ_REFLOW_PERF_DSP", reflow_perf)
1614 # ==============================================================
1618 def layout_debugger(debug):
1624 "--enable-layout-debugger",
1625 default=layout_debugger,
1626 help="{Enable|Disable} layout debugger",
1629 set_config("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
1630 set_define("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
1633 # Shader Compiler for Windows (and MinGW Cross Compile)
1634 # ==============================================================
1636 with only_when(compile_environment):
1639 ("fxc.exe", "fxc2.exe"),
1640 when=depends(target)(lambda t: t.kernel == "WINNT"),
1648 with only_when(compile_environment):
1649 option("--with-system-libvpx", help="Use system libvpx (located with pkgconfig)")
1651 with only_when("--with-system-libvpx"):
1652 vpx = pkg_check_modules("MOZ_LIBVPX", "vpx >= 1.8.0")
1655 "vpx/vpx_decoder.h",
1657 onerror=lambda: die(
1658 "Couldn't find vpx/vpx_decoder.h, which is required to build "
1659 "with system libvpx. Use --without-system-libvpx to build "
1660 "with in-tree libvpx."
1665 "vpx_codec_dec_init_ver",
1667 onerror=lambda: die(
1668 "--with-system-libvpx requested but symbol vpx_codec_dec_init_ver "
1673 set_config("MOZ_SYSTEM_LIBVPX", True)
1675 @depends("--with-system-libvpx", target)
1676 def in_tree_vpx(system_libvpx, target):
1680 arm_asm = (target.cpu == "arm") or None
1681 return namespace(arm_asm=arm_asm)
1683 @depends(target, when=in_tree_vpx)
1684 def vpx_nasm(target):
1685 if target.cpu in ("x86", "x86_64"):
1686 if target.kernel == "WINNT":
1687 # Version 2.03 is needed for automatic safeseh support.
1688 return namespace(version="2.03", what="VPX")
1689 return namespace(what="VPX")
1691 # Building with -mfpu=neon requires either the "softfp" or the
1692 # "hardfp" ABI. Depending on the compiler's default target, and the
1693 # CFLAGS, the default ABI might be neither, in which case it is the
1695 # The "softfloat" ABI is binary-compatible with the "softfp" ABI, so
1696 # we can safely mix code built with both ABIs. So, if we detect
1697 # that compiling uses the "softfloat" ABI, force the use of the
1698 # "softfp" ABI instead.
1699 # Confusingly, the __SOFTFP__ preprocessor variable indicates the
1700 # "softfloat" ABI, not the "softfp" ABI.
1701 # Note: VPX_ASFLAGS is also used in CFLAGS.
1702 softfp = cxx_compiler.try_compile(
1705 #error "compiler target supports -mfpu=neon, so we don't have to add extra flags"
1707 when=in_tree_vpx.arm_asm,
1710 @depends(in_tree_vpx, vpx_nasm, softfp, target)
1711 def vpx_as_flags(vpx, vpx_nasm, softfp, target):
1713 if vpx and vpx.arm_asm:
1714 # These flags are a lie; they're just used to enable the requisite
1715 # opcodes; actual arch detection is done at runtime.
1716 flags = ["-march=armv7-a", "-mfpu=neon"]
1718 flags.append("-mfloat-abi=softfp")
1719 elif vpx and vpx_nasm and target.os != "WINNT" and target.cpu != "x86_64":
1723 set_config("VPX_USE_NASM", True, when=vpx_nasm)
1724 set_config("VPX_ASFLAGS", vpx_as_flags)
1730 with only_when(compile_environment):
1732 "--with-system-jpeg",
1734 help="Use system libjpeg (installed at given prefix)",
1737 @depends_if("--with-system-jpeg")
1738 def jpeg_flags(value):
1741 cflags=("-I%s/include" % value[0],),
1742 ldflags=("-L%s/lib" % value[0], "-ljpeg"),
1745 ldflags=("-ljpeg",),
1748 with only_when("--with-system-jpeg"):
1750 "jpeg_destroy_compress",
1751 flags=jpeg_flags.ldflags,
1752 onerror=lambda: die(
1753 "--with-system-jpeg requested but symbol "
1754 "jpeg_destroy_compress not found."
1758 c_compiler.try_compile(
1765 #if JPEG_LIB_VERSION < 62
1766 #error Insufficient JPEG library version
1769 flags=jpeg_flags.cflags,
1770 check_msg="for sufficient jpeg library version",
1771 onerror=lambda: die(
1772 "Insufficient JPEG library version for "
1773 "--with-system-jpeg (62 required)"
1777 c_compiler.try_compile(
1784 #ifndef JCS_EXTENSIONS
1785 #error libjpeg-turbo JCS_EXTENSIONS required
1788 flags=jpeg_flags.cflags,
1789 check_msg="for sufficient libjpeg-turbo JCS_EXTENSIONS",
1790 onerror=lambda: die(
1791 "libjpeg-turbo JCS_EXTENSIONS required for " "--with-system-jpeg"
1795 set_config("MOZ_JPEG_CFLAGS", jpeg_flags.cflags)
1796 set_config("MOZ_JPEG_LIBS", jpeg_flags.ldflags)
1798 @depends("--with-system-jpeg", target)
1799 def in_tree_jpeg(system_jpeg, target):
1803 if target.kernel == "Darwin":
1804 if target.cpu == "x86":
1805 return ("-DPIC", "-DMACHO")
1806 elif target.cpu == "x86_64":
1807 return ("-D__x86_64__", "-DPIC", "-DMACHO")
1808 elif target.kernel == "WINNT":
1809 if target.cpu == "x86":
1810 return ("-DPIC", "-DWIN32")
1811 elif target.cpu == "x86_64":
1812 return ("-D__x86_64__", "-DPIC", "-DWIN64", "-DMSVC")
1813 elif target.cpu == "arm":
1814 return ("-march=armv7-a", "-mfpu=neon")
1815 elif target.cpu == "aarch64":
1816 return ("-march=armv8-a",)
1817 elif target.cpu == "mips32":
1819 elif target.cpu == "x86":
1820 return ("-DPIC", "-DELF")
1821 elif target.cpu == "x86_64":
1822 return ("-D__x86_64__", "-DPIC", "-DELF")
1824 @depends(target, when=in_tree_jpeg)
1825 def jpeg_nasm(target):
1826 if target.cpu in ("x86", "x86_64"):
1827 # libjpeg-turbo 2.0.6 requires nasm 2.10.
1828 return namespace(version="2.10", what="JPEG")
1830 set_config("LIBJPEG_TURBO_USE_NASM", True, when=jpeg_nasm)
1831 set_config("LIBJPEG_TURBO_ASFLAGS", in_tree_jpeg)
1834 # FFmpeg's ffvpx configuration
1835 # ==============================================================
1836 with only_when(compile_environment):
1839 def libav_fft(target):
1840 return target.kernel == "WINNT" or target.cpu == "x86_64"
1842 set_config("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
1843 set_define("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
1846 # Artifact builds need MOZ_FFVPX defined as if compilation happened.
1847 with only_when(compile_environment | artifact_builds):
1851 enable = use_nasm = True
1855 if target.kernel == "WINNT":
1856 if target.cpu == "x86":
1857 # 32-bit windows need to prefix symbols with an underscore.
1858 flags = ["-DPIC", "-DWIN32", "-DPREFIX", "-Pconfig_win32.asm"]
1859 elif target.cpu == "x86_64":
1865 "-Pconfig_win64.asm",
1867 elif target.cpu == "aarch64":
1868 flags = ["-DPIC", "-DWIN64"]
1870 elif target.kernel == "Darwin":
1871 if target.cpu == "x86_64":
1872 # 32/64-bit macosx asemblers need to prefix symbols with an
1879 "-Pconfig_darwin64.asm",
1883 elif target.cpu == "x86_64":
1884 flags = ["-D__x86_64__", "-DPIC", "-DELF", "-Pconfig_unix64.asm"]
1885 elif target.cpu in ("x86", "arm", "aarch64"):
1890 if flac_only or not enable:
1894 # default disabled components
1895 flags.append("-Pdefaults_disabled.asm")
1900 flac_only=flac_only,
1904 @depends(when=ffvpx.use_nasm)
1906 # nasm 2.10 for AVX-2 support.
1907 return namespace(version="2.10", what="FFVPX")
1909 # ffvpx_nasm can't indirectly depend on vpx_as_flags, because it depends
1910 # on a compiler test, so we have to do a little bit of dance here.
1911 @depends(ffvpx, vpx_as_flags, target)
1912 def ffvpx(ffvpx, vpx_as_flags, target):
1913 if ffvpx and vpx_as_flags and target.cpu in ("arm", "aarch64"):
1914 ffvpx.flags.extend(vpx_as_flags)
1917 set_config("MOZ_FFVPX", True, when=ffvpx.enable)
1918 set_define("MOZ_FFVPX", True, when=ffvpx.enable)
1919 set_config("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.flac_only)
1920 set_define("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.flac_only)
1921 set_config("FFVPX_ASFLAGS", ffvpx.flags)
1922 set_config("FFVPX_USE_NASM", True, when=ffvpx.use_nasm)
1926 # ==============================================================
1927 @depends(dav1d_nasm, vpx_nasm, jpeg_nasm, ffvpx_nasm, when=compile_environment)
1928 def need_nasm(*requirements):
1930 x.what: x.version if hasattr(x, "version") else True for x in requirements if x
1933 items = sorted(requires.keys())
1935 what = " and ".join((", ".join(items[:-1]), items[-1]))
1938 versioned = {k: v for (k, v) in requires.items() if v is not True}
1939 return namespace(what=what, versioned=versioned)
1951 @depends(nasm, need_nasm.what)
1952 def check_nasm(nasm, what):
1953 if not nasm and what:
1954 die("Nasm is required to build with %s, but it was not found." % what)
1958 @depends_if(check_nasm)
1959 @checking("nasm version")
1960 def nasm_version(nasm):
1962 check_cmd_output(nasm, "-v", onerror=lambda: die("Failed to get nasm version."))
1966 return Version(version)
1969 @depends(nasm_version, need_nasm.versioned, when=need_nasm.versioned)
1970 def check_nasm_version(nasm_version, versioned):
1971 by_version = sorted(versioned.items(), key=lambda x: x[1])
1972 what, version = by_version[-1]
1973 if nasm_version < version:
1975 "Nasm version %s or greater is required to build with %s." % (version, what)
1980 @depends(target, when=check_nasm_version)
1981 def nasm_asflags(target):
1983 ("OSX", "x86"): ["-f", "macho32"],
1984 ("OSX", "x86_64"): ["-f", "macho64"],
1985 ("WINNT", "x86"): ["-f", "win32"],
1986 ("WINNT", "x86_64"): ["-f", "win64"],
1987 }.get((target.os, target.cpu), None)
1989 # We're assuming every x86 platform we support that's
1990 # not Windows or Mac is ELF.
1991 if target.cpu == "x86":
1992 asflags = ["-f", "elf32"]
1993 elif target.cpu == "x86_64":
1994 asflags = ["-f", "elf64"]
1998 set_config("NASM_ASFLAGS", nasm_asflags)
2001 # ANGLE OpenGL->D3D translator for WebGL
2002 # ==============================================================
2004 with only_when(compile_environment & target_is_windows):
2006 def d3d_compiler_dll_result(value):
2008 return "provided by the OS"
2011 @depends(target, valid_windows_sdk_dir, fxc)
2012 @checking("for D3D compiler DLL", d3d_compiler_dll_result)
2014 def d3d_compiler_dll(target, windows_sdk_dir, fxc):
2017 }.get(target.cpu, target.cpu)
2019 name = "d3dcompiler_47.dll"
2021 if target.cpu == "aarch64":
2022 # AArch64 Windows comes with d3dcompiler_47.dll installed
2023 return namespace(name=name, path=None)
2026 path = os.path.join(windows_sdk_dir.path, "Redist", "D3D", suffix, name)
2027 error_extra = "in Windows SDK at {}".format(windows_sdk_dir.path)
2029 path = os.path.join(os.path.dirname(fxc), name)
2030 error_extra = "alongside FXC at {}".format(fxc)
2032 if os.path.exists(path):
2033 return namespace(name=name, path=path)
2034 die("Could not find {} {}".format(name, error_extra))
2036 set_config("MOZ_ANGLE_RENDERER", True)
2038 "MOZ_D3DCOMPILER_VISTA_DLL", d3d_compiler_dll.name, when=d3d_compiler_dll.path
2040 set_config("MOZ_D3DCOMPILER_VISTA_DLL_PATH", d3d_compiler_dll.path)
2042 # Remoting protocol support
2043 # ==============================================================
2047 def has_remote(toolkit):
2048 if toolkit in ("gtk", "windows", "cocoa"):
2052 set_config("MOZ_HAS_REMOTE", has_remote)
2053 set_define("MOZ_HAS_REMOTE", has_remote)
2055 # RLBox Library Sandboxing wasm support
2056 # ==============================================================
2059 def wasm_sandboxing_libraries():
2068 "--with-wasm-sandboxed-libraries",
2069 env="WASM_SANDBOXED_LIBRARIES",
2070 help="Enable wasm sandboxing for the selected libraries",
2072 choices=dependable(wasm_sandboxing_libraries),
2076 @depends("--with-wasm-sandboxed-libraries")
2077 def requires_wasm_sandboxing(libraries):
2082 set_config("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
2083 set_define("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
2085 with only_when(requires_wasm_sandboxing & compile_environment):
2086 lucetc = check_prog("LUCETC", ["lucetc"], bootstrap="lucetc")
2089 "--with-wasi-sysroot",
2092 help="Path to wasi sysroot for wasm sandboxing",
2095 @depends("--with-wasi-sysroot", toolchains_base_dir)
2097 def wasi_sysroot(wasi_sysroot, toolchains_base_dir):
2098 if not wasi_sysroot:
2099 sysroot = os.path.join(
2100 toolchains_base_dir, "wasi-sysroot", "share", "wasi-sysroot"
2102 if os.path.isdir(sysroot):
2105 "Cannot find a wasi sysroot. Install the sysroot at %s or set "
2106 "--with-wasi-sysroot." % sysroot
2109 wasi_sysroot = wasi_sysroot[0]
2110 if not os.path.isdir(wasi_sysroot):
2111 die("Argument to --with-wasi-sysroot must be a directory")
2112 if not os.path.isabs(wasi_sysroot):
2113 die("Argument to --with-wasi-sysroot must be an absolute path")
2117 set_config("WASI_SYSROOT", wasi_sysroot)
2119 def wasm_compiler_with_flags(
2120 wasm_compiler, provided_wasm_compiler, sysroot, compiler_wrapper
2124 if provided_wasm_compiler:
2126 list(compiler_wrapper or [])
2127 + provided_wasm_compiler.wrapper
2128 + [provided_wasm_compiler.program]
2129 + provided_wasm_compiler.flags
2130 + ["--sysroot=%s" % sysroot]
2134 list(compiler_wrapper or [])
2136 + ["--target=wasm32-wasi", "--sysroot=%s" % sysroot]
2139 option(env="WASM_CC", nargs=1, help="Path to the C->WASM compiler")
2140 provided_wasm_cc = provided_program("WASM_CC")
2141 wasm_cc = check_prog(
2144 input=provided_wasm_cc.program,
2145 paths=clang_search_path,
2147 what="the C->WASM compiler",
2150 @depends(wasm_cc, provided_wasm_cc, wasi_sysroot, compiler_wrapper)
2151 def wasm_cc_with_flags(wasm_cc, provided_wasm_cc, wasi_sysroot, compiler_wrapper):
2152 return wasm_compiler_with_flags(
2153 wasm_cc, provided_wasm_cc, wasi_sysroot, compiler_wrapper
2156 set_config("WASM_CC", wasm_cc_with_flags)
2158 option(env="WASM_CXX", nargs=1, help="Path to the C++->WASM compiler")
2159 provided_wasm_cxx = provided_program("WASM_CXX")
2160 wasm_cxx = check_prog(
2163 input=provided_wasm_cxx.program,
2164 paths=clang_search_path,
2166 what="the C++->WASM compiler",
2169 @depends(wasm_cxx, provided_wasm_cxx, wasi_sysroot, compiler_wrapper)
2170 def wasm_cxx_with_flags(
2171 wasm_cxx, provided_wasm_cxx, wasi_sysroot, compiler_wrapper
2173 return wasm_compiler_with_flags(
2174 wasm_cxx, provided_wasm_cxx, wasi_sysroot, compiler_wrapper
2177 set_config("WASM_CXX", wasm_cxx_with_flags)
2179 wasm_compile_flags = dependable(
2180 ["-fno-exceptions", "-fno-strict-aliasing", "-Qunused-arguments"]
2182 option(env="WASM_CFLAGS", nargs=1, help="Options to pass to WASM_CC")
2184 @depends("WASM_CFLAGS", wasm_compile_flags)
2185 def wasm_cflags(value, wasm_compile_flags):
2187 return wasm_compile_flags + value
2189 return wasm_compile_flags
2191 set_config("WASM_CFLAGS", wasm_cflags)
2193 option(env="WASM_CXXFLAGS", nargs=1, help="Options to pass to WASM_CXX")
2195 @depends("WASM_CXXFLAGS", wasm_compile_flags)
2196 def wasm_cxxflags(value, wasm_compile_flags):
2198 return wasm_compile_flags + value
2200 return wasm_compile_flags
2202 set_config("WASM_CXXFLAGS", wasm_cxxflags)
2205 env="WASM_LDFLAGS", nargs=1, help="Options to pass when linking wasm modules"
2208 @depends("WASM_LDFLAGS")
2209 def wasm_ldflags(value):
2213 set_config("WASM_LDFLAGS", wasm_ldflags)
2215 # This function is returning "ldflags" that lucetc will use when invoking
2216 # the linker, but really lucetc is going to be invoking the compiler, since
2217 # the compiler handles lots of details for us (like finding the linker in
2218 # cross-compilation scenarios).
2220 def lucetc_ldflags(target):
2221 if target.kernel == "Linux":
2227 if target.kernel == "Darwin":
2231 "-Wl,-export_dynamic",
2232 "-Wl,-undefined,dynamic_lookup",
2236 set_config("LUCETC_LDFLAGS", lucetc_ldflags)
2238 # Re-using the Rust target triple here is not exactly correct, but it is an
2239 # excellent approximation for the platforms we currently support
2240 set_config("LUCETC_TARGET", rust_target_triple)
2243 @depends("--with-wasm-sandboxed-libraries", target)
2244 def wasm_sandboxing(libraries, target):
2248 # Wasm sandboxing is only enabled on specific targets.
2250 target.cpu in ("x86_64",)
2251 and (target.kernel == "Linux" and target.os != "Android")
2252 or target.kernel == "Darwin"
2254 die("wasm sandboxing is only enabled on x86-64 Linux and Mac")
2256 return namespace(**{name: True for name in libraries})
2260 def wasm_sandboxing_config_defines():
2261 for lib in wasm_sandboxing_libraries():
2263 "MOZ_WASM_SANDBOXING_%s" % lib.upper(), getattr(wasm_sandboxing, lib)
2266 "MOZ_WASM_SANDBOXING_%s" % lib.upper(), getattr(wasm_sandboxing, lib)
2270 wasm_sandboxing_config_defines()
2273 # new XULStore implementation
2274 # ==============================================================
2278 def new_xulstore(milestone):
2279 if milestone.is_nightly:
2283 set_config("MOZ_NEW_XULSTORE", True, when=new_xulstore)
2284 set_define("MOZ_NEW_XULSTORE", True, when=new_xulstore)
2287 # new Notification Store implementation
2288 # ==============================================================
2292 def new_notification_store(milestone):
2293 if milestone.is_nightly:
2297 set_config("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)
2298 set_define("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)
2301 # Glean SDK Integration Crate
2302 # ==============================================================
2306 def glean_android(target):
2307 return target.os == "Android"
2310 set_config("MOZ_GLEAN_ANDROID", True, when=glean_android)
2311 set_define("MOZ_GLEAN_ANDROID", True, when=glean_android)
2314 # New Firefox Accounts client implemented in Rust
2315 # ===============================================
2318 @depends(milestone, target)
2319 def rust_fxa_client(milestone, target):
2320 if milestone.is_nightly and target.os != "Android":
2324 set_config("MOZ_RUST_FXA_CLIENT", True, when=rust_fxa_client)
2325 set_define("MOZ_RUST_FXA_CLIENT", True, when=rust_fxa_client)
2329 # ==============================================================
2335 bootstrap="dump_syms",
2336 when=compile_environment,
2345 when=compile_environment & target_is_windows,
2349 @depends("MOZ_AUTOMATION", c_compiler)
2350 def allow_missing_winchecksec(automation, c_compiler):
2353 if c_compiler and c_compiler.type != "clang-cl":
2359 ["winchecksec.exe", "winchecksec"],
2360 bootstrap="winchecksec",
2361 allow_missing=allow_missing_winchecksec,
2362 when=compile_environment & target_is_windows,
2366 @depends(target, build_project)
2367 def forkserver_default(target, build_project):
2368 return build_project == "browser" and (
2369 (target.os == "GNU" and target.kernel == "Linux") or target.os == "FreeBSD"
2374 "--enable-forkserver",
2375 default=forkserver_default,
2376 env="MOZ_ENABLE_FORKSERVER",
2377 help="{Enable|Disable} fork server",
2381 @depends("--enable-forkserver", target)
2382 def forkserver_flag(value, target):
2384 target.os == "Android"
2385 or (target.os == "GNU" and target.kernel == "Linux")
2386 or target.os == "FreeBSD"
2392 set_config("MOZ_ENABLE_FORKSERVER", forkserver_flag)
2393 set_define("MOZ_ENABLE_FORKSERVER", forkserver_flag, forkserver_flag)
2396 # ==============================================================
2398 with only_when(compile_environment & target_is_linux):
2399 # Check if we need to use the breakpad_getcontext fallback.
2400 getcontext = check_symbol("getcontext")
2401 set_config("HAVE_GETCONTEXT", getcontext)
2402 set_define("HAVE_GETCONTEXT", getcontext)
2405 # ==============================================================
2406 include("../build/moz.configure/nss.configure")
2409 # Enable or disable running in background task mode: headless for
2410 # periodic, short-lived, maintenance tasks.
2411 # ==============================================================================
2415 "--disable-backgroundtasks",
2416 help="Disable running in background task mode",
2421 "MOZ_BACKGROUNDTASKS", depends_if("--enable-backgroundtasks")(lambda _: True)
2425 # Update-related programs: updater, maintenance service, update agent,
2426 # default browser agent.
2427 # ==============================================================
2428 include("../build/moz.configure/update-programs.configure")
2431 # Mobile optimizations
2432 # ==============================================================
2434 "--enable-mobile-optimize",
2435 default=target_is_android,
2436 help="{Enable|Disable} mobile optimizations",
2439 set_define("MOZ_GFX_OPTIMIZE_MOBILE", True, when="--enable-mobile-optimize")
2440 # We ignore "paint will resample" on mobile for performance.
2441 # We may want to revisit this later.
2442 set_define("MOZ_IGNORE_PAINT_WILL_RESAMPLE", True, when="--enable-mobile-optimize")
2445 # ==============================================================
2446 option("--disable-pref-extensions", help="Disable pref extensions such as autoconfig")
2447 set_config("MOZ_PREF_EXTENSIONS", True, when="--enable-pref-extensions")
2449 # Offer a way to disable the startup cache
2450 # ==============================================================
2451 option("--disable-startupcache", help="Disable startup cache")
2454 @depends("--enable-startupcache")
2455 def enable_startupcache(value):
2461 "MOZ_DISABLE_STARTUPCACHE", True, when=depends(enable_startupcache)(lambda x: not x)
2466 # ==============================================================
2468 env="MOZ_APP_REMOTINGNAME",
2470 help="Used for the internal program name, which affects profile name "
2471 "and remoting. If not set, defaults to MOZ_APP_NAME.",
2475 @depends("MOZ_APP_REMOTINGNAME", moz_app_name)
2476 def moz_app_remotingname(value, moz_app_name):
2482 set_config("MOZ_APP_REMOTINGNAME", moz_app_remotingname)
2485 env="ANDROID_PACKAGE_NAME",
2487 help="Name of the Android package (default org.mozilla.$MOZ_APP_NAME)",
2491 @depends("ANDROID_PACKAGE_NAME", moz_app_name)
2492 def android_package_name(value, moz_app_name):
2495 if moz_app_name == "fennec":
2496 return "org.mozilla.fennec_aurora"
2497 return "org.mozilla.%s" % moz_app_name
2500 set_config("ANDROID_PACKAGE_NAME", android_package_name)
2503 # Miscellaneous options
2504 # ==============================================================
2505 option(env="MOZ_WINCONSOLE", nargs="?", help="Whether we can create a console window.")
2506 set_define("MOZ_WINCONSOLE", True, when=depends("MOZ_WINCONSOLE")(lambda x: x))
2509 env="MOZ_USE_NATIVE_POPUP_WINDOWS",
2510 default=target_is_android,
2511 help="Whether to use native popup windows",
2514 set_define("MOZ_USE_NATIVE_POPUP_WINDOWS", True, when="MOZ_USE_NATIVE_POPUP_WINDOWS")
2517 # Alternative Crashreporter setting
2519 "--with-crashreporter-url",
2520 env="MOZ_CRASHREPORTER_URL",
2521 default="https://crash-reports.mozilla.com/",
2523 help="Set an alternative crashreporter url",
2527 "MOZ_CRASHREPORTER_URL",
2528 depends("--with-crashreporter-url")(lambda x: x[0].rstrip("/")),
2532 # Crash reporter options
2533 # ==============================================================
2535 def oxidized_breakpad(target):
2536 if target.kernel == "Linux" and target.os != "Android":
2537 return target.cpu in ("x86", "x86_64")
2541 set_config("MOZ_OXIDIZED_BREAKPAD", True, when=oxidized_breakpad)
2542 set_define("MOZ_OXIDIZED_BREAKPAD", True, when=oxidized_breakpad)