summaryrefslogtreecommitdiff
path: root/engine/SCons/Platform
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2017-10-01 13:23:10 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2017-10-01 13:23:10 +0200
commit0414abd565dbdf12ea741930bef5268bc7fe6da3 (patch)
treeaa7e983f81ffe2090fa31869b6670bf18bcc28a0 /engine/SCons/Platform
parent3765e33b76c51c81dd7bbbfacab0c4e76a1713cb (diff)
parent3bab2962eecc24c19366692e52ebca5eb835d117 (diff)
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'engine/SCons/Platform')
-rw-r--r--engine/SCons/Platform/__init__.py25
-rw-r--r--engine/SCons/Platform/aix.py6
-rw-r--r--engine/SCons/Platform/cygwin.py6
-rw-r--r--engine/SCons/Platform/darwin.py10
-rw-r--r--engine/SCons/Platform/hpux.py6
-rw-r--r--engine/SCons/Platform/irix.py6
-rw-r--r--engine/SCons/Platform/os2.py6
-rw-r--r--engine/SCons/Platform/posix.py6
-rw-r--r--engine/SCons/Platform/sunos.py6
-rw-r--r--engine/SCons/Platform/win32.py113
10 files changed, 127 insertions, 63 deletions
diff --git a/engine/SCons/Platform/__init__.py b/engine/SCons/Platform/__init__.py
index c95f291..61a4010 100644
--- a/engine/SCons/Platform/__init__.py
+++ b/engine/SCons/Platform/__init__.py
@@ -20,8 +20,8 @@ their own platform definition.
"""
#
-# Copyright (c) 2001 - 2016 The SCons Foundation
-#
+# Copyright (c) 2001 - 2017 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
@@ -41,8 +41,9 @@ their own platform definition.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
+from __future__ import print_function
-__revision__ = "src/engine/SCons/Platform/__init__.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"
+__revision__ = "src/engine/SCons/Platform/__init__.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
import SCons.compat
@@ -55,6 +56,7 @@ import SCons.Errors
import SCons.Subst
import SCons.Tool
+
def platform_default():
"""Return the platform string for our execution environment.
@@ -130,7 +132,7 @@ class PlatformSpec(object):
def __str__(self):
return self.name
-
+
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
@@ -183,9 +185,9 @@ class TempFileMunge(object):
node = target[0] if SCons.Util.is_List(target) else target
cmdlist = getattr(node.attributes, 'tempfile_cmdlist', None) \
if node is not None else None
- if cmdlist is not None :
+ if cmdlist is not None :
return cmdlist
-
+
# 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
@@ -215,7 +217,7 @@ class TempFileMunge(object):
prefix = '@'
args = list(map(SCons.Subst.quote_spaces, cmd[1:]))
- os.write(fd, " ".join(args) + "\n")
+ os.write(fd, bytearray(" ".join(args) + "\n",'utf-8'))
os.close(fd)
# XXX Using the SCons.Action.print_actions value directly
# like this is bogus, but expedient. This class should
@@ -233,14 +235,14 @@ class TempFileMunge(object):
# purity get in the way of just being helpful, so we'll
# reach into SCons.Action directly.
if SCons.Action.print_actions:
- cmdstr = env.subst(self.cmdstr, SCons.Subst.SUBST_RAW, target,
+ cmdstr = env.subst(self.cmdstr, SCons.Subst.SUBST_RAW, target,
source) if self.cmdstr is not None else ''
# Print our message only if XXXCOMSTR returns an empty string
if len(cmdstr) == 0 :
print("Using tempfile "+native_tmp+" for command line:\n"+
str(cmd[0]) + " " + " ".join(args))
-
- # Store the temporary file command list into the target Node.attributes
+
+ # Store the temporary file command list into the target Node.attributes
# to avoid creating two temporary files one for print and one for execute.
cmdlist = [ cmd[0], prefix + native_tmp + '\n' + rm, native_tmp ]
if node is not None:
@@ -249,7 +251,8 @@ class TempFileMunge(object):
except AttributeError:
pass
return cmdlist
-
+
+
def Platform(name = platform_default()):
"""Select a canned Platform specification.
"""
diff --git a/engine/SCons/Platform/aix.py b/engine/SCons/Platform/aix.py
index 42de812..caeb3fb 100644
--- a/engine/SCons/Platform/aix.py
+++ b/engine/SCons/Platform/aix.py
@@ -8,7 +8,7 @@ selection method.
"""
#
-# Copyright (c) 2001 - 2016 The SCons Foundation
+# Copyright (c) 2001 - 2017 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -30,12 +30,12 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/aix.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"
+__revision__ = "src/engine/SCons/Platform/aix.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
import os
import subprocess
-import posix
+from . import posix
import SCons.Util
import SCons.Action
diff --git a/engine/SCons/Platform/cygwin.py b/engine/SCons/Platform/cygwin.py
index 6922cf1..0e30b5f 100644
--- a/engine/SCons/Platform/cygwin.py
+++ b/engine/SCons/Platform/cygwin.py
@@ -8,7 +8,7 @@ selection method.
"""
#
-# Copyright (c) 2001 - 2016 The SCons Foundation
+# Copyright (c) 2001 - 2017 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -30,9 +30,9 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/cygwin.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"
+__revision__ = "src/engine/SCons/Platform/cygwin.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
-import posix
+from . import posix
from SCons.Platform import TempFileMunge
def generate(env):
diff --git a/engine/SCons/Platform/darwin.py b/engine/SCons/Platform/darwin.py
index d3b77db..70ffcf4 100644
--- a/engine/SCons/Platform/darwin.py
+++ b/engine/SCons/Platform/darwin.py
@@ -8,7 +8,7 @@ selection method.
"""
#
-# Copyright (c) 2001 - 2016 The SCons Foundation
+# Copyright (c) 2001 - 2017 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -30,9 +30,9 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/darwin.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"
+__revision__ = "src/engine/SCons/Platform/darwin.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
-import posix
+from . import posix
import os
def generate(env):
@@ -63,6 +63,10 @@ def generate(env):
env.AppendENVPath('PATHOSX', line.strip('\n'))
f.close()
+ # Not sure why this wasn't the case all along?
+ if env['ENV'].get('PATHOSX', False) and os.environ.get('SCONS_USE_MAC_PATHS', False):
+ env.AppendENVPath('PATH',env['ENV']['PATHOSX'])
+
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
diff --git a/engine/SCons/Platform/hpux.py b/engine/SCons/Platform/hpux.py
index b66a791..8b34901 100644
--- a/engine/SCons/Platform/hpux.py
+++ b/engine/SCons/Platform/hpux.py
@@ -8,7 +8,7 @@ selection method.
"""
#
-# Copyright (c) 2001 - 2016 The SCons Foundation
+# Copyright (c) 2001 - 2017 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -30,9 +30,9 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/hpux.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"
+__revision__ = "src/engine/SCons/Platform/hpux.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
-import posix
+from . import posix
def generate(env):
posix.generate(env)
diff --git a/engine/SCons/Platform/irix.py b/engine/SCons/Platform/irix.py
index 1d57400..1ff4530 100644
--- a/engine/SCons/Platform/irix.py
+++ b/engine/SCons/Platform/irix.py
@@ -8,7 +8,7 @@ selection method.
"""
#
-# Copyright (c) 2001 - 2016 The SCons Foundation
+# Copyright (c) 2001 - 2017 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -30,9 +30,9 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/irix.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"
+__revision__ = "src/engine/SCons/Platform/irix.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
-import posix
+from . import posix
def generate(env):
posix.generate(env)
diff --git a/engine/SCons/Platform/os2.py b/engine/SCons/Platform/os2.py
index 584e1ed..cd1c35c 100644
--- a/engine/SCons/Platform/os2.py
+++ b/engine/SCons/Platform/os2.py
@@ -8,7 +8,7 @@ selection method.
"""
#
-# Copyright (c) 2001 - 2016 The SCons Foundation
+# Copyright (c) 2001 - 2017 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -30,8 +30,8 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/os2.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"
-import win32
+__revision__ = "src/engine/SCons/Platform/os2.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
+from . import win32
def generate(env):
if 'ENV' not in env:
diff --git a/engine/SCons/Platform/posix.py b/engine/SCons/Platform/posix.py
index c2d3e50..890a70a 100644
--- a/engine/SCons/Platform/posix.py
+++ b/engine/SCons/Platform/posix.py
@@ -8,7 +8,7 @@ selection method.
"""
#
-# Copyright (c) 2001 - 2016 The SCons Foundation
+# Copyright (c) 2001 - 2017 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/posix.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"
+__revision__ = "src/engine/SCons/Platform/posix.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
import errno
import os
@@ -56,7 +56,7 @@ def escape(arg):
for c in special:
arg = arg.replace(c, slash+c)
- # print "ESCAPE RESULT: %s"%arg
+ # print("ESCAPE RESULT: %s" % arg)
return '"' + arg + '"'
diff --git a/engine/SCons/Platform/sunos.py b/engine/SCons/Platform/sunos.py
index 77862a5..3279fb9 100644
--- a/engine/SCons/Platform/sunos.py
+++ b/engine/SCons/Platform/sunos.py
@@ -8,7 +8,7 @@ selection method.
"""
#
-# Copyright (c) 2001 - 2016 The SCons Foundation
+# Copyright (c) 2001 - 2017 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -30,9 +30,9 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/sunos.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"
+__revision__ = "src/engine/SCons/Platform/sunos.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
-import posix
+from . import posix
def generate(env):
posix.generate(env)
diff --git a/engine/SCons/Platform/win32.py b/engine/SCons/Platform/win32.py
index dacb27d..79955e7 100644
--- a/engine/SCons/Platform/win32.py
+++ b/engine/SCons/Platform/win32.py
@@ -8,7 +8,7 @@ selection method.
"""
#
-# Copyright (c) 2001 - 2016 The SCons Foundation
+# Copyright (c) 2001 - 2017 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -30,7 +30,7 @@ selection method.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Platform/win32.py rel_2.5.1:3735:9dc6cee5c168 2016/11/03 14:02:02 bdbaddog"
+__revision__ = "src/engine/SCons/Platform/win32.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
import os
import os.path
@@ -60,15 +60,8 @@ except AttributeError:
else:
parallel_msg = None
- _builtin_file = file
_builtin_open = open
- class _scons_file(_builtin_file):
- def __init__(self, *args, **kw):
- _builtin_file.__init__(self, *args, **kw)
- win32api.SetHandleInformation(msvcrt.get_osfhandle(self.fileno()),
- win32con.HANDLE_FLAG_INHERIT, 0)
-
def _scons_open(*args, **kw):
fp = _builtin_open(*args, **kw)
win32api.SetHandleInformation(msvcrt.get_osfhandle(fp.fileno()),
@@ -76,13 +69,64 @@ else:
0)
return fp
- file = _scons_file
open = _scons_open
+ if sys.version_info.major == 2:
+ _builtin_file = file
+ class _scons_file(_builtin_file):
+ def __init__(self, *args, **kw):
+ _builtin_file.__init__(self, *args, **kw)
+ win32api.SetHandleInformation(msvcrt.get_osfhandle(self.fileno()),
+ win32con.HANDLE_FLAG_INHERIT, 0)
+ file = _scons_file
+ else:
+ import io
+ for io_class in ['BufferedReader', 'BufferedWriter', 'BufferedRWPair',
+ 'BufferedRandom', 'TextIOWrapper']:
+ _builtin_file = getattr(io, io_class)
+ class _scons_file(_builtin_file):
+ def __init__(self, *args, **kw):
+ _builtin_file.__init__(self, *args, **kw)
+ win32api.SetHandleInformation(msvcrt.get_osfhandle(self.fileno()),
+ win32con.HANDLE_FLAG_INHERIT, 0)
+ setattr(io, io_class, _scons_file)
+
+
+
+if False:
+ # Now swap out shutil.filecopy and filecopy2 for win32 api native CopyFile
+ try:
+ from ctypes import windll
+ import shutil
+
+ CopyFile = windll.kernel32.CopyFileA
+ SetFileTime = windll.kernel32.SetFileTime
+
+ _shutil_copy = shutil.copy
+ _shutil_copy2 = shutil.copy2
+
+ shutil.copy2 = CopyFile
+
+ def win_api_copyfile(src,dst):
+ CopyFile(src,dst)
+ os.utime(dst)
+
+ shutil.copy = win_api_copyfile
+
+ except AttributeError:
+ parallel_msg = \
+ "Couldn't override shutil.copy or shutil.copy2 falling back to shutil defaults"
+
+
+
+
+
+
+
try:
import threading
spawn_lock = threading.Lock()
-
+
# This locked version of spawnve works around a Windows
# MSVCRT bug, because its spawnve is not thread-safe.
# Without this, python can randomly crash while using -jN.
@@ -111,11 +155,12 @@ except ImportError:
# simulating a non-existent package.
def spawnve(mode, file, args, env):
return os.spawnve(mode, file, args, env)
-
+
# 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:
@@ -136,8 +181,7 @@ def piped_spawn(sh, escape, cmd, args, env, stdout, stderr):
stderrRedirected = 0
for arg in args:
# are there more possibilities to redirect stdout ?
- if (arg.find( ">", 0, 1 ) != -1 or
- arg.find( "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 arg.find( "2>", 0, 2 ) != -1:
@@ -153,7 +197,7 @@ def piped_spawn(sh, escape, cmd, args, env, stdout, stderr):
try:
args = [sh, '/C', escape(' '.join(args)) ]
ret = spawnve(os.P_WAIT, sh, args, env)
- except OSError, e:
+ except OSError as e:
# catch any error
try:
ret = exitvalmap[e[0]]
@@ -178,13 +222,14 @@ def piped_spawn(sh, escape, cmd, args, env, stdout, stderr):
pass
return ret
+
def exec_spawn(l, env):
try:
result = spawnve(os.P_WAIT, l[0], l, env)
- except OSError, e:
+ except (OSError, EnvironmentError) as e:
try:
- result = exitvalmap[e[0]]
- sys.stderr.write("scons: %s: %s\n" % (l[0], e[1]))
+ result = exitvalmap[e.errno]
+ sys.stderr.write("scons: %s: %s\n" % (l[0], e.strerror))
except KeyError:
result = 127
if len(l) > 2:
@@ -194,9 +239,10 @@ def exec_spawn(l, env):
command = l[0]
else:
command = l[0]
- sys.stderr.write("scons: unknown OSError exception code %d - '%s': %s\n" % (e[0], command, e[1]))
+ sys.stderr.write("scons: unknown OSError exception code %d - '%s': %s\n" % (e.errno, command, e.strerror))
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")
@@ -216,6 +262,7 @@ def escape(x):
# Get the windows system directory name
_system_root = None
+
def get_system_root():
global _system_root
if _system_root is not None:
@@ -240,11 +287,21 @@ def get_system_root():
raise
except:
pass
+
+ # Ensure system root is a string and not unicode
+ # (This only matters for py27 were unicode in env passed to POpen fails)
+ val = str(val)
_system_root = val
return val
-# Get the location of the program files directory
+
def get_program_files_dir():
+ """
+ Get the location of the program files directory
+ Returns
+ -------
+
+ """
# Now see if we can look in the registry...
val = ''
if SCons.Util.can_read_reg:
@@ -261,14 +318,13 @@ def get_program_files_dir():
# 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
+ return val
-# Determine which windows CPU were running on.
class ArchDefinition(object):
"""
+ Determine which windows CPU were running on.
A class for defining architecture-specific settings and logic.
"""
def __init__(self, arch, synonyms=[]):
@@ -298,6 +354,7 @@ for a in SupportedArchitectureList:
for s in a.synonyms:
SupportedArchitectureMap[s] = a
+
def get_architecture(arch=None):
"""Returns the definition for the specified architecture string.
@@ -311,6 +368,7 @@ def get_architecture(arch=None):
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
@@ -346,7 +404,7 @@ def generate(env):
os.path.join(systemroot,'System32')
tmp_pathext = '.com;.exe;.bat;.cmd'
if 'PATHEXT' in os.environ:
- tmp_pathext = os.environ['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)
@@ -356,7 +414,6 @@ def generate(env):
if not cmd_interp:
cmd_interp = env.Detect('command')
-
if 'ENV' not in env:
env['ENV'] = {}
@@ -368,7 +425,7 @@ def generate(env):
# for SystemDrive because it's related.
#
# Weigh the impact carefully before adding other variables to this list.
- import_env = [ 'SystemDrive', 'SystemRoot', 'TEMP', 'TMP' ]
+ import_env = ['SystemDrive', 'SystemRoot', 'TEMP', 'TMP' ]
for var in import_env:
v = os.environ.get(var)
if v:
@@ -401,10 +458,10 @@ def generate(env):
env['TEMPFILEPREFIX'] = '@'
env['MAXLINELENGTH'] = 2048
env['ESCAPE'] = escape
-
+
env['HOST_OS'] = 'win32'
env['HOST_ARCH'] = get_architecture().arch
-
+
# Local Variables:
# tab-width:4