build/buildconfig.py

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

     1 # This Source Code Form is subject to the terms of the Mozilla Public
     2 # License, v. 2.0. If a copy of the MPL was not distributed with this
     3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
     5 import imp
     6 import os
     7 import sys
     9 path = os.path.dirname(__file__)
    10 while not os.path.exists(os.path.join(path, 'config.status')):
    11     parent = os.path.normpath(os.path.join(path, os.pardir))
    12     if parent == path:
    13         raise Exception("Can't find config.status")
    14     path = parent
    16 path = os.path.join(path, 'config.status')
    17 config = imp.load_module('_buildconfig', open(path), path, ('', 'r', imp.PY_SOURCE))
    19 # Copy values from the config.status namespace into this module namespace.
    20 # This effectively imports topsrcdir, topobjdir, defines, substs, files,
    21 # headers and non_global_defines
    22 for var in config.__all__:
    23     value = getattr(config, var)
    24     if isinstance(value, list) and value and isinstance(value[0], tuple):
    25         value = dict(value)
    26     setattr(sys.modules[__name__], var, value)
    28 for var in os.environ:
    29     if var != 'SHELL' and var in substs:
    30         substs[var] = os.environ[var]

mercurial