From 0b8f418488c4eb46d793e7580fb76dd42c92ad7e Mon Sep 17 00:00:00 2001 From: Sanjiv Gupta Date: Thu, 9 Jul 2009 08:23:38 +0000 Subject: Add a -t="dir" option to the driver. This can be used to specify the directory to be used as TempDir if somebody doesn't want to use the standard /tmp. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75121 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CompilerDriver/BuiltinOptions.cpp | 2 ++ lib/CompilerDriver/Main.cpp | 9 +++++++++ 2 files changed, 11 insertions(+) (limited to 'lib/CompilerDriver') diff --git a/lib/CompilerDriver/BuiltinOptions.cpp b/lib/CompilerDriver/BuiltinOptions.cpp index a3364e8a72..c4660e17a5 100644 --- a/lib/CompilerDriver/BuiltinOptions.cpp +++ b/lib/CompilerDriver/BuiltinOptions.cpp @@ -25,6 +25,8 @@ cl::list InputFilenames(cl::Positional, cl::desc(""), cl::ZeroOrMore); cl::opt OutputFilename("o", cl::desc("Output file name"), cl::value_desc("file"), cl::Prefix); +cl::opt TempDirname("t", cl::desc("Temp dir name"), + cl::value_desc("dir"), cl::Prefix); cl::list Languages("x", cl::desc("Specify the language of the following input files"), cl::ZeroOrMore); diff --git a/lib/CompilerDriver/Main.cpp b/lib/CompilerDriver/Main.cpp index 7d1a3d8fbc..57d2937b33 100644 --- a/lib/CompilerDriver/Main.cpp +++ b/lib/CompilerDriver/Main.cpp @@ -31,6 +31,15 @@ namespace { sys::Path getTempDir() { sys::Path tempDir; + if (! TempDirname.empty() { + tempDir = TempDirname; + if (!tempDir.exists()) { + std::string ErrMsg; + if (tempDir.createDirectoryOnDisk(true, &ErrMsg)) + throw std::runtime_error(ErrMsg); + } + } + // GCC 4.5-style -save-temps handling. if (SaveTemps == SaveTempsEnum::Unset) { tempDir = sys::Path::GetTemporaryDirectory(); -- cgit v1.2.3