DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (fabc3d5da6cb)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
# -*- 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 http://mozilla.org/MPL/2.0/.

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

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

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

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

    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

@depends(tup)
@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, cargo)
@imports('re')
def check_tup_cargo_channel(tup, cargo):
    channel = None
    out = check_cmd_output(cargo, '--version')
    VERSION_FORMAT = r'cargo \d\.\d+\.\d+-(\S+)'
    m = re.match(VERSION_FORMAT, out)
    if m:
        channel = m.group(1)
    if tup and channel != 'nightly':
        die('Nightly Cargo is required when building with Tup.')

@depends(tup, target, build_project)
def tup_and_non_linux(tup, target, build_project):
    if tup and (target.kernel != 'Linux' or build_project != 'browser'):
        die('The tup backend can only be used to build the browser on Linux. '
            'Use the make backend until your target is supported.')

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

@depends('--upload-tup-db')
def upload_tdb(value):
    if value:
        return True

set_config('UPLOAD_TUP_DB', upload_tdb)