Bug 1669129 - [devtools] Enable devtools.overflow.debugging.enabled. r=jdescottes
[gecko.git] / moz.configure
blobd9339664b2c0129fd5f3630163bab648771c4a88
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 != 'WINNT'))
152 check_prog('WGET', ('wget',), allow_missing=True)
155 include('build/moz.configure/toolchain.configure',
156         when='--enable-compile-environment')
158 include('build/moz.configure/pkg.configure')
159 # Make this assignment here rather than in pkg.configure to avoid
160 # requiring this file in unit tests.
161 add_old_configure_assignment('PKG_CONFIG', pkg_config)
163 include('build/moz.configure/memory.configure',
164         when='--enable-compile-environment')
165 include('build/moz.configure/headers.configure',
166         when='--enable-compile-environment')
167 include('build/moz.configure/warnings.configure',
168         when='--enable-compile-environment')
169 include('build/moz.configure/lto-pgo.configure',
170         when='--enable-compile-environment')
171 include('build/moz.configure/flags.configure',
172         when='--enable-compile-environment')
173 # rust.configure is included by js/moz.configure.
175 js_option('--enable-valgrind',
176           help='Enable Valgrind integration hooks')
178 valgrind_h = check_header('valgrind/valgrind.h', when='--enable-valgrind')
180 @depends('--enable-valgrind', valgrind_h)
181 def check_valgrind(valgrind, valgrind_h):
182     if valgrind:
183         if not valgrind_h:
184             die('--enable-valgrind specified but Valgrind is not installed')
185         return True
187 set_define('MOZ_VALGRIND', check_valgrind)
188 set_config('MOZ_VALGRIND', check_valgrind)
190 @depends(target, host)
191 def is_openbsd(target, host):
192     return target.kernel == 'OpenBSD' or host.kernel == 'OpenBSD'
194 option(env='SO_VERSION', nargs=1, default='1.0', when=is_openbsd,
195        help='Shared library version for OpenBSD systems')
197 @depends('SO_VERSION', when=is_openbsd)
198 def so_version(value):
199     return value
201 @template
202 def library_name_info_template(host_or_target):
203     assert host_or_target in {host, target}
204     compiler = {
205         host: host_c_compiler,
206         target: c_compiler,
207     }[host_or_target]
209     @depends(host_or_target, compiler, so_version)
210     def library_name_info_impl(host_or_target, compiler, so_version):
211         if host_or_target.kernel == 'WINNT':
212             # There aren't artifacts for mingw builds, so it's OK that the
213             # results are inaccurate in that case.
214             if compiler and compiler.type != 'clang-cl':
215                 return namespace(
216                     dll=namespace(prefix='', suffix='.dll'),
217                     lib=namespace(prefix='lib', suffix='a'),
218                     import_lib=namespace(prefix='lib', suffix='a'),
219                     rust_lib=namespace(prefix='', suffix='lib'),
220                     obj=namespace(prefix='', suffix='o'),
221                 )
223             return namespace(
224                 dll=namespace(prefix='', suffix='.dll'),
225                 lib=namespace(prefix='', suffix='lib'),
226                 import_lib=namespace(prefix='', suffix='lib'),
227                 rust_lib=namespace(prefix='', suffix='lib'),
228                 obj=namespace(prefix='', suffix='obj'),
229             )
231         elif host_or_target.kernel == 'Darwin':
232             return namespace(
233                 dll=namespace(prefix='lib', suffix='.dylib'),
234                 lib=namespace(prefix='lib', suffix='a'),
235                 import_lib=namespace(prefix=None, suffix=''),
236                 rust_lib=namespace(prefix='lib', suffix='a'),
237                 obj=namespace(prefix='', suffix='o'),
238             )
239         elif so_version:
240             so = '.so.%s' % so_version
241         else:
242             so = '.so'
244         return namespace(
245             dll=namespace(prefix='lib', suffix=so),
246             lib=namespace(prefix='lib', suffix='a'),
247             import_lib=namespace(prefix=None, suffix=''),
248             rust_lib=namespace(prefix='lib', suffix='a'),
249             obj=namespace(prefix='', suffix='o'),
250         )
252     return library_name_info_impl
254 host_library_name_info = library_name_info_template(host)
255 library_name_info = library_name_info_template(target)
257 set_config('DLL_PREFIX', library_name_info.dll.prefix)
258 set_config('DLL_SUFFIX', library_name_info.dll.suffix)
259 set_config('HOST_DLL_PREFIX', host_library_name_info.dll.prefix)
260 set_config('HOST_DLL_SUFFIX', host_library_name_info.dll.suffix)
261 set_config('LIB_PREFIX', library_name_info.lib.prefix)
262 set_config('LIB_SUFFIX', library_name_info.lib.suffix)
263 set_config('RUST_LIB_PREFIX', library_name_info.rust_lib.prefix)
264 set_config('RUST_LIB_SUFFIX', library_name_info.rust_lib.suffix)
265 set_config('OBJ_SUFFIX', library_name_info.obj.suffix)
266 # Lots of compilation tests depend on this variable being present.
267 add_old_configure_assignment('OBJ_SUFFIX', library_name_info.obj.suffix)
268 set_config('IMPORT_LIB_SUFFIX', library_name_info.import_lib.suffix)
269 set_define('MOZ_DLL_PREFIX', depends(library_name_info.dll.prefix)(lambda s: '"%s"' % s))
270 set_define('MOZ_DLL_SUFFIX', depends(library_name_info.dll.suffix)(lambda s: '"%s"' % s))
271 set_config('WASM_OBJ_SUFFIX', 'wasm')
273 # Make `profiling` available to this file even when js/moz.configure
274 # doesn't end up included.
275 profiling = dependable(False)
276 # Same for js_standalone
277 js_standalone = dependable(False)
278 # Same for fold_libs
279 fold_libs = dependable(False)
281 include(include_project_configure)
283 @depends('--help')
284 @imports(_from='mozbuild.backend', _import='backends')
285 def build_backends_choices(_):
286     return tuple(backends)
289 @deprecated_option('--enable-build-backend', nargs='+',
290                    choices=build_backends_choices)
291 def build_backend(backends):
292     if backends:
293         return tuple('+%s' % b for b in backends)
295 imply_option('--build-backends', build_backend)
298 @depends('--enable-artifact-builds', '--disable-compile-environment',
299          '--enable-build-backend', '--enable-project', '--enable-application',
300          '--help')
301 @imports('sys')
302 def build_backend_defaults(artifact_builds, compile_environment, requested_backends,
303                            project, application, _):
304     if application:
305         project = application[0]
306     elif project:
307         project = project[0]
309     if 'Tup' in requested_backends:
310         # As a special case, if Tup was requested, do not combine it with any
311         # Make based backend by default.
312         all_backends = []
313     elif artifact_builds:
314         all_backends = ['FasterMake+RecursiveMake']
315     else:
316         all_backends = ['RecursiveMake', 'FasterMake']
317     # Normally, we'd use target.os == 'WINNT', but a dependency on target
318     # would require target to depend on --help, as well as host and shell,
319     # and this is not a can of worms we can open at the moment.
320     if sys.platform == 'win32' and compile_environment and project != 'mobile/android':
321         all_backends.append('VisualStudio')
322     return tuple(all_backends) or None
324 option('--build-backends', nargs='+', default=build_backend_defaults,
325        choices=build_backends_choices, help='Build backends to generate')
327 @depends('--build-backends')
328 def build_backends(backends):
329     return backends
331 set_config('BUILD_BACKENDS', build_backends)
334 @depends(check_build_environment, build_backends)
335 @imports('glob')
336 def check_objdir_backend_reuse(build_env, backends):
337     # "Make based" might be RecursiveMake or a hybrid backend, so "Make" is
338     # intentionally vague for use with the substring match below.
339     incompatible_backends = (
340         ('Tup', 'Make'),
341         ('Make', 'Tup')
342     )
343     for backend_file in glob.iglob(os.path.join(build_env.topobjdir,
344                                                 'backend.*Backend')):
345         for prev, curr in incompatible_backends:
346             if prev in backend_file and any(curr in b for b in backends):
347                 die("The active objdir, %s, was previously "
348                     "used to build with a %s based backend. "
349                     "Change objdirs (by setting MOZ_OBJDIR in "
350                     "your mozconfig) or clobber to continue.\n",
351                     build_env.topobjdir, prev)
354 option('--disable-gtest-in-build',
355        help='Force disable building the gtest libxul during the build.',
356        when='--enable-compile-environment')
358 # Determine whether to build the gtest xul. This happens in automation
359 # on Android and Desktop platforms with the exception of:
360 #  - Windows PGO, where linking xul-gtest.dll takes too long;
361 #  - Android other than x86_64, where gtest is not required.
362 @depends('MOZ_PGO', build_project, target, 'MOZ_AUTOMATION', '--disable-gtest-in-build',
363          enable_tests, when='--enable-compile-environment')
364 def build_gtest(pgo, build_project, target, automation, enabled, enable_tests):
365     if not enable_tests or not enabled:
366         return None
367     if (automation and build_project in ('browser', 'comm/mail', 'mobile/android') and
368         not ((pgo and target.os == 'WINNT') or (target.os == 'Android' and target.cpu != 'x86_64'))):
369         return True
371 set_config('LINK_GTEST_DURING_COMPILE', build_gtest)
373 # Localization
374 # ==============================================================
375 option('--enable-ui-locale', default='en-US',
376        help='Select the user interface locale (default: en-US)')
378 set_config('MOZ_UI_LOCALE', depends('--enable-ui-locale')(lambda x: x))
380 # clang-plugin location
381 # ==============================================================
382 @depends(host_library_name_info, check_build_environment,
383          when='--enable-clang-plugin')
384 def clang_plugin_path(library_name_info, build_env):
385     topobjdir = build_env.topobjdir
386     if topobjdir.endswith('/js/src'):
387         topobjdir = topobjdir[:-7]
388     return os.path.abspath(
389         os.path.join(topobjdir, 'build', 'clang-plugin',
390                      '%sclang-plugin%s' % (library_name_info.dll.prefix,
391                                            library_name_info.dll.suffix))
392     )
394 add_old_configure_assignment('CLANG_PLUGIN', clang_plugin_path)
397 # Awk detection
398 # ==============================================================
399 awk = check_prog('AWK', ('gawk', 'mawk', 'nawk', 'awk'))
401 # Until the AWK variable is not necessary in old-configure
402 @depends(awk)
403 def awk_for_old_configure(value):
404     return value
406 add_old_configure_assignment('AWK', awk_for_old_configure)
409 # Perl detection
410 # ==============================================================
411 perl = check_prog('PERL', ('perl5', 'perl'))
413 # Until the PERL variable is not necessary in old-configure
414 @depends(perl)
415 def perl_for_old_configure(value):
416     return value
418 add_old_configure_assignment('PERL', perl_for_old_configure)
420 @template
421 def perl_version_check(min_version):
422     @depends(perl)
423     @checking('for minimum required perl version >= %s' % min_version)
424     def get_perl_version(perl):
425         return Version(check_cmd_output(
426             perl, '-e', 'print $]',
427             onerror=lambda: die('Failed to get perl version.')
428         ))
430     @depends(get_perl_version)
431     def check_perl_version(version):
432         if version < min_version:
433             die('Perl %s or higher is required.', min_version)
435     @depends(perl)
436     @checking('for full perl installation')
437     @imports('subprocess')
438     def has_full_perl_installation(perl):
439         ret = subprocess.call(
440             [perl, '-e', 'use Config; exit(!-d $Config{archlib})'])
441         return ret == 0
443     @depends(has_full_perl_installation)
444     def require_full_perl_installation(has_full_perl_installation):
445         if not has_full_perl_installation:
446             die('Cannot find Config.pm or $Config{archlib}. '
447                 'A full perl installation is required.')
449 perl_version_check('5.006')
452 # GNU make detection
453 # ==============================================================
454 option(env='MAKE', nargs=1, help='Path to GNU make')
456 @depends('MAKE', host)
457 def possible_makes(make, host):
458     candidates = []
459     if host.kernel == 'WINNT':
460         candidates.append('mingw32-make')
461     if make:
462         candidates.append(make[0])
463     if host.kernel == 'WINNT':
464         candidates.extend(('make', 'gmake'))
465     else:
466         candidates.extend(('gmake', 'make'))
467     return candidates
469 check_prog('GMAKE', possible_makes)
471 # watchman detection
472 # ==============================================================
474 option(env='WATCHMAN', nargs=1, help='Path to the watchman program')
476 @depends(host, 'WATCHMAN')
477 @checking('for watchman', callback=lambda w: w.path if w else 'not found')
478 def watchman(host, prog):
479     # On Windows, `watchman` is only supported on 64-bit hosts.
480     if host.os == 'WINNT' and host.cpu != 'x86_64':
481         return
483     if not prog:
484         prog = find_program('watchman')
486     if not prog:
487         return
489     # `watchman version` will talk to the Watchman daemon service.
490     # This can hang due to permissions problems. e.g.
491     # https://github.com/facebook/watchman/issues/376. So use
492     # `watchman --version` to prevent a class of failures.
493     out = check_cmd_output(prog, '--version', onerror=lambda: None)
494     if out is None:
495         return
497     return namespace(path=prog, version=Version(out.strip()))
499 @depends_if(watchman)
500 @checking('for watchman version')
501 def watchman_version(w):
502     return w.version
504 set_config('WATCHMAN', watchman.path)
506 @depends_all(hg_version, hg_config, watchman)
507 @checking('for watchman Mercurial integration')
508 @imports('os')
509 def watchman_hg(hg_version, hg_config, watchman):
510     if hg_version < Version('3.8'):
511         return 'no (Mercurial 3.8+ required)'
513     ext_enabled = False
514     mode_disabled = False
516     for k in ('extensions.fsmonitor', 'extensions.hgext.fsmonitor'):
517         if k in hg_config and hg_config[k] != '!':
518             ext_enabled = True
520     mode_disabled = hg_config.get('fsmonitor.mode') == 'off'
522     if not ext_enabled:
523         return 'no (fsmonitor extension not enabled)'
524     if mode_disabled:
525         return 'no (fsmonitor.mode=off disables fsmonitor)'
527     return True
529 # Miscellaneous programs
530 # ==============================================================
531 check_prog('XARGS', ('xargs',))
533 @depends(target)
534 def extra_programs(target):
535     if target.kernel == 'Darwin':
536         return namespace(
537             DSYMUTIL=('dsymutil', 'llvm-dsymutil'),
538             MKFSHFS=('newfs_hfs', 'mkfs.hfsplus'),
539             HFS_TOOL=('hfsplus',)
540         )
541     if target.os == 'GNU' and target.kernel == 'Linux':
542         return namespace(RPMBUILD=('rpmbuild',))
544 check_prog('DSYMUTIL', extra_programs.DSYMUTIL,
545            allow_missing=True)
546 check_prog('MKFSHFS', extra_programs.MKFSHFS,
547            allow_missing=True)
548 check_prog('HFS_TOOL', extra_programs.HFS_TOOL,
549            allow_missing=True)
550 check_prog('RPMBUILD', extra_programs.RPMBUILD,
551            allow_missing=True)
554 @depends(target)
555 @imports('os')
556 def makensis_progs(target):
557     if target.kernel != 'WINNT':
558         return
560     candidates = [
561         'makensis-3.01',
562         'makensis-3.0b3',
563         'makensis-3.0b1',
564         'makensis',
565     ]
567     # Look for nsis installed by msys environment. But only the 32-bit version.
568     # We use an absolute path and insert as the first entry so it is preferred
569     # over a 64-bit exe that may be in PATH.
570     if 'MSYSTEM_PREFIX' in os.environ:
571         prefix = os.path.dirname(os.environ['MSYSTEM_PREFIX'])
572         candidates.insert(0, os.path.join(prefix, 'mingw32', 'bin', 'makensis.exe'))
574     return tuple(candidates)
576 nsis = check_prog('MAKENSISU', makensis_progs, allow_missing=True)
578 # Make sure the version of makensis is up to date.
579 @depends(nsis, wine)
580 @checking('for NSIS version')
581 @imports('re')
582 def nsis_version(nsis, wine):
583     if not nsis:
584         return None
585     nsis_min_version = '3.0b1'
586     onerror = lambda: die('Failed to get nsis version.')
587     if wine and nsis.lower().endswith('.exe'):
588         out = check_cmd_output(wine, nsis, '-version', onerror=onerror)
589     else:
590         out = check_cmd_output(nsis, '-version', onerror=onerror)
592     m = re.search(r'(?<=v)[0-9]+\.[0-9]+((a|b|rc)[0-9]+)?', out)
594     if not m:
595         raise FatalCheckError('Unknown version of makensis')
596     ver = Version(m.group(0))
598     # Versions comparisons don't quite work well with beta versions, so ensure
599     # it works for the non-beta version.
600     if ver < nsis_min_version and (ver >= '3.0a' or ver < '3'):
601         raise FatalCheckError('To build the installer you must have NSIS'
602                               ' version %s or greater in your path'
603                               % nsis_min_version)
605     return ver
607 # And that makensis is 32-bit (but only on Windows).
608 @depends_if(nsis, when=depends(host)(lambda h: h.kernel == 'WINNT'))
609 @checking('for 32-bit NSIS')
610 def nsis_binary_type(nsis):
611     bin_type = windows_binary_type(nsis)
612     if bin_type != 'win32':
613         raise FatalCheckError('%s is not a 32-bit Windows application' % nsis)
615     return 'yes'
617 # And any flags we have to give to makensis
618 @depends(host)
619 def nsis_flags(host):
620     if host.kernel != 'WINNT':
621         return '-nocd'
622     return ''
624 set_config('MAKENSISU_FLAGS', nsis_flags)
626 check_prog('7Z', ('7z', '7za'), allow_missing=True, when=target_is_windows)
627 check_prog('UPX', ('upx',), allow_missing=True, when=target_is_windows)
630 @depends(host_c_compiler, c_compiler, bindgen_config_paths)
631 def llvm_objdump(host_c_compiler, c_compiler, bindgen_config_paths):
632     clang = None
633     for compiler in (host_c_compiler, c_compiler):
634         if compiler and compiler.type == 'clang':
635             clang = compiler.compiler
636             break
637         elif compiler and compiler.type == 'clang-cl':
638             clang = os.path.join(os.path.dirname(compiler.compiler), 'clang')
639             break
641     if not clang and bindgen_config_paths:
642         clang = bindgen_config_paths.clang_path
643     llvm_objdump = 'llvm-objdump'
644     if clang:
645         out = check_cmd_output(clang, '--print-prog-name=llvm-objdump',
646                                onerror=lambda: None)
647         if out:
648             llvm_objdump = out.rstrip()
649     return (llvm_objdump,)
652 llvm_objdump = check_prog('LLVM_OBJDUMP', llvm_objdump, what='llvm-objdump',
653                           when='--enable-compile-environment',
654                           paths=toolchain_search_path)
656 add_old_configure_assignment('LLVM_OBJDUMP', llvm_objdump)
659 js_option('--enable-dtrace', help='Build with dtrace support')
661 dtrace = check_header('sys/sdt.h', when='--enable-dtrace',
662                       onerror=lambda: die('dtrace enabled but sys/sdt.h not found'))
664 set_config('HAVE_DTRACE', True, when=dtrace)
665 set_define('INCLUDE_MOZILLA_DTRACE', True, when=dtrace)
666 add_old_configure_assignment('enable_dtrace', 'yes', when=dtrace)
669 js_option('--disable-icf', help='Disable Identical Code Folding')
671 add_old_configure_assignment(
672     'MOZ_DISABLE_ICF', '1', when=depends('--enable-icf')(lambda x: not x))
675 js_option('--enable-strip', when=compile_environment,
676           help='Enable stripping of libs & executables')
678 # This should be handled as a `when` once bug 1617793 is fixed.
679 @depends('--enable-strip', c_compiler, when=compile_environment)
680 def enable_strip(strip, c_compiler):
681     if strip and c_compiler.type != 'clang-cl':
682         return True
684 set_config('ENABLE_STRIP', enable_strip)
686 js_option('--disable-install-strip', when=compile_environment,
687           help='Enable stripping of libs & executables when packaging')
689 # This should be handled as a `when` once bug 1617793 is fixed.
690 @depends('--enable-install-strip', c_compiler, when=compile_environment)
691 def enable_install_strip(strip, c_compiler):
692     if strip and c_compiler.type != 'clang-cl':
693         return True
695 set_config('PKG_STRIP', enable_install_strip)
698 @depends('--enable-strip', '--enable-install-strip', when=compile_environment)
699 def strip(strip, install_strip):
700     return strip or install_strip
702 js_option(env='STRIP_FLAGS', nargs=1, when=strip, help='Flags for the strip command')
704 @depends('STRIP_FLAGS', target, when=strip)
705 def strip_flags(flags, target):
706     if flags:
707         return flags[0].split()
708     # Strip everything we can, which happens without flags on non-Darwin.
709     # On Darwin, it tries to strip things it can't, so we need to limit its scope.
710     if target.kernel == 'Darwin':
711         return ['-x', '-S']
713 set_config('STRIP_FLAGS', strip_flags)
716 @depends(js_standalone, target)
717 def system_zlib_default(js_standalone, target):
718     return js_standalone and target.kernel != 'WINNT'
720 js_option('--with-system-zlib', nargs='?', default=system_zlib_default,
721           help='{Use|Do not use} system libz')
723 @depends('--with-system-zlib')
724 def deprecated_system_zlib_path(value):
725     if len(value) == 1:
726         die('--with-system-zlib=PATH is not supported anymore. Please use '
727             '--with-system-zlib and set any necessary pkg-config environment variable.')
729 pkg_check_modules('MOZ_ZLIB', 'zlib >= 1.2.3', when='--with-system-zlib')
731 set_config('MOZ_SYSTEM_ZLIB', True, when='--with-system-zlib')
732 add_old_configure_assignment('MOZ_SYSTEM_ZLIB', True, when='--with-system-zlib')
735 # Please do not add configure checks from here on.
737 # Fallthrough to autoconf-based configure
738 include('build/moz.configure/old.configure')
740 # JS Subconfigure.
741 include('js/sub.configure', when=compile_environment & toolkit)
744 @depends(check_build_environment, build_project)
745 @imports('__sandbox__')
746 @imports('glob')
747 @imports(_from='os.path', _import='exists')
748 def config_status_deps(build_env, build_project):
750     topsrcdir = build_env.topsrcdir
751     topobjdir = build_env.topobjdir
753     if not topobjdir.endswith('js/src'):
754         extra_deps = [os.path.join(topobjdir, '.mozconfig.json')]
755     else:
756         # mozconfig changes may impact js configure.
757         extra_deps = [os.path.join(topobjdir[:-7], '.mozconfig.json')]
759     confvars = os.path.join(topsrcdir, build_project, 'confvars.sh')
760     if exists(confvars):
761         extra_deps.append(confvars)
763     return list(__sandbox__._all_paths) + extra_deps + [
764         os.path.join(topsrcdir, 'CLOBBER'),
765         os.path.join(topsrcdir, 'configure'),
766         os.path.join(topsrcdir, 'js', 'src', 'configure'),
767         os.path.join(topsrcdir, 'configure.in'),
768         os.path.join(topsrcdir, 'js', 'src', 'configure.in'),
769         os.path.join(topsrcdir, 'nsprpub', 'configure'),
770         os.path.join(topsrcdir, 'config', 'milestone.txt'),
771         os.path.join(topsrcdir, 'browser', 'config', 'version.txt'),
772         os.path.join(topsrcdir, 'browser', 'config', 'version_display.txt'),
773         os.path.join(topsrcdir, 'build', 'build_virtualenv_packages.txt'),
774         os.path.join(topsrcdir, 'build', 'common_virtualenv_packages.txt'),
775         os.path.join(topsrcdir, 'build', 'mach_virtualenv_packages.txt'),
776         os.path.join(topsrcdir, 'python', 'mozbuild', 'mozbuild', 'virtualenv.py'),
777         os.path.join(topsrcdir, 'testing', 'mozbase', 'packages.txt'),
778         os.path.join(topsrcdir, 'aclocal.m4'),
779         os.path.join(topsrcdir, 'old-configure.in'),
780         os.path.join(topsrcdir, 'js', 'src', 'aclocal.m4'),
781         os.path.join(topsrcdir, 'js', 'src', 'old-configure.in'),
782     ] + glob.glob(os.path.join(topsrcdir, 'build', 'autoconf', '*.m4'))
784 set_config('CONFIG_STATUS_DEPS', config_status_deps)
785 # Please do not add anything after setting config_dep_paths.