Anonymous avatar Anonymous committed bda684e

Add a Platform() method.

Comments (0)

Files changed (18)

 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 
 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
 .B Depends 
 method of a construction environment (see below).
 
-Additional Environment methods include:
-
-.TP
-.RI Command( target ", " source ", " commands )
-Executes a specific action
-(or list of actions)
-to build a target file or files.
-This is more convenient
-than defining a separate Builder object
-for a single special-case build.
-
-Note that an action can be an external command,
-specified as a string,
-or a callable Python object;
-see "Action Objects," below.
-Examples:
-
-.ES
-env.Command('foo.out', 'foo.in',
-            "$FOO_BUILD < $SOURCES > $TARGET")
-
-env.Command('bar.out', 'bar.in',
-            ["rm -f $TARGET",
-             "$BAR_BUILD < $SOURCES > $TARGET"])
-
-def rename(env, target, source):
-    import os
-    os.rename('.tmp', str(target[0]))
-
-env.Command('baz.out', 'baz.in',
-            ["$BAZ_BUILD < $SOURCES > .tmp",
-	     rename ])
-.EE
-
-.TP
-.RI Copy([ key = val ", ...])"
-Return a separate copy of a construction environment.
-If there are any keyword arguments specified,
-they are added to the returned copy,
-overwriting any existing values
-for the keywords.
-
-.ES
-env2 = env.Copy()
-env3 = env.Copy(CCFLAGS = '-g')
-.EE
-
-.TP
-.RI Depends( target ", " dependency )
-Specifies an explicit dependency;
-the target file(s) will be rebuilt
-whenever the dependency file(s) has changed.
-This should only be necessary
-for cases where the dependency
-is not caught by a Scanner
-for the file.
-
-.ES
-env.Depends('foo', 'other-input-file-for-foo')
-.EE
-
-.TP
-.RI Dictionary([ vars ])
-Returns a dictionary object
-containing copies of all of the
-construction variables in the environment.
-If there are any variable names specified,
-only the specified construction
-variables are returned in the dictionary.
-
-.ES
-dict = env.Dictionary()
-cc_dict = env.Dictionary('CC', 'CCFLAGS', 'CCCOM')
-.EE
-
-.TP
-.RI Ignore( target ", " dependency )
-The specified dependency file(s)
-will be ignored when deciding if
-the target file(s) need to be rebuilt.
-
-.ES
-env.Ignore('foo', 'foo.c')
-env.Ignore('bar', ['bar1.h', 'bar2.h'])
-.EE
-
-.TP
-.RI Install( dir ", " source )
-Installs one or more files in a destination directory.
-The file names remain the same.
-
-.ES
-env.Install(dir = '/usr/local/bin', source = 'foo bar')
-.EE
-
-.TP
-.RI InstallAs( target ", " source )
-Installs one or more files as specific file names,
-allowing changing a file name as part of the
-installation.
-It is an error if the target and source
-list different numbers of files.
-
-.ES
-env.InstallAs(target = '/usr/local/bin/foo',
-              source = 'foo_debug')
-env.InstallAs(target = '../lib/libfoo.a ../lib/libbar.a',
-              source = 'libFOO.a libBAR.a')
-.EE
-
-.TP
-.RI Precious( target ", ...)"
-Marks each given
-.I target
-as precious so it is not deleted before it is rebuilt. Normally
-.B scons
-deletes a target before building it.
-Multiple targets can be passed in to a single call to
-.BR Precious ().
+.SS Other Construction Environment Methods
+Additional construction environment methods include:
 
 .TP
 .RI Alias( alias ", " targets )
 .EE
 
 .TP
-.RI Replace( key = val ", [...])"
-Replaces construction variables in the Environment
-with the specified keyword arguments.
-(Note:  "Update()" is a deprecated synonym for this method.)
-
-.ES
-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.
 env.Append(CCFLAGS = ' -g', FOO = ['foo.yyy'])
 .EE
 
+.TP
+.RI Command( target ", " source ", " commands )
+Executes a specific action
+(or list of actions)
+to build a target file or files.
+This is more convenient
+than defining a separate Builder object
+for a single special-case build.
+
+Note that an action can be an external command,
+specified as a string,
+or a callable Python object;
+see "Action Objects," below.
+Examples:
+
+.ES
+env.Command('foo.out', 'foo.in',
+            "$FOO_BUILD < $SOURCES > $TARGET")
+
+env.Command('bar.out', 'bar.in',
+            ["rm -f $TARGET",
+             "$BAR_BUILD < $SOURCES > $TARGET"])
+
+def rename(env, target, source):
+    import os
+    os.rename('.tmp', str(target[0]))
+
+env.Command('baz.out', 'baz.in',
+            ["$BAZ_BUILD < $SOURCES > .tmp",
+	     rename ])
+.EE
+
+.TP
+.RI Copy([ key = val ", ...])"
+Return a separate copy of a construction environment.
+If there are any keyword arguments specified,
+they are added to the returned copy,
+overwriting any existing values
+for the keywords.
+
+.ES
+env2 = env.Copy()
+env3 = env.Copy(CCFLAGS = '-g')
+.EE
+
+.TP
+.RI Depends( target ", " dependency )
+Specifies an explicit dependency;
+the target file(s) will be rebuilt
+whenever the dependency file(s) has changed.
+This should only be necessary
+for cases where the dependency
+is not caught by a Scanner
+for the file.
+
+.ES
+env.Depends('foo', 'other-input-file-for-foo')
+.EE
+
+.TP
+.RI Dictionary([ vars ])
+Returns a dictionary object
+containing copies of all of the
+construction variables in the environment.
+If there are any variable names specified,
+only the specified construction
+variables are returned in the dictionary.
+
+.ES
+dict = env.Dictionary()
+cc_dict = env.Dictionary('CC', 'CCFLAGS', 'CCCOM')
+.EE
+
+.TP
+.RI Ignore( target ", " dependency )
+The specified dependency file(s)
+will be ignored when deciding if
+the target file(s) need to be rebuilt.
+
+.ES
+env.Ignore('foo', 'foo.c')
+env.Ignore('bar', ['bar1.h', 'bar2.h'])
+.EE
+
+.TP
+.RI Install( dir ", " source )
+Installs one or more files in a destination directory.
+The file names remain the same.
+
+.ES
+env.Install(dir = '/usr/local/bin', source = 'foo bar')
+.EE
+
+.TP
+.RI InstallAs( target ", " source )
+Installs one or more files as specific file names,
+allowing changing a file name as part of the
+installation.
+It is an error if the target and source
+list different numbers of files.
+
+.ES
+env.InstallAs(target = '/usr/local/bin/foo',
+              source = 'foo_debug')
+env.InstallAs(target = '../lib/libfoo.a ../lib/libbar.a',
+              source = 'libFOO.a libBAR.a')
+.EE
+
+.TP
+.RI Precious( target ", ...)"
+Marks each given
+.I target
+as precious so it is not deleted before it is rebuilt. Normally
+.B scons
+deletes a target before building it.
+Multiple targets can be passed in to a single call to
+.BR Precious ().
+
+.TP
+.RI Replace( key = val ", [...])"
+Replaces construction variables in the Environment
+with the specified keyword arguments.
+(Note:  "Update()" is a deprecated synonym for this method.)
+
+.ES
+env.Replace(CCFLAGS = '-g', FOO = 'foo.xxx')
+.EE
+
 .SS Construction Variables
 .\" XXX From Gary Ruben, 23 April 2002:
 .\" I think it would be good to have an example with each construction
 .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
 /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
 
 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

src/engine/MANIFEST.in

 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

src/engine/SCons/Action.py

     13 : 126,
 }
 
+default_ENV = None
+
 if os.name == 'posix':
 
     def defaultSpawn(cmd, args, env):
                     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

src/engine/SCons/Defaults.py

 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
         'AR'         : 'lib',
         'ARFLAGS'    : '/nologo',
         'ARCOM'      : '$AR $ARFLAGS /OUT:$TARGET $SOURCES',
-        'SHLIBPREFIX': '',
-        'SHLIBSUFFIX': '.dll',
         'LEX'        : 'lex',
         'LEXFLAGS'   : '',
         'LEXCOM'     : '$LEX $LEXFLAGS -t $SOURCES > $TARGET',
         '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'         : '',
             'INCLUDE'  : include,
             'LIB'      : lib,
             'PATH'     : path,
-                'PATHEXT' : '.COM;.EXE;.BAT;.CMD',
             },
         }
 
         'RANLIB'     : ranlib,
         'RANLIBFLAGS' : '',
         'ARCOM'      : arcom,
-        'SHLIBPREFIX': '$LIBPREFIX',
-        'SHLIBSUFFIX': '.so',
         'LEX'        : 'lex',
         'LEXFLAGS'   : '',
         'LEXCOM'     : '$LEX $LEXFLAGS -t $SOURCES > $TARGET',
         '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':
                 include_path,
                 lib_path,
                 exe_path)
-

src/engine/SCons/Environment.py

     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)
 
         #

src/engine/SCons/EnvironmentTests.py

         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__":

src/engine/SCons/Platform/.aeignore

+*,D
+*.pyc
+.*.swp
+.consign
+.sconsign

src/engine/SCons/Platform/PlatformTests.py

+#
+# 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)

src/engine/SCons/Platform/__init__.py

+"""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

src/engine/SCons/Platform/cygwin.py

+"""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' ]

src/engine/SCons/Platform/posix.py

+"""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' ]

src/engine/SCons/Platform/win32.py

+"""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'

src/engine/SCons/Script/SConscript.py

 import SCons.Errors
 import SCons.Node
 import SCons.Node.FS
+import SCons.Platform
 import SCons.Util
 
 import os
     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
     'version'          : "__VERSION__",
     'packages'         : ["SCons",
                           "SCons.Node",
+                          "SCons.Platform",
                           "SCons.Scanner",
                           "SCons.Sig",
                           "SCons.Script"],
+#!/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()
+

test/option--debug.py

 
 test.run(arguments = "--debug=tree foo.xxx")
 
-import SCons.Defaults
-obj = SCons.Defaults.ConstructionEnvironment['OBJSUFFIX']
 tree = """
 +-foo.xxx
   +-foo.ooo
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.