зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1278415 - Make the buildconfig module use MozbuildObject.from_environment. r=gps
The buildconfig module predates MozbuildObject.from_environment, and it's about time to start factoring things out such that we only have one way to get config.status data. This is step 1: making the buildconfig module use MozbuildObject.from_environment. Eventually, we'll want to remove the buildconfig module uses everywhere.
This commit is contained in:
Родитель
721ada9f07
Коммит
a4b157940a
|
@ -2,29 +2,19 @@
|
|||
# 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/.
|
||||
|
||||
import imp
|
||||
import os
|
||||
import sys
|
||||
from mozbuild.base import MozbuildObject
|
||||
|
||||
path = os.path.dirname(sys.executable)
|
||||
while not os.path.exists(os.path.join(path, 'config.status')):
|
||||
parent = os.path.normpath(os.path.join(path, os.pardir))
|
||||
if parent == path:
|
||||
raise Exception("Can't find config.status")
|
||||
path = parent
|
||||
config = MozbuildObject.from_environment()
|
||||
|
||||
path = os.path.join(path, 'config.status')
|
||||
config = imp.load_module('_buildconfig', open(path), path, ('', 'r', imp.PY_SOURCE))
|
||||
|
||||
# Copy values from the config.status namespace into this module namespace.
|
||||
# This effectively imports topsrcdir, topobjdir, defines, substs, files,
|
||||
# headers and non_global_defines
|
||||
for var in config.__all__:
|
||||
for var in ('topsrcdir', 'topobjdir', 'defines', 'non_global_defines',
|
||||
'substs'):
|
||||
value = getattr(config, var)
|
||||
if isinstance(value, list) and value and isinstance(value[0], tuple):
|
||||
value = dict(value)
|
||||
setattr(sys.modules[__name__], var, value)
|
||||
|
||||
substs = dict(substs)
|
||||
|
||||
for var in os.environ:
|
||||
if var != 'SHELL' and var in substs:
|
||||
substs[var] = os.environ[var]
|
||||
|
|
|
@ -269,6 +269,10 @@ class MozbuildObject(ProcessExecutionMixin):
|
|||
def defines(self):
|
||||
return self.config_environment.defines
|
||||
|
||||
@property
|
||||
def non_global_defines(self):
|
||||
return self.config_environment.non_global_defines
|
||||
|
||||
@property
|
||||
def substs(self):
|
||||
return self.config_environment.substs
|
||||
|
|
Загрузка…
Ссылка в новой задаче