[lit] Add %:[STpst] to represent paths without colons on Windows.

Summary:
We need these variables to concatenate two absolute paths to construct
a valid path. Currently, %t\%t is, for example, expanded to C:\foo\C:\foo,
which is not a valid path because ":" is not a valid path character
on Windows. With this patch, %t will be expanded to C\foo.

Differential Revision: http://reviews.llvm.org/D19757

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268168 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rui Ueyama 2016-04-30 21:32:12 +00:00
parent 585ee3d03c
commit d5ebabfb3e

View File

@ -568,6 +568,24 @@ def getDefaultSubstitutions(test, tmpDir, tmpBase, normalize_slashes=False):
('%/t', tmpBase.replace('\\', '/') + '.tmp'),
('%/T', tmpDir.replace('\\', '/')),
])
# "%:[STpst]" are paths without colons.
if kIsWindows:
substitutions.extend([
('%:s', re.sub(r'^(.):', r'\1', sourcepath)),
('%:S', re.sub(r'^(.):', r'\1', sourcedir)),
('%:p', re.sub(r'^(.):', r'\1', sourcedir)),
('%:t', re.sub(r'^(.):', r'\1', tmpBase) + '.tmp'),
('%:T', re.sub(r'^(.):', r'\1', tmpDir)),
])
else:
substitutions.extend([
('%:s', sourcepath),
('%:S', sourcedir),
('%:p', sourcedir),
('%:t', tmpBase + '.tmp'),
('%:T', tmpDir),
])
return substitutions
def applySubstitutions(script, substitutions):