From e5dced9bf6e4e42051d478c855cc1e1dadea410f Mon Sep 17 00:00:00 2001 From: stevenknight Date: Sat, 8 Jan 2005 20:20:03 +0000 Subject: [PATCH] Remove build engine dependencies on SCons.Script. Fix a misspelled variable name. git-svn-id: http://scons.tigris.org/svn/scons/trunk@1210 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/engine/SCons/Environment.py | 2 +- src/engine/SCons/EnvironmentTests.py | 3 --- src/engine/SCons/SConf.py | 12 +++--------- src/engine/SCons/SConfTests.py | 2 -- src/engine/SCons/Script/SConscript.py | 14 +++++++++++++- src/engine/SCons/Tool/__init__.py | 2 +- src/engine/SCons/Tool/aixc++.py | 3 +-- test/Configure.py | 8 ++++---- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index c98c7aa1..fbc84541 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -1188,7 +1188,7 @@ class Base(SubstitutionEnvironment): if args: nargs = nargs + self.subst_list(args)[0] nkw = self.subst_kw(kw) - nkw['called_from_env_method'] = 1 + nkw['_depth'] = kw.get('_depth', 0) + 1 try: nkw['custom_tests'] = self.subst_kw(nkw['custom_tests']) except KeyError: diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index b34657af..ad5a9b2b 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -2159,9 +2159,6 @@ f5: \ # Configure() will write to a local temporary file. test = TestCmd.TestCmd(workdir = '') save = os.getcwd() - # Configure() will test, if we are reading a SConscript file - import SCons.Script.SConscript - SCons.Script.SConscript.sconscript_reading = 1 try: os.chdir(test.workpath()) diff --git a/src/engine/SCons/SConf.py b/src/engine/SCons/SConf.py index 76df30a8..6b963847 100644 --- a/src/engine/SCons/SConf.py +++ b/src/engine/SCons/SConf.py @@ -326,17 +326,13 @@ class SConf: """ def __init__(self, env, custom_tests = {}, conf_dir='#/.sconf_temp', - log_file='#/config.log', config_h = None, - called_from_env_method = 0): + log_file='#/config.log', config_h = None, _depth = 0): """Constructor. Pass additional tests in the custom_tests-dictinary, e.g. custom_tests={'CheckPrivate':MyPrivateTest}, where MyPrivateTest defines a custom test. Note also the conf_dir and log_file arguments (you may want to build tests in the BuildDir, not in the SourceDir) """ - import SCons.Script.SConscript - if not SCons.Script.SConscript.sconscript_reading: - raise SCons.Errors.UserError, "Calling Configure from Builders is not supported." global SConfFS if not SConfFS: SConfFS = SCons.Node.FS.FS(SCons.Node.FS.default_fs.pathTop) @@ -350,7 +346,7 @@ class SConf: self.logfile = None self.logstream = None self.lastTarget = None - self.called_from_env_method = called_from_env_method + self.depth = _depth self.cached = 0 # will be set, if all test results are cached # add default tests @@ -603,7 +599,7 @@ class SConf: # existing file with the same name in the source directory self.logfile.dir.add_ignore( [self.logfile] ) - tb = traceback.extract_stack()[-3-self.called_from_env_method] + tb = traceback.extract_stack()[-3-self.depth] old_fs_dir = SConfFS.getcwd() SConfFS.chdir(SConfFS.Top, change_os_dir=0) self.logstream.write('file %s,line %d:\n\tConfigure(confdir = %s)\n' % @@ -870,5 +866,3 @@ def CheckLibWithHeader(context, libs, header, language, call = call, language = language, autoadd = autoadd) context.did_show_result = 1 return not res - - diff --git a/src/engine/SCons/SConfTests.py b/src/engine/SCons/SConfTests.py index b704f62e..3cde7d0f 100644 --- a/src/engine/SCons/SConfTests.py +++ b/src/engine/SCons/SConfTests.py @@ -64,8 +64,6 @@ class SConfTestCase(unittest.TestCase): # we only use SCons.Environment and SCons.SConf for these tests. import SCons.Environment import SCons.SConf - import SCons.Script.SConscript - SCons.Script.SConscript.sconscript_reading = 1 self.Environment = SCons.Environment self.SConf = SCons.SConf # and we need a new environment, cause references may point to diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index 4bc8bd31..30f6933d 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -413,6 +413,12 @@ class SConsEnvironment(SCons.Environment.Base): # as global functions. # + def Configure(self, *args, **kw): + if not SCons.Script.SConscript.sconscript_reading: + raise SCons.Errors.UserError, "Calling Configure from Builders is not supported." + kw['_depth'] = kw.get('_depth', 0) + 1 + return apply(SCons.Environment.Base.Configure, (self,)+args, kw) + def Default(self, *targets): global DefaultCalled global DefaultTargets @@ -527,6 +533,12 @@ SCons.Environment.Environment = SConsEnvironment def Options(files=None, args=Arguments): return SCons.Options.Options(files, args) +def Configure(*args, **kw): + if not SCons.Script.SConscript.sconscript_reading: + raise SCons.Errors.UserError, "Calling Configure from Builders is not supported." + kw['_depth'] = 1 + return apply(SCons.SConf.SConf, args, kw) + # _DefaultEnvironmentProxy = None @@ -646,7 +658,7 @@ def BuildDefaultGlobals(): 'Action' : SCons.Action.Action, 'BoolOption' : SCons.Options.BoolOption, 'Builder' : SCons.Builder.Builder, - 'Configure' : SCons.SConf.SConf, + 'Configure' : Configure, 'EnumOption' : SCons.Options.EnumOption, 'Environment' : SCons.Environment.Environment, 'ListOption' : SCons.Options.ListOption, diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 5513f5e4..1cfe6eff 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -179,7 +179,7 @@ def createLoadableModuleBuilder(env): """ try: - loadable_module = env['BUILDERS']['LoadableModule'] + ld_module = env['BUILDERS']['LoadableModule'] except KeyError: action_list = [ SCons.Defaults.SharedCheck, SCons.Defaults.LdModuleLinkAction ] diff --git a/src/engine/SCons/Tool/aixc++.py b/src/engine/SCons/Tool/aixc++.py index dcc444ab..91aa92e7 100644 --- a/src/engine/SCons/Tool/aixc++.py +++ b/src/engine/SCons/Tool/aixc++.py @@ -36,7 +36,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os.path import SCons.Platform.aix -import SCons.Script.SConscript cplusplus = __import__('c++', globals(), locals(), []) @@ -48,7 +47,7 @@ def get_xlc(env): return SCons.Platform.aix.get_xlc(env, xlc, xlc_r, packages) def smart_cxxflags(source, target, env, for_signature): - build_dir = SCons.Script.SConscript.GetBuildPath() + build_dir = env.GetBuildPath() if build_dir: return '-qtempinc=' + os.path.join(build_dir, 'tempinc') return '' diff --git a/test/Configure.py b/test/Configure.py index 2309904c..715219ed 100644 --- a/test/Configure.py +++ b/test/Configure.py @@ -85,6 +85,10 @@ def checklib(lang, name, up_to_date): elif lang == 'C++': return (".cc", _obj, _exe) +class NoMatch: + def __init__(self, p): + self.pos = p + NCR = 0 # non-cached rebuild CR = 1 # cached rebuild (up to date) NCF = 2 # non-cached build failure @@ -93,10 +97,6 @@ CF = 3 # cached build failure def checkLogAndStdout(checks, results, cached, test, logfile, sconf_dir, sconstruct, doCheckLog=1, doCheckStdout=1): - class NoMatch: - def __init__(self, p): - self.pos = p - def matchPart(log, logfile, lastEnd): m = re.match(log, logfile[lastEnd:]) if not m: -- 2.26.2