Bug 1318565 - Allow extensions with permission to read from tainted Canvas r=bz
[gecko.git] / moz.configure
blob42d9b9573b97da0de9ecffcd20520e3598402074
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 # Multiprocess Firefox Testing UI - Nightly and Aurora
18 # To be removed in Bug 1003313
19 @depends(milestone)
20 def e10s_testing_only(milestone):
21     if not milestone.is_release_or_beta:
22         return True
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):
33     if value:
34         return True
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):
50     if value:
51         return False
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):
60     if compile_env:
61         return True
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):
71     if value:
72         return True
74 set_config('ENABLE_TESTS', enable_tests)
75 set_define('ENABLE_TESTS', enable_tests)
77 @depends(enable_tests)
78 def gtest_has_rtti(value):
79     if value:
80         return '0'
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,
89                          has_clone='0')
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',
99           nargs='?',
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)
122 @depends('--help')
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):
131     if 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')
138 @imports('sys')
139 def build_backend_defaults(artifact_builds, compile_environment, _):
140     if artifact_builds:
141         all_backends = ['FasterMake+RecursiveMake']
142     else:
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):
156     return 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):
170     if not enabled:
171         return None
172     if (automation and build_project == 'browser' and
173         not (pgo and target.os == 'WINNT')):
174         return True
176 set_config('LINK_GTEST_DURING_COMPILE', build_gtest)
178 # Awk detection
179 # ==============================================================
180 awk = check_prog('AWK', ('gawk', 'mawk', 'nawk', 'awk'))
182 # Until the AWK variable is not necessary in old-configure
183 @depends(awk)
184 def awk_for_old_configure(value):
185     return value
187 add_old_configure_assignment('AWK', awk_for_old_configure)
190 # Perl detection
191 # ==============================================================
192 perl = check_prog('PERL', ('perl5', 'perl'))
194 # Until the PERL variable is not necessary in old-configure
195 @depends(perl)
196 def perl_for_old_configure(value):
197     return value
199 add_old_configure_assignment('PERL', perl_for_old_configure)
201 @template
202 def perl_version_check(min_version):
203     @depends(perl)
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.')
209         ))
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)
216     @depends(perl)
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})'])
222         return ret == 0
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')
233 # GNU make detection
234 # ==============================================================
235 option(env='MAKE', nargs=1, help='Path to GNU make')
237 @depends('MAKE', host)
238 def possible_makes(make, host):
239     candidates = []
240     if host.kernel == 'WINNT':
241         candidates.append('mingw32-make')
242     if make:
243         candidates.append(make[0])
244     if host.kernel == 'WINNT':
245         candidates.extend(('make', 'gmake'))
246     else:
247         candidates.extend(('gmake', 'make'))
248     return candidates
250 check_prog('GMAKE', possible_makes)
252 # tup detection
253 # ==============================================================
254 @depends(build_backends)
255 def tup_progs(build_backends):
256     for backend in build_backends:
257         if 'Tup' in backend:
258             return ['tup']
259     return None
261 tup = check_prog('TUP', tup_progs)
263 # Miscellaneous programs
264 # ==============================================================
265 check_prog('DOXYGEN', ('doxygen',), allow_missing=True)
266 check_prog('XARGS', ('xargs',))
268 @depends(target)
269 def extra_programs(target):
270     if target.kernel == 'Darwin':
271         return namespace(
272             DSYMUTIL=('dsymutil', 'llvm-dsymutil'),
273             MKFSHFS=('newfs_hfs', 'mkfs.hfsplus'),
274             HFS_TOOL=('hfsplus',)
275         )
276     if target.os == 'GNU' and target.kernel == 'Linux':
277         return namespace(RPMBUILD=('rpmbuild',))
279 check_prog('DSYMUTIL', delayed_getattr(extra_programs, 'DSYMUTIL'),
280            allow_missing=True)
281 check_prog('MKFSHFS', delayed_getattr(extra_programs, 'MKFSHFS'),
282            allow_missing=True)
283 check_prog('HFS_TOOL', delayed_getattr(extra_programs, 'HFS_TOOL'),
284            allow_missing=True)
285 check_prog('RPMBUILD', delayed_getattr(extra_programs, 'RPMBUILD'),
286            allow_missing=True)
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))
301 @depends(target)
302 @imports('os')
303 def makensis_progs(target):
304     if target.kernel != 'WINNT':
305         return
307     candidates = [
308         'makensis-3.01.exe',
309         'makensis-3.0b3.exe',
310         'makensis-3.0b1.exe',
311         'makensis.exe',
312         'makensis',
313     ]
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.
327 @depends_if(nsis)
328 @checking('for NSIS version')
329 @imports('re')
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)
336     if not m:
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'
345                               % nsis_min_version)
347     return ver
349 # And that makensis is 32-bit.
350 @depends_if(nsis)
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)
357     return 'yes'
360 # Fallthrough to autoconf-based configure
361 include('build/moz.configure/old.configure')
363 @imports('__sandbox__')
364 def all_paths():
365     return __sandbox__._all_paths
367 set_config('ALL_CONFIGURE_PATHS', all_paths())
368 # Please do not add anything after setting ALL_CONFIGURE_PATHS.