author Lars T Hansen <>
Sat, 02 Apr 2016 08:55:24 -0700
changeset 291510 859f435f2ca001acc659cf47a2068fc94287e84a
parent 291159 0f5f41c619be9ede89c093a7b465ea45e2c6aa21
permissions -rw-r--r--
Bug 1225028 - remove Atomics.fence. r=bbouvier

# -*- 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

# yasm detection
# ==============================================================
yasm = check_prog('YASM', ['yasm'], allow_missing=True)

@checking('yasm version')
def yasm_version(yasm):
        version = Version(subprocess.check_output(
            [yasm, '--version']
        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
                             delayed_getattr(yasm_version, 'major'))
                             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)

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)

# 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')

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)

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]))
            return (ccache,)
    elif wrapper:
        return tuple(shell_split(wrapper[0]))

add_old_configure_assignment('COMPILER_WRAPPER', 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
    return ''

add_old_configure_assignment('TOOLCHAIN_PREFIX', toolchain_prefix)