Bug 1669129 - [devtools] Enable devtools.overflow.debugging.enabled. r=jdescottes
[gecko.git] / toolkit / moz.configure
bloba30c6b227481334561cc9f0c236f25f2ef77cc50
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 (value is not None and value.origin not in ('default', 'implied') and
32                 value != option.default):
33             result.append(ensure_unicode(__sandbox__._raw_options[option],
34                                          system_encoding))
35         # We however always include options that are sent to old configure
36         # because we don't know their actual defaults. (Keep the conditions
37         # separate for ease of understanding and ease of removal)
38         elif (option.help == 'Help missing for old configure options' and
39                 option in __sandbox__._raw_options):
40             result.append(ensure_unicode(__sandbox__._raw_options[option],
41                                          system_encoding))
43     # We shouldn't need this, but currently, quote will return a byte string
44     # if result is empty, and that's not wanted here.
45     if not result:
46         return ''
48     return quote(*result)
51 set_config('MOZ_CONFIGURE_OPTIONS', all_configure_options)
53 @depends(target)
54 def fold_libs(target):
55     return target.os in ('WINNT', 'OSX', 'Android')
57 set_config('MOZ_FOLD_LIBS', fold_libs)
59 # Profiling
60 # ==============================================================
61 # Some of the options here imply an option from js/moz.configure,
62 # so, need to be declared before the include.
64 option('--enable-jprof', env='MOZ_JPROF',
65        help='Enable jprof profiling tool (needs mozilla/tools/jprof)')
67 @depends('--enable-jprof')
68 def jprof(value):
69     if value:
70         return True
72 set_config('MOZ_JPROF', jprof)
73 set_define('MOZ_JPROF', jprof)
74 imply_option('--enable-profiling', jprof)
76 @depends(target)
77 def gecko_profiler(target):
78     if target.os == 'Android':
79         return target.cpu in ('aarch64', 'arm', 'x86', 'x86_64')
80     elif target.kernel == 'Linux':
81         return target.cpu in ('aarch64', 'arm', 'x86', 'x86_64', 'mips64')
82     elif target.kernel == 'FreeBSD':
83         return target.cpu in ('aarch64', 'x86_64')
84     return target.os in ('OSX', 'WINNT')
86 @depends(gecko_profiler)
87 def gecko_profiler_define(value):
88     if value:
89         return True
91 set_config('MOZ_GECKO_PROFILER', gecko_profiler_define)
92 set_define('MOZ_GECKO_PROFILER', gecko_profiler_define)
95 # Whether code to parse ELF binaries should be compiled for the Gecko profiler
96 # (for symbol table dumping).
97 @depends(gecko_profiler, target)
98 def gecko_profiler_parse_elf(value, target):
99     # Currently we only want to build this code on Linux (including Android) and BSD.
100     # For Android, this is in order to dump symbols from Android system, where
101     # on other platforms there exist alternatives that don't require bloating
102     # up our binary size. For Linux more generally, we use this in profile
103     # pre-symbolication support, since MozDescribeCodeAddress doesn't do
104     # anything useful on that platform. (Ideally, we would update
105     # MozDescribeCodeAddress to call into some Rust crates that parse ELF and
106     # DWARF data, but build system issues currently prevent Rust from being
107     # used in mozglue.)
108     if value and (target.kernel == 'Linux' or target.kernel == 'FreeBSD'):
109         return True
111 set_config('MOZ_GECKO_PROFILER_PARSE_ELF', gecko_profiler_parse_elf)
112 set_define('MOZ_GECKO_PROFILER_PARSE_ELF', gecko_profiler_parse_elf)
114 # enable this by default if the profiler is enabled
115 # Note: also requires jemalloc
116 set_config('MOZ_PROFILER_MEMORY', gecko_profiler_define)
117 set_define('MOZ_PROFILER_MEMORY', gecko_profiler_define)
120 @depends('--enable-debug', milestone, build_project,
121          # Artifact builds are included because the downloaded artifacts can
122          # have DMD enabled.
123          when=artifact_builds | depends(when='--enable-replace-malloc')(lambda: True))
124 def dmd_default(debug, milestone, build_project):
125     return bool(build_project == 'browser' and (debug or milestone.is_nightly))
128 option('--enable-dmd', env='MOZ_DMD', default=dmd_default,
129        help='{Enable|Disable} Dark Matter Detector (heap profiler). '
130             'Also enables jemalloc, replace-malloc and profiling')
133 @depends('--enable-dmd')
134 def dmd(value):
135     if value:
136         return True
139 set_config('MOZ_DMD', dmd)
140 set_define('MOZ_DMD', dmd)
141 add_old_configure_assignment('MOZ_DMD', dmd)
142 imply_option('--enable-profiling', dmd)
143 imply_option('--enable-jemalloc', dmd, when=compile_environment)
144 imply_option('--enable-replace-malloc', dmd, when=compile_environment)
146 # ALSA cubeb backend
147 # ==============================================================
148 option('--enable-alsa', env='MOZ_ALSA',
149        help='Enable ALSA audio backend.')
151 alsa = pkg_check_modules('MOZ_ALSA', 'alsa', when='--enable-alsa')
153 set_config('MOZ_ALSA', depends_if(alsa)(lambda _: True))
154 set_define('MOZ_ALSA', depends_if(alsa)(lambda _: True))
156 # JACK cubeb backend
157 # ==============================================================
158 option('--enable-jack', env='MOZ_JACK',
159        help='Enable JACK audio backend.')
161 jack = pkg_check_modules('MOZ_JACK', 'jack', when='--enable-jack')
163 set_config('MOZ_JACK', depends_if(jack)(lambda _: True))
164 set_define('MOZ_JACK', depends_if(jack)(lambda _: True))
166 # PulseAudio cubeb backend
167 # ==============================================================
168 @depends(target)
169 def pulseaudio_default(target):
170     return target.os not in ('WINNT', 'OSX', 'Android', 'OpenBSD')
172 option('--enable-pulseaudio', env='MOZ_PULSEAUDIO', default=pulseaudio_default,
173        help='{Enable|Disable} PulseAudio audio backend.')
175 pulseaudio = pkg_check_modules('MOZ_PULSEAUDIO', 'libpulse', when='--enable-pulseaudio')
177 set_config('MOZ_PULSEAUDIO', depends_if(pulseaudio)(lambda _: True))
178 set_define('MOZ_PULSEAUDIO', depends_if(pulseaudio)(lambda _: True))
180 # AudioUnit cubeb Rust backend
181 # ==============================================================
182 @depends(target)
183 def enable_audiounit_rust(target):
184     return target.os == 'OSX' and target.kernel == 'Darwin'
186 set_config('MOZ_AUDIOUNIT_RUST', True, when=enable_audiounit_rust)
187 set_define('MOZ_AUDIOUNIT_RUST', True, when=enable_audiounit_rust)
189 # Javascript engine
190 # ==============================================================
191 include('../js/moz.configure')
194 # NodeJS
195 # ==============================================================
196 include('../build/moz.configure/node.configure')
198 # L10N
199 # ==============================================================
200 option('--with-l10n-base', nargs=1, env='L10NBASEDIR',
201        help='Path to l10n repositories')
203 @depends('--with-l10n-base', 'MOZ_AUTOMATION', check_build_environment)
204 @imports(_from='os.path', _import='isdir')
205 @imports(_from='os.path', _import='expanduser')
206 @imports(_from='os', _import='environ')
207 def l10n_base(value, automation, build_env):
208     if value:
209         path = value[0]
210         if not isdir(path):
211             die("Invalid value --with-l10n-base, %s doesn't exist", path)
212     elif automation:
213         path = os.path.join(build_env.topsrcdir, '../l10n-central')
214     else:
215         path = os.path.join(
216             environ.get(
217                 'MOZBUILD_STATE_PATH',
218                 expanduser(os.path.join('~', '.mozbuild'))),
219             'l10n-central')
220     return os.path.realpath(os.path.abspath(path))
222 set_config('L10NBASEDIR', l10n_base)
225 # Default toolkit
226 # ==============================================================
227 @depends(target)
228 def toolkit_choices(target):
229     if target.os == 'WINNT':
230         return ('cairo-windows',)
231     elif target.os == 'OSX':
232         return ('cairo-cocoa',)
233     elif target.os == 'Android':
234         return ('cairo-android',)
235     else:
236         return ('cairo-gtk3', 'cairo-gtk3-wayland')
238 @depends(toolkit_choices)
239 def toolkit_default(choices):
240     return choices[0]
242 option('--enable-default-toolkit', nargs=1,
243        choices=toolkit_choices, default=toolkit_default,
244        help='Select default toolkit')
246 @depends_if('--enable-default-toolkit')
247 def full_toolkit(value):
248     return value[0]
250 @depends(full_toolkit)
251 def toolkit(toolkit):
252     if toolkit.startswith('cairo-gtk3'):
253         widget_toolkit = 'gtk'
254     else:
255         widget_toolkit = toolkit.replace('cairo-', '')
256     return widget_toolkit
258 set_config('MOZ_WIDGET_TOOLKIT', toolkit)
259 add_old_configure_assignment('MOZ_WIDGET_TOOLKIT', toolkit)
261 @depends(toolkit)
262 def toolkit_define(toolkit):
263     if toolkit != 'windows':
264         return 'MOZ_WIDGET_%s' % toolkit.upper()
266 set_define(toolkit_define, True)
268 @depends(toolkit)
269 def toolkit_gtk(toolkit):
270     return toolkit == 'gtk'
272 set_config('MOZ_X11', True, when=toolkit_gtk)
273 set_define('MOZ_X11', True, when=toolkit_gtk)
274 add_old_configure_assignment('MOZ_X11', True, when=toolkit_gtk)
276 # Wayland support
277 # ==============================================================
278 wayland_headers = pkg_check_modules(
279     'MOZ_WAYLAND', 'gtk+-wayland-3.0 >= 3.14 xkbcommon >= 0.4.1 libdrm >= 2.4',
280     allow_missing=depends(full_toolkit)(lambda t: t == 'cairo-gtk3'),
281     when=depends(full_toolkit)(lambda t: t in ('cairo-gtk3', 'cairo-gtk3-wayland')))
284 @depends(wayland_headers, toolkit_gtk, artifact_builds)
285 def wayland_headers(wayland, toolkit_gtk, artifacts):
286     if toolkit_gtk and artifacts:
287         return True
288     return wayland
291 set_config('MOZ_WAYLAND', depends_if(wayland_headers)(lambda _: True))
292 set_define('MOZ_WAYLAND', depends_if(wayland_headers)(lambda _: True))
294 # GL Provider
295 # ==============================================================
296 option('--with-gl-provider', nargs=1, help='Set GL provider backend type')
298 @depends('--with-gl-provider')
299 def gl_provider(value):
300     if value:
301         return value[0]
303 @depends(gl_provider)
304 def gl_provider_define(provider):
305     if provider:
306         return 'GLContextProvider%s' % provider
308 set_define('MOZ_GL_PROVIDER', gl_provider_define)
310 @depends(gl_provider, wayland_headers, toolkit_gtk)
311 def gl_default_provider(value, wayland, toolkit_gtk):
312     if value:
313         return value
314     elif wayland:
315         return 'EGL'
316     elif toolkit_gtk:
317         return 'GLX'
319 set_config('MOZ_GL_PROVIDER', gl_provider)
320 set_config('MOZ_GL_DEFAULT_PROVIDER', gl_default_provider)
322 @depends(gl_default_provider)
323 def gl_provider_define(provider):
324     if provider:
325         return 'GL_PROVIDER_%s' % provider
327 set_define(gl_provider_define, True)
330 # PDF printing
331 # ==============================================================
332 @depends(toolkit)
333 def pdf_printing(toolkit):
334     if toolkit in ('windows', 'gtk', 'android'):
335         return True
337 @depends(pdf_printing)
338 def pdf_surface_feature(pdf_printing):
339     if pdf_printing:
340         return '#define CAIRO_HAS_PDF_SURFACE 1'
341     else:
342         # CONFIGURE_SUBST_FILES need explicit empty values.
343         return ''
345 set_config('MOZ_PDF_PRINTING', pdf_printing)
346 set_config('PDF_SURFACE_FEATURE', pdf_surface_feature)
349 # Event loop instrumentation
350 # ==============================================================
351 option(env='MOZ_INSTRUMENT_EVENT_LOOP',
352        help='Force-enable event loop instrumentation')
354 @depends('MOZ_INSTRUMENT_EVENT_LOOP', toolkit)
355 def instrument_event_loop(value, toolkit):
356     if value or (toolkit in ('windows', 'gtk', 'cocoa', 'android') and
357                  value.origin == 'default'):
358         return True
360 set_config('MOZ_INSTRUMENT_EVENT_LOOP', instrument_event_loop)
361 set_define('MOZ_INSTRUMENT_EVENT_LOOP', instrument_event_loop)
364 # Fontconfig Freetype
365 # ==============================================================
366 option(env='USE_FC_FREETYPE',
367        help='Force-enable the use of fontconfig freetype')
369 @depends('USE_FC_FREETYPE', toolkit)
370 def fc_freetype(value, toolkit):
371     if value or (toolkit == 'gtk' and
372                  value.origin == 'default'):
373         return True
375 add_old_configure_assignment('USE_FC_FREETYPE', fc_freetype)
377 # Pango
378 # ==============================================================
379 pkg_check_modules('MOZ_PANGO',
380                   'pango >= 1.22.0 pangoft2 >= 1.22.0 pangocairo >= 1.22.0',
381                   when=toolkit_gtk)
383 # Fontconfig
384 # ==============================================================
385 fontconfig_info = pkg_check_modules('_FONTCONFIG', 'fontconfig >= 2.7.0',
386                                     when=fc_freetype)
388 @depends(fc_freetype)
389 def check_for_freetype2(fc_freetype):
390     if fc_freetype:
391         return True
393 # Check for freetype2. Flags are combined with fontconfig flags.
394 freetype2_info = pkg_check_modules('_FT2', 'freetype2 >= 6.1.0',
395                                    when=check_for_freetype2)
397 @depends(fontconfig_info, freetype2_info)
398 def freetype2_combined_info(fontconfig_info, freetype2_info):
399     if not freetype2_info:
400         return
401     if not fontconfig_info:
402         return freetype2_info
403     return namespace(
404         cflags=freetype2_info.cflags + fontconfig_info.cflags,
405         libs=freetype2_info.libs + fontconfig_info.libs,
406     )
408 add_old_configure_assignment('_HAVE_FREETYPE2',
409                              depends_if(freetype2_info)(lambda _: True))
411 # Apple platform decoder support
412 # ==============================================================
413 @depends(toolkit)
414 def applemedia(toolkit):
415     if toolkit in ('cocoa', 'uikit'):
416         return True
418 set_config('MOZ_APPLEMEDIA', applemedia)
419 set_define('MOZ_APPLEMEDIA', applemedia)
420 add_old_configure_assignment('MOZ_APPLEMEDIA', applemedia)
422 # Windows Media Foundation support
423 # ==============================================================
424 option('--disable-wmf',
425        help='Disable support for Windows Media Foundation')
427 @depends('--disable-wmf', target)
428 def wmf(value, target):
429     enabled = bool(value)
430     if value.origin == 'default':
431         # Enable Windows Media Foundation support by default.
432         # Note our minimum SDK version is Windows 7 SDK, so we are (currently)
433         # guaranteed to have a recent-enough SDK to build WMF.
434         enabled = target.os == 'WINNT'
435     if enabled and target.os != 'WINNT':
436         die('Cannot enable Windows Media Foundation support on %s', target.os)
437     if enabled:
438         return True
440 set_config('MOZ_WMF', wmf)
441 set_define('MOZ_WMF', wmf)
443 # FFmpeg H264/AAC Decoding Support
444 # ==============================================================
445 option('--disable-ffmpeg',
446        help='Disable FFmpeg for fragmented H264/AAC decoding')
448 @depends('--disable-ffmpeg', target)
449 def ffmpeg(value, target):
450     enabled = bool(value)
451     if value.origin == 'default':
452         enabled = target.os not in ('Android', 'WINNT')
453     if enabled:
454         return True
456 set_config('MOZ_FFMPEG', ffmpeg)
457 set_define('MOZ_FFMPEG', ffmpeg)
458 imply_option('--enable-fmp4', ffmpeg, '--enable-ffmpeg')
460 # AV1 Video Codec Support
461 # ==============================================================
462 option('--disable-av1',
463         help='Disable av1 video support')
465 @depends('--enable-av1')
466 def av1(value):
467     if value:
468         return True
470 @depends(target, nasm_version, when=av1 & compile_environment)
471 def dav1d_asm(target, nasm_version):
472     if target.cpu == 'aarch64':
473         return True
474     elif target.cpu in ('x86', 'x86_64'):
475         if (not nasm_version) or nasm_version < '2.14':
476             die('nasm 2.14 or greater is required for AV1 support. '
477                 'Either install nasm or add --disable-av1 to your configure options.')
478         return True
481 set_config('MOZ_DAV1D_ASM', dav1d_asm)
482 set_define('MOZ_DAV1D_ASM', dav1d_asm)
483 set_config('MOZ_AV1', av1)
484 set_define('MOZ_AV1', av1)
486 # Built-in fragmented MP4 support.
487 # ==============================================================
488 option('--disable-fmp4', env='MOZ_FMP4',
489        help='Disable support for in built Fragmented MP4 parsing')
491 @depends('--disable-fmp4', target, wmf, applemedia)
492 def fmp4(value, target, wmf, applemedia):
493     enabled = bool(value)
494     if value.origin == 'default':
495         # target.os == 'Android' includes all B2G versions
496         enabled = wmf or applemedia or target.os == 'Android'
497     if enabled:
498         return True
500 set_config('MOZ_FMP4', fmp4)
501 set_define('MOZ_FMP4', fmp4)
502 add_old_configure_assignment('MOZ_FMP4', fmp4)
504 @depends(target)
505 def sample_type_is_s16(target):
506     # Use integers over floats for audio on Android regardless of the CPU
507     # architecture, because audio backends for Android don't support floats.
508     # We also use integers on ARM because it's more efficient.
509     if target.os == 'Android' or target.cpu == 'arm':
510         return True
512 @depends(sample_type_is_s16)
513 def sample_type_is_float(t):
514     if not t:
515         return True
517 set_config('MOZ_SAMPLE_TYPE_S16', sample_type_is_s16)
518 set_define('MOZ_SAMPLE_TYPE_S16', sample_type_is_s16)
519 set_config('MOZ_SAMPLE_TYPE_FLOAT32', sample_type_is_float)
520 set_define('MOZ_SAMPLE_TYPE_FLOAT32', sample_type_is_float)
522 set_define('MOZ_VORBIS', sample_type_is_float)
523 set_config('MOZ_VORBIS', sample_type_is_float)
524 set_define('MOZ_TREMOR', sample_type_is_s16)
525 set_config('MOZ_TREMOR', sample_type_is_s16)
527 # OpenMAX IL Decoding Support
528 # ==============================================================
529 option('--enable-openmax',
530        help='Enable OpenMAX IL for video/audio decoding')
532 @depends('--enable-openmax')
533 def openmax(value):
534     enabled = bool(value)
535     if enabled:
536         return True
538 set_config('MOZ_OMX', openmax)
539 set_define('MOZ_OMX', openmax)
541 # EME Support
542 # ==============================================================
543 @depends(target)
544 def eme_choices(target):
545     if (target.kernel in ('Darwin', 'WINNT', 'Linux') and
546         target.os != 'Android' and
547         target.cpu in ('x86', 'x86_64')):
548         return ('widevine',)
549     if target.kernel == 'WINNT' and target.cpu == 'aarch64':
550         return ('widevine',)
553 # Widevine is enabled by default in desktop browser builds, except
554 # on aarch64 Windows.
555 @depends(build_project, eme_choices, target)
556 def eme_default(build_project, choices, target):
557     if build_project == 'browser':
558         if target.kernel != 'WINNT' or target.cpu != 'aarch64':
559             return choices
562 option('--enable-eme',
563        nargs='+',
564        choices=eme_choices,
565        default=eme_default,
566        when=eme_choices,
567        help='{Enable|Disable} support for Encrypted Media Extensions')
570 @depends('--enable-eme', fmp4, when=eme_choices)
571 def eme(enabled, fmp4):
572     if enabled and enabled.origin != 'default' and not fmp4:
573         die('Encrypted Media Extension support requires '
574             'Fragmented MP4 support')
577 @depends('--enable-eme', when=eme_choices)
578 def eme_modules(value):
579     return value
582 # Fallback to an empty list when eme_choices is empty, setting eme_modules to
583 # None.
584 set_config('MOZ_EME_MODULES', eme_modules | dependable([]))
587 @depends(eme_modules, target, when=eme_modules)
588 def eme_win32_artifact(modules, target):
589     if 'widevine' in modules and target.kernel == 'WINNT' and target.cpu == 'aarch64':
590         return True
593 set_config('MOZ_EME_WIN32_ARTIFACT', eme_win32_artifact)
595 option(name='--enable-chrome-format',
596        help='Select FORMAT of chrome files during packaging.',
597        nargs=1,
598        choices=('omni', 'jar', 'flat'),
599        default='omni')
601 @depends('--enable-chrome-format')
602 def packager_format(value):
603     return value[0]
605 set_config('MOZ_PACKAGER_FORMAT', packager_format)
607 @depends(host, build_project)
608 def jar_maker_format(host, build_project):
609     # Multilocales for mobile/android use the same mergedirs for all locales,
610     # so we can't use symlinks for those builds.
611     if host.os == 'WINNT' or build_project == 'mobile/android':
612         return 'flat'
613     return 'symlink'
615 set_config('MOZ_JAR_MAKER_FILE_FORMAT', jar_maker_format)
617 @depends(toolkit)
618 def omnijar_name(toolkit):
619     # Fennec's static resources live in the assets/ folder of the
620     # APK.  Adding a path to the name here works because we only
621     # have one omnijar file in the final package (which is not the
622     # case on desktop).
623     return 'assets/omni.ja' if toolkit == 'android' else 'omni.ja'
625 set_config('OMNIJAR_NAME', omnijar_name)
627 project_flag('MOZ_PLACES',
628              help='Build Places if required',
629              set_as_define=True)
631 project_flag('MOZ_SERVICES_HEALTHREPORT',
632              help='Build Firefox Health Reporter Service',
633              set_for_old_configure=True,
634              set_as_define=True)
636 project_flag('MOZ_NORMANDY',
637              help='Enable Normandy recipe runner',
638              set_for_old_configure=True,
639              set_as_define=True)
641 project_flag('MOZ_SERVICES_SYNC',
642              help='Build Sync Services if required')
644 project_flag('MOZ_ANDROID_HISTORY',
645              help='Enable Android History instead of Places',
646              set_as_define=True)
648 project_flag('MOZ_DEDICATED_PROFILES',
649              help='Enable dedicated profiles per install',
650              set_as_define=True)
652 project_flag('MOZ_BLOCK_PROFILE_DOWNGRADE',
653              help='Block users from starting profiles last used by a newer build',
654              set_as_define=True)
656 @depends('MOZ_PLACES', 'MOZ_ANDROID_HISTORY')
657 def check_places_and_android_history(places, android_history):
658     if places and android_history:
659         die('Cannot use MOZ_ANDROID_HISTORY alongside MOZ_PLACES.')
662 option(env='MOZ_TELEMETRY_REPORTING', default=mozilla_official,
663        help='Enable telemetry reporting')
665 set_define('MOZ_TELEMETRY_REPORTING', True, when='MOZ_TELEMETRY_REPORTING')
666 add_old_configure_assignment(
667     'MOZ_TELEMETRY_REPORTING', True, when='MOZ_TELEMETRY_REPORTING')
670 @depends('MOZ_TELEMETRY_REPORTING', milestone.is_nightly, fennec_nightly)
671 def telemetry_on_by_default(reporting, is_nightly, fennec_nightly):
672     return reporting and (is_nightly or fennec_nightly)
675 set_define('MOZ_TELEMETRY_ON_BY_DEFAULT', True, when=telemetry_on_by_default)
678 # gpsd support
679 # ==============================================================
680 option('--enable-gpsd', env='MOZ_GPSD',
681        help='Enable gpsd support')
683 @depends('--enable-gpsd')
684 def gpsd(value):
685     return bool(value)
687 system_gpsd = pkg_check_modules('MOZ_GPSD', 'libgps >= 3.11',
688                                 when=gpsd)
690 set_config('MOZ_GPSD', depends_if(system_gpsd)(lambda _: True))
692 # Miscellaneous programs
693 # ==============================================================
695 check_prog('TAR', ('gnutar', 'gtar', 'tar'))
696 check_prog('UNZIP', ('unzip',))
697 check_prog('ZIP', ('zip',))
698 check_prog('GN', ('gn',), allow_missing=True)
700 # Key files
701 # ==============================================================
702 include('../build/moz.configure/keyfiles.configure')
704 simple_keyfile('Mozilla API')
706 simple_keyfile('Google Location Service API')
708 simple_keyfile('Google Safebrowsing API')
710 id_and_secret_keyfile('Bing API')
712 simple_keyfile('Adjust SDK')
714 id_and_secret_keyfile('Leanplum SDK')
716 simple_keyfile('Pocket API')
719 # WebRender Debugger integration
720 # ==============================================================
722 option('--enable-webrender-debugger',
723        help='Build the websocket debug server in WebRender')
725 set_config('MOZ_WEBRENDER_DEBUGGER',
726            depends_if('--enable-webrender-debugger')(lambda _: True))
728 # Additional system headers defined at the application level
729 # ==============================================================
731 option('--enable-app-system-headers', env='MOZ_APP_SYSTEM_HEADERS',
732        help='Use additional system headers defined in $MOZ_BUILD_APP/app-system-headers.mozbuild')
734 @depends('--enable-app-system-headers')
735 def app_system_headers(value):
736     if value:
737         return True
739 set_config('MOZ_APP_SYSTEM_HEADERS', app_system_headers)
740 set_define('MOZ_APP_SYSTEM_HEADERS', app_system_headers)
742 # Printing
743 # ==============================================================
744 option('--disable-printing', help='Disable printing support')
746 @depends('--disable-printing')
747 def printing(value):
748     if value:
749         return True
751 set_config('NS_PRINTING', printing)
752 set_define('NS_PRINTING', printing)
753 set_define('NS_PRINT_PREVIEW', printing)
755 # Speech-dispatcher support
756 # ==============================================================
757 @depends(toolkit)
758 def no_speechd_on_non_gtk(toolkit):
759     if toolkit != 'gtk':
760         return False
762 imply_option('--enable-synth-speechd', no_speechd_on_non_gtk,
763              reason='--enable-default-toolkit')
765 option('--disable-synth-speechd', help='Disable speech-dispatcher support')
767 set_config('MOZ_SYNTH_SPEECHD',
768            depends_if('--disable-synth-speechd')(lambda _: True))
770 # Speech API
771 # ==============================================================
772 option('--disable-webspeech', help='Disable support for HTML Speech API')
774 @depends('--disable-webspeech')
775 def webspeech(value):
776     if value:
777         return True
779 set_config('MOZ_WEBSPEECH', webspeech)
780 set_define('MOZ_WEBSPEECH', webspeech)
781 add_old_configure_assignment('MOZ_WEBSPEECH', webspeech)
783 # Speech API test backend
784 # ==============================================================
785 option('--enable-webspeechtestbackend', default=webspeech,
786        help='{Enable|Disable} support for HTML Speech API Test Backend')
788 @depends_if('--enable-webspeechtestbackend')
789 def webspeech_test_backend(value):
790     return True
792 set_config('MOZ_WEBSPEECH_TEST_BACKEND', webspeech_test_backend)
793 set_define('MOZ_WEBSPEECH_TEST_BACKEND', webspeech_test_backend)
795 # Enable IPDL's "expensive" unit tests
796 # ==============================================================
797 option('--enable-ipdl-tests', help='Enable expensive IPDL tests')
799 set_config('MOZ_IPDL_TESTS',
800            depends_if('--enable-ipdl-tests')(lambda _: True))
802 # Graphics
803 # ==============================================================
804 option('--disable-skia', help='Disable use of Skia')
806 @depends('--disable-skia')
807 def skia(value):
808     if not value:
809         die('--disable-skia is not supported anymore')
810     else:
811         return True
813 set_config('MOZ_ENABLE_SKIA', skia)
814 set_define('MOZ_ENABLE_SKIA', skia)
815 set_define('USE_SKIA', skia)
817 option('--enable-skia-pdf', help='Enable Skia PDF')
819 @depends('--enable-skia-pdf', skia, target, milestone)
820 def skia_pdf(value, skia, target, milestone):
821     if value.origin == 'default':
822         if not skia:
823             return None
824         if milestone.is_nightly and target.os != 'WINNT':
825             return True
826     elif value and not skia:
827         die('Cannot enable Skia PDF without enabling Skia')
828     if skia and value:
829         return True
831 set_config('MOZ_ENABLE_SKIA_PDF', skia_pdf)
832 set_define('MOZ_ENABLE_SKIA_PDF', skia_pdf)
834 option('--enable-skia-pdf-sfntly', help='Enable SFNTLY font subsetting in Skia PDF')
836 @depends('--enable-skia-pdf-sfntly', skia_pdf)
837 def skia_pdf_sfntly(value, skia_pdf):
838     if value.origin == 'default':
839         return skia_pdf
840     if value and not skia_pdf:
841         die('Cannot enable SFNTLY subsetting without enabling Skia PDF')
842     if skia_pdf and value:
843         return True
845 set_config('MOZ_ENABLE_SKIA_PDF_SFNTLY', skia_pdf_sfntly)
846 set_define('MOZ_ENABLE_SKIA_PDF_SFNTLY', skia_pdf_sfntly)
848 @depends(skia_pdf_sfntly)
849 def sfntly_includes(skia_pdf_sfntly):
850     includes = []
851     if skia_pdf_sfntly:
852         includes += [
853             '/gfx/sfntly/cpp/src',
854         ]
855     return includes
857 set_config('SFNTLY_INCLUDES', sfntly_includes)
859 @depends(skia)
860 def skia_includes(skia):
861     includes = []
862     if skia:
863         includes += [
864             '/gfx/skia',
865             '/gfx/skia/skia',
866         ]
867     return includes
869 set_config('SKIA_INCLUDES', skia_includes)
871 option('--with-system-webp',
872        help='Use system libwebp (located with pkgconfig)')
874 system_webp = pkg_check_modules('MOZ_WEBP', 'libwebp >= 1.0.2 libwebpdemux >= 1.0.2',
875                                 when='--with-system-webp')
877 set_config('MOZ_SYSTEM_WEBP', depends(when=system_webp)(lambda: True))
879 # Build Freetype in the tree
880 # ==============================================================
881 @depends(target, skia_pdf)
882 def tree_freetype(target, skia_pdf):
883     if target.os == 'Android' or (skia_pdf and target.os == 'WINNT'):
884         return True
886 set_define('MOZ_TREE_FREETYPE', tree_freetype)
887 set_config('MOZ_TREE_FREETYPE', tree_freetype)
888 add_old_configure_assignment('MOZ_TREE_FREETYPE', tree_freetype)
890 set_define('HAVE_FT_BITMAP_SIZE_Y_PPEM', tree_freetype)
891 set_define('HAVE_FT_GLYPHSLOT_EMBOLDEN', tree_freetype)
892 set_define('HAVE_FT_LOAD_SFNT_TABLE', tree_freetype)
894 @depends(freetype2_combined_info, tree_freetype, check_build_environment)
895 def ft2_info(freetype2_combined_info, tree_freetype, build_env):
896     if tree_freetype:
897         return namespace(cflags=('-I%s/modules/freetype2/include' % build_env.topsrcdir,),
898                          libs=())
899     if freetype2_combined_info:
900         return freetype2_combined_info
902 set_config('FT2_LIBS', ft2_info.libs)
903 add_old_configure_assignment('FT2_LIBS',
904                              ft2_info.libs)
905 add_old_configure_assignment('FT2_CFLAGS',
906                              ft2_info.cflags)
909 # Remote agent
910 # (partial implementation of Chromium Remote Debugging Protocol)
911 # ==============================================================
913 # See https://firefox-source-docs.mozilla.org/remote/ for more.
914 # The source code lives under ../remote.
916 @depends(target, build_project, milestone)
917 def remote_default(target, project, milestone):
918     # no support for Android
919     if target.os == 'Android':
920         return False
922     # enable on Firefox Nightly channel only
923     # TODO(ato): https://bugzil.la/1544393
924     return project == 'browser' and milestone.is_nightly
926 option('--enable-cdp', default=remote_default,
927        help='{Enable|Disable} remote agent')
929 @depends('--enable-cdp')
930 def remote(value):
931     if value:
932         return True
934 set_config('ENABLE_REMOTE_AGENT', remote)
935 set_define('ENABLE_REMOTE_AGENT', remote)
938 # Marionette remote protocol
939 # ==============================================================
941 # Marionette is the Gecko remote protocol used for various remote control,
942 # automation, and testing purposes throughout Gecko, Firefox, and Fennec.
943 # Marionette lives in ../testing/marionette.
945 # Marionette is not really a toolkit feature, as much as a Gecko
946 # engine feature.  But it is enabled based on the toolkit, so here it
947 # lives.
949 # It also backs ../testing/geckodriver, which is Mozilla's WebDriver
950 # implementation.
952 # For more information, see
953 # https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette.
955 option('--disable-marionette',
956        help='Disable Marionette remote protocol')
958 @depends('--disable-marionette')
959 def marionette(value):
960     if value:
961         return True
963 set_config('ENABLE_MARIONETTE', marionette)
966 # geckodriver WebDriver implementation
967 # ==============================================================
969 # Turn off geckodriver for build configs we don't handle yet,
970 # but allow --enable-geckodriver to override when compile environment is available.
971 # --disable-tests implies disabling geckodriver.
972 # Disable building in CI
974 @depends('--enable-tests', target, cross_compiling, hazard_analysis, asan, 'MOZ_AUTOMATION')
975 def geckodriver_default(enable_tests, target, cross_compile, hazard, asan, automation):
976     if not enable_tests:
977         return False
978     # geckodriver depends on winapi 0.2.8, which doesn't work with AArch64.
979     if target.os == 'WINNT' and target.cpu == 'aarch64':
980         return False
981     if hazard or target.os == 'Android' or (asan and cross_compile):
982         return False
983     if automation:
984         return False
985     return True
987 option('--enable-geckodriver', default=geckodriver_default,
988        when='--enable-compile-environment',
989        help='{Build|Do not build} geckodriver')
991 @depends('--enable-geckodriver', when='--enable-compile-environment')
992 def geckodriver(enabled):
993     if enabled:
994         return True
996 set_config('ENABLE_GECKODRIVER', geckodriver)
999 # WebRTC
1000 # ========================================================
1001 @depends(target)
1002 def webrtc_default(target):
1003     # Turn off webrtc for OS's we don't handle yet, but allow
1004     # --enable-webrtc to override.
1005     os_match = False
1006     for os_fragment in ('linux', 'mingw', 'android', 'linuxandroid',
1007                         'dragonfly', 'freebsd', 'netbsd', 'openbsd',
1008                         'darwin'):
1009         if target.raw_os.startswith(os_fragment):
1010             os_match = True
1012     cpu_match = False
1013     if (target.cpu in ('x86_64', 'arm', 'aarch64', 'x86', 'ia64', 'mips32', 'mips64') or
1014         target.cpu.startswith('ppc')):
1015         cpu_match = True
1017     if os_match and cpu_match:
1018         return True
1019     return False
1021 option('--disable-webrtc', default=webrtc_default,
1022        help='{Enable|Disable} support for WebRTC')
1024 @depends('--disable-webrtc')
1025 def webrtc(enabled):
1026     if enabled:
1027         return True
1029 set_config('MOZ_WEBRTC', webrtc)
1030 set_define('MOZ_WEBRTC', webrtc)
1031 add_old_configure_assignment('MOZ_WEBRTC', webrtc)
1032 set_config('MOZ_SCTP', webrtc)
1033 set_define('MOZ_SCTP', webrtc)
1034 set_config('MOZ_SRTP', webrtc)
1035 set_define('MOZ_SRTP', webrtc)
1036 set_config('MOZ_WEBRTC_SIGNALING', webrtc)
1037 set_define('MOZ_WEBRTC_SIGNALING', webrtc)
1038 set_config('MOZ_PEERCONNECTION', webrtc)
1039 set_define('MOZ_PEERCONNECTION', webrtc)
1040 # MOZ_WEBRTC_ASSERT_ALWAYS turns on a number of safety asserts in
1041 # opt/production builds (via MOZ_CRASH())
1042 set_config('MOZ_WEBRTC_ASSERT_ALWAYS', webrtc)
1043 set_define('MOZ_WEBRTC_ASSERT_ALWAYS', webrtc)
1045 # RAW media
1046 # ==============================================================
1048 @depends(target, webrtc)
1049 def raw_media_default(target, webrtc):
1050     if target.os == 'Android':
1051         return True
1052     if webrtc:
1053         return True
1055 option('--enable-raw',
1056        default=raw_media_default,
1057        help='{Enable|Disable} support for RAW media')
1059 set_config('MOZ_RAW', depends_if('--enable-raw')(lambda _: True))
1060 set_define('MOZ_RAW', depends_if('--enable-raw')(lambda _: True))
1062 # ASan Reporter Addon
1063 # ==============================================================
1064 option('--enable-address-sanitizer-reporter',
1065        help='Enable Address Sanitizer Reporter Extension')
1067 @depends('--enable-address-sanitizer-reporter')
1068 def enable_asan_reporter(value):
1069     if value:
1070         return True
1072 set_config('MOZ_ASAN_REPORTER', enable_asan_reporter)
1073 set_define('MOZ_ASAN_REPORTER', enable_asan_reporter)
1074 add_old_configure_assignment('MOZ_ASAN_REPORTER', enable_asan_reporter)
1076 # Elfhack
1077 # ==============================================================
1078 with only_when('--enable-compile-environment'):
1079     @depends(host, target)
1080     def has_elfhack(host, target):
1081         return target.kernel == 'Linux' and host.kernel == 'Linux' and \
1082                target.cpu in ('arm', 'x86', 'x86_64')
1084     @depends('--enable-release', enable_linker)
1085     def default_elfhack(release, linker):
1086         # Disable elfhack when explicitly building with --enable-linker=lld
1087         if linker and linker.origin != 'default' and linker[0] == 'lld':
1088             return False
1089         return bool(release)
1091     with only_when(has_elfhack):
1092         option('--disable-elf-hack', default=default_elfhack,
1093                help='{Enable|Disable} elf hacks')
1095         set_config('USE_ELF_HACK',
1096                    depends_if('--enable-elf-hack')(lambda _: True))
1099 @depends(check_build_environment)
1100 def idl_roots(build_env):
1101     return namespace(ipdl_root=os.path.join(build_env.topobjdir, 'ipc', 'ipdl'),
1102                      webidl_root=os.path.join(build_env.topobjdir,
1103                                               'dom', 'bindings'),
1104                      xpcom_root=os.path.join(build_env.topobjdir,
1105                                              'xpcom', 'components'))
1107 set_config('WEBIDL_ROOT', idl_roots.webidl_root)
1108 set_config('IPDL_ROOT', idl_roots.ipdl_root)
1109 set_config('XPCOM_ROOT', idl_roots.xpcom_root)
1111 # Proxy bypass protection
1112 # ==============================================================
1114 option('--enable-proxy-bypass-protection',
1115        help='Prevent suspected or confirmed proxy bypasses')
1117 @depends_if('--enable-proxy-bypass-protection')
1118 def proxy_bypass_protection(_):
1119     return True
1121 set_config('MOZ_PROXY_BYPASS_PROTECTION', proxy_bypass_protection)
1122 set_define('MOZ_PROXY_BYPASS_PROTECTION', proxy_bypass_protection)
1124 # MIDL
1125 # ==============================================================
1127 @depends(c_compiler, toolchain_prefix)
1128 def midl_names(c_compiler, toolchain_prefix):
1129     if c_compiler and c_compiler.type in ['gcc', 'clang']:
1130         # mingw
1131         widl = ('widl', )
1132         if toolchain_prefix:
1133             prefixed = tuple('%s%s' % (p, 'widl') for p in toolchain_prefix)
1134             widl = prefixed + widl
1135         return widl
1137     return ('midl.exe',)
1139 @depends(target, '--enable-compile-environment')
1140 def check_for_midl(target, compile_environment):
1141     if target.os != 'WINNT':
1142         return
1144     if compile_environment:
1145         return True
1148 midl = check_prog('MIDL', midl_names, when=check_for_midl, allow_missing=True,
1149                   paths=sdk_bin_path)
1151 option(env='MIDL_FLAGS', nargs=1, help='Extra flags to pass to MIDL')
1153 @depends('MIDL_FLAGS', c_compiler, target, host, midl,
1154          when=depends(midl, target)(lambda m, t: m and t.kernel == 'WINNT'))
1155 def midl_flags(flags , c_compiler, target, host, midl):
1156     if flags:
1157         flags = flags[0].split()
1158     else:
1159         flags = []
1161     if not midl.endswith('widl'):
1162         env = {
1163             'x86': 'win32',
1164             'x86_64': 'x64',
1165             'aarch64': 'arm64',
1166         }[target.cpu]
1167         flags += ['-env', env]
1169         if host.os == 'WINNT':
1170             return flags + ['-cpp_cmd', c_compiler.compiler]
1172         # If cross-compiling and using midl instead of widl, for now, we'll
1173         # assume we can find the Windows version of clang-cl in the PATH.
1174         # It is required because while Wine is able to spawn Linux
1175         # processes from Windows programs(!), the calling program doesn't
1176         # have access to the process output and can't wait for it to
1177         # finish. Midl runs clang-cl as a preprocessor and expects to read
1178         # its output...
1179         clang_cl_exe = find_program('clang-cl.exe')
1180         if not clang_cl_exe:
1181             die("Cannot find clang-cl.exe")
1182         return flags + ['-cpp_cmd', clang_cl_exe]
1184     # widl
1185     return flags + {
1186         'x86': ['--win32', '-m32'],
1187         'x86_64': ['--win64', '-m64'],
1188     }[target.cpu]
1191 set_config('MIDL_FLAGS', midl_flags)
1193 # Accessibility
1194 # ==============================================================
1196 option('--disable-accessibility', help='Disable accessibility support')
1198 @depends('--enable-accessibility', check_for_midl, midl, c_compiler)
1199 def accessibility(value, check_for_midl, midl, c_compiler):
1200     enabled = bool(value)
1202     if not enabled:
1203         return
1205     if check_for_midl and not midl:
1206         if c_compiler and c_compiler.type in ('gcc', 'clang'):
1207             die('You have accessibility enabled, but widl could not be found. '
1208                 'Add --disable-accessibility to your mozconfig or install widl. '
1209                 'See https://developer.mozilla.org/en-US/docs/Cross_Compile_Mozilla_for_Mingw32 for details.')
1210         else:
1211             die('MIDL could not be found. '
1212                 'Building accessibility without MIDL is not supported.')
1214     return enabled
1217 set_config('ACCESSIBILITY', accessibility)
1218 set_define('ACCESSIBILITY', accessibility)
1219 add_old_configure_assignment('ACCESSIBILITY', accessibility)
1221 # Addon signing
1222 # ==============================================================
1224 option('--with-unsigned-addon-scopes',
1225        nargs='+', choices=('app', 'system'),
1226        help='Addon scopes where signature is not required')
1228 @depends('--with-unsigned-addon-scopes')
1229 def unsigned_addon_scopes(scopes):
1230     return namespace(
1231         app='app' in scopes or None,
1232         system='system' in scopes or None,
1233     )
1235 set_config('MOZ_UNSIGNED_APP_SCOPE', unsigned_addon_scopes.app)
1236 set_config('MOZ_UNSIGNED_SYSTEM_SCOPE', unsigned_addon_scopes.system)
1238 # Addon sideloading
1239 # ==============================================================
1241 @depends(update_channel)
1242 def addon_sideload_allowed_default(update_channel):
1243     if update_channel == 'esr':
1244         return True
1246 option('--allow-addon-sideload', default=addon_sideload_allowed_default,
1247        help='Addon sideloading is allowed')
1249 @depends('--allow-addon-sideload')
1250 def addon_sideload_allowed(value):
1251     allowed = bool(value)
1252     if allowed:
1253         return True
1255 set_config('MOZ_ALLOW_ADDON_SIDELOAD', addon_sideload_allowed)
1257 # Launcher process (Windows only)
1258 # ==============================================================
1260 @depends(target)
1261 def launcher_process_default(target):
1262     return target.os == 'WINNT'
1264 option('--enable-launcher-process', default=launcher_process_default,
1265        help='{Enable|Disable} launcher process by default')
1267 @depends('--enable-launcher-process', target)
1268 def launcher(value, target):
1269     enabled = bool(value)
1270     if enabled and target.os != 'WINNT':
1271         die('Cannot enable launcher process on %s', target.os)
1272     if enabled:
1273         return True
1275 set_config('MOZ_LAUNCHER_PROCESS', launcher)
1276 set_define('MOZ_LAUNCHER_PROCESS', launcher)
1278 # llvm-dlltool (Windows only)
1279 # ==============================================================
1281 @depends(build_project, target, '--enable-compile-environment')
1282 def check_for_llvm_dlltool(build_project, target, compile_environment):
1283     if build_project != 'browser':
1284         return
1286     if target.os != 'WINNT':
1287         return
1289     return compile_environment
1291 llvm_dlltool = check_prog('LLVM_DLLTOOL', ('llvm-dlltool',),
1292                           what='llvm-dlltool', when=check_for_llvm_dlltool,
1293                           paths=toolchain_search_path)
1295 @depends(target, when=llvm_dlltool)
1296 def llvm_dlltool_flags(target):
1297     arch = {
1298         'x86': 'i386',
1299         'x86_64': 'i386:x86-64',
1300         'aarch64': 'arm64',
1301     }[target.cpu]
1303     return ['-m', arch]
1305 set_config('LLVM_DLLTOOL_FLAGS', llvm_dlltool_flags)
1307 # BITS download (Windows only)
1308 # ==============================================================
1310 option('--enable-bits-download',
1311        when=target_is_windows, default=target_is_windows,
1312        help='{Enable|Disable} building BITS download support')
1314 set_define('MOZ_BITS_DOWNLOAD',
1315            depends_if('--enable-bits-download',
1316                       when=target_is_windows)(lambda _: True))
1317 set_config('MOZ_BITS_DOWNLOAD',
1318            depends_if('--enable-bits-download',
1319                       when=target_is_windows)(lambda _: True))
1321 # Bundled fonts on desktop platform
1322 # ==============================================================
1324 @depends(target)
1325 def bundled_fonts_default(target):
1326     return target.os == 'WINNT' or target.kernel == 'Linux'
1328 @depends(build_project)
1329 def allow_bundled_fonts(project):
1330     return project == 'browser' or project == 'comm/mail'
1332 option('--enable-bundled-fonts', default=bundled_fonts_default,
1333        when=allow_bundled_fonts,
1334        help='{Enable|Disable} support for bundled fonts on desktop platforms')
1336 set_define('MOZ_BUNDLED_FONTS',
1337            depends_if('--enable-bundled-fonts', when=allow_bundled_fonts)(lambda _: True))
1339 # TaskTracer
1340 # ==============================================================
1342 option('--enable-tasktracer', help='Enable TaskTracer')
1344 set_define('MOZ_TASK_TRACER', depends_if('--enable-tasktracer')(lambda _: True))
1345 set_config('MOZ_TASK_TRACER', depends_if('--enable-tasktracer')(lambda _: True))
1347 # Reflow counting
1348 # ==============================================================
1350 @depends(moz_debug)
1351 def reflow_perf(debug):
1352     if debug:
1353         return True
1355 option('--enable-reflow-perf',
1356        default=reflow_perf,
1357        help='{Enable|Disable} reflow performance tracing')
1359 # The difference in conditions here comes from the initial implementation
1360 # in old-configure, which was unexplained there as well.
1361 set_define('MOZ_REFLOW_PERF', depends_if('--enable-reflow-perf')(lambda _: True))
1362 set_define('MOZ_REFLOW_PERF_DSP', reflow_perf)
1364 # Layout debugger
1365 # ==============================================================
1367 @depends(moz_debug)
1368 def layout_debugger(debug):
1369     if debug:
1370         return True
1372 option('--enable-layout-debugger',
1373        default=layout_debugger,
1374        help='{Enable|Disable} layout debugger')
1376 set_config('MOZ_LAYOUT_DEBUGGER', True, when='--enable-layout-debugger')
1377 set_define('MOZ_LAYOUT_DEBUGGER', True, when='--enable-layout-debugger')
1380 # Shader Compiler for Windows (and MinGW Cross Compile)
1381 # ==============================================================
1383 with only_when(compile_environment):
1384     fxc = check_prog('FXC', ('fxc.exe', 'fxc2.exe'), when=depends(target)
1385                      (lambda t: t.kernel == 'WINNT'),
1386                      paths=sdk_bin_path)
1389 # VPX
1390 # ===
1392 with only_when(compile_environment):
1393     option('--with-system-libvpx',
1394            help='Use system libvpx (located with pkgconfig)')
1396     with only_when('--with-system-libvpx'):
1397         vpx = pkg_check_modules('MOZ_LIBVPX', 'vpx >= 1.8.0')
1399         check_header('vpx/vpx_decoder.h', flags=vpx.cflags, onerror=lambda: die(
1400             "Couldn't find vpx/vpx_decoder.h, which is required to build "
1401             "with system libvpx. Use --without-system-libvpx to build "
1402             "with in-tree libvpx."))
1404         check_symbol('vpx_codec_dec_init_ver', flags=vpx.libs, onerror=lambda: die(
1405             "--with-system-libvpx requested but symbol vpx_codec_dec_init_ver "
1406             "not found"
1407         ))
1409         set_config('MOZ_SYSTEM_LIBVPX', True)
1412     @depends('--with-system-libvpx', target, gnu_as)
1413     def in_tree_vpx(system_libvpx, target, gnu_as):
1414         if system_libvpx:
1415             return
1417         use_yasm = (target.cpu in ('x86', 'x86_64')) or None
1418         need_yasm = False
1419         arm_asm = (target.cpu == 'arm' and gnu_as) or None
1421         if use_yasm:
1422             need_yasm = True
1423             if target.kernel == 'WINNT':
1424                 need_yasm = Version('1.1')
1426         return namespace(arm_asm=arm_asm, use_yasm=use_yasm, need_yasm=need_yasm)
1429     # Building with -mfpu=neon requires either the "softfp" or the
1430     # "hardfp" ABI. Depending on the compiler's default target, and the
1431     # CFLAGS, the default ABI might be neither, in which case it is the
1432     # "softfloat" ABI.
1433     # The "softfloat" ABI is binary-compatible with the "softfp" ABI, so
1434     # we can safely mix code built with both ABIs. So, if we detect
1435     # that compiling uses the "softfloat" ABI, force the use of the
1436     # "softfp" ABI instead.
1437     # Confusingly, the __SOFTFP__ preprocessor variable indicates the
1438     # "softfloat" ABI, not the "softfp" ABI.
1439     # Note: VPX_ASFLAGS is also used in CFLAGS.
1440     softfp = cxx_compiler.try_compile(body='''
1441         #ifndef __SOFTFP__
1442         #error "compiler target supports -mfpu=neon, so we don't have to add extra flags"
1443         #endif''', when=in_tree_vpx.arm_asm)
1446     @depends(in_tree_vpx, softfp, target)
1447     def vpx_as_flags(vpx, softfp, target):
1448         flags = []
1449         if vpx and vpx.arm_asm:
1450             # These flags are a lie; they're just used to enable the requisite
1451             # opcodes; actual arch detection is done at runtime.
1452             flags = ['-march=armv7-a', '-mfpu=neon']
1453             if softfp:
1454                 flags.append('-mfloat-abi=softfp')
1455         elif vpx and vpx.use_yasm and target.os != 'WINNT' and target.cpu != 'x86_64':
1456             flags = ['-DPIC']
1457         return flags
1460     set_config('VPX_USE_YASM', in_tree_vpx.use_yasm)
1461     set_config('VPX_ASFLAGS', vpx_as_flags)
1464 # JPEG
1465 # ====
1467 with only_when(compile_environment):
1468     option('--with-system-jpeg', nargs='?',
1469            help='Use system libjpeg (installed at given prefix)')
1471     @depends_if('--with-system-jpeg')
1472     def jpeg_flags(value):
1473         if len(value):
1474             return namespace(
1475                 cflags=('-I%s/include' % value[0],),
1476                 ldflags=('-L%s/lib' % value[0], '-ljpeg'),
1477             )
1478         return namespace(
1479             ldflags=('-ljpeg',),
1480         )
1482     with only_when('--with-system-jpeg'):
1483         check_symbol('jpeg_destroy_compress', flags=jpeg_flags.ldflags,
1484                      onerror=lambda: die('--with-system-jpeg requested but symbol '
1485                                          'jpeg_destroy_compress not found.'))
1487         c_compiler.try_compile(
1488             includes=[
1489                 'stdio.h',
1490                 'sys/types.h',
1491                 'jpeglib.h',
1492             ],
1493             body='''
1494                 #if JPEG_LIB_VERSION < 62
1495                 #error Insufficient JPEG library version
1496                 #endif
1497             ''',
1498             flags=jpeg_flags.cflags,
1499             check_msg='for sufficient jpeg library version',
1500             onerror=lambda: die('Insufficient JPEG library version for '
1501                                 '--with-system-jpeg (62 required)'),
1502         )
1504         c_compiler.try_compile(
1505             includes=[
1506                 'stdio.h',
1507                 'sys/types.h',
1508                 'jpeglib.h',
1509             ],
1510             body='''
1511                 #ifndef JCS_EXTENSIONS
1512                 #error libjpeg-turbo JCS_EXTENSIONS required
1513                 #endif
1514             ''',
1515             flags=jpeg_flags.cflags,
1516             check_msg='for sufficient libjpeg-turbo JCS_EXTENSIONS',
1517             onerror=lambda: die('libjpeg-turbo JCS_EXTENSIONS required for '
1518                                  '--with-system-jpeg'),
1519         )
1521         set_config('MOZ_JPEG_CFLAGS', jpeg_flags.cflags)
1522         set_config('MOZ_JPEG_LIBS', jpeg_flags.ldflags)
1524     @depends('--with-system-jpeg', target)
1525     def in_tree_jpeg(system_jpeg, target):
1526         if system_jpeg:
1527             return
1529         flags = ()
1530         use_yasm = None
1531         need_yasm = False
1532         if target.kernel == 'Darwin':
1533             if target.cpu == 'x86':
1534                 flags = ('-DPIC', '-DMACHO')
1535             elif target.cpu == 'x86_64':
1536                 flags = ('-D__x86_64__', '-DPIC', '-DMACHO')
1537         elif target.kernel == 'WINNT':
1538             if target.cpu == 'x86':
1539                 flags = ('-DPIC', '-DWIN32')
1540             elif target.cpu == 'x86_64':
1541                 flags = ('-D__x86_64__', '-DPIC', '-DWIN64', '-DMSVC')
1542         elif target.cpu == 'arm':
1543             flags = ('-march=armv7-a', '-mfpu=neon')
1544         elif target.cpu == 'aarch64':
1545             flags = ('-march=armv8-a',)
1546         elif target.cpu == 'mips32':
1547             flags = ('-mdspr2',)
1548         elif target.cpu == 'x86':
1549             flags = ('-DPIC', '-DELF')
1550         elif target.cpu == 'x86_64':
1551             flags = ('-D__x86_64__', '-DPIC', '-DELF')
1553         if target.cpu in ('x86', 'x86_64'):
1554             use_yasm = True
1555             if target.kernel == 'Linux' and target.os == 'GNU':
1556                 need_yasm = Version('1.0.1')
1557             else:
1558                 need_yasm = Version('1.1')
1560         return namespace(flags=flags, use_yasm=use_yasm, need_yasm=need_yasm)
1562     set_config('LIBJPEG_TURBO_USE_YASM', in_tree_jpeg.use_yasm)
1563     set_config('LIBJPEG_TURBO_ASFLAGS', in_tree_jpeg.flags)
1566 # Libav-fft Support
1567 # ==============================================================
1568 with only_when(compile_environment):
1569     @depends(target)
1570     def libav_fft(target):
1571         flags = None
1572         if target.kernel == 'WINNT' and target.cpu == 'x86':
1573             flags = ['-DPIC', '-DWIN32']
1574         elif target.kernel == 'WINNT' and target.cpu == 'aarch64':
1575             flags = ['-DPIC', '-DWIN64']
1576         elif target.cpu == 'x86_64':
1577             if target.kernel == 'Darwin':
1578                 flags = ['-D__x86_64__', '-DPIC', '-DMACHO']
1579             elif target.kernel == 'WINNT':
1580                 flags = ['-D__x86_64__', '-DPIC', '-DWIN64', '-DMSVC']
1581             else:
1582                 flags = ['-D__x86_64__', '-DPIC', '-DELF']
1583         if flags:
1584             if target.kernel == 'Linux' and target.os == 'GNU':
1585                 need_yasm = Version('1.0.1')
1586             else:
1587                 need_yasm = Version('1.1')
1588             return namespace(flags=flags, need_yasm=need_yasm)
1591     set_config('MOZ_LIBAV_FFT', depends(when=libav_fft)(lambda: True))
1592     set_define('MOZ_LIBAV_FFT', depends(when=libav_fft)(lambda: True))
1593     set_config('LIBAV_FFT_ASFLAGS', libav_fft.flags)
1596 # FFmpeg's ffvpx configuration
1597 # ==============================================================
1598 # Artifact builds need MOZ_FFVPX defined as if compilation happened.
1599 with only_when(compile_environment | artifact_builds):
1600     @depends_if(yasm_version)
1601     def yasm_has_avx2(yasm_version):
1602         return yasm_version >= '1.2'
1605     set_config('YASM_HAS_AVX2', yasm_has_avx2)
1608     @depends(yasm_has_avx2, libav_fft, vpx_as_flags, target)
1609     def ffvpx(yasm_has_avx2, libav_fft, vpx_as_flags, target):
1610         enable = flac_only = use_yasm = False
1611         flags = []
1612         if target.cpu in ('x86', 'x86_64') or \
1613                 target.cpu == 'aarch64' and target.kernel == 'WINNT':
1614             enable = True
1615             if libav_fft and libav_fft.flags:
1616                 use_yasm = True
1617                 flags.extend(libav_fft.flags)
1618                 if target.kernel == 'WINNT':
1619                     if target.cpu == 'x86':
1620                         # 32-bit windows need to prefix symbols with an underscore.
1621                         flags.extend(('-DPREFIX', '-Pconfig_win32.asm'))
1622                     elif target.cpu == 'aarch64':
1623                         use_yasm = False
1624                     else:
1625                         flags.append('-Pconfig_win64.asm')
1626                 elif target.kernel == 'Darwin':
1627                     # 32/64-bit macosx assemblers need to prefix symbols with an
1628                     # underscore.
1629                     flags.extend(('-DPREFIX', '-Pconfig_darwin64.asm'))
1630                 else:
1631                     # Default to unix.
1632                     flags.append('-Pconfig_unix64.asm')
1633             else:
1634                 flac_only = True
1635         elif target.cpu in ('arm', 'aarch64') and \
1636                 target.kernel not in ('WINNT', 'Darwin'):
1637             enable = flac_only = True
1638             if vpx_as_flags:
1639                 flags.extend(vpx_as_flags)
1641         if use_yasm:
1642             # default disabled components
1643             flags.append('-Pdefaults_disabled.asm')
1644             if not yasm_has_avx2:
1645                 flags.extend((
1646                     '-DHAVE_AVX2=0',
1647                     '-DHAVE_AVX2_INTERNAL=0',
1648                     '-DHAVE_AVX2_EXTERNAL=0',
1649                 ))
1651         return namespace(
1652             enable=enable,
1653             use_yasm=use_yasm,
1654             flac_only=flac_only,
1655             flags=flags,
1656         )
1659     set_config('MOZ_FFVPX', True, when=ffvpx.enable)
1660     set_define('MOZ_FFVPX', True, when=ffvpx.enable)
1661     set_config('MOZ_FFVPX_AUDIOONLY', True, when=ffvpx.flac_only)
1662     set_define('MOZ_FFVPX_AUDIOONLY', True, when=ffvpx.flac_only)
1663     set_config('FFVPX_ASFLAGS', ffvpx.flags)
1664     set_config('FFVPX_USE_YASM', True, when=ffvpx.use_yasm)
1667 @depends(yasm_version, in_tree_vpx.need_yasm, in_tree_jpeg.use_yasm,
1668          libav_fft.need_yasm, ffvpx.use_yasm)
1669 @imports(_from='__builtin__', _import='sorted')
1670 def valid_yasm_version(yasm_version, for_vpx, for_jpeg, for_libav,
1671                        for_ffvpx=False):
1672     # Note: the default for for_ffvpx above only matters for unit tests.
1673     requires = {
1674         'vpx': for_vpx,
1675         'jpeg': for_jpeg,
1676         'libav': for_libav,
1677         'ffvpx': for_ffvpx,
1678     }
1679     requires = {k: v for (k, v) in requires.items() if v}
1680     if requires and not yasm_version:
1681         items = sorted(requires.keys())
1682         if len(items) > 1:
1683             what = ' and '.join((', '.join(items[:-1]), items[-1]))
1684         else:
1685             what = items[0]
1686         die('Yasm is required to build with %s, but you do not appear to have '
1687             'Yasm installed.' % what)
1689     versioned = {k: v for (k, v) in requires.items() if v is not True}
1690     by_version = sorted(versioned.items(), key=lambda x: x[1])
1691     if by_version:
1692         what, version = by_version[-1]
1693         if yasm_version < version:
1694             die('Yasm version %s or greater is required to build with %s.'
1695                 % (version, what))
1698 # ANGLE OpenGL->D3D translator for WebGL
1699 # ==============================================================
1701 with only_when(compile_environment & target_is_windows):
1702     def d3d_compiler_dll_result(value):
1703         if not value.path:
1704             return 'provided by the OS'
1705         return value.path
1707     @depends(target, valid_windows_sdk_dir, fxc)
1708     @checking('for D3D compiler DLL', d3d_compiler_dll_result)
1709     @imports('os.path')
1710     def d3d_compiler_dll(target, windows_sdk_dir, fxc):
1711         suffix = {
1712             'x86_64': 'x64',
1713         }.get(target.cpu, target.cpu)
1715         name = 'd3dcompiler_47.dll'
1717         if target.cpu == 'aarch64':
1718             # AArch64 Windows comes with d3dcompiler_47.dll installed
1719             return namespace(name=name, path=None)
1721         if windows_sdk_dir:
1722             path = os.path.join(windows_sdk_dir.path, 'Redist', 'D3D', suffix, name)
1723             error_extra = 'in Windows SDK at {}'.format(windows_sdk_dir.path)
1724         else:
1725             path = os.path.join(os.path.dirname(fxc), name)
1726             error_extra = 'alongside FXC at {}'.format(fxc)
1728         if os.path.exists(path):
1729             return namespace(name=name, path=path)
1730         die('Could not find {} {}'.format(name, error_extra))
1733     set_config('MOZ_ANGLE_RENDERER', True)
1734     set_config('MOZ_D3DCOMPILER_VISTA_DLL', d3d_compiler_dll.name,
1735                when=d3d_compiler_dll.path)
1736     set_config('MOZ_D3DCOMPILER_VISTA_DLL_PATH', d3d_compiler_dll.path)
1738 # Remoting protocol support
1739 # ==============================================================
1741 @depends(toolkit)
1742 def has_remote(toolkit):
1743     if toolkit in ('gtk', 'windows', 'cocoa'):
1744         return True
1746 set_config('MOZ_HAS_REMOTE', has_remote)
1747 set_define('MOZ_HAS_REMOTE', has_remote)
1749 # RLBox Library Sandboxing wasm support
1750 # ==============================================================
1752 def wasm_sandboxing_libraries():
1753     return ('graphite', 'ogg',)
1755 option('--with-wasm-sandboxed-libraries',
1756        env='WASM_SANDBOXED_LIBRARIES',
1757        help='Enable wasm sandboxing for the selected libraries',
1758        nargs='+',
1759        choices=dependable(wasm_sandboxing_libraries))
1761 @depends('--with-wasm-sandboxed-libraries')
1762 def requires_wasm_sandboxing(libraries):
1763     if libraries:
1764         return True
1766 set_config('MOZ_USING_WASM_SANDBOXING', requires_wasm_sandboxing)
1767 set_define('MOZ_USING_WASM_SANDBOXING', requires_wasm_sandboxing)
1769 with only_when(requires_wasm_sandboxing & compile_environment):
1770     lucetc = check_prog('LUCETC', ['lucetc'],
1771                         paths=toolchain_search_path)
1773     option('--with-wasi-sysroot',
1774            env='WASI_SYSROOT',
1775            nargs=1,
1776            help='Path to wasi sysroot for wasm sandboxing')
1778     @depends('--with-wasi-sysroot', mozbuild_state_path)
1779     @imports('os')
1780     def wasi_sysroot(wasi_sysroot, mozbuild_state_path):
1781         if not wasi_sysroot:
1782             sysroot = os.path.join(mozbuild_state_path, 'wasi-sysroot', 'share',
1783                                    'wasi-sysroot')
1784             if os.path.isdir(sysroot):
1785                 return sysroot
1786             die('Cannot find a wasi sysroot. Install the sysroot at %s or set '
1787                 '--with-wasi-sysroot.' % sysroot)
1789         wasi_sysroot = wasi_sysroot[0]
1790         if not os.path.isdir(wasi_sysroot):
1791             die('Argument to --with-wasi-sysroot must be a directory')
1792         if not os.path.isabs(wasi_sysroot):
1793             die('Argument to --with-wasi-sysroot must be an absolute path')
1795         return wasi_sysroot
1797     set_config('WASI_SYSROOT', wasi_sysroot)
1800     def wasm_compiler_with_flags(wasm_compiler, provided_wasm_compiler, sysroot,
1801                                  compiler_wrapper):
1802         if not sysroot:
1803             return
1804         if provided_wasm_compiler:
1805             return ' '.join(
1806                 list(compiler_wrapper or []) +
1807                 provided_wasm_compiler.wrapper + [provided_wasm_compiler.program]
1808                 + provided_wasm_compiler.flags + ['--sysroot=%s' % sysroot])
1809         elif wasm_compiler:
1810             return ' '.join(
1811                 list(compiler_wrapper or []) +
1812                 [wasm_compiler] +
1813                 ['--target=wasm32-wasi', '--sysroot=%s' % sysroot])
1815     option(env='WASM_CC', nargs=1, help='Path to the C->WASM compiler')
1816     provided_wasm_cc = provided_program('WASM_CC')
1817     wasm_cc = check_prog('_WASM_CC', ['clang'], input=provided_wasm_cc.program,
1818                          paths=toolchain_search_path, allow_missing=True,
1819                          what='the C->WASM compiler')
1820     @depends(wasm_cc, provided_wasm_cc, wasi_sysroot, compiler_wrapper)
1821     def wasm_cc_with_flags(wasm_cc, provided_wasm_cc, wasi_sysroot,
1822                            compiler_wrapper):
1823         return wasm_compiler_with_flags(wasm_cc, provided_wasm_cc, wasi_sysroot,
1824                                         compiler_wrapper)
1825     set_config('WASM_CC', wasm_cc_with_flags)
1827     option(env='WASM_CXX', nargs=1, help='Path to the C++->WASM compiler')
1828     provided_wasm_cxx = provided_program('WASM_CXX')
1829     wasm_cxx = check_prog(
1830         '_WASM_CXX', ['clang++'], input=provided_wasm_cxx.program,
1831         paths=toolchain_search_path, allow_missing=True,
1832         what='the C++->WASM compiler')
1833     @depends(wasm_cxx, provided_wasm_cxx, wasi_sysroot, compiler_wrapper)
1834     def wasm_cxx_with_flags(wasm_cxx, provided_wasm_cxx, wasi_sysroot,
1835                             compiler_wrapper):
1836         return wasm_compiler_with_flags(wasm_cxx, provided_wasm_cxx, wasi_sysroot,
1837                                         compiler_wrapper)
1839     set_config('WASM_CXX', wasm_cxx_with_flags)
1842     wasm_compile_flags = dependable(['-fno-exceptions', '-fno-strict-aliasing', '-Qunused-arguments'])
1843     option(env='WASM_CFLAGS', nargs=1, help='Options to pass to WASM_CC')
1844     @depends('WASM_CFLAGS', wasm_compile_flags)
1845     def wasm_cflags(value, wasm_compile_flags):
1846         if value:
1847             return wasm_compile_flags + value
1848         else:
1849             return wasm_compile_flags
1850     set_config('WASM_CFLAGS', wasm_cflags)
1852     option(env='WASM_CXXFLAGS', nargs=1, help='Options to pass to WASM_CXX')
1853     @depends('WASM_CXXFLAGS', wasm_compile_flags)
1854     def wasm_cxxflags(value, wasm_compile_flags):
1855         if value:
1856             return wasm_compile_flags + value
1857         else:
1858             return wasm_compile_flags
1859     set_config('WASM_CXXFLAGS', wasm_cxxflags)
1861     option(env='WASM_LDFLAGS', nargs=1,
1862            help='Options to pass when linking wasm modules')
1863     @depends('WASM_LDFLAGS')
1864     def wasm_ldflags(value):
1865         if value:
1866             return value
1867     set_config('WASM_LDFLAGS', wasm_ldflags)
1869     # This function is returning "ldflags" that lucetc will use when invoking
1870     # the linker, but really lucetc is going to be invoking the compiler, since
1871     # the compiler handles lots of details for us (like finding the linker in
1872     # cross-compilation scenarios).
1873     @depends(target)
1874     def lucetc_ldflags(target):
1875         if target.kernel == 'Linux':
1876             return [
1877                 '-Wl,-shared',
1878                 '-nostdlib',
1879             ]
1881         if target.kernel == 'Darwin':
1882             return [
1883                 '-Wl,-dylib',
1884                 '-Wl,-dead_strip',
1885                 '-Wl,-export_dynamic',
1886                 '-Wl,-undefined,dynamic_lookup',
1887                 '-nostdlib',
1888             ]
1890     set_config('LUCETC_LDFLAGS', lucetc_ldflags)
1892     # Re-using the Rust target triple here is not exactly correct, but it is an
1893     # excellent approximation for the platforms we currently support
1894     set_config('LUCETC_TARGET', rust_target_triple)
1897 @depends('--with-wasm-sandboxed-libraries', target)
1898 def wasm_sandboxing(libraries, target):
1899     if not libraries:
1900         return
1902     # Wasm sandboxing is only enabled on specific targets.
1903     if not (target.cpu in ('x86_64',) and \
1904             (target.kernel == 'Linux' and target.os != 'Android') or \
1905             target.kernel == 'Darwin'):
1906         die('wasm sandboxing is only enabled on x86-64 Linux and Mac')
1908     return namespace(**{name: True for name in libraries})
1910 @template
1911 def wasm_sandboxing_config_defines():
1912     for lib in wasm_sandboxing_libraries():
1913         set_config('MOZ_WASM_SANDBOXING_%s' % lib.upper(), getattr(wasm_sandboxing, lib))
1914         set_define('MOZ_WASM_SANDBOXING_%s' % lib.upper(), getattr(wasm_sandboxing, lib))
1916 wasm_sandboxing_config_defines()
1919 # new XULStore implementation
1920 # ==============================================================
1922 @depends(milestone)
1923 def new_xulstore(milestone):
1924     if milestone.is_nightly:
1925         return True
1927 set_config('MOZ_NEW_XULSTORE', True, when=new_xulstore)
1928 set_define('MOZ_NEW_XULSTORE', True, when=new_xulstore)
1931 # new Notification Store implementation
1932 # ==============================================================
1934 @depends(milestone)
1935 def new_notification_store(milestone):
1936     if milestone.is_nightly:
1937         return True
1939 set_config('MOZ_NEW_NOTIFICATION_STORE', True, when=new_notification_store)
1940 set_define('MOZ_NEW_NOTIFICATION_STORE', True, when=new_notification_store)
1943 # Glean SDK Integration Crate
1944 # ==============================================================
1946 @depends(milestone, target)
1947 def glean(milestone, target):
1948     if milestone.is_nightly and target.os != 'Android':
1949         return True
1951 set_config('MOZ_GLEAN', True, when=glean)
1952 set_define('MOZ_GLEAN', True, when=glean)
1956 # New Firefox Accounts client implemented in Rust
1957 # ===============================================
1959 @depends(milestone, target)
1960 def rust_fxa_client(milestone, target):
1961     if milestone.is_nightly and target.os != 'Android':
1962         return True
1964 set_config('MOZ_RUST_FXA_CLIENT', True, when=rust_fxa_client)
1965 set_define('MOZ_RUST_FXA_CLIENT', True, when=rust_fxa_client)
1969 # dump_syms
1970 # ==============================================================
1972 check_prog('DUMP_SYMS', ['dump_syms'], allow_missing=True, paths=toolchain_search_path,
1973            when=compile_environment)
1976 check_prog('PDBSTR', ['pdbstr.exe'], allow_missing=True, paths=toolchain_search_path,
1977            when=compile_environment & target_is_windows)
1979 @depends('MOZ_AUTOMATION', c_compiler)
1980 def allow_missing_winchecksec(automation, c_compiler):
1981     if not automation:
1982         return True
1983     if c_compiler and c_compiler.type != 'clang-cl':
1984         return True
1986 check_prog('WINCHECKSEC', ['winchecksec.exe', 'winchecksec'], paths=toolchain_search_path,
1987            allow_missing=allow_missing_winchecksec,
1988            when=compile_environment & target_is_windows)
1990 # Fork server
1991 @depends(target, build_project)
1992 def forkserver_default(target, build_project):
1993     return build_project == 'browser' and \
1994         ((target.os == 'GNU' and target.kernel == 'Linux') or \
1995          target.os == 'FreeBSD')
1997 option('--enable-forkserver', default=forkserver_default,
1998        env='MOZ_ENABLE_FORKSERVER', help='{Enable|Disable} fork server')
2000 @depends('--enable-forkserver', target)
2001 def forkserver_flag(value, target):
2002     if target.os == 'Android' or \
2003        (target.os == 'GNU' and target.kernel == 'Linux') or \
2004        target.os == 'FreeBSD':
2005         return bool(value)
2006     pass
2008 set_config('MOZ_ENABLE_FORKSERVER', forkserver_flag)
2009 set_define('MOZ_ENABLE_FORKSERVER', forkserver_flag, forkserver_flag)
2011 # new cert storage implementation
2012 # ==============================================================
2013 option('--disable-new-cert-storage', env='MOZ_NEW_CERT_STORAGE',
2014        help='{Enable|Disable} new certificate storage')
2016 set_config('MOZ_NEW_CERT_STORAGE', True, when='--enable-new-cert-storage')
2017 set_define('MOZ_NEW_CERT_STORAGE', True, when='--enable-new-cert-storage')
2019 # Crash Reporter
2020 # ==============================================================
2022 with only_when(compile_environment & target_is_linux):
2023     # Check if we need to use the breakpad_getcontext fallback.
2024     getcontext = check_symbol('getcontext')
2025     set_config('HAVE_GETCONTEXT', getcontext)
2026     set_define('HAVE_GETCONTEXT', getcontext)
2028 # NSS
2029 # ==============================================================
2030 include('../build/moz.configure/nss.configure')
2032 # Update-related programs: updater, maintenance service, update agent,
2033 # default browser agent.
2034 # ==============================================================
2035 include('../build/moz.configure/update-programs.configure')
2037 # Mobile optimizations
2038 # ==============================================================
2039 option('--enable-mobile-optimize', default=target_is_android,
2040        help='{Enable|Disable} mobile optimizations')
2042 set_define('MOZ_GFX_OPTIMIZE_MOBILE', True, when='--enable-mobile-optimize')
2043 # We ignore "paint will resample" on mobile for performance.
2044 # We may want to revisit this later.
2045 set_define('MOZ_IGNORE_PAINT_WILL_RESAMPLE', True,
2046            when='--enable-mobile-optimize')
2048 # Pref extensions
2049 # ==============================================================
2050 option('--disable-pref-extensions',
2051        help='Disable pref extensions such as autoconfig')
2052 set_config('MOZ_PREF_EXTENSIONS', True, when='--enable-pref-extensions')
2054 # Offer a way to disable the startup cache
2055 # ==============================================================
2056 option('--disable-startupcache', help='Disable startup cache')
2058 @depends('--enable-startupcache')
2059 def enable_startupcache(value):
2060     if value:
2061         return True
2063 set_define('MOZ_DISABLE_STARTUPCACHE', True,
2064            when=depends(enable_startupcache)(lambda x: not x))
2067 # Branding
2068 # ==============================================================
2069 option(env='MOZ_APP_REMOTINGNAME', nargs=1,
2070        help='Used for the internal program name, which affects profile name '
2071        'and remoting. If not set, defaults to MOZ_APP_NAME.')
2073 @depends('MOZ_APP_REMOTINGNAME', moz_app_name)
2074 def moz_app_remotingname(value, moz_app_name):
2075     if value:
2076         return value[0]
2077     return moz_app_name
2079 set_config('MOZ_APP_REMOTINGNAME', moz_app_remotingname)
2081 option(env='ANDROID_PACKAGE_NAME', nargs=1,
2082        help='Name of the Android package (default org.mozilla.$MOZ_APP_NAME)')
2084 @depends('ANDROID_PACKAGE_NAME', moz_app_name)
2085 def android_package_name(value, moz_app_name):
2086     if value:
2087         return value[0]
2088     if moz_app_name == 'fennec':
2089         return 'org.mozilla.fennec_aurora'
2090     return 'org.mozilla.%s' % moz_app_name
2092 set_config('ANDROID_PACKAGE_NAME', android_package_name)
2095 # Miscellaneous options
2096 # ==============================================================
2097 option(env='MOZ_WINCONSOLE', nargs='?',
2098        help='Whether we can create a console window.')
2099 set_define('MOZ_WINCONSOLE', True, when=depends('MOZ_WINCONSOLE')(lambda x: x))
2101 option(env='MOZ_USE_NATIVE_POPUP_WINDOWS', default=target_is_android,
2102        help='Whether to use native popup windows')
2104 set_define('MOZ_USE_NATIVE_POPUP_WINDOWS', True,
2105            when='MOZ_USE_NATIVE_POPUP_WINDOWS')