summaryrefslogtreecommitdiff
path: root/src/engine/SCons/Platform
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons/Platform')
-rw-r--r--src/engine/SCons/Platform/PlatformTests.py126
-rw-r--r--src/engine/SCons/Platform/__init__.py236
-rw-r--r--src/engine/SCons/Platform/__init__.xml183
-rw-r--r--src/engine/SCons/Platform/aix.py70
-rw-r--r--src/engine/SCons/Platform/cygwin.py55
-rw-r--r--src/engine/SCons/Platform/darwin.py46
-rw-r--r--src/engine/SCons/Platform/hpux.py46
-rw-r--r--src/engine/SCons/Platform/irix.py44
-rw-r--r--src/engine/SCons/Platform/os2.py58
-rw-r--r--src/engine/SCons/Platform/posix.py264
-rw-r--r--src/engine/SCons/Platform/posix.xml51
-rw-r--r--src/engine/SCons/Platform/sunos.py50
-rw-r--r--src/engine/SCons/Platform/sunos.xml30
-rw-r--r--src/engine/SCons/Platform/win32.py386
-rw-r--r--src/engine/SCons/Platform/win32.xml14
15 files changed, 1659 insertions, 0 deletions
diff --git a/src/engine/SCons/Platform/PlatformTests.py b/src/engine/SCons/Platform/PlatformTests.py
new file mode 100644
index 0000000..e1e19cd
--- /dev/null
+++ b/src/engine/SCons/Platform/PlatformTests.py
@@ -0,0 +1,126 @@
+#
+# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation
+#
+# 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__ = "src/engine/SCons/Platform/PlatformTests.py 4577 2009/12/27 19:44:43 scons"
+
+import sys
+import unittest
+
+import SCons.Errors
+import SCons.Platform
+import UserDict
+
+class Environment(UserDict.UserDict):
+ def Detect(self, cmd):
+ return cmd
+ def AppendENVPath(self, key, value):
+ pass
+
+class PlatformTestCase(unittest.TestCase):
+ def test_Platform(self):
+ """Test the Platform() function"""
+ p = SCons.Platform.Platform('cygwin')
+ assert str(p) == 'cygwin', p
+ env = Environment()
+ p(env)
+ assert env['PROGSUFFIX'] == '.exe', env
+ assert env['LIBSUFFIX'] == '.a', env
+ assert env['SHELL'] == 'sh', env
+
+ p = SCons.Platform.Platform('os2')
+ assert str(p) == 'os2', p
+ env = Environment()
+ p(env)
+ assert env['PROGSUFFIX'] == '.exe', env
+ assert env['LIBSUFFIX'] == '.lib', env
+
+ p = SCons.Platform.Platform('posix')
+ assert str(p) == 'posix', p
+ env = Environment()
+ p(env)
+ assert env['PROGSUFFIX'] == '', env
+ assert env['LIBSUFFIX'] == '.a', env
+ assert env['SHELL'] == 'sh', env
+
+ p = SCons.Platform.Platform('irix')
+ assert str(p) == 'irix', p
+ env = Environment()
+ p(env)
+ assert env['PROGSUFFIX'] == '', env
+ assert env['LIBSUFFIX'] == '.a', env
+ assert env['SHELL'] == 'sh', env
+
+ p = SCons.Platform.Platform('aix')
+ assert str(p) == 'aix', p
+ env = Environment()
+ p(env)
+ assert env['PROGSUFFIX'] == '', env
+ assert env['LIBSUFFIX'] == '.a', env
+ assert env['SHELL'] == 'sh', env
+
+ p = SCons.Platform.Platform('sunos')
+ assert str(p) == 'sunos', p
+ env = Environment()
+ p(env)
+ assert env['PROGSUFFIX'] == '', env
+ assert env['LIBSUFFIX'] == '.a', env
+ assert env['SHELL'] == 'sh', env
+
+ p = SCons.Platform.Platform('hpux')
+ assert str(p) == 'hpux', p
+ env = Environment()
+ p(env)
+ assert env['PROGSUFFIX'] == '', env
+ assert env['LIBSUFFIX'] == '.a', env
+ assert env['SHELL'] == 'sh', env
+
+ p = SCons.Platform.Platform('win32')
+ assert str(p) == 'win32', p
+ env = Environment()
+ 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 = Environment()
+ 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)
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/src/engine/SCons/Platform/__init__.py b/src/engine/SCons/Platform/__init__.py
new file mode 100644
index 0000000..671e929
--- /dev/null
+++ b/src/engine/SCons/Platform/__init__.py
@@ -0,0 +1,236 @@
+"""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, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation
+#
+# 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__ = "src/engine/SCons/Platform/__init__.py 4577 2009/12/27 19:44:43 scons"
+
+import SCons.compat
+
+import imp
+import os
+import string
+import sys
+import tempfile
+
+import SCons.Errors
+import SCons.Subst
+import SCons.Tool
+
+def platform_default():
+ """Return the platform string for our execution environment.
+
+ The returned value should map to one of the SCons/Platform/*.py
+ files. Since we're architecture independent, though, we don't
+ care about the machine architecture.
+ """
+ osname = os.name
+ if osname == 'java':
+ osname = os._osType
+ if osname == 'posix':
+ if sys.platform == 'cygwin':
+ return 'cygwin'
+ elif string.find(sys.platform, 'irix') != -1:
+ return 'irix'
+ elif string.find(sys.platform, 'sunos') != -1:
+ return 'sunos'
+ elif string.find(sys.platform, 'hp-ux') != -1:
+ return 'hpux'
+ elif string.find(sys.platform, 'aix') != -1:
+ return 'aix'
+ elif string.find(sys.platform, 'darwin') != -1:
+ return 'darwin'
+ else:
+ return 'posix'
+ elif os.name == 'os2':
+ return 'os2'
+ else:
+ return sys.platform
+
+def platform_module(name = platform_default()):
+ """Return the imported module for the platform.
+
+ 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):
+ if os.name == 'java':
+ eval(full_name)
+ else:
+ try:
+ file, path, desc = imp.find_module(name,
+ sys.modules['SCons.Platform'].__path__)
+ try:
+ mod = imp.load_module(full_name, file, path, desc)
+ finally:
+ if file:
+ file.close()
+ except ImportError:
+ try:
+ import zipimport
+ importer = zipimport.zipimporter( sys.modules['SCons.Platform'].__path__[0] )
+ mod = importer.load_module(full_name)
+ except ImportError:
+ raise SCons.Errors.UserError, "No platform named '%s'" % name
+ setattr(SCons.Platform, name, mod)
+ return sys.modules[full_name]
+
+def DefaultToolList(platform, env):
+ """Select a default tool list for the specified platform.
+ """
+ return SCons.Tool.tool_list(platform, env)
+
+class PlatformSpec:
+ def __init__(self, name):
+ self.name = name
+
+ def __str__(self):
+ return self.name
+
+class TempFileMunge:
+ """A callable class. You can set an Environment variable to this,
+ then call it with a string argument, then it will perform temporary
+ file substitution on it. This is used to circumvent the long command
+ line limitation.
+
+ Example usage:
+ env["TEMPFILE"] = TempFileMunge
+ env["LINKCOM"] = "${TEMPFILE('$LINK $TARGET $SOURCES')}"
+
+ By default, the name of the temporary file used begins with a
+ prefix of '@'. This may be configred for other tool chains by
+ setting '$TEMPFILEPREFIX'.
+
+ env["TEMPFILEPREFIX"] = '-@' # diab compiler
+ env["TEMPFILEPREFIX"] = '-via' # arm tool chain
+ """
+ def __init__(self, cmd):
+ self.cmd = cmd
+
+ def __call__(self, target, source, env, for_signature):
+ if for_signature:
+ # If we're being called for signature calculation, it's
+ # because we're being called by the string expansion in
+ # Subst.py, which has the logic to strip any $( $) that
+ # may be in the command line we squirreled away. So we
+ # just return the raw command line and let the upper
+ # string substitution layers do their thing.
+ return self.cmd
+
+ # Now we're actually being called because someone is actually
+ # going to try to execute the command, so we have to do our
+ # own expansion.
+ cmd = env.subst_list(self.cmd, SCons.Subst.SUBST_CMD, target, source)[0]
+ try:
+ maxline = int(env.subst('$MAXLINELENGTH'))
+ except ValueError:
+ maxline = 2048
+
+ if (reduce(lambda x, y: x + len(y), cmd, 0) + len(cmd)) <= maxline:
+ return self.cmd
+
+ # We do a normpath because mktemp() has what appears to be
+ # a bug in Windows that will use a forward slash as a path
+ # delimiter. Windows's link mistakes that for a command line
+ # switch and barfs.
+ #
+ # We use the .lnk suffix for the benefit of the Phar Lap
+ # linkloc linker, which likes to append an .lnk suffix if
+ # none is given.
+ (fd, tmp) = tempfile.mkstemp('.lnk', text=True)
+ native_tmp = SCons.Util.get_native_path(os.path.normpath(tmp))
+
+ if env['SHELL'] and env['SHELL'] == 'sh':
+ # The sh shell will try to escape the backslashes in the
+ # path, so unescape them.
+ native_tmp = string.replace(native_tmp, '\\', r'\\\\')
+ # In Cygwin, we want to use rm to delete the temporary
+ # file, because del does not exist in the sh shell.
+ rm = env.Detect('rm') or 'del'
+ else:
+ # Don't use 'rm' if the shell is not sh, because rm won't
+ # work with the Windows shells (cmd.exe or command.com) or
+ # Windows path names.
+ rm = 'del'
+
+ prefix = env.subst('$TEMPFILEPREFIX')
+ if not prefix:
+ prefix = '@'
+
+ args = map(SCons.Subst.quote_spaces, cmd[1:])
+ os.write(fd, string.join(args, " ") + "\n")
+ os.close(fd)
+ # XXX Using the SCons.Action.print_actions value directly
+ # like this is bogus, but expedient. This class should
+ # really be rewritten as an Action that defines the
+ # __call__() and strfunction() methods and lets the
+ # normal action-execution logic handle whether or not to
+ # print/execute the action. The problem, though, is all
+ # of that is decided before we execute this method as
+ # part of expanding the $TEMPFILE construction variable.
+ # Consequently, refactoring this will have to wait until
+ # we get more flexible with allowing Actions to exist
+ # independently and get strung together arbitrarily like
+ # Ant tasks. In the meantime, it's going to be more
+ # user-friendly to not let obsession with architectural
+ # purity get in the way of just being helpful, so we'll
+ # reach into SCons.Action directly.
+ if SCons.Action.print_actions:
+ print("Using tempfile "+native_tmp+" for command line:\n"+
+ str(cmd[0]) + " " + string.join(args," "))
+ return [ cmd[0], prefix + native_tmp + '\n' + rm, native_tmp ]
+
+def Platform(name = platform_default()):
+ """Select a canned Platform specification.
+ """
+ module = platform_module(name)
+ spec = PlatformSpec(name)
+ spec.__call__ = module.generate
+ return spec
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/src/engine/SCons/Platform/__init__.xml b/src/engine/SCons/Platform/__init__.xml
new file mode 100644
index 0000000..dc5a415
--- /dev/null
+++ b/src/engine/SCons/Platform/__init__.xml
@@ -0,0 +1,183 @@
+<!--
+Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation
+
+This file is processed by the bin/SConsDoc.py module.
+See its __doc__ string for a discussion of the format.
+-->
+<cvar name="ESCAPE">
+<summary>
+A function that will be called to escape shell special characters in
+command lines. The function should take one argument: the command line
+string to escape; and should return the escaped command line.
+</summary>
+</cvar>
+
+<cvar name="LIBPREFIX">
+<summary>
+The prefix used for (static) library file names.
+A default value is set for each platform
+(posix, win32, os2, etc.),
+but the value is overridden by individual tools
+(ar, mslib, sgiar, sunar, tlib, etc.)
+to reflect the names of the libraries they create.
+</summary>
+</cvar>
+
+<cvar name="LIBPREFIXES">
+<summary>
+A list of all legal prefixes for library file names.
+When searching for library dependencies,
+SCons will look for files with these prefixes,
+the base library name,
+and suffixes in the &cv-LIBSUFFIXES; list.
+</summary>
+</cvar>
+
+<cvar name="LIBSUFFIX">
+<summary>
+The suffix used for (static) library file names.
+A default value is set for each platform
+(posix, win32, os2, etc.),
+but the value is overridden by individual tools
+(ar, mslib, sgiar, sunar, tlib, etc.)
+to reflect the names of the libraries they create.
+</summary>
+</cvar>
+
+<cvar name="LIBSUFFIXES">
+<summary>
+A list of all legal suffixes for library file names.
+When searching for library dependencies,
+SCons will look for files with prefixes, in the &cv-LIBPREFIXES; list,
+the base library name,
+and these suffixes.
+</summary>
+</cvar>
+
+<cvar name="OBJPREFIX">
+<summary>
+The prefix used for (static) object file names.
+</summary>
+</cvar>
+
+<cvar name="OBJSUFFIX">
+<summary>
+The suffix used for (static) object file names.
+</summary>
+</cvar>
+
+<cvar name="PLATFORM">
+<summary>
+The name of the platform used to create the Environment. If no platform is
+specified when the Environment is created,
+&scons;
+autodetects the platform.
+
+<example>
+env = Environment(tools = [])
+if env['PLATFORM'] == 'cygwin':
+ Tool('mingw')(env)
+else:
+ Tool('msvc')(env)
+</example>
+</summary>
+</cvar>
+
+<cvar name="HOST_OS">
+ <summary>
+ The name of the host operating system used to create the Environment.
+ If a platform is specified when creating the Environment, then
+ that Platform's logic will handle setting this value.
+ This value is immutable, and should not be changed by the user after
+ the Environment is initialized.
+ Currently only set for Win32.
+ </summary>
+</cvar>
+
+<cvar name="HOST_ARCH">
+ <summary>
+ The name of the host hardware architecture used to create the Environment.
+ If a platform is specified when creating the Environment, then
+ that Platform's logic will handle setting this value.
+ This value is immutable, and should not be changed by the user after
+ the Environment is initialized.
+ Currently only set for Win32.
+ </summary>
+</cvar>
+
+<cvar name="TARGET_OS">
+ <summary>
+ The name of the target operating system for the compiled objects
+ created by this Environment.
+ This defaults to the value of HOST_OS, and the user can override it.
+ Currently only set for Win32.
+ </summary>
+</cvar>
+
+<cvar name="TARGET_ARCH">
+ <summary>
+ The name of the target hardware architecture for the compiled objects
+ created by this Environment.
+ This defaults to the value of HOST_ARCH, and the user can override it.
+ Currently only set for Win32.
+ </summary>
+</cvar>
+
+
+<cvar name="PROGPREFIX">
+<summary>
+The prefix used for executable file names.
+</summary>
+</cvar>
+
+<cvar name="PROGSUFFIX">
+<summary>
+The suffix used for executable file names.
+</summary>
+</cvar>
+
+<cvar name="SHELL">
+<summary>
+A string naming the shell program that will be passed to the
+&cv-SPAWN;
+function.
+See the
+&cv-SPAWN;
+construction variable for more information.
+</summary>
+</cvar>
+
+<cvar name="SHLIBPREFIX">
+<summary>
+The prefix used for shared library file names.
+</summary>
+</cvar>
+
+<cvar name="SHLIBSUFFIX">
+<summary>
+The suffix used for shared library file names.
+</summary>
+</cvar>
+
+<cvar name="SHOBJPREFIX">
+<summary>
+The prefix used for shared object file names.
+</summary>
+</cvar>
+
+<cvar name="SHOBJSUFFIX">
+<summary>
+The suffix used for shared object file names.
+</summary>
+</cvar>
+
+<cvar name="TEMPFILEPREFIX">
+<summary>
+The prefix for a temporary file used
+to execute lines longer than $MAXLINELENGTH.
+The default is '@'.
+This may be set for toolchains that use other values,
+such as '-@' for the diab compiler
+or '-via' for ARM toolchain.
+</summary>
+</cvar>
diff --git a/src/engine/SCons/Platform/aix.py b/src/engine/SCons/Platform/aix.py
new file mode 100644
index 0000000..8d6b6e6
--- /dev/null
+++ b/src/engine/SCons/Platform/aix.py
@@ -0,0 +1,70 @@
+"""engine.SCons.Platform.aix
+
+Platform-specific initialization for IBM AIX 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, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation
+#
+# 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__ = "src/engine/SCons/Platform/aix.py 4577 2009/12/27 19:44:43 scons"
+
+import os
+import string
+
+import posix
+
+def get_xlc(env, xlc=None, xlc_r=None, packages=[]):
+ # Use the AIX package installer tool lslpp to figure out where a
+ # given xl* compiler is installed and what version it is.
+ xlcPath = None
+ xlcVersion = None
+
+ if xlc is None:
+ xlc = env.get('CC', 'xlc')
+ if xlc_r is None:
+ xlc_r = xlc + '_r'
+ for package in packages:
+ cmd = "lslpp -fc " + package + " 2>/dev/null | egrep '" + xlc + "([^-_a-zA-Z0-9].*)?$'"
+ line = os.popen(cmd).readline()
+ if line:
+ v, p = string.split(line, ':')[1:3]
+ xlcVersion = string.split(v)[1]
+ xlcPath = string.split(p)[0]
+ xlcPath = xlcPath[:xlcPath.rindex('/')]
+ break
+ return (xlcPath, xlc, xlc_r, xlcVersion)
+
+def generate(env):
+ posix.generate(env)
+ #Based on AIX 5.2: ARG_MAX=24576 - 3000 for environment expansion
+ env['MAXLINELENGTH'] = 21576
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/src/engine/SCons/Platform/cygwin.py b/src/engine/SCons/Platform/cygwin.py
new file mode 100644
index 0000000..cf6ecce
--- /dev/null
+++ b/src/engine/SCons/Platform/cygwin.py
@@ -0,0 +1,55 @@
+"""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, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation
+#
+# 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__ = "src/engine/SCons/Platform/cygwin.py 4577 2009/12/27 19:44:43 scons"
+
+import posix
+from SCons.Platform import TempFileMunge
+
+def generate(env):
+ posix.generate(env)
+
+ env['PROGPREFIX'] = ''
+ env['PROGSUFFIX'] = '.exe'
+ env['SHLIBPREFIX'] = ''
+ env['SHLIBSUFFIX'] = '.dll'
+ env['LIBPREFIXES'] = [ '$LIBPREFIX', '$SHLIBPREFIX' ]
+ env['LIBSUFFIXES'] = [ '$LIBSUFFIX', '$SHLIBSUFFIX' ]
+ env['TEMPFILE'] = TempFileMunge
+ env['TEMPFILEPREFIX'] = '@'
+ env['MAXLINELENGTH'] = 2048
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/src/engine/SCons/Platform/darwin.py b/src/engine/SCons/Platform/darwin.py
new file mode 100644
index 0000000..35f8fc8
--- /dev/null
+++ b/src/engine/SCons/Platform/darwin.py
@@ -0,0 +1,46 @@
+"""engine.SCons.Platform.darwin
+
+Platform-specific initialization for Mac OS X 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, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation
+#
+# 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__ = "src/engine/SCons/Platform/darwin.py 4577 2009/12/27 19:44:43 scons"
+
+import posix
+
+def generate(env):
+ posix.generate(env)
+ env['SHLIBSUFFIX'] = '.dylib'
+ env['ENV']['PATH'] = env['ENV']['PATH'] + ':/sw/bin'
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/src/engine/SCons/Platform/hpux.py b/src/engine/SCons/Platform/hpux.py
new file mode 100644
index 0000000..2d55556
--- /dev/null
+++ b/src/engine/SCons/Platform/hpux.py
@@ -0,0 +1,46 @@
+"""engine.SCons.Platform.hpux
+
+Platform-specific initialization for HP-UX 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, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation
+#
+# 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__ = "src/engine/SCons/Platform/hpux.py 4577 2009/12/27 19:44:43 scons"
+
+import posix
+
+def generate(env):
+ posix.generate(env)
+ #Based on HP-UX11i: ARG_MAX=2048000 - 3000 for environment expansion
+ env['MAXLINELENGTH'] = 2045000
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/src/engine/SCons/Platform/irix.py b/src/engine/SCons/Platform/irix.py
new file mode 100644
index 0000000..c6a4990
--- /dev/null
+++ b/src/engine/SCons/Platform/irix.py
@@ -0,0 +1,44 @@
+"""SCons.Platform.irix
+
+Platform-specific initialization for SGI IRIX 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, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation
+#
+# 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__ = "src/engine/SCons/Platform/irix.py 4577 2009/12/27 19:44:43 scons"
+
+import posix
+
+def generate(env):
+ posix.generate(env)
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/src/engine/SCons/Platform/os2.py b/src/engine/SCons/Platform/os2.py
new file mode 100644
index 0000000..930a5a9
--- /dev/null
+++ b/src/engine/SCons/Platform/os2.py
@@ -0,0 +1,58 @@
+"""SCons.Platform.os2
+
+Platform-specific initialization for OS/2 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, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation
+#
+# 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__ = "src/engine/SCons/Platform/os2.py 4577 2009/12/27 19:44:43 scons"
+import win32
+
+def generate(env):
+ if not env.has_key('ENV'):
+ env['ENV'] = {}
+ env['OBJPREFIX'] = ''
+ env['OBJSUFFIX'] = '.obj'
+ env['SHOBJPREFIX'] = '$OBJPREFIX'
+ env['SHOBJSUFFIX'] = '$OBJSUFFIX'
+ env['PROGPREFIX'] = ''
+ env['PROGSUFFIX'] = '.exe'
+ env['LIBPREFIX'] = ''
+ env['LIBSUFFIX'] = '.lib'
+ env['SHLIBPREFIX'] = ''
+ env['SHLIBSUFFIX'] = '.dll'
+ env['LIBPREFIXES'] = '$LIBPREFIX'
+ env['LIBSUFFIXES'] = [ '$LIBSUFFIX', '$SHLIBSUFFIX' ]
+ env['HOST_OS'] = 'os2'
+ env['HOST_ARCH'] = win32.get_architecture().arch
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/src/engine/SCons/Platform/posix.py b/src/engine/SCons/Platform/posix.py
new file mode 100644
index 0000000..50dfb69
--- /dev/null
+++ b/src/engine/SCons/Platform/posix.py
@@ -0,0 +1,264 @@
+"""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, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation
+#
+# 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__ = "src/engine/SCons/Platform/posix.py 4577 2009/12/27 19:44:43 scons"
+
+import errno
+import os
+import os.path
+import string
+import subprocess
+import sys
+import select
+
+import SCons.Util
+from SCons.Platform import TempFileMunge
+
+exitvalmap = {
+ 2 : 127,
+ 13 : 126,
+}
+
+def escape(arg):
+ "escape shell special characters"
+ slash = '\\'
+ special = '"$()'
+
+ arg = string.replace(arg, slash, slash+slash)
+ for c in special:
+ arg = string.replace(arg, c, slash+c)
+
+ return '"' + arg + '"'
+
+def exec_system(l, env):
+ stat = os.system(string.join(l))
+ if stat & 0xff:
+ return stat | 0x80
+ return stat >> 8
+
+def exec_spawnvpe(l, env):
+ stat = os.spawnvpe(os.P_WAIT, l[0], l, env)
+ # os.spawnvpe() returns the actual exit code, not the encoding
+ # returned by os.waitpid() or os.system().
+ return stat
+
+def exec_fork(l, env):
+ pid = os.fork()
+ if not pid:
+ # Child process.
+ exitval = 127
+ try:
+ os.execvpe(l[0], l, env)
+ except OSError, e:
+ exitval = exitvalmap.get(e[0], e[0])
+ sys.stderr.write("scons: %s: %s\n" % (l[0], e[1]))
+ os._exit(exitval)
+ else:
+ # Parent process.
+ pid, stat = os.waitpid(pid, 0)
+ if stat & 0xff:
+ return stat | 0x80
+ return stat >> 8
+
+def _get_env_command(sh, escape, cmd, args, env):
+ s = string.join(args)
+ if env:
+ l = ['env', '-'] + \
+ map(lambda t, e=escape: e(t[0])+'='+e(t[1]), env.items()) + \
+ [sh, '-c', escape(s)]
+ s = string.join(l)
+ return s
+
+def env_spawn(sh, escape, cmd, args, env):
+ return exec_system([_get_env_command( sh, escape, cmd, args, env)], env)
+
+def spawnvpe_spawn(sh, escape, cmd, args, env):
+ return exec_spawnvpe([sh, '-c', string.join(args)], env)
+
+def fork_spawn(sh, escape, cmd, args, env):
+ return exec_fork([sh, '-c', string.join(args)], env)
+
+def process_cmd_output(cmd_stdout, cmd_stderr, stdout, stderr):
+ stdout_eof = stderr_eof = 0
+ while not (stdout_eof and stderr_eof):
+ try:
+ (i,o,e) = select.select([cmd_stdout, cmd_stderr], [], [])
+ if cmd_stdout in i:
+ str = cmd_stdout.read()
+ if len(str) == 0:
+ stdout_eof = 1
+ elif stdout is not None:
+ stdout.write(str)
+ if cmd_stderr in i:
+ str = cmd_stderr.read()
+ if len(str) == 0:
+ #sys.__stderr__.write( "stderr_eof=1\n" )
+ stderr_eof = 1
+ else:
+ #sys.__stderr__.write( "str(stderr) = %s\n" % str )
+ stderr.write(str)
+ except select.error, (_errno, _strerror):
+ if _errno != errno.EINTR:
+ raise
+
+def exec_popen3(l, env, stdout, stderr):
+ proc = subprocess.Popen(string.join(l),
+ stdout=stdout,
+ stderr=stderr,
+ shell=True)
+ stat = proc.wait()
+ if stat & 0xff:
+ return stat | 0x80
+ return stat >> 8
+
+def exec_piped_fork(l, env, stdout, stderr):
+ # spawn using fork / exec and providing a pipe for the command's
+ # stdout / stderr stream
+ if stdout != stderr:
+ (rFdOut, wFdOut) = os.pipe()
+ (rFdErr, wFdErr) = os.pipe()
+ else:
+ (rFdOut, wFdOut) = os.pipe()
+ rFdErr = rFdOut
+ wFdErr = wFdOut
+ # do the fork
+ pid = os.fork()
+ if not pid:
+ # Child process
+ os.close( rFdOut )
+ if rFdOut != rFdErr:
+ os.close( rFdErr )
+ os.dup2( wFdOut, 1 ) # is there some symbolic way to do that ?
+ os.dup2( wFdErr, 2 )
+ os.close( wFdOut )
+ if stdout != stderr:
+ os.close( wFdErr )
+ exitval = 127
+ try:
+ os.execvpe(l[0], l, env)
+ except OSError, e:
+ exitval = exitvalmap.get(e[0], e[0])
+ stderr.write("scons: %s: %s\n" % (l[0], e[1]))
+ os._exit(exitval)
+ else:
+ # Parent process
+ pid, stat = os.waitpid(pid, 0)
+ os.close( wFdOut )
+ if stdout != stderr:
+ os.close( wFdErr )
+ childOut = os.fdopen( rFdOut )
+ if stdout != stderr:
+ childErr = os.fdopen( rFdErr )
+ else:
+ childErr = childOut
+ process_cmd_output(childOut, childErr, stdout, stderr)
+ os.close( rFdOut )
+ if stdout != stderr:
+ os.close( rFdErr )
+ if stat & 0xff:
+ return stat | 0x80
+ return stat >> 8
+
+def piped_env_spawn(sh, escape, cmd, args, env, stdout, stderr):
+ # spawn using Popen3 combined with the env command
+ # the command name and the command's stdout is written to stdout
+ # the command's stderr is written to stderr
+ return exec_popen3([_get_env_command(sh, escape, cmd, args, env)],
+ env, stdout, stderr)
+
+def piped_fork_spawn(sh, escape, cmd, args, env, stdout, stderr):
+ # spawn using fork / exec and providing a pipe for the command's
+ # stdout / stderr stream
+ return exec_piped_fork([sh, '-c', string.join(args)],
+ env, stdout, stderr)
+
+
+
+def generate(env):
+ # If os.spawnvpe() exists, we use it to spawn commands. Otherwise
+ # if the env utility exists, we use os.system() to spawn commands,
+ # finally we fall back on os.fork()/os.exec().
+ #
+ # os.spawnvpe() is prefered because it is the most efficient. But
+ # for Python versions without it, os.system() is prefered because it
+ # is claimed that it works better with threads (i.e. -j) and is more
+ # efficient than forking Python.
+ #
+ # NB: Other people on the scons-users mailing list have claimed that
+ # os.fork()/os.exec() works better than os.system(). There may just
+ # not be a default that works best for all users.
+
+ if os.__dict__.has_key('spawnvpe'):
+ spawn = spawnvpe_spawn
+ elif env.Detect('env'):
+ spawn = env_spawn
+ else:
+ spawn = fork_spawn
+
+ if env.Detect('env'):
+ pspawn = piped_env_spawn
+ else:
+ pspawn = piped_fork_spawn
+
+ if not env.has_key('ENV'):
+ env['ENV'] = {}
+ env['ENV']['PATH'] = '/usr/local/bin:/opt/bin:/bin:/usr/bin'
+ env['OBJPREFIX'] = ''
+ env['OBJSUFFIX'] = '.o'
+ env['SHOBJPREFIX'] = '$OBJPREFIX'
+ env['SHOBJSUFFIX'] = '$OBJSUFFIX'
+ env['PROGPREFIX'] = ''
+ env['PROGSUFFIX'] = ''
+ env['LIBPREFIX'] = 'lib'
+ env['LIBSUFFIX'] = '.a'
+ env['SHLIBPREFIX'] = '$LIBPREFIX'
+ env['SHLIBSUFFIX'] = '.so'
+ env['LIBPREFIXES'] = [ '$LIBPREFIX' ]
+ env['LIBSUFFIXES'] = [ '$LIBSUFFIX', '$SHLIBSUFFIX' ]
+ env['PSPAWN'] = pspawn
+ env['SPAWN'] = spawn
+ env['SHELL'] = 'sh'
+ env['ESCAPE'] = escape
+ env['TEMPFILE'] = TempFileMunge
+ env['TEMPFILEPREFIX'] = '@'
+ #Based on LINUX: ARG_MAX=ARG_MAX=131072 - 3000 for environment expansion
+ #Note: specific platforms might rise or lower this value
+ env['MAXLINELENGTH'] = 128072
+
+ # This platform supports RPATH specifications.
+ env['__RPATH'] = '$_RPATH'
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/src/engine/SCons/Platform/posix.xml b/src/engine/SCons/Platform/posix.xml
new file mode 100644
index 0000000..6336202
--- /dev/null
+++ b/src/engine/SCons/Platform/posix.xml
@@ -0,0 +1,51 @@
+<!--
+Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation
+
+This file is processed by the bin/SConsDoc.py module.
+See its __doc__ string for a discussion of the format.
+-->
+<cvar name="RPATH">
+<summary>
+A list of paths to search for shared libraries when running programs.
+Currently only used in the GNU (gnulink),
+IRIX (sgilink) and Sun (sunlink) linkers.
+Ignored on platforms and toolchains that don't support it.
+Note that the paths added to RPATH
+are not transformed by
+&scons;
+in any way: if you want an absolute
+path, you must make it absolute yourself.
+</summary>
+</cvar>
+
+<cvar name="_RPATH">
+<summary>
+An automatically-generated construction variable
+containing the rpath flags to be used when linking
+a program with shared libraries.
+The value of &cv-_RPATH; is created
+by appending &cv-RPATHPREFIX; and &cv-RPATHSUFFIX;
+to the beginning and end
+of each directory in &cv-RPATH;.
+</summary>
+</cvar>
+
+<cvar name="RPATHPREFIX">
+<summary>
+The prefix used to specify a directory to be searched for
+shared libraries when running programs.
+This will be appended to the beginning of each directory
+in the &cv-RPATH; construction variable
+when the &cv-_RPATH; variable is automatically generated.
+</summary>
+</cvar>
+
+<cvar name="RPATHSUFFIX">
+<summary>
+The suffix used to specify a directory to be searched for
+shared libraries when running programs.
+This will be appended to the end of each directory
+in the &cv-RPATH; construction variable
+when the &cv-_RPATH; variable is automatically generated.
+</summary>
+</cvar>
diff --git a/src/engine/SCons/Platform/sunos.py b/src/engine/SCons/Platform/sunos.py
new file mode 100644
index 0000000..5604598
--- /dev/null
+++ b/src/engine/SCons/Platform/sunos.py
@@ -0,0 +1,50 @@
+"""engine.SCons.Platform.sunos
+
+Platform-specific initialization for Sun 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, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation
+#
+# 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__ = "src/engine/SCons/Platform/sunos.py 4577 2009/12/27 19:44:43 scons"
+
+import posix
+
+def generate(env):
+ posix.generate(env)
+ # Based on sunSparc 8:32bit
+ # ARG_MAX=1048320 - 3000 for environment expansion
+ env['MAXLINELENGTH'] = 1045320
+ env['PKGINFO'] = 'pkginfo'
+ env['PKGCHK'] = '/usr/sbin/pkgchk'
+ env['ENV']['PATH'] = env['ENV']['PATH'] + ':/opt/SUNWspro/bin:/usr/ccs/bin'
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/src/engine/SCons/Platform/sunos.xml b/src/engine/SCons/Platform/sunos.xml
new file mode 100644
index 0000000..72dd85f
--- /dev/null
+++ b/src/engine/SCons/Platform/sunos.xml
@@ -0,0 +1,30 @@
+<!--
+Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation
+
+This file is processed by the bin/SConsDoc.py module.
+See its __doc__ string for a discussion of the format.
+-->
+
+<cvar name="PKGCHK">
+<summary>
+On Solaris systems,
+the package-checking program that will
+be used (along with &cv-PKGINFO;)
+to look for installed versions of
+the Sun PRO C++ compiler.
+The default is
+<filename>/usr/sbin/pgkchk</filename>.
+</summary>
+</cvar>
+
+<cvar name="PKGINFO">
+<summary>
+On Solaris systems,
+the package information program that will
+be used (along with &cv-PKGCHK;)
+to look for installed versions of
+the Sun PRO C++ compiler.
+The default is
+<filename>pkginfo</filename>.
+</summary>
+</cvar>
diff --git a/src/engine/SCons/Platform/win32.py b/src/engine/SCons/Platform/win32.py
new file mode 100644
index 0000000..5672315
--- /dev/null
+++ b/src/engine/SCons/Platform/win32.py
@@ -0,0 +1,386 @@
+"""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, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation
+#
+# 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__ = "src/engine/SCons/Platform/win32.py 4577 2009/12/27 19:44:43 scons"
+
+import os
+import os.path
+import string
+import sys
+import tempfile
+
+from SCons.Platform.posix import exitvalmap
+from SCons.Platform import TempFileMunge
+import SCons.Util
+
+try:
+ import msvcrt
+ import win32api
+ import win32con
+
+ msvcrt.get_osfhandle
+ win32api.SetHandleInformation
+ win32con.HANDLE_FLAG_INHERIT
+except ImportError:
+ parallel_msg = \
+ "you do not seem to have the pywin32 extensions installed;\n" + \
+ "\tparallel (-j) builds may not work reliably with open Python files."
+except AttributeError:
+ parallel_msg = \
+ "your pywin32 extensions do not support file handle operations;\n" + \
+ "\tparallel (-j) builds may not work reliably with open Python files."
+else:
+ parallel_msg = None
+
+ import __builtin__
+
+ _builtin_file = __builtin__.file
+ _builtin_open = __builtin__.open
+
+ def _scons_file(*args, **kw):
+ fp = apply(_builtin_file, args, kw)
+ win32api.SetHandleInformation(msvcrt.get_osfhandle(fp.fileno()),
+ win32con.HANDLE_FLAG_INHERIT,
+ 0)
+ return fp
+
+ def _scons_open(*args, **kw):
+ fp = apply(_builtin_open, args, kw)
+ win32api.SetHandleInformation(msvcrt.get_osfhandle(fp.fileno()),
+ win32con.HANDLE_FLAG_INHERIT,
+ 0)
+ return fp
+
+ __builtin__.file = _scons_file
+ __builtin__.open = _scons_open
+
+
+
+# The upshot of all this is that, if you are using Python 1.5.2,
+# you had better have cmd or command.com in your PATH when you run
+# scons.
+
+def piped_spawn(sh, escape, cmd, args, env, stdout, stderr):
+ # There is no direct way to do that in python. What we do
+ # here should work for most cases:
+ # In case stdout (stderr) is not redirected to a file,
+ # we redirect it into a temporary file tmpFileStdout
+ # (tmpFileStderr) and copy the contents of this file
+ # to stdout (stderr) given in the argument
+ if not sh:
+ sys.stderr.write("scons: Could not find command interpreter, is it in your PATH?\n")
+ return 127
+ else:
+ # one temporary file for stdout and stderr
+ tmpFileStdout = os.path.normpath(tempfile.mktemp())
+ tmpFileStderr = os.path.normpath(tempfile.mktemp())
+
+ # check if output is redirected
+ stdoutRedirected = 0
+ stderrRedirected = 0
+ for arg in args:
+ # are there more possibilities to redirect stdout ?
+ if (string.find( arg, ">", 0, 1 ) != -1 or
+ string.find( arg, "1>", 0, 2 ) != -1):
+ stdoutRedirected = 1
+ # are there more possibilities to redirect stderr ?
+ if string.find( arg, "2>", 0, 2 ) != -1:
+ stderrRedirected = 1
+
+ # redirect output of non-redirected streams to our tempfiles
+ if stdoutRedirected == 0:
+ args.append(">" + str(tmpFileStdout))
+ if stderrRedirected == 0:
+ args.append("2>" + str(tmpFileStderr))
+
+ # actually do the spawn
+ try:
+ args = [sh, '/C', escape(string.join(args)) ]
+ ret = os.spawnve(os.P_WAIT, sh, args, env)
+ except OSError, e:
+ # catch any error
+ try:
+ ret = exitvalmap[e[0]]
+ except KeyError:
+ sys.stderr.write("scons: unknown OSError exception code %d - %s: %s\n" % (e[0], cmd, e[1]))
+ if stderr is not None:
+ stderr.write("scons: %s: %s\n" % (cmd, e[1]))
+ # copy child output from tempfiles to our streams
+ # and do clean up stuff
+ if stdout is not None and stdoutRedirected == 0:
+ try:
+ stdout.write(open( tmpFileStdout, "r" ).read())
+ os.remove( tmpFileStdout )
+ except (IOError, OSError):
+ pass
+
+ if stderr is not None and stderrRedirected == 0:
+ try:
+ stderr.write(open( tmpFileStderr, "r" ).read())
+ os.remove( tmpFileStderr )
+ except (IOError, OSError):
+ pass
+ return ret
+
+def exec_spawn(l, env):
+ try:
+ result = os.spawnve(os.P_WAIT, l[0], l, env)
+ except OSError, e:
+ try:
+ result = exitvalmap[e[0]]
+ sys.stderr.write("scons: %s: %s\n" % (l[0], e[1]))
+ except KeyError:
+ result = 127
+ if len(l) > 2:
+ if len(l[2]) < 1000:
+ command = string.join(l[0:3])
+ else:
+ command = l[0]
+ else:
+ command = l[0]
+ sys.stderr.write("scons: unknown OSError exception code %d - '%s': %s\n" % (e[0], command, e[1]))
+ return result
+
+def spawn(sh, escape, cmd, args, env):
+ if not sh:
+ sys.stderr.write("scons: Could not find command interpreter, is it in your PATH?\n")
+ return 127
+ return exec_spawn([sh, '/C', escape(string.join(args))], env)
+
+# Windows does not allow special characters in file names anyway, so no
+# need for a complex escape function, we will just quote the arg, except
+# that "cmd /c" requires that if an argument ends with a backslash it
+# needs to be escaped so as not to interfere with closing double quote
+# that we add.
+def escape(x):
+ if x[-1] == '\\':
+ x = x + '\\'
+ return '"' + x + '"'
+
+# Get the windows system directory name
+_system_root = None
+
+def get_system_root():
+ global _system_root
+ if _system_root is not None:
+ return _system_root
+
+ # A resonable default if we can't read the registry
+ val = os.environ.get('SystemRoot', "C:/WINDOWS")
+
+ if SCons.Util.can_read_reg:
+ try:
+ # Look for Windows NT system root
+ k=SCons.Util.RegOpenKeyEx(SCons.Util.hkey_mod.HKEY_LOCAL_MACHINE,
+ 'Software\\Microsoft\\Windows NT\\CurrentVersion')
+ val, tok = SCons.Util.RegQueryValueEx(k, 'SystemRoot')
+ except SCons.Util.RegError:
+ try:
+ # Okay, try the Windows 9x system root
+ k=SCons.Util.RegOpenKeyEx(SCons.Util.hkey_mod.HKEY_LOCAL_MACHINE,
+ 'Software\\Microsoft\\Windows\\CurrentVersion')
+ val, tok = SCons.Util.RegQueryValueEx(k, 'SystemRoot')
+ except KeyboardInterrupt:
+ raise
+ except:
+ pass
+ _system_root = val
+ return val
+
+# Get the location of the program files directory
+def get_program_files_dir():
+ # Now see if we can look in the registry...
+ val = ''
+ if SCons.Util.can_read_reg:
+ try:
+ # Look for Windows Program Files directory
+ k=SCons.Util.RegOpenKeyEx(SCons.Util.hkey_mod.HKEY_LOCAL_MACHINE,
+ 'Software\\Microsoft\\Windows\\CurrentVersion')
+ val, tok = SCons.Util.RegQueryValueEx(k, 'ProgramFilesDir')
+ except SCons.Util.RegError:
+ val = ''
+ pass
+
+ if val == '':
+ # A reasonable default if we can't read the registry
+ # (Actually, it's pretty reasonable even if we can :-)
+ val = os.path.join(os.path.dirname(get_system_root()),"Program Files")
+
+ return val
+
+
+
+# Determine which windows CPU were running on.
+class ArchDefinition:
+ """
+ A class for defining architecture-specific settings and logic.
+ """
+ def __init__(self, arch, synonyms=[]):
+ self.arch = arch
+ self.synonyms = synonyms
+
+SupportedArchitectureList = [
+ ArchDefinition(
+ 'x86',
+ ['i386', 'i486', 'i586', 'i686'],
+ ),
+
+ ArchDefinition(
+ 'x86_64',
+ ['AMD64', 'amd64', 'em64t', 'EM64T', 'x86_64'],
+ ),
+
+ ArchDefinition(
+ 'ia64',
+ ['IA64'],
+ ),
+]
+
+SupportedArchitectureMap = {}
+for a in SupportedArchitectureList:
+ SupportedArchitectureMap[a.arch] = a
+ for s in a.synonyms:
+ SupportedArchitectureMap[s] = a
+
+def get_architecture(arch=None):
+ """Returns the definition for the specified architecture string.
+
+ If no string is specified, the system default is returned (as defined
+ by the PROCESSOR_ARCHITEW6432 or PROCESSOR_ARCHITECTURE environment
+ variables).
+ """
+ if arch is None:
+ arch = os.environ.get('PROCESSOR_ARCHITEW6432')
+ if not arch:
+ arch = os.environ.get('PROCESSOR_ARCHITECTURE')
+ return SupportedArchitectureMap.get(arch, ArchDefinition('', ['']))
+
+def generate(env):
+ # Attempt to find cmd.exe (for WinNT/2k/XP) or
+ # command.com for Win9x
+ cmd_interp = ''
+ # First see if we can look in the registry...
+ if SCons.Util.can_read_reg:
+ try:
+ # Look for Windows NT system root
+ k=SCons.Util.RegOpenKeyEx(SCons.Util.hkey_mod.HKEY_LOCAL_MACHINE,
+ 'Software\\Microsoft\\Windows NT\\CurrentVersion')
+ val, tok = SCons.Util.RegQueryValueEx(k, 'SystemRoot')
+ cmd_interp = os.path.join(val, 'System32\\cmd.exe')
+ except SCons.Util.RegError:
+ try:
+ # Okay, try the Windows 9x system root
+ k=SCons.Util.RegOpenKeyEx(SCons.Util.hkey_mod.HKEY_LOCAL_MACHINE,
+ 'Software\\Microsoft\\Windows\\CurrentVersion')
+ val, tok = SCons.Util.RegQueryValueEx(k, 'SystemRoot')
+ cmd_interp = os.path.join(val, 'command.com')
+ except KeyboardInterrupt:
+ raise
+ except:
+ pass
+
+ # For the special case of not having access to the registry, we
+ # use a temporary path and pathext to attempt to find the command
+ # interpreter. If we fail, we try to find the interpreter through
+ # the env's PATH. The problem with that is that it might not
+ # contain an ENV and a PATH.
+ if not cmd_interp:
+ systemroot = get_system_root()
+ tmp_path = systemroot + os.pathsep + \
+ os.path.join(systemroot,'System32')
+ tmp_pathext = '.com;.exe;.bat;.cmd'
+ if os.environ.has_key('PATHEXT'):
+ tmp_pathext = os.environ['PATHEXT']
+ cmd_interp = SCons.Util.WhereIs('cmd', tmp_path, tmp_pathext)
+ if not cmd_interp:
+ cmd_interp = SCons.Util.WhereIs('command', tmp_path, tmp_pathext)
+
+ if not cmd_interp:
+ cmd_interp = env.Detect('cmd')
+ if not cmd_interp:
+ cmd_interp = env.Detect('command')
+
+
+ if not env.has_key('ENV'):
+ env['ENV'] = {}
+
+ # Import things from the external environment to the construction
+ # environment's ENV. This is a potential slippery slope, because we
+ # *don't* want to make builds dependent on the user's environment by
+ # default. We're doing this for SystemRoot, though, because it's
+ # needed for anything that uses sockets, and seldom changes, and
+ # for SystemDrive because it's related.
+ #
+ # Weigh the impact carefully before adding other variables to this list.
+ import_env = [ 'SystemDrive', 'SystemRoot', 'TEMP', 'TMP' ]
+ for var in import_env:
+ v = os.environ.get(var)
+ if v:
+ env['ENV'][var] = v
+
+ if not env['ENV'].has_key('COMSPEC'):
+ v = os.environ.get("COMSPEC")
+ if v:
+ env['ENV']['COMSPEC'] = v
+
+ env.AppendENVPath('PATH', get_system_root() + '\System32')
+
+ env['ENV']['PATHEXT'] = '.COM;.EXE;.BAT;.CMD'
+ env['OBJPREFIX'] = ''
+ env['OBJSUFFIX'] = '.obj'
+ env['SHOBJPREFIX'] = '$OBJPREFIX'
+ env['SHOBJSUFFIX'] = '$OBJSUFFIX'
+ env['PROGPREFIX'] = ''
+ env['PROGSUFFIX'] = '.exe'
+ env['LIBPREFIX'] = ''
+ env['LIBSUFFIX'] = '.lib'
+ env['SHLIBPREFIX'] = ''
+ env['SHLIBSUFFIX'] = '.dll'
+ env['LIBPREFIXES'] = [ '$LIBPREFIX' ]
+ env['LIBSUFFIXES'] = [ '$LIBSUFFIX' ]
+ env['PSPAWN'] = piped_spawn
+ env['SPAWN'] = spawn
+ env['SHELL'] = cmd_interp
+ env['TEMPFILE'] = TempFileMunge
+ env['TEMPFILEPREFIX'] = '@'
+ env['MAXLINELENGTH'] = 2048
+ env['ESCAPE'] = escape
+
+ env['HOST_OS'] = 'win32'
+ env['HOST_ARCH'] = get_architecture().arch
+
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/src/engine/SCons/Platform/win32.xml b/src/engine/SCons/Platform/win32.xml
new file mode 100644
index 0000000..dc60c90
--- /dev/null
+++ b/src/engine/SCons/Platform/win32.xml
@@ -0,0 +1,14 @@
+<!--
+Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation
+
+This file is processed by the bin/SConsDoc.py module.
+See its __doc__ string for a discussion of the format.
+-->
+<cvar name="MAXLINELENGTH">
+<summary>
+The maximum number of characters allowed on an external command line.
+On Win32 systems,
+link lines longer than this many characters
+are linked via a temporary file name.
+</summary>
+</cvar>