Bug 1708243 - Part 3: Use actor messaging for tabs.detectLanguage, stop loading Messa...
[gecko.git] / toolkit / moz.configure
blob00ec0a474dd215a366aafec4042df49e43582f88
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)
9 @dependable
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():
16     result = []
17     previous = None
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
21         # consecutive.
22         # Also ignore OLD_CONFIGURE and MOZCONFIG because they're not
23         # interesting.
24         if option == previous or option.env in ("OLD_CONFIGURE", "MOZCONFIG"):
25             continue
26         previous = option
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
30         # defaults.
31         if (
32             value is not None
33             and value.origin not in ("default", "implied")
34             and value != option.default
35         ):
36             result.append(
37                 ensure_unicode(__sandbox__._raw_options[option], system_encoding)
38             )
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)
42         elif (
43             option.help == "Help missing for old configure options"
44             and option in __sandbox__._raw_options
45         ):
46             result.append(
47                 ensure_unicode(__sandbox__._raw_options[option], system_encoding)
48             )
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.
52     if not result:
53         return ""
55     return quote(*result)
58 set_config("MOZ_CONFIGURE_OPTIONS", all_configure_options)
61 @depends(target)
62 def fold_libs(target):
63     return target.os in ("WINNT", "OSX", "Android")
66 set_config("MOZ_FOLD_LIBS", fold_libs)
68 # Profiling
69 # ==============================================================
70 # Some of the options here imply an option from js/moz.configure,
71 # so, need to be declared before the include.
73 option(
74     "--enable-jprof",
75     env="MOZ_JPROF",
76     help="Enable jprof profiling tool (needs mozilla/tools/jprof)",
80 @depends("--enable-jprof")
81 def jprof(value):
82     if value:
83         return True
86 set_config("MOZ_JPROF", jprof)
87 set_define("MOZ_JPROF", jprof)
88 imply_option("--enable-profiling", jprof)
91 @depends(target)
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):
104     if value:
105         return True
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
124     # used in mozglue.)
125     if value and (target.kernel == "Linux" or target.kernel == "FreeBSD"):
126         return True
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)
138 @depends(
139     "--enable-debug",
140     milestone,
141     build_project,
142     # Artifact builds are included because the downloaded artifacts can
143     # have DMD enabled.
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))
150 option(
151     "--enable-dmd",
152     env="MOZ_DMD",
153     default=dmd_default,
154     help="{Enable|Disable} Dark Matter Detector (heap profiler). "
155     "Also enables jemalloc, replace-malloc and profiling",
159 @depends("--enable-dmd")
160 def dmd(value):
161     if value:
162         return True
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)
172 # ALSA cubeb backend
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))
181 # JACK cubeb backend
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 # ==============================================================
192 @depends(target)
193 def pulseaudio_default(target):
194     return target.os not in ("WINNT", "OSX", "Android", "OpenBSD")
197 option(
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 # ==============================================================
211 @depends(target)
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)
219 # Javascript engine
220 # ==============================================================
221 include("../js/moz.configure")
224 # NodeJS
225 # ==============================================================
226 include("../build/moz.configure/node.configure")
228 # L10N
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):
238     if value:
239         path = value[0]
240         if not isdir(path):
241             die("Invalid value --with-l10n-base, %s doesn't exist", path)
242     elif automation:
243         path = os.path.join(build_env.topsrcdir, "../l10n-central")
244     else:
245         path = os.path.join(
246             environ.get(
247                 "MOZBUILD_STATE_PATH", expanduser(os.path.join("~", ".mozbuild"))
248             ),
249             "l10n-central",
250         )
251     return os.path.realpath(os.path.abspath(path))
254 set_config("L10NBASEDIR", l10n_base)
257 # Default toolkit
258 # ==============================================================
259 @depends(target)
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",)
267     else:
268         return ("cairo-gtk3", "cairo-gtk3-wayland")
271 @depends(toolkit_choices)
272 def toolkit_default(choices):
273     return choices[0]
276 option(
277     "--enable-default-toolkit",
278     nargs=1,
279     choices=toolkit_choices,
280     default=toolkit_default,
281     help="Select default toolkit",
285 @depends_if("--enable-default-toolkit")
286 def full_toolkit(value):
287     return value[0]
290 @depends(full_toolkit)
291 def toolkit(toolkit):
292     if toolkit.startswith("cairo-gtk3"):
293         widget_toolkit = "gtk"
294     else:
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)
303 @depends(toolkit)
304 def toolkit_define(toolkit):
305     if toolkit != "windows":
306         return "MOZ_WIDGET_%s" % toolkit.upper()
309 set_define(toolkit_define, True)
312 @depends(toolkit)
313 def toolkit_gtk(toolkit):
314     return toolkit == "gtk"
317 # Wayland support
318 # ==============================================================
319 wayland_headers = pkg_check_modules(
320     "MOZ_WAYLAND",
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:
330         return True
331     return wayland
334 set_config("MOZ_WAYLAND", depends_if(wayland_headers)(lambda _: True))
335 set_define("MOZ_WAYLAND", depends_if(wayland_headers)(lambda _: True))
337 # GL Provider
338 # ==============================================================
339 option("--with-gl-provider", nargs=1, help="Set GL provider backend type")
342 @depends("--with-gl-provider")
343 def gl_provider(value):
344     if value:
345         return value[0]
348 @depends(gl_provider)
349 def gl_provider_define(provider):
350     if 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):
359     if value:
360         return value
361     elif wayland:
362         return "EGL"
363     elif toolkit_gtk:
364         return "GLX"
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):
373     if provider:
374         return "GL_PROVIDER_%s" % provider
377 set_define(gl_provider_define, True)
380 # PDF printing
381 # ==============================================================
382 @depends(toolkit)
383 def pdf_printing(toolkit):
384     if toolkit in ("windows", "gtk", "android"):
385         return True
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):
399     if value or (
400         toolkit in ("windows", "gtk", "cocoa", "android") and value.origin == "default"
401     ):
402         return True
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"):
417         return True
420 add_old_configure_assignment("USE_FC_FREETYPE", fc_freetype)
421 set_define("USE_FC_FREETYPE", fc_freetype)
423 # Pango
424 # ==============================================================
425 pkg_check_modules("MOZ_PANGO", "pango >= 1.22.0", when=toolkit_gtk)
427 # Fontconfig
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):
436     if fc_freetype:
437         return True
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:
449         return
450     if not fontconfig_info:
451         return freetype2_info
452     return namespace(
453         cflags=freetype2_info.cflags + fontconfig_info.cflags,
454         libs=freetype2_info.libs + fontconfig_info.libs,
455     )
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 # ==============================================================
465 @depends(toolkit)
466 def applemedia(toolkit):
467     if toolkit in ("cocoa", "uikit"):
468         return True
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)
490     if enabled:
491         return True
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")
507     if enabled:
508         return True
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")
521 def av1(value):
522     if value:
523         return True
526 @depends(target, when=av1 & compile_environment)
527 def dav1d_asm(target):
528     if target.cpu in ("aarch64", "x86", "x86_64"):
529         return True
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:
551         return True
554 set_config("MOZ_JXL", jxl)
555 set_define("MOZ_JXL", jxl)
557 # Built-in fragmented MP4 support.
558 # ==============================================================
559 option(
560     "--disable-fmp4",
561     env="MOZ_FMP4",
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"
572     if enabled:
573         return True
576 set_config("MOZ_FMP4", fmp4)
577 set_define("MOZ_FMP4", fmp4)
578 add_old_configure_assignment("MOZ_FMP4", fmp4)
581 @depends(target)
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":
587         return True
590 @depends(sample_type_is_s16)
591 def sample_type_is_float(t):
592     if not t:
593         return True
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")
612 def openmax(value):
613     enabled = bool(value)
614     if enabled:
615         return True
618 set_config("MOZ_OMX", openmax)
619 set_define("MOZ_OMX", openmax)
621 # EME Support
622 # ==============================================================
623 @depends(target)
624 def eme_choices(target):
625     if (
626         target.kernel in ("WINNT", "Linux")
627         and target.os != "Android"
628         and target.cpu in ("x86", "x86_64")
629     ):
630         return ("widevine",)
631     if target.kernel == "WINNT" and target.cpu == "aarch64":
632         return ("widevine",)
633     if target.os in ("OSX"):
634         return ("widevine",)
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":
643             return choices
646 option(
647     "--enable-eme",
648     nargs="+",
649     choices=eme_choices,
650     default=eme_default,
651     when=eme_choices,
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):
664     return value
667 # Fallback to an empty list when eme_choices is empty, setting eme_modules to
668 # None.
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":
675         return True
678 set_config("MOZ_EME_WIN32_ARTIFACT", eme_win32_artifact)
680 option(
681     name="--enable-chrome-format",
682     help="Select FORMAT of chrome files during packaging.",
683     nargs=1,
684     choices=("omni", "jar", "flat"),
685     default="omni",
689 @depends("--enable-chrome-format")
690 def packager_format(value):
691     return value[0]
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":
702         return "flat"
703     return "symlink"
706 set_config("MOZ_JAR_MAKER_FILE_FORMAT", jar_maker_format)
709 @depends(toolkit)
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
714     # case on desktop).
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)
722 project_flag(
723     "MOZ_SERVICES_HEALTHREPORT",
724     help="Build Firefox Health Reporter Service",
725     set_for_old_configure=True,
726     set_as_define=True,
729 project_flag(
730     "MOZ_NORMANDY",
731     help="Enable Normandy recipe runner",
732     set_for_old_configure=True,
733     set_as_define=True,
736 project_flag("MOZ_SERVICES_SYNC", help="Build Sync Services if required")
738 project_flag(
739     "MOZ_ANDROID_HISTORY",
740     help="Enable Android History instead of Places",
741     set_as_define=True,
744 project_flag(
745     "MOZ_DEDICATED_PROFILES",
746     help="Enable dedicated profiles per install",
747     set_as_define=True,
750 project_flag(
751     "MOZ_BLOCK_PROFILE_DOWNGRADE",
752     help="Block users from starting profiles last used by a newer build",
753     set_as_define=True,
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.")
763 option(
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)
783 # gpsd support
784 # ==============================================================
785 option("--enable-gpsd", env="MOZ_GPSD", help="Enable gpsd support")
788 @depends("--enable-gpsd")
789 def gpsd(value):
790     return bool(value)
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)
805 # Key files
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 # ==============================================================
827 option(
828     "--enable-webrender-debugger", help="Build the websocket debug server in WebRender"
831 set_config(
832     "MOZ_WEBRENDER_DEBUGGER", depends_if("--enable-webrender-debugger")(lambda _: True)
835 # Additional system headers defined at the application level
836 # ==============================================================
838 option(
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):
847     if value:
848         return True
851 set_config("MOZ_APP_SYSTEM_HEADERS", app_system_headers)
852 set_define("MOZ_APP_SYSTEM_HEADERS", app_system_headers)
854 # Printing
855 # ==============================================================
856 option("--disable-printing", help="Disable printing support")
859 @depends("--disable-printing")
860 def printing(value):
861     if value:
862         return True
865 set_config("NS_PRINTING", printing)
866 set_define("NS_PRINTING", printing)
867 set_define("NS_PRINT_PREVIEW", printing)
869 # Speech-dispatcher support
870 # ==============================================================
871 @depends(toolkit)
872 def no_speechd_on_non_gtk(toolkit):
873     if toolkit != "gtk":
874         return False
877 imply_option(
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))
885 # Speech API
886 # ==============================================================
887 option("--disable-webspeech", help="Disable support for HTML Speech API")
890 @depends("--disable-webspeech")
891 def webspeech(value):
892     if value:
893         return True
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 # ==============================================================
902 option(
903     "--enable-webspeechtestbackend",
904     default=webspeech,
905     help="{Enable|Disable} support for HTML Speech API Test Backend",
909 @depends_if("--enable-webspeechtestbackend")
910 def webspeech_test_backend(value):
911     return True
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))
923 # Graphics
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")
935 set_config(
936     "SKIA_INCLUDES",
937     [
938         "/gfx/skia",
939         "/gfx/skia/skia",
940     ],
943 system_lib_option(
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"):
958         return True
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):
972     if tree_freetype:
973         return namespace(
974             cflags=("-I%s/modules/freetype2/include" % build_env.topsrcdir,), libs=()
975         )
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
1004 # implementation.
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
1024 option(
1025     "--disable-webdriver",
1026     help="Disable support for WebDriver remote protocols",
1030 @depends("--disable-webdriver")
1031 def webdriver(enabled):
1032     if enabled:
1033         return True
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
1049 @depends(
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:
1054         return False
1055     if hazard or target.os == "Android" or (asan and cross_compile):
1056         return False
1057     if automation:
1058         return False
1059     return True
1062 option(
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):
1072     if enabled:
1073         return True
1076 set_config("MOZ_GECKODRIVER", geckodriver)
1079 # WebRTC
1080 # ========================================================
1081 @depends(target)
1082 def webrtc_default(target):
1083     # Turn off webrtc for OS's we don't handle yet, but allow
1084     # --enable-webrtc to override.
1085     os_match = False
1086     for os_fragment in (
1087         "linux",
1088         "mingw",
1089         "android",
1090         "linuxandroid",
1091         "dragonfly",
1092         "freebsd",
1093         "netbsd",
1094         "openbsd",
1095         "darwin",
1096     ):
1097         if target.raw_os.startswith(os_fragment):
1098             os_match = True
1100     cpu_match = False
1101     if (
1102         target.cpu
1103         in (
1104             "x86_64",
1105             "arm",
1106             "aarch64",
1107             "x86",
1108             "ia64",
1109             "mips32",
1110             "mips64",
1111         )
1112         or target.cpu.startswith("ppc")
1113     ):
1114         cpu_match = True
1116     if os_match and cpu_match:
1117         return True
1118     return False
1121 option(
1122     "--disable-webrtc",
1123     default=webrtc_default,
1124     help="{Enable|Disable} support for WebRTC",
1128 @depends("--disable-webrtc")
1129 def webrtc(enabled):
1130     if enabled:
1131         return True
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)
1149 # RAW media
1150 # ==============================================================
1153 @depends(target, webrtc)
1154 def raw_media_default(target, webrtc):
1155     if target.os == "Android":
1156         return True
1157     if webrtc:
1158         return True
1161 option(
1162     "--enable-raw",
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))
1171 # X11
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):
1179     libs = [
1180         "x11",
1181         "xcb",
1182         "xcb-shm",
1183         "x11-xcb",
1184         "xext",
1185         "xrandr >= 1.4.0",
1186         "xrender",
1187     ]
1188     if webrtc:
1189         # third_party/libwebrtc/webrtc/webrtc_gn/moz.build adds those
1190         # manually, ensure they're available.
1191         libs += [
1192             "xcomposite",
1193             "xcursor",
1194             "xdamage",
1195             "xfixes",
1196             "xi",
1197         ]
1198     return " ".join(libs)
1201 pkg_check_modules("MOZ_X11", x11_libs, when=toolkit_gtk)
1204 # ASan Reporter Addon
1205 # ==============================================================
1206 option(
1207     "--enable-address-sanitizer-reporter",
1208     help="Enable Address Sanitizer Reporter Extension",
1212 @depends("--enable-address-sanitizer-reporter")
1213 def enable_asan_reporter(value):
1214     if value:
1215         return True
1218 set_config("MOZ_ASAN_REPORTER", enable_asan_reporter)
1219 set_define("MOZ_ASAN_REPORTER", enable_asan_reporter)
1220 add_old_configure_assignment("MOZ_ASAN_REPORTER", enable_asan_reporter)
1222 # Elfhack
1223 # ==============================================================
1224 with only_when("--enable-compile-environment"):
1226     @depends(host, target)
1227     def has_elfhack(host, target):
1228         return (
1229             target.kernel == "Linux"
1230             and host.kernel == "Linux"
1231             and target.cpu in ("arm", "x86", "x86_64")
1232         )
1234     @depends("--enable-release", enable_linker)
1235     def default_elfhack(release, linker):
1236         # Disable elfhack when explicitly building with --enable-linker=lld
1237         if linker and linker.origin != "default" and linker[0] == "lld":
1238             return False
1239         return bool(release)
1241     with only_when(has_elfhack):
1242         option(
1243             "--disable-elf-hack",
1244             default=default_elfhack,
1245             help="{Enable|Disable} elf hacks",
1246         )
1248         set_config("USE_ELF_HACK", depends_if("--enable-elf-hack")(lambda _: True))
1251 @depends(check_build_environment)
1252 def idl_roots(build_env):
1253     return namespace(
1254         ipdl_root=os.path.join(build_env.topobjdir, "ipc", "ipdl"),
1255         webidl_root=os.path.join(build_env.topobjdir, "dom", "bindings"),
1256         xpcom_root=os.path.join(build_env.topobjdir, "xpcom", "components"),
1257     )
1260 set_config("WEBIDL_ROOT", idl_roots.webidl_root)
1261 set_config("IPDL_ROOT", idl_roots.ipdl_root)
1262 set_config("XPCOM_ROOT", idl_roots.xpcom_root)
1264 # Proxy bypass protection
1265 # ==============================================================
1267 option(
1268     "--enable-proxy-bypass-protection",
1269     help="Prevent suspected or confirmed proxy bypasses",
1273 @depends_if("--enable-proxy-bypass-protection")
1274 def proxy_bypass_protection(_):
1275     return True
1278 set_config("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1279 set_define("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1281 # Proxy direct failover
1282 # ==============================================================
1284 option(
1285     "--disable-proxy-direct-failover",
1286     help="Disable direct failover for system requests",
1290 @depends_if("--disable-proxy-direct-failover")
1291 def proxy_direct_failover(value):
1292     if value:
1293         return True
1296 set_config("MOZ_PROXY_DIRECT_FAILOVER", proxy_direct_failover)
1297 set_define("MOZ_PROXY_DIRECT_FAILOVER", proxy_direct_failover)
1299 # MIDL
1300 # ==============================================================
1303 @depends(c_compiler, toolchain_prefix)
1304 def midl_names(c_compiler, toolchain_prefix):
1305     if c_compiler and c_compiler.type in ["gcc", "clang"]:
1306         # mingw
1307         widl = ("widl",)
1308         if toolchain_prefix:
1309             prefixed = tuple("%s%s" % (p, "widl") for p in toolchain_prefix)
1310             widl = prefixed + widl
1311         return widl
1313     return ("midl.exe",)
1316 @depends(target, "--enable-compile-environment")
1317 def check_for_midl(target, compile_environment):
1318     if target.os != "WINNT":
1319         return
1321     if compile_environment:
1322         return True
1325 midl = check_prog(
1326     "MIDL", midl_names, when=check_for_midl, allow_missing=True, paths=sdk_bin_path
1329 option(env="MIDL_FLAGS", nargs=1, help="Extra flags to pass to MIDL")
1332 @depends(
1333     "MIDL_FLAGS",
1334     c_compiler,
1335     target,
1336     host,
1337     midl,
1338     when=depends(midl, target)(lambda m, t: m and t.kernel == "WINNT"),
1340 def midl_flags(flags, c_compiler, target, host, midl):
1341     if flags:
1342         flags = flags[0].split()
1343     else:
1344         flags = []
1346     if not midl.endswith("widl"):
1347         env = {
1348             "x86": "win32",
1349             "x86_64": "x64",
1350             "aarch64": "arm64",
1351         }[target.cpu]
1352         flags += ["-env", env]
1354         if host.os == "WINNT":
1355             return flags + ["-cpp_cmd", c_compiler.compiler]
1357         # If cross-compiling and using midl instead of widl, for now, we'll
1358         # assume we can find the Windows version of clang-cl in the PATH.
1359         # It is required because while Wine is able to spawn Linux
1360         # processes from Windows programs(!), the calling program doesn't
1361         # have access to the process output and can't wait for it to
1362         # finish. Midl runs clang-cl as a preprocessor and expects to read
1363         # its output...
1364         clang_cl_exe = find_program("clang-cl.exe")
1365         if not clang_cl_exe:
1366             die("Cannot find clang-cl.exe")
1367         return flags + ["-cpp_cmd", clang_cl_exe]
1369     # widl
1370     return flags + {
1371         "x86": ["--win32", "-m32"],
1372         "x86_64": ["--win64", "-m64"],
1373     }[target.cpu]
1376 set_config("MIDL_FLAGS", midl_flags)
1378 # Accessibility
1379 # ==============================================================
1381 option("--disable-accessibility", help="Disable accessibility support")
1384 @depends("--enable-accessibility", check_for_midl, midl, c_compiler)
1385 def accessibility(value, check_for_midl, midl, c_compiler):
1386     enabled = bool(value)
1388     if not enabled:
1389         return
1391     if check_for_midl and not midl:
1392         if c_compiler and c_compiler.type in ("gcc", "clang"):
1393             die(
1394                 "You have accessibility enabled, but widl could not be found. "
1395                 "Add --disable-accessibility to your mozconfig or install widl. "
1396                 "See https://developer.mozilla.org/en-US/docs/Cross_Compile_Mozilla_for_Mingw32 for details."
1397             )
1398         else:
1399             die(
1400                 "MIDL could not be found. "
1401                 "Building accessibility without MIDL is not supported."
1402             )
1404     return enabled
1407 set_config("ACCESSIBILITY", accessibility)
1408 set_define("ACCESSIBILITY", accessibility)
1409 add_old_configure_assignment("ACCESSIBILITY", accessibility)
1412 # Addon signing
1413 # ==============================================================
1414 @depends(milestone)
1415 def require_signing(milestone):
1416     return milestone.is_release_or_beta and not milestone.is_esr
1419 option(
1420     env="MOZ_REQUIRE_SIGNING",
1421     default=require_signing,
1422     help="Enforce that add-ons are signed by the trusted root",
1425 set_config("MOZ_REQUIRE_SIGNING", True, when="MOZ_REQUIRE_SIGNING")
1426 set_define("MOZ_REQUIRE_SIGNING", True, when="MOZ_REQUIRE_SIGNING")
1428 option(
1429     "--with-unsigned-addon-scopes",
1430     nargs="+",
1431     choices=("app", "system"),
1432     help="Addon scopes where signature is not required",
1436 @depends("--with-unsigned-addon-scopes")
1437 def unsigned_addon_scopes(scopes):
1438     return namespace(
1439         app="app" in scopes or None,
1440         system="system" in scopes or None,
1441     )
1444 set_config("MOZ_UNSIGNED_APP_SCOPE", unsigned_addon_scopes.app)
1445 set_config("MOZ_UNSIGNED_SYSTEM_SCOPE", unsigned_addon_scopes.system)
1448 # Addon sideloading
1449 # ==============================================================
1450 option(
1451     "--allow-addon-sideload",
1452     default=milestone.is_esr,
1453     help="Addon sideloading is allowed",
1457 set_config("MOZ_ALLOW_ADDON_SIDELOAD", True, when="--allow-addon-sideload")
1459 # WebExtensions API WebIDL bindings
1460 # ==============================================================
1463 @depends(milestone)
1464 def extensions_webidl_bindings_default(milestone):
1465     # Only enable the webidl bindings for the WebExtensions APIs
1466     # in Nightly.
1467     return milestone.is_nightly
1470 option(
1471     "--enable-extensions-webidl-bindings",
1472     default=extensions_webidl_bindings_default,
1473     help="{Enable|Disable} building experimental WebExtensions WebIDL bindings",
1477 @depends("--enable-extensions-webidl-bindings")
1478 def extensions_webidl_enabled(value):
1479     return bool(value)
1482 set_config("MOZ_WEBEXT_WEBIDL_ENABLED", extensions_webidl_enabled)
1484 # Launcher process (Windows only)
1485 # ==============================================================
1488 @depends(target)
1489 def launcher_process_default(target):
1490     return target.os == "WINNT"
1493 option(
1494     "--enable-launcher-process",
1495     default=launcher_process_default,
1496     help="{Enable|Disable} launcher process by default",
1500 @depends("--enable-launcher-process", target)
1501 def launcher(value, target):
1502     enabled = bool(value)
1503     if enabled and target.os != "WINNT":
1504         die("Cannot enable launcher process on %s", target.os)
1505     if enabled:
1506         return True
1509 set_config("MOZ_LAUNCHER_PROCESS", launcher)
1510 set_define("MOZ_LAUNCHER_PROCESS", launcher)
1512 # llvm-dlltool (Windows only)
1513 # ==============================================================
1516 @depends(build_project, target, "--enable-compile-environment")
1517 def check_for_llvm_dlltool(build_project, target, compile_environment):
1518     if build_project != "browser":
1519         return
1521     if target.os != "WINNT":
1522         return
1524     return compile_environment
1527 llvm_dlltool = check_prog(
1528     "LLVM_DLLTOOL",
1529     ("llvm-dlltool",),
1530     what="llvm-dlltool",
1531     when=check_for_llvm_dlltool,
1532     paths=clang_search_path,
1536 @depends(target, when=llvm_dlltool)
1537 def llvm_dlltool_flags(target):
1538     arch = {
1539         "x86": "i386",
1540         "x86_64": "i386:x86-64",
1541         "aarch64": "arm64",
1542     }[target.cpu]
1544     return ["-m", arch]
1547 set_config("LLVM_DLLTOOL_FLAGS", llvm_dlltool_flags)
1549 # BITS download (Windows only)
1550 # ==============================================================
1552 option(
1553     "--enable-bits-download",
1554     when=target_is_windows,
1555     default=target_is_windows,
1556     help="{Enable|Disable} building BITS download support",
1559 set_define(
1560     "MOZ_BITS_DOWNLOAD",
1561     depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
1563 set_config(
1564     "MOZ_BITS_DOWNLOAD",
1565     depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
1568 # Bundled fonts on desktop platform
1569 # ==============================================================
1572 @depends(target)
1573 def bundled_fonts_default(target):
1574     return target.os == "WINNT" or target.kernel == "Linux"
1577 @depends(build_project)
1578 def allow_bundled_fonts(project):
1579     return project == "browser" or project == "comm/mail"
1582 option(
1583     "--enable-bundled-fonts",
1584     default=bundled_fonts_default,
1585     when=allow_bundled_fonts,
1586     help="{Enable|Disable} support for bundled fonts on desktop platforms",
1589 set_define(
1590     "MOZ_BUNDLED_FONTS",
1591     depends_if("--enable-bundled-fonts", when=allow_bundled_fonts)(lambda _: True),
1594 # Reflow counting
1595 # ==============================================================
1598 @depends(moz_debug)
1599 def reflow_perf(debug):
1600     if debug:
1601         return True
1604 option(
1605     "--enable-reflow-perf",
1606     default=reflow_perf,
1607     help="{Enable|Disable} reflow performance tracing",
1610 # The difference in conditions here comes from the initial implementation
1611 # in old-configure, which was unexplained there as well.
1612 set_define("MOZ_REFLOW_PERF", depends_if("--enable-reflow-perf")(lambda _: True))
1613 set_define("MOZ_REFLOW_PERF_DSP", reflow_perf)
1615 # Layout debugger
1616 # ==============================================================
1619 @depends(moz_debug)
1620 def layout_debugger(debug):
1621     if debug:
1622         return True
1625 option(
1626     "--enable-layout-debugger",
1627     default=layout_debugger,
1628     help="{Enable|Disable} layout debugger",
1631 set_config("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
1632 set_define("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
1635 # Shader Compiler for Windows (and MinGW Cross Compile)
1636 # ==============================================================
1638 with only_when(compile_environment):
1639     fxc = check_prog(
1640         "FXC",
1641         ("fxc.exe", "fxc2.exe"),
1642         when=depends(target)(lambda t: t.kernel == "WINNT"),
1643         paths=sdk_bin_path,
1644     )
1647 # VPX
1648 # ===
1650 with only_when(compile_environment):
1651     system_lib_option(
1652         "--with-system-libvpx", help="Use system libvpx (located with pkgconfig)"
1653     )
1655     with only_when("--with-system-libvpx"):
1656         vpx = pkg_check_modules("MOZ_LIBVPX", "vpx >= 1.8.0")
1658         check_header(
1659             "vpx/vpx_decoder.h",
1660             flags=vpx.cflags,
1661             onerror=lambda: die(
1662                 "Couldn't find vpx/vpx_decoder.h, which is required to build "
1663                 "with system libvpx. Use --without-system-libvpx to build "
1664                 "with in-tree libvpx."
1665             ),
1666         )
1668         check_symbol(
1669             "vpx_codec_dec_init_ver",
1670             flags=vpx.libs,
1671             onerror=lambda: die(
1672                 "--with-system-libvpx requested but symbol vpx_codec_dec_init_ver "
1673                 "not found"
1674             ),
1675         )
1677         set_config("MOZ_SYSTEM_LIBVPX", True)
1679     @depends("--with-system-libvpx", target)
1680     def in_tree_vpx(system_libvpx, target):
1681         if system_libvpx:
1682             return
1684         arm_asm = (target.cpu == "arm") or None
1685         return namespace(arm_asm=arm_asm)
1687     @depends(target, when=in_tree_vpx)
1688     def vpx_nasm(target):
1689         if target.cpu in ("x86", "x86_64"):
1690             if target.kernel == "WINNT":
1691                 # Version 2.03 is needed for automatic safeseh support.
1692                 return namespace(version="2.03", what="VPX")
1693             return namespace(what="VPX")
1695     # Building with -mfpu=neon requires either the "softfp" or the
1696     # "hardfp" ABI. Depending on the compiler's default target, and the
1697     # CFLAGS, the default ABI might be neither, in which case it is the
1698     # "softfloat" ABI.
1699     # The "softfloat" ABI is binary-compatible with the "softfp" ABI, so
1700     # we can safely mix code built with both ABIs. So, if we detect
1701     # that compiling uses the "softfloat" ABI, force the use of the
1702     # "softfp" ABI instead.
1703     # Confusingly, the __SOFTFP__ preprocessor variable indicates the
1704     # "softfloat" ABI, not the "softfp" ABI.
1705     # Note: VPX_ASFLAGS is also used in CFLAGS.
1706     softfp = cxx_compiler.try_compile(
1707         body="""
1708         #ifndef __SOFTFP__
1709         #error "compiler target supports -mfpu=neon, so we don't have to add extra flags"
1710         #endif""",
1711         when=in_tree_vpx.arm_asm,
1712     )
1714     @depends(in_tree_vpx, vpx_nasm, softfp, target)
1715     def vpx_as_flags(vpx, vpx_nasm, softfp, target):
1716         flags = []
1717         if vpx and vpx.arm_asm:
1718             # These flags are a lie; they're just used to enable the requisite
1719             # opcodes; actual arch detection is done at runtime.
1720             flags = ["-march=armv7-a", "-mfpu=neon"]
1721             if softfp:
1722                 flags.append("-mfloat-abi=softfp")
1723         elif vpx and vpx_nasm and target.os != "WINNT" and target.cpu != "x86_64":
1724             flags = ["-DPIC"]
1725         return flags
1727     set_config("VPX_USE_NASM", True, when=vpx_nasm)
1728     set_config("VPX_ASFLAGS", vpx_as_flags)
1731 # JPEG
1732 # ====
1734 with only_when(compile_environment):
1735     system_lib_option(
1736         "--with-system-jpeg",
1737         nargs="?",
1738         help="Use system libjpeg (installed at given prefix)",
1739     )
1741     @depends_if("--with-system-jpeg")
1742     def jpeg_flags(value):
1743         if len(value):
1744             return namespace(
1745                 cflags=("-I%s/include" % value[0],),
1746                 ldflags=("-L%s/lib" % value[0], "-ljpeg"),
1747             )
1748         return namespace(
1749             ldflags=("-ljpeg",),
1750         )
1752     with only_when("--with-system-jpeg"):
1753         check_symbol(
1754             "jpeg_destroy_compress",
1755             flags=jpeg_flags.ldflags,
1756             onerror=lambda: die(
1757                 "--with-system-jpeg requested but symbol "
1758                 "jpeg_destroy_compress not found."
1759             ),
1760         )
1762         c_compiler.try_compile(
1763             includes=[
1764                 "stdio.h",
1765                 "sys/types.h",
1766                 "jpeglib.h",
1767             ],
1768             body="""
1769                 #if JPEG_LIB_VERSION < 62
1770                 #error Insufficient JPEG library version
1771                 #endif
1772             """,
1773             flags=jpeg_flags.cflags,
1774             check_msg="for sufficient jpeg library version",
1775             onerror=lambda: die(
1776                 "Insufficient JPEG library version for "
1777                 "--with-system-jpeg (62 required)"
1778             ),
1779         )
1781         c_compiler.try_compile(
1782             includes=[
1783                 "stdio.h",
1784                 "sys/types.h",
1785                 "jpeglib.h",
1786             ],
1787             body="""
1788                 #ifndef JCS_EXTENSIONS
1789                 #error libjpeg-turbo JCS_EXTENSIONS required
1790                 #endif
1791             """,
1792             flags=jpeg_flags.cflags,
1793             check_msg="for sufficient libjpeg-turbo JCS_EXTENSIONS",
1794             onerror=lambda: die(
1795                 "libjpeg-turbo JCS_EXTENSIONS required for " "--with-system-jpeg"
1796             ),
1797         )
1799         set_config("MOZ_JPEG_CFLAGS", jpeg_flags.cflags)
1800         set_config("MOZ_JPEG_LIBS", jpeg_flags.ldflags)
1802     @depends("--with-system-jpeg", target)
1803     def in_tree_jpeg_arm(system_jpeg, target):
1804         if system_jpeg:
1805             return
1807         if target.cpu == "arm":
1808             return ("-march=armv7-a", "-mfpu=neon")
1809         elif target.cpu == "aarch64":
1810             return ("-march=armv8-a",)
1812     @depends("--with-system-jpeg", target)
1813     def in_tree_jpeg(system_jpeg, target):
1814         if system_jpeg:
1815             return
1817         if target.cpu == "arm":
1818             return ("-march=armv7-a", "-mfpu=neon")
1819         elif target.cpu == "aarch64":
1820             return ("-march=armv8-a",)
1821         elif target.kernel == "Darwin":
1822             if target.cpu == "x86":
1823                 return ("-DPIC", "-DMACHO")
1824             elif target.cpu == "x86_64":
1825                 return ("-D__x86_64__", "-DPIC", "-DMACHO")
1826         elif target.kernel == "WINNT":
1827             if target.cpu == "x86":
1828                 return ("-DPIC", "-DWIN32")
1829             elif target.cpu == "x86_64":
1830                 return ("-D__x86_64__", "-DPIC", "-DWIN64", "-DMSVC")
1831         elif target.cpu == "mips32":
1832             return ("-mdspr2",)
1833         elif target.cpu == "mips64":
1834             return ("-Wa,-mloongson-mmi", "-mloongson-ext")
1835         elif target.cpu == "x86":
1836             return ("-DPIC", "-DELF")
1837         elif target.cpu == "x86_64":
1838             return ("-D__x86_64__", "-DPIC", "-DELF")
1840     @depends(target, when=in_tree_jpeg)
1841     def jpeg_nasm(target):
1842         if target.cpu in ("x86", "x86_64"):
1843             # libjpeg-turbo 2.0.6 requires nasm 2.10.
1844             return namespace(version="2.10", what="JPEG")
1846     jpeg_arm_neon_vld1_s16_x3 = c_compiler.try_compile(
1847         includes=["arm_neon.h"],
1848         body="int16_t input[12] = {}; int16x4x3_t output = vld1_s16_x3(input);",
1849         check_msg="for vld1_s16_x3 in arm_neon.h",
1850         flags=in_tree_jpeg_arm,
1851         when=in_tree_jpeg_arm,
1852     )
1854     jpeg_arm_neon_vld1_u16_x2 = c_compiler.try_compile(
1855         includes=["arm_neon.h"],
1856         body="uint16_t input[8] = {}; uint16x4x2_t output = vld1_u16_x2(input);",
1857         check_msg="for vld1_u16_x2 in arm_neon.h",
1858         flags=in_tree_jpeg_arm,
1859         when=in_tree_jpeg_arm,
1860     )
1862     jpeg_arm_neon_vld1q_u8_x4 = c_compiler.try_compile(
1863         includes=["arm_neon.h"],
1864         body="uint8_t input[64] = {}; uint8x16x4_t output = vld1q_u8_x4(input);",
1865         check_msg="for vld1q_u8_x4 in arm_neon.h",
1866         flags=in_tree_jpeg_arm,
1867         when=in_tree_jpeg_arm,
1868     )
1870     set_config("LIBJPEG_TURBO_USE_NASM", True, when=jpeg_nasm)
1871     set_config("LIBJPEG_TURBO_SIMD_FLAGS", in_tree_jpeg)
1872     set_config("LIBJPEG_TURBO_HAVE_VLD1_S16_X3", jpeg_arm_neon_vld1_s16_x3)
1873     set_config("LIBJPEG_TURBO_HAVE_VLD1_U16_X2", jpeg_arm_neon_vld1_u16_x2)
1874     set_config("LIBJPEG_TURBO_HAVE_VLD1Q_U8_X4", jpeg_arm_neon_vld1q_u8_x4)
1875     set_config(
1876         "LIBJPEG_TURBO_NEON_INTRINSICS",
1877         jpeg_arm_neon_vld1_s16_x3
1878         & jpeg_arm_neon_vld1_u16_x2
1879         & jpeg_arm_neon_vld1q_u8_x4,
1880     )
1883 # FFmpeg's ffvpx configuration
1884 # ==============================================================
1885 with only_when(compile_environment):
1887     @depends(target)
1888     def libav_fft(target):
1889         return target.kernel == "WINNT" or target.cpu == "x86_64"
1891     set_config("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
1892     set_define("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
1895 # Artifact builds need MOZ_FFVPX defined as if compilation happened.
1896 with only_when(compile_environment | artifact_builds):
1898     @depends(target)
1899     def ffvpx(target):
1900         enable = use_nasm = True
1901         flac_only = False
1902         flags = []
1904         if target.kernel == "WINNT":
1905             if target.cpu == "x86":
1906                 # 32-bit windows need to prefix symbols with an underscore.
1907                 flags = ["-DPIC", "-DWIN32", "-DPREFIX", "-Pconfig_win32.asm"]
1908             elif target.cpu == "x86_64":
1909                 flags = [
1910                     "-D__x86_64__",
1911                     "-DPIC",
1912                     "-DWIN64",
1913                     "-DMSVC",
1914                     "-Pconfig_win64.asm",
1915                 ]
1916             elif target.cpu == "aarch64":
1917                 flags = ["-DPIC", "-DWIN64"]
1918                 use_nasm = False
1919         elif target.kernel == "Darwin":
1920             if target.cpu == "x86_64":
1921                 # 32/64-bit macosx asemblers need to prefix symbols with an
1922                 # underscore.
1923                 flags = [
1924                     "-D__x86_64__",
1925                     "-DPIC",
1926                     "-DMACHO",
1927                     "-DPREFIX",
1928                     "-Pconfig_darwin64.asm",
1929                 ]
1930             else:
1931                 flac_only = True
1932         elif target.cpu == "x86_64":
1933             flags = ["-D__x86_64__", "-DPIC", "-DELF", "-Pconfig_unix64.asm"]
1934         elif target.cpu in ("x86", "arm", "aarch64"):
1935             flac_only = True
1936         else:
1937             enable = False
1939         if flac_only or not enable:
1940             use_nasm = False
1942         if use_nasm:
1943             # default disabled components
1944             flags.append("-Pdefaults_disabled.asm")
1946         return namespace(
1947             enable=enable,
1948             use_nasm=use_nasm,
1949             flac_only=flac_only,
1950             flags=flags,
1951         )
1953     @depends(when=ffvpx.use_nasm)
1954     def ffvpx_nasm():
1955         # nasm 2.10 for AVX-2 support.
1956         return namespace(version="2.10", what="FFVPX")
1958     # ffvpx_nasm can't indirectly depend on vpx_as_flags, because it depends
1959     # on a compiler test, so we have to do a little bit of dance here.
1960     @depends(ffvpx, vpx_as_flags, target)
1961     def ffvpx(ffvpx, vpx_as_flags, target):
1962         if ffvpx and vpx_as_flags and target.cpu in ("arm", "aarch64"):
1963             ffvpx.flags.extend(vpx_as_flags)
1964         return ffvpx
1966     set_config("MOZ_FFVPX", True, when=ffvpx.enable)
1967     set_define("MOZ_FFVPX", True, when=ffvpx.enable)
1968     set_config("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.flac_only)
1969     set_define("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.flac_only)
1970     set_config("FFVPX_ASFLAGS", ffvpx.flags)
1971     set_config("FFVPX_USE_NASM", True, when=ffvpx.use_nasm)
1974 # nasm detection
1975 # ==============================================================
1976 @depends(dav1d_nasm, vpx_nasm, jpeg_nasm, ffvpx_nasm, when=compile_environment)
1977 def need_nasm(*requirements):
1978     requires = {
1979         x.what: x.version if hasattr(x, "version") else True for x in requirements if x
1980     }
1981     if requires:
1982         items = sorted(requires.keys())
1983         if len(items) > 1:
1984             what = " and ".join((", ".join(items[:-1]), items[-1]))
1985         else:
1986             what = items[0]
1987         versioned = {k: v for (k, v) in requires.items() if v is not True}
1988         return namespace(what=what, versioned=versioned)
1991 nasm = check_prog(
1992     "NASM",
1993     ["nasm"],
1994     allow_missing=True,
1995     bootstrap="nasm",
1996     when=need_nasm,
2000 @depends(nasm, need_nasm.what)
2001 def check_nasm(nasm, what):
2002     if not nasm and what:
2003         die("Nasm is required to build with %s, but it was not found." % what)
2004     return nasm
2007 @depends_if(check_nasm)
2008 @checking("nasm version")
2009 def nasm_version(nasm):
2010     version = (
2011         check_cmd_output(nasm, "-v", onerror=lambda: die("Failed to get nasm version."))
2012         .splitlines()[0]
2013         .split()[2]
2014     )
2015     return Version(version)
2018 @depends(nasm_version, need_nasm.versioned, when=need_nasm.versioned)
2019 def check_nasm_version(nasm_version, versioned):
2020     by_version = sorted(versioned.items(), key=lambda x: x[1])
2021     what, version = by_version[-1]
2022     if nasm_version < version:
2023         die(
2024             "Nasm version %s or greater is required to build with %s." % (version, what)
2025         )
2026     return nasm_version
2029 @depends(target, when=check_nasm_version)
2030 def nasm_asflags(target):
2031     asflags = {
2032         ("OSX", "x86"): ["-f", "macho32"],
2033         ("OSX", "x86_64"): ["-f", "macho64"],
2034         ("WINNT", "x86"): ["-f", "win32"],
2035         ("WINNT", "x86_64"): ["-f", "win64"],
2036     }.get((target.os, target.cpu), None)
2037     if asflags is None:
2038         # We're assuming every x86 platform we support that's
2039         # not Windows or Mac is ELF.
2040         if target.cpu == "x86":
2041             asflags = ["-f", "elf32"]
2042         elif target.cpu == "x86_64":
2043             asflags = ["-f", "elf64"]
2044     return asflags
2047 set_config("NASM_ASFLAGS", nasm_asflags)
2050 # ANGLE OpenGL->D3D translator for WebGL
2051 # ==============================================================
2053 with only_when(compile_environment & target_is_windows):
2055     def d3d_compiler_dll_result(value):
2056         if not value.path:
2057             return "provided by the OS"
2058         return value.path
2060     @depends(target, valid_windows_sdk_dir, fxc)
2061     @checking("for D3D compiler DLL", d3d_compiler_dll_result)
2062     @imports("os.path")
2063     def d3d_compiler_dll(target, windows_sdk_dir, fxc):
2064         suffix = {
2065             "x86_64": "x64",
2066         }.get(target.cpu, target.cpu)
2068         name = "d3dcompiler_47.dll"
2070         if target.cpu == "aarch64":
2071             # AArch64 Windows comes with d3dcompiler_47.dll installed
2072             return namespace(name=name, path=None)
2074         if windows_sdk_dir:
2075             path = os.path.join(windows_sdk_dir.path, "Redist", "D3D", suffix, name)
2076             error_extra = "in Windows SDK at {}".format(windows_sdk_dir.path)
2077         else:
2078             path = os.path.join(os.path.dirname(fxc), name)
2079             error_extra = "alongside FXC at {}".format(fxc)
2081         if os.path.exists(path):
2082             return namespace(name=name, path=path)
2083         die("Could not find {} {}".format(name, error_extra))
2085     set_config("MOZ_ANGLE_RENDERER", True)
2086     set_config(
2087         "MOZ_D3DCOMPILER_VISTA_DLL", d3d_compiler_dll.name, when=d3d_compiler_dll.path
2088     )
2089     set_config("MOZ_D3DCOMPILER_VISTA_DLL_PATH", d3d_compiler_dll.path)
2091 # Remoting protocol support
2092 # ==============================================================
2095 @depends(toolkit)
2096 def has_remote(toolkit):
2097     if toolkit in ("gtk", "windows", "cocoa"):
2098         return True
2101 set_config("MOZ_HAS_REMOTE", has_remote)
2102 set_define("MOZ_HAS_REMOTE", has_remote)
2104 # RLBox Library Sandboxing wasm support
2105 # ==============================================================
2108 def wasm_sandboxing_libraries():
2109     return (
2110         "graphite",
2111         "ogg",
2112         "hunspell",
2113     )
2116 @depends(dependable(wasm_sandboxing_libraries), target, "MOZ_AUTOMATION")
2117 def default_wasm_sandboxing_libraries(libraries, target, automation):
2118     non_default_libs = set()
2119     if target.bitness == 32:
2120         non_default_libs.add("ogg")
2122     if automation:
2123         return tuple(l for l in libraries if l not in non_default_libs)
2126 option(
2127     "--with-wasm-sandboxed-libraries",
2128     env="WASM_SANDBOXED_LIBRARIES",
2129     help="{Enable wasm sandboxing for the selected libraries|Disable wasm sandboxing}",
2130     nargs="+",
2131     choices=dependable(wasm_sandboxing_libraries),
2132     default=default_wasm_sandboxing_libraries,
2136 @depends("--with-wasm-sandboxed-libraries")
2137 def requires_wasm_sandboxing(libraries):
2138     if libraries:
2139         return True
2142 set_config("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
2143 set_define("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
2145 with only_when(requires_wasm_sandboxing & compile_environment):
2146     option(
2147         "--with-wasi-sysroot",
2148         env="WASI_SYSROOT",
2149         nargs=1,
2150         help="Path to wasi sysroot for wasm sandboxing",
2151     )
2153     @depends("--with-wasi-sysroot", requires_wasm_sandboxing)
2154     def bootstrap_wasi_sysroot(wasi_sysroot, requires_wasm_sandboxing):
2155         return requires_wasm_sandboxing and not wasi_sysroot
2157     @depends(
2158         "--with-wasi-sysroot",
2159         bootstrap_path("sysroot-wasm32-wasi", when=bootstrap_wasi_sysroot),
2160     )
2161     @imports("os")
2162     def wasi_sysroot(wasi_sysroot, bootstrapped_sysroot):
2163         if not wasi_sysroot:
2164             if not bootstrapped_sysroot:
2165                 die(
2166                     "Cannot find a wasi sysroot. Please give its location with "
2167                     "--with-wasi-sysroot."
2168                 )
2169             return bootstrapped_sysroot
2171         wasi_sysroot = wasi_sysroot[0]
2172         if not os.path.isdir(wasi_sysroot):
2173             die("Argument to --with-wasi-sysroot must be a directory")
2174         if not os.path.isabs(wasi_sysroot):
2175             die("Argument to --with-wasi-sysroot must be an absolute path")
2177         return wasi_sysroot
2179     set_config("WASI_SYSROOT", wasi_sysroot)
2181     def wasm_compiler_with_flags(compiler, sysroot):
2182         if not sysroot:
2183             return
2184         elif compiler:
2185             return (
2186                 compiler.wrapper
2187                 + [compiler.compiler]
2188                 + compiler.flags
2189                 + ["--sysroot=%s" % sysroot]
2190             )
2192     wasm_cc = compiler("C", wasm, other_compiler=c_compiler)
2194     @depends(wasm_cc, wasi_sysroot)
2195     def wasm_cc_with_flags(wasm_cc, wasi_sysroot):
2196         return wasm_compiler_with_flags(wasm_cc, wasi_sysroot)
2198     set_config("WASM_CC", wasm_cc_with_flags)
2200     wasm_cxx = compiler(
2201         "C++",
2202         wasm,
2203         c_compiler=wasm_cc,
2204         other_compiler=cxx_compiler,
2205         other_c_compiler=c_compiler,
2206     )
2208     @depends(wasm_cxx, wasi_sysroot)
2209     def wasm_cxx_with_flags(wasm_cxx, wasi_sysroot):
2210         return wasm_compiler_with_flags(wasm_cxx, wasi_sysroot)
2212     set_config("WASM_CXX", wasm_cxx_with_flags)
2214     wasm_compile_flags = dependable(
2215         ["-fno-exceptions", "-fno-strict-aliasing", "-Qunused-arguments"]
2216     )
2217     option(env="WASM_CFLAGS", nargs=1, help="Options to pass to WASM_CC")
2219     @depends("WASM_CFLAGS", wasm_compile_flags)
2220     def wasm_cflags(value, wasm_compile_flags):
2221         if value:
2222             return wasm_compile_flags + value
2223         else:
2224             return wasm_compile_flags
2226     set_config("WASM_CFLAGS", wasm_cflags)
2228     option(env="WASM_CXXFLAGS", nargs=1, help="Options to pass to WASM_CXX")
2230     @depends("WASM_CXXFLAGS", wasm_compile_flags)
2231     def wasm_cxxflags(value, wasm_compile_flags):
2232         if value:
2233             return wasm_compile_flags + value
2234         else:
2235             return wasm_compile_flags
2237     set_config("WASM_CXXFLAGS", wasm_cxxflags)
2240 @depends("--with-wasm-sandboxed-libraries")
2241 def wasm_sandboxing(libraries):
2242     if not libraries:
2243         return
2245     return namespace(**{name: True for name in libraries})
2248 @template
2249 def wasm_sandboxing_config_defines():
2250     for lib in wasm_sandboxing_libraries():
2251         set_config(
2252             "MOZ_WASM_SANDBOXING_%s" % lib.upper(), getattr(wasm_sandboxing, lib)
2253         )
2254         set_define(
2255             "MOZ_WASM_SANDBOXING_%s" % lib.upper(), getattr(wasm_sandboxing, lib)
2256         )
2259 wasm_sandboxing_config_defines()
2262 # new XULStore implementation
2263 # ==============================================================
2266 @depends(milestone)
2267 def new_xulstore(milestone):
2268     if milestone.is_nightly:
2269         return True
2272 set_config("MOZ_NEW_XULSTORE", True, when=new_xulstore)
2273 set_define("MOZ_NEW_XULSTORE", True, when=new_xulstore)
2276 # new Notification Store implementation
2277 # ==============================================================
2280 @depends(milestone)
2281 def new_notification_store(milestone):
2282     if milestone.is_nightly:
2283         return True
2286 set_config("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)
2287 set_define("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)
2290 # Glean SDK Integration Crate
2291 # ==============================================================
2294 @depends(target)
2295 def glean_android(target):
2296     return target.os == "Android"
2299 set_config("MOZ_GLEAN_ANDROID", True, when=glean_android)
2300 set_define("MOZ_GLEAN_ANDROID", True, when=glean_android)
2303 # dump_syms
2304 # ==============================================================
2306 check_prog(
2307     "DUMP_SYMS",
2308     ["dump_syms"],
2309     allow_missing=True,
2310     bootstrap="dump_syms",
2311     when=compile_environment,
2315 check_prog(
2316     "PDBSTR",
2317     ["pdbstr.exe"],
2318     allow_missing=True,
2319     bootstrap="pdbstr",
2320     when=compile_environment & target_is_windows,
2324 @depends("MOZ_AUTOMATION", c_compiler)
2325 def allow_missing_winchecksec(automation, c_compiler):
2326     if not automation:
2327         return True
2328     if c_compiler and c_compiler.type != "clang-cl":
2329         return True
2332 check_prog(
2333     "WINCHECKSEC",
2334     ["winchecksec.exe", "winchecksec"],
2335     bootstrap="winchecksec",
2336     allow_missing=allow_missing_winchecksec,
2337     when=compile_environment & target_is_windows,
2340 # Fork server
2341 @depends(target, build_project)
2342 def forkserver_default(target, build_project):
2343     return build_project == "browser" and (
2344         (target.os == "GNU" and target.kernel == "Linux")
2345         or target.os == "FreeBSD"
2346         or target.os == "OpenBSD"
2347     )
2350 option(
2351     "--enable-forkserver",
2352     default=forkserver_default,
2353     env="MOZ_ENABLE_FORKSERVER",
2354     help="{Enable|Disable} fork server",
2358 @depends("--enable-forkserver", target)
2359 def forkserver_flag(value, target):
2360     if (
2361         target.os == "Android"
2362         or (target.os == "GNU" and target.kernel == "Linux")
2363         or target.os == "FreeBSD"
2364         or target.os == "OpenBSD"
2365     ):
2366         return bool(value)
2367     pass
2370 set_config("MOZ_ENABLE_FORKSERVER", forkserver_flag)
2371 set_define("MOZ_ENABLE_FORKSERVER", forkserver_flag, forkserver_flag)
2373 # Crash Reporter
2374 # ==============================================================
2376 with only_when(compile_environment & target_is_linux):
2377     # Check if we need to use the breakpad_getcontext fallback.
2378     getcontext = check_symbol("getcontext")
2379     set_config("HAVE_GETCONTEXT", getcontext)
2380     set_define("HAVE_GETCONTEXT", getcontext)
2382 # NSS
2383 # ==============================================================
2384 include("../build/moz.configure/nss.configure")
2387 # Enable or disable running in background task mode: headless for
2388 # periodic, short-lived, maintenance tasks.
2389 # ==============================================================================
2392 option(
2393     "--disable-backgroundtasks",
2394     help="Disable running in background task mode",
2398 set_config(
2399     "MOZ_BACKGROUNDTASKS", depends_if("--enable-backgroundtasks")(lambda _: True)
2403 # Update-related programs: updater, maintenance service, update agent,
2404 # default browser agent.
2405 # ==============================================================
2406 include("../build/moz.configure/update-programs.configure")
2409 # Mobile optimizations
2410 # ==============================================================
2411 option(
2412     "--enable-mobile-optimize",
2413     default=target_is_android,
2414     help="{Enable|Disable} mobile optimizations",
2417 set_define("MOZ_GFX_OPTIMIZE_MOBILE", True, when="--enable-mobile-optimize")
2418 # We ignore "paint will resample" on mobile for performance.
2419 # We may want to revisit this later.
2420 set_define("MOZ_IGNORE_PAINT_WILL_RESAMPLE", True, when="--enable-mobile-optimize")
2422 # Pref extensions
2423 # ==============================================================
2424 option("--disable-pref-extensions", help="Disable pref extensions such as autoconfig")
2425 set_config("MOZ_PREF_EXTENSIONS", True, when="--enable-pref-extensions")
2427 # Offer a way to disable the startup cache
2428 # ==============================================================
2429 option("--disable-startupcache", help="Disable startup cache")
2432 @depends("--enable-startupcache")
2433 def enable_startupcache(value):
2434     if value:
2435         return True
2438 set_define(
2439     "MOZ_DISABLE_STARTUPCACHE", True, when=depends(enable_startupcache)(lambda x: not x)
2443 # Branding
2444 # ==============================================================
2445 option(
2446     env="MOZ_APP_REMOTINGNAME",
2447     nargs=1,
2448     help="Used for the internal program name, which affects profile name "
2449     "and remoting. If not set, defaults to MOZ_APP_NAME.",
2453 @depends("MOZ_APP_REMOTINGNAME", moz_app_name)
2454 def moz_app_remotingname(value, moz_app_name):
2455     if value:
2456         return value[0]
2457     return moz_app_name
2460 set_config("MOZ_APP_REMOTINGNAME", moz_app_remotingname)
2462 option(
2463     env="ANDROID_PACKAGE_NAME",
2464     nargs=1,
2465     help="Name of the Android package (default org.mozilla.$MOZ_APP_NAME)",
2469 @depends("ANDROID_PACKAGE_NAME", moz_app_name)
2470 def android_package_name(value, moz_app_name):
2471     if value:
2472         return value[0]
2473     if moz_app_name == "fennec":
2474         return "org.mozilla.fennec_aurora"
2475     return "org.mozilla.%s" % moz_app_name
2478 set_config("ANDROID_PACKAGE_NAME", android_package_name)
2481 # Miscellaneous options
2482 # ==============================================================
2483 option(env="MOZ_WINCONSOLE", nargs="?", help="Whether we can create a console window.")
2484 set_define("MOZ_WINCONSOLE", True, when=depends("MOZ_WINCONSOLE")(lambda x: x))
2486 option(
2487     env="MOZ_USE_NATIVE_POPUP_WINDOWS",
2488     default=target_is_android,
2489     help="Whether to use native popup windows",
2492 set_define("MOZ_USE_NATIVE_POPUP_WINDOWS", True, when="MOZ_USE_NATIVE_POPUP_WINDOWS")
2495 # Alternative Crashreporter setting
2496 option(
2497     "--with-crashreporter-url",
2498     env="MOZ_CRASHREPORTER_URL",
2499     default="https://crash-reports.mozilla.com/",
2500     nargs=1,
2501     help="Set an alternative crashreporter url",
2504 set_config(
2505     "MOZ_CRASHREPORTER_URL",
2506     depends("--with-crashreporter-url")(lambda x: x[0].rstrip("/")),
2510 # Crash reporter options
2511 # ==============================================================
2512 @depends(target)
2513 def oxidized_breakpad(target):
2514     if target.kernel == "Linux" and target.os != "Android":
2515         return target.cpu in ("x86", "x86_64")
2516     return False
2519 set_config("MOZ_OXIDIZED_BREAKPAD", True, when=oxidized_breakpad)
2520 set_define("MOZ_OXIDIZED_BREAKPAD", True, when=oxidized_breakpad)
2523 # Wine
2524 # ==============================================================
2525 @depends(target, host)
2526 def want_wine(target, host):
2527     return target.kernel == "WINNT" and host.kernel != "WINNT"
2530 wine = check_prog(
2531     "WINE",
2532     ["wine64", "wine"],
2533     when=want_wine,
2534     bootstrap="wine/bin",