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)
162 # ==============================================================
163 awk = check_prog('AWK', ('gawk', 'mawk', 'nawk', 'awk'))
165 # Until the AWK variable is not necessary in old-configure
167 def awk_for_old_configure(value):
170 add_old_configure_assignment('AWK', awk_for_old_configure)
174 # ==============================================================
175 perl = check_prog('PERL', ('perl5', 'perl'))
177 # Until the PERL variable is not necessary in old-configure
179 def perl_for_old_configure(value):
182 add_old_configure_assignment('PERL', perl_for_old_configure)
185 def perl_version_check(min_version):
187 @checking('for minimum required perl version >= %s' % min_version)
188 def get_perl_version(perl):
189 return Version(check_cmd_output(
190 perl, '-e', 'print $]',
191 onerror=lambda: die('Failed to get perl version.')
194 @depends(get_perl_version)
195 def check_perl_version(version):
196 if version < min_version:
197 die('Perl %s or higher is required.', min_version)
200 @checking('for full perl installation')
201 @imports('subprocess')
202 def has_full_perl_installation(perl):
203 ret = subprocess.call(
204 [perl, '-e', 'use Config; exit(!-d $Config{archlib})'])
207 @depends(has_full_perl_installation)
208 def require_full_perl_installation(has_full_perl_installation):
209 if not has_full_perl_installation:
210 die('Cannot find Config.pm or $Config{archlib}. '
211 'A full perl installation is required.')
213 perl_version_check('5.006')
217 # ==============================================================
218 option(env='MAKE', nargs=1, help='Path to GNU make')
220 @depends('MAKE', host)
221 def possible_makes(make, host):
223 if host.kernel == 'WINNT':
224 candidates.append('mingw32-make')
226 candidates.append(make[0])
227 if host.kernel == 'WINNT':
228 candidates.extend(('make', 'gmake'))
230 candidates.extend(('gmake', 'make'))
233 check_prog('GMAKE', possible_makes)
236 # ==============================================================
237 @depends(build_backends)
238 def tup_progs(build_backends):
239 for backend in build_backends:
244 tup = check_prog('TUP', tup_progs)
246 # Miscellaneous programs
247 # ==============================================================
248 check_prog('DOXYGEN', ('doxygen',), allow_missing=True)
249 check_prog('XARGS', ('xargs',))
252 def extra_programs(target):
253 if target.kernel == 'Darwin':
255 DSYMUTIL=('dsymutil', 'llvm-dsymutil'),
256 GENISOIMAGE=('genisoimage',),
258 if target.os == 'GNU' and target.kernel == 'Linux':
259 return namespace(RPMBUILD=('rpmbuild',))
261 check_prog('DSYMUTIL', delayed_getattr(extra_programs, 'DSYMUTIL'),
263 check_prog('GENISOIMAGE', delayed_getattr(extra_programs, 'GENISOIMAGE'),
265 check_prog('RPMBUILD', delayed_getattr(extra_programs, 'RPMBUILD'),
268 option('--enable-system-hunspell',
269 help="Use system hunspell (located with pkgconfig)")
271 @depends('--enable-system-hunspell', compile_environment)
272 def check_for_hunspell(value, compile_env):
273 return value and compile_env
275 system_hunspell = pkg_check_modules('MOZ_HUNSPELL', 'hunspell',
276 when=check_for_hunspell)
278 set_config('MOZ_SYSTEM_HUNSPELL', depends_if(system_hunspell)(lambda _: True))
283 def makensis_progs(target):
284 if target.kernel != 'WINNT':
288 'makensis-3.0b3.exe',
289 'makensis-3.0b1.exe',
294 # Look for nsis installed by msys environment. But only the 32-bit version.
295 # We use an absolute path and insert as the first entry so it is preferred
296 # over a 64-bit exe that may be in PATH.
297 if 'MSYSTEM_PREFIX' in os.environ:
298 prefix = os.path.dirname(os.environ['MSYSTEM_PREFIX'])
299 candidates.insert(0, os.path.join(prefix, 'mingw32', 'bin', 'makensis.exe'))
301 return tuple(candidates)
303 nsis = check_prog('MAKENSISU', makensis_progs)
305 # Make sure the version of makensis is up to date.
307 @checking('for NSIS version')
309 def nsis_version(nsis):
310 nsis_min_version = '3.0b1'
311 out = check_cmd_output(nsis, '-version',
312 onerror=lambda: die('Failed to get nsis version.'))
313 m = re.search(r'(?<=v)[0-9]+\.[0-9]+((a|b|rc)[0-9]+)?', out)
316 raise FatalCheckError('Unknown version of makensis')
317 ver = Version(m.group(0))
319 # Versions comparisons don't quite work well with beta versions, so ensure
320 # it works for the non-beta version.
321 if ver < nsis_min_version and (ver >= '3.0a' or ver < '3'):
322 raise FatalCheckError('To build the installer you must have NSIS'
323 ' version %s or greater in your path'
328 # And that makensis is 32-bit.
330 @checking('for 32-bit NSIS')
331 def nsis_binary_type(nsis):
332 bin_type = windows_binary_type(nsis)
333 if bin_type != 'win32':
334 raise FatalCheckError('%s is not a 32-bit Windows application' % nsis)
339 # Fallthrough to autoconf-based configure
340 include('build/moz.configure/old.configure')
342 @imports('__sandbox__')
344 return __sandbox__._all_paths
346 set_config('ALL_CONFIGURE_PATHS', all_paths())
347 # Please do not add anything after setting ALL_CONFIGURE_PATHS.