From: Daniel Dunbar Date: Mon, 2 Mar 2009 19:59:07 +0000 (+0000) Subject: Stub out some structure for C++ driver. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3ede8d0a7d1813f678ccc6011a99a0834b1b6116;p=clang Stub out some structure for C++ driver. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65867 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/Compilation.h b/include/clang/Driver/Compilation.h new file mode 100644 index 0000000000..d4792e898a --- /dev/null +++ b/include/clang/Driver/Compilation.h @@ -0,0 +1,29 @@ +//===--- Compilation.h - Compilation Task Data Structure --------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef CLANG_DRIVER_COMPILATION_H_ +#define CLANG_DRIVER_COMPILATION_H_ + +namespace clang { + +/// Compilation - A set of tasks to perform for a single driver +/// invocation. +class Compilation { +public: + Compilation(); + ~Compilation(); + + /// Execute - Execute the compilation jobs and return an + /// appropriate exit code. + int Execute() const; +}; + +} // end namespace clang + +#endif diff --git a/include/clang/Driver/Driver.h b/include/clang/Driver/Driver.h new file mode 100644 index 0000000000..62bcd43294 --- /dev/null +++ b/include/clang/Driver/Driver.h @@ -0,0 +1,30 @@ +//===--- Driver.h - Clang GCC Compatible Driver -----------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef CLANG_DRIVER_DRIVER_H_ +#define CLANG_DRIVER_DRIVER_H_ + +namespace clang { + class Compilation; + +/// Driver - Encapsulate logic for constructing compilation processes +/// from a set of gcc-driver-like command line arguments. +class Driver { +public: + Driver(); + ~Driver(); + + /// BuildCompilation - Construct a compilation object for a command + /// line argument vector. + Compilation *BuildCompilation(int argc, const char **argv); +}; + +} // end namespace clang + +#endif diff --git a/lib/Driver/Compilation.cpp b/lib/Driver/Compilation.cpp new file mode 100644 index 0000000000..7f3454bcd8 --- /dev/null +++ b/lib/Driver/Compilation.cpp @@ -0,0 +1,21 @@ +//===--- Compilation.cpp - Compilation Task Implementation --------------*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "clang/Driver/Compilation.h" +using namespace clang; + +Compilation::Compilation() { +} + +Compilation::~Compilation() { +} + +int Compilation::Execute() const { + return 0; +} diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp new file mode 100644 index 0000000000..7ecc38ad29 --- /dev/null +++ b/lib/Driver/Driver.cpp @@ -0,0 +1,24 @@ +//===--- 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. +// +//===----------------------------------------------------------------------===// + +#include "clang/Driver/Compilation.h" +#include "clang/Driver/Driver.h" +using namespace clang; + +Driver::Driver() { +} + +Driver::~Driver() { +} + +Compilation *Driver::BuildCompilation(int argc, const char **argv) { + return new Compilation(); +} + + diff --git a/lib/Driver/Makefile b/lib/Driver/Makefile new file mode 100644 index 0000000000..a43033acbe --- /dev/null +++ b/lib/Driver/Makefile @@ -0,0 +1,18 @@ +##===- clang/lib/Driver/Makefile ---------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LEVEL = ../../../.. +LIBRARYNAME := clangDriver +BUILD_ARCHIVE = 1 +CXXFLAGS = -fno-rtti + +CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include + +include $(LEVEL)/Makefile.common + diff --git a/lib/Makefile b/lib/Makefile index 802c91e943..50ed94a88d 100755 --- a/lib/Makefile +++ b/lib/Makefile @@ -8,7 +8,8 @@ ##===----------------------------------------------------------------------===## LEVEL = ../../.. -PARALLEL_DIRS = Headers Basic Lex Parse AST Sema CodeGen Analysis Rewrite Frontend +PARALLEL_DIRS = Headers Basic Lex Parse AST Sema CodeGen Analysis Rewrite \ + Frontend Driver include $(LEVEL)/Makefile.common diff --git a/tools/Makefile b/tools/Makefile index 0fee3f8a11..25a43cdc67 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -8,6 +8,6 @@ ##===----------------------------------------------------------------------===## LEVEL := ../../.. -DIRS := ccc +DIRS := ccc driver include $(LEVEL)/Makefile.common diff --git a/tools/driver/Makefile b/tools/driver/Makefile new file mode 100644 index 0000000000..88b9309eda --- /dev/null +++ b/tools/driver/Makefile @@ -0,0 +1,21 @@ +##===- tools/driver/Makefile -------------------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## +LEVEL = ../../../.. + +TOOLNAME = clang-driver +CPPFLAGS += -I$(PROJ_SRC_DIR)/../../include +CXXFLAGS = -fno-rtti + +LINK_COMPONENTS := system +USEDLIBS = clangDriver.a + +# This tool has no plugins, optimize startup time. +TOOL_NO_EXPORTS = 1 + +include $(LEVEL)/Makefile.common diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp new file mode 100644 index 0000000000..7c01e9b49b --- /dev/null +++ b/tools/driver/driver.cpp @@ -0,0 +1,29 @@ +//===-- 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. +// +//===----------------------------------------------------------------------===// +// +// This is the entry point to the clang driver; it is a thin +// wrapper for functionality in the Driver clang library. +// +//===----------------------------------------------------------------------===// + +#include "clang/Driver/Compilation.h" +#include "clang/Driver/Driver.h" +#include "llvm/ADT/OwningPtr.h" +#include "llvm/System/Signals.h" +using namespace clang; + +int main(int argc, const char **argv) { + llvm::sys::PrintStackTraceOnErrorSignal(); + + llvm::OwningPtr TheDriver(new Driver()); + + llvm::OwningPtr C(TheDriver->BuildCompilation(argc, argv)); + + return C->Execute(); +}