Bug 1283439 - Include OpusDecoder.h only for Rust MP4 parsing r=kinetik
[gecko.git] / moz.configure
blobc4355cc113555bc5f472521ed966fd7526413724
1 # -*- Mode: python; c-basic-offset: 4; 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:
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 @depends('--enable-artifact-builds')
39 def imply_disable_compile_environment(value):
40     if value:
41         return False
43 imply_option('--enable-compile-environment', imply_disable_compile_environment)
45 option('--disable-compile-environment',
46        help='Disable compiler/library checks')
48 @depends('--disable-compile-environment')
49 def compile_environment(compile_env):
50     if compile_env:
51         return True
53 set_config('COMPILE_ENVIRONMENT', compile_environment)
54 add_old_configure_assignment('COMPILE_ENVIRONMENT', compile_environment)
56 js_option('--disable-tests',
57           help='Do not build test libraries & programs')
59 @depends('--disable-tests')
60 def enable_tests(value):
61     if value:
62         return True
64 set_config('ENABLE_TESTS', enable_tests)
65 set_define('ENABLE_TESTS', enable_tests)
67 @depends(enable_tests)
68 def gtest_has_rtti(value):
69     if value:
70         return '0'
72 set_define('GTEST_HAS_RTTI', gtest_has_rtti)
74 @depends(target, enable_tests)
75 def linux_gtest_defines(target, enable_tests):
76     if enable_tests and target.os == 'Android':
77         return namespace(os_linux_android=True,
78                          use_own_tr1_tuple=True,
79                          has_clone='0')
81 set_define('GTEST_OS_LINUX_ANDROID',
82            delayed_getattr(linux_gtest_defines, 'os_linux_android'))
83 set_define('GTEST_USE_OWN_TR1_TUPLE',
84            delayed_getattr(linux_gtest_defines, 'use_own_tr1_tuple'))
85 set_define('GTEST_HAS_CLONE',
86            delayed_getattr(linux_gtest_defines, 'has_clone'))
88 js_option('--enable-debug',
89           nargs='?',
90           help='Enable building with developer debug info '
91                '(using the given compiler flags).')
93 add_old_configure_assignment('MOZ_DEBUG',
94                              depends('--enable-debug')(lambda v: bool(v)))
96 @depends('--disable-compile-environment', '--help')
97 def toolchain_include(compile_env, help):
98     if compile_env:
99         return 'build/moz.configure/toolchain.configure'
101 include(toolchain_include)
103 @depends('--disable-compile-environment', '--help')
104 def memory_include(compile_env, help):
105     if compile_env:
106         return 'build/moz.configure/memory.configure'
108 include(memory_include)
111 @depends('--help')
112 @imports(_from='mozbuild.backend', _import='backends')
113 def build_backends_choices(help):
114     return tuple(backends)
117 @deprecated_option('--enable-build-backend', nargs='+',
118                    choices=build_backends_choices)
119 def build_backend(backends):
120     if backends:
121         return tuple('+%s' % b for b in backends)
123 imply_option('--build-backends', build_backend)
126 @depends('--enable-artifact-builds', '--disable-compile-environment', '--help')
127 @imports('sys')
128 def build_backend_defaults(artifact_builds, compile_environment, _):
129     if artifact_builds:
130         all_backends = ['FasterMake+RecursiveMake']
131     else:
132         all_backends = ['RecursiveMake', 'FasterMake']
133     # Normally, we'd use target.os == 'WINNT', but a dependency on target
134     # would require target to depend on --help, as well as host and shell,
135     # and this is not a can of worms we can open at the moment.
136     if sys.platform == 'win32' and compile_environment:
137         all_backends.append('VisualStudio')
138     return tuple(all_backends)
140 option('--build-backends', nargs='+', default=build_backend_defaults,
141        choices=build_backends_choices, help='Build backends to generate')
143 @depends('--build-backends')
144 def build_backends(backends):
145     return backends
147 set_config('BUILD_BACKENDS', build_backends)
150 # Awk detection
151 # ==============================================================
152 awk = check_prog('AWK', ('gawk', 'mawk', 'nawk', 'awk'))
154 # Until the AWK variable is not necessary in old-configure
155 @depends(awk)
156 def awk_for_old_configure(value):
157     return value
159 add_old_configure_assignment('AWK', awk_for_old_configure)
162 # Perl detection
163 # ==============================================================
164 perl = check_prog('PERL', ('perl5', 'perl'))
166 # Until the PERL variable is not necessary in old-configure
167 @depends(perl)
168 def perl_for_old_configure(value):
169     return value
171 add_old_configure_assignment('PERL', perl_for_old_configure)
173 @template
174 def perl_version_check(min_version):
175     @depends(perl)
176     @checking('for minimum required perl version >= %s' % min_version)
177     def get_perl_version(perl):
178         return Version(check_cmd_output(
179             perl, '-e', 'print $]',
180             onerror=lambda: die('Failed to get perl version.')
181         ))
183     @depends(get_perl_version)
184     def check_perl_version(version):
185         if version < min_version:
186             die('Perl %s or higher is required.', min_version)
188     @depends(perl)
189     @checking('for full perl installation')
190     @imports('subprocess')
191     def has_full_perl_installation(perl):
192         ret = subprocess.call(
193             [perl, '-e', 'use Config; exit(!-d $Config{archlib})'])
194         return ret == 0
196     @depends(has_full_perl_installation)
197     def require_full_perl_installation(has_full_perl_installation):
198         if not has_full_perl_installation:
199             die('Cannot find Config.pm or $Config{archlib}. '
200                 'A full perl installation is required.')
202 perl_version_check('5.006')
205 # Miscellaneous programs
206 # ==============================================================
207 check_prog('DOXYGEN', ('doxygen',), allow_missing=True)
208 check_prog('XARGS', ('xargs',))
210 @depends(target)
211 def extra_programs(target):
212     if target.kernel == 'Darwin':
213         return namespace(
214             DSYMUTIL=('dsymutil', 'llvm-dsymutil'),
215             GENISOIMAGE=('genisoimage',),
216         )
217     if target.os == 'GNU' and target.kernel == 'Linux':
218         return namespace(RPMBUILD=('rpmbuild',))
220 check_prog('DSYMUTIL', delayed_getattr(extra_programs, 'DSYMUTIL'),
221            allow_missing=True)
222 check_prog('GENISOIMAGE', delayed_getattr(extra_programs, 'GENISOIMAGE'),
223            allow_missing=True)
224 check_prog('RPMBUILD', delayed_getattr(extra_programs, 'RPMBUILD'),
225            allow_missing=True)
227 option('--enable-system-hunspell',
228        help="Use system hunspell (located with pkgconfig)")
230 @depends('--enable-system-hunspell', compile_environment)
231 def check_for_hunspell(value, compile_env):
232     return value and compile_env
234 system_hunspell = pkg_check_modules('MOZ_HUNSPELL', 'hunspell',
235                                     check_for_hunspell)
237 set_config('MOZ_SYSTEM_HUNSPELL', system_hunspell)
239 # Fallthrough to autoconf-based configure
240 include('build/moz.configure/old.configure')
241 # Please do not add anything after the include of old.configure.