gecko-dev/build/moz.configure/toolchain.configure

134 строки
4.4 KiB
Python

# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# 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/.
# yasm detection
# ==============================================================
yasm = check_prog('YASM', ['yasm'], allow_missing=True)
@depends_if(yasm)
@checking('yasm version')
@imports('subprocess')
def yasm_version(yasm):
try:
version = Version(subprocess.check_output(
[yasm, '--version']
).splitlines()[0].split()[1])
return version
except subprocess.CalledProcessError as e:
die('Failed to get yasm version: %s', e.message)
# Until we move all the yasm consumers out of old-configure.
# bug 1257904
add_old_configure_assignment('_YASM_MAJOR_VERSION',
delayed_getattr(yasm_version, 'major'))
add_old_configure_assignment('_YASM_MINOR_VERSION',
delayed_getattr(yasm_version, 'minor'))
@depends(yasm, target)
def yasm_asflags(yasm, target):
if yasm:
asflags = {
('OSX', 'x86'): '-f macho32',
('OSX', 'x86_64'): '-f macho64',
('WINNT', 'x86'): '-f win32',
('WINNT', 'x86_64'): '-f x64',
}.get((target.os, target.cpu), None)
if asflags is None:
# We're assuming every x86 platform we support that's
# not Windows or Mac is ELF.
if target.cpu == 'x86':
asflags = '-f elf32'
elif target.cpu == 'x86_64':
asflags = '-f elf64'
if asflags:
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)
# Android NDK
# ==============================================================
@depends('--disable-compile-environment', build_project, '--help')
def android_ndk_include(compile_env, build_project, _):
if compile_env and build_project in ('mobile/android', 'js'):
return 'android-ndk.configure'
include(android_ndk_include)
# Compiler wrappers
# ==============================================================
js_option('--with-compiler-wrapper', env='COMPILER_WRAPPER', nargs=1,
help='Enable compiling with wrappers such as distcc and ccache')
js_option('--with-ccache', env='CCACHE', nargs='?',
help='Enable compiling with ccache')
@depends_if('--with-ccache')
def ccache(value):
if len(value):
return value
# If --with-ccache was given without an explicit value, we default to
# 'ccache'.
return 'ccache'
ccache = check_prog('CCACHE', progs=(), input=ccache)
@depends_if(ccache)
def using_ccache(ccache):
return True
set_config('MOZ_USING_CCACHE', using_ccache)
@depends('--with-compiler-wrapper', ccache)
@imports(_from='mozbuild.shellutil', _import='split', _as='shell_split')
def compiler_wrapper(wrapper, ccache):
if ccache:
if wrapper:
return tuple([ccache] + shell_split(wrapper[0]))
else:
return (ccache,)
elif wrapper:
return tuple(shell_split(wrapper[0]))
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)
# Cross-compilation related things.
# ==============================================================
js_option('--with-toolchain-prefix', env='TOOLCHAIN_PREFIX', nargs=1,
help='Prefix for the target toolchain')
@depends('--with-toolchain-prefix', target, host, cross_compiling)
def toolchain_prefix(value, target, host, cross_compiling):
if value:
return value[0]
# Special case x86-64 <-> x86 cross compiling until we have the right tests
# in moz.configure land.
if cross_compiling and not all(i.cpu in ('x86_64', 'x86')
for i in (target, host)):
return '%s-' % target.toolchain
set_config('TOOLCHAIN_PREFIX', toolchain_prefix)
add_old_configure_assignment('TOOLCHAIN_PREFIX', toolchain_prefix)