mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
Remove some duplication.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75163 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3a780d1214
commit
f5f9a4d7db
@ -31,31 +31,29 @@ namespace {
|
||||
sys::Path getTempDir() {
|
||||
sys::Path tempDir;
|
||||
|
||||
if (! TempDirname.empty()) {
|
||||
// The --temp-dir option.
|
||||
if (!TempDirname.empty()) {
|
||||
tempDir = TempDirname;
|
||||
if (!tempDir.exists()) {
|
||||
std::string ErrMsg;
|
||||
if (tempDir.createDirectoryOnDisk(true, &ErrMsg))
|
||||
throw std::runtime_error(ErrMsg);
|
||||
}
|
||||
return tempDir;
|
||||
}
|
||||
|
||||
// GCC 4.5-style -save-temps handling.
|
||||
if (SaveTemps == SaveTempsEnum::Unset) {
|
||||
else if (SaveTemps == SaveTempsEnum::Unset) {
|
||||
tempDir = sys::Path::GetTemporaryDirectory();
|
||||
return tempDir;
|
||||
}
|
||||
else if (SaveTemps == SaveTempsEnum::Obj && !OutputFilename.empty()) {
|
||||
tempDir = OutputFilename;
|
||||
tempDir = tempDir.getDirname();
|
||||
}
|
||||
else {
|
||||
// SaveTemps == Cwd --> use current dir (leave tempDir empty).
|
||||
return tempDir;
|
||||
}
|
||||
|
||||
if (!tempDir.exists()) {
|
||||
std::string ErrMsg;
|
||||
if (tempDir.createDirectoryOnDisk(true, &ErrMsg))
|
||||
throw std::runtime_error(ErrMsg);
|
||||
}
|
||||
}
|
||||
// else if (SaveTemps == Cwd) -> use current dir (leave tempDir empty)
|
||||
|
||||
return tempDir;
|
||||
}
|
||||
@ -64,17 +62,19 @@ namespace {
|
||||
int BuildTargets(CompilationGraph& graph, const LanguageMap& langMap) {
|
||||
int ret;
|
||||
const sys::Path& tempDir = getTempDir();
|
||||
bool toDelete =
|
||||
(SaveTemps == SaveTempsEnum::Unset && TempDirname.empty());
|
||||
|
||||
try {
|
||||
ret = graph.Build(tempDir, langMap);
|
||||
}
|
||||
catch(...) {
|
||||
if (SaveTemps == SaveTempsEnum::Unset)
|
||||
if (toDelete)
|
||||
tempDir.eraseFromDisk(true);
|
||||
throw;
|
||||
}
|
||||
|
||||
if (SaveTemps == SaveTempsEnum::Unset)
|
||||
if (toDelete)
|
||||
tempDir.eraseFromDisk(true);
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user