summaryrefslogtreecommitdiff
path: root/engine/SCons/Platform
diff options
context:
space:
mode:
Diffstat (limited to 'engine/SCons/Platform')
-rw-r--r--engine/SCons/Platform/__init__.py43
-rw-r--r--engine/SCons/Platform/aix.py9
-rw-r--r--engine/SCons/Platform/cygwin.py2
-rw-r--r--engine/SCons/Platform/darwin.py2
-rw-r--r--engine/SCons/Platform/hpux.py2
-rw-r--r--engine/SCons/Platform/irix.py2
-rw-r--r--engine/SCons/Platform/os2.py4
-rw-r--r--engine/SCons/Platform/posix.py27
-rw-r--r--engine/SCons/Platform/sunos.py2
-rw-r--r--engine/SCons/Platform/win32.py37
10 files changed, 66 insertions, 64 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:
diff --git a/engine/SCons/Platform/aix.py b/engine/SCons/Platform/aix.py
index 039d3d4..e729bcb 100644
--- a/engine/SCons/Platform/aix.py
+++ b/engine/SCons/Platform/aix.py
@@ -30,10 +30,9 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/aix.py 4720 2010/03/24 03:14:11 jars"
+__revision__ = "src/engine/SCons/Platform/aix.py 5023 2010/06/14 22:05:46 scons"
import os
-import string
import posix
@@ -51,9 +50,9 @@ def get_xlc(env, xlc=None, xlc_r=None, 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]
+ v, p = line.split(':')[1:3]
+ xlcVersion = v.split()[1]
+ xlcPath = p.split()[0]
xlcPath = xlcPath[:xlcPath.rindex('/')]
break
return (xlcPath, xlc, xlc_r, xlcVersion)
diff --git a/engine/SCons/Platform/cygwin.py b/engine/SCons/Platform/cygwin.py
index 0105ae9..854a2c5 100644
--- a/engine/SCons/Platform/cygwin.py
+++ b/engine/SCons/Platform/cygwin.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/cygwin.py 4720 2010/03/24 03:14:11 jars"
+__revision__ = "src/engine/SCons/Platform/cygwin.py 5023 2010/06/14 22:05:46 scons"
import posix
from SCons.Platform import TempFileMunge
diff --git a/engine/SCons/Platform/darwin.py b/engine/SCons/Platform/darwin.py
index 18c58f2..4d62517 100644
--- a/engine/SCons/Platform/darwin.py
+++ b/engine/SCons/Platform/darwin.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/darwin.py 4720 2010/03/24 03:14:11 jars"
+__revision__ = "src/engine/SCons/Platform/darwin.py 5023 2010/06/14 22:05:46 scons"
import posix
diff --git a/engine/SCons/Platform/hpux.py b/engine/SCons/Platform/hpux.py
index d5ce3bb..4544dfb 100644
--- a/engine/SCons/Platform/hpux.py
+++ b/engine/SCons/Platform/hpux.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/hpux.py 4720 2010/03/24 03:14:11 jars"
+__revision__ = "src/engine/SCons/Platform/hpux.py 5023 2010/06/14 22:05:46 scons"
import posix
diff --git a/engine/SCons/Platform/irix.py b/engine/SCons/Platform/irix.py
index 95df7eb..3daebf5 100644
--- a/engine/SCons/Platform/irix.py
+++ b/engine/SCons/Platform/irix.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/irix.py 4720 2010/03/24 03:14:11 jars"
+__revision__ = "src/engine/SCons/Platform/irix.py 5023 2010/06/14 22:05:46 scons"
import posix
diff --git a/engine/SCons/Platform/os2.py b/engine/SCons/Platform/os2.py
index 973ac6b..e74a22c 100644
--- a/engine/SCons/Platform/os2.py
+++ b/engine/SCons/Platform/os2.py
@@ -30,11 +30,11 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/os2.py 4720 2010/03/24 03:14:11 jars"
+__revision__ = "src/engine/SCons/Platform/os2.py 5023 2010/06/14 22:05:46 scons"
import win32
def generate(env):
- if not env.has_key('ENV'):
+ if 'ENV' not in env:
env['ENV'] = {}
env['OBJPREFIX'] = ''
env['OBJSUFFIX'] = '.obj'
diff --git a/engine/SCons/Platform/posix.py b/engine/SCons/Platform/posix.py
index 67aef3e..1f19277 100644
--- a/engine/SCons/Platform/posix.py
+++ b/engine/SCons/Platform/posix.py
@@ -30,12 +30,11 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/posix.py 4720 2010/03/24 03:14:11 jars"
+__revision__ = "src/engine/SCons/Platform/posix.py 5023 2010/06/14 22:05:46 scons"
import errno
import os
import os.path
-import string
import subprocess
import sys
import select
@@ -53,14 +52,14 @@ def escape(arg):
slash = '\\'
special = '"$()'
- arg = string.replace(arg, slash, slash+slash)
+ arg = arg.replace(slash, slash+slash)
for c in special:
- arg = string.replace(arg, c, slash+c)
+ arg = arg.replace(c, slash+c)
return '"' + arg + '"'
def exec_system(l, env):
- stat = os.system(string.join(l))
+ stat = os.system(' '.join(l))
if stat & 0xff:
return stat | 0x80
return stat >> 8
@@ -90,22 +89,22 @@ def exec_fork(l, env):
return stat >> 8
def _get_env_command(sh, escape, cmd, args, env):
- s = string.join(args)
+ s = ' '.join(args)
if env:
l = ['env', '-'] + \
- map(lambda t, e=escape: e(t[0])+'='+e(t[1]), env.items()) + \
+ [escape(t[0])+'='+escape(t[1]) for t in env.items()] + \
[sh, '-c', escape(s)]
- s = string.join(l)
+ s = ' '.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)
+ return exec_spawnvpe([sh, '-c', ' '.join(args)], env)
def fork_spawn(sh, escape, cmd, args, env):
- return exec_fork([sh, '-c', string.join(args)], env)
+ return exec_fork([sh, '-c', ' '.join(args)], env)
def process_cmd_output(cmd_stdout, cmd_stderr, stdout, stderr):
stdout_eof = stderr_eof = 0
@@ -131,7 +130,7 @@ def process_cmd_output(cmd_stdout, cmd_stderr, stdout, stderr):
raise
def exec_popen3(l, env, stdout, stderr):
- proc = subprocess.Popen(string.join(l),
+ proc = subprocess.Popen(' '.join(l),
stdout=stdout,
stderr=stderr,
shell=True)
@@ -198,7 +197,7 @@ def piped_env_spawn(sh, escape, cmd, args, 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)],
+ return exec_piped_fork([sh, '-c', ' '.join(args)],
env, stdout, stderr)
@@ -217,7 +216,7 @@ def generate(env):
# 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'):
+ if 'spawnvpe' in os.__dict__:
spawn = spawnvpe_spawn
elif env.Detect('env'):
spawn = env_spawn
@@ -229,7 +228,7 @@ def generate(env):
else:
pspawn = piped_fork_spawn
- if not env.has_key('ENV'):
+ if 'ENV' not in env:
env['ENV'] = {}
env['ENV']['PATH'] = '/usr/local/bin:/opt/bin:/bin:/usr/bin'
env['OBJPREFIX'] = ''
diff --git a/engine/SCons/Platform/sunos.py b/engine/SCons/Platform/sunos.py
index 0a816db..f855aa8 100644
--- a/engine/SCons/Platform/sunos.py
+++ b/engine/SCons/Platform/sunos.py
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/sunos.py 4720 2010/03/24 03:14:11 jars"
+__revision__ = "src/engine/SCons/Platform/sunos.py 5023 2010/06/14 22:05:46 scons"
import posix
diff --git a/engine/SCons/Platform/win32.py b/engine/SCons/Platform/win32.py
index 1443099..57d9bdc 100644
--- a/engine/SCons/Platform/win32.py
+++ b/engine/SCons/Platform/win32.py
@@ -30,11 +30,10 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/win32.py 4720 2010/03/24 03:14:11 jars"
+__revision__ = "src/engine/SCons/Platform/win32.py 5023 2010/06/14 22:05:46 scons"
import os
import os.path
-import string
import sys
import tempfile
@@ -61,27 +60,27 @@ except AttributeError:
else:
parallel_msg = None
- import __builtin__
+ import builtins
- _builtin_file = __builtin__.file
- _builtin_open = __builtin__.open
+ _builtin_file = builtins.file
+ _builtin_open = builtins.open
def _scons_file(*args, **kw):
- fp = apply(_builtin_file, args, kw)
+ fp = _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)
+ fp = _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
+ builtins.file = _scons_file
+ builtins.open = _scons_open
@@ -109,11 +108,11 @@ def piped_spawn(sh, escape, cmd, args, env, stdout, stderr):
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):
+ if (arg.find( ">", 0, 1 ) != -1 or
+ arg.find( "1>", 0, 2 ) != -1):
stdoutRedirected = 1
# are there more possibilities to redirect stderr ?
- if string.find( arg, "2>", 0, 2 ) != -1:
+ if arg.find( "2>", 0, 2 ) != -1:
stderrRedirected = 1
# redirect output of non-redirected streams to our tempfiles
@@ -124,7 +123,7 @@ def piped_spawn(sh, escape, cmd, args, env, stdout, stderr):
# actually do the spawn
try:
- args = [sh, '/C', escape(string.join(args)) ]
+ args = [sh, '/C', escape(' '.join(args)) ]
ret = os.spawnve(os.P_WAIT, sh, args, env)
except OSError, e:
# catch any error
@@ -162,7 +161,7 @@ def exec_spawn(l, env):
result = 127
if len(l) > 2:
if len(l[2]) < 1000:
- command = string.join(l[0:3])
+ command = ' '.join(l[0:3])
else:
command = l[0]
else:
@@ -174,7 +173,7 @@ 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)
+ return exec_spawn([sh, '/C', escape(' '.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
@@ -240,7 +239,7 @@ def get_program_files_dir():
# Determine which windows CPU were running on.
-class ArchDefinition:
+class ArchDefinition(object):
"""
A class for defining architecture-specific settings and logic.
"""
@@ -318,7 +317,7 @@ def generate(env):
tmp_path = systemroot + os.pathsep + \
os.path.join(systemroot,'System32')
tmp_pathext = '.com;.exe;.bat;.cmd'
- if os.environ.has_key('PATHEXT'):
+ if 'PATHEXT' in os.environ:
tmp_pathext = os.environ['PATHEXT']
cmd_interp = SCons.Util.WhereIs('cmd', tmp_path, tmp_pathext)
if not cmd_interp:
@@ -330,7 +329,7 @@ def generate(env):
cmd_interp = env.Detect('command')
- if not env.has_key('ENV'):
+ if 'ENV' not in env:
env['ENV'] = {}
# Import things from the external environment to the construction
@@ -347,7 +346,7 @@ def generate(env):
if v:
env['ENV'][var] = v
- if not env['ENV'].has_key('COMSPEC'):
+ if 'COMSPEC' not in env['ENV']:
v = os.environ.get("COMSPEC")
if v:
env['ENV']['COMSPEC'] = v