summaryrefslogtreecommitdiff
path: root/engine/SCons/Platform/__init__.py
diff options
context:
space:
mode:
authorLuca Falavigna <dktrkranz@debian.org>2010-06-15 09:21:32 +0000
committerLuca Falavigna <dktrkranz@debian.org>2010-06-15 09:21:32 +0000
commit340d57481935334465037d97c0db1555b70c0eb1 (patch)
tree8396a9a52eed6e40268c1916bcfa8957dddef71c /engine/SCons/Platform/__init__.py
parent86baccee0a1dddf43f7eefe48e2d9e9037468b9c (diff)
Imported Upstream version 2.0.0upstream/2.0.0
Diffstat (limited to 'engine/SCons/Platform/__init__.py')
-rw-r--r--engine/SCons/Platform/__init__.py43
1 files changed, 24 insertions, 19 deletions
diff --git a/engine/SCons/Platform/__init__.py b/engine/SCons/Platform/__init__.py
index 33cad25..7e6288d 100644
--- a/engine/SCons/Platform/__init__.py
+++ b/engine/SCons/Platform/__init__.py
@@ -42,13 +42,12 @@ their own platform definition.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/__init__.py 4720 2010/03/24 03:14:11 jars"
+__revision__ = "src/engine/SCons/Platform/__init__.py 5023 2010/06/14 22:05:46 scons"
import SCons.compat
import imp
import os
-import string
import sys
import tempfile
@@ -69,15 +68,15 @@ def platform_default():
if osname == 'posix':
if sys.platform == 'cygwin':
return 'cygwin'
- elif string.find(sys.platform, 'irix') != -1:
+ elif sys.platform.find('irix') != -1:
return 'irix'
- elif string.find(sys.platform, 'sunos') != -1:
+ elif sys.platform.find('sunos') != -1:
return 'sunos'
- elif string.find(sys.platform, 'hp-ux') != -1:
+ elif sys.platform.find('hp-ux') != -1:
return 'hpux'
- elif string.find(sys.platform, 'aix') != -1:
+ elif sys.platform.find('aix') != -1:
return 'aix'
- elif string.find(sys.platform, 'darwin') != -1:
+ elif sys.platform.find('darwin') != -1:
return 'darwin'
else:
return 'posix'
@@ -94,7 +93,7 @@ def platform_module(name = platform_default()):
our execution environment.
"""
full_name = 'SCons.Platform.' + name
- if not sys.modules.has_key(full_name):
+ if full_name not in sys.modules:
if os.name == 'java':
eval(full_name)
else:
@@ -112,7 +111,7 @@ def platform_module(name = platform_default()):
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
+ raise SCons.Errors.UserError("No platform named '%s'" % name)
setattr(SCons.Platform, name, mod)
return sys.modules[full_name]
@@ -121,14 +120,18 @@ def DefaultToolList(platform, env):
"""
return SCons.Tool.tool_list(platform, env)
-class PlatformSpec:
- def __init__(self, name):
+class PlatformSpec(object):
+ def __init__(self, name, generate):
self.name = name
+ self.generate = generate
+
+ def __call__(self, *args, **kw):
+ return self.generate(*args, **kw)
def __str__(self):
return self.name
-class TempFileMunge:
+class TempFileMunge(object):
"""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
@@ -167,7 +170,10 @@ class TempFileMunge:
except ValueError:
maxline = 2048
- if (reduce(lambda x, y: x + len(y), cmd, 0) + len(cmd)) <= maxline:
+ length = 0
+ for c in cmd:
+ length += len(c)
+ if length <= maxline:
return self.cmd
# We do a normpath because mktemp() has what appears to be
@@ -184,7 +190,7 @@ class TempFileMunge:
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'\\\\')
+ native_tmp = native_tmp.replace('\\', 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'
@@ -198,8 +204,8 @@ class TempFileMunge:
if not prefix:
prefix = '@'
- args = map(SCons.Subst.quote_spaces, cmd[1:])
- os.write(fd, string.join(args, " ") + "\n")
+ args = list(map(SCons.Subst.quote_spaces, cmd[1:]))
+ os.write(fd, " ".join(args) + "\n")
os.close(fd)
# XXX Using the SCons.Action.print_actions value directly
# like this is bogus, but expedient. This class should
@@ -218,15 +224,14 @@ class TempFileMunge:
# 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," "))
+ str(cmd[0]) + " " + " ".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
+ spec = PlatformSpec(name, module.generate)
return spec
# Local Variables: