Bug 1726591 [wpt PR 30088] - Check if a <fe*Lighting> has a light source before inval...
[gecko.git] / toolkit / moz.configure
blob81ec31b7a6a825828ab2f73760a5cc8cd03d3428
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         "xrender",
1186     ]
1187     if webrtc:
1188         # third_party/libwebrtc/webrtc/webrtc_gn/moz.build adds those
1189         # manually, ensure they're available.
1190         libs += [
1191             "xcomposite",
1192             "xcursor",
1193             "xdamage",
1194             "xfixes",
1195             "xi",
1196         ]
1197     return " ".join(libs)
1200 pkg_check_modules("MOZ_X11", x11_libs, when=toolkit_gtk)
1203 # ASan Reporter Addon
1204 # ==============================================================
1205 option(
1206     "--enable-address-sanitizer-reporter",
1207     help="Enable Address Sanitizer Reporter Extension",
1211 @depends("--enable-address-sanitizer-reporter")
1212 def enable_asan_reporter(value):
1213     if value:
1214         return True
1217 set_config("MOZ_ASAN_REPORTER", enable_asan_reporter)
1218 set_define("MOZ_ASAN_REPORTER", enable_asan_reporter)
1219 add_old_configure_assignment("MOZ_ASAN_REPORTER", enable_asan_reporter)
1221 # Elfhack
1222 # ==============================================================
1223 with only_when("--enable-compile-environment"):
1225     @depends(host, target)
1226     def has_elfhack(host, target):
1227         return (
1228             target.kernel == "Linux"
1229             and host.kernel == "Linux"
1230             and target.cpu in ("arm", "x86", "x86_64")
1231         )
1233     @depends("--enable-release", enable_linker)
1234     def default_elfhack(release, linker):
1235         # Disable elfhack when explicitly building with --enable-linker=lld
1236         if linker and linker.origin != "default" and linker[0] == "lld":
1237             return False
1238         return bool(release)
1240     with only_when(has_elfhack):
1241         option(
1242             "--disable-elf-hack",
1243             default=default_elfhack,
1244             help="{Enable|Disable} elf hacks",
1245         )
1247         set_config("USE_ELF_HACK", depends_if("--enable-elf-hack")(lambda _: True))
1250 @depends(check_build_environment)
1251 def idl_roots(build_env):
1252     return namespace(
1253         ipdl_root=os.path.join(build_env.topobjdir, "ipc", "ipdl"),
1254         webidl_root=os.path.join(build_env.topobjdir, "dom", "bindings"),
1255         xpcom_root=os.path.join(build_env.topobjdir, "xpcom", "components"),
1256     )
1259 set_config("WEBIDL_ROOT", idl_roots.webidl_root)
1260 set_config("IPDL_ROOT", idl_roots.ipdl_root)
1261 set_config("XPCOM_ROOT", idl_roots.xpcom_root)
1263 # Proxy bypass protection
1264 # ==============================================================
1266 option(
1267     "--enable-proxy-bypass-protection",
1268     help="Prevent suspected or confirmed proxy bypasses",
1272 @depends_if("--enable-proxy-bypass-protection")
1273 def proxy_bypass_protection(_):
1274     return True
1277 set_config("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1278 set_define("MOZ_PROXY_BYPASS_PROTECTION", proxy_bypass_protection)
1280 # Proxy direct failover
1281 # ==============================================================
1283 option(
1284     "--disable-proxy-direct-failover",
1285     help="Disable direct failover for system requests",
1289 @depends_if("--disable-proxy-direct-failover")
1290 def proxy_direct_failover(value):
1291     if value:
1292         return True
1295 set_config("MOZ_PROXY_DIRECT_FAILOVER", proxy_direct_failover)
1296 set_define("MOZ_PROXY_DIRECT_FAILOVER", proxy_direct_failover)
1298 # MIDL
1299 # ==============================================================
1302 @depends(c_compiler, toolchain_prefix)
1303 def midl_names(c_compiler, toolchain_prefix):
1304     if c_compiler and c_compiler.type in ["gcc", "clang"]:
1305         # mingw
1306         widl = ("widl",)
1307         if toolchain_prefix:
1308             prefixed = tuple("%s%s" % (p, "widl") for p in toolchain_prefix)
1309             widl = prefixed + widl
1310         return widl
1312     return ("midl.exe",)
1315 @depends(target, "--enable-compile-environment")
1316 def check_for_midl(target, compile_environment):
1317     if target.os != "WINNT":
1318         return
1320     if compile_environment:
1321         return True
1324 midl = check_prog(
1325     "MIDL", midl_names, when=check_for_midl, allow_missing=True, paths=sdk_bin_path
1328 option(env="MIDL_FLAGS", nargs=1, help="Extra flags to pass to MIDL")
1331 @depends(
1332     "MIDL_FLAGS",
1333     c_compiler,
1334     target,
1335     host,
1336     midl,
1337     when=depends(midl, target)(lambda m, t: m and t.kernel == "WINNT"),
1339 def midl_flags(flags, c_compiler, target, host, midl):
1340     if flags:
1341         flags = flags[0].split()
1342     else:
1343         flags = []
1345     if not midl.endswith("widl"):
1346         env = {
1347             "x86": "win32",
1348             "x86_64": "x64",
1349             "aarch64": "arm64",
1350         }[target.cpu]
1351         flags += ["-env", env]
1353         if host.os == "WINNT":
1354             return flags + ["-cpp_cmd", c_compiler.compiler]
1356         # If cross-compiling and using midl instead of widl, for now, we'll
1357         # assume we can find the Windows version of clang-cl in the PATH.
1358         # It is required because while Wine is able to spawn Linux
1359         # processes from Windows programs(!), the calling program doesn't
1360         # have access to the process output and can't wait for it to
1361         # finish. Midl runs clang-cl as a preprocessor and expects to read
1362         # its output...
1363         clang_cl_exe = find_program("clang-cl.exe")
1364         if not clang_cl_exe:
1365             die("Cannot find clang-cl.exe")
1366         return flags + ["-cpp_cmd", clang_cl_exe]
1368     # widl
1369     return flags + {
1370         "x86": ["--win32", "-m32"],
1371         "x86_64": ["--win64", "-m64"],
1372     }[target.cpu]
1375 set_config("MIDL_FLAGS", midl_flags)
1377 # Accessibility
1378 # ==============================================================
1380 option("--disable-accessibility", help="Disable accessibility support")
1383 @depends("--enable-accessibility", check_for_midl, midl, c_compiler)
1384 def accessibility(value, check_for_midl, midl, c_compiler):
1385     enabled = bool(value)
1387     if not enabled:
1388         return
1390     if check_for_midl and not midl:
1391         if c_compiler and c_compiler.type in ("gcc", "clang"):
1392             die(
1393                 "You have accessibility enabled, but widl could not be found. "
1394                 "Add --disable-accessibility to your mozconfig or install widl. "
1395                 "See https://developer.mozilla.org/en-US/docs/Cross_Compile_Mozilla_for_Mingw32 for details."
1396             )
1397         else:
1398             die(
1399                 "MIDL could not be found. "
1400                 "Building accessibility without MIDL is not supported."
1401             )
1403     return enabled
1406 set_config("ACCESSIBILITY", accessibility)
1407 set_define("ACCESSIBILITY", accessibility)
1408 add_old_configure_assignment("ACCESSIBILITY", accessibility)
1411 # Addon signing
1412 # ==============================================================
1413 @depends(milestone)
1414 def require_signing(milestone):
1415     return milestone.is_release_or_beta and not milestone.is_esr
1418 option(
1419     env="MOZ_REQUIRE_SIGNING",
1420     default=require_signing,
1421     help="Enforce that add-ons are signed by the trusted root",
1424 set_config("MOZ_REQUIRE_SIGNING", True, when="MOZ_REQUIRE_SIGNING")
1425 set_define("MOZ_REQUIRE_SIGNING", True, when="MOZ_REQUIRE_SIGNING")
1427 option(
1428     "--with-unsigned-addon-scopes",
1429     nargs="+",
1430     choices=("app", "system"),
1431     help="Addon scopes where signature is not required",
1435 @depends("--with-unsigned-addon-scopes")
1436 def unsigned_addon_scopes(scopes):
1437     return namespace(
1438         app="app" in scopes or None,
1439         system="system" in scopes or None,
1440     )
1443 set_config("MOZ_UNSIGNED_APP_SCOPE", unsigned_addon_scopes.app)
1444 set_config("MOZ_UNSIGNED_SYSTEM_SCOPE", unsigned_addon_scopes.system)
1447 # Addon sideloading
1448 # ==============================================================
1449 option(
1450     "--allow-addon-sideload",
1451     default=milestone.is_esr,
1452     help="Addon sideloading is allowed",
1456 set_config("MOZ_ALLOW_ADDON_SIDELOAD", True, when="--allow-addon-sideload")
1458 # WebExtensions API WebIDL bindings
1459 # ==============================================================
1462 @depends(milestone)
1463 def extensions_webidl_bindings_default(milestone):
1464     # Only enable the webidl bindings for the WebExtensions APIs
1465     # in Nightly.
1466     return milestone.is_nightly
1469 option(
1470     "--enable-extensions-webidl-bindings",
1471     default=extensions_webidl_bindings_default,
1472     help="{Enable|Disable} building experimental WebExtensions WebIDL bindings",
1476 @depends("--enable-extensions-webidl-bindings")
1477 def extensions_webidl_enabled(value):
1478     return bool(value)
1481 set_config("MOZ_WEBEXT_WEBIDL_ENABLED", extensions_webidl_enabled)
1483 # Launcher process (Windows only)
1484 # ==============================================================
1487 @depends(target)
1488 def launcher_process_default(target):
1489     return target.os == "WINNT"
1492 option(
1493     "--enable-launcher-process",
1494     default=launcher_process_default,
1495     help="{Enable|Disable} launcher process by default",
1499 @depends("--enable-launcher-process", target)
1500 def launcher(value, target):
1501     enabled = bool(value)
1502     if enabled and target.os != "WINNT":
1503         die("Cannot enable launcher process on %s", target.os)
1504     if enabled:
1505         return True
1508 set_config("MOZ_LAUNCHER_PROCESS", launcher)
1509 set_define("MOZ_LAUNCHER_PROCESS", launcher)
1511 # llvm-dlltool (Windows only)
1512 # ==============================================================
1515 @depends(build_project, target, "--enable-compile-environment")
1516 def check_for_llvm_dlltool(build_project, target, compile_environment):
1517     if build_project != "browser":
1518         return
1520     if target.os != "WINNT":
1521         return
1523     return compile_environment
1526 llvm_dlltool = check_prog(
1527     "LLVM_DLLTOOL",
1528     ("llvm-dlltool",),
1529     what="llvm-dlltool",
1530     when=check_for_llvm_dlltool,
1531     paths=clang_search_path,
1535 @depends(target, when=llvm_dlltool)
1536 def llvm_dlltool_flags(target):
1537     arch = {
1538         "x86": "i386",
1539         "x86_64": "i386:x86-64",
1540         "aarch64": "arm64",
1541     }[target.cpu]
1543     return ["-m", arch]
1546 set_config("LLVM_DLLTOOL_FLAGS", llvm_dlltool_flags)
1548 # BITS download (Windows only)
1549 # ==============================================================
1551 option(
1552     "--enable-bits-download",
1553     when=target_is_windows,
1554     default=target_is_windows,
1555     help="{Enable|Disable} building BITS download support",
1558 set_define(
1559     "MOZ_BITS_DOWNLOAD",
1560     depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
1562 set_config(
1563     "MOZ_BITS_DOWNLOAD",
1564     depends_if("--enable-bits-download", when=target_is_windows)(lambda _: True),
1567 # Bundled fonts on desktop platform
1568 # ==============================================================
1571 @depends(target)
1572 def bundled_fonts_default(target):
1573     return target.os == "WINNT" or target.kernel == "Linux"
1576 @depends(build_project)
1577 def allow_bundled_fonts(project):
1578     return project == "browser" or project == "comm/mail"
1581 option(
1582     "--enable-bundled-fonts",
1583     default=bundled_fonts_default,
1584     when=allow_bundled_fonts,
1585     help="{Enable|Disable} support for bundled fonts on desktop platforms",
1588 set_define(
1589     "MOZ_BUNDLED_FONTS",
1590     depends_if("--enable-bundled-fonts", when=allow_bundled_fonts)(lambda _: True),
1593 # Reflow counting
1594 # ==============================================================
1597 @depends(moz_debug)
1598 def reflow_perf(debug):
1599     if debug:
1600         return True
1603 option(
1604     "--enable-reflow-perf",
1605     default=reflow_perf,
1606     help="{Enable|Disable} reflow performance tracing",
1609 # The difference in conditions here comes from the initial implementation
1610 # in old-configure, which was unexplained there as well.
1611 set_define("MOZ_REFLOW_PERF", depends_if("--enable-reflow-perf")(lambda _: True))
1612 set_define("MOZ_REFLOW_PERF_DSP", reflow_perf)
1614 # Layout debugger
1615 # ==============================================================
1618 @depends(moz_debug)
1619 def layout_debugger(debug):
1620     if debug:
1621         return True
1624 option(
1625     "--enable-layout-debugger",
1626     default=layout_debugger,
1627     help="{Enable|Disable} layout debugger",
1630 set_config("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
1631 set_define("MOZ_LAYOUT_DEBUGGER", True, when="--enable-layout-debugger")
1634 # Shader Compiler for Windows (and MinGW Cross Compile)
1635 # ==============================================================
1637 with only_when(compile_environment):
1638     fxc = check_prog(
1639         "FXC",
1640         ("fxc.exe", "fxc2.exe"),
1641         when=depends(target)(lambda t: t.kernel == "WINNT"),
1642         paths=sdk_bin_path,
1643     )
1646 # VPX
1647 # ===
1649 with only_when(compile_environment):
1650     system_lib_option(
1651         "--with-system-libvpx", help="Use system libvpx (located with pkgconfig)"
1652     )
1654     with only_when("--with-system-libvpx"):
1655         vpx = pkg_check_modules("MOZ_LIBVPX", "vpx >= 1.8.0")
1657         check_header(
1658             "vpx/vpx_decoder.h",
1659             flags=vpx.cflags,
1660             onerror=lambda: die(
1661                 "Couldn't find vpx/vpx_decoder.h, which is required to build "
1662                 "with system libvpx. Use --without-system-libvpx to build "
1663                 "with in-tree libvpx."
1664             ),
1665         )
1667         check_symbol(
1668             "vpx_codec_dec_init_ver",
1669             flags=vpx.libs,
1670             onerror=lambda: die(
1671                 "--with-system-libvpx requested but symbol vpx_codec_dec_init_ver "
1672                 "not found"
1673             ),
1674         )
1676         set_config("MOZ_SYSTEM_LIBVPX", True)
1678     @depends("--with-system-libvpx", target)
1679     def in_tree_vpx(system_libvpx, target):
1680         if system_libvpx:
1681             return
1683         arm_asm = (target.cpu == "arm") or None
1684         return namespace(arm_asm=arm_asm)
1686     @depends(target, when=in_tree_vpx)
1687     def vpx_nasm(target):
1688         if target.cpu in ("x86", "x86_64"):
1689             if target.kernel == "WINNT":
1690                 # Version 2.03 is needed for automatic safeseh support.
1691                 return namespace(version="2.03", what="VPX")
1692             return namespace(what="VPX")
1694     # Building with -mfpu=neon requires either the "softfp" or the
1695     # "hardfp" ABI. Depending on the compiler's default target, and the
1696     # CFLAGS, the default ABI might be neither, in which case it is the
1697     # "softfloat" ABI.
1698     # The "softfloat" ABI is binary-compatible with the "softfp" ABI, so
1699     # we can safely mix code built with both ABIs. So, if we detect
1700     # that compiling uses the "softfloat" ABI, force the use of the
1701     # "softfp" ABI instead.
1702     # Confusingly, the __SOFTFP__ preprocessor variable indicates the
1703     # "softfloat" ABI, not the "softfp" ABI.
1704     # Note: VPX_ASFLAGS is also used in CFLAGS.
1705     softfp = cxx_compiler.try_compile(
1706         body="""
1707         #ifndef __SOFTFP__
1708         #error "compiler target supports -mfpu=neon, so we don't have to add extra flags"
1709         #endif""",
1710         when=in_tree_vpx.arm_asm,
1711     )
1713     @depends(in_tree_vpx, vpx_nasm, softfp, target)
1714     def vpx_as_flags(vpx, vpx_nasm, softfp, target):
1715         flags = []
1716         if vpx and vpx.arm_asm:
1717             # These flags are a lie; they're just used to enable the requisite
1718             # opcodes; actual arch detection is done at runtime.
1719             flags = ["-march=armv7-a", "-mfpu=neon"]
1720             if softfp:
1721                 flags.append("-mfloat-abi=softfp")
1722         elif vpx and vpx_nasm and target.os != "WINNT" and target.cpu != "x86_64":
1723             flags = ["-DPIC"]
1724         return flags
1726     set_config("VPX_USE_NASM", True, when=vpx_nasm)
1727     set_config("VPX_ASFLAGS", vpx_as_flags)
1730 # JPEG
1731 # ====
1733 with only_when(compile_environment):
1734     system_lib_option(
1735         "--with-system-jpeg",
1736         nargs="?",
1737         help="Use system libjpeg (installed at given prefix)",
1738     )
1740     @depends_if("--with-system-jpeg")
1741     def jpeg_flags(value):
1742         if len(value):
1743             return namespace(
1744                 cflags=("-I%s/include" % value[0],),
1745                 ldflags=("-L%s/lib" % value[0], "-ljpeg"),
1746             )
1747         return namespace(
1748             ldflags=("-ljpeg",),
1749         )
1751     with only_when("--with-system-jpeg"):
1752         check_symbol(
1753             "jpeg_destroy_compress",
1754             flags=jpeg_flags.ldflags,
1755             onerror=lambda: die(
1756                 "--with-system-jpeg requested but symbol "
1757                 "jpeg_destroy_compress not found."
1758             ),
1759         )
1761         c_compiler.try_compile(
1762             includes=[
1763                 "stdio.h",
1764                 "sys/types.h",
1765                 "jpeglib.h",
1766             ],
1767             body="""
1768                 #if JPEG_LIB_VERSION < 62
1769                 #error Insufficient JPEG library version
1770                 #endif
1771             """,
1772             flags=jpeg_flags.cflags,
1773             check_msg="for sufficient jpeg library version",
1774             onerror=lambda: die(
1775                 "Insufficient JPEG library version for "
1776                 "--with-system-jpeg (62 required)"
1777             ),
1778         )
1780         c_compiler.try_compile(
1781             includes=[
1782                 "stdio.h",
1783                 "sys/types.h",
1784                 "jpeglib.h",
1785             ],
1786             body="""
1787                 #ifndef JCS_EXTENSIONS
1788                 #error libjpeg-turbo JCS_EXTENSIONS required
1789                 #endif
1790             """,
1791             flags=jpeg_flags.cflags,
1792             check_msg="for sufficient libjpeg-turbo JCS_EXTENSIONS",
1793             onerror=lambda: die(
1794                 "libjpeg-turbo JCS_EXTENSIONS required for " "--with-system-jpeg"
1795             ),
1796         )
1798         set_config("MOZ_JPEG_CFLAGS", jpeg_flags.cflags)
1799         set_config("MOZ_JPEG_LIBS", jpeg_flags.ldflags)
1801     @depends("--with-system-jpeg", target)
1802     def in_tree_jpeg(system_jpeg, target):
1803         if system_jpeg:
1804             return
1806         if target.kernel == "Darwin":
1807             if target.cpu == "x86":
1808                 return ("-DPIC", "-DMACHO")
1809             elif target.cpu == "x86_64":
1810                 return ("-D__x86_64__", "-DPIC", "-DMACHO")
1811         elif target.kernel == "WINNT":
1812             if target.cpu == "x86":
1813                 return ("-DPIC", "-DWIN32")
1814             elif target.cpu == "x86_64":
1815                 return ("-D__x86_64__", "-DPIC", "-DWIN64", "-DMSVC")
1816         elif target.cpu == "arm":
1817             return ("-march=armv7-a", "-mfpu=neon")
1818         elif target.cpu == "aarch64":
1819             return ("-march=armv8-a",)
1820         elif target.cpu == "mips32":
1821             return ("-mdspr2",)
1822         elif target.cpu == "x86":
1823             return ("-DPIC", "-DELF")
1824         elif target.cpu == "x86_64":
1825             return ("-D__x86_64__", "-DPIC", "-DELF")
1827     @depends(target, when=in_tree_jpeg)
1828     def jpeg_nasm(target):
1829         if target.cpu in ("x86", "x86_64"):
1830             # libjpeg-turbo 2.0.6 requires nasm 2.10.
1831             return namespace(version="2.10", what="JPEG")
1833     set_config("LIBJPEG_TURBO_USE_NASM", True, when=jpeg_nasm)
1834     set_config("LIBJPEG_TURBO_ASFLAGS", in_tree_jpeg)
1837 # FFmpeg's ffvpx configuration
1838 # ==============================================================
1839 with only_when(compile_environment):
1841     @depends(target)
1842     def libav_fft(target):
1843         return target.kernel == "WINNT" or target.cpu == "x86_64"
1845     set_config("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
1846     set_define("MOZ_LIBAV_FFT", depends(when=libav_fft)(lambda: True))
1849 # Artifact builds need MOZ_FFVPX defined as if compilation happened.
1850 with only_when(compile_environment | artifact_builds):
1852     @depends(target)
1853     def ffvpx(target):
1854         enable = use_nasm = True
1855         flac_only = False
1856         flags = []
1858         if target.kernel == "WINNT":
1859             if target.cpu == "x86":
1860                 # 32-bit windows need to prefix symbols with an underscore.
1861                 flags = ["-DPIC", "-DWIN32", "-DPREFIX", "-Pconfig_win32.asm"]
1862             elif target.cpu == "x86_64":
1863                 flags = [
1864                     "-D__x86_64__",
1865                     "-DPIC",
1866                     "-DWIN64",
1867                     "-DMSVC",
1868                     "-Pconfig_win64.asm",
1869                 ]
1870             elif target.cpu == "aarch64":
1871                 flags = ["-DPIC", "-DWIN64"]
1872                 use_nasm = False
1873         elif target.kernel == "Darwin":
1874             if target.cpu == "x86_64":
1875                 # 32/64-bit macosx asemblers need to prefix symbols with an
1876                 # underscore.
1877                 flags = [
1878                     "-D__x86_64__",
1879                     "-DPIC",
1880                     "-DMACHO",
1881                     "-DPREFIX",
1882                     "-Pconfig_darwin64.asm",
1883                 ]
1884             else:
1885                 flac_only = True
1886         elif target.cpu == "x86_64":
1887             flags = ["-D__x86_64__", "-DPIC", "-DELF", "-Pconfig_unix64.asm"]
1888         elif target.cpu in ("x86", "arm", "aarch64"):
1889             flac_only = True
1890         else:
1891             enable = False
1893         if flac_only or not enable:
1894             use_nasm = False
1896         if use_nasm:
1897             # default disabled components
1898             flags.append("-Pdefaults_disabled.asm")
1900         return namespace(
1901             enable=enable,
1902             use_nasm=use_nasm,
1903             flac_only=flac_only,
1904             flags=flags,
1905         )
1907     @depends(when=ffvpx.use_nasm)
1908     def ffvpx_nasm():
1909         # nasm 2.10 for AVX-2 support.
1910         return namespace(version="2.10", what="FFVPX")
1912     # ffvpx_nasm can't indirectly depend on vpx_as_flags, because it depends
1913     # on a compiler test, so we have to do a little bit of dance here.
1914     @depends(ffvpx, vpx_as_flags, target)
1915     def ffvpx(ffvpx, vpx_as_flags, target):
1916         if ffvpx and vpx_as_flags and target.cpu in ("arm", "aarch64"):
1917             ffvpx.flags.extend(vpx_as_flags)
1918         return ffvpx
1920     set_config("MOZ_FFVPX", True, when=ffvpx.enable)
1921     set_define("MOZ_FFVPX", True, when=ffvpx.enable)
1922     set_config("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.flac_only)
1923     set_define("MOZ_FFVPX_AUDIOONLY", True, when=ffvpx.flac_only)
1924     set_config("FFVPX_ASFLAGS", ffvpx.flags)
1925     set_config("FFVPX_USE_NASM", True, when=ffvpx.use_nasm)
1928 # nasm detection
1929 # ==============================================================
1930 @depends(dav1d_nasm, vpx_nasm, jpeg_nasm, ffvpx_nasm, when=compile_environment)
1931 def need_nasm(*requirements):
1932     requires = {
1933         x.what: x.version if hasattr(x, "version") else True for x in requirements if x
1934     }
1935     if requires:
1936         items = sorted(requires.keys())
1937         if len(items) > 1:
1938             what = " and ".join((", ".join(items[:-1]), items[-1]))
1939         else:
1940             what = items[0]
1941         versioned = {k: v for (k, v) in requires.items() if v is not True}
1942         return namespace(what=what, versioned=versioned)
1945 nasm = check_prog(
1946     "NASM",
1947     ["nasm"],
1948     allow_missing=True,
1949     bootstrap="nasm",
1950     when=need_nasm,
1954 @depends(nasm, need_nasm.what)
1955 def check_nasm(nasm, what):
1956     if not nasm and what:
1957         die("Nasm is required to build with %s, but it was not found." % what)
1958     return nasm
1961 @depends_if(check_nasm)
1962 @checking("nasm version")
1963 def nasm_version(nasm):
1964     version = (
1965         check_cmd_output(nasm, "-v", onerror=lambda: die("Failed to get nasm version."))
1966         .splitlines()[0]
1967         .split()[2]
1968     )
1969     return Version(version)
1972 @depends(nasm_version, need_nasm.versioned, when=need_nasm.versioned)
1973 def check_nasm_version(nasm_version, versioned):
1974     by_version = sorted(versioned.items(), key=lambda x: x[1])
1975     what, version = by_version[-1]
1976     if nasm_version < version:
1977         die(
1978             "Nasm version %s or greater is required to build with %s." % (version, what)
1979         )
1980     return nasm_version
1983 @depends(target, when=check_nasm_version)
1984 def nasm_asflags(target):
1985     asflags = {
1986         ("OSX", "x86"): ["-f", "macho32"],
1987         ("OSX", "x86_64"): ["-f", "macho64"],
1988         ("WINNT", "x86"): ["-f", "win32"],
1989         ("WINNT", "x86_64"): ["-f", "win64"],
1990     }.get((target.os, target.cpu), None)
1991     if asflags is None:
1992         # We're assuming every x86 platform we support that's
1993         # not Windows or Mac is ELF.
1994         if target.cpu == "x86":
1995             asflags = ["-f", "elf32"]
1996         elif target.cpu == "x86_64":
1997             asflags = ["-f", "elf64"]
1998     return asflags
2001 set_config("NASM_ASFLAGS", nasm_asflags)
2004 # ANGLE OpenGL->D3D translator for WebGL
2005 # ==============================================================
2007 with only_when(compile_environment & target_is_windows):
2009     def d3d_compiler_dll_result(value):
2010         if not value.path:
2011             return "provided by the OS"
2012         return value.path
2014     @depends(target, valid_windows_sdk_dir, fxc)
2015     @checking("for D3D compiler DLL", d3d_compiler_dll_result)
2016     @imports("os.path")
2017     def d3d_compiler_dll(target, windows_sdk_dir, fxc):
2018         suffix = {
2019             "x86_64": "x64",
2020         }.get(target.cpu, target.cpu)
2022         name = "d3dcompiler_47.dll"
2024         if target.cpu == "aarch64":
2025             # AArch64 Windows comes with d3dcompiler_47.dll installed
2026             return namespace(name=name, path=None)
2028         if windows_sdk_dir:
2029             path = os.path.join(windows_sdk_dir.path, "Redist", "D3D", suffix, name)
2030             error_extra = "in Windows SDK at {}".format(windows_sdk_dir.path)
2031         else:
2032             path = os.path.join(os.path.dirname(fxc), name)
2033             error_extra = "alongside FXC at {}".format(fxc)
2035         if os.path.exists(path):
2036             return namespace(name=name, path=path)
2037         die("Could not find {} {}".format(name, error_extra))
2039     set_config("MOZ_ANGLE_RENDERER", True)
2040     set_config(
2041         "MOZ_D3DCOMPILER_VISTA_DLL", d3d_compiler_dll.name, when=d3d_compiler_dll.path
2042     )
2043     set_config("MOZ_D3DCOMPILER_VISTA_DLL_PATH", d3d_compiler_dll.path)
2045 # Remoting protocol support
2046 # ==============================================================
2049 @depends(toolkit)
2050 def has_remote(toolkit):
2051     if toolkit in ("gtk", "windows", "cocoa"):
2052         return True
2055 set_config("MOZ_HAS_REMOTE", has_remote)
2056 set_define("MOZ_HAS_REMOTE", has_remote)
2058 # RLBox Library Sandboxing wasm support
2059 # ==============================================================
2062 def wasm_sandboxing_libraries():
2063     return (
2064         "graphite",
2065         "ogg",
2066         "hunspell",
2067     )
2070 @depends(dependable(wasm_sandboxing_libraries), "MOZ_AUTOMATION")
2071 def default_wasm_sandboxing_libraries(libraries, automation):
2072     if automation:
2073         return libraries
2076 option(
2077     "--with-wasm-sandboxed-libraries",
2078     env="WASM_SANDBOXED_LIBRARIES",
2079     help="{Enable wasm sandboxing for the selected libraries|Disable wasm sandboxing}",
2080     nargs="+",
2081     choices=dependable(wasm_sandboxing_libraries),
2082     default=default_wasm_sandboxing_libraries,
2086 @depends("--with-wasm-sandboxed-libraries")
2087 def requires_wasm_sandboxing(libraries):
2088     if libraries:
2089         return True
2092 set_config("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
2093 set_define("MOZ_USING_WASM_SANDBOXING", requires_wasm_sandboxing)
2095 with only_when(requires_wasm_sandboxing & compile_environment):
2096     option(
2097         "--with-wasi-sysroot",
2098         env="WASI_SYSROOT",
2099         nargs=1,
2100         help="Path to wasi sysroot for wasm sandboxing",
2101     )
2103     @depends("--with-wasi-sysroot", requires_wasm_sandboxing)
2104     def bootstrap_wasi_sysroot(wasi_sysroot, requires_wasm_sandboxing):
2105         return requires_wasm_sandboxing and not wasi_sysroot
2107     @depends(
2108         "--with-wasi-sysroot",
2109         bootstrap_path("sysroot-wasm32-wasi", when=bootstrap_wasi_sysroot),
2110     )
2111     @imports("os")
2112     def wasi_sysroot(wasi_sysroot, bootstrapped_sysroot):
2113         if not wasi_sysroot:
2114             if not bootstrapped_sysroot:
2115                 die(
2116                     "Cannot find a wasi sysroot. Please give its location with "
2117                     "--with-wasi-sysroot."
2118                 )
2119             return bootstrapped_sysroot
2121         wasi_sysroot = wasi_sysroot[0]
2122         if not os.path.isdir(wasi_sysroot):
2123             die("Argument to --with-wasi-sysroot must be a directory")
2124         if not os.path.isabs(wasi_sysroot):
2125             die("Argument to --with-wasi-sysroot must be an absolute path")
2127         return wasi_sysroot
2129     set_config("WASI_SYSROOT", wasi_sysroot)
2131     def wasm_compiler_with_flags(compiler, sysroot):
2132         if not sysroot:
2133             return
2134         elif compiler:
2135             return (
2136                 compiler.wrapper
2137                 + [compiler.compiler]
2138                 + compiler.flags
2139                 + ["--sysroot=%s" % sysroot]
2140             )
2142     wasm_cc = compiler("C", wasm, other_compiler=c_compiler)
2144     @depends(wasm_cc, wasi_sysroot)
2145     def wasm_cc_with_flags(wasm_cc, wasi_sysroot):
2146         return wasm_compiler_with_flags(wasm_cc, wasi_sysroot)
2148     set_config("WASM_CC", wasm_cc_with_flags)
2150     wasm_cxx = compiler(
2151         "C++",
2152         wasm,
2153         c_compiler=wasm_cc,
2154         other_compiler=cxx_compiler,
2155         other_c_compiler=c_compiler,
2156     )
2158     @depends(wasm_cxx, wasi_sysroot)
2159     def wasm_cxx_with_flags(wasm_cxx, wasi_sysroot):
2160         return wasm_compiler_with_flags(wasm_cxx, wasi_sysroot)
2162     set_config("WASM_CXX", wasm_cxx_with_flags)
2164     wasm_compile_flags = dependable(
2165         ["-fno-exceptions", "-fno-strict-aliasing", "-Qunused-arguments"]
2166     )
2167     option(env="WASM_CFLAGS", nargs=1, help="Options to pass to WASM_CC")
2169     @depends("WASM_CFLAGS", wasm_compile_flags)
2170     def wasm_cflags(value, wasm_compile_flags):
2171         if value:
2172             return wasm_compile_flags + value
2173         else:
2174             return wasm_compile_flags
2176     set_config("WASM_CFLAGS", wasm_cflags)
2178     option(env="WASM_CXXFLAGS", nargs=1, help="Options to pass to WASM_CXX")
2180     @depends("WASM_CXXFLAGS", wasm_compile_flags)
2181     def wasm_cxxflags(value, wasm_compile_flags):
2182         if value:
2183             return wasm_compile_flags + value
2184         else:
2185             return wasm_compile_flags
2187     set_config("WASM_CXXFLAGS", wasm_cxxflags)
2190 @depends("--with-wasm-sandboxed-libraries")
2191 def wasm_sandboxing(libraries):
2192     if not libraries:
2193         return
2195     return namespace(**{name: True for name in libraries})
2198 @template
2199 def wasm_sandboxing_config_defines():
2200     for lib in wasm_sandboxing_libraries():
2201         set_config(
2202             "MOZ_WASM_SANDBOXING_%s" % lib.upper(), getattr(wasm_sandboxing, lib)
2203         )
2204         set_define(
2205             "MOZ_WASM_SANDBOXING_%s" % lib.upper(), getattr(wasm_sandboxing, lib)
2206         )
2209 wasm_sandboxing_config_defines()
2212 # new XULStore implementation
2213 # ==============================================================
2216 @depends(milestone)
2217 def new_xulstore(milestone):
2218     if milestone.is_nightly:
2219         return True
2222 set_config("MOZ_NEW_XULSTORE", True, when=new_xulstore)
2223 set_define("MOZ_NEW_XULSTORE", True, when=new_xulstore)
2226 # new Notification Store implementation
2227 # ==============================================================
2230 @depends(milestone)
2231 def new_notification_store(milestone):
2232     if milestone.is_nightly:
2233         return True
2236 set_config("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)
2237 set_define("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)
2240 # Glean SDK Integration Crate
2241 # ==============================================================
2244 @depends(target)
2245 def glean_android(target):
2246     return target.os == "Android"
2249 set_config("MOZ_GLEAN_ANDROID", True, when=glean_android)
2250 set_define("MOZ_GLEAN_ANDROID", True, when=glean_android)
2253 # dump_syms
2254 # ==============================================================
2256 check_prog(
2257     "DUMP_SYMS",
2258     ["dump_syms"],
2259     allow_missing=True,
2260     bootstrap="dump_syms",
2261     when=compile_environment,
2265 check_prog(
2266     "PDBSTR",
2267     ["pdbstr.exe"],
2268     allow_missing=True,
2269     bootstrap="pdbstr",
2270     when=compile_environment & target_is_windows,
2274 @depends("MOZ_AUTOMATION", c_compiler)
2275 def allow_missing_winchecksec(automation, c_compiler):
2276     if not automation:
2277         return True
2278     if c_compiler and c_compiler.type != "clang-cl":
2279         return True
2282 check_prog(
2283     "WINCHECKSEC",
2284     ["winchecksec.exe", "winchecksec"],
2285     bootstrap="winchecksec",
2286     allow_missing=allow_missing_winchecksec,
2287     when=compile_environment & target_is_windows,
2290 # Fork server
2291 @depends(target, build_project)
2292 def forkserver_default(target, build_project):
2293     return build_project == "browser" and (
2294         (target.os == "GNU" and target.kernel == "Linux")
2295         or target.os == "FreeBSD"
2296         or target.os == "OpenBSD"
2297     )
2300 option(
2301     "--enable-forkserver",
2302     default=forkserver_default,
2303     env="MOZ_ENABLE_FORKSERVER",
2304     help="{Enable|Disable} fork server",
2308 @depends("--enable-forkserver", target)
2309 def forkserver_flag(value, target):
2310     if (
2311         target.os == "Android"
2312         or (target.os == "GNU" and target.kernel == "Linux")
2313         or target.os == "FreeBSD"
2314         or target.os == "OpenBSD"
2315     ):
2316         return bool(value)
2317     pass
2320 set_config("MOZ_ENABLE_FORKSERVER", forkserver_flag)
2321 set_define("MOZ_ENABLE_FORKSERVER", forkserver_flag, forkserver_flag)
2323 # Crash Reporter
2324 # ==============================================================
2326 with only_when(compile_environment & target_is_linux):
2327     # Check if we need to use the breakpad_getcontext fallback.
2328     getcontext = check_symbol("getcontext")
2329     set_config("HAVE_GETCONTEXT", getcontext)
2330     set_define("HAVE_GETCONTEXT", getcontext)
2332 # NSS
2333 # ==============================================================
2334 include("../build/moz.configure/nss.configure")
2337 # Enable or disable running in background task mode: headless for
2338 # periodic, short-lived, maintenance tasks.
2339 # ==============================================================================
2342 option(
2343     "--disable-backgroundtasks",
2344     help="Disable running in background task mode",
2348 set_config(
2349     "MOZ_BACKGROUNDTASKS", depends_if("--enable-backgroundtasks")(lambda _: True)
2353 # Update-related programs: updater, maintenance service, update agent,
2354 # default browser agent.
2355 # ==============================================================
2356 include("../build/moz.configure/update-programs.configure")
2359 # Mobile optimizations
2360 # ==============================================================
2361 option(
2362     "--enable-mobile-optimize",
2363     default=target_is_android,
2364     help="{Enable|Disable} mobile optimizations",
2367 set_define("MOZ_GFX_OPTIMIZE_MOBILE", True, when="--enable-mobile-optimize")
2368 # We ignore "paint will resample" on mobile for performance.
2369 # We may want to revisit this later.
2370 set_define("MOZ_IGNORE_PAINT_WILL_RESAMPLE", True, when="--enable-mobile-optimize")
2372 # Pref extensions
2373 # ==============================================================
2374 option("--disable-pref-extensions", help="Disable pref extensions such as autoconfig")
2375 set_config("MOZ_PREF_EXTENSIONS", True, when="--enable-pref-extensions")
2377 # Offer a way to disable the startup cache
2378 # ==============================================================
2379 option("--disable-startupcache", help="Disable startup cache")
2382 @depends("--enable-startupcache")
2383 def enable_startupcache(value):
2384     if value:
2385         return True
2388 set_define(
2389     "MOZ_DISABLE_STARTUPCACHE", True, when=depends(enable_startupcache)(lambda x: not x)
2393 # Branding
2394 # ==============================================================
2395 option(
2396     env="MOZ_APP_REMOTINGNAME",
2397     nargs=1,
2398     help="Used for the internal program name, which affects profile name "
2399     "and remoting. If not set, defaults to MOZ_APP_NAME.",
2403 @depends("MOZ_APP_REMOTINGNAME", moz_app_name)
2404 def moz_app_remotingname(value, moz_app_name):
2405     if value:
2406         return value[0]
2407     return moz_app_name
2410 set_config("MOZ_APP_REMOTINGNAME", moz_app_remotingname)
2412 option(
2413     env="ANDROID_PACKAGE_NAME",
2414     nargs=1,
2415     help="Name of the Android package (default org.mozilla.$MOZ_APP_NAME)",
2419 @depends("ANDROID_PACKAGE_NAME", moz_app_name)
2420 def android_package_name(value, moz_app_name):
2421     if value:
2422         return value[0]
2423     if moz_app_name == "fennec":
2424         return "org.mozilla.fennec_aurora"
2425     return "org.mozilla.%s" % moz_app_name
2428 set_config("ANDROID_PACKAGE_NAME", android_package_name)
2431 # Miscellaneous options
2432 # ==============================================================
2433 option(env="MOZ_WINCONSOLE", nargs="?", help="Whether we can create a console window.")
2434 set_define("MOZ_WINCONSOLE", True, when=depends("MOZ_WINCONSOLE")(lambda x: x))
2436 option(
2437     env="MOZ_USE_NATIVE_POPUP_WINDOWS",
2438     default=target_is_android,
2439     help="Whether to use native popup windows",
2442 set_define("MOZ_USE_NATIVE_POPUP_WINDOWS", True, when="MOZ_USE_NATIVE_POPUP_WINDOWS")
2445 # Alternative Crashreporter setting
2446 option(
2447     "--with-crashreporter-url",
2448     env="MOZ_CRASHREPORTER_URL",
2449     default="https://crash-reports.mozilla.com/",
2450     nargs=1,
2451     help="Set an alternative crashreporter url",
2454 set_config(
2455     "MOZ_CRASHREPORTER_URL",
2456     depends("--with-crashreporter-url")(lambda x: x[0].rstrip("/")),
2460 # Crash reporter options
2461 # ==============================================================
2462 @depends(target)
2463 def oxidized_breakpad(target):
2464     if target.kernel == "Linux" and target.os != "Android":
2465         return target.cpu in ("x86", "x86_64")
2466     return False
2469 set_config("MOZ_OXIDIZED_BREAKPAD", True, when=oxidized_breakpad)
2470 set_define("MOZ_OXIDIZED_BREAKPAD", True, when=oxidized_breakpad)