summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2003-08-16 04:19:30 (GMT)
committerSteven Knight <knight@baldmt.com>2003-08-16 04:19:30 (GMT)
commit9d21228a092cc048be6e60053d0ed739eec5b629 (patch)
treed2447f2650bf7782e58826ad0c16364496722d1c /src/engine
parent601839d06d9563854ce22a615d6670a7651cd858 (diff)
downloadSCons-9d21228a092cc048be6e60053d0ed739eec5b629.zip
SCons-9d21228a092cc048be6e60053d0ed739eec5b629.tar.gz
SCons-9d21228a092cc048be6e60053d0ed739eec5b629.tar.bz2
Branch for User's Guide changes.
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/SCons/Defaults.py2
-rw-r--r--src/engine/SCons/Environment.py10
-rw-r--r--src/engine/SCons/EnvironmentTests.py51
3 files changed, 60 insertions, 3 deletions
diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py
index 87420aa..5ade3e0 100644
--- a/src/engine/SCons/Defaults.py
+++ b/src/engine/SCons/Defaults.py
@@ -257,7 +257,7 @@ class NullCmdGenerator:
def __init__(self, cmd):
self.cmd = cmd
- def __call__(self, target, source, env):
+ def __call__(self, target, source, env, for_signature=None):
return self.cmd
ConstructionEnvironment = {
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py
index d0a22b5..fae86e4 100644
--- a/src/engine/SCons/Environment.py
+++ b/src/engine/SCons/Environment.py
@@ -165,7 +165,7 @@ class Environment:
"""
def __init__(self,
- platform=SCons.Platform.Platform(),
+ platform=None,
tools=None,
options=None,
**kw):
@@ -174,6 +174,10 @@ class Environment:
self._dict['BUILDERS'] = BuilderDict(self._dict['BUILDERS'], self)
+ if platform is None:
+ platform = self._dict.get('PLATFORM', None)
+ if platform is None:
+ platform = SCons.Platform.Platform()
if SCons.Util.is_String(platform):
platform = SCons.Platform.Platform(platform)
self._dict['PLATFORM'] = str(platform)
@@ -189,7 +193,9 @@ class Environment:
options.Update(self)
if tools is None:
- tools = ['default']
+ tools = self._dict.get('TOOLS', None)
+ if tools is None:
+ tools = ['default']
apply_tools(self, tools)
# Reapply the passed in variables after calling the tools,
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index 5038419..e79ce7c 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -909,11 +909,37 @@ class EnvironmentTestCase(unittest.TestCase):
def __call__(self, env): env['XYZZY'] = 777
def tool(env):
+ env['SET_TOOL'] = 'initialized'
assert env['PLATFORM'] == "TestPlatform"
env = Environment(platform = platform(), tools = [tool])
assert env['XYZZY'] == 777, env
assert env['PLATFORM'] == "TestPlatform"
+ assert env['SET_TOOL'] == "initialized"
+
+ def test_Default_PLATFORM(self):
+ """Test overriding the default PLATFORM variable"""
+ class platform:
+ def __str__(self): return "DefaultTestPlatform"
+ def __call__(self, env): env['XYZZY'] = 888
+
+ def tool(env):
+ env['SET_TOOL'] = 'abcde'
+ assert env['PLATFORM'] == "DefaultTestPlatform"
+
+ import SCons.Defaults
+ save = SCons.Defaults.ConstructionEnvironment.copy()
+ try:
+ import SCons.Defaults
+ SCons.Defaults.ConstructionEnvironment.update({
+ 'PLATFORM' : platform(),
+ })
+ env = Environment(tools = [tool])
+ assert env['XYZZY'] == 888, env
+ assert env['PLATFORM'] == "DefaultTestPlatform"
+ assert env['SET_TOOL'] == "abcde"
+ finally:
+ SCons.Defaults.ConstructionEnvironment = save
def test_tools(self):
"""Test specifying a tool callable when instantiating."""
@@ -932,6 +958,31 @@ class EnvironmentTestCase(unittest.TestCase):
t4(env)
assert env['TOOL4'] == 444, env
+ def test_Default_TOOLS(self):
+ """Test overriding the default TOOLS variable"""
+ def t5(env):
+ env['TOOL5'] = 555
+ def t6(env):
+ env['TOOL6'] = 666
+ def t7(env):
+ env['BBB'] = env['XYZ']
+ def t8(env):
+ env['TOOL8'] = 888
+
+ import SCons.Defaults
+ save = SCons.Defaults.ConstructionEnvironment.copy()
+ try:
+ SCons.Defaults.ConstructionEnvironment.update({
+ 'TOOLS' : [t5, t6, t7],
+ })
+ env = Environment(XYZ = 'bbb')
+ assert env['TOOL5'] == 555, env['TOOL5']
+ assert env['TOOL6'] == 666, env
+ assert env['BBB'] == 'bbb', env
+ t8(env)
+ assert env['TOOL8'] == 888, env
+ finally:
+ SCons.Defaults.ConstructionEnvironment = save
def test_get(self):
"""Test the get() method."""