зеркало из https://github.com/microsoft/clang-1.git
ccc: Remove temporary files used in compilation, and remove
compilation results on failures. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65254 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
85c3515516
Коммит
9ff1c0784c
|
@ -37,6 +37,11 @@ class Driver(object):
|
||||||
# Certain options suppress the 'no input files' warning.
|
# Certain options suppress the 'no input files' warning.
|
||||||
self.suppressMissingInputWarning = False
|
self.suppressMissingInputWarning = False
|
||||||
|
|
||||||
|
# Temporary files used in compilation, removed on exit.
|
||||||
|
self.tempFiles = []
|
||||||
|
# Result files produced by compilation, removed on error.
|
||||||
|
self.resultFiles = []
|
||||||
|
|
||||||
# Host queries which can be forcibly over-riden by the user for
|
# Host queries which can be forcibly over-riden by the user for
|
||||||
# testing purposes.
|
# testing purposes.
|
||||||
#
|
#
|
||||||
|
@ -219,6 +224,24 @@ class Driver(object):
|
||||||
raise ValueError,'Encountered unknown job.'
|
raise ValueError,'Encountered unknown job.'
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
try:
|
||||||
|
try:
|
||||||
|
self.executeJobs(args, jobs)
|
||||||
|
except:
|
||||||
|
for f in self.resultFiles:
|
||||||
|
# Fail if removing a result fails:
|
||||||
|
if os.path.exists(f):
|
||||||
|
os.remove(f)
|
||||||
|
raise
|
||||||
|
finally:
|
||||||
|
for f in self.tempFiles:
|
||||||
|
# Ignore failures in removing temporary files
|
||||||
|
try:
|
||||||
|
os.remove(f)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def executeJobs(self, args, jobs):
|
||||||
vArg = args.getLastArg(self.parser.vOption)
|
vArg = args.getLastArg(self.parser.vOption)
|
||||||
for j in jobs.iterjobs():
|
for j in jobs.iterjobs():
|
||||||
if isinstance(j, Jobs.Command):
|
if isinstance(j, Jobs.Command):
|
||||||
|
@ -807,9 +830,6 @@ class Driver(object):
|
||||||
jobs.addJob(output)
|
jobs.addJob(output)
|
||||||
else:
|
else:
|
||||||
# Figure out what the derived output location would be.
|
# Figure out what the derived output location would be.
|
||||||
#
|
|
||||||
# FIXME: gcc has some special case in here so that it doesn't
|
|
||||||
# create output files if they would conflict with an input.
|
|
||||||
if phase.type is Types.ImageType:
|
if phase.type is Types.ImageType:
|
||||||
namedOutput = "a.out"
|
namedOutput = "a.out"
|
||||||
else:
|
else:
|
||||||
|
@ -821,9 +841,12 @@ class Driver(object):
|
||||||
base,_ = os.path.splitext(inputName)
|
base,_ = os.path.splitext(inputName)
|
||||||
namedOutput = base + '.' + phase.type.tempSuffix
|
namedOutput = base + '.' + phase.type.tempSuffix
|
||||||
|
|
||||||
|
isTemp = False
|
||||||
# Output to user requested destination?
|
# Output to user requested destination?
|
||||||
if atTopLevel and finalOutput:
|
if atTopLevel and finalOutput:
|
||||||
output = finalOutput
|
output = finalOutput
|
||||||
|
self.resultFiles.append(args.getValue(finalOutput))
|
||||||
|
|
||||||
# Contruct a named destination?
|
# Contruct a named destination?
|
||||||
elif atTopLevel or hasSaveTemps:
|
elif atTopLevel or hasSaveTemps:
|
||||||
# As an annoying special case, pch generation
|
# As an annoying special case, pch generation
|
||||||
|
@ -834,9 +857,12 @@ class Driver(object):
|
||||||
outputName = os.path.basename(namedOutput)
|
outputName = os.path.basename(namedOutput)
|
||||||
output = args.makeSeparateArg(outputName,
|
output = args.makeSeparateArg(outputName,
|
||||||
self.parser.oOption)
|
self.parser.oOption)
|
||||||
|
self.resultFiles.append(outputName)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Output to temp file...
|
# Output to temp file...
|
||||||
fd,filename = tempfile.mkstemp(suffix='.'+phase.type.tempSuffix)
|
fd,filename = tempfile.mkstemp(suffix='.'+phase.type.tempSuffix)
|
||||||
output = args.makeSeparateArg(filename,
|
output = args.makeSeparateArg(filename,
|
||||||
self.parser.oOption)
|
self.parser.oOption)
|
||||||
|
self.tempFiles.append(filename)
|
||||||
return output,jobList
|
return output,jobList
|
||||||
|
|
Загрузка…
Ссылка в новой задаче