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')
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.
17 # Multiprocess Firefox Testing UI - Nightly and Aurora
18 # To be removed in Bug 1003313
20 def e10s_testing_only(milestone):
21 if not milestone.is_release_or_beta:
24 set_config('E10S_TESTING_ONLY', e10s_testing_only)
25 set_define('E10S_TESTING_ONLY', e10s_testing_only)
28 option('--enable-artifact-builds', env='MOZ_ARTIFACT_BUILDS',
29 help='Download and use prebuilt binary artifacts.')
31 @depends('--enable-artifact-builds')
32 def artifact_builds(value):
36 set_config('MOZ_ARTIFACT_BUILDS', artifact_builds)
38 imply_option('--enable-artifact-build-symbols',
39 depends(artifact_builds)(lambda v: False if v is None else None),
40 reason='--disable-artifact-builds')
42 option('--enable-artifact-build-symbols',
43 help='Download symbols when artifact builds are enabled.')
45 set_config('MOZ_ARTIFACT_BUILD_SYMBOLS',
46 depends_if('--enable-artifact-build-symbols')(lambda _: True))
48 @depends('--enable-artifact-builds')
49 def imply_disable_compile_environment(value):
53 imply_option('--enable-compile-environment', imply_disable_compile_environment)
55 option('--disable-compile-environment',
56 help='Disable compiler/library checks')
58 @depends('--disable-compile-environment')
59 def compile_environment(compile_env):
63 set_config('COMPILE_ENVIRONMENT', compile_environment)
64 add_old_configure_assignment('COMPILE_ENVIRONMENT', compile_environment)
66 js_option('--disable-tests',
67 help='Do not build test libraries & programs')
69 @depends('--disable-tests')
70 def enable_tests(value):
74 set_config('ENABLE_TESTS', enable_tests)
75 set_define('ENABLE_TESTS', enable_tests)
77 @depends(enable_tests)
78 def gtest_has_rtti(value):
82 set_define('GTEST_HAS_RTTI', gtest_has_rtti)
84 @depends(target, enable_tests)
85 def linux_gtest_defines(target, enable_tests):
86 if enable_tests and target.os == 'Android':
87 return namespace(os_linux_android=True,
88 use_own_tr1_tuple=True,
91 set_define('GTEST_OS_LINUX_ANDROID',
92 delayed_getattr(linux_gtest_defines, 'os_linux_android'))
93 set_define('GTEST_USE_OWN_TR1_TUPLE',
94 delayed_getattr(linux_gtest_defines, 'use_own_tr1_tuple'))
95 set_define('GTEST_HAS_CLONE',
96 delayed_getattr(linux_gtest_defines, 'has_clone'))
98 js_option('--enable-debug',
100 help='Enable building with developer debug info '
101 '(using the given compiler flags).')
103 add_old_configure_assignment('MOZ_DEBUG',
104 depends('--enable-debug')(lambda v: bool(v)))
106 include('build/moz.configure/pkg.configure')
107 # Make this assignment here rather than in pkg.configure to avoid
108 # requiring this file in unit tests.
109 add_old_configure_assignment('PKG_CONFIG', pkg_config)
111 include('build/moz.configure/toolchain.configure',
112 when='--enable-compile-environment')
113 include('build/moz.configure/memory.configure',
114 when='--enable-compile-environment')
115 include('build/moz.configure/headers.configure',
116 when='--enable-compile-environment')
117 include('build/moz.configure/warnings.configure',
118 when='--enable-compile-environment')
120 include(include_project_configure)
123 @imports(_from='mozbuild.backend', _import='backends')
124 def build_backends_choices(_):
125 return tuple(backends)
128 @deprecated_option('--enable-build-backend', nargs='+',
129 choices=build_backends_choices)
130 def build_backend(backends):
132 return tuple('+%s' % b for b in backends)
134 imply_option('--build-backends', build_backend)
137 @depends('--enable-artifact-builds', '--disable-compile-environment', '--help')
139 def build_backend_defaults(artifact_builds, compile_environment, _):
141 all_backends = ['FasterMake+RecursiveMake']
143 all_backends = ['RecursiveMake', 'FasterMake']
144 # Normally, we'd use target.os == 'WINNT', but a dependency on target
145 # would require target to depend on --help, as well as host and shell,
146 # and this is not a can of worms we can open at the moment.
147 if sys.platform == 'win32' and compile_environment:
148 all_backends.append('VisualStudio')
149 return tuple(all_backends)
151 option('--build-backends', nargs='+', default=build_backend_defaults,
152 choices=build_backends_choices, help='Build backends to generate')
154 @depends('--build-backends')
155 def build_backends(backends):
158 set_config('BUILD_BACKENDS', build_backends)
160 option('--disable-gtest-in-build',
161 help='Force disable building the gtest libxul during the build.',
162 when='--enable-compile-environment')
164 # Determine whether to build the gtest xul. This happens in automation
165 # on Desktop platforms with the exception of Windows PGO, where linking
166 # xul-gtest.dll takes too long.
167 @depends('MOZ_PGO', build_project, target, 'MOZ_AUTOMATION', '--disable-gtest-in-build',
168 when='--enable-compile-environment')
169 def build_gtest(pgo, build_project, target, automation, enabled):
172 if (automation and build_project == 'browser' and
173 not (pgo and target.os == 'WINNT')):
176 set_config('LINK_GTEST_DURING_COMPILE', build_gtest)
179 # ==============================================================
180 awk = check_prog('AWK', ('gawk', 'mawk', 'nawk', 'awk'))
182 # Until the AWK variable is not necessary in old-configure
184 def awk_for_old_configure(value):
187 add_old_configure_assignment('AWK', awk_for_old_configure)
191 # ==============================================================
192 perl = check_prog('PERL', ('perl5', 'perl'))
194 # Until the PERL variable is not necessary in old-configure
196 def perl_for_old_configure(value):
199 add_old_configure_assignment('PERL', perl_for_old_configure)
202 def perl_version_check(min_version):
204 @checking('for minimum required perl version >= %s' % min_version)
205 def get_perl_version(perl):
206 return Version(check_cmd_output(
207 perl, '-e', 'print $]',
208 onerror=lambda: die('Failed to get perl version.')
211 @depends(get_perl_version)
212 def check_perl_version(version):
213 if version < min_version:
214 die('Perl %s or higher is required.', min_version)
217 @checking('for full perl installation')
218 @imports('subprocess')
219 def has_full_perl_installation(perl):
220 ret = subprocess.call(
221 [perl, '-e', 'use Config; exit(!-d $Config{archlib})'])
224 @depends(has_full_perl_installation)
225 def require_full_perl_installation(has_full_perl_installation):
226 if not has_full_perl_installation:
227 die('Cannot find Config.pm or $Config{archlib}. '
228 'A full perl installation is required.')
230 perl_version_check('5.006')
234 # ==============================================================
235 option(env='MAKE', nargs=1, help='Path to GNU make')
237 @depends('MAKE', host)
238 def possible_makes(make, host):
240 if host.kernel == 'WINNT':
241 candidates.append('mingw32-make')
243 candidates.append(make[0])
244 if host.kernel == 'WINNT':
245 candidates.extend(('make', 'gmake'))
247 candidates.extend(('gmake', 'make'))
250 check_prog('GMAKE', possible_makes)
253 # ==============================================================
254 @depends(build_backends)
255 def tup_progs(build_backends):
256 for backend in build_backends:
261 tup = check_prog('TUP', tup_progs)
263 # Miscellaneous programs
264 # ==============================================================
265 check_prog('DOXYGEN', ('doxygen',), allow_missing=True)
266 check_prog('XARGS', ('xargs',))
269 def extra_programs(target):
270 if target.kernel == 'Darwin':
272 DSYMUTIL=('dsymutil', 'llvm-dsymutil'),
273 MKFSHFS=('newfs_hfs', 'mkfs.hfsplus'),
274 HFS_TOOL=('hfsplus',)
276 if target.os == 'GNU' and target.kernel == 'Linux':
277 return namespace(RPMBUILD=('rpmbuild',))
279 check_prog('DSYMUTIL', delayed_getattr(extra_programs, 'DSYMUTIL'),
281 check_prog('MKFSHFS', delayed_getattr(extra_programs, 'MKFSHFS'),
283 check_prog('HFS_TOOL', delayed_getattr(extra_programs, 'HFS_TOOL'),
285 check_prog('RPMBUILD', delayed_getattr(extra_programs, 'RPMBUILD'),
288 option('--enable-system-hunspell',
289 help="Use system hunspell (located with pkgconfig)")
291 @depends('--enable-system-hunspell', compile_environment)
292 def check_for_hunspell(value, compile_env):
293 return value and compile_env
295 system_hunspell = pkg_check_modules('MOZ_HUNSPELL', 'hunspell',
296 when=check_for_hunspell)
298 set_config('MOZ_SYSTEM_HUNSPELL', depends_if(system_hunspell)(lambda _: True))
303 def makensis_progs(target):
304 if target.kernel != 'WINNT':
309 'makensis-3.0b3.exe',
310 'makensis-3.0b1.exe',
315 # Look for nsis installed by msys environment. But only the 32-bit version.
316 # We use an absolute path and insert as the first entry so it is preferred
317 # over a 64-bit exe that may be in PATH.
318 if 'MSYSTEM_PREFIX' in os.environ:
319 prefix = os.path.dirname(os.environ['MSYSTEM_PREFIX'])
320 candidates.insert(0, os.path.join(prefix, 'mingw32', 'bin', 'makensis.exe'))
322 return tuple(candidates)
324 nsis = check_prog('MAKENSISU', makensis_progs)
326 # Make sure the version of makensis is up to date.
328 @checking('for NSIS version')
330 def nsis_version(nsis):
331 nsis_min_version = '3.0b1'
332 out = check_cmd_output(nsis, '-version',
333 onerror=lambda: die('Failed to get nsis version.'))
334 m = re.search(r'(?<=v)[0-9]+\.[0-9]+((a|b|rc)[0-9]+)?', out)
337 raise FatalCheckError('Unknown version of makensis')
338 ver = Version(m.group(0))
340 # Versions comparisons don't quite work well with beta versions, so ensure
341 # it works for the non-beta version.
342 if ver < nsis_min_version and (ver >= '3.0a' or ver < '3'):
343 raise FatalCheckError('To build the installer you must have NSIS'
344 ' version %s or greater in your path'
349 # And that makensis is 32-bit.
351 @checking('for 32-bit NSIS')
352 def nsis_binary_type(nsis):
353 bin_type = windows_binary_type(nsis)
354 if bin_type != 'win32':
355 raise FatalCheckError('%s is not a 32-bit Windows application' % nsis)
360 # Fallthrough to autoconf-based configure
361 include('build/moz.configure/old.configure')
363 @imports('__sandbox__')
365 return __sandbox__._all_paths
367 set_config('ALL_CONFIGURE_PATHS', all_paths())
368 # Please do not add anything after setting ALL_CONFIGURE_PATHS.