blob: c5edac960629fc02c52bef533797289704722176 [file] [log] [blame]
Anton Korobeynikovac67b7e2008-03-23 08:57:20 +00001//===--- llvmcc.cpp - The LLVM Compiler Driver ------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open
6// Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
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.
14//
15//===----------------------------------------------------------------------===//
16
17#include "Core.h"
18#include "Utility.h"
19#include "Tools.h"
20
21#include "llvm/System/Path.h"
22#include "llvm/Support/CommandLine.h"
23
24#include <iostream>
25#include <stdexcept>
26#include <string>
27
28using namespace llvm;
29using namespace llvmcc;
30
31// These variables are also used in Core.cpp,
32// so they should have external linkage.
33cl::list<std::string> InputFilenames(cl::Positional,
34 cl::desc("<input file>"), cl::OneOrMore);
35cl::opt<std::string> OutputFilename("o", cl::desc("Output file name"),
36 cl::value_desc("file"));
37cl::opt<bool> VerboseMode("v", cl::desc("Enable verbose mode"));
38
39
40namespace {
41 int BuildTargets(const CompilationGraph& graph) {
42 int ret;
43 sys::Path tempDir(sys::Path::GetTemporaryDirectory());
44
45 try {
46 ret = graph.Build(tempDir);
47 }
48 catch(...) {
49 tempDir.eraseFromDisk(true);
50 throw;
51 }
52
53 tempDir.eraseFromDisk(true);
54 return ret;
55 }
56}
57
58int main(int argc, char** argv) {
59 try {
60 CompilationGraph graph;
61
62 cl::ParseCommandLineOptions(argc, argv,
63 "LLVM Compiler Driver(Work In Progress)");
64 PopulateCompilationGraph(graph);
65 return BuildTargets(graph);
66 }
67 catch(const std::exception& ex) {
68 std::cerr << ex.what() << '\n';
69 }
70 catch(...) {
71 std::cerr << "Unknown error!\n";
72 }
73}