Add a -t="dir" option to the driver. This can be used to specify the directory to...
authorSanjiv Gupta <sanjiv.gupta@microchip.com>
Thu, 9 Jul 2009 08:23:38 +0000 (08:23 +0000)
committerSanjiv Gupta <sanjiv.gupta@microchip.com>
Thu, 9 Jul 2009 08:23:38 +0000 (08:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75121 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CompilerDriver/BuiltinOptions.h
lib/CompilerDriver/BuiltinOptions.cpp
lib/CompilerDriver/Main.cpp

index 492dffd30725f2fb918f8f345950422775028570..fe44c30a7ad584b3c79e3a8b269b51d551ff1432 100644 (file)
@@ -22,6 +22,7 @@ namespace SaveTempsEnum { enum Values { Cwd, Obj, Unset }; }
 
 extern llvm::cl::list<std::string> InputFilenames;
 extern llvm::cl::opt<std::string> OutputFilename;
+extern llvm::cl::opt<std::string> TempDirname;
 extern llvm::cl::list<std::string> Languages;
 extern llvm::cl::opt<bool> DryRun;
 extern llvm::cl::opt<bool> VerboseMode;
index a3364e8a72f0ba4cbce8e6b6dfdf34cec7b04f98..c4660e17a531f68f0c0cb027ea82b28c8d842895 100644 (file)
@@ -25,6 +25,8 @@ cl::list<std::string> InputFilenames(cl::Positional, cl::desc("<input file>"),
                                      cl::ZeroOrMore);
 cl::opt<std::string> OutputFilename("o", cl::desc("Output file name"),
                                     cl::value_desc("file"), cl::Prefix);
+cl::opt<std::string> TempDirname("t", cl::desc("Temp dir name"),
+                                    cl::value_desc("dir"), cl::Prefix);
 cl::list<std::string> Languages("x",
           cl::desc("Specify the language of the following input files"),
           cl::ZeroOrMore);
index 7d1a3d8fbc4eb43caac758fb757e8a6e4b0bca76..57d2937b339fa63357cc6e1ab4bc45d579f9bb49 100644 (file)
@@ -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();