2016-03-24 02:36:23 +03:00
|
|
|
# -*- 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)
|
|
|
|
|
2016-03-24 09:26:32 +03:00
|
|
|
@depends_if(yasm)
|
2016-03-24 02:36:23 +03:00
|
|
|
@checking('yasm version')
|
2016-03-27 05:40:13 +03:00
|
|
|
@imports('subprocess')
|
2016-03-24 02:36:23 +03:00
|
|
|
def yasm_version(yasm):
|
2016-03-24 09:26:32 +03:00
|
|
|
try:
|
|
|
|
version = Version(subprocess.check_output(
|
|
|
|
[yasm, '--version']
|
|
|
|
).splitlines()[0].split()[1])
|
|
|
|
return version
|
|
|
|
except subprocess.CalledProcessError as e:
|
2016-03-25 09:48:21 +03:00
|
|
|
die('Failed to get yasm version: %s', e.message)
|
2016-03-24 02:36:23 +03:00
|
|
|
|
|
|
|
# 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)
|
2016-03-25 15:14:59 +03:00
|
|
|
|
|
|
|
|
|
|
|
# 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)
|
2016-03-27 05:40:13 +03:00
|
|
|
@imports(_from='mozbuild.shellutil', _import='split', _as='shell_split')
|
2016-03-25 15:14:59 +03:00
|
|
|
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)
|