author Mike Hommey <>
Fri, 25 Mar 2016 21:14:59 +0900
changeset 290987 352568360a612b1cca16f2083a981276d3c81502
parent 290971 f97bcb2eaf41b62bb7d222f8a627a45e17fbbf54
child 290992 f4e24db79431e447e3f6b2758ec6dba4dca817c2
permissions -rw-r--r--
Bug 1259381 - Move --with-ccache and --with-compiler-wrapper to moz.configure. r=chmanchester

# -*- 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):
    import subprocess
        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)
def compiler_wrapper(wrapper, ccache):
    from mozbuild.shellutil import split as shell_split
    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)