Bug 1672538 [wpt PR 26196] - Fix two hyphenation tests, a=testonly
[gecko.git] / moz.configure
blobf460868f94c3ac2766dfd2ea5f1f8df81648844c
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 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 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 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 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 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 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                     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                 obj=namespace(prefix='', suffix='obj'),
227             )
229         elif host_or_target.kernel == 'Darwin':
230             return namespace(
231                 dll=namespace(prefix='lib', suffix='.dylib'),
232                 lib=namespace(prefix='lib', suffix='a'),
233                 import_lib=namespace(prefix=None, suffix=''),
234                 obj=namespace(prefix='', suffix='o'),
235             )
236         elif so_version:
237             so = '.so.%s' % so_version
238         else:
239             so = '.so'
241         return namespace(
242             dll=namespace(prefix='lib', suffix=so),
243             lib=namespace(prefix='lib', suffix='a'),
244             import_lib=namespace(prefix=None, suffix=''),
245             obj=namespace(prefix='', suffix='o'),
246         )
248     return library_name_info_impl
250 host_library_name_info = library_name_info_template(host)
251 library_name_info = library_name_info_template(target)
253 set_config('DLL_PREFIX', library_name_info.dll.prefix)
254 set_config('DLL_SUFFIX', library_name_info.dll.suffix)
255 set_config('HOST_DLL_PREFIX', host_library_name_info.dll.prefix)
256 set_config('HOST_DLL_SUFFIX', host_library_name_info.dll.suffix)
257 set_config('LIB_PREFIX', library_name_info.lib.prefix)
258 set_config('LIB_SUFFIX', library_name_info.lib.suffix)
259 set_config('OBJ_SUFFIX', library_name_info.obj.suffix)
260 # Lots of compilation tests depend on this variable being present.
261 add_old_configure_assignment('OBJ_SUFFIX', library_name_info.obj.suffix)
262 set_config('IMPORT_LIB_SUFFIX', library_name_info.import_lib.suffix)
263 set_define('MOZ_DLL_PREFIX', depends(library_name_info.dll.prefix)(lambda s: '"%s"' % s))
264 set_define('MOZ_DLL_SUFFIX', depends(library_name_info.dll.suffix)(lambda s: '"%s"' % s))
265 set_config('WASM_OBJ_SUFFIX', 'wasm')
267 # Make `profiling` available to this file even when js/moz.configure
268 # doesn't end up included.
269 profiling = dependable(False)
270 # Same for js_standalone
271 js_standalone = dependable(False)
272 # Same for fold_libs
273 fold_libs = dependable(False)
275 include(include_project_configure)
277 @depends('--help')
278 @imports(_from='mozbuild.backend', _import='backends')
279 def build_backends_choices(_):
280     return tuple(backends)
283 @deprecated_option('--enable-build-backend', nargs='+',
284                    choices=build_backends_choices)
285 def build_backend(backends):
286     if backends:
287         return tuple('+%s' % b for b in backends)
289 imply_option('--build-backends', build_backend)
292 @depends('--enable-artifact-builds', '--disable-compile-environment',
293          '--enable-build-backend', '--enable-project', '--enable-application',
294          '--help')
295 @imports('sys')
296 def build_backend_defaults(artifact_builds, compile_environment, requested_backends,
297                            project, application, _):
298     if application:
299         project = application[0]
300     elif project:
301         project = project[0]
303     if 'Tup' in requested_backends:
304         # As a special case, if Tup was requested, do not combine it with any
305         # Make based backend by default.
306         all_backends = []
307     elif artifact_builds:
308         all_backends = ['FasterMake+RecursiveMake']
309     else:
310         all_backends = ['RecursiveMake', 'FasterMake']
311     # Normally, we'd use target.os == 'WINNT', but a dependency on target
312     # would require target to depend on --help, as well as host and shell,
313     # and this is not a can of worms we can open at the moment.
314     if sys.platform == 'win32' and compile_environment and project != 'mobile/android':
315         all_backends.append('VisualStudio')
316     return tuple(all_backends) or None
318 option('--build-backends', nargs='+', default=build_backend_defaults,
319        choices=build_backends_choices, help='Build backends to generate')
321 @depends('--build-backends')
322 def build_backends(backends):
323     return backends
325 set_config('BUILD_BACKENDS', build_backends)
328 @depends(check_build_environment, build_backends)
329 @imports('glob')
330 def check_objdir_backend_reuse(build_env, backends):
331     # "Make based" might be RecursiveMake or a hybrid backend, so "Make" is
332     # intentionally vague for use with the substring match below.
333     incompatible_backends = (
334         ('Tup', 'Make'),
335         ('Make', 'Tup')
336     )
337     for backend_file in glob.iglob(os.path.join(build_env.topobjdir,
338                                                 'backend.*Backend')):
339         for prev, curr in incompatible_backends:
340             if prev in backend_file and any(curr in b for b in backends):
341                 die("The active objdir, %s, was previously "
342                     "used to build with a %s based backend. "
343                     "Change objdirs (by setting MOZ_OBJDIR in "
344                     "your mozconfig) or clobber to continue.\n",
345                     build_env.topobjdir, prev)
348 option('--disable-gtest-in-build',
349        help='Force disable building the gtest libxul during the build.',
350        when='--enable-compile-environment')
352 # Determine whether to build the gtest xul. This happens in automation
353 # on Android and Desktop platforms with the exception of:
354 #  - Windows PGO, where linking xul-gtest.dll takes too long;
355 #  - Android other than x86_64, where gtest is not required.
356 @depends('MOZ_PGO', build_project, target, 'MOZ_AUTOMATION', '--disable-gtest-in-build',
357          enable_tests, when='--enable-compile-environment')
358 def build_gtest(pgo, build_project, target, automation, enabled, enable_tests):
359     if not enable_tests or not enabled:
360         return None
361     if (automation and build_project in ('browser', 'comm/mail', 'mobile/android') and
362         not ((pgo and target.os == 'WINNT') or (target.os == 'Android' and target.cpu != 'x86_64'))):
363         return True
365 set_config('LINK_GTEST_DURING_COMPILE', build_gtest)
367 # Localization
368 # ==============================================================
369 option('--enable-ui-locale', default='en-US',
370        help='Select the user interface locale (default: en-US)')
372 set_config('MOZ_UI_LOCALE', depends('--enable-ui-locale')(lambda x: x))
374 # clang-plugin location
375 # ==============================================================
376 @depends(host_library_name_info, check_build_environment,
377          when='--enable-clang-plugin')
378 def clang_plugin_path(library_name_info, build_env):
379     topobjdir = build_env.topobjdir
380     if topobjdir.endswith('/js/src'):
381         topobjdir = topobjdir[:-7]
382     return os.path.abspath(
383         os.path.join(topobjdir, 'build', 'clang-plugin',
384                      '%sclang-plugin%s' % (library_name_info.dll.prefix,
385                                            library_name_info.dll.suffix))
386     )
388 add_old_configure_assignment('CLANG_PLUGIN', clang_plugin_path)
391 # Awk detection
392 # ==============================================================
393 awk = check_prog('AWK', ('gawk', 'mawk', 'nawk', 'awk'))
395 # Until the AWK variable is not necessary in old-configure
396 @depends(awk)
397 def awk_for_old_configure(value):
398     return value
400 add_old_configure_assignment('AWK', awk_for_old_configure)
403 # Perl detection
404 # ==============================================================
405 perl = check_prog('PERL', ('perl5', 'perl'))
407 # Until the PERL variable is not necessary in old-configure
408 @depends(perl)
409 def perl_for_old_configure(value):
410     return value
412 add_old_configure_assignment('PERL', perl_for_old_configure)
414 @template
415 def perl_version_check(min_version):
416     @depends(perl)
417     @checking('for minimum required perl version >= %s' % min_version)
418     def get_perl_version(perl):
419         return Version(check_cmd_output(
420             perl, '-e', 'print $]',
421             onerror=lambda: die('Failed to get perl version.')
422         ))
424     @depends(get_perl_version)
425     def check_perl_version(version):
426         if version < min_version:
427             die('Perl %s or higher is required.', min_version)
429     @depends(perl)
430     @checking('for full perl installation')
431     @imports('subprocess')
432     def has_full_perl_installation(perl):
433         ret = subprocess.call(
434             [perl, '-e', 'use Config; exit(!-d $Config{archlib})'])
435         return ret == 0
437     @depends(has_full_perl_installation)
438     def require_full_perl_installation(has_full_perl_installation):
439         if not has_full_perl_installation:
440             die('Cannot find Config.pm or $Config{archlib}. '
441                 'A full perl installation is required.')
443 perl_version_check('5.006')
446 # GNU make detection
447 # ==============================================================
448 option(env='MAKE', nargs=1, help='Path to GNU make')
450 @depends('MAKE', host)
451 def possible_makes(make, host):
452     candidates = []
453     if host.kernel == 'WINNT':
454         candidates.append('mingw32-make')
455     if make:
456         candidates.append(make[0])
457     if host.kernel == 'WINNT':
458         candidates.extend(('make', 'gmake'))
459     else:
460         candidates.extend(('gmake', 'make'))
461     return candidates
463 check_prog('GMAKE', possible_makes)
465 # watchman detection
466 # ==============================================================
468 option(env='WATCHMAN', nargs=1, help='Path to the watchman program')
470 @depends(host, 'WATCHMAN')
471 @checking('for watchman', callback=lambda w: w.path if w else 'not found')
472 def watchman(host, prog):
473     # On Windows, `watchman` is only supported on 64-bit hosts.
474     if host.os == 'WINNT' and host.cpu != 'x86_64':
475         return
477     if not prog:
478         prog = find_program('watchman')
480     if not prog:
481         return
483     # `watchman version` will talk to the Watchman daemon service.
484     # This can hang due to permissions problems. e.g.
485     # https://github.com/facebook/watchman/issues/376. So use
486     # `watchman --version` to prevent a class of failures.
487     out = check_cmd_output(prog, '--version', onerror=lambda: None)
488     if out is None:
489         return
491     return namespace(path=prog, version=Version(out.strip()))
493 @depends_if(watchman)
494 @checking('for watchman version')
495 def watchman_version(w):
496     return w.version
498 set_config('WATCHMAN', watchman.path)
500 @depends_all(hg_version, hg_config, watchman)
501 @checking('for watchman Mercurial integration')
502 @imports('os')
503 def watchman_hg(hg_version, hg_config, watchman):
504     if hg_version < Version('3.8'):
505         return 'no (Mercurial 3.8+ required)'
507     ext_enabled = False
508     mode_disabled = False
510     for k in ('extensions.fsmonitor', 'extensions.hgext.fsmonitor'):
511         if k in hg_config and hg_config[k] != '!':
512             ext_enabled = True
514     mode_disabled = hg_config.get('fsmonitor.mode') == 'off'
516     if not ext_enabled:
517         return 'no (fsmonitor extension not enabled)'
518     if mode_disabled:
519         return 'no (fsmonitor.mode=off disables fsmonitor)'
521     return True
523 # Miscellaneous programs
524 # ==============================================================
525 check_prog('XARGS', ('xargs',))
527 @depends(target)
528 def extra_programs(target):
529     if target.kernel == 'Darwin':
530         return namespace(
531             DSYMUTIL=('dsymutil', 'llvm-dsymutil'),
532             MKFSHFS=('newfs_hfs', 'mkfs.hfsplus'),
533             HFS_TOOL=('hfsplus',)
534         )
535     if target.os == 'GNU' and target.kernel == 'Linux':
536         return namespace(RPMBUILD=('rpmbuild',))
538 check_prog('DSYMUTIL', extra_programs.DSYMUTIL,
539            allow_missing=True)
540 check_prog('MKFSHFS', extra_programs.MKFSHFS,
541            allow_missing=True)
542 check_prog('HFS_TOOL', extra_programs.HFS_TOOL,
543            allow_missing=True)
544 check_prog('RPMBUILD', extra_programs.RPMBUILD,
545            allow_missing=True)
548 @depends(target)
549 @imports('os')
550 def makensis_progs(target):
551     if target.kernel != 'WINNT':
552         return
554     candidates = [
555         'makensis-3.01',
556         'makensis-3.0b3',
557         'makensis-3.0b1',
558         'makensis',
559     ]
561     # Look for nsis installed by msys environment. But only the 32-bit version.
562     # We use an absolute path and insert as the first entry so it is preferred
563     # over a 64-bit exe that may be in PATH.
564     if 'MSYSTEM_PREFIX' in os.environ:
565         prefix = os.path.dirname(os.environ['MSYSTEM_PREFIX'])
566         candidates.insert(0, os.path.join(prefix, 'mingw32', 'bin', 'makensis.exe'))
568     return tuple(candidates)
570 nsis = check_prog('MAKENSISU', makensis_progs, allow_missing=True)
572 # Make sure the version of makensis is up to date.
573 @depends(nsis, wine)
574 @checking('for NSIS version')
575 @imports('re')
576 def nsis_version(nsis, wine):
577     if not nsis:
578         return None
579     nsis_min_version = '3.0b1'
580     onerror = lambda: die('Failed to get nsis version.')
581     if wine and nsis.lower().endswith('.exe'):
582         out = check_cmd_output(wine, nsis, '-version', onerror=onerror)
583     else:
584         out = check_cmd_output(nsis, '-version', onerror=onerror)
586     m = re.search(r'(?<=v)[0-9]+\.[0-9]+((a|b|rc)[0-9]+)?', out)
588     if not m:
589         raise FatalCheckError('Unknown version of makensis')
590     ver = Version(m.group(0))
592     # Versions comparisons don't quite work well with beta versions, so ensure
593     # it works for the non-beta version.
594     if ver < nsis_min_version and (ver >= '3.0a' or ver < '3'):
595         raise FatalCheckError('To build the installer you must have NSIS'
596                               ' version %s or greater in your path'
597                               % nsis_min_version)
599     return ver
601 # And that makensis is 32-bit (but only on Windows).
602 @depends_if(nsis, when=depends(host)(lambda h: h.kernel == 'WINNT'))
603 @checking('for 32-bit NSIS')
604 def nsis_binary_type(nsis):
605     bin_type = windows_binary_type(nsis)
606     if bin_type != 'win32':
607         raise FatalCheckError('%s is not a 32-bit Windows application' % nsis)
609     return 'yes'
611 # And any flags we have to give to makensis
612 @depends(host)
613 def nsis_flags(host):
614     if host.kernel != 'WINNT':
615         return '-nocd'
616     return ''
618 set_config('MAKENSISU_FLAGS', nsis_flags)
620 check_prog('7Z', ('7z', '7za'), allow_missing=True, when=target_is_windows)
621 check_prog('UPX', ('upx',), allow_missing=True, when=target_is_windows)
624 @depends(host_c_compiler, c_compiler, bindgen_config_paths)
625 def llvm_objdump(host_c_compiler, c_compiler, bindgen_config_paths):
626     clang = None
627     for compiler in (host_c_compiler, c_compiler):
628         if compiler and compiler.type == 'clang':
629             clang = compiler.compiler
630             break
631         elif compiler and compiler.type == 'clang-cl':
632             clang = os.path.join(os.path.dirname(compiler.compiler), 'clang')
633             break
635     if not clang and bindgen_config_paths:
636         clang = bindgen_config_paths.clang_path
637     llvm_objdump = 'llvm-objdump'
638     if clang:
639         out = check_cmd_output(clang, '--print-prog-name=llvm-objdump',
640                                onerror=lambda: None)
641         if out:
642             llvm_objdump = out.rstrip()
643     return (llvm_objdump,)
646 llvm_objdump = check_prog('LLVM_OBJDUMP', llvm_objdump, what='llvm-objdump',
647                           when='--enable-compile-environment',
648                           paths=toolchain_search_path)
650 add_old_configure_assignment('LLVM_OBJDUMP', llvm_objdump)
653 option('--enable-dtrace', help='Build with dtrace support')
655 dtrace = check_header('sys/sdt.h', when='--enable-dtrace',
656                       onerror=lambda: die('dtrace enabled but sys/sdt.h not found'))
658 set_config('HAVE_DTRACE', True, when=dtrace)
659 set_define('INCLUDE_MOZILLA_DTRACE', True, when=dtrace)
660 add_old_configure_assignment('enable_dtrace', 'yes', when=dtrace)
663 option('--disable-icf', help='Disable Identical Code Folding')
665 add_old_configure_assignment(
666     'MOZ_DISABLE_ICF', '1', when=depends('--enable-icf')(lambda x: not x))
669 option('--enable-strip', when=compile_environment,
670        help='Enable stripping of libs & executables')
672 # This should be handled as a `when` once bug 1617793 is fixed.
673 @depends('--enable-strip', c_compiler, when=compile_environment)
674 def enable_strip(strip, c_compiler):
675     if strip and c_compiler.type != 'clang-cl':
676         return True
678 set_config('ENABLE_STRIP', enable_strip)
680 option('--disable-install-strip', when=compile_environment,
681        help='Enable stripping of libs & executables when packaging')
683 # This should be handled as a `when` once bug 1617793 is fixed.
684 @depends('--enable-install-strip', c_compiler, when=compile_environment)
685 def enable_install_strip(strip, c_compiler):
686     if strip and c_compiler.type != 'clang-cl':
687         return True
689 set_config('PKG_STRIP', enable_install_strip)
692 @depends('--enable-strip', '--enable-install-strip', when=compile_environment)
693 def strip(strip, install_strip):
694     return strip or install_strip
696 option(env='STRIP_FLAGS', nargs=1, when=strip, help='Flags for the strip command')
698 @depends('STRIP_FLAGS', target, when=strip)
699 def strip_flags(flags, target):
700     if flags:
701         return flags[0].split()
702     # Strip everything we can, which happens without flags on non-Darwin.
703     # On Darwin, it tries to strip things it can't, so we need to limit its scope.
704     if target.kernel == 'Darwin':
705         return ['-x', '-S']
707 set_config('STRIP_FLAGS', strip_flags)
710 @depends(js_standalone, target)
711 def system_zlib_default(js_standalone, target):
712     return js_standalone and target.kernel != 'WINNT'
714 option('--with-system-zlib', nargs='?', default=system_zlib_default,
715        help='{Use|Do not use} system libz')
717 @depends('--with-system-zlib')
718 def deprecated_system_zlib_path(value):
719     if len(value) == 1:
720         die('--with-system-zlib=PATH is not supported anymore. Please use '
721             '--with-system-zlib and set any necessary pkg-config environment variable.')
723 pkg_check_modules('MOZ_ZLIB', 'zlib >= 1.2.3', when='--with-system-zlib')
725 set_config('MOZ_SYSTEM_ZLIB', True, when='--with-system-zlib')
726 add_old_configure_assignment('MOZ_SYSTEM_ZLIB', True, when='--with-system-zlib')
729 # Please do not add configure checks from here on.
731 # Fallthrough to autoconf-based configure
732 include('build/moz.configure/old.configure')
734 # JS Subconfigure.
735 include('js/sub.configure', when=compile_environment & toolkit)
738 @depends(check_build_environment, build_project)
739 @imports('__sandbox__')
740 @imports('glob')
741 @imports(_from='os.path', _import='exists')
742 def config_status_deps(build_env, build_project):
744     topsrcdir = build_env.topsrcdir
745     topobjdir = build_env.topobjdir
747     if not topobjdir.endswith('js/src'):
748         extra_deps = [os.path.join(topobjdir, '.mozconfig.json')]
749     else:
750         # mozconfig changes may impact js configure.
751         extra_deps = [os.path.join(topobjdir[:-7], '.mozconfig.json')]
753     confvars = os.path.join(topsrcdir, build_project, 'confvars.sh')
754     if exists(confvars):
755         extra_deps.append(confvars)
757     return list(__sandbox__._all_paths) + extra_deps + [
758         os.path.join(topsrcdir, 'CLOBBER'),
759         os.path.join(topsrcdir, 'configure.in'),
760         os.path.join(topsrcdir, 'js', 'src', 'configure.in'),
761         os.path.join(topsrcdir, 'nsprpub', 'configure'),
762         os.path.join(topsrcdir, 'config', 'milestone.txt'),
763         os.path.join(topsrcdir, 'browser', 'config', 'version.txt'),
764         os.path.join(topsrcdir, 'browser', 'config', 'version_display.txt'),
765         os.path.join(topsrcdir, 'build', 'build_virtualenv_packages.txt'),
766         os.path.join(topsrcdir, 'build', 'common_virtualenv_packages.txt'),
767         os.path.join(topsrcdir, 'build', 'mach_virtualenv_packages.txt'),
768         os.path.join(topsrcdir, 'python', 'mozbuild', 'mozbuild', 'virtualenv.py'),
769         os.path.join(topsrcdir, 'testing', 'mozbase', 'packages.txt'),
770         os.path.join(topsrcdir, 'aclocal.m4'),
771         os.path.join(topsrcdir, 'old-configure.in'),
772         os.path.join(topsrcdir, 'js', 'src', 'aclocal.m4'),
773         os.path.join(topsrcdir, 'js', 'src', 'old-configure.in'),
774     ] + glob.glob(os.path.join(topsrcdir, 'build', 'autoconf', '*.m4'))
776 set_config('CONFIG_STATUS_DEPS', config_status_deps)
777 # Please do not add anything after setting config_dep_paths.