Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 1 | //===--- llvmc.cpp - The LLVM Compiler Driver -------------------*- C++ -*-===// |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 5 | // This file was developed by Reid Spencer and is distributed under the |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 6 | // University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This tool provides a single point of access to the LLVM compilation tools. |
| 11 | // It has many options. To discover the options supported please refer to the |
| 12 | // tools' manual page (docs/CommandGuide/html/llvmc.html) or run the tool with |
| 13 | // the --help option. |
| 14 | // |
| 15 | //===------------------------------------------------------------------------=== |
| 16 | |
Reid Spencer | abf1ce3 | 2004-08-10 16:29:18 +0000 | [diff] [blame] | 17 | #include "CompilerDriver.h" |
Reid Spencer | f51a87c | 2004-08-19 21:52:49 +0000 | [diff] [blame] | 18 | #include "Configuration.h" |
Reid Spencer | 4495632 | 2004-08-24 17:54:26 +0000 | [diff] [blame^] | 19 | #include "llvm/Pass.h" |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 20 | #include "llvm/System/Signals.h" |
| 21 | #include "Support/CommandLine.h" |
| 22 | #include <iostream> |
| 23 | |
| 24 | using namespace llvm; |
| 25 | |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 26 | namespace { |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 27 | //===------------------------------------------------------------------------=== |
| 28 | //=== PHASE OPTIONS |
| 29 | //===------------------------------------------------------------------------=== |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 30 | cl::opt<CompilerDriver::Phases> FinalPhase( |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 31 | cl::desc("Choose final phase of compilation:"), |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 32 | cl::init(CompilerDriver::LINKING), |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 33 | cl::values( |
| 34 | clEnumValN(CompilerDriver::PREPROCESSING,"E", |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 35 | "Stop compilation after pre-processing phase"), |
| 36 | clEnumValN(CompilerDriver::TRANSLATION, "t", |
| 37 | "Stop compilation after translation phase"), |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 38 | clEnumValN(CompilerDriver::OPTIMIZATION,"c", |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 39 | "Stop compilation after optimization phase"), |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 40 | clEnumValN(CompilerDriver::ASSEMBLY,"S", |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 41 | "Stop compilation after assembly phase"), |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 42 | clEnumValEnd |
| 43 | ) |
| 44 | ); |
| 45 | |
| 46 | //===------------------------------------------------------------------------=== |
| 47 | //=== OPTIMIZATION OPTIONS |
| 48 | //===------------------------------------------------------------------------=== |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 49 | cl::opt<CompilerDriver::OptimizationLevels> OptLevel( |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 50 | cl::desc("Choose level of optimization to apply:"), |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 51 | cl::init(CompilerDriver::OPT_FAST_COMPILE), |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 52 | cl::values( |
| 53 | clEnumValN(CompilerDriver::OPT_FAST_COMPILE,"O0", |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 54 | "An alias for the -O1 option."), |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 55 | clEnumValN(CompilerDriver::OPT_FAST_COMPILE,"O1", |
| 56 | "Optimize for compilation speed, not execution speed."), |
| 57 | clEnumValN(CompilerDriver::OPT_SIMPLE,"O2", |
| 58 | "Perform simple translation time optimizations"), |
| 59 | clEnumValN(CompilerDriver::OPT_AGGRESSIVE,"O3", |
| 60 | "Perform aggressive translation time optimizations"), |
| 61 | clEnumValN(CompilerDriver::OPT_LINK_TIME,"O4", |
| 62 | "Perform link time optimizations"), |
| 63 | clEnumValN(CompilerDriver::OPT_AGGRESSIVE_LINK_TIME,"O5", |
| 64 | "Perform aggressive link time optimizations"), |
| 65 | clEnumValEnd |
| 66 | ) |
| 67 | ); |
| 68 | |
| 69 | //===------------------------------------------------------------------------=== |
| 70 | //=== TOOL OPTIONS |
| 71 | //===------------------------------------------------------------------------=== |
| 72 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 73 | cl::list<std::string> PreprocessorToolOpts("Tpre", cl::ZeroOrMore, |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 74 | cl::desc("Pass specific options to the pre-processor"), |
| 75 | cl::value_desc("option")); |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 76 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 77 | cl::list<std::string> TranslatorToolOpts("Ttrn", cl::ZeroOrMore, |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 78 | cl::desc("Pass specific options to the assembler"), |
| 79 | cl::value_desc("option")); |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 80 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 81 | cl::list<std::string> AssemblerToolOpts("Tasm", cl::ZeroOrMore, |
Reid Spencer | bf43772 | 2004-08-15 08:19:46 +0000 | [diff] [blame] | 82 | cl::desc("Pass specific options to the assembler"), |
| 83 | cl::value_desc("option")); |
| 84 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 85 | cl::list<std::string> OptimizerToolOpts("Topt", cl::ZeroOrMore, |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 86 | cl::desc("Pass specific options to the optimizer"), |
| 87 | cl::value_desc("option")); |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 88 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 89 | cl::list<std::string> LinkerToolOpts("Tlnk", cl::ZeroOrMore, |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 90 | cl::desc("Pass specific options to the linker"), |
| 91 | cl::value_desc("option")); |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 92 | |
| 93 | //===------------------------------------------------------------------------=== |
| 94 | //=== INPUT OPTIONS |
| 95 | //===------------------------------------------------------------------------=== |
| 96 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 97 | cl::list<std::string> LibPaths("L", cl::Prefix, |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 98 | cl::desc("Specify a library search path"), cl::value_desc("directory")); |
| 99 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 100 | cl::list<std::string> Libraries("l", cl::Prefix, |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 101 | cl::desc("Specify libraries to link to"), cl::value_desc("library prefix")); |
| 102 | |
| 103 | |
| 104 | //===------------------------------------------------------------------------=== |
| 105 | //=== OUTPUT OPTIONS |
| 106 | //===------------------------------------------------------------------------=== |
| 107 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 108 | cl::opt<std::string> OutputFilename("o", |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 109 | cl::desc("Override output filename"), cl::value_desc("filename")); |
| 110 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 111 | cl::opt<std::string> OutputMachine("m", cl::Prefix, |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 112 | cl::desc("Specify a target machine"), cl::value_desc("machine")); |
| 113 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 114 | cl::opt<bool> Native("native", cl::init(false), |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 115 | cl::desc("Generative native object and executables instead of bytecode")); |
| 116 | |
| 117 | //===------------------------------------------------------------------------=== |
| 118 | //=== INFORMATION OPTIONS |
| 119 | //===------------------------------------------------------------------------=== |
| 120 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 121 | cl::opt<bool> DryRun("dry-run", cl::Optional, cl::init(false), |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 122 | cl::desc("Do everything but perform the compilation actions")); |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 123 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 124 | cl::alias DryRunAlias("y", cl::Optional, |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 125 | cl::desc("Alias for -dry-run"), cl::aliasopt(DryRun)); |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 126 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 127 | cl::opt<bool> Verbose("verbose", cl::Optional, cl::init(false), |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 128 | cl::desc("Print out each action taken")); |
| 129 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 130 | cl::alias VerboseAlias("v", cl::Optional, |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 131 | cl::desc("Alias for -verbose"), cl::aliasopt(Verbose)); |
| 132 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 133 | cl::opt<bool> Debug("debug", cl::Optional, cl::init(false), |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 134 | cl::Hidden, cl::desc("Print out debugging information")); |
| 135 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 136 | cl::alias DebugAlias("d", cl::Optional, |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 137 | cl::desc("Alias for -debug"), cl::aliasopt(Debug)); |
| 138 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 139 | cl::opt<bool> TimeActions("time-actions", cl::Optional, cl::init(false), |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 140 | cl::desc("Print execution time for each action taken")); |
| 141 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 142 | cl::opt<bool> ShowStats("stats", cl::Optional, cl::init(false), |
| 143 | cl::desc("Print statistics accumulated during optimization")); |
| 144 | |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 145 | //===------------------------------------------------------------------------=== |
| 146 | //=== ADVANCED OPTIONS |
| 147 | //===------------------------------------------------------------------------=== |
| 148 | |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 149 | static cl::opt<std::string> ConfigDir("config-dir", cl::Optional, |
| 150 | cl::desc("Specify a configuration directory to override defaults"), |
| 151 | cl::value_desc("directory")); |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 152 | |
Reid Spencer | bf43772 | 2004-08-15 08:19:46 +0000 | [diff] [blame] | 153 | static cl::opt<bool> EmitRawCode("emit-raw-code", cl::Hidden, cl::Optional, |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 154 | cl::desc("Emit raw, unoptimized code")); |
| 155 | |
Reid Spencer | bf43772 | 2004-08-15 08:19:46 +0000 | [diff] [blame] | 156 | static cl::opt<bool> PipeCommands("pipe", cl::Optional, |
| 157 | cl::desc("Invoke sub-commands by linking input/output with pipes")); |
| 158 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 159 | static cl::opt<bool> KeepTemporaries("keep-temps", cl::Optional, |
| 160 | cl::desc("Don't delete the temporary files created during compilation")); |
| 161 | |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 162 | //===------------------------------------------------------------------------=== |
| 163 | //=== POSITIONAL OPTIONS |
| 164 | //===------------------------------------------------------------------------=== |
| 165 | |
| 166 | static cl::list<std::string> Files(cl::Positional, cl::OneOrMore, |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 167 | cl::desc("[Sources/objects/libraries]")); |
| 168 | |
| 169 | static cl::list<std::string> Languages("x", cl::ZeroOrMore, |
| 170 | cl::desc("Specify the source language for subsequent files"), |
| 171 | cl::value_desc("language")); |
| 172 | |
| 173 | //===------------------------------------------------------------------------=== |
| 174 | //=== GetFileType - determine type of a file |
| 175 | //===------------------------------------------------------------------------=== |
| 176 | const std::string GetFileType(const std::string& fname, unsigned pos ) { |
| 177 | static std::vector<std::string>::iterator langIt = Languages.begin(); |
| 178 | static std::string CurrLang = ""; |
| 179 | |
| 180 | // If a -x LANG option has been specified .. |
| 181 | if ( langIt != Languages.end() ) |
| 182 | // If the -x LANG option came before the current file on command line |
| 183 | if ( Languages.getPosition( langIt - Languages.begin() ) < pos ) { |
| 184 | // use that language |
| 185 | CurrLang = *langIt++; |
| 186 | return CurrLang; |
| 187 | } |
| 188 | |
| 189 | // If there's a current language in effect |
| 190 | if (!CurrLang.empty()) |
| 191 | return CurrLang; // use that language |
| 192 | |
| 193 | // otherwise just determine lang from the filename's suffix |
| 194 | return fname.substr( fname.rfind('.',fname.size()) + 1 ); |
| 195 | } |
| 196 | |
| 197 | } // end anonymous namespace |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 198 | |
| 199 | |
| 200 | /// @brief The main program for llvmc |
| 201 | int main(int argc, char **argv) { |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 202 | try { |
| 203 | // Make sure we print stack trace if we get bad signals |
| 204 | PrintStackTraceOnErrorSignal(); |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 205 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 206 | // Parse the command line options |
| 207 | cl::ParseCommandLineOptions(argc, argv, |
| 208 | " LLVM Compilation Driver (llvmc)\n\n" |
| 209 | " This program provides easy invocation of the LLVM tool set\n" |
| 210 | " and source language compiler tools.\n" |
| 211 | ); |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 212 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 213 | // Deal with unimplemented options. |
| 214 | if (PipeCommands) |
Reid Spencer | 2cf17a4 | 2004-08-24 14:05:30 +0000 | [diff] [blame] | 215 | throw "Not implemented yet: -pipe"; |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 216 | |
Reid Spencer | 2cf17a4 | 2004-08-24 14:05:30 +0000 | [diff] [blame] | 217 | if (OutputFilename.empty()) |
| 218 | if (OptLevel == CompilerDriver::LINKING) |
| 219 | OutputFilename = "a.out"; |
| 220 | else |
| 221 | throw "An output file must be specified. Please use the -o option"; |
| 222 | |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 223 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 224 | // Construct the ConfigDataProvider object |
| 225 | LLVMC_ConfigDataProvider Provider; |
| 226 | Provider.setConfigDir(ConfigDir); |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 227 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 228 | // Construct the CompilerDriver object |
| 229 | CompilerDriver CD(Provider); |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 230 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 231 | // Configure the driver based on options |
| 232 | CD.setVerbose(Verbose); |
| 233 | CD.setDebug(Debug); |
| 234 | CD.setDryRun(DryRun); |
| 235 | CD.setFinalPhase(FinalPhase); |
| 236 | CD.setOptimization(OptLevel); |
| 237 | CD.setOutputMachine(OutputMachine); |
| 238 | CD.setEmitNativeCode(Native); |
| 239 | CD.setEmitRawCode(EmitRawCode); |
| 240 | CD.setTimeActions(TimeActions); |
Reid Spencer | 4495632 | 2004-08-24 17:54:26 +0000 | [diff] [blame^] | 241 | CD.setTimePasses(TimePassesIsEnabled); |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 242 | CD.setShowStats(ShowStats); |
| 243 | CD.setKeepTemporaries(KeepTemporaries); |
| 244 | CD.setLibraryPaths(LibPaths); |
| 245 | if (!PreprocessorToolOpts.empty()) |
| 246 | CD.setPhaseArgs(CompilerDriver::PREPROCESSING, PreprocessorToolOpts); |
| 247 | if (!TranslatorToolOpts.empty()) |
| 248 | CD.setPhaseArgs(CompilerDriver::TRANSLATION, TranslatorToolOpts); |
| 249 | if (!OptimizerToolOpts.empty()) |
| 250 | CD.setPhaseArgs(CompilerDriver::OPTIMIZATION, OptimizerToolOpts); |
| 251 | if (!AssemblerToolOpts.empty()) |
| 252 | CD.setPhaseArgs(CompilerDriver::ASSEMBLY,AssemblerToolOpts); |
| 253 | if (!LinkerToolOpts.empty()) |
| 254 | CD.setPhaseArgs(CompilerDriver::LINKING, LinkerToolOpts); |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 255 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 256 | // Prepare the list of files to be compiled by the CompilerDriver. |
| 257 | CompilerDriver::InputList InpList; |
| 258 | std::vector<std::string>::iterator fileIt = Files.begin(); |
| 259 | std::vector<std::string>::iterator libIt = Libraries.begin(); |
| 260 | unsigned libPos = 0, filePos = 0; |
| 261 | while ( 1 ) { |
| 262 | if ( libIt != Libraries.end() ) |
| 263 | libPos = Libraries.getPosition( libIt - Libraries.begin() ); |
| 264 | else |
| 265 | libPos = 0; |
| 266 | if ( fileIt != Files.end() ) |
| 267 | filePos = Files.getPosition( fileIt - Files.begin() ); |
| 268 | else |
| 269 | filePos = 0; |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 270 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 271 | if ( filePos != 0 && (libPos == 0 || filePos < libPos) ) { |
| 272 | // Add a source file |
| 273 | InpList.push_back( std::make_pair(*fileIt, GetFileType(*fileIt,filePos))); |
| 274 | ++fileIt; |
| 275 | } |
| 276 | else if ( libPos != 0 && (filePos == 0 || libPos < filePos) ) { |
| 277 | // Add a library |
| 278 | InpList.push_back( std::make_pair(*libIt++,"")); |
| 279 | } |
| 280 | else |
| 281 | break; // we're done with the list |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 282 | } |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 283 | |
| 284 | // Tell the driver to do its thing |
| 285 | int result = CD.execute(InpList,OutputFilename); |
| 286 | if (result != 0) { |
Reid Spencer | 2cf17a4 | 2004-08-24 14:05:30 +0000 | [diff] [blame] | 287 | throw "Error executing actions. Terminated.\n"; |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 288 | return result; |
Reid Spencer | 5c56dc1 | 2004-08-13 20:22:43 +0000 | [diff] [blame] | 289 | } |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 290 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 291 | // All is good, return success |
| 292 | return 0; |
| 293 | } catch (std::string& msg) { |
Reid Spencer | 2cf17a4 | 2004-08-24 14:05:30 +0000 | [diff] [blame] | 294 | std::cerr << argv[0] << ": " << msg << "\n"; |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 295 | } catch (...) { |
Reid Spencer | 2cf17a4 | 2004-08-24 14:05:30 +0000 | [diff] [blame] | 296 | std::cerr << argv[0] << ": Unexpected unknown exception occurred.\n"; |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 297 | } |
Reid Spencer | 034a544 | 2004-08-10 16:26:01 +0000 | [diff] [blame] | 298 | } |