summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/man/scons.1124
-rw-r--r--rpm/scons.spec8
-rw-r--r--src/CHANGES.txt6
-rw-r--r--src/engine/MANIFEST.in4
-rw-r--r--src/engine/SCons/Action.py9
-rw-r--r--src/engine/SCons/Defaults.py24
-rw-r--r--src/engine/SCons/Environment.py5
-rw-r--r--src/engine/SCons/EnvironmentTests.py7
-rw-r--r--src/engine/SCons/Platform/.aeignore5
-rw-r--r--src/engine/SCons/Platform/PlatformTests.py72
-rw-r--r--src/engine/SCons/Platform/__init__.py92
-rw-r--r--src/engine/SCons/Platform/cygwin.py48
-rw-r--r--src/engine/SCons/Platform/posix.py48
-rw-r--r--src/engine/SCons/Platform/win32.py48
-rw-r--r--src/engine/SCons/Script/SConscript.py2
-rw-r--r--src/setup.py1
-rw-r--r--test/Platform.py63
-rw-r--r--test/option--debug.py2
18 files changed, 501 insertions, 67 deletions
diff --git a/doc/man/scons.1 b/doc/man/scons.1
index a4539de..7df959a 100644
--- a/doc/man/scons.1
+++ b/doc/man/scons.1
@@ -628,8 +628,42 @@ function:
env = Environment()
.EE
-Build rules are specified by calling builder methods on a construction
-environment. The arguments to the builder methods are target (a list of
+By default, a new construction environment is
+initialized with a set of builder methods
+and construction variables that are appropriate
+for the current platform.
+An optional platform keyword argument may be
+used to specify that an environment should
+be initialized for a different platform:
+
+.ES
+env = Environment(platform = 'cygwin')
+env = Environment(platform = 'posix')
+env = Environment(platform = 'win32')
+.EE
+
+Specifying a platform initializes the appropriate
+construction variables in the environment
+to use and generate file names with prefixes
+and suffixes appropriate for the platform.
+
+The platform argument may be function or callable object,
+in which case the Environment() method
+will call the specified argument to update
+the new construction environment:
+
+.ES
+def my_platform(env):
+ env['VAR'] = 'xyzzy'
+
+env = Environment(platform = my_platform)
+.EE
+
+.SS Builder Methods
+
+Build rules are specified by calling a construction
+environment's builder methods.
+The arguments to the builder methods are target (a list of
target files) and source (a list of source files).
If a string is given
for target or source, then
@@ -645,7 +679,7 @@ you must change them by next release.
See the discussion of the Split() function
for more information.
-The following are examples of calling a builder:
+The following are examples of calling the Program builder:
.ES
# The recommended ways to call a builder
@@ -860,7 +894,43 @@ be specified using the
.B Depends
method of a construction environment (see below).
-Additional Environment methods include:
+.SS Other Construction Environment Methods
+Additional construction environment methods include:
+
+.TP
+.RI Alias( alias ", " targets )
+Creates a phony target that
+expands to one or more other targets.
+Returns the Node object representing the alias,
+which exists outside of any file system.
+This Node object, or the alias name,
+may be used as a dependency of any other target,
+including another alias. Alias can be called multiple times for the same
+alias to add additional targets to the alias.
+
+.ES
+env.Alias('install', ['/usr/local/bin', '/usr/local/lib'])
+env.Alias('install', ['/usr/local/man'])
+.EE
+
+.TP
+.RI Append( key = val ", [...])"
+Appends the specified keyword arguments
+to the construction variables in the environment.
+If the Environment does not have
+the specified construction variable,
+it is simply added to the environment.
+If the values of the construction variable
+and the keyword argument are the same type,
+then the two values will be simply added together.
+Otherwise, the construction variable
+and the value of the keyword argument
+are both coerced to lists,
+and the lists are added together.
+
+.ES
+env.Append(CCFLAGS = ' -g', FOO = ['foo.yyy'])
+.EE
.TP
.RI Command( target ", " source ", " commands )
@@ -981,22 +1051,6 @@ Multiple targets can be passed in to a single call to
.BR Precious ().
.TP
-.RI Alias( alias ", " targets )
-Creates a phony target that
-expands to one or more other targets.
-Returns the Node object representing the alias,
-which exists outside of any file system.
-This Node object, or the alias name,
-may be used as a dependency of any other target,
-including another alias. Alias can be called multiple times for the same
-alias to add additional targets to the alias.
-
-.ES
-env.Alias('install', ['/usr/local/bin', '/usr/local/lib'])
-env.Alias('install', ['/usr/local/man'])
-.EE
-
-.TP
.RI Replace( key = val ", [...])"
Replaces construction variables in the Environment
with the specified keyword arguments.
@@ -1006,25 +1060,6 @@ with the specified keyword arguments.
env.Replace(CCFLAGS = '-g', FOO = 'foo.xxx')
.EE
-.TP
-.RI Append( key = val ", [...])"
-Appends the specified keyword arguments
-to the construction variables in the environment.
-If the Environment does not have
-the specified construction variable,
-it is simply added to the environment.
-If the values of the construction variable
-and the keyword argument are the same type,
-then the two values will be simply added together.
-Otherwise, the construction variable
-and the value of the keyword argument
-are both coerced to lists,
-and the lists are added together.
-
-.ES
-env.Append(CCFLAGS = ' -g', FOO = ['foo.yyy'])
-.EE
-
.SS Construction Variables
.\" XXX From Gary Ruben, 23 April 2002:
.\" I think it would be good to have an example with each construction
@@ -1594,6 +1629,17 @@ Import("env", "variable")
.EE
.TP
+.RI Platform( string )
+Returns a callable object
+that can be used to initialize
+a construction environment using the
+platform keyword of the Environment() method.
+
+.ES
+env = Environment(platform = Platform('win32'))
+.EE
+
+.TP
.RI Return( vars )
This tells
.B scons
diff --git a/rpm/scons.spec b/rpm/scons.spec
index 45b3936..635e157 100644
--- a/rpm/scons.spec
+++ b/rpm/scons.spec
@@ -68,6 +68,14 @@ rm -rf $RPM_BUILD_ROOT
/usr/lib/scons/SCons/Node/FS.pyc
/usr/lib/scons/SCons/Node/__init__.py
/usr/lib/scons/SCons/Node/__init__.pyc
+/usr/lib/scons/SCons/Platform/cygwin.py
+/usr/lib/scons/SCons/Platform/cygwin.pyc
+/usr/lib/scons/SCons/Platform/posix.py
+/usr/lib/scons/SCons/Platform/posix.pyc
+/usr/lib/scons/SCons/Platform/win32.py
+/usr/lib/scons/SCons/Platform/win32.pyc
+/usr/lib/scons/SCons/Platform/__init__.py
+/usr/lib/scons/SCons/Platform/__init__.pyc
/usr/lib/scons/SCons/Scanner/C.py
/usr/lib/scons/SCons/Scanner/C.pyc
/usr/lib/scons/SCons/Scanner/Prog.py
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 3797327..965b7a6 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -10,6 +10,12 @@
RELEASE 0.08 -
+ From Steven Knight:
+
+ - Add a "platform=" keyword argument to Environment instantiation,
+ and a separate Platform() method, for more flexible specification
+ of platform-specific environment changes.
+
From Anthony Roach:
- Add a "multi" keyword argument to Builder creation that specifies
diff --git a/src/engine/MANIFEST.in b/src/engine/MANIFEST.in
index e86d601..9194557 100644
--- a/src/engine/MANIFEST.in
+++ b/src/engine/MANIFEST.in
@@ -9,6 +9,10 @@ SCons/exitfuncs.py
SCons/Node/__init__.py
SCons/Node/Alias.py
SCons/Node/FS.py
+SCons/Platform/__init__.py
+SCons/Platform/cygwin.py
+SCons/Platform/posix.py
+SCons/Platform/win32.py
SCons/Scanner/__init__.py
SCons/Scanner/C.py
SCons/Scanner/Prog.py
diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py
index 94af6bd..f8d37ee 100644
--- a/src/engine/SCons/Action.py
+++ b/src/engine/SCons/Action.py
@@ -48,6 +48,8 @@ exitvalmap = {
13 : 126,
}
+default_ENV = None
+
if os.name == 'posix':
def defaultSpawn(cmd, args, env):
@@ -356,8 +358,11 @@ class CommandAction(ActionBase):
try:
ENV = kw['env']['ENV']
except:
- import SCons.Defaults
- ENV = SCons.Defaults.ConstructionEnvironment['ENV']
+ global default_ENV
+ if not default_ENV:
+ import SCons.Environment
+ default_ENV = SCons.Environment.Environment()['ENV']
+ ENV = default_ENV
ret = spawn(cmd_line[0], cmd_line, ENV)
if ret:
return ret
diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py
index 7597169..a7b0dc0 100644
--- a/src/engine/SCons/Defaults.py
+++ b/src/engine/SCons/Defaults.py
@@ -47,6 +47,7 @@ import SCons.Builder
import SCons.Errors
import SCons.Node.Alias
import SCons.Node.FS
+import SCons.Platform
import SCons.Scanner.C
import SCons.Scanner.Prog
import SCons.Util
@@ -452,8 +453,6 @@ def make_win32_env_from_paths(include, lib, path):
'AR' : 'lib',
'ARFLAGS' : '/nologo',
'ARCOM' : '$AR $ARFLAGS /OUT:$TARGET $SOURCES',
- 'SHLIBPREFIX': '',
- 'SHLIBSUFFIX': '.dll',
'LEX' : 'lex',
'LEXFLAGS' : '',
'LEXCOM' : '$LEX $LEXFLAGS -t $SOURCES > $TARGET',
@@ -485,14 +484,6 @@ def make_win32_env_from_paths(include, lib, path):
'BUILDERS' : [Alias, CFile, CXXFile, DVI, Library, Object,
PDF, PostScript, Program],
'SCANNERS' : [CScan],
- 'OBJPREFIX' : '',
- 'OBJSUFFIX' : '.obj',
- 'PROGPREFIX' : '',
- 'PROGSUFFIX' : '.exe',
- 'LIBPREFIX' : '',
- 'LIBPREFIXES': '$LIBPREFIX',
- 'LIBSUFFIX' : '.lib',
- 'LIBSUFFIXES': '$LIBSUFFIX',
'LIBDIRPREFIX' : '/LIBPATH:',
'LIBDIRSUFFIX' : '',
'LIBLINKPREFIX' : '',
@@ -509,7 +500,6 @@ def make_win32_env_from_paths(include, lib, path):
'INCLUDE' : include,
'LIB' : lib,
'PATH' : path,
- 'PATHEXT' : '.COM;.EXE;.BAT;.CMD',
},
}
@@ -567,8 +557,6 @@ if os.name == 'posix':
'RANLIB' : ranlib,
'RANLIBFLAGS' : '',
'ARCOM' : arcom,
- 'SHLIBPREFIX': '$LIBPREFIX',
- 'SHLIBSUFFIX': '.so',
'LEX' : 'lex',
'LEXFLAGS' : '',
'LEXCOM' : '$LEX $LEXFLAGS -t $SOURCES > $TARGET',
@@ -598,21 +586,12 @@ if os.name == 'posix':
'BUILDERS' : [Alias, CFile, CXXFile, DVI, Library, Object,
PDF, PostScript, Program],
'SCANNERS' : [CScan],
- 'OBJPREFIX' : '',
- 'OBJSUFFIX' : '.o',
- 'PROGPREFIX' : '',
- 'PROGSUFFIX' : (sys.platform == 'cygwin') and '.exe' or '',
- 'LIBPREFIX' : 'lib',
- 'LIBPREFIXES': '$LIBPREFIX',
- 'LIBSUFFIX' : '.a',
- 'LIBSUFFIXES': [ '$LIBSUFFIX', '$SHLIBSUFFIX' ],
'LIBDIRPREFIX' : '-L',
'LIBDIRSUFFIX' : '',
'LIBLINKPREFIX' : '-l',
'LIBLINKSUFFIX' : '',
'INCPREFIX' : '-I',
'INCSUFFIX' : '',
- 'ENV' : { 'PATH' : '/usr/local/bin:/bin:/usr/bin' },
}
elif os.name == 'nt':
@@ -662,4 +641,3 @@ elif os.name == 'nt':
include_path,
lib_path,
exe_path)
-
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py
index c5f3407..8c61ceb 100644
--- a/src/engine/SCons/Environment.py
+++ b/src/engine/SCons/Environment.py
@@ -92,9 +92,12 @@ class Environment:
Environment.
"""
- def __init__(self, **kw):
+ def __init__(self, platform=SCons.Platform.Platform(), **kw):
self.fs = SCons.Node.FS.default_fs
self._dict = our_deepcopy(SCons.Defaults.ConstructionEnvironment)
+ if SCons.Util.is_String(platform):
+ platform = SCons.Platform.Platform(platform)
+ platform(self)
apply(self.Replace, (), kw)
#
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index f16632d..3066fc2 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -403,6 +403,13 @@ class EnvironmentTestCase(unittest.TestCase):
assert len(dict['_INCFLAGS']) == 0, dict['_INCFLAGS']
assert len(dict['_LIBDIRFLAGS']) == 0, dict['_LIBDIRFLAGS']
+ def test_platform(self):
+ """Test specifying a platform callable when instantiating."""
+ def p(env):
+ env['XYZZY'] = 777
+ env = Environment(platform = p)
+ assert env['XYZZY'] == 777, env
+
if __name__ == "__main__":
diff --git a/src/engine/SCons/Platform/.aeignore b/src/engine/SCons/Platform/.aeignore
new file mode 100644
index 0000000..22ebd62
--- /dev/null
+++ b/src/engine/SCons/Platform/.aeignore
@@ -0,0 +1,5 @@
+*,D
+*.pyc
+.*.swp
+.consign
+.sconsign
diff --git a/src/engine/SCons/Platform/PlatformTests.py b/src/engine/SCons/Platform/PlatformTests.py
new file mode 100644
index 0000000..e3f5966
--- /dev/null
+++ b/src/engine/SCons/Platform/PlatformTests.py
@@ -0,0 +1,72 @@
+#
+# Copyright (c) 2001, 2002 Steven Knight
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import sys
+import unittest
+
+import SCons.Errors
+import SCons.Platform
+
+class PlatformTestCase(unittest.TestCase):
+ def test_Platform(self):
+ """Test the Platform() function"""
+ p = SCons.Platform.Platform('cygwin')
+ assert str(p) == 'cygwin', p
+ env = {}
+ p(env)
+ assert env['PROGSUFFIX'] == '.exe', env
+ assert env['LIBSUFFIX'] == '.a', env
+
+ p = SCons.Platform.Platform('posix')
+ assert str(p) == 'posix', p
+ env = {}
+ p(env)
+ assert env['PROGSUFFIX'] == '', env
+ assert env['LIBSUFFIX'] == '.a', env
+
+ p = SCons.Platform.Platform('win32')
+ assert str(p) == 'win32', p
+ env = {}
+ p(env)
+ assert env['PROGSUFFIX'] == '.exe', env
+ assert env['LIBSUFFIX'] == '.lib', env
+ assert str
+
+ try:
+ p = SCons.Platform.Platform('_does_not_exist_')
+ except SCons.Errors.UserError:
+ pass
+ else:
+ raise
+
+ env = {}
+ SCons.Platform.Platform()(env)
+ assert env != {}, env
+
+
+if __name__ == "__main__":
+ suite = unittest.makeSuite(PlatformTestCase, 'test_')
+ if not unittest.TextTestRunner().run(suite).wasSuccessful():
+ sys.exit(1)
diff --git a/src/engine/SCons/Platform/__init__.py b/src/engine/SCons/Platform/__init__.py
new file mode 100644
index 0000000..201a1b9
--- /dev/null
+++ b/src/engine/SCons/Platform/__init__.py
@@ -0,0 +1,92 @@
+"""SCons.Platform
+
+SCons platform selection.
+
+This looks for modules that define a callable object that can modify a
+construction environment as appropriate for a given platform.
+
+Note that we take a more simplistic view of "platform" than Python does.
+We're looking for a single string that determines a set of
+tool-independent variables with which to initialize a construction
+environment. Consequently, we'll examine both sys.platform and os.name
+(and anything else that might come in to play) in order to return some
+specification which is unique enough for our purposes.
+
+Note that because this subsysem just *selects* a callable that can
+modify a construction environment, it's possible for people to define
+their own "platform specification" in an arbitrary callable function.
+No one needs to use or tie in to this subsystem in order to roll
+their own platform definition.
+"""
+
+#
+# Copyright (c) 2001, 2002 Steven Knight
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+__version__ = "__VERSION__"
+
+import imp
+import os
+import sys
+
+import SCons.Errors
+
+def platform_default():
+ """Return the platform string for our execution environment.
+ """
+ if sys.platform == 'win32':
+ return 'win32'
+ if os.name == 'cygwin':
+ return 'cygwin'
+ if os.name == 'posix':
+ return 'posix'
+ return None
+
+class PlatformSpec:
+ def __init__(self, name):
+ self.name = name
+
+ def __str__(self):
+ return self.name
+
+def Platform(name = platform_default()):
+ """Select a canned Platform specification.
+
+ This looks for a module name that matches the specified argument.
+ If the name is unspecified, we fetch the appropriate default for
+ our execution environment.
+ """
+ full_name = 'SCons.Platform.' + name
+ if not sys.modules.has_key(full_name):
+ try:
+ file, path, desc = imp.find_module(name,
+ sys.modules['SCons.Platform'].__path__)
+ imp.load_module(full_name, file, path, desc)
+ except ImportError:
+ raise SCons.Errors.UserError, "No platform named '%s'" % name
+ if file:
+ file.close()
+ spec = PlatformSpec(name)
+ spec.__call__ = sys.modules[full_name].generate
+ return spec
diff --git a/src/engine/SCons/Platform/cygwin.py b/src/engine/SCons/Platform/cygwin.py
new file mode 100644
index 0000000..7faafd8
--- /dev/null
+++ b/src/engine/SCons/Platform/cygwin.py
@@ -0,0 +1,48 @@
+"""SCons.Platform.cygwin
+
+Platform-specific initialization for Cygwin systems.
+
+There normally shouldn't be any need to import this module directly. It
+will usually be imported through the generic SCons.Platform.Platform()
+selection method.
+"""
+
+#
+# Copyright (c) 2001, 2002 Steven Knight
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+def generate(env):
+ if not env.has_key('ENV'):
+ env['ENV'] = {}
+ env['ENV']['PATH'] = '/usr/local/bin:/bin:/usr/bin'
+ env['OBJPREFIX'] = ''
+ env['OBJSUFFIX'] = '.o'
+ env['PROGPREFIX'] = ''
+ env['PROGSUFFIX'] = '.exe'
+ env['LIBPREFIX'] = 'lib'
+ env['LIBSUFFIX'] = '.a'
+ env['SHLIBPREFIX'] = '$LIBPREFIX'
+ env['SHLIBSUFFIX'] = '.so'
+ env['LIBPREFIXES'] = '$LIBPREFIX'
+ env['LIBSUFFIXES'] = [ '$LIBSUFFIX', '$SHLIBSUFFIX' ]
diff --git a/src/engine/SCons/Platform/posix.py b/src/engine/SCons/Platform/posix.py
new file mode 100644
index 0000000..4de68f6
--- /dev/null
+++ b/src/engine/SCons/Platform/posix.py
@@ -0,0 +1,48 @@
+"""SCons.Platform.posix
+
+Platform-specific initialization for POSIX (Linux, UNIX, etc.) systems.
+
+There normally shouldn't be any need to import this module directly. It
+will usually be imported through the generic SCons.Platform.Platform()
+selection method.
+"""
+
+#
+# Copyright (c) 2001, 2002 Steven Knight
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+def generate(env):
+ if not env.has_key('ENV'):
+ env['ENV'] = {}
+ env['ENV']['PATH'] = '/usr/local/bin:/bin:/usr/bin'
+ env['OBJPREFIX'] = ''
+ env['OBJSUFFIX'] = '.o'
+ env['PROGPREFIX'] = ''
+ env['PROGSUFFIX'] = ''
+ env['LIBPREFIX'] = 'lib'
+ env['LIBSUFFIX'] = '.a'
+ env['SHLIBPREFIX'] = '$LIBPREFIX'
+ env['SHLIBSUFFIX'] = '.so'
+ env['LIBPREFIXES'] = '$LIBPREFIX'
+ env['LIBSUFFIXES'] = [ '$LIBSUFFIX', '$SHLIBSUFFIX' ]
diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py
new file mode 100644
index 0000000..aa9a75f
--- /dev/null
+++ b/src/engine/SCons/Platform/win32.py
@@ -0,0 +1,48 @@
+"""SCons.Platform.win32
+
+Platform-specific initialization for Win32 systems.
+
+There normally shouldn't be any need to import this module directly. It
+will usually be imported through the generic SCons.Platform.Platform()
+selection method.
+"""
+
+#
+# Copyright (c) 2001, 2002 Steven Knight
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+def generate(env):
+ if not env.has_key('ENV'):
+ env['ENV'] = {}
+ env['ENV']['PATHEXT'] = '.COM;.EXE;.BAT;.CMD'
+ env['OBJPREFIX'] = ''
+ env['OBJSUFFIX'] = '.obj'
+ env['PROGPREFIX'] = ''
+ env['PROGSUFFIX'] = '.exe'
+ env['LIBPREFIX'] = ''
+ env['LIBSUFFIX'] = '.lib'
+ env['SHLIBPREFIX'] = ''
+ env['SHLIBSUFFIX'] = '.dll'
+ env['LIBPREFIXES'] = '$LIBPREFIX'
+ env['LIBSUFFIXES'] = '$LIBSUFFIX'
diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py
index 606be08..44ec7ce 100644
--- a/src/engine/SCons/Script/SConscript.py
+++ b/src/engine/SCons/Script/SConscript.py
@@ -36,6 +36,7 @@ import SCons.Environment
import SCons.Errors
import SCons.Node
import SCons.Node.FS
+import SCons.Platform
import SCons.Util
import os
@@ -260,6 +261,7 @@ def BuildDefaultGlobals():
globals['Import'] = Import
globals['Library'] = SCons.Defaults.Library
globals['Object'] = SCons.Defaults.Object
+ globals['Platform'] = SCons.Platform.Platform
globals['Program'] = SCons.Defaults.Program
globals['Return'] = Return
globals['Scanner'] = SCons.Scanner.Base
diff --git a/src/setup.py b/src/setup.py
index 73abe19..b84f41a 100644
--- a/src/setup.py
+++ b/src/setup.py
@@ -66,6 +66,7 @@ arguments = {
'version' : "__VERSION__",
'packages' : ["SCons",
"SCons.Node",
+ "SCons.Platform",
"SCons.Scanner",
"SCons.Sig",
"SCons.Script"],
diff --git a/test/Platform.py b/test/Platform.py
new file mode 100644
index 0000000..f4b470c
--- /dev/null
+++ b/test/Platform.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2001, 2002 Steven Knight
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """
+env = {}
+Platform('cygwin')(env)
+print "'%s'" % env['PROGSUFFIX']
+Platform('posix')(env)
+print "'%s'" % env['PROGSUFFIX']
+Platform('win32')(env)
+print "'%s'" % env['PROGSUFFIX']
+SConscript('SConscript')
+""")
+
+test.write('SConscript', """
+env = {}
+Platform('cygwin')(env)
+print "'%s'" % env['LIBSUFFIX']
+Platform('posix')(env)
+print "'%s'" % env['LIBSUFFIX']
+Platform('win32')(env)
+print "'%s'" % env['LIBSUFFIX']
+""")
+
+expect = """'.exe'
+''
+'.exe'
+'.a'
+'.a'
+'.lib'
+"""
+
+test.run(stdout = expect)
+
+test.pass_test()
+
diff --git a/test/option--debug.py b/test/option--debug.py
index 035525e..74019fe 100644
--- a/test/option--debug.py
+++ b/test/option--debug.py
@@ -65,8 +65,6 @@ test.write('bar.h', """
test.run(arguments = "--debug=tree foo.xxx")
-import SCons.Defaults
-obj = SCons.Defaults.ConstructionEnvironment['OBJSUFFIX']
tree = """
+-foo.xxx
+-foo.ooo