Source code

Revision control

Other Tools

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/.
6
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('__sandbox__')
14
def all_configure_options():
15
result = []
16
previous = None
17
for option in __sandbox__._options.itervalues():
18
# __sandbox__._options contains items for both option.name and
19
# option.env. But it's also an OrderedDict, meaning both are
20
# consecutive.
21
# Also ignore OLD_CONFIGURE and MOZCONFIG because they're not
22
# interesting.
23
if option == previous or option.env in ('OLD_CONFIGURE', 'MOZCONFIG'):
24
continue
25
previous = option
26
value = __sandbox__._value_for(option)
27
# We only want options that were explicitly given on the command
28
# line, the environment, or mozconfig, and that differ from the
29
# defaults.
30
if (value is not None and value.origin not in ('default', 'implied') and
31
value != option.default):
32
result.append(ensure_unicode(__sandbox__._raw_options[option],
33
system_encoding))
34
# We however always include options that are sent to old configure
35
# because we don't know their actual defaults. (Keep the conditions
36
# separate for ease of understanding and ease of removal)
37
elif (option.help == 'Help missing for old configure options' and
38
option in __sandbox__._raw_options):
39
result.append(ensure_unicode(__sandbox__._raw_options[option],
40
system_encoding))
41
42
# We shouldn't need this, but currently, quote will return a byte string
43
# if result is empty, and that's not wanted here.
44
if not result:
45
return ''
46
47
return quote(*result)
48
49
50
set_config('MOZ_CONFIGURE_OPTIONS', all_configure_options)
51
52
# Profiling
53
# ==============================================================
54
# Some of the options here imply an option from js/moz.configure,
55
# so, need to be declared before the include.
56
57
option('--enable-jprof', env='MOZ_JPROF',
58
help='Enable jprof profiling tool (needs mozilla/tools/jprof)')
59
60
@depends('--enable-jprof')
61
def jprof(value):
62
if value:
63
return True
64
65
set_config('MOZ_JPROF', jprof)
66
set_define('MOZ_JPROF', jprof)
67
imply_option('--enable-profiling', jprof)
68
69
@depends(target)
70
def gecko_profiler(target):
71
if target.os == 'Android':
72
return target.cpu in ('aarch64', 'arm', 'x86', 'x86_64')
73
elif target.kernel == 'Linux':
74
return target.cpu in ('aarch64', 'arm', 'x86', 'x86_64', 'mips64')
75
return target.os in ('OSX', 'WINNT')
76
77
@depends(gecko_profiler)
78
def gecko_profiler_define(value):
79
if value:
80
return True
81
82
set_config('MOZ_GECKO_PROFILER', gecko_profiler_define)
83
set_define('MOZ_GECKO_PROFILER', gecko_profiler_define)
84
85
86
# Whether code to parse ELF binaries should be compiled for the Gecko profiler
87
# (for symbol table dumping).
88
@depends(gecko_profiler, target)
89
def gecko_profiler_parse_elf(value, target):
90
# Currently we only want to build this code on Linux (including Android).
91
# For Android, this is in order to dump symbols from Android system, where
92
# on other platforms there exist alternatives that don't require bloating
93
# up our binary size. For Linux more generally, we use this in profile
94
# pre-symbolication support, since MozDescribeCodeAddress doesn't do
95
# anything useful on that platform. (Ideally, we would update
96
# MozDescribeCodeAddress to call into some Rust crates that parse ELF and
97
# DWARF data, but build system issues currently prevent Rust from being
98
# used in mozglue.)
99
if value and target.kernel == 'Linux':
100
return True
101
102
set_config('MOZ_GECKO_PROFILER_PARSE_ELF', gecko_profiler_parse_elf)
103
set_define('MOZ_GECKO_PROFILER_PARSE_ELF', gecko_profiler_parse_elf)
104
105
# enable this by default if the profiler is enabled
106
# Note: also requires jemalloc
107
set_config('MOZ_PROFILER_MEMORY', gecko_profiler_define)
108
set_define('MOZ_PROFILER_MEMORY', gecko_profiler_define)
109
110
111
@depends('--enable-debug', milestone, build_project,
112
# Artifact builds are included because the downloaded artifacts can
113
# have DMD enabled.
114
when=artifact_builds | depends(when='--enable-replace-malloc')(lambda: True))
115
def dmd_default(debug, milestone, build_project):
116
return bool(build_project == 'browser' and (debug or milestone.is_nightly))
117
118
119
option('--enable-dmd', env='MOZ_DMD', default=dmd_default,
120
help='{Enable|Disable} Dark Matter Detector (heap profiler). '
121
'Also enables jemalloc, replace-malloc and profiling')
122
123
124
@depends('--enable-dmd')
125
def dmd(value):
126
if value:
127
return True
128
129
130
set_config('MOZ_DMD', dmd)
131
set_define('MOZ_DMD', dmd)
132
add_old_configure_assignment('MOZ_DMD', dmd)
133
imply_option('--enable-profiling', dmd)
134
imply_option('--enable-jemalloc', dmd, when=compile_environment)
135
imply_option('--enable-replace-malloc', dmd, when=compile_environment)
136
137
# ALSA cubeb backend
138
# ==============================================================
139
option('--enable-alsa', env='MOZ_ALSA',
140
help='Enable ALSA audio backend.')
141
142
alsa = pkg_check_modules('MOZ_ALSA', 'alsa', when='--enable-alsa')
143
144
set_config('MOZ_ALSA', depends_if(alsa)(lambda _: True))
145
set_define('MOZ_ALSA', depends_if(alsa)(lambda _: True))
146
147
# JACK cubeb backend
148
# ==============================================================
149
option('--enable-jack', env='MOZ_JACK',
150
help='Enable JACK audio backend.')
151
152
jack = pkg_check_modules('MOZ_JACK', 'jack', when='--enable-jack')
153
154
set_config('MOZ_JACK', depends_if(jack)(lambda _: True))
155
set_define('MOZ_JACK', depends_if(jack)(lambda _: True))
156
157
# PulseAudio cubeb backend
158
# ==============================================================
159
@depends(target)
160
def pulseaudio_default(target):
161
return target.os not in ('WINNT', 'OSX', 'iOS', 'Android', 'OpenBSD')
162
163
option('--enable-pulseaudio', env='MOZ_PULSEAUDIO', default=pulseaudio_default,
164
help='{Enable|Disable} PulseAudio audio backend.')
165
166
pulseaudio = pkg_check_modules('MOZ_PULSEAUDIO', 'libpulse', when='--enable-pulseaudio')
167
168
set_config('MOZ_PULSEAUDIO', depends_if(pulseaudio)(lambda _: True))
169
set_define('MOZ_PULSEAUDIO', depends_if(pulseaudio)(lambda _: True))
170
171
# AudioUnit cubeb Rust backend
172
# ==============================================================
173
@depends(target)
174
def enable_audiounit_rust(target):
175
return target.os == 'OSX' and target.kernel == 'Darwin'
176
177
set_config('MOZ_AUDIOUNIT_RUST', True, when=enable_audiounit_rust)
178
set_define('MOZ_AUDIOUNIT_RUST', True, when=enable_audiounit_rust)
179
180
# Javascript engine
181
# ==============================================================
182
include('../js/moz.configure')
183
184
185
# NodeJS
186
# ==============================================================
187
include('../build/moz.configure/node.configure')
188
189
# L10N
190
# ==============================================================
191
option('--with-l10n-base', nargs=1, env='L10NBASEDIR',
192
help='Path to l10n repositories')
193
194
@depends('--with-l10n-base', 'MOZ_AUTOMATION', target, check_build_environment)
195
@imports(_from='os.path', _import='isdir')
196
@imports(_from='os.path', _import='expanduser')
197
@imports(_from='os', _import='environ')
198
def l10n_base(value, automation, target, build_env):
199
if value:
200
path = value[0]
201
if not isdir(path):
202
die("Invalid value --with-l10n-base, %s doesn't exist", path)
203
elif automation:
204
if target.os == 'Android':
205
path = os.path.join(build_env.topobjdir, '..', '..', 'l10n-central')
206
else:
207
path = os.path.join(build_env.topobjdir, '..', '..', 'l10n')
208
else:
209
path = os.path.join(
210
environ.get(
211
'MOZBUILD_STATE_PATH',
212
expanduser(os.path.join('~', '.mozbuild'))),
213
'l10n-central')
214
return os.path.realpath(os.path.abspath(path))
215
216
set_config('L10NBASEDIR', l10n_base)
217
218
219
# Default toolkit
220
# ==============================================================
221
@depends(target)
222
def toolkit_choices(target):
223
if target.os == 'WINNT':
224
return ('cairo-windows',)
225
elif target.os == 'OSX':
226
return ('cairo-cocoa',)
227
elif target.os == 'iOS':
228
return ('cairo-uikit',)
229
elif target.os == 'Android':
230
return ('cairo-android',)
231
else:
232
return ('cairo-gtk3', 'cairo-gtk3-wayland')
233
234
@depends(toolkit_choices)
235
def toolkit_default(choices):
236
return choices[0]
237
238
option('--enable-default-toolkit', nargs=1,
239
choices=toolkit_choices, default=toolkit_default,
240
help='Select default toolkit')
241
242
@depends_if('--enable-default-toolkit')
243
def full_toolkit(value):
244
return value[0]
245
246
@depends(full_toolkit)
247
def toolkit(toolkit):
248
if toolkit.startswith('cairo-gtk3'):
249
widget_toolkit = 'gtk'
250
else:
251
widget_toolkit = toolkit.replace('cairo-', '')
252
return widget_toolkit
253
254
set_config('MOZ_WIDGET_TOOLKIT', toolkit)
255
add_old_configure_assignment('MOZ_WIDGET_TOOLKIT', toolkit)
256
257
@depends(toolkit)
258
def toolkit_define(toolkit):
259
if toolkit != 'windows':
260
return 'MOZ_WIDGET_%s' % toolkit.upper()
261
262
set_define(toolkit_define, True)
263
264
@depends(toolkit)
265
def toolkit_gtk(toolkit):
266
return toolkit == 'gtk'
267
268
set_config('MOZ_X11', True, when=toolkit_gtk)
269
set_define('MOZ_X11', True, when=toolkit_gtk)
270
add_old_configure_assignment('MOZ_X11', True, when=toolkit_gtk)
271
272
# Wayland support
273
# ==============================================================
274
wayland_headers = pkg_check_modules(
275
'MOZ_WAYLAND', 'gtk+-wayland-3.0 >= 3.10 xkbcommon >= 0.4.1 libdrm >= 2.4',
276
allow_missing=depends(full_toolkit)(lambda t: t == 'cairo-gtk3'),
277
when=depends(full_toolkit)(lambda t: t in ('cairo-gtk3', 'cairo-gtk3-wayland')))
278
279
280
@depends(wayland_headers, toolkit_gtk, artifact_builds)
281
def wayland_headers(wayland, toolkit_gtk, artifacts):
282
if toolkit_gtk and artifacts:
283
return True
284
return wayland
285
286
287
set_config('MOZ_WAYLAND', depends_if(wayland_headers)(lambda _: True))
288
set_define('MOZ_WAYLAND', depends_if(wayland_headers)(lambda _: True))
289
290
# GL Provider
291
# ==============================================================
292
option('--with-gl-provider', nargs=1, help='Set GL provider backend type')
293
294
@depends('--with-gl-provider')
295
def gl_provider(value):
296
if value:
297
return value[0]
298
299
@depends(gl_provider)
300
def gl_provider_define(provider):
301
if provider:
302
return 'GLContextProvider%s' % provider
303
304
set_define('MOZ_GL_PROVIDER', gl_provider_define)
305
306
@depends(gl_provider, wayland_headers, toolkit_gtk)
307
def gl_default_provider(value, wayland, toolkit_gtk):
308
if value:
309
return value
310
elif wayland:
311
return 'EGL'
312
elif toolkit_gtk:
313
return 'GLX'
314
315
set_config('MOZ_GL_PROVIDER', gl_provider)
316
set_config('MOZ_GL_DEFAULT_PROVIDER', gl_default_provider)
317
318
@depends(gl_default_provider)
319
def gl_provider_define(provider):
320
if provider:
321
return 'GL_PROVIDER_%s' % provider
322
323
set_define(gl_provider_define, True)
324
325
326
# PDF printing
327
# ==============================================================
328
@depends(toolkit)
329
def pdf_printing(toolkit):
330
if toolkit in ('windows', 'gtk', 'android'):
331
return True
332
333
@depends(pdf_printing)
334
def pdf_surface_feature(pdf_printing):
335
if pdf_printing:
336
return '#define CAIRO_HAS_PDF_SURFACE 1'
337
else:
338
# CONFIGURE_SUBST_FILES need explicit empty values.
339
return ''
340
341
set_config('MOZ_PDF_PRINTING', pdf_printing)
342
set_config('PDF_SURFACE_FEATURE', pdf_surface_feature)
343
344
345
# Event loop instrumentation
346
# ==============================================================
347
option(env='MOZ_INSTRUMENT_EVENT_LOOP',
348
help='Force-enable event loop instrumentation')
349
350
@depends('MOZ_INSTRUMENT_EVENT_LOOP', toolkit)
351
def instrument_event_loop(value, toolkit):
352
if value or (toolkit in ('windows', 'gtk', 'cocoa', 'android') and
353
value.origin == 'default'):
354
return True
355
356
set_config('MOZ_INSTRUMENT_EVENT_LOOP', instrument_event_loop)
357
set_define('MOZ_INSTRUMENT_EVENT_LOOP', instrument_event_loop)
358
359
360
# Fontconfig Freetype
361
# ==============================================================
362
option(env='USE_FC_FREETYPE',
363
help='Force-enable the use of fontconfig freetype')
364
365
@depends('USE_FC_FREETYPE', toolkit)
366
def fc_freetype(value, toolkit):
367
if value or (toolkit == 'gtk' and
368
value.origin == 'default'):
369
return True
370
371
add_old_configure_assignment('USE_FC_FREETYPE', fc_freetype)
372
373
# Pango
374
# ==============================================================
375
pkg_check_modules('MOZ_PANGO',
376
'pango >= 1.22.0 pangoft2 >= 1.22.0 pangocairo >= 1.22.0',
377
when=toolkit_gtk)
378
379
# Fontconfig
380
# ==============================================================
381
fontconfig_info = pkg_check_modules('_FONTCONFIG', 'fontconfig >= 2.7.0',
382
when=fc_freetype)
383
384
@depends(fc_freetype)
385
def check_for_freetype2(fc_freetype):
386
if fc_freetype:
387
return True
388
389
# Check for freetype2. Flags are combined with fontconfig flags.
390
freetype2_info = pkg_check_modules('_FT2', 'freetype2 >= 6.1.0',
391
when=check_for_freetype2)
392
393
@depends(fontconfig_info, freetype2_info)
394
def freetype2_combined_info(fontconfig_info, freetype2_info):
395
if not freetype2_info:
396
return
397
if not fontconfig_info:
398
return freetype2_info
399
return namespace(
400
cflags=freetype2_info.cflags + fontconfig_info.cflags,
401
libs=freetype2_info.libs + fontconfig_info.libs,
402
)
403
404
add_old_configure_assignment('_HAVE_FREETYPE2',
405
depends_if(freetype2_info)(lambda _: True))
406
407
# Apple platform decoder support
408
# ==============================================================
409
@depends(toolkit)
410
def applemedia(toolkit):
411
if toolkit in ('cocoa', 'uikit'):
412
return True
413
414
set_config('MOZ_APPLEMEDIA', applemedia)
415
set_define('MOZ_APPLEMEDIA', applemedia)
416
add_old_configure_assignment('MOZ_APPLEMEDIA', applemedia)
417
418
# Windows Media Foundation support
419
# ==============================================================
420
option('--disable-wmf',
421
help='Disable support for Windows Media Foundation')
422
423
@depends('--disable-wmf', target)
424
def wmf(value, target):
425
enabled = bool(value)
426
if value.origin == 'default':
427
# Enable Windows Media Foundation support by default.
428
# Note our minimum SDK version is Windows 7 SDK, so we are (currently)
429
# guaranteed to have a recent-enough SDK to build WMF.
430
enabled = target.os == 'WINNT'
431
if enabled and target.os != 'WINNT':
432
die('Cannot enable Windows Media Foundation support on %s', target.os)
433
if enabled:
434
return True
435
436
set_config('MOZ_WMF', wmf)
437
set_define('MOZ_WMF', wmf)
438
439
# FFmpeg H264/AAC Decoding Support
440
# ==============================================================
441
option('--disable-ffmpeg',
442
help='Disable FFmpeg for fragmented H264/AAC decoding')
443
444
@depends('--disable-ffmpeg', target)
445
def ffmpeg(value, target):
446
enabled = bool(value)
447
if value.origin == 'default':
448
enabled = target.os not in ('Android', 'WINNT')
449
if enabled:
450
return True
451
452
set_config('MOZ_FFMPEG', ffmpeg)
453
set_define('MOZ_FFMPEG', ffmpeg)
454
imply_option('--enable-fmp4', ffmpeg, '--enable-ffmpeg')
455
456
# AV1 Video Codec Support
457
# ==============================================================
458
option('--disable-av1',
459
help='Disable av1 video support')
460
461
@depends('--enable-av1')
462
def av1(value):
463
if value:
464
return True
465
466
@depends(target, nasm_version, when=av1 & compile_environment)
467
def dav1d_asm(target, nasm_version):
468
if target.os != 'Android':
469
if target.cpu == 'aarch64':
470
return True
471
elif target.cpu in ('x86', 'x86_64'):
472
if nasm_version < '2.13':
473
die('nasm 2.13 or greater is required for AV1 support. '
474
'Either install nasm or add --disable-av1 to your configure options.')
475
return True
476
477
478
set_config('MOZ_DAV1D_ASM', dav1d_asm)
479
set_define('MOZ_DAV1D_ASM', dav1d_asm)
480
set_config('MOZ_AV1', av1)
481
set_define('MOZ_AV1', av1)
482
483
# Built-in fragmented MP4 support.
484
# ==============================================================
485
option('--disable-fmp4', env='MOZ_FMP4',
486
help='Disable support for in built Fragmented MP4 parsing')
487
488
@depends('--disable-fmp4', target, wmf, applemedia)
489
def fmp4(value, target, wmf, applemedia):
490
enabled = bool(value)
491
if value.origin == 'default':
492
# target.os == 'Android' includes all B2G versions
493
enabled = wmf or applemedia or target.os == 'Android'
494
if enabled:
495
return True
496
497
set_config('MOZ_FMP4', fmp4)
498
set_define('MOZ_FMP4', fmp4)
499
add_old_configure_assignment('MOZ_FMP4', fmp4)
500
501
@depends(target)
502
def sample_type_is_s16(target):
503
# Use integers over floats for audio on Android regardless of the CPU
504
# architecture, because audio backends for Android don't support floats.
505
# We also use integers on ARM because it's more efficient.
506
if target.os == 'Android' or target.cpu == 'arm':
507
return True
508
509
@depends(sample_type_is_s16)
510
def sample_type_is_float(t):
511
if not t:
512
return True
513
514
set_config('MOZ_SAMPLE_TYPE_S16', sample_type_is_s16)
515
set_define('MOZ_SAMPLE_TYPE_S16', sample_type_is_s16)
516
set_config('MOZ_SAMPLE_TYPE_FLOAT32', sample_type_is_float)
517
set_define('MOZ_SAMPLE_TYPE_FLOAT32', sample_type_is_float)
518
519
set_define('MOZ_VORBIS', sample_type_is_float)
520
set_config('MOZ_VORBIS', sample_type_is_float)
521
set_define('MOZ_TREMOR', sample_type_is_s16)
522
set_config('MOZ_TREMOR', sample_type_is_s16)
523
524
# OpenMAX IL Decoding Support
525
# ==============================================================
526
option('--enable-openmax',
527
help='Enable OpenMAX IL for video/audio decoding')
528
529
@depends('--enable-openmax')
530
def openmax(value):
531
enabled = bool(value)
532
if enabled:
533
return True
534
535
set_config('MOZ_OMX', openmax)
536
set_define('MOZ_OMX', openmax)
537
538
# EME Support
539
# ==============================================================
540
@depends(target)
541
def eme_choices(target):
542
if (target.kernel in ('Darwin', 'WINNT', 'Linux') and
543
target.os not in ('Android', 'iOS') and
544
target.cpu in ('x86', 'x86_64')):
545
return ('widevine',)
546
if target.kernel == 'WINNT' and target.cpu == 'aarch64':
547
return ('widevine',)
548
549
550
# Widevine is enabled by default in desktop browser builds, except
551
# on aarch64 Windows.
552
@depends(build_project, eme_choices, target)
553
def eme_default(build_project, choices, target):
554
if build_project == 'browser':
555
if target.kernel != 'WINNT' or target.cpu != 'aarch64':
556
return choices
557
558
559
option('--enable-eme',
560
nargs='+',
561
choices=eme_choices,
562
default=eme_default,
563
when=eme_choices,
564
help='{Enable|Disable} support for Encrypted Media Extensions')
565
566
567
@depends('--enable-eme', fmp4, when=eme_choices)
568
def eme(enabled, fmp4):
569
if enabled and enabled.origin != 'default' and not fmp4:
570
die('Encrypted Media Extension support requires '
571
'Fragmented MP4 support')
572
573
574
@depends('--enable-eme', when=eme_choices)
575
def eme_modules(value):
576
return value
577
578
579
# Fallback to an empty list when eme_choices is empty, setting eme_modules to
580
# None.
581
set_config('MOZ_EME_MODULES', eme_modules | dependable([]))
582
583
584
@depends(eme_modules, target, when=eme_modules)
585
def eme_win32_artifact(modules, target):
586
if 'widevine' in modules and target.kernel == 'WINNT' and target.cpu == 'aarch64':
587
return True
588
589
590
set_config('MOZ_EME_WIN32_ARTIFACT', eme_win32_artifact)
591
592
option(name='--enable-chrome-format',
593
help='Select FORMAT of chrome files during packaging.',
594
nargs=1,
595
choices=('omni', 'jar', 'flat'),
596
default='omni')
597
598
@depends('--enable-chrome-format')
599
def packager_format(value):
600
return value[0]
601
602
set_config('MOZ_PACKAGER_FORMAT', packager_format)
603
604
@depends(host, build_project)
605
def jar_maker_format(host, build_project):
606
# Multilocales for mobile/android use the same mergedirs for all locales,
607
# so we can't use symlinks for those builds.
608
if host.os == 'WINNT' or build_project == 'mobile/android':
609
return 'flat'
610
return 'symlink'
611
612
set_config('MOZ_JAR_MAKER_FILE_FORMAT', jar_maker_format)
613
614
@depends(toolkit)
615
def omnijar_name(toolkit):
616
# Fennec's static resources live in the assets/ folder of the
617
# APK. Adding a path to the name here works because we only
618
# have one omnijar file in the final package (which is not the
619
# case on desktop).
620
return 'assets/omni.ja' if toolkit == 'android' else 'omni.ja'
621
622
set_config('OMNIJAR_NAME', omnijar_name)
623
624
project_flag('MOZ_PLACES',
625
help='Build Places if required',
626
set_as_define=True)
627
628
project_flag('MOZ_SERVICES_HEALTHREPORT',
629
help='Build Firefox Health Reporter Service',
630
set_for_old_configure=True,
631
set_as_define=True)
632
633
project_flag('MOZ_NORMANDY',
634
help='Enable Normandy recipe runner',
635
set_for_old_configure=True,
636
set_as_define=True)
637
638
project_flag('MOZ_SERVICES_SYNC',
639
help='Build Sync Services if required')
640
641
project_flag('MOZ_ANDROID_HISTORY',
642
help='Enable Android History instead of Places',
643
set_as_define=True)
644
645
project_flag('MOZ_DEDICATED_PROFILES',
646
help='Enable dedicated profiles per install',
647
set_as_define=True)
648
649
project_flag('MOZ_BLOCK_PROFILE_DOWNGRADE',
650
help='Block users from starting profiles last used by a newer build',
651
set_as_define=True)
652
653
option(env='MOZ_ALLOW_LEGACY_EXTENSIONS',
654
default=milestone.is_nightly,
655
help='Allow legacy browser extensions')
656
657
@depends('MOZ_ALLOW_LEGACY_EXTENSIONS')
658
def legacy_extensions(value):
659
if bool(value):
660
return True
661
662
set_config('MOZ_ALLOW_LEGACY_EXTENSIONS', legacy_extensions)
663
set_define('MOZ_ALLOW_LEGACY_EXTENSIONS', legacy_extensions)
664
665
@depends('MOZ_PLACES', 'MOZ_ANDROID_HISTORY')
666
def check_places_and_android_history(places, android_history):
667
if places and android_history:
668
die('Cannot use MOZ_ANDROID_HISTORY alongside MOZ_PLACES.')
669
670
671
option(env='MOZ_TELEMETRY_REPORTING', default=mozilla_official,
672
help='Enable telemetry reporting')
673
674
set_define('MOZ_TELEMETRY_REPORTING', True, when='MOZ_TELEMETRY_REPORTING')
675
add_old_configure_assignment(
676
'MOZ_TELEMETRY_REPORTING', True, when='MOZ_TELEMETRY_REPORTING')
677
678
679
@depends('MOZ_TELEMETRY_REPORTING', milestone.is_nightly, fennec_nightly)
680
def telemetry_on_by_default(reporting, is_nightly, fennec_nightly):
681
return reporting and (is_nightly or fennec_nightly)
682
683
684
set_define('MOZ_TELEMETRY_ON_BY_DEFAULT', True, when=telemetry_on_by_default)
685
686
687
# gpsd support
688
# ==============================================================
689
option('--enable-gpsd', env='MOZ_GPSD',
690
help='Enable gpsd support')
691
692
@depends('--enable-gpsd')
693
def gpsd(value):
694
return bool(value)
695
696
system_gpsd = pkg_check_modules('MOZ_GPSD', 'libgps >= 3.11',
697
when=gpsd)
698
699
set_config('MOZ_GPSD', depends_if(system_gpsd)(lambda _: True))
700
701
# Miscellaneous programs
702
# ==============================================================
703
704
check_prog('TAR', ('gnutar', 'gtar', 'tar'))
705
check_prog('UNZIP', ('unzip',))
706
check_prog('ZIP', ('zip',))
707
check_prog('GN', ('gn',), allow_missing=True)
708
709
# Key files
710
# ==============================================================
711
include('../build/moz.configure/keyfiles.configure')
712
713
simple_keyfile('Mozilla API')
714
715
simple_keyfile('Google Location Service API')
716
717
simple_keyfile('Google Safebrowsing API')
718
719
id_and_secret_keyfile('Bing API')
720
721
simple_keyfile('Adjust SDK')
722
723
id_and_secret_keyfile('Leanplum SDK')
724
725
simple_keyfile('Pocket API')
726
727
728
# WebRender Debugger integration
729
# ==============================================================
730
731
option('--enable-webrender-debugger',
732
help='Build the websocket debug server in WebRender')
733
734
set_config('MOZ_WEBRENDER_DEBUGGER',
735
depends_if('--enable-webrender-debugger')(lambda _: True))
736
737
# Additional system headers defined at the application level
738
# ==============================================================
739
740
option('--enable-app-system-headers', env='MOZ_APP_SYSTEM_HEADERS',
741
help='Use additional system headers defined in $MOZ_BUILD_APP/app-system-headers.mozbuild')
742
743
@depends('--enable-app-system-headers')
744
def app_system_headers(value):
745
if value:
746
return True
747
748
set_config('MOZ_APP_SYSTEM_HEADERS', app_system_headers)
749
set_define('MOZ_APP_SYSTEM_HEADERS', app_system_headers)
750
751
# Printing
752
# ==============================================================
753
@depends(target)
754
def ios_disable_printing(target):
755
if target.os == 'iOS':
756
return False
757
758
imply_option('--enable-printing', ios_disable_printing, reason='--target')
759
760
option('--disable-printing', help='Disable printing support')
761
762
@depends('--disable-printing')
763
def printing(value):
764
if value:
765
return True
766
767
set_config('NS_PRINTING', printing)
768
set_define('NS_PRINTING', printing)
769
set_define('NS_PRINT_PREVIEW', printing)
770
771
# Speech-dispatcher support
772
# ==============================================================
773
@depends(toolkit)
774
def no_speechd_on_non_gtk(toolkit):
775
if toolkit != 'gtk':
776
return False
777
778
imply_option('--enable-synth-speechd', no_speechd_on_non_gtk,
779
reason='--enable-default-toolkit')
780
781
option('--disable-synth-speechd', help='Disable speech-dispatcher support')
782
783
set_config('MOZ_SYNTH_SPEECHD',
784
depends_if('--disable-synth-speechd')(lambda _: True))
785
786
# Speech API
787
# ==============================================================
788
option('--disable-webspeech', help='Disable support for HTML Speech API')
789
790
@depends('--disable-webspeech')
791
def webspeech(value):
792
if value:
793
return True
794
795
set_config('MOZ_WEBSPEECH', webspeech)
796
set_define('MOZ_WEBSPEECH', webspeech)
797
add_old_configure_assignment('MOZ_WEBSPEECH', webspeech)
798
799
# Speech API test backend
800
# ==============================================================
801
option('--enable-webspeechtestbackend', default=webspeech,
802
help='{Enable|Disable} support for HTML Speech API Test Backend')
803
804
@depends_if('--enable-webspeechtestbackend')
805
def webspeech_test_backend(value):
806
return True
807
808
set_config('MOZ_WEBSPEECH_TEST_BACKEND', webspeech_test_backend)
809
set_define('MOZ_WEBSPEECH_TEST_BACKEND', webspeech_test_backend)
810
811
# Enable IPDL's "expensive" unit tests
812
# ==============================================================
813
option('--enable-ipdl-tests', help='Enable expensive IPDL tests')
814
815
set_config('MOZ_IPDL_TESTS',
816
depends_if('--enable-ipdl-tests')(lambda _: True))
817
818
include('nss.configure')
819
820
# Graphics
821
# ==============================================================
822
option('--disable-skia', help='Disable use of Skia')
823
824
@depends('--disable-skia')
825
def skia(value):
826
if not value:
827
die('--disable-skia is not supported anymore')
828
else:
829
return True
830
831
set_config('MOZ_ENABLE_SKIA', skia)
832
set_define('MOZ_ENABLE_SKIA', skia)
833
set_define('USE_SKIA', skia)
834
835
option('--enable-skia-pdf', help='Enable Skia PDF')
836
837
@depends('--enable-skia-pdf', skia, target, milestone)
838
def skia_pdf(value, skia, target, milestone):
839
if value.origin == 'default':
840
if not skia:
841
return None
842
if milestone.is_nightly and target.os != 'WINNT':
843
return True
844
elif value and not skia:
845
die('Cannot enable Skia PDF without enabling Skia')
846
if skia and value:
847
return True
848
849
set_config('MOZ_ENABLE_SKIA_PDF', skia_pdf)
850
set_define('MOZ_ENABLE_SKIA_PDF', skia_pdf)
851
852
option('--enable-skia-pdf-sfntly', help='Enable SFNTLY font subsetting in Skia PDF')
853
854
@depends('--enable-skia-pdf-sfntly', skia_pdf)
855
def skia_pdf_sfntly(value, skia_pdf):
856
if value.origin == 'default':
857
return skia_pdf
858
if value and not skia_pdf:
859
die('Cannot enable SFNTLY subsetting without enabling Skia PDF')
860
if skia_pdf and value:
861
return True
862
863
set_config('MOZ_ENABLE_SKIA_PDF_SFNTLY', skia_pdf_sfntly)
864
set_define('MOZ_ENABLE_SKIA_PDF_SFNTLY', skia_pdf_sfntly)
865
866
@depends(skia_pdf_sfntly)
867
def sfntly_includes(skia_pdf_sfntly):
868
includes = []
869
if skia_pdf_sfntly:
870
includes += [
871
'/gfx/sfntly/cpp/src',
872
]
873
return includes
874
875
set_config('SFNTLY_INCLUDES', sfntly_includes)
876
877
@depends(skia)
878
def skia_includes(skia):
879
includes = []
880
if skia:
881
includes += [
882
'/gfx/skia',
883
'/gfx/skia/skia',
884
]
885
return includes
886
887
set_config('SKIA_INCLUDES', skia_includes)
888
889
option('--with-system-webp',
890
help='Use system libwebp (located with pkgconfig)')
891
892
system_webp = pkg_check_modules('MOZ_WEBP', 'libwebp >= 1.0.2 libwebpdemux >= 1.0.2',
893
when='--with-system-webp')
894
895
set_config('MOZ_SYSTEM_WEBP', depends(when=system_webp)(lambda: True))
896
897
# Build Freetype in the tree
898
# ==============================================================
899
@depends(target, skia_pdf)
900
def tree_freetype(target, skia_pdf):
901
if target.os == 'Android' or (skia_pdf and target.os == 'WINNT'):
902
return True
903
904
set_define('MOZ_TREE_FREETYPE', tree_freetype)
905
set_config('MOZ_TREE_FREETYPE', tree_freetype)
906
add_old_configure_assignment('MOZ_TREE_FREETYPE', tree_freetype)
907
908
set_define('HAVE_FT_BITMAP_SIZE_Y_PPEM', tree_freetype)
909
set_define('HAVE_FT_GLYPHSLOT_EMBOLDEN', tree_freetype)
910
set_define('HAVE_FT_LOAD_SFNT_TABLE', tree_freetype)
911
912
@depends(freetype2_combined_info, tree_freetype, check_build_environment)
913
def ft2_info(freetype2_combined_info, tree_freetype, build_env):
914
if tree_freetype:
915
return namespace(cflags=('-I%s/modules/freetype2/include' % build_env.topsrcdir,),
916
libs=())
917
if freetype2_combined_info:
918
return freetype2_combined_info
919
920
set_config('FT2_LIBS', ft2_info.libs)
921
add_old_configure_assignment('FT2_LIBS',
922
ft2_info.libs)
923
add_old_configure_assignment('FT2_CFLAGS',
924
ft2_info.cflags)
925
926
927
# Remote agent (part of CDP based remote protocol)
928
# ==============================================================
929
#
931
# The source code lives under ../remote.
932
933
@depends(target, milestone)
934
def remote_default(target, milestone):
935
return target.os != 'Android' and milestone.is_nightly
936
937
option('--disable-cdp', default=remote_default,
938
help='{Enable|Disable} remote agent')
939
940
@depends('--disable-cdp')
941
def remote(value):
942
if value:
943
return True
944
945
set_config('ENABLE_REMOTE_AGENT', remote)
946
set_define('ENABLE_REMOTE_AGENT', remote)
947
948
949
# Marionette remote protocol
950
# ==============================================================
951
#
952
# Marionette is the Gecko remote protocol used for various remote control,
953
# automation, and testing purposes throughout Gecko, Firefox, and Fennec.
954
# Marionette lives in ../testing/marionette.
955
#
956
# Marionette is not really a toolkit feature, as much as a Gecko
957
# engine feature. But it is enabled based on the toolkit, so here it
958
# lives.
959
#
960
# It also backs ../testing/geckodriver, which is Mozilla's WebDriver
961
# implementation.
962
#
963
# For more information, see
965
966
option('--disable-marionette',
967
help='Disable Marionette remote protocol')
968
969
@depends('--disable-marionette')
970
def marionette(value):
971
if value:
972
return True
973
974
set_config('ENABLE_MARIONETTE', marionette)
975
976
977
# geckodriver WebDriver implementation
978
# ==============================================================
979
#
980
# Turn off geckodriver for build configs we don't handle yet,
981
# but allow --enable-geckodriver to override when compile environment is available.
982
# --disable-tests implies disabling geckodriver.
983
984
@depends('--enable-tests', target, cross_compiling, hazard_analysis, asan)
985
def geckodriver_default(enable_tests, target, cross_compile, hazard, asan):
986
if not enable_tests:
987
return False
988
# geckodriver depends on winapi 0.2.8, which doesn't work with AArch64.
989
if target.os == 'WINNT' and target.cpu == 'aarch64':
990
return False
991
if hazard or target.os == 'Android' or (asan and cross_compile):
992
return False
993
return True
994
995
option('--enable-geckodriver', default=geckodriver_default,
996
when='--enable-compile-environment',
997
help='{Build|Do not build} geckodriver')
998
999
@depends('--enable-geckodriver', when='--enable-compile-environment')
1000
def geckodriver(enabled):
1001
if enabled:
1002
return True
1003
1004
set_config('ENABLE_GECKODRIVER', geckodriver)
1005
1006
1007
# WebRTC
1008
# ========================================================
1009
@depends(target)
1010
def webrtc_default(target):
1011
# Turn off webrtc for OS's we don't handle yet, but allow
1012
# --enable-webrtc to override.
1013
os_match = False
1014
for os_fragment in ('linux', 'mingw', 'android', 'linuxandroid',
1015
'dragonfly', 'freebsd', 'netbsd', 'openbsd',
1016
'darwin'):
1017
if target.raw_os.startswith(os_fragment):
1018
os_match = True
1019
1020
cpu_match = False
1021
if (target.cpu in ('x86_64', 'arm', 'aarch64', 'x86', 'ia64', 'mips32', 'mips64') or
1022
target.cpu.startswith('ppc')):
1023
cpu_match = True
1024
1025
if os_match and cpu_match:
1026
return True
1027
return False
1028
1029
option('--disable-webrtc', default=webrtc_default,
1030
help='{Enable|Disable} support for WebRTC')
1031
1032
@depends('--disable-webrtc')
1033
def webrtc(enabled):
1034
if enabled:
1035
return True
1036
1037
set_config('MOZ_WEBRTC', webrtc)
1038
set_define('MOZ_WEBRTC', webrtc)
1039
add_old_configure_assignment('MOZ_WEBRTC', webrtc)
1040
set_config('MOZ_SCTP', webrtc)
1041
set_define('MOZ_SCTP', webrtc)
1042
set_config('MOZ_SRTP', webrtc)
1043
set_define('MOZ_SRTP', webrtc)
1044
set_config('MOZ_WEBRTC_SIGNALING', webrtc)
1045
set_define('MOZ_WEBRTC_SIGNALING', webrtc)
1046
set_config('MOZ_PEERCONNECTION', webrtc)
1047
set_define('MOZ_PEERCONNECTION', webrtc)
1048
# MOZ_WEBRTC_ASSERT_ALWAYS turns on a number of safety asserts in
1049
# opt/production builds (via MOZ_CRASH())
1050
set_config('MOZ_WEBRTC_ASSERT_ALWAYS', webrtc)
1051
set_define('MOZ_WEBRTC_ASSERT_ALWAYS', webrtc)
1052
1053
option('--enable-hardware-aec-ns', when=webrtc,
1054
help='Enable support for hardware AEC and noise suppression')
1055
1056
set_config('MOZ_WEBRTC_HARDWARE_AEC_NS',
1057
depends_if('--enable-hardware-aec-ns', when=webrtc)(lambda _: True))
1058
set_define('MOZ_WEBRTC_HARDWARE_AEC_NS',
1059
depends_if('--enable-hardware-aec-ns', when=webrtc)(lambda _: True))
1060
1061
# RAW media
1062
# ==============================================================
1063
1064
@depends(target, webrtc)
1065
def raw_media_default(target, webrtc):
1066
if target.os == 'Android':
1067
return True
1068
if webrtc:
1069
return True
1070
1071
option('--enable-raw',
1072
default=raw_media_default,
1073
help='{Enable|Disable} support for RAW media')
1074
1075
set_config('MOZ_RAW', depends_if('--enable-raw')(lambda _: True))
1076
set_define('MOZ_RAW', depends_if('--enable-raw')(lambda _: True))
1077
1078
# ASan Reporter Addon
1079
# ==============================================================
1080
option('--enable-address-sanitizer-reporter',
1081
help='Enable Address Sanitizer Reporter Extension')
1082
1083
@depends('--enable-address-sanitizer-reporter')
1084
def enable_asan_reporter(value):
1085
if value:
1086
return True
1087
1088
set_config('MOZ_ASAN_REPORTER', enable_asan_reporter)
1089
set_define('MOZ_ASAN_REPORTER', enable_asan_reporter)
1090
add_old_configure_assignment('MOZ_ASAN_REPORTER', enable_asan_reporter)
1091
1092
# Elfhack
1093
# ==============================================================
1094
with only_when('--enable-compile-environment'):
1095
@depends(host, target)
1096
def has_elfhack(host, target):
1097
return target.kernel == 'Linux' and host.kernel == 'Linux' and \
1098
target.cpu in ('arm', 'x86', 'x86_64')
1099
1100
@depends('--enable-release')
1101
def default_elfhack(release):
1102
return bool(release)
1103
1104
with only_when(has_elfhack):
1105
option('--disable-elf-hack', default=default_elfhack,
1106
help='{Enable|Disable} elf hacks')
1107
1108
set_config('USE_ELF_HACK',
1109
depends_if('--enable-elf-hack')(lambda _: True))
1110
1111
1112
@depends(check_build_environment)
1113
def idl_roots(build_env):
1114
return namespace(ipdl_root=os.path.join(build_env.topobjdir, 'ipc', 'ipdl'),
1115
webidl_root=os.path.join(build_env.topobjdir,
1116
'dom', 'bindings'),
1117
xpcom_root=os.path.join(build_env.topobjdir,
1118
'xpcom', 'components'))
1119
1120
set_config('WEBIDL_ROOT', idl_roots.webidl_root)
1121
set_config('IPDL_ROOT', idl_roots.ipdl_root)
1122
set_config('XPCOM_ROOT', idl_roots.xpcom_root)
1123
1124
# Proxy bypass protection
1125
# ==============================================================
1126
1127
option('--enable-proxy-bypass-protection',
1128
help='Prevent suspected or confirmed proxy bypasses')
1129
1130
@depends_if('--enable-proxy-bypass-protection')
1131
def proxy_bypass_protection(_):
1132
return True
1133
1134
set_config('MOZ_PROXY_BYPASS_PROTECTION', proxy_bypass_protection)
1135
set_define('MOZ_PROXY_BYPASS_PROTECTION', proxy_bypass_protection)
1136
1137
# MIDL
1138
# ==============================================================
1139
1140
@depends(c_compiler, toolchain_prefix)
1141
def midl_names(c_compiler, toolchain_prefix):
1142
if c_compiler and c_compiler.type in ['gcc', 'clang']:
1143
# mingw
1144
widl = ('widl', )
1145
if toolchain_prefix:
1146
prefixed = tuple('%s%s' % (p, 'widl') for p in toolchain_prefix)
1147
widl = prefixed + widl
1148
return widl
1149
1150
return ('midl',)
1151
1152
@depends(target, '--enable-compile-environment')
1153
def check_for_midl(target, compile_environment):
1154
if target.os != 'WINNT':
1155
return
1156
1157
if compile_environment:
1158
return True
1159
1160
1161
midl = check_prog('MIDL', midl_names, when=check_for_midl, allow_missing=True,
1162
paths=sdk_bin_path)
1163
1164
1165
@depends(c_compiler, target, toolchain_search_path,
1166
when=depends(midl, target)(lambda m, t: m and t.kernel == 'WINNT'))
1167
@imports(_from='mozbuild.shellutil', _import='quote')
1168
def midl_flags(c_compiler, target, toolchain_search_path):
1169
if c_compiler and c_compiler.type == 'clang-cl':
1170
env = {
1171
'x86': 'win32',
1172
'x86_64': 'x64',
1173
'aarch64': 'arm64',
1174
}[target.cpu]
1175
flags = ['-env', env]
1176
1177
if c_compiler.version >= '8':
1178
return flags + ['-cpp_cmd', c_compiler.compiler]
1179
1180
# clang-cl didn't work as a preprocessor for midl before version 8
1181
# so we need to find cl if we use an older version.
1183
cl = find_program('cl', paths=toolchain_search_path)
1184
if not cl:
1185
die('Could not find Microsoft Visual C/C++ compiler for MIDL')
1186
flags += ['-cpp_cmd', cl]
1187
return flags
1188
1189
# mingw
1190
return {
1191
'x86': ['--win32', '-m32'],
1192
'x86_64': ['--win64', '-m64'],
1193
}[target.cpu]
1194
1195
1196
set_config('MIDL_FLAGS', midl_flags)
1197
1198
# Accessibility
1199
# ==============================================================
1200
1201
option('--disable-accessibility', help='Disable accessibility support')
1202
1203
@depends('--enable-accessibility', check_for_midl, midl, c_compiler)
1204
def accessibility(value, check_for_midl, midl, c_compiler):
1205
enabled = bool(value)
1206
1207
if not enabled:
1208
return
1209
1210
if check_for_midl and not midl:
1211
if c_compiler and c_compiler.type in ('gcc', 'clang'):
1212
die('You have accessibility enabled, but widl could not be found. '
1213
'Add --disable-accessibility to your mozconfig or install widl. '
1215
else:
1216
die('MIDL could not be found. '
1217
'Building accessibility without MIDL is not supported.')
1218
1219
return enabled
1220
1221
1222
set_config('ACCESSIBILITY', accessibility)
1223
set_define('ACCESSIBILITY', accessibility)
1224
add_old_configure_assignment('ACCESSIBILITY', accessibility)
1225
1226
# Addon signing
1227
# ==============================================================
1228
1229
option('--with-unsigned-addon-scopes',
1230
nargs='+', choices=('app', 'system'),
1231
help='Addon scopes where signature is not required')
1232
1233
@depends('--with-unsigned-addon-scopes')
1234
def unsigned_addon_scopes(scopes):
1235
return namespace(
1236
app='app' in scopes or None,
1237
system='system' in scopes or None,
1238
)
1239
1240
set_config('MOZ_UNSIGNED_APP_SCOPE', unsigned_addon_scopes.app)
1241
set_config('MOZ_UNSIGNED_SYSTEM_SCOPE', unsigned_addon_scopes.system)
1242
1243
# Launcher process (Windows only)
1244
# ==============================================================
1245
1246
@depends(target)
1247
def launcher_process_default(target):
1248
return target.os == 'WINNT'
1249
1250
option('--enable-launcher-process', default=launcher_process_default,
1251
help='{Enable|Disable} launcher process by default')
1252
1253
@depends('--enable-launcher-process', target)
1254
def launcher(value, target):
1255
enabled = bool(value)
1256
if enabled and target.os != 'WINNT':
1257
die('Cannot enable launcher process on %s', target.os)
1258
if enabled:
1259
return True
1260
1261
set_config('MOZ_LAUNCHER_PROCESS', launcher)
1262
set_define('MOZ_LAUNCHER_PROCESS', launcher)
1263
1264
# llvm-dlltool (Windows only)
1265
# ==============================================================
1266
1267
@depends(build_project, target, '--enable-compile-environment')
1268
def check_for_llvm_dlltool(build_project, target, compile_environment):
1269
if build_project != 'browser':
1270
return
1271
1272
if target.os != 'WINNT':
1273
return
1274
1275
return compile_environment
1276
1277
llvm_dlltool = check_prog('LLVM_DLLTOOL', ('llvm-dlltool',),
1278
what='llvm-dlltool', when=check_for_llvm_dlltool,
1279
paths=toolchain_search_path)
1280
1281
@depends(target, when=llvm_dlltool)
1282
def llvm_dlltool_flags(target):
1283
arch = {
1284
'x86': 'i386',
1285
'x86_64': 'i386:x86-64',
1286
'aarch64': 'arm64',
1287
}[target.cpu]
1288
1289
return ['-m', arch]
1290
1291
set_config('LLVM_DLLTOOL_FLAGS', llvm_dlltool_flags)
1292
1293
# Maintenance service (Windows only)
1294
# ==============================================================
1295
1296
option('--enable-maintenance-service',
1297
when=target_is_windows, default=target_is_windows,
1298
help='{Enable|Disable} building of maintenance service')
1299
1300
set_define('MOZ_MAINTENANCE_SERVICE',
1301
depends_if('--enable-maintenance-service',
1302
when=target_is_windows)(lambda _: True))
1303
set_config('MOZ_MAINTENANCE_SERVICE',
1304
depends_if('--enable-maintenance-service',
1305
when=target_is_windows)(lambda _: True))
1306
1307
# BITS download (Windows only)
1308
# ==============================================================
1309
1310
option('--enable-bits-download',
1311
when=target_is_windows, default=target_is_windows,
1312
help='{Enable|Disable} building BITS download support')
1313
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))
1320
1321
# Bundled fonts on desktop platform
1322
# ==============================================================
1323
1324
@depends(target)
1325
def bundled_fonts_default(target):
1326
return target.os == 'WINNT' or target.kernel == 'Linux'
1327
1328
@depends(build_project)
1329
def allow_bundled_fonts(project):
1330
return project == 'browser' or project == 'comm/mail'
1331
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')
1335
1336
set_define('MOZ_BUNDLED_FONTS',
1337
depends_if('--enable-bundled-fonts', when=allow_bundled_fonts)(lambda _: True))
1338
1339
# Verify MAR signatures
1340
# ==============================================================
1341
1342
option('--disable-verify-mar', help='Disable verifying MAR signatures')
1343
1344
set_define('MOZ_VERIFY_MAR_SIGNATURE',
1345
depends_if('--enable-verify-mar')(lambda _: True))
1346
set_config('MOZ_VERIFY_MAR_SIGNATURE',
1347
depends_if('--enable-verify-mar')(lambda _: True))
1348
1349
# TaskTracer
1350
# ==============================================================
1351
1352
option('--enable-tasktracer', help='Enable TaskTracer')
1353
1354
set_define('MOZ_TASK_TRACER', depends_if('--enable-tasktracer')(lambda _: True))
1355
set_config('MOZ_TASK_TRACER', depends_if('--enable-tasktracer')(lambda _: True))
1356
1357
# Reflow counting
1358
# ==============================================================
1359
1360
@depends(moz_debug)
1361
def reflow_perf(debug):
1362
if debug:
1363
return True
1364
1365
option('--enable-reflow-perf',
1366
default=reflow_perf,
1367
help='{Enable|Disable} reflow performance tracing')
1368
1369
# The difference in conditions here comes from the initial implementation
1370
# in old-configure, which was unexplained there as well.
1371
set_define('MOZ_REFLOW_PERF', depends_if('--enable-reflow-perf')(lambda _: True))
1372
set_define('MOZ_REFLOW_PERF_DSP', reflow_perf)
1373
1374
# Layout debugger
1375
# ==============================================================
1376
1377
@depends(moz_debug)
1378
def layout_debugger(debug):
1379
if debug:
1380
return True
1381
1382
option('--enable-layout-debugger',
1383
default=layout_debugger,
1384
help='{Enable|Disable} layout debugger')
1385
1386
set_config('MOZ_LAYOUT_DEBUGGER', depends_if('--enable-layout-debugger')(lambda _: True))
1387
1388
1389
# Shader Compiler for Windows (and MinGW Cross Compile)
1390
# ==============================================================
1391
1392
with only_when(compile_environment):
1393
fxc = check_prog('FXC', ('fxc.exe', 'fxc2.exe'), when=depends(target)
1394
(lambda t: t.kernel == 'WINNT'),
1395
paths=sdk_bin_path)
1396
wine = check_prog('WINE', ['wine'], when=depends(target, host)
1397
(lambda t, h: t.kernel == 'WINNT' and h.kernel == 'Linux'))
1398
1399
1400
# VPX
1401
# ===
1402
1403
with only_when(compile_environment):
1404
option('--with-system-libvpx',
1405
help='Use system libvpx (located with pkgconfig)')
1406
1407
with only_when('--with-system-libvpx'):
1408
vpx = pkg_check_modules('MOZ_LIBVPX', 'vpx >= 1.7.0')
1409
1410
check_header('vpx/vpx_decoder.h', flags=vpx.cflags, onerror=lambda: die(
1411
"Couldn't find vpx/vpx_decoder.h, which is required to build "
1412
"with system libvpx. Use --without-system-libvpx to build "
1413
"with in-tree libvpx."))
1414
1415
check_symbol('vpx_codec_dec_init_ver', flags=vpx.libs, onerror=lambda: die(
1416
"--with-system-libvpx requested but symbol vpx_codec_dec_init_ver "
1417
"not found"
1418
))
1419
1420
set_config('MOZ_SYSTEM_LIBVPX', True)
1421
1422
1423
@depends('--with-system-libvpx', target, gnu_as)
1424
def in_tree_vpx(system_libvpx, target, gnu_as):
1425
if system_libvpx:
1426
return
1427
1428
use_yasm = (target.cpu in ('x86', 'x86_64')) or None
1429
need_yasm = False
1430
arm_asm = (target.cpu == 'arm' and gnu_as) or None
1431
1432
if use_yasm:
1433
need_yasm = True
1434
if target.kernel == 'WINNT':
1435
need_yasm = Version('1.1')
1436
1437
return namespace(arm_asm=arm_asm, use_yasm=use_yasm, need_yasm=need_yasm)
1438
1439
1440
# Building with -mfpu=neon requires either the "softfp" or the
1441
# "hardfp" ABI. Depending on the compiler's default target, and the
1442
# CFLAGS, the default ABI might be neither, in which case it is the
1443
# "softfloat" ABI.
1444
# The "softfloat" ABI is binary-compatible with the "softfp" ABI, so
1445
# we can safely mix code built with both ABIs. So, if we detect
1446
# that compiling uses the "softfloat" ABI, force the use of the
1447
# "softfp" ABI instead.
1448
# Confusingly, the __SOFTFP__ preprocessor variable indicates the
1449
# "softfloat" ABI, not the "softfp" ABI.
1450
# Note: VPX_ASFLAGS is also used in CFLAGS.
1451
softfp = cxx_compiler.try_compile(body='''
1452
#ifndef __SOFTFP__
1453
#error "compiler target supports -mfpu=neon, so we don't have to add extra flags"
1454
#endif''', when=in_tree_vpx.arm_asm)
1455
1456
1457
@depends(in_tree_vpx, softfp, target)
1458
def vpx_as_flags(vpx, softfp, target):
1459
flags = []
1460
if vpx and vpx.arm_asm:
1461
# These flags are a lie; they're just used to enable the requisite
1462
# opcodes; actual arch detection is done at runtime.
1463
flags = ['-march=armv7-a', '-mfpu=neon']
1464
if softfp:
1465
flags.append('-mfloat-abi=softfp')
1466
elif vpx and vpx.use_yasm and target.os != 'WINNT' and target.cpu != 'x86_64':
1467
flags = ['-DPIC']
1468
return flags
1469
1470
1471
set_config('VPX_USE_YASM', in_tree_vpx.use_yasm)
1472
set_config('VPX_ASFLAGS', vpx_as_flags)
1473
1474
1475
# JPEG
1476
# ====
1477
1478
with only_when(compile_environment):
1479
option('--with-system-jpeg', nargs='?',
1480
help='Use system libjpeg (installed at given prefix)')
1481
1482
@depends_if('--with-system-jpeg')
1483
def jpeg_flags(value):
1484
if len(value):
1485
return namespace(
1486
cflags=('-I%s/include' % value[0],),
1487
ldflags=('-L%s/lib' % value[0], '-ljpeg'),
1488
)
1489
return namespace(
1490
ldflags=('-ljpeg',),
1491
)
1492
1493
with only_when('--with-system-jpeg'):
1494
check_symbol('jpeg_destroy_compress', flags=jpeg_flags.ldflags,
1495
onerror=lambda: die('--with-system-jpeg requested but symbol '
1496
'jpeg_destroy_compress not found.'))
1497
1498
c_compiler.try_compile(
1499
includes=[
1500
'stdio.h',
1501
'sys/types.h',
1502
'jpeglib.h',
1503
],
1504
body='''
1505
#if JPEG_LIB_VERSION < 62
1506
#error Insufficient JPEG library version
1507
#endif
1508
''',
1509
flags=jpeg_flags.cflags,
1510
check_msg='for sufficient jpeg library version',
1511
onerror=lambda: die('Insufficient JPEG library version for '
1512
'--with-system-jpeg (62 required)'),
1513
)
1514
1515
c_compiler.try_compile(
1516
includes=[
1517
'stdio.h',
1518
'sys/types.h',
1519
'jpeglib.h',
1520
],
1521
body='''
1522
#ifndef JCS_EXTENSIONS
1523
#error libjpeg-turbo JCS_EXTENSIONS required
1524
#endif
1525
''',
1526
flags=jpeg_flags.cflags,
1527
check_msg='for sufficient libjpeg-turbo JCS_EXTENSIONS',
1528
onerror=lambda: die('libjpeg-turbo JCS_EXTENSIONS required for '
1529
'--with-system-jpeg'),
1530
)
1531
1532
set_config('MOZ_JPEG_CFLAGS', jpeg_flags.cflags)
1533
set_config('MOZ_JPEG_LIBS', jpeg_flags.ldflags)
1534
1535
@depends('--with-system-jpeg', target)
1536
def in_tree_jpeg(system_jpeg, target):
1537
if system_jpeg:
1538
return
1539
1540
flags = ()
1541
use_yasm = None
1542
need_yasm = False
1543
if target.kernel == 'Darwin':
1544
if target.cpu == 'x86':
1545
flags = ('-DPIC', '-DMACHO')
1546
elif target.cpu == 'x86_64':
1547
flags = ('-D__x86_64__', '-DPIC', '-DMACHO')
1548
elif target.kernel == 'WINNT':
1549
if target.cpu == 'x86':
1550
flags = ('-DPIC', '-DWIN32')
1551
elif target.cpu == 'x86_64':
1552
flags = ('-D__x86_64__', '-DPIC', '-DWIN64', '-DMSVC')
1553
elif target.cpu == 'arm':
1554
flags = ('-march=armv7-a', '-mfpu=neon')
1555
elif target.cpu == 'aarch64':
1556
flags = ('-march=armv8-a',)
1557
elif target.cpu == 'mips32':
1558
flags = ('-mdspr2',)
1559
elif target.cpu == 'x86':
1560
flags = ('-DPIC', '-DELF')
1561
elif target.cpu == 'x86_64':
1562
flags = ('-D__x86_64__', '-DPIC', '-DELF')
1563
1564
if target.cpu in ('x86', 'x86_64'):
1565
use_yasm = True
1566
if target.kernel == 'Linux' and target.os == 'GNU':
1567
need_yasm = Version('1.0.1')
1568
else:
1569
need_yasm = Version('1.1')
1570
1571
return namespace(flags=flags, use_yasm=use_yasm, need_yasm=need_yasm)
1572
1573
set_config('LIBJPEG_TURBO_USE_YASM', in_tree_jpeg.use_yasm)
1574
set_config('LIBJPEG_TURBO_ASFLAGS', in_tree_jpeg.flags)
1575
1576
1577
# Libav-fft Support
1578
# ==============================================================
1579
with only_when(compile_environment):
1580
@depends(target)
1581
def libav_fft(target):
1582
flags = None
1583
if target.kernel == 'WINNT' and target.cpu == 'x86':
1584
flags = ['-DPIC', '-DWIN32']
1585
elif target.kernel == 'WINNT' and target.cpu == 'aarch64':
1586
flags = ['-DPIC', '-DWIN64']
1587
elif target.cpu == 'x86_64':
1588
if target.kernel == 'Darwin':
1589
flags = ['-D__x86_64__', '-DPIC', '-DMACHO']
1590
elif target.kernel == 'WINNT':
1591
flags = ['-D__x86_64__', '-DPIC', '-DWIN64', '-DMSVC']
1592
else:
1593
flags = ['-D__x86_64__', '-DPIC', '-DELF']
1594
if flags:
1595
if target.kernel == 'Linux' and target.os == 'GNU':
1596
need_yasm = Version('1.0.1')
1597
else:
1598
need_yasm = Version('1.1')
1599
return namespace(flags=flags, need_yasm=need_yasm)
1600
1601
1602
set_config('MOZ_LIBAV_FFT', depends(when=libav_fft)(lambda: True))
1603
set_define('MOZ_LIBAV_FFT', depends(when=libav_fft)(lambda: True))
1604
set_config('LIBAV_FFT_ASFLAGS', libav_fft.flags)
1605
1606
1607
# FFmpeg's ffvpx configuration
1608
# ==============================================================
1609
# Artifact builds need MOZ_FFVPX defined as if compilation happened.
1610
with only_when(compile_environment | artifact_builds):
1611
@depends_if(yasm_version)
1612
def yasm_has_avx2(yasm_version):
1613
return yasm_version >= '1.2'
1614
1615
1616
set_config('YASM_HAS_AVX2', yasm_has_avx2)
1617
1618
1619
@depends(yasm_has_avx2, libav_fft, vpx_as_flags, target)
1620
def ffvpx(yasm_has_avx2, libav_fft, vpx_as_flags, target):
1621
enable = flac_only = use_yasm = False
1622
flags = []
1623
if target.cpu in ('x86', 'x86_64') or \
1624
target.cpu == 'aarch64' and target.kernel == 'WINNT':
1625
enable = True
1626
if libav_fft and libav_fft.flags:
1627
use_yasm = True
1628
flags.extend(libav_fft.flags)
1629
if target.kernel == 'WINNT':
1630
if target.cpu == 'x86':
1631
# 32-bit windows need to prefix symbols with an underscore.
1632
flags.extend(('-DPREFIX', '-Pconfig_win32.asm'))
1633
elif target.cpu == 'aarch64':
1634
use_yasm = False
1635
else:
1636
flags.append('-Pconfig_win64.asm')
1637
elif target.kernel == 'Darwin':
1638
# 32/64-bit macosx assemblers need to prefix symbols with an
1639
# underscore.
1640
flags.extend(('-DPREFIX', '-Pconfig_darwin64.asm'))
1641
else:
1642
# Default to unix.
1643
flags.append('-Pconfig_unix64.asm')
1644
else:
1645
flac_only = True
1646
elif target.cpu in ('arm', 'aarch64') and \
1647
target.kernel not in ('WINNT', 'Darwin'):
1648
enable = flac_only = True
1649
if vpx_as_flags:
1650
flags.extend(vpx_as_flags)
1651
1652
if use_yasm:
1653
# default disabled components
1654
flags.append('-Pdefaults_disabled.asm')
1655
if not yasm_has_avx2:
1656
flags.extend((
1657
'-DHAVE_AVX2=0',
1658
'-DHAVE_AVX2_INTERNAL=0',
1659
'-DHAVE_AVX2_EXTERNAL=0',
1660
))
1661
1662
return namespace(
1663
enable=enable,
1664
use_yasm=use_yasm,
1665
flac_only=flac_only,
1666
flags=flags,
1667
)
1668
1669
1670
set_config('MOZ_FFVPX', True, when=ffvpx.enable)
1671
set_define('MOZ_FFVPX', True, when=ffvpx.enable)
1672
set_config('MOZ_FFVPX_AUDIOONLY', True, when=ffvpx.flac_only)
1673
set_define('MOZ_FFVPX_AUDIOONLY', True, when=ffvpx.flac_only)
1674
set_config('FFVPX_ASFLAGS', ffvpx.flags)
1675
set_config('FFVPX_USE_YASM', True, when=ffvpx.use_yasm)
1676
1677
1678
@depends(yasm_version, in_tree_vpx.need_yasm, in_tree_jpeg.use_yasm,
1679
libav_fft.need_yasm, ffvpx.use_yasm)
1680
@imports(_from='__builtin__', _import='sorted')
1681
def valid_yasm_version(yasm_version, for_vpx, for_jpeg, for_libav,
1682
for_ffvpx=False):
1683
# Note: the default for for_ffvpx above only matters for unit tests.
1684
requires = {
1685
'vpx': for_vpx,
1686
'jpeg': for_jpeg,
1687
'libav': for_libav,
1688
'ffvpx': for_ffvpx,
1689
}
1690
requires = {k: v for (k, v) in requires.items() if v}
1691
if requires and not yasm_version:
1692
items = sorted(requires.keys())
1693
if len(items) > 1:
1694
what = ' and '.join((', '.join(items[:-1]), items[-1]))
1695
else:
1696
what = items[0]
1697
die('Yasm is required to build with %s, but you do not appear to have '
1698
'Yasm installed.' % what)
1699
1700
versioned = {k: v for (k, v) in requires.items() if v is not True}
1701
by_version = sorted(versioned.items(), key=lambda x: x[1])
1702
if by_version:
1703
what, version = by_version[-1]
1704
if yasm_version < version:
1705
die('Yasm version %s or greater is required to build with %s.'
1706
% (version, what))
1707
1708
1709
# ANGLE OpenGL->D3D translator for WebGL
1710
# ==============================================================
1711
1712
with only_when(compile_environment & target_is_windows):
1713
def d3d_compiler_dll_result(value):
1714
if not value.path:
1715
return 'provided by the OS'
1716
return value.path
1717
1718
@depends(target, valid_windows_sdk_dir, fxc)
1719
@checking('for D3D compiler DLL', d3d_compiler_dll_result)
1720
@imports('os.path')
1721
def d3d_compiler_dll(target, windows_sdk_dir, fxc):
1722
suffix = {
1723
'x86_64': 'x64',
1724
}.get(target.cpu, target.cpu)
1725
1726
name = 'd3dcompiler_47.dll'
1727
1728
if target.cpu == 'aarch64':
1729
# AArch64 Windows comes with d3dcompiler_47.dll installed
1730
return namespace(name=name, path=None)
1731
1732
if windows_sdk_dir:
1733
path = os.path.join(windows_sdk_dir.path, 'Redist', 'D3D', suffix, name)
1734
error_extra = 'in Windows SDK at {}'.format(windows_sdk_dir.path)
1735
else:
1736
path = os.path.join(os.path.dirname(fxc), name)
1737
error_extra = 'alongside FXC at {}'.format(fxc)
1738
1739
if os.path.exists(path):
1740
return namespace(name=name, path=path)
1741
die('Could not find {} {}'.format(name, error_extra))
1742
1743
1744
set_config('MOZ_ANGLE_RENDERER', True)
1745
set_config('MOZ_D3DCOMPILER_VISTA_DLL', d3d_compiler_dll.name,
1746
when=d3d_compiler_dll.path)
1747
set_config('MOZ_D3DCOMPILER_VISTA_DLL_PATH', d3d_compiler_dll.path)
1748
1749
# Remoting protocol support
1750
# ==============================================================
1751
1752
@depends(toolkit)
1753
def has_remote(toolkit):
1754
if toolkit in ('gtk', 'windows'):
1755
return True
1756
1757
set_config('MOZ_HAS_REMOTE', has_remote)
1758
set_define('MOZ_HAS_REMOTE', has_remote)
1759
1760
1761
# wasm sandboxing support
1762
# ==============================================================
1763
1764
def wasm_sandboxing_libraries():
1765
return ('graphite',)
1766
1767
option('--with-wasm-sandboxed-libraries',
1768
help='Enable wasm sandboxing for the selected libraries',
1769
nargs='+',
1770
choices=dependable(wasm_sandboxing_libraries))
1771
1772
@depends('--with-wasm-sandboxed-libraries')
1773
def requires_wasm_sandboxing(libraries):
1774
if libraries:
1775
return True
1776
1777
set_config('MOZ_USING_WASM_SANDBOXING', requires_wasm_sandboxing)
1778
1779
lucetc = check_prog('LUCETC', ['lucetc'],
1780
paths=toolchain_search_path, when=requires_wasm_sandboxing)
1781
1782
option('--with-wasi-sysroot',
1783
nargs=1,
1784
help='Path to wasi sysroot for wasm sandboxing',
1785
when=requires_wasm_sandboxing)
1786
1787
@depends('--with-wasi-sysroot', when=requires_wasm_sandboxing)
1788
@imports('os')
1789
def wasi_sysroot(wasi_sysroot):
1790
if not wasi_sysroot:
1791
return
1792
1793
wasi_sysroot = wasi_sysroot[0]
1794
if not os.path.isdir(wasi_sysroot):
1795
die('Argument to --with-wasi-sysroot must be a directory')
1796
if not os.path.isabs(wasi_sysroot):
1797
die('Argument to --with-wasi-sysroot must be an absolute path')
1798
1799
return wasi_sysroot
1800
1801
set_config('WASI_SYSROOT', wasi_sysroot)
1802
1803
1804
def wasm_compiler_with_flags(wasm_compiler, provided_wasm_compiler, sysroot):
1805
if not sysroot:
1806
return
1807
if provided_wasm_compiler:
1808
return ' '.join(
1809
provided_wasm_compiler.wrapper + [provided_wasm_compiler.program]
1810
+ provided_wasm_compiler.flags + ['--sysroot=%s' % sysroot])
1811
elif wasm_compiler:
1812
return '%s --target=wasm32-wasi --sysroot=%s' % (wasm_compiler, sysroot)
1813
1814
option(env='WASM_CC', nargs=1, help='Path to the C->WASM compiler',
1815
when=requires_wasm_sandboxing)
1816
provided_wasm_cc = provided_program('WASM_CC', when=requires_wasm_sandboxing)
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', when=requires_wasm_sandboxing)
1820
@depends(wasm_cc, provided_wasm_cc, wasi_sysroot, when=requires_wasm_sandboxing)
1821
def wasm_cc_with_flags(wasm_cc, provided_wasm_cc, wasi_sysroot):
1822
return wasm_compiler_with_flags(wasm_cc, provided_wasm_cc, wasi_sysroot)
1823
set_config('WASM_CC', wasm_cc_with_flags, when=requires_wasm_sandboxing)
1824
1825
option(env='WASM_CXX', nargs=1, help='Path to the C++->WASM compiler',
1826
when=requires_wasm_sandboxing)
1827
provided_wasm_cxx = provided_program('WASM_CXX', when=requires_wasm_sandboxing)
1828
wasm_cxx = check_prog(
1829
'_WASM_CXX', ['clang++'], input=provided_wasm_cxx.program,
1830
paths=toolchain_search_path, allow_missing=True,
1831
what='the C++->WASM compiler', when=requires_wasm_sandboxing)
1832
@depends(wasm_cxx, provided_wasm_cxx, wasi_sysroot,
1833
when=requires_wasm_sandboxing)
1834
def wasm_cxx_with_flags(wasm_cxx, provided_wasm_cxx, wasi_sysroot):
1835
return wasm_compiler_with_flags(wasm_cxx, provided_wasm_cxx, wasi_sysroot)
1836
set_config('WASM_CXX', wasm_cxx_with_flags, when=requires_wasm_sandboxing)
1837
1838
1839
@depends('--with-wasm-sandboxed-libraries', target)
1840
def wasm_sandboxing(libraries, target):
1841
if not libraries:
1842
return
1843
1844
# Wasm sandboxing is only enabled on specific targets.
1845
if not (target.cpu in ('x86_64',) and \
1846
target.kernel == 'Linux' and \
1847
target.os != 'Android'):
1848
die('wasm sandboxing is only enabled on x86-64 Linux')
1849
1850
return namespace(**{name: True for name in libraries})
1851
1852
@template
1853
def wasm_sandboxing_config_defines():
1854
for lib in wasm_sandboxing_libraries():
1855
set_config('MOZ_WASM_SANDBOXING_%s' % lib.upper(), getattr(wasm_sandboxing, lib))
1856
set_define('MOZ_WASM_SANDBOXING_%s' % lib.upper(), getattr(wasm_sandboxing, lib))
1857
1858
wasm_sandboxing_config_defines()
1859
1860
1861
# new XULStore implementation
1862
# ==============================================================
1863
1864
@depends(milestone)
1865
def new_xulstore(milestone):
1866
if milestone.is_nightly:
1867
return True
1868
1869
set_config('MOZ_NEW_XULSTORE', True, when=new_xulstore)
1870
set_define('MOZ_NEW_XULSTORE', True, when=new_xulstore)
1871
1872
1873
# new Notification Store implementation
1874
# ==============================================================
1875
1876
@depends(milestone)
1877
def new_notification_store(milestone):
1878
if milestone.is_nightly:
1879
return True
1880
1881
set_config('MOZ_NEW_NOTIFICATION_STORE', True, when=new_notification_store)
1882
set_define('MOZ_NEW_NOTIFICATION_STORE', True, when=new_notification_store)
1883
1884
1885
# new Cert Storage implementation
1886
# ==============================================================
1887
1888
@depends(milestone)
1889
def new_cert_storage(milestone):
1890
if milestone.is_nightly:
1891
return True
1892
1893
set_config('MOZ_NEW_CERT_STORAGE', True, when=new_cert_storage)
1894
set_define('MOZ_NEW_CERT_STORAGE', True, when=new_cert_storage)