author tbirdbld
Wed, 28 Aug 2013 16:07:07 -0400
changeset 149329 0c687b12a2fee2b42f6df703b42b4ed14033a689
parent 140560 861f3c6327a4705c7d4d6d3353ac2ce40b171ea5
child 155640 3fc5338cc5b1fb9b42e2f35bc25e66c516285668
permissions -rwxr-xr-x
Automated checkin: version bump for thunderbird 24.0b2 release. DONTBUILD CLOSED TREE a=release

#!/usr/bin/env 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

from __future__ import print_function, unicode_literals

import os
import sys

def ancestors(path):
    while path:
        yield path
        (path, child) = os.path.split(path)
        if child == "":

def load_mach(topsrcdir):
    sys.path[0:0] = [os.path.join(topsrcdir, "build")]
    import mach_bootstrap
    return mach_bootstrap.bootstrap(topsrcdir)

# Check whether the current directory is within a mach src or obj dir.
for dir_path in ancestors(os.getcwd()):
    # If we find a "mozinfo.json" file, we are in the objdir.
    mozinfo_path = os.path.join(dir_path, "mozinfo.json")
    if os.path.isfile(mozinfo_path):
        import json
        info = json.load(open(mozinfo_path))
        if "mozconfig" in info and "MOZCONFIG" not in os.environ:
            # If the MOZCONFIG environment variable is not already set, set it
            # to the value from mozinfo.json.  This will tell the build system
            # to look for a config file at the path in $MOZCONFIG rather than
            # its default locations.
            # Note: subprocess requires native strings in os.environ Python
            # 2.7.2 and earlier on Windows.
            os.environ[b"MOZCONFIG"] = str(info["mozconfig"])

        if "topsrcdir" in info:
            # Continue searching for mach_bootstrap in the source directory.
            dir_path = info["topsrcdir"]

    # If we find the mach bootstrap module, we are in the srcdir.
    mach_path = os.path.join(dir_path, "build/")
    if os.path.isfile(mach_path):
        mach = load_mach(dir_path)

print("Could not run mach: No mach source directory found")