author Chris Manchester <>
Tue, 26 Jun 2018 20:32:16 -0700
changeset 423990 93ac072b098daedac96ec44652c6fd441aa4b962
child 426590 b3eb58b5214a01e33a8584b5216f3c06c5d8a39e
permissions -rw-r--r--
Bug 1471425 - Require rustc 1.28 in configure when building with Tup. r=mshal MozReview-Commit-ID: 9FCs5FPcchC

# -*- Mode: python; 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

# tup detection
# ==============================================================

tup = check_prog('TUP', ['tup'])

@checking('for tup version')
def tup_version(tup):
    tup_min_version = '0.7.6'
    out = check_cmd_output(tup, '--version',
                           onerror=lambda: die('Failed to get tup version'))
    m ='tup v?([0-9]+\.[0-9]+\.[0-9]+)', out)

    if not m:
        raise FatalCheckError('Unknown version of tup: %s' % out)
    ver = Version(

    if ver < tup_min_version:
        raise FatalCheckError('To use the tup backend you must have tup version '
                              '%s or greater in your path' % tup_min_version)
    return ver

@checking('for tup ldpreload dependency checker')
def tup_is_ldpreload(tup):
    out = check_cmd_output(tup, 'server',
                           onerror=lambda: die('Failed to get tup dependency checker'))
    if out.rstrip() != 'ldpreload':
        raise FatalCheckError('To use the tup backend, please use a version '
                              'of tup compiled with the ldpreload dependency '
                              'checker. Either compile tup locally with '
                              'CONFIG_TUP_SERVER=ldpreload in your tup.config '
                              'file, or use the version from the toolchain '
                              'task via |./mach artifact toolchain '
                              '--from-build linux64-tup|')
    return True

@depends(tup, using_sccache)
def tup_and_sccache(tup, using_sccache):
    if tup and using_sccache:
        die('Cannot use sccache with tup yet. Please disable sccache or use '
            'the make backend until it is supported.')

@depends(tup, rustc_info)
def check_tup_min_rustc_version(tup, rustc_info):
    min_rustc_version = Version('1.28.0')
    if tup and rustc_info.version < min_rustc_version:
        die('Cannot build with tup and rustc %s. please update to at least '
            'rustc %s to continue.', rustc_info.version, min_rustc_version)

option('--upload-tup-db', help= 'Upload the tup database from an automated build.')

def upload_tdb(value):
    if value:
        return True

set_config('UPLOAD_TUP_DB', upload_tdb)