2009-03-03 03:59:07 +08:00
|
|
|
//===-- driver.cpp - Clang GCC-Compatible Driver --------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2009-03-03 13:55:11 +08:00
|
|
|
// This is the entry point to the clang driver; it is a thin wrapper
|
|
|
|
// for functionality in the Driver clang library.
|
2009-03-03 03:59:07 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/Driver/Compilation.h"
|
|
|
|
#include "clang/Driver/Driver.h"
|
2009-03-04 16:33:23 +08:00
|
|
|
#include "clang/Driver/Option.h"
|
|
|
|
#include "clang/Driver/Options.h"
|
|
|
|
|
2009-03-12 16:55:43 +08:00
|
|
|
#include "clang/Frontend/TextDiagnosticPrinter.h"
|
|
|
|
|
2009-03-03 03:59:07 +08:00
|
|
|
#include "llvm/ADT/OwningPtr.h"
|
2009-03-11 07:41:59 +08:00
|
|
|
#include "llvm/Config/config.h"
|
2009-03-12 16:55:43 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2009-03-11 04:52:46 +08:00
|
|
|
#include "llvm/System/Path.h"
|
2009-03-03 03:59:07 +08:00
|
|
|
#include "llvm/System/Signals.h"
|
2009-03-12 16:55:43 +08:00
|
|
|
using namespace clang;
|
2009-03-05 04:49:20 +08:00
|
|
|
using namespace clang::driver;
|
2009-03-03 03:59:07 +08:00
|
|
|
|
|
|
|
int main(int argc, const char **argv) {
|
|
|
|
llvm::sys::PrintStackTraceOnErrorSignal();
|
|
|
|
|
2009-03-12 16:55:43 +08:00
|
|
|
llvm::OwningPtr<DiagnosticClient>
|
|
|
|
DiagClient(new TextDiagnosticPrinter(llvm::errs()));
|
|
|
|
|
|
|
|
Diagnostic Diags(DiagClient.get());
|
|
|
|
|
2009-03-11 04:52:46 +08:00
|
|
|
// FIXME: We should use GetMainExecutable here, probably, but we may
|
|
|
|
// want to handle symbolic links slightly differently. The problem
|
|
|
|
// is that the path derived from this will influence search paths.
|
|
|
|
llvm::sys::Path Path(argv[0]);
|
|
|
|
|
2009-03-11 07:41:59 +08:00
|
|
|
// FIXME: Use the triple of the host, not the triple that we were
|
|
|
|
// compiled on.
|
2009-03-11 04:52:46 +08:00
|
|
|
llvm::OwningPtr<Driver> TheDriver(new Driver(Path.getBasename().c_str(),
|
2009-03-11 07:41:59 +08:00
|
|
|
Path.getDirname().c_str(),
|
2009-03-12 16:55:43 +08:00
|
|
|
LLVM_HOSTTRIPLE,
|
2009-03-16 14:56:51 +08:00
|
|
|
"a.out",
|
2009-03-12 16:55:43 +08:00
|
|
|
Diags));
|
|
|
|
|
2009-03-03 03:59:07 +08:00
|
|
|
llvm::OwningPtr<Compilation> C(TheDriver->BuildCompilation(argc, argv));
|
|
|
|
|
2009-03-12 16:55:43 +08:00
|
|
|
// If there were errors building the compilation, quit now.
|
|
|
|
if (Diags.getNumErrors())
|
|
|
|
return 1;
|
2009-03-14 01:24:34 +08:00
|
|
|
if (!C.get())
|
|
|
|
return 0;
|
2009-03-12 16:55:43 +08:00
|
|
|
|
2009-03-03 03:59:07 +08:00
|
|
|
return C->Execute();
|
|
|
|
}
|