Bug 1406668 - Make build/moz.configure/*.configure compliant to the pep8 format + add to the list of directories to check r=glandium

MozReview-Commit-ID: 89NxxGUVjHV

--HG--
extra : rebase_source : 3d22007ea6793961e7031603efe58cdc66e3c6c9
This commit is contained in:
Sylvestre Ledru 2017-10-11 16:28:29 +02:00
Родитель b8394ce023
Коммит 4e4de3339f
16 изменённых файлов: 277 добавлений и 38 удалений

Просмотреть файл

@ -11,6 +11,7 @@ js_option('--with-android-ndk', nargs=1,
js_option('--with-android-toolchain', nargs=1,
help='location of the Android toolchain')
@depends(target)
def min_android_version(target):
if target.cpu in ['aarch64', 'x86_64', 'mips64']:
@ -18,11 +19,13 @@ def min_android_version(target):
return '21'
return '9'
js_option('--with-android-version',
nargs=1,
help='android platform version',
default=min_android_version)
@depends('--with-android-version', min_android_version, '--help')
@imports(_from='__builtin__', _import='ValueError')
def android_version(value, min_version, _):
@ -41,8 +44,10 @@ def android_version(value, min_version, _):
return version
add_old_configure_assignment('android_version', android_version)
@depends('--with-android-ndk', build_project, '--help')
def ndk(value, build_project, help):
if help:
@ -53,9 +58,11 @@ def ndk(value, build_project, help):
if value:
return value[0]
set_config('ANDROID_NDK', ndk)
add_old_configure_assignment('android_ndk', ndk)
@depends(ndk)
@checking('for android ndk version')
@imports(_from='__builtin__', _import='open')
@ -73,6 +80,7 @@ def ndk_version(ndk):
die('Unexpected Pkg.Revision line in source.properties')
die('Cannot determine NDK version from source.properties')
@depends(ndk_version)
def ndk_major_version(ndk_version):
if not ndk_version:
@ -83,7 +91,9 @@ def ndk_major_version(ndk_version):
return major
die('Unexpected NDK version string: ' + ndk_version)
set_config('ANDROID_NDK_MAJOR_VERSION', ndk_major_version);
set_config('ANDROID_NDK_MAJOR_VERSION', ndk_major_version)
@depends(ndk_version)
def ndk_minor_version(ndk_version):
@ -95,7 +105,9 @@ def ndk_minor_version(ndk_version):
return minor
die('Unexpected NDK version string: ' + ndk_version)
set_config('ANDROID_NDK_MINOR_VERSION', ndk_minor_version);
set_config('ANDROID_NDK_MINOR_VERSION', ndk_minor_version)
@depends(target, android_version, ndk, '--help')
@checking('for android platform directory')
@ -131,8 +143,10 @@ def android_platform(target, android_version, ndk, _):
return platform_dir
add_old_configure_assignment('android_platform', android_platform)
@depends(android_platform)
def extra_toolchain_flags(platform_dir):
if not platform_dir:
@ -140,6 +154,7 @@ def extra_toolchain_flags(platform_dir):
return ['-idirafter',
os.path.join(platform_dir, 'usr', 'include')]
@depends(target, host, ndk, '--with-android-toolchain', '--help')
@checking('for the Android toolchain directory', lambda x: x or 'not found')
@imports(_from='os.path', _import='isdir')
@ -175,8 +190,10 @@ def android_toolchain(target, host, ndk, toolchain, _):
die('You have to specify --with-android-toolchain='
'/path/to/ndk/toolchain.')
set_config('ANDROID_TOOLCHAIN', android_toolchain)
@depends(target)
def android_toolchain_prefix_base(target):
if target.cpu == 'x86':
@ -185,11 +202,13 @@ def android_toolchain_prefix_base(target):
return 'i686-linux-android'
return target.toolchain
@depends(android_toolchain_prefix_base, android_toolchain)
def android_toolchain_prefix(prefix_base, toolchain):
if toolchain:
return '%s/bin/%s-' % (toolchain, prefix_base)
imply_option('--with-toolchain-prefix', android_toolchain_prefix,
reason='--with-android-ndk')
@ -197,6 +216,7 @@ option(env='STLPORT_CPPFLAGS',
nargs=1,
help='Options compiler should pass for standard C++ library')
@depends('STLPORT_CPPFLAGS', ndk, '--help')
@imports(_from='os.path', _import='isdir')
def stlport_cppflags(value, ndk, _):
@ -231,8 +251,10 @@ def stlport_cppflags(value, ndk, _):
'support', 'include'),
cxxabi_include)
add_old_configure_assignment('stlport_cppflags', stlport_cppflags)
@depends(stlport_cppflags, android_platform, android_toolchain,
android_toolchain_prefix_base, '--help')
def bindgen_cflags_defaults(stlport_cppflags, android_platform, toolchain,
@ -240,7 +262,8 @@ def bindgen_cflags_defaults(stlport_cppflags, android_platform, toolchain,
if not stlport_cppflags:
return
gcc_include = os.path.join(toolchain, 'lib', 'gcc', toolchain_prefix, '4.9')
gcc_include = os.path.join(
toolchain, 'lib', 'gcc', toolchain_prefix, '4.9')
cflags_format = "%s -isystem %s -gcc-toolchain %s -I%s -I%s"
return cflags_format % (stlport_cppflags,

Просмотреть файл

@ -11,6 +11,8 @@
# lot of them, let's stack them all here. When adding a new one, put it in the
# _declare_exceptions template, and add it to the return statement. Then
# destructure in the assignment below the function declaration.
@template
@imports(_from='__builtin__', _import='Exception')
def _declare_exceptions():
@ -21,6 +23,7 @@ def _declare_exceptions():
printed out.'''
return (FatalCheckError,)
(FatalCheckError,) = _declare_exceptions()
del _declare_exceptions
@ -42,6 +45,8 @@ del _declare_exceptions
# ...
# An optional callback can be given, that will be used to format the returned
# value when displaying it.
@template
def checking(what, callback=None):
def decorator(func):

Просмотреть файл

@ -68,6 +68,8 @@ def check_header(header, language='C++', flags=None, includes=None, when=None):
# provided headers.
# - `headers` are the headers to be checked.
# - `kwargs` are keyword arguments passed verbatim to check_header.
@template
def check_headers(*headers, **kwargs):
checks = []
@ -80,6 +82,7 @@ def check_headers(*headers, **kwargs):
def warnings_cflags():
return []
@dependable
def warnings_cxxflags():
return []
@ -149,6 +152,8 @@ def check_and_add_gcc_warning(warning, compiler=None, when=None, check=True):
# is added for both compilers.
# - `when` (optional) is a @depends function or option name conditioning
# when the warning flag is wanted.
@template
def add_gcc_warning(warning, compiler=None, when=None):
check_and_add_gcc_warning(warning, compiler, when, check=False)

Просмотреть файл

@ -4,6 +4,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@template
@imports('textwrap')
@imports(_from='mozbuild.configure', _import='SandboxDependsFunction')
@ -54,9 +55,10 @@ def compiler_class(compiler, host_or_target):
flags.append('-c')
if try_invoke_compiler(
compiler.wrapper + [compiler.compiler] + compiler.flags,
compiler.language, source, flags,
onerror=onerror) is not None:
compiler.wrapper +
[compiler.compiler] + compiler.flags,
compiler.language, source, flags,
onerror=onerror) is not None:
return True
return func

Просмотреть файл

@ -72,7 +72,9 @@ js_option('--with-linux-headers',
help='location where the Linux kernel headers can be found',
nargs=1)
passed_linux_header_flags = depends_if('--with-linux-headers')(lambda v: ['-I%s' % v[0]])
passed_linux_header_flags = depends_if(
'--with-linux-headers')(lambda v: ['-I%s' % v[0]])
@depends(try_compile(includes=['asm/unistd.h'],
body='return sizeof(__NR_perf_event_open);',
@ -83,11 +85,14 @@ def have_perf_event_open(have_perf_event_open):
if have_perf_event_open:
return True
set_config('HAVE_LINUX_PERF_EVENT_H', have_perf_event_open)
@depends(passed_linux_header_flags, have_perf_event_open)
def linux_headers_includes(passed_linux_header_flags, have_perf_event_open):
if have_perf_event_open and passed_linux_header_flags:
return passed_linux_header_flags[0]
set_config('LINUX_HEADERS_INCLUDES', linux_headers_includes)

Просмотреть файл

@ -11,6 +11,8 @@ option(env='DIST', nargs=1, help='DIST directory')
# Do not allow objdir == srcdir builds.
# ==============================================================
@depends('--help', 'DIST')
@imports(_from='os.path', _import='exists')
def check_build_environment(help, dist):
@ -42,7 +44,7 @@ def check_build_environment(help, dist):
' * If you are building with a mozconfig, you will need to change your\n'
' * mozconfig to point to a different object directory.\n'
' ***'
)
)
# Check for a couple representative files in the source tree
conflict_files = [
@ -61,10 +63,11 @@ def check_build_environment(help, dist):
' * 2. gmake distclean\n'
' ***'
% ('\n '.join(conflict_files), topsrcdir)
)
)
return result
set_config('TOPSRCDIR', check_build_environment.topsrcdir)
set_config('TOPOBJDIR', check_build_environment.topobjdir)
set_config('MOZ_BUILD_ROOT', check_build_environment.topobjdir)
@ -91,11 +94,13 @@ option(env='MOZCONFIG', nargs=1, help='Mozconfig location')
option('--with-external-source-dir', env='EXTERNAL_SOURCE_DIR', nargs=1,
help='External directory containing additional build files')
@depends('--with-external-source-dir')
def external_source_dir(value):
if value:
return value[0]
set_config('EXTERNAL_SOURCE_DIR', external_source_dir)
add_old_configure_assignment('EXTERNAL_SOURCE_DIR', external_source_dir)
@ -104,6 +109,8 @@ add_old_configure_assignment('EXTERNAL_SOURCE_DIR', external_source_dir)
# Note: the dependency on --help is only there to always read the mozconfig,
# even when --help is passed. Without this dependency, the function wouldn't
# be called when --help is passed, and the mozconfig wouldn't be read.
@depends('MOZ_CURRENT_PROJECT', 'MOZCONFIG', 'OLD_CONFIGURE',
check_build_environment, '--with-external-source-dir',
'--help')
@ -143,6 +150,7 @@ def mozconfig(current_project, mozconfig, old_configure, build_env,
return mozconfig
set_config('MOZCONFIG', depends(mozconfig)(lambda m: m['path']))
@ -150,6 +158,8 @@ option(env='PYTHON', nargs=1, help='Python interpreter')
# Setup python virtualenv
# ==============================================================
@depends('PYTHON', check_build_environment, mozconfig, '--help')
@imports('os')
@imports('sys')
@ -193,7 +203,8 @@ def virtualenv_python(env_python, build_env, mozconfig, help):
# If we're not in the virtualenv, we need the which module for
# find_program.
if normsep(sys.executable) != normsep(manager.python_path):
sys.path.append(os.path.join(topsrcdir, 'third_party', 'python', 'which'))
sys.path.append(os.path.join(
topsrcdir, 'third_party', 'python', 'which'))
found_python = find_program(python)
if not found_python:
die('The PYTHON environment variable does not contain '
@ -222,6 +233,7 @@ def virtualenv_python(env_python, build_env, mozconfig, help):
return python
set_config('PYTHON', virtualenv_python)
add_old_configure_assignment('PYTHON', virtualenv_python)
@ -229,6 +241,8 @@ add_old_configure_assignment('PYTHON', virtualenv_python)
# ==============================================================
# All options defined above this point can't be injected in mozconfig_options
# below, so collect them.
@template
def early_options():
@dependable
@ -241,8 +255,10 @@ def early_options():
)
return early_options
early_options = early_options()
@depends(mozconfig, 'MOZ_AUTOMATION', '--help')
# This gives access to the sandbox. Don't copy this blindly.
@imports('__sandbox__')
@ -293,6 +309,8 @@ option(env='CONFIG_SHELL', nargs=1, help='Path to a POSIX shell')
# It feels dirty replicating this from python/mozbuild/mozbuild/mozconfig.py,
# but the end goal being that the configure script would go away...
@depends('CONFIG_SHELL', 'MOZILLABUILD')
@checking('for a shell')
@imports('sys')
@ -312,6 +330,7 @@ def shell(value, mozillabuild):
option(env='PYTHON3', nargs=1, help='Python 3 interpreter (3.5 or later)')
@depends('PYTHON3')
@checking('for Python 3',
callback=lambda x: '%s (%s)' % (x.path, x.str_version) if x else 'no')
@ -348,12 +367,14 @@ def python3(env_python):
str_version='.'.join(str(v) for v in version),
)
set_config('PYTHON3', depends_if(python3)(lambda p: p.path))
set_config('PYTHON3_VERSION', depends_if(python3)(lambda p: p.str_version))
# Source checkout and version control integration.
# ================================================
@depends(check_build_environment, 'MOZ_AUTOMATION', '--help')
@checking('for vcs source checkout')
@imports('os')
@ -369,12 +390,14 @@ def vcs_checkout_type(build_env, automation, _):
# Resolve VCS binary for detected repository type.
# TODO remove hg.exe once bug 1382940 addresses ambiguous executables case.
hg = check_prog('HG', ('hg.exe', 'hg',), allow_missing=True,
when=depends(vcs_checkout_type)(lambda x: x == 'hg'))
git = check_prog('GIT', ('git',), allow_missing=True,
when=depends(vcs_checkout_type)(lambda x: x == 'git'))
@depends_if(hg)
@checking('for Mercurial version')
@imports('os')
@ -390,7 +413,8 @@ def hg_version(hg):
match = re.search(r'Mercurial Distributed SCM \(version ([^\)]+)', out)
if not match:
raise FatalCheckError('unable to determine Mercurial version: %s' % out)
raise FatalCheckError(
'unable to determine Mercurial version: %s' % out)
# The version string may be "unknown" for Mercurial run out of its own
# source checkout or for bad builds. But LooseVersion handles it.
@ -400,6 +424,8 @@ def hg_version(hg):
# Resolve Mercurial config items so other checks have easy access.
# Do NOT set this in the config because it may contain sensitive data
# like API keys.
@depends_all(check_build_environment, hg, hg_version)
@imports('os')
def hg_config(build_env, hg, version):
@ -430,6 +456,7 @@ def hg_config(build_env, hg, version):
return config
@depends_if(git)
@checking('for Git version')
@imports('re')
@ -446,6 +473,8 @@ def git_version(git):
# Only set VCS_CHECKOUT_TYPE if we resolved the VCS binary.
# Require resolved VCS info when running in automation so automation's
# environment is more well-defined.
@depends(vcs_checkout_type, hg_version, git_version, 'MOZ_AUTOMATION')
def exposed_vcs_checkout_type(vcs_checkout_type, hg, git, automation):
if vcs_checkout_type == 'hg':
@ -464,9 +493,12 @@ def exposed_vcs_checkout_type(vcs_checkout_type, hg, git, automation):
elif vcs_checkout_type:
raise FatalCheckError('unhandled VCS type: %s' % vcs_checkout_type)
set_config('VCS_CHECKOUT_TYPE', exposed_vcs_checkout_type)
# Obtain a Repository interface for the current VCS repository.
@depends(check_build_environment, exposed_vcs_checkout_type, hg, git)
@imports(_from='mozversioncontrol', _import='get_repository_object')
def vcs_repository(build_env, vcs_checkout_type, hg, git):
@ -477,11 +509,13 @@ def vcs_repository(build_env, vcs_checkout_type, hg, git):
elif vcs_checkout_type:
raise FatalCheckError('unhandled VCS type: %s' % vcs_checkout_type)
@depends_if(vcs_repository)
@checking('for sparse checkout')
def vcs_sparse_checkout(repo):
return repo.sparse_checkout_present()
set_config('VCS_SPARSE_CHECKOUT', vcs_sparse_checkout)
# Host and target systems
@ -492,6 +526,7 @@ option('--target', nargs=1,
help='Define the system type where the resulting executables will be '
'used')
@imports(_from='mozbuild.configure.constants', _import='CPU')
@imports(_from='mozbuild.configure.constants', _import='CPU_bitness')
@imports(_from='mozbuild.configure.constants', _import='Endianness')
@ -664,6 +699,7 @@ def host(value, shell):
return split_triplet(config_sub(shell, host))
host = help_host_target | host
@ -674,6 +710,7 @@ def target(value, host, shell):
return host
return split_triplet(config_sub(shell, value[0]))
target = help_host_target | target
@ -682,6 +719,7 @@ target = help_host_target | target
def cross_compiling(host, target):
return host != target
set_config('CROSS_COMPILE', cross_compiling)
set_define('CROSS_COMPILE', cross_compiling)
add_old_configure_assignment('CROSS_COMPILE', cross_compiling)
@ -692,25 +730,32 @@ def have_64_bit(target):
if target.bitness == 64:
return True
set_config('HAVE_64BIT_BUILD', have_64_bit)
set_define('HAVE_64BIT_BUILD', have_64_bit)
add_old_configure_assignment('HAVE_64BIT_BUILD', have_64_bit)
@depends(host)
def host_os_kernel_major_version(host):
versions = host.raw_os.split('.')
version = ''.join(x for x in versions[0] if x.isdigit())
return version
set_config('HOST_MAJOR_VERSION', host_os_kernel_major_version)
# Autoconf needs these set
@depends(host)
def host_for_old_configure(host):
return '--host=%s' % host.alias
add_old_configure_arg(host_for_old_configure)
@depends(target)
def target_for_old_configure(target):
target_alias = target.alias
@ -720,6 +765,7 @@ def target_for_old_configure(target):
target_alias = target_alias.replace('-ios', '-darwin')
return '--target=%s' % target_alias
add_old_configure_arg(target_for_old_configure)
@ -750,6 +796,7 @@ def target_variables(target):
INTEL_ARCHITECTURE=target.cpu in ('x86', 'x86_64') or None,
)
set_config('OS_TARGET', target_variables.OS_TARGET)
add_old_configure_assignment('OS_TARGET',
target_variables.OS_TARGET)
@ -776,61 +823,76 @@ def host_variables(host):
HOST_OS_ARCH=os_arch,
)
set_config('HOST_CPU_ARCH', host.cpu)
set_config('HOST_OS_ARCH', host_variables.HOST_OS_ARCH)
add_old_configure_assignment('HOST_OS_ARCH',
host_variables.HOST_OS_ARCH)
@depends(target)
def target_is_windows(target):
if target.kernel == 'WINNT':
return True
set_define('_WINDOWS', target_is_windows)
set_define('WIN32', target_is_windows)
set_define('XP_WIN', target_is_windows)
set_define('XP_WIN32', target_is_windows)
@depends(target)
def target_is_unix(target):
if target.kernel != 'WINNT':
return True
set_define('XP_UNIX', target_is_unix)
@depends(target)
def target_is_darwin(target):
if target.kernel == 'Darwin':
return True
set_define('XP_DARWIN', target_is_darwin)
@depends(target)
def target_is_ios(target):
if target.kernel == 'Darwin' and target.os == 'iOS':
return True
set_define('XP_IOS', target_is_ios)
@depends(target)
def target_is_osx(target):
if target.kernel == 'Darwin' and target.os == 'OSX':
return True
set_define('XP_MACOSX', target_is_osx)
@depends(target)
def target_is_linux(target):
if target.kernel == 'Linux':
return True
set_define('XP_LINUX', target_is_linux)
@depends(target)
def target_is_solaris(target):
if target.kernel == 'SunOS':
return True
set_define('XP_SOLARIS', target_is_solaris)
# The application/project to build
@ -838,11 +900,13 @@ set_define('XP_SOLARIS', target_is_solaris)
option('--enable-application', nargs=1, env='MOZ_BUILD_APP',
help='Application to build. Same as --enable-project.')
@depends('--enable-application', '--help')
def application(app, help):
if app:
return app
imply_option('--enable-project', application)
@ -852,9 +916,11 @@ def default_project(build_env, help):
return 'js'
return 'browser'
option('--enable-project', nargs=1, default=default_project,
help='Project to build')
@depends('--enable-project', '--with-external-source-dir',
check_build_environment, '--help')
@imports(_from='os.path', _import='exists')
@ -878,6 +944,7 @@ def build_project(include_project_configure, build_env, help):
build_env.topsrcdir))
return ret
set_config('MOZ_BUILD_APP', build_project)
set_define('MOZ_BUILD_APP', build_project)
add_old_configure_assignment('MOZ_BUILD_APP', build_project)
@ -908,6 +975,7 @@ def milestone(build_env, _):
is_nightly=is_nightly,
is_release_or_beta=is_release_or_beta)
set_config('GRE_MILESTONE', milestone.version)
set_config('NIGHTLY_BUILD', milestone.is_nightly)
set_define('NIGHTLY_BUILD', milestone.is_nightly)
@ -925,12 +993,14 @@ option('--enable-update-channel',
help='Select application update channel',
default='default')
@depends('--enable-update-channel')
def update_channel(channel):
if channel[0] == '':
return 'default'
return channel[0].lower()
set_config('MOZ_UPDATE_CHANNEL', update_channel)
set_define('MOZ_UPDATE_CHANNEL', update_channel)
add_old_configure_assignment('MOZ_UPDATE_CHANNEL', update_channel)
@ -949,7 +1019,8 @@ def project_flag(env=None, set_for_old_configure=False,
set_as_define=False, **kwargs):
if not env:
configure_error("A project_flag must be passed a variable name to set.")
configure_error(
"A project_flag must be passed a variable name to set.")
opt = option(env=env, possible_origins=('implied',), **kwargs)
@ -967,12 +1038,16 @@ def project_flag(env=None, set_for_old_configure=False,
add_old_configure_assignment(env, option_implementation)
# milestone.is_nightly corresponds to cases NIGHTLY_BUILD is set.
@depends(milestone, '--help')
def enabled_in_nightly(milestone, _):
return milestone.is_nightly
# Set the MOZ_CONFIGURE_OPTIONS variable with all the options that
# were passed somehow (environment, command line, mozconfig)
@dependable
@imports(_from='mozbuild.shellutil', _import='quote')
@imports('__sandbox__')
@ -1004,6 +1079,7 @@ def all_configure_options():
return quote(*result)
set_config('MOZ_CONFIGURE_OPTIONS', all_configure_options)

Просмотреть файл

@ -10,6 +10,7 @@
option('--with-java-bin-path', nargs=1,
help='Location of Java binaries (java, javac, jar)')
@depends('--with-java-bin-path')
@imports(_from='os', _import='environ')
def java_search_paths(path):
@ -25,6 +26,8 @@ def java_search_paths(path):
# Finds the given java tool, failing with a custom error message if we can't
# find it.
@template
def check_java_tool(tool):
check = check_prog(tool.upper(), (tool,), paths=java_search_paths,
@ -40,6 +43,7 @@ def check_java_tool(tool):
return require_tool
check_java_tool('java')
check_java_tool('javah')
check_java_tool('jar')
@ -47,6 +51,7 @@ check_java_tool('jarsigner')
check_java_tool('keytool')
javac = check_java_tool('javac')
@depends(javac)
@checking('for javac version')
@imports('subprocess')

Просмотреть файл

@ -59,7 +59,6 @@ def id_and_secret_keyfile(desc, default=None):
default=default,
callback=id_and_secret)
name = desc.upper().replace(' ', '_')
set_config('MOZ_%s_CLIENTID' % name, content.id)
set_config('MOZ_%s_KEY' % name, content.secret)

Просмотреть файл

@ -13,6 +13,7 @@ def moz_jemalloc4(value):
option('--enable-jemalloc', env='MOZ_MEMORY',
help='Replace memory allocator with jemalloc')
@depends('--enable-jemalloc', target, build_project, c_compiler)
def jemalloc(value, target, build_project, c_compiler):
if value.origin != 'default':
@ -48,12 +49,14 @@ add_old_configure_assignment('MOZ_MEMORY', jemalloc)
def jemalloc_for_old_configure(jemalloc):
return '--%s-jemalloc' % ('enable' if jemalloc else 'disable')
add_old_configure_arg(jemalloc_for_old_configure)
option('--enable-replace-malloc',
help='Enable ability to dynamically replace the malloc implementation')
@depends('--enable-replace-malloc', jemalloc, milestone, build_project)
def replace_malloc(value, jemalloc, milestone, build_project):
# Enable on central for the debugging opportunities it adds.
@ -64,6 +67,7 @@ def replace_malloc(value, jemalloc, milestone, build_project):
if milestone.is_nightly and jemalloc and build_project != 'js':
return True
set_config('MOZ_REPLACE_MALLOC', replace_malloc)
set_define('MOZ_REPLACE_MALLOC', replace_malloc)
add_old_configure_assignment('MOZ_REPLACE_MALLOC', replace_malloc)

Просмотреть файл

@ -4,6 +4,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@imports('codecs')
@imports('sys')
def encoded_open(path, mode):
@ -13,6 +14,7 @@ def encoded_open(path, mode):
option(env='AUTOCONF', nargs=1, help='Path to autoconf 2.13')
@depends(mozconfig, 'AUTOCONF')
@checking('for autoconf')
@imports(_from='os.path', _import='exists')
@ -56,6 +58,7 @@ def autoconf(mozconfig, autoconf):
return autoconf
set_config('AUTOCONF', autoconf)
@ -117,6 +120,7 @@ def prepare_configure(old_configure, mozconfig, autoconf, build_env, shell,
cmd = [shell, old_configure]
with encoded_open('old-configure.vars', 'w') as out:
log.debug('Injecting the following to old-configure:')
def inject(command):
print(command, file=out)
log.debug('| %s', command)
@ -360,7 +364,7 @@ def old_configure(prepare_configure, extra_old_configure_args, all_options,
# Every variation of the exec() function I tried led to:
# SyntaxError: unqualified exec is not allowed in function 'main' it
# contains a nested function with free variables
exec code in raw_config
exec code in raw_config # noqa
# Ensure all the flags known to old-configure appear in the
# @old_configure_options above.
@ -384,6 +388,8 @@ def set_old_configure_config(name, value):
__sandbox__.set_config_impl(name, value)
# Same as set_old_configure_config, but for set_define.
@imports('__sandbox__')
def set_old_configure_define(name, value):
__sandbox__.set_define_impl(name, value)

Просмотреть файл

@ -4,13 +4,16 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@depends('--enable-compile-environment')
def pkg_config(compile_env):
if compile_env:
return ('pkg-config',)
pkg_config = check_prog('PKG_CONFIG', pkg_config, allow_missing=True)
@depends_if(pkg_config)
@checking('for pkg-config version')
@imports('subprocess')
@ -29,6 +32,8 @@ def pkg_config_version(pkg_config):
# will not result in an error or logged message, and any error message
# will be returned to the caller.
# Returns `True` when the package description is fulfilled.
@template
def pkg_check_modules(var, package_desc, when=always,
allow_missing=False):

Просмотреть файл

@ -9,6 +9,7 @@
rustc = check_prog('RUSTC', ['rustc'], allow_missing=True)
cargo = check_prog('CARGO', ['cargo'], allow_missing=True)
@depends_if(rustc)
@checking('rustc version', lambda info: info.version)
def rustc_info(rustc):
@ -19,6 +20,7 @@ def rustc_info(rustc):
commit=info.get('commit-hash', 'unknown'),
)
@depends_if(cargo)
@checking('cargo version', lambda info: info.version)
@imports('re')
@ -43,6 +45,7 @@ def cargo_info(cargo):
version=Version(version),
)
@depends(rustc_info, cargo_info)
@imports(_from='textwrap', _import='dedent')
def rust_compiler(rustc_info, cargo_info):
@ -173,7 +176,8 @@ def rust_triple_alias(host_or_target):
(host_or_target.cpu, host_or_target_raw_os))
if rustc_target is None:
die("Don't know how to translate {} for rustc".format(host_or_target.alias))
die("Don't know how to translate {} for rustc".format(
host_or_target.alias))
# Check to see whether our rustc has a reasonably functional stdlib
# for our chosen target.
@ -197,6 +201,7 @@ def rust_triple_alias(host_or_target):
'-o', out_path,
in_path,
]
def failed():
die(dedent('''\
Cannot compile for {} with {}
@ -217,15 +222,18 @@ def rust_triple_alias(host_or_target):
return rust_target
rust_target_triple = rust_triple_alias(target)
rust_host_triple = rust_triple_alias(host)
set_config('RUST_TARGET', rust_target_triple)
set_config('RUST_HOST_TARGET', rust_host_triple)
@depends(rust_target_triple)
def rust_target_env_name(triple):
return triple.upper().replace('-','_')
return triple.upper().replace('-', '_')
# We need this to form various Cargo environment variables, as there is no
# uppercase function in make, and we don't want to shell out just for

Просмотреть файл

@ -15,6 +15,7 @@ add_old_configure_assignment('MOZ_PGO', depends('MOZ_PGO')(lambda x: bool(x)))
# ==============================================================
yasm = check_prog('YASM', ['yasm'], allow_missing=True)
@depends_if(yasm)
@checking('yasm version')
def yasm_version(yasm):
@ -24,6 +25,7 @@ def yasm_version(yasm):
).splitlines()[0].split()[1]
return Version(version)
# Until we move all the yasm consumers out of old-configure.
# bug 1257904
add_old_configure_assignment('_YASM_MAJOR_VERSION',
@ -31,6 +33,7 @@ add_old_configure_assignment('_YASM_MAJOR_VERSION',
add_old_configure_assignment('_YASM_MINOR_VERSION',
yasm_version.minor)
@depends(yasm, target)
def yasm_asflags(yasm, target):
if yasm:
@ -51,13 +54,16 @@ def yasm_asflags(yasm, target):
asflags += ' -rnasm -pnasm'
return asflags
set_config('YASM_ASFLAGS', yasm_asflags)
@depends(yasm_asflags)
def have_yasm(value):
if value:
return True
set_config('HAVE_YASM', have_yasm)
# Until the YASM variable is not necessary in old-configure.
add_old_configure_assignment('YASM', have_yasm)
@ -65,10 +71,12 @@ add_old_configure_assignment('YASM', have_yasm)
# Android NDK
# ==============================================================
@depends('--disable-compile-environment', build_project, '--help')
def compiling_android(compile_env, build_project, _):
return compile_env and build_project in ('mobile/android', 'js')
include('android-ndk.configure', when=compiling_android)
# MacOS deployment target version
@ -78,6 +86,7 @@ include('android-ndk.configure', when=compiling_android)
option('--enable-macos-target', env='MACOSX_DEPLOYMENT_TARGET', nargs=1,
default='10.7', help='Set the minimum MacOS version needed at runtime')
@depends('--enable-macos-target', target)
@imports(_from='os', _import='environ')
def macos_target(value, target):
@ -97,7 +106,8 @@ add_old_configure_assignment('MACOSX_DEPLOYMENT_TARGET', macos_target)
# ===========
js_option('--disable-xcode-checks',
help='Do not check that Xcode is installed and properly configured')
help='Do not check that Xcode is installed and properly configured')
@depends(host, '--disable-xcode-checks')
def xcode_path(host, xcode_checks):
@ -127,12 +137,13 @@ def xcode_path(host, xcode_checks):
'Xcode Command Line Tools installed, '
'add the --disable-xcode-checks configure flag')
res = check_cmd_output('pkgutil', '--pkg-info',
'com.apple.pkg.CLTools_Executables',
onerror=no_cltools)
check_cmd_output('pkgutil', '--pkg-info',
'com.apple.pkg.CLTools_Executables',
onerror=no_cltools)
return xcode_path
set_config('XCODE_PATH', xcode_path)
@ -148,6 +159,7 @@ option('--with-compiler-wrapper', env='COMPILER_WRAPPER', nargs=1,
option('--with-ccache', env='CCACHE', nargs='?',
help='Enable compiling with ccache')
@depends_if('--with-ccache')
def ccache(value):
if len(value):
@ -156,32 +168,42 @@ def ccache(value):
# 'ccache'.
return 'ccache'
ccache = check_prog('CCACHE', progs=(), input=ccache)
# Distinguish ccache from sccache.
@depends_if(ccache)
def ccache_is_sccache(ccache):
return check_cmd_output(ccache, '--version').startswith('sccache')
@depends(ccache, ccache_is_sccache)
def using_ccache(ccache, ccache_is_sccache):
return ccache and not ccache_is_sccache
@depends_if(ccache, ccache_is_sccache)
def using_sccache(ccache, ccache_is_sccache):
return ccache and ccache_is_sccache
set_config('MOZ_USING_CCACHE', using_ccache)
set_config('MOZ_USING_SCCACHE', using_sccache)
option(env='SCCACHE_VERBOSE_STATS', help='Print verbose sccache stats after build')
option(env='SCCACHE_VERBOSE_STATS',
help='Print verbose sccache stats after build')
@depends(using_sccache, 'SCCACHE_VERBOSE_STATS')
def sccache_verbose_stats(using_sccache, verbose_stats):
return using_sccache and bool(verbose_stats)
set_config('SCCACHE_VERBOSE_STATS', sccache_verbose_stats)
@depends('--with-compiler-wrapper', ccache)
@imports(_from='mozbuild.shellutil', _import='split', _as='shell_split')
def compiler_wrapper(wrapper, ccache):
@ -202,12 +224,15 @@ def compiler_wrapper(wrapper, ccache):
elif wrapper:
return tuple(wrapper)
add_old_configure_assignment('COMPILER_WRAPPER', compiler_wrapper)
@depends_if(compiler_wrapper)
def using_compiler_wrapper(compiler_wrapper):
return True
set_config('MOZ_USING_COMPILER_WRAPPER', using_compiler_wrapper)
@ -215,11 +240,13 @@ set_config('MOZ_USING_COMPILER_WRAPPER', using_compiler_wrapper)
# ==============================================================
option(env='MOZ_HAZARD', help='Build for the GC rooting hazard analysis')
@depends('MOZ_HAZARD')
def hazard_analysis(value):
if value:
return True
set_config('MOZ_HAZARD', hazard_analysis)
@ -228,6 +255,7 @@ set_config('MOZ_HAZARD', hazard_analysis)
js_option('--with-toolchain-prefix', env='TOOLCHAIN_PREFIX', nargs=1,
help='Prefix for the target toolchain')
@depends('--with-toolchain-prefix', target, cross_compiling)
def toolchain_prefix(value, target, cross_compiling):
if value:
@ -235,6 +263,7 @@ def toolchain_prefix(value, target, cross_compiling):
if cross_compiling:
return ('%s-' % target.toolchain, '%s-' % target.alias)
@depends(toolchain_prefix, target)
def first_toolchain_prefix(toolchain_prefix, target):
# Pass TOOLCHAIN_PREFIX down to the build system if it was given from the
@ -243,6 +272,7 @@ def first_toolchain_prefix(toolchain_prefix, target):
if toolchain_prefix and (target.os == 'Android' or len(toolchain_prefix) == 1):
return toolchain_prefix[0]
set_config('TOOLCHAIN_PREFIX', first_toolchain_prefix)
add_old_configure_assignment('TOOLCHAIN_PREFIX', first_toolchain_prefix)
@ -251,9 +281,11 @@ add_old_configure_assignment('TOOLCHAIN_PREFIX', first_toolchain_prefix)
# ==============================================================
include('compilers-util.configure')
def try_preprocess(compiler, language, source):
return try_invoke_compiler(compiler, language, source, ['-E'])
@imports(_from='mozbuild.configure.constants', _import='CompilerType')
@imports(_from='mozbuild.configure.constants',
_import='CPU_preprocessor_checks')
@ -432,7 +464,7 @@ def check_compiler(compiler, language, target):
# GCC 4.9 indicates that it implements draft C++14 features
# instead of the full language.
elif info.type == 'gcc' and not \
(info.language_version == draft_cxx14_version or info.language_version == cxx14_version):
(info.language_version == draft_cxx14_version or info.language_version == cxx14_version):
append_flag('-std=gnu++14')
# We force clang-cl to emulate Visual C++ 2015 Update 3.
@ -501,24 +533,29 @@ def get_vc_paths(topsrcdir):
# Then VS2017 and newer.
for install in vswhere(['-requires', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64']):
path = install['installationPath']
tools_version = open(os.path.join(path, r'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt'), 'rb').read().strip()
tools_path = os.path.join(path, r'VC\Tools\MSVC', tools_version, r'bin\HostX64')
tools_version = open(os.path.join(
path, r'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt'), 'rb').read().strip()
tools_path = os.path.join(
path, r'VC\Tools\MSVC', tools_version, r'bin\HostX64')
yield (Version(install['installationVersion']), {
'x64': [os.path.join(tools_path, 'x64')],
# The x64->x86 cross toolchain requires DLLs from the native x64 toolchain.
'x86': [os.path.join(tools_path, 'x86'), os.path.join(tools_path, 'x64')],
})
js_option('--with-visual-studio-version', nargs=1,
choices=('2015', '2017'),
help='Select a specific Visual Studio version to use')
@depends('--with-visual-studio-version')
def vs_major_version(value):
if value:
return {'2015': 14,
'2017': 15}[value[0]]
@depends(host, target, vs_major_version, check_build_environment, '--with-visual-studio-version')
@imports(_from='__builtin__', _import='sorted')
@imports(_from='operator', _import='itemgetter')
@ -538,7 +575,8 @@ def vc_compiler_path(host, target, vs_major_version, env, vs_release_name):
if not all_versions:
return
if vs_major_version:
versions = [d for (v, d) in all_versions if v.major == vs_major_version]
versions = [d for (v, d) in all_versions if v.major ==
vs_major_version]
if not versions:
die('Visual Studio %s could not be found!' % vs_release_name)
data = versions[0]
@ -654,7 +692,7 @@ def compiler(language, host_or_target, c_compiler=None, other_compiler=None,
'C++': lambda: default_cxx_compilers(c_compiler),
}[language]()
what='the %s %s compiler' % (host_or_target_str, language)
what = 'the %s %s compiler' % (host_or_target_str, language)
option(env=var, nargs=1, help='Path to %s' % what)
@ -887,7 +925,6 @@ def compiler(language, host_or_target, c_compiler=None, other_compiler=None,
valid_compiler.try_compile(check_msg='%s works' % what,
onerror=compiler_error)
# Set CPP/CXXCPP for both the build system and old-configure. We don't
# need to check this works for preprocessing, because we already relied
# on $CC -E/$CXX -E doing preprocessing work to validate the compiler
@ -899,7 +936,7 @@ def compiler(language, host_or_target, c_compiler=None, other_compiler=None,
}[language]
preprocessor = depends_if(valid_compiler)(
lambda x: list(x.wrapper) + [x.compiler, '-E'] + list(x.flags))
lambda x: list(x.wrapper) + [x.compiler, '-E'] + list(x.flags))
set_config(pp_var, preprocessor)
add_old_configure_assignment(pp_var, preprocessor)
@ -942,6 +979,7 @@ host_cxx_compiler = compiler('C++', host, c_compiler=host_c_compiler,
non_msvc_compiler = depends(c_compiler)(lambda info: info.type != 'msvc')
building_with_gcc = depends(c_compiler)(lambda info: info.type == 'gcc')
@depends(c_compiler)
def msvs_version(info):
# clang-cl emulates the same version scheme as cl. And MSVS_VERSION needs to
@ -954,10 +992,12 @@ def msvs_version(info):
return ''
set_config('MSVS_VERSION', msvs_version)
include('compile-checks.configure')
@depends(have_64_bit,
try_compile(body='static_assert(sizeof(void *) == 8, "")',
check_msg='for 64-bit OS'))
@ -966,11 +1006,13 @@ def check_have_64_bit(have_64_bit, compiler_have_64_bit):
configure_error('The target compiler does not agree with configure '
'about the target bitness.')
option(env='BINDGEN_CFLAGS',
nargs=1,
default=bindgen_cflags_defaults,
help='Options bindgen should pass to the C/C++ parser')
@depends('BINDGEN_CFLAGS')
@checking('bindgen cflags', lambda s: s if s and s.strip() else 'no')
def bindgen_cflags(value):
@ -980,8 +1022,10 @@ def bindgen_cflags(value):
return ', '.join('"' + flag + '"' for flag in flags)
return ''
set_config('BINDGEN_CFLAGS', bindgen_cflags)
@depends(c_compiler)
def default_debug_flags(compiler_info):
# Debug info is ON by default.
@ -989,6 +1033,7 @@ def default_debug_flags(compiler_info):
return '-Zi'
return '-g'
option(env='MOZ_DEBUG_FLAGS',
nargs=1,
help='Debug compiler flags')
@ -1004,6 +1049,7 @@ js_option('--enable-debug-symbols',
set_config('MOZ_DEBUG_SYMBOLS',
depends_if('--enable-debug-symbols')(lambda _: True))
@depends('MOZ_DEBUG_FLAGS', '--enable-debug-symbols', default_debug_flags)
def debug_flags(env_debug_flags, enable_debug_flags, default_debug_flags):
# If MOZ_DEBUG_FLAGS is set, and --enable-debug-symbols is set to a value,
@ -1015,9 +1061,11 @@ def debug_flags(env_debug_flags, enable_debug_flags, default_debug_flags):
return env_debug_flags[0]
return default_debug_flags
set_config('MOZ_DEBUG_FLAGS', debug_flags)
add_old_configure_assignment('MOZ_DEBUG_FLAGS', debug_flags)
@depends(c_compiler)
def color_cflags(info):
# We could test compiling with flags. By why incur the overhead when
@ -1037,6 +1085,7 @@ def color_cflags(info):
else:
return ''
set_config('COLOR_CFLAGS', color_cflags)
# Some standard library headers (notably bionic on Android) declare standard
@ -1078,16 +1127,21 @@ set_config('COLOR_CFLAGS', color_cflags)
#
# _LIBCPP_ALWAYS_INLINE needs similar workarounds, since it too declares
# hidden visibility.
@depends(c_compiler, target)
def libcxx_override_visibility(c_compiler, target):
if c_compiler.type == 'clang' and target.os == 'Android':
return ''
set_define('_LIBCPP_INLINE_VISIBILITY', libcxx_override_visibility)
set_define('_LIBCPP_INLINE_VISIBILITY_EXCEPT_GCC49', libcxx_override_visibility)
set_define('_LIBCPP_INLINE_VISIBILITY_EXCEPT_GCC49',
libcxx_override_visibility)
set_define('_LIBCPP_ALWAYS_INLINE', libcxx_override_visibility)
set_define('_LIBCPP_ALWAYS_INLINE_EXCEPT_GCC49', libcxx_override_visibility)
@depends(target, check_build_environment)
def visibility_flags(target, env):
if target.os != 'WINNT':
@ -1097,11 +1151,13 @@ def visibility_flags(target, env):
'-include',
'%s/config/gcc_hidden.h' % env.topsrcdir)
@depends(target, visibility_flags)
def wrap_system_includes(target, visibility_flags):
if visibility_flags and target.kernel != 'Darwin':
return True
set_define('HAVE_VISIBILITY_HIDDEN_ATTRIBUTE',
depends(visibility_flags)(lambda v: bool(v) or None))
set_define('HAVE_VISIBILITY_ATTRIBUTE',
@ -1109,6 +1165,7 @@ set_define('HAVE_VISIBILITY_ATTRIBUTE',
set_config('WRAP_SYSTEM_INCLUDES', wrap_system_includes)
set_config('VISIBILITY_FLAGS', visibility_flags)
@depends(c_compiler)
@imports('multiprocessing')
@imports(_from='__builtin__', _import='min')
@ -1142,6 +1199,7 @@ def pgo_flags(compiler):
use_ldflags=['-LTCG:PGUPDATE', cgthreads],
)
set_config('PROFILE_GEN_CFLAGS', pgo_flags.gen_cflags)
set_config('PROFILE_GEN_LDFLAGS', pgo_flags.gen_ldflags)
set_config('PROFILE_USE_CFLAGS', pgo_flags.use_cflags)
@ -1149,10 +1207,13 @@ set_config('PROFILE_USE_LDFLAGS', pgo_flags.use_ldflags)
# We only want to include windows.configure when we are compiling on
# Windows, for Windows.
@depends(target, host)
def is_windows(target, host):
return host.kernel == 'WINNT' and target.kernel == 'WINNT'
include('windows.configure', when=is_windows)
# Shader Compiler for Windows (and MinGW Cross Compile)
@ -1169,11 +1230,13 @@ wine = check_prog('WINE', ['wine'], when=depends(target, host)
option('--enable-hardening', env='MOZ_SECURITY_HARDENING',
help='Enables security hardening compiler options')
@depends('--enable-hardening', c_compiler)
def security_hardening_cflags(value, c_compiler):
if value and c_compiler.type in ['gcc', 'clang']:
return '-fstack-protector-strong'
add_old_configure_assignment('HARDENING_CFLAGS', security_hardening_cflags)
imply_option('--enable-pie', depends_if('--enable-hardening')(lambda v: v))
@ -1190,17 +1253,20 @@ js_option('--enable-release',
help='Build with more conservative, release engineering-oriented '
'options. This may slow down builds.')
@depends('--enable-release')
def developer_options(value):
if not value:
return True
add_old_configure_assignment('DEVELOPER_OPTIONS', developer_options)
set_config('DEVELOPER_OPTIONS', developer_options)
# Linker detection
# ==============================================================
@depends(target)
def is_linker_option_enabled(target):
if target.kernel not in ('Darwin', 'WINNT', 'SunOS'):
@ -1229,7 +1295,8 @@ def enable_gnu_linker(enable_gold_option, c_compiler, developer_options, build_e
targetDir = os.path.join(build_env.topobjdir, 'build', 'unix', 'gold')
gold_detection_arg = '-print-prog-name=ld.gold'
gold = check_cmd_output(c_compiler.compiler, gold_detection_arg).strip()
gold = check_cmd_output(c_compiler.compiler,
gold_detection_arg).strip()
if not gold:
return
@ -1285,11 +1352,13 @@ def enable_gnu_linker(enable_gold_option, c_compiler, developer_options, build_e
KIND='other'
)
js_option('--enable-linker', nargs=1,
choices=('bfd', 'gold', 'lld', 'other'),
help='Select the linker',
when=is_linker_option_enabled)
@depends('--enable-linker', c_compiler, developer_options, check_build_environment,
extra_toolchain_flags, when=is_linker_option_enabled)
@checking('for linker', lambda x: x.KIND)
@ -1300,7 +1369,8 @@ def select_linker(linker, c_compiler, developer_options, build_env, toolchain_fl
build_env, toolchain_flags, linker)
if linker == 'lld':
version_check = ['-Wl,--version']
cmd_base = c_compiler.wrapper + [c_compiler.compiler] + c_compiler.flags
cmd_base = c_compiler.wrapper + \
[c_compiler.compiler] + c_compiler.flags
lld = "-fuse-ld=" + linker
cmd = cmd_base + [lld] + version_check
if 'LLD' in check_cmd_output(*cmd).decode('utf-8'):
@ -1312,19 +1382,22 @@ def select_linker(linker, c_compiler, developer_options, build_env, toolchain_fl
die("Could not use lld as linker")
set_config('LD_IS_BFD', depends(select_linker.KIND)(lambda x: x == 'bfd' or None))
set_config('LD_IS_BFD', depends(select_linker.KIND)
(lambda x: x == 'bfd' or None))
set_config('LINKER_LDFLAGS', select_linker.LINKER_FLAG)
# Code Coverage
# ==============================================================
js_option('--enable-coverage', env='MOZ_CODE_COVERAGE',
help='Enable code coverage')
help='Enable code coverage')
@depends('--enable-coverage')
def code_coverage(value):
if value:
return True
set_config('MOZ_CODE_COVERAGE', code_coverage)
set_define('MOZ_CODE_COVERAGE', code_coverage)

Просмотреть файл

@ -4,6 +4,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@imports('sys')
def die(*args):
'Print an error and terminate configure.'
@ -22,6 +23,8 @@ def configure_error(message):
# by running the given command if it exits normally, and streams that
# output to log.debug and calls die or the given error callback if it
# does not.
@imports(_from='__builtin__', _import='unicode')
@imports('subprocess')
@imports('sys')
@ -67,6 +70,7 @@ def check_cmd_output(*args, **kwargs):
die('Command `%s` failed with exit status %d.' %
(quote(*args), retcode))
@imports('os')
def is_absolute_or_relative(path):
if os.altsep and os.altsep in path:
@ -88,7 +92,8 @@ def windows_binary_type(path):
Returns WindowsBinaryType constant.
"""
GetBinaryTypeW = ctypes.windll.kernel32.GetBinaryTypeW
GetBinaryTypeW.argtypes = [wintypes.LPWSTR, wintypes.POINTER(wintypes.DWORD)]
GetBinaryTypeW.argtypes = [wintypes.LPWSTR,
wintypes.POINTER(wintypes.DWORD)]
GetBinaryTypeW.restype = wintypes.BOOL
bin_type = wintypes.DWORD()
@ -147,6 +152,7 @@ def normalize_path():
return normalize_path
normalize_path = normalize_path()
@ -364,6 +370,8 @@ def Version(v):
# The function may handle the option like a typical @depends function would,
# but it is recommended it emits a deprecation error message suggesting an
# alternative option to use if there is one.
@template
def deprecated_option(*args, **kwargs):
assert 'help' not in kwargs
@ -414,6 +422,7 @@ def depends_tmpl(eval_args_fn, *args, **kwargs):
when = kwargs['when']
else:
when = None
def decorator(func):
@depends(*args, when=when)
def wrapper(*args):
@ -444,10 +453,12 @@ def depends_all(*args, **kwargs):
def old_configure_assignments():
return []
@dependable
def extra_old_configure_args():
return []
@template
def add_old_configure_assignment(var, value):
var = dependable(var)
@ -467,6 +478,7 @@ def add_old_configure_assignment(var, value):
value = quote(*value)
assignments.append('%s=%s' % (var, quote(str(value))))
@template
def add_old_configure_arg(arg):
@depends(extra_old_configure_args, arg)

Просмотреть файл

@ -8,6 +8,7 @@ option('--with-windows-version', nargs=1, default='603',
help='Windows SDK version to target. Win 8.1 (603) is currently'
'the minimum supported version.')
@depends('--with-windows-version')
@imports(_from='__builtin__', _import='ValueError')
def valid_windows_version(value):
@ -26,6 +27,7 @@ def valid_windows_version(value):
option(env='WINDOWSSDKDIR', nargs=1,
help='Directory containing the Windows SDK')
@depends('WINDOWSSDKDIR', host)
def windows_sdk_dir(value, host):
if value:
@ -44,6 +46,8 @@ def windows_sdk_dir(value, host):
# The $SDK/lib directories always have version subdirectories, but while the
# versions match the one in $SDK/include for SDK 10, it's "winv6.3" for SDK
# 8.1.
@imports('os')
@imports('re')
@imports(_from='__builtin__', _import='sorted')
@ -89,6 +93,7 @@ def valid_windows_sdk_dir_result(value):
if value:
return '0x%04x in %s' % (value.version, quote(value.path))
@depends(c_compiler, windows_sdk_dir, valid_windows_version, 'WINDOWSSDKDIR')
@checking('for Windows SDK', valid_windows_sdk_dir_result)
@imports(_from='__builtin__', _import='sorted')
@ -165,6 +170,7 @@ def valid_ucrt_sdk_dir_result(value):
if value:
return '%s in %s' % (value.version, quote(value.path))
@depends(windows_sdk_dir, 'WINDOWSSDKDIR')
@checking('for Universal CRT SDK', valid_ucrt_sdk_dir_result)
@imports('os')
@ -226,7 +232,7 @@ def valid_ucrt_sdk_dir(windows_sdk_dir, windows_sdk_dir_env):
if version < minimum_ucrt_version:
raise FatalCheckError('Latest Universal CRT SDK version found %s'
' and minimum required is %s.'
% (version, minimum_ucrt_version))
% (version, minimum_ucrt_version))
return namespace(
path=sdk.path,
@ -267,7 +273,8 @@ def dia_sdk_dir(vc_path, c_compiler):
else:
# This would be easier if we had the installationPath that
# get_vc_paths works with, since 'DIA SDK' is relative to that.
path = os.path.normpath(os.path.join(vc_path, r'..\..\..\..\DIA SDK'))
path = os.path.normpath(os.path.join(
vc_path, r'..\..\..\..\DIA SDK'))
if isdir(path):
return path
@ -306,6 +313,7 @@ def include_path(vc_path, windows_sdk_dir, ucrt_sdk_dir, dia_sdk_dir):
os.environ['INCLUDE'] = includes
return includes
set_config('INCLUDE', include_path)
@ -363,11 +371,13 @@ def lib_path(target, c_compiler, vc_path, windows_sdk_dir, ucrt_sdk_dir, dia_sdk
os.environ['LIB'] = libs
return libs
set_config('LIB', lib_path)
option(env='MT', nargs=1, help='Path to the Microsoft Manifest Tool')
@depends(valid_windows_sdk_dir, valid_ucrt_sdk_dir)
@imports(_from='os', _import='environ')
@imports('platform')
@ -408,7 +418,7 @@ def valid_mt(path):
out = '\n'.join(l for l in out
if 'Microsoft (R) Manifest Tool' in l)
if out:
return path
return path
except subprocess.CalledProcessError:
pass
raise FatalCheckError('%s is not Microsoft Manifest Tool')
@ -433,7 +443,7 @@ def alter_path(sdk_bin_path):
os.environ['PATH'] = path
return path
set_config('PATH', alter_path)
check_prog('MAKECAB', ('makecab.exe',))

Просмотреть файл

@ -2,6 +2,7 @@
flake8:
description: Python linter
include:
- build/moz.configure/*.configure
- config/check_macroassembler_style.py
- config/mozunit.py
- layout/tools/reftest