summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2019-01-16 00:28:02 (GMT)
committerMats Wichmann <mats@linux.com>2019-01-16 00:28:02 (GMT)
commitb04db00ba0818a1f22c08491b50fc7977cbe8bbd (patch)
treeba1ffc4d8a8725dba639034cc3dbb84a1521b9f1 /src
parentf3739c4f655b26b96e82945c07bc3c5d51edd2f8 (diff)
downloadSCons-b04db00ba0818a1f22c08491b50fc7977cbe8bbd.zip
SCons-b04db00ba0818a1f22c08491b50fc7977cbe8bbd.tar.gz
SCons-b04db00ba0818a1f22c08491b50fc7977cbe8bbd.tar.bz2
[WIP] customizable tempfile extension (issue #2431)
Apply the patch (adjusted) from issue #2341: instead of hardcoding the filename extenstion for the tempfile to help with linking on Windows targets, allow some variability. Current marked WIP because there are some other comments in the issue tracker that can maybe be flushed out by submitting this PR, and there are no tests (should presumably go in test/TEMPFILEPREFIX.py, or a new test TEMPFILEEXTENSION.py) Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'src')
-rw-r--r--src/CHANGES.txt2
-rw-r--r--src/engine/SCons/Platform/__init__.py35
2 files changed, 25 insertions, 12 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 2c0cef6..8059f5d 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -14,6 +14,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
- Improve finding of Microsoft compiler: add a 'products' wildcard
in case 2017 Build Tools only is installed as it is considered a separate
product from the default Visual Studio
+ - Add TEMPFILEEXTENSION as in the patch attached to issue #2431,
+ updated to current codebase.
From Daniel Moody:
- Improved support for VC14.1 and Visual Studio 2017, as well as arm and arm64 targets.
diff --git a/src/engine/SCons/Platform/__init__.py b/src/engine/SCons/Platform/__init__.py
index 8117e60..75c4839 100644
--- a/src/engine/SCons/Platform/__init__.py
+++ b/src/engine/SCons/Platform/__init__.py
@@ -144,15 +144,20 @@ class TempFileMunge(object):
line limitation.
Example usage:
- env["TEMPFILE"] = TempFileMunge
- env["LINKCOM"] = "${TEMPFILE('$LINK $TARGET $SOURCES','$LINKCOMSTR')}"
+ env["TEMPFILE"] = TempFileMunge
+ env["LINKCOM"] = "${TEMPFILE('$LINK $TARGET $SOURCES','$LINKCOMSTR')}"
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
+ prefix of '@'. This may be configured for other tool chains by
+ setting '$TEMPFILEPREFIX':
+ env["TEMPFILEPREFIX"] = '-@' # diab compiler
+ env["TEMPFILEPREFIX"] = '-via' # arm tool chain
+ env["TEMPFILEPREFIX"] = '' # (the empty string) PC Lint
+
+ You can configure the extension of the temporary file through the
+ TEMPFILEEXTENSION variable, which defaults to '.lnk' (see comments
+ in the code below):
+ env["TEMPFILEEXTENSION"] = '.lnt' # PC Lint
"""
def __init__(self, cmd, cmdstr = None):
self.cmd = cmd
@@ -194,16 +199,21 @@ class TempFileMunge(object):
# 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
+ # delimiter. Windows' 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)
+ if env.has_key('TEMPFILEEXTENSION'):
+ extension = env.subst('$TEMPFILEEXTENSION')
+ else:
+ extension = '.lnk' # TODO: better way to pick default?
+ (fd, tmp) = tempfile.mkstemp(extension, text=True)
+
native_tmp = SCons.Util.get_native_path(os.path.normpath(tmp))
- if env.get('SHELL',None) == 'sh':
+ if env.get('SHELL', None) == 'sh':
# The sh shell will try to escape the backslashes in the
# path, so unescape them.
native_tmp = native_tmp.replace('\\', r'\\\\')
@@ -216,8 +226,9 @@ class TempFileMunge(object):
# Windows path names.
rm = 'del'
- prefix = env.subst('$TEMPFILEPREFIX')
- if not prefix:
+ if env.has_key('TEMPFILEPREFIX'):
+ prefix = env.subst('$TEMPFILEPREFIX')
+ else:
prefix = '@'
args = list(map(SCons.Subst.quote_spaces, cmd[1:]))