mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-20 09:30:43 +00:00
7defa2d3d5
The -save-temps option now behaves like described in GCC 4.5 release notes (you can specify output directory for temporary files with -save-temps=obj -o $DIRNAME). I do not have GCC 4.5 installed, so if there are any inconsistencies between llvmc and GCC in the implementation of this feature, please let me know. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74190 91177308-0d34-0410-b5e6-96231b3b80d8
73 lines
2.1 KiB
C++
73 lines
2.1 KiB
C++
//===--- Tool.cpp - The LLVM Compiler Driver --------------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open
|
|
// Source License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Tool base class - implementation details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/CompilerDriver/BuiltinOptions.h"
|
|
#include "llvm/CompilerDriver/Tool.h"
|
|
|
|
#include "llvm/System/Path.h"
|
|
|
|
using namespace llvm;
|
|
using namespace llvmc;
|
|
|
|
namespace {
|
|
sys::Path MakeTempFile(const sys::Path& TempDir, const std::string& BaseName,
|
|
const std::string& Suffix) {
|
|
sys::Path Out;
|
|
|
|
// Make sure we don't end up with path names like '/file.o' if the
|
|
// TempDir is empty.
|
|
if (TempDir.empty()) {
|
|
Out.set(BaseName);
|
|
}
|
|
else {
|
|
Out = TempDir;
|
|
Out.appendComponent(BaseName);
|
|
}
|
|
Out.appendSuffix(Suffix);
|
|
// NOTE: makeUnique always *creates* a unique temporary file,
|
|
// which is good, since there will be no races. However, some
|
|
// tools do not like it when the output file already exists, so
|
|
// they need to be placated with -f or something like that.
|
|
Out.makeUnique(true, NULL);
|
|
return Out;
|
|
}
|
|
}
|
|
|
|
sys::Path Tool::OutFilename(const sys::Path& In,
|
|
const sys::Path& TempDir,
|
|
bool StopCompilation,
|
|
const char* OutputSuffix) const {
|
|
sys::Path Out;
|
|
|
|
if (StopCompilation) {
|
|
if (!OutputFilename.empty() && SaveTemps != SaveTempsEnum::Obj ) {
|
|
Out.set(OutputFilename);
|
|
}
|
|
else if (IsJoin()) {
|
|
Out.set("a");
|
|
Out.appendSuffix(OutputSuffix);
|
|
}
|
|
else {
|
|
Out.set(In.getBasename());
|
|
Out.appendSuffix(OutputSuffix);
|
|
}
|
|
}
|
|
else {
|
|
if (IsJoin())
|
|
Out = MakeTempFile(TempDir, "tmp", OutputSuffix);
|
|
else
|
|
Out = MakeTempFile(TempDir, In.getBasename(), OutputSuffix);
|
|
}
|
|
return Out;
|
|
}
|