2008-05-30 06:16:32 +00:00
|
|
|
// A (first stab at a) replacement for the Clang's ccc script.
|
|
|
|
// To compile, use this command:
|
2008-10-02 21:15:05 +00:00
|
|
|
// cd $LLVMC2_DIR
|
2008-10-03 09:09:34 +00:00
|
|
|
// make DRIVER_NAME=ccc2 BUILTIN_PLUGINS=Clang
|
2008-05-30 06:16:32 +00:00
|
|
|
|
2008-10-02 21:15:05 +00:00
|
|
|
include "llvm/CompilerDriver/Common.td"
|
2008-05-30 06:16:32 +00:00
|
|
|
|
2008-05-30 06:26:08 +00:00
|
|
|
|
|
|
|
def Options : OptionList<[
|
|
|
|
(switch_option "E",
|
|
|
|
(help "Stop after the preprocessing stage, do not run the compiler"))
|
|
|
|
]>;
|
|
|
|
|
|
|
|
class clang_base<string language, dag cmdline> : Tool<
|
|
|
|
[(in_language language),
|
2008-05-30 06:16:32 +00:00
|
|
|
(out_language "llvm-bitcode"),
|
|
|
|
(output_suffix "bc"),
|
2008-05-30 06:26:08 +00:00
|
|
|
(cmd_line cmdline),
|
|
|
|
(switch_option "E", (stop_compilation), (output_suffix "i")),
|
2008-05-30 06:16:32 +00:00
|
|
|
(sink)
|
|
|
|
]>;
|
|
|
|
|
2008-05-30 06:26:08 +00:00
|
|
|
def clang_c : clang_base<"c",
|
|
|
|
(case
|
|
|
|
(switch_on "E"),
|
|
|
|
(case
|
|
|
|
(not_empty "o"),
|
|
|
|
"clang -E -x c $INFILE -o $OUTFILE",
|
|
|
|
(default),
|
|
|
|
"clang -E -x c $INFILE"),
|
|
|
|
(default),
|
|
|
|
"clang -emit-llvm-bc -x c $INFILE -o $OUTFILE")>;
|
|
|
|
|
|
|
|
def clang_cpp : clang_base<"c++",
|
|
|
|
(case
|
|
|
|
(switch_on "E"),
|
|
|
|
(case
|
|
|
|
(not_empty "o"),
|
|
|
|
"clang -E -x c++ $INFILE -o $OUTFILE",
|
|
|
|
(default),
|
|
|
|
"clang -E -x c++ $INFILE"),
|
|
|
|
(default),
|
|
|
|
"clang -emit-llvm-bc -x c++ $INFILE -o $OUTFILE")>;
|
|
|
|
|
|
|
|
def clang_objective_c : clang_base<"objective-c",
|
|
|
|
(case
|
|
|
|
(switch_on "E"),
|
|
|
|
(case
|
|
|
|
(not_empty "o"),
|
|
|
|
"clang -E -x objective-c $INFILE -o $OUTFILE",
|
|
|
|
(default),
|
|
|
|
"clang -E -x objective-c $INFILE"),
|
|
|
|
(default),
|
|
|
|
"clang -emit-llvm-bc -x objective-c $INFILE -o $OUTFILE")>;
|
|
|
|
|
2008-05-30 06:16:32 +00:00
|
|
|
// Default linker
|
|
|
|
def llvm_ld : Tool<
|
|
|
|
[(in_language "llvm-bitcode"),
|
|
|
|
(out_language "executable"),
|
|
|
|
(output_suffix "out"),
|
|
|
|
(cmd_line "llvm-ld -native -disable-internalize $INFILE -o $OUTFILE"),
|
|
|
|
(prefix_list_option "L", (forward), (help "Specify a library search path")),
|
|
|
|
(join)
|
|
|
|
]>;
|
|
|
|
|
|
|
|
// Language map
|
|
|
|
|
|
|
|
def LanguageMap : LanguageMap<
|
|
|
|
[LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>,
|
|
|
|
LangToSuffixes<"c", ["c"]>,
|
|
|
|
LangToSuffixes<"objective-c", ["m"]>,
|
|
|
|
LangToSuffixes<"c-cpp-output", ["i"]>,
|
|
|
|
LangToSuffixes<"objective-c-cpp-output", ["mi"]>
|
|
|
|
]>;
|
|
|
|
|
|
|
|
// Compilation graph
|
|
|
|
|
|
|
|
def CompilationGraph : CompilationGraph<[
|
2008-11-17 17:29:18 +00:00
|
|
|
Edge<"root", "clang_c">,
|
|
|
|
Edge<"root", "clang_cpp">,
|
|
|
|
Edge<"root", "clang_objective_c">,
|
|
|
|
Edge<"clang_c", "llvm_ld">,
|
|
|
|
Edge<"clang_cpp", "llvm_ld">,
|
|
|
|
Edge<"clang_objective_c", "llvm_ld">
|
2008-05-30 06:16:32 +00:00
|
|
|
]>;
|