build/mach_bootstrap.py
author Tom Prince <mozilla@hocat.ca>
Mon, 24 Jul 2017 14:13:51 -0600
changeset 53296 84bff8ee00a5e92861c4862ac61d7952aa6cb0b0
parent 16282 4c46112cb67718e10cd8043d87984ef37b52acbd
child 54079 485076ce2db5bca9bbcbf4e5de4d23889a6467ff
child 54080 f3facce2436394b710d4895c7096ec6d1c6d902c
permissions -rw-r--r--
Make mach ignore comm-central's mach_boostrap.py when it isn't topsrcdir. MozReview-Commit-ID: D7husrPpvaB

# 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/.

from __future__ import unicode_literals

import os, sys

def bootstrap(topsrcdir, mozilla_dir=None):
    if mozilla_dir is None:
        mozilla_dir = os.path.join(topsrcdir, 'mozilla')

    if not os.path.exists(mozilla_dir):
        # If we can't find `mozilla` as a subdirectory of the `comm` checkout,
        # assume that we are a subdirectory of a mozilla checkout. If we return
        # `None` here, the `mach` entrypoint will keep searching for a build
        # directory.  Since the entry point imports this into `sys.modules`,
        # clean it up, since we aren't the `mach_bootstrap` that `mach` is
        # looking for.
        sys.modules['mach_bootstrap'] = None
        return None

    sys.path[0:0] = [mozilla_dir]
    import build.mach_bootstrap
    return build.mach_bootstrap.bootstrap(topsrcdir, mozilla_dir)