Bug 1641886 [wpt PR 23851] - Support interpolating contain-intrinsic-size, a=testonly
[gecko.git] / moz.configure
blobe86018b1e8149427f0c64413b4e03a35df5c8134
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 include('build/moz.configure/init.configure')
9 # Note:
10 # - Gecko-specific options and rules should go in toolkit/moz.configure.
11 # - Firefox-specific options and rules should go in browser/moz.configure.
12 # - Fennec-specific options and rules should go in
13 #   mobile/android/moz.configure.
14 # - Spidermonkey-specific options and rules should go in js/moz.configure.
15 # - etc.
17 option('--enable-artifact-builds', env='MOZ_ARTIFACT_BUILDS',
18        help='Download and use prebuilt binary artifacts.')
20 @depends('--enable-artifact-builds')
21 def artifact_builds(value):
22     if value:
23         return True
25 set_config('MOZ_ARTIFACT_BUILDS', artifact_builds)
27 imply_option('--enable-artifact-build-symbols',
28              depends(artifact_builds)(lambda v: False if v is None else None),
29              reason='--disable-artifact-builds')
31 option('--enable-artifact-build-symbols', nargs='?', choices=('full',),
32        help='Download symbols when artifact builds are enabled.')
34 @depends('--enable-artifact-build-symbols', 'MOZ_AUTOMATION', target)
35 def enable_artifact_build_symbols(value, automation, target):
36     if len(value):
37         return value[0]
38     if bool(value):
39         if target.os == 'Android' and not automation:
40             return 'full'
41         return True
42     return None
44 set_config('MOZ_ARTIFACT_BUILD_SYMBOLS',
45            enable_artifact_build_symbols)
47 @depends('--enable-artifact-builds')
48 def imply_disable_compile_environment(value):
49     if value:
50         return False
52 option(env='MOZ_COPY_PDBS',
53     help='For builds that do not support symbols in the normal fashion,'
54          ' generate and copy them into the resulting build archive.')
56 set_config('MOZ_COPY_PDBS', depends_if('MOZ_COPY_PDBS')(lambda _: True))
58 imply_option('--enable-compile-environment', imply_disable_compile_environment)
60 option('--disable-compile-environment',
61        help='Disable compiler/library checks')
63 @depends('--disable-compile-environment')
64 def compile_environment(compile_env):
65     if compile_env:
66         return True
68 set_config('COMPILE_ENVIRONMENT', compile_environment)
69 add_old_configure_assignment('COMPILE_ENVIRONMENT', compile_environment)
71 js_option('--disable-tests',
72           help='Do not build test libraries & programs')
74 @depends('--disable-tests')
75 def enable_tests(value):
76     if value:
77         return True
79 set_config('ENABLE_TESTS', enable_tests)
80 set_define('ENABLE_TESTS', enable_tests)
82 @depends(enable_tests)
83 def gtest_has_rtti(value):
84     if value:
85         return '0'
87 set_define('GTEST_HAS_RTTI', gtest_has_rtti)
89 @depends(target, enable_tests)
90 def linux_gtest_defines(target, enable_tests):
91     if enable_tests and target.os == 'Android':
92         return namespace(os_linux_android=True,
93                          use_own_tr1_tuple=True,
94                          has_clone='0')
96 set_define('GTEST_OS_LINUX_ANDROID',
97            linux_gtest_defines.os_linux_android)
98 set_define('GTEST_USE_OWN_TR1_TUPLE',
99            linux_gtest_defines.use_own_tr1_tuple)
100 set_define('GTEST_HAS_CLONE',
101            linux_gtest_defines.has_clone)
103 js_option('--enable-debug',
104           nargs='?',
105           help='Enable building with developer debug info '
106                '(using the given compiler flags).')
108 @depends('--enable-debug')
109 def moz_debug(debug):
110     if debug:
111         return bool(debug)
113 set_config('MOZ_DEBUG', moz_debug)
114 set_define('MOZ_DEBUG', moz_debug)
115 # Override any value MOZ_DEBUG may have from the environment when passing it
116 # down to old-configure.
117 add_old_configure_assignment('MOZ_DEBUG',
118                              depends('--enable-debug')(lambda x: bool(x)))
120 js_option('--with-debug-label', nargs='+',
121           help='Debug DEBUG_<value> for each comma-separated value given')
123 @depends(moz_debug, '--with-debug-label')
124 def debug_defines(debug, labels):
125     if debug:
126         return ['DEBUG'] + ['DEBUG_%s' % label for label in labels]
127     return ['NDEBUG', 'TRIMMED']
129 set_config('MOZ_DEBUG_DEFINES', debug_defines)
131 js_option('--enable-rust-debug',
132           default=depends(when='--enable-debug')(lambda: True),
133           help='{Build|Do not build} Rust code with debug assertions turned '
134                'on.')
136 @depends(when='--enable-rust-debug')
137 def debug_rust():
138     return True
140 set_config('MOZ_DEBUG_RUST', debug_rust)
141 set_define('MOZ_DEBUG_RUST', debug_rust)
143 js_option(env='MOZ_PGO', help='Build with profile guided optimizations')
145 set_config('MOZ_PGO', depends('MOZ_PGO')(lambda x: bool(x)))
148 wine = check_prog(
149     'WINE', ['wine64', 'wine'], allow_missing=True,
150     when=depends(target, host)(
151         lambda t, h: t.kernel == 'WINNT' and h.kernel == 'Linux'))
154 include('build/moz.configure/toolchain.configure',
155         when='--enable-compile-environment')
157 include('build/moz.configure/pkg.configure')
158 # Make this assignment here rather than in pkg.configure to avoid
159 # requiring this file in unit tests.
160 add_old_configure_assignment('PKG_CONFIG', pkg_config)
162 include('build/moz.configure/memory.configure',
163         when='--enable-compile-environment')
164 include('build/moz.configure/headers.configure',
165         when='--enable-compile-environment')
166 include('build/moz.configure/warnings.configure',
167         when='--enable-compile-environment')
168 include('build/moz.configure/lto-pgo.configure',
169         when='--enable-compile-environment')
170 include('build/moz.configure/flags.configure',
171         when='--enable-compile-environment')
172 # rust.configure is included by js/moz.configure.
174 js_option('--enable-valgrind',
175           help='Enable Valgrind integration hooks')
177 valgrind_h = check_header('valgrind/valgrind.h', when='--enable-valgrind')
179 @depends('--enable-valgrind', valgrind_h)
180 def check_valgrind(valgrind, valgrind_h):
181     if valgrind:
182         if not valgrind_h:
183             die('--enable-valgrind specified but Valgrind is not installed')
184         return True
186 set_define('MOZ_VALGRIND', check_valgrind)
187 set_config('MOZ_VALGRIND', check_valgrind)
189 @depends(target, host)
190 def is_openbsd(target, host):
191     return target.kernel == 'OpenBSD' or host.kernel == 'OpenBSD'
193 option(env='SO_VERSION', nargs=1, default='1.0', when=is_openbsd,
194        help='Shared library version for OpenBSD systems')
196 @depends('SO_VERSION', when=is_openbsd)
197 def so_version(value):
198     return value
200 @template
201 def library_name_info_template(host_or_target):
202     assert host_or_target in {host, target}
203     compiler = {
204         host: host_c_compiler,
205         target: c_compiler,
206     }[host_or_target]
208     @depends(host_or_target, compiler, so_version)
209     def library_name_info_impl(host_or_target, compiler, so_version):
210         if host_or_target.kernel == 'WINNT':
211             # There aren't artifacts for mingw builds, so it's OK that the
212             # results are inaccurate in that case.
213             if compiler and compiler.type != 'clang-cl':
214                 return namespace(
215                     dll=namespace(prefix='', suffix='.dll'),
216                     lib=namespace(prefix='lib', suffix='a'),
217                     import_lib=namespace(prefix='lib', suffix='a'),
218                     rust_lib=namespace(prefix='', suffix='lib'),
219                     obj=namespace(prefix='', suffix='o'),
220                 )
222             return namespace(
223                 dll=namespace(prefix='', suffix='.dll'),
224                 lib=namespace(prefix='', suffix='lib'),
225                 import_lib=namespace(prefix='', suffix='lib'),
226                 rust_lib=namespace(prefix='', suffix='lib'),
227                 obj=namespace(prefix='', suffix='obj'),
228             )
230         elif host_or_target.kernel == 'Darwin':
231             return namespace(
232                 dll=namespace(prefix='lib', suffix='.dylib'),
233                 lib=namespace(prefix='lib', suffix='a'),
234                 import_lib=namespace(prefix=None, suffix=''),
235                 rust_lib=namespace(prefix='lib', suffix='a'),
236                 obj=namespace(prefix='', suffix='o'),
237             )
238         elif so_version:
239             so = '.so.%s' % so_version
240         else:
241             so = '.so'
243         return namespace(
244             dll=namespace(prefix='lib', suffix=so),
245             lib=namespace(prefix='lib', suffix='a'),
246             import_lib=namespace(prefix=None, suffix=''),
247             rust_lib=namespace(prefix='lib', suffix='a'),
248             obj=namespace(prefix='', suffix='o'),
249         )
251     return library_name_info_impl
253 host_library_name_info = library_name_info_template(host)
254 library_name_info = library_name_info_template(target)
256 set_config('DLL_PREFIX', library_name_info.dll.prefix)
257 set_config('DLL_SUFFIX', library_name_info.dll.suffix)
258 set_config('HOST_DLL_PREFIX', host_library_name_info.dll.prefix)
259 set_config('HOST_DLL_SUFFIX', host_library_name_info.dll.suffix)
260 set_config('LIB_PREFIX', library_name_info.lib.prefix)
261 set_config('LIB_SUFFIX', library_name_info.lib.suffix)
262 set_config('RUST_LIB_PREFIX', library_name_info.rust_lib.prefix)
263 set_config('RUST_LIB_SUFFIX', library_name_info.rust_lib.suffix)
264 set_config('OBJ_SUFFIX', library_name_info.obj.suffix)
265 # Lots of compilation tests depend on this variable being present.
266 add_old_configure_assignment('OBJ_SUFFIX', library_name_info.obj.suffix)
267 set_config('IMPORT_LIB_SUFFIX', library_name_info.import_lib.suffix)
268 set_define('MOZ_DLL_PREFIX', depends(library_name_info.dll.prefix)(lambda s: '"%s"' % s))
269 set_define('MOZ_DLL_SUFFIX', depends(library_name_info.dll.suffix)(lambda s: '"%s"' % s))
270 set_config('WASM_OBJ_SUFFIX', 'wasm')
272 # Make `profiling` available to this file even when js/moz.configure
273 # doesn't end up included.
274 profiling = dependable(False)
275 # Same for js_standalone
276 js_standalone = dependable(False)
277 # Same for fold_libs
278 fold_libs = dependable(False)
280 include(include_project_configure)
282 @depends('--help')
283 @imports(_from='mozbuild.backend', _import='backends')
284 def build_backends_choices(_):
285     return tuple(backends)
288 @deprecated_option('--enable-build-backend', nargs='+',
289                    choices=build_backends_choices)
290 def build_backend(backends):
291     if backends:
292         return tuple('+%s' % b for b in backends)
294 imply_option('--build-backends', build_backend)
297 @depends('--enable-artifact-builds', '--disable-compile-environment',
298          '--enable-build-backend', '--enable-project', '--enable-application',
299          '--help')
300 @imports('sys')
301 def build_backend_defaults(artifact_builds, compile_environment, requested_backends,
302                            project, application, _):
303     if application:
304         project = application[0]
305     elif project:
306         project = project[0]
308     if 'Tup' in requested_backends:
309         # As a special case, if Tup was requested, do not combine it with any
310         # Make based backend by default.
311         all_backends = []
312     elif artifact_builds:
313         all_backends = ['FasterMake+RecursiveMake']
314     else:
315         all_backends = ['RecursiveMake', 'FasterMake']
316     # Normally, we'd use target.os == 'WINNT', but a dependency on target
317     # would require target to depend on --help, as well as host and shell,
318     # and this is not a can of worms we can open at the moment.
319     if sys.platform == 'win32' and compile_environment and project != 'mobile/android':
320         all_backends.append('VisualStudio')
321     return tuple(all_backends) or None
323 option('--build-backends', nargs='+', default=build_backend_defaults,
324        choices=build_backends_choices, help='Build backends to generate')
326 @depends('--build-backends')
327 def build_backends(backends):
328     return backends
330 set_config('BUILD_BACKENDS', build_backends)
333 @depends(check_build_environment, build_backends)
334 @imports('glob')
335 def check_objdir_backend_reuse(build_env, backends):
336     # "Make based" might be RecursiveMake or a hybrid backend, so "Make" is
337     # intentionally vague for use with the substring match below.
338     incompatible_backends = (
339         ('Tup', 'Make'),
340         ('Make', 'Tup')
341     )
342     for backend_file in glob.iglob(os.path.join(build_env.topobjdir,
343                                                 'backend.*Backend')):
344         for prev, curr in incompatible_backends:
345             if prev in backend_file and any(curr in b for b in backends):
346                 die("The active objdir, %s, was previously "
347                     "used to build with a %s based backend. "
348                     "Change objdirs (by setting MOZ_OBJDIR in "
349                     "your mozconfig) or clobber to continue.\n",
350                     build_env.topobjdir, prev)
353 option('--disable-gtest-in-build',
354        help='Force disable building the gtest libxul during the build.',
355        when='--enable-compile-environment')
357 # Determine whether to build the gtest xul. This happens in automation
358 # on Android and Desktop platforms with the exception of:
359 #  - Windows PGO, where linking xul-gtest.dll takes too long;
360 #  - Android other than x86_64, where gtest is not required.
361 @depends('MOZ_PGO', build_project, target, 'MOZ_AUTOMATION', '--disable-gtest-in-build',
362          enable_tests, when='--enable-compile-environment')
363 def build_gtest(pgo, build_project, target, automation, enabled, enable_tests):
364     if not enable_tests or not enabled:
365         return None
366     if (automation and build_project in ('browser', 'comm/mail', 'mobile/android') and
367         not ((pgo and target.os == 'WINNT') or (target.os == 'Android' and target.cpu != 'x86_64'))):
368         return True
370 set_config('LINK_GTEST_DURING_COMPILE', build_gtest)
372 # Localization
373 # ==============================================================
374 option('--enable-ui-locale', default='en-US',
375        help='Select the user interface locale (default: en-US)')
377 set_config('MOZ_UI_LOCALE', depends('--enable-ui-locale')(lambda x: x))
379 # clang-plugin location
380 # ==============================================================
381 @depends(host_library_name_info, check_build_environment,
382          when='--enable-clang-plugin')
383 def clang_plugin_path(library_name_info, build_env):
384     topobjdir = build_env.topobjdir
385     if topobjdir.endswith('/js/src'):
386         topobjdir = topobjdir[:-7]
387     return os.path.abspath(
388         os.path.join(topobjdir, 'build', 'clang-plugin',
389                      '%sclang-plugin%s' % (library_name_info.dll.prefix,
390                                            library_name_info.dll.suffix))
391     )
393 add_old_configure_assignment('CLANG_PLUGIN', clang_plugin_path)
396 # Awk detection
397 # ==============================================================
398 awk = check_prog('AWK', ('gawk', 'mawk', 'nawk', 'awk'))
400 # Until the AWK variable is not necessary in old-configure
401 @depends(awk)
402 def awk_for_old_configure(value):
403     return value
405 add_old_configure_assignment('AWK', awk_for_old_configure)
408 # Perl detection
409 # ==============================================================
410 perl = check_prog('PERL', ('perl5', 'perl'))
412 # Until the PERL variable is not necessary in old-configure
413 @depends(perl)
414 def perl_for_old_configure(value):
415     return value
417 add_old_configure_assignment('PERL', perl_for_old_configure)
419 @template
420 def perl_version_check(min_version):
421     @depends(perl)
422     @checking('for minimum required perl version >= %s' % min_version)
423     def get_perl_version(perl):
424         return Version(check_cmd_output(
425             perl, '-e', 'print $]',
426             onerror=lambda: die('Failed to get perl version.')
427         ))
429     @depends(get_perl_version)
430     def check_perl_version(version):
431         if version < min_version:
432             die('Perl %s or higher is required.', min_version)
434     @depends(perl)
435     @checking('for full perl installation')
436     @imports('subprocess')
437     def has_full_perl_installation(perl):
438         ret = subprocess.call(
439             [perl, '-e', 'use Config; exit(!-d $Config{archlib})'])
440         return ret == 0
442     @depends(has_full_perl_installation)
443     def require_full_perl_installation(has_full_perl_installation):
444         if not has_full_perl_installation:
445             die('Cannot find Config.pm or $Config{archlib}. '
446                 'A full perl installation is required.')
448 perl_version_check('5.006')
451 # GNU make detection
452 # ==============================================================
453 option(env='MAKE', nargs=1, help='Path to GNU make')
455 @depends('MAKE', host)
456 def possible_makes(make, host):
457     candidates = []
458     if host.kernel == 'WINNT':
459         candidates.append('mingw32-make')
460     if make:
461         candidates.append(make[0])
462     if host.kernel == 'WINNT':
463         candidates.extend(('make', 'gmake'))
464     else:
465         candidates.extend(('gmake', 'make'))
466     return candidates
468 check_prog('GMAKE', possible_makes)
470 # watchman detection
471 # ==============================================================
473 option(env='WATCHMAN', nargs=1, help='Path to the watchman program')
475 @depends(host, 'WATCHMAN')
476 @checking('for watchman', callback=lambda w: w.path if w else 'not found')
477 def watchman(host, prog):
478     # On Windows, `watchman` is only supported on 64-bit hosts.
479     if host.os == 'WINNT' and host.cpu != 'x86_64':
480         return
482     if not prog:
483         prog = find_program('watchman')
485     if not prog:
486         return
488     # `watchman version` will talk to the Watchman daemon service.
489     # This can hang due to permissions problems. e.g.
490     # https://github.com/facebook/watchman/issues/376. So use
491     # `watchman --version` to prevent a class of failures.
492     out = check_cmd_output(prog, '--version', onerror=lambda: None)
493     if out is None:
494         return
496     return namespace(path=prog, version=Version(out.strip()))
498 @depends_if(watchman)
499 @checking('for watchman version')
500 def watchman_version(w):
501     return w.version
503 set_config('WATCHMAN', watchman.path)
505 @depends_all(hg_version, hg_config, watchman)
506 @checking('for watchman Mercurial integration')
507 @imports('os')
508 def watchman_hg(hg_version, hg_config, watchman):
509     if hg_version < Version('3.8'):
510         return 'no (Mercurial 3.8+ required)'
512     ext_enabled = False
513     mode_disabled = False
515     for k in ('extensions.fsmonitor', 'extensions.hgext.fsmonitor'):
516         if k in hg_config and hg_config[k] != '!':
517             ext_enabled = True
519     mode_disabled = hg_config.get('fsmonitor.mode') == 'off'
521     if not ext_enabled:
522         return 'no (fsmonitor extension not enabled)'
523     if mode_disabled:
524         return 'no (fsmonitor.mode=off disables fsmonitor)'
526     return True
528 # Miscellaneous programs
529 # ==============================================================
530 check_prog('XARGS', ('xargs',))
532 @depends(target)
533 def extra_programs(target):
534     if target.kernel == 'Darwin':
535         return namespace(
536             DSYMUTIL=('dsymutil', 'llvm-dsymutil'),
537             MKFSHFS=('newfs_hfs', 'mkfs.hfsplus'),
538             HFS_TOOL=('hfsplus',)
539         )
540     if target.os == 'GNU' and target.kernel == 'Linux':
541         return namespace(RPMBUILD=('rpmbuild',))
543 check_prog('DSYMUTIL', extra_programs.DSYMUTIL,
544            allow_missing=True)
545 check_prog('MKFSHFS', extra_programs.MKFSHFS,
546            allow_missing=True)
547 check_prog('HFS_TOOL', extra_programs.HFS_TOOL,
548            allow_missing=True)
549 check_prog('RPMBUILD', extra_programs.RPMBUILD,
550            allow_missing=True)
553 @depends(target)
554 @imports('os')
555 def makensis_progs(target):
556     if target.kernel != 'WINNT':
557         return
559     candidates = [
560         'makensis-3.01',
561         'makensis-3.0b3',
562         'makensis-3.0b1',
563         'makensis',
564     ]
566     # Look for nsis installed by msys environment. But only the 32-bit version.
567     # We use an absolute path and insert as the first entry so it is preferred
568     # over a 64-bit exe that may be in PATH.
569     if 'MSYSTEM_PREFIX' in os.environ:
570         prefix = os.path.dirname(os.environ['MSYSTEM_PREFIX'])
571         candidates.insert(0, os.path.join(prefix, 'mingw32', 'bin', 'makensis.exe'))
573     return tuple(candidates)
575 nsis = check_prog('MAKENSISU', makensis_progs, allow_missing=True)
577 # Make sure the version of makensis is up to date.
578 @depends(nsis, wine)
579 @checking('for NSIS version')
580 @imports('re')
581 def nsis_version(nsis, wine):
582     if not nsis:
583         return None
584     nsis_min_version = '3.0b1'
585     onerror = lambda: die('Failed to get nsis version.')
586     if wine and nsis.lower().endswith('.exe'):
587         out = check_cmd_output(wine, nsis, '-version', onerror=onerror)
588     else:
589         out = check_cmd_output(nsis, '-version', onerror=onerror)
591     m = re.search(r'(?<=v)[0-9]+\.[0-9]+((a|b|rc)[0-9]+)?', out)
593     if not m:
594         raise FatalCheckError('Unknown version of makensis')
595     ver = Version(m.group(0))
597     # Versions comparisons don't quite work well with beta versions, so ensure
598     # it works for the non-beta version.
599     if ver < nsis_min_version and (ver >= '3.0a' or ver < '3'):
600         raise FatalCheckError('To build the installer you must have NSIS'
601                               ' version %s or greater in your path'
602                               % nsis_min_version)
604     return ver
606 # And that makensis is 32-bit (but only on Windows).
607 @depends_if(nsis, when=depends(host)(lambda h: h.kernel == 'WINNT'))
608 @checking('for 32-bit NSIS')
609 def nsis_binary_type(nsis):
610     bin_type = windows_binary_type(nsis)
611     if bin_type != 'win32':
612         raise FatalCheckError('%s is not a 32-bit Windows application' % nsis)
614     return 'yes'
616 # And any flags we have to give to makensis
617 @depends(host)
618 def nsis_flags(host):
619     if host.kernel != 'WINNT':
620         return '-nocd'
621     return ''
623 set_config('MAKENSISU_FLAGS', nsis_flags)
625 check_prog('7Z', ('7z', '7za'), allow_missing=True, when=target_is_windows)
626 check_prog('UPX', ('upx',), allow_missing=True, when=target_is_windows)
629 @depends(host_c_compiler, c_compiler, bindgen_config_paths)
630 def llvm_objdump(host_c_compiler, c_compiler, bindgen_config_paths):
631     clang = None
632     for compiler in (host_c_compiler, c_compiler):
633         if compiler and compiler.type == 'clang':
634             clang = compiler.compiler
635             break
636         elif compiler and compiler.type == 'clang-cl':
637             clang = os.path.join(os.path.dirname(compiler.compiler), 'clang')
638             break
640     if not clang and bindgen_config_paths:
641         clang = bindgen_config_paths.clang_path
642     llvm_objdump = 'llvm-objdump'
643     if clang:
644         out = check_cmd_output(clang, '--print-prog-name=llvm-objdump',
645                                onerror=lambda: None)
646         if out:
647             llvm_objdump = out.rstrip()
648     return (llvm_objdump,)
651 llvm_objdump = check_prog('LLVM_OBJDUMP', llvm_objdump, what='llvm-objdump',
652                           when='--enable-compile-environment',
653                           paths=toolchain_search_path)
655 add_old_configure_assignment('LLVM_OBJDUMP', llvm_objdump)
658 js_option('--enable-dtrace', help='Build with dtrace support')
660 dtrace = check_header('sys/sdt.h', when='--enable-dtrace',
661                       onerror=lambda: die('dtrace enabled but sys/sdt.h not found'))
663 set_config('HAVE_DTRACE', True, when=dtrace)
664 set_define('INCLUDE_MOZILLA_DTRACE', True, when=dtrace)
665 add_old_configure_assignment('enable_dtrace', 'yes', when=dtrace)
668 js_option('--disable-icf', help='Disable Identical Code Folding')
670 add_old_configure_assignment(
671     'MOZ_DISABLE_ICF', '1', when=depends('--enable-icf')(lambda x: not x))
674 @depends(compile_environment, target)
675 def may_strip(compile_environment, target):
676     return compile_environment and target.kernel != 'WINNT'
678 js_option('--enable-strip', when=may_strip, help='Enable stripping of libs & executables')
680 set_config('ENABLE_STRIP', True, when='--enable-strip')
682 js_option('--disable-install-strip', when=may_strip,
683           help='Enable stripping of libs & executables when packaging')
685 # The nested depends is because depending on --enable-install-strip needs the
686 # `when=may_strip`, but we also need to test when may_strip is False.
687 @depends(depends('--enable-install-strip', when=may_strip)(lambda x: x), may_strip)
688 def pkg_skip_strip(install_strip, may_strip):
689     return not install_strip or not may_strip
691 set_config('PKG_SKIP_STRIP', True, when=pkg_skip_strip)
694 @depends('--enable-strip', '--enable-install-strip', when=may_strip)
695 def strip(strip, install_strip):
696     return strip or install_strip
698 js_option(env='STRIP_FLAGS', nargs=1, when=strip, help='Flags for the strip command')
700 @depends('STRIP_FLAGS', profiling, target, when=strip)
701 def strip_flags(flags, profiling, target):
702     if flags:
703         return flags[0].split()
704     if profiling:
705         # Only strip debug info and symbols when profiling is enabled, keeping
706         # local symbols.
707         if target.kernel == 'Darwin':
708             return ['-S']
709         else:
710             return ['--strip-debug']
711     # Otherwise strip everything we can, which happens without flags on non-Darwin.
712     # On Darwin, it tries to strip things it can't, so we need to limit its scope.
713     elif target.kernel == 'Darwin':
714         return ['-x', '-S']
716 set_config('STRIP_FLAGS', strip_flags)
719 @depends(js_standalone, target)
720 def system_zlib_default(js_standalone, target):
721     return js_standalone and target.kernel != 'WINNT'
723 js_option('--with-system-zlib', nargs='?', default=system_zlib_default,
724           help='{Use|Do not use} system libz')
726 @depends('--with-system-zlib')
727 def deprecated_system_zlib_path(value):
728     if len(value) == 1:
729         die('--with-system-zlib=PATH is not supported anymore. Please use '
730             '--with-system-zlib and set any necessary pkg-config environment variable.')
732 pkg_check_modules('MOZ_ZLIB', 'zlib >= 1.2.3', when='--with-system-zlib')
734 set_config('MOZ_SYSTEM_ZLIB', True, when='--with-system-zlib')
735 add_old_configure_assignment('MOZ_SYSTEM_ZLIB', True, when='--with-system-zlib')
738 # Please do not add configure checks from here on.
740 # Fallthrough to autoconf-based configure
741 include('build/moz.configure/old.configure')
743 # JS Subconfigure.
744 include('js/sub.configure', when=compile_environment & toolkit)
747 @depends(check_build_environment, build_project)
748 @imports('__sandbox__')
749 @imports('glob')
750 @imports(_from='os.path', _import='exists')
751 def config_status_deps(build_env, build_project):
753     topsrcdir = build_env.topsrcdir
754     topobjdir = build_env.topobjdir
756     if not topobjdir.endswith('js/src'):
757         extra_deps = [os.path.join(topobjdir, '.mozconfig.json')]
758     else:
759         # mozconfig changes may impact js configure.
760         extra_deps = [os.path.join(topobjdir[:-7], '.mozconfig.json')]
762     confvars = os.path.join(topsrcdir, build_project, 'confvars.sh')
763     if exists(confvars):
764         extra_deps.append(confvars)
766     return list(__sandbox__._all_paths) + extra_deps + [
767         os.path.join(topsrcdir, 'CLOBBER'),
768         os.path.join(topsrcdir, 'configure'),
769         os.path.join(topsrcdir, 'js', 'src', 'configure'),
770         os.path.join(topsrcdir, 'configure.in'),
771         os.path.join(topsrcdir, 'js', 'src', 'configure.in'),
772         os.path.join(topsrcdir, 'nsprpub', 'configure'),
773         os.path.join(topsrcdir, 'config', 'milestone.txt'),
774         os.path.join(topsrcdir, 'browser', 'config', 'version.txt'),
775         os.path.join(topsrcdir, 'browser', 'config', 'version_display.txt'),
776         os.path.join(topsrcdir, 'build', 'virtualenv_packages.txt'),
777         os.path.join(topsrcdir, 'python', 'mozbuild', 'mozbuild', 'virtualenv.py'),
778         os.path.join(topsrcdir, 'testing', 'mozbase', 'packages.txt'),
779         os.path.join(topsrcdir, 'aclocal.m4'),
780         os.path.join(topsrcdir, 'old-configure.in'),
781         os.path.join(topsrcdir, 'js', 'src', 'aclocal.m4'),
782         os.path.join(topsrcdir, 'js', 'src', 'old-configure.in'),
783     ] + glob.glob(os.path.join(topsrcdir, 'build', 'autoconf', '*.m4'))
785 set_config('CONFIG_STATUS_DEPS', config_status_deps)
786 # Please do not add anything after setting config_dep_paths.