1 //===--- llvmcc.cpp - The LLVM Compiler Driver ------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open
6 // Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This tool provides a single point of access to the LLVM
11 // compilation tools. It has many options. To discover the options
12 // supported please refer to the tools' manual page or run the tool
13 // with the --help option.
15 //===----------------------------------------------------------------------===//
17 #include "CompilationGraph.h"
20 #include "llvm/System/Path.h"
21 #include "llvm/Support/CommandLine.h"
27 namespace cl = llvm::cl;
28 namespace sys = llvm::sys;
29 using namespace llvmcc;
31 // Built-in command-line options.
32 // External linkage here is intentional.
34 cl::list<std::string> InputFilenames(cl::Positional, cl::desc("<input file>"),
36 cl::opt<std::string> OutputFilename("o", cl::desc("Output file name"),
37 cl::value_desc("file"));
38 cl::opt<bool> VerboseMode("v",
39 cl::desc("Enable verbose mode"));
40 cl::opt<bool> WriteGraph("write-graph",
41 cl::desc("Write CompilationGraph.dot file"),
43 cl::opt<bool> ViewGraph("view-graph",
44 cl::desc("Show compilation graph in GhostView"),
48 int BuildTargets(const CompilationGraph& graph) {
50 sys::Path tempDir(sys::Path::GetTemporaryDirectory());
53 ret = graph.Build(tempDir);
56 tempDir.eraseFromDisk(true);
60 tempDir.eraseFromDisk(true);
65 int main(int argc, char** argv) {
67 CompilationGraph graph;
69 cl::ParseCommandLineOptions(argc, argv,
70 "LLVM Compiler Driver(Work In Progress)");
71 PopulateCompilationGraph(graph);
78 return BuildTargets(graph);
80 catch(const std::exception& ex) {
81 std::cerr << ex.what() << '\n';
84 std::cerr << "Unknown error!\n";