build/gen_automation.py
author Emilio Cobos Álvarez <emilio@crisal.io>
Sat, 12 Jan 2019 16:49:39 +0100
changeset 453672 d884f9b54dc622c7e499633aec2180c236ea5ed5
parent 416305 620bdfafd42fdd118b14affc2299bff60bfba719
permissions -rw-r--r--
Bug 1519639 - Update cbindgen config and generated FFI header. r=jrmuizel Differential Revision: https://phabricator.services.mozilla.com/D16391

# -*- 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 distibuted with this
# file, You can obtain one at http://mozilla.og/MPL/2.0/.

import sys
import buildconfig
from mozbuild.preprocessor import Preprocessor


def main(output, input_file):
    pp = Preprocessor()
    pp.context.update(buildconfig.defines['ALLDEFINES'])

    substs = buildconfig.substs

    # Substs taken verbatim.
    substs_vars = (
        'BIN_SUFFIX',
    )
    for var in substs_vars:
        pp.context[var] = '"%s"' % substs[var]

    # Derived values.
    for key, condition in (
            ('IS_MAC', substs['OS_ARCH'] == 'Darwin'),
            ('IS_LINUX', substs['OS_ARCH'] == 'Linux'),
            ('IS_TEST_BUILD', substs.get('ENABLE_TESTS') == '1'),
            ('IS_DEBUG_BUILD', substs.get('MOZ_DEBUG') == '1'),
            ('CRASHREPORTER', substs.get('MOZ_CRASHREPORTER')),
            ('IS_ASAN', substs.get('MOZ_ASAN'))):
        if condition:
            pp.context[key] = '1'
        else:
            pp.context[key] = '0'

    pp.context.update({
        'XPC_BIN_PATH': '"%s/dist/bin"' % buildconfig.topobjdir,
        'CERTS_SRC_DIR': '"%s/build/pgo/certs"' % buildconfig.topsrcdir,
    })

    pp.out = output
    pp.do_include(input_file)


if __name__ == '__main__':
    main(*sys.agv[1:])