|
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/. |
|
4 |
|
5 import imp |
|
6 import os |
|
7 import sys |
|
8 |
|
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 |
|
15 |
|
16 path = os.path.join(path, 'config.status') |
|
17 config = imp.load_module('_buildconfig', open(path), path, ('', 'r', imp.PY_SOURCE)) |
|
18 |
|
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) |
|
27 |
|
28 for var in os.environ: |
|
29 if var != 'SHELL' and var in substs: |
|
30 substs[var] = os.environ[var] |