2008-12-07 16:43:17 +00:00
|
|
|
// A replacement for the Clang's ccc script.
|
|
|
|
// Depends on the Base plugin.
|
2008-05-30 06:16:32 +00:00
|
|
|
// 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<[
|
2008-12-07 16:43:17 +00:00
|
|
|
(extern_switch "E",
|
|
|
|
(help "Stop after the preprocessing stage, do not run the compiler")),
|
|
|
|
(extern_list "L", (help "Specify a library search path")),
|
|
|
|
(switch_option "clang", (help "Use Clang instead of llvm-gcc"))
|
2008-05-30 06:26:08 +00:00
|
|
|
]>;
|
|
|
|
|
2008-11-28 00:14:11 +00:00
|
|
|
class clang_based<string language, string cmd> : Tool<
|
2008-05-30 06:26:08 +00:00
|
|
|
[(in_language language),
|
2008-05-30 06:16:32 +00:00
|
|
|
(out_language "llvm-bitcode"),
|
|
|
|
(output_suffix "bc"),
|
2008-11-28 00:14:11 +00:00
|
|
|
(cmd_line (case
|
|
|
|
(switch_on "E"),
|
|
|
|
(case
|
|
|
|
(not_empty "o"),
|
|
|
|
!strconcat(cmd, " -E $INFILE -o $OUTFILE"),
|
|
|
|
(default),
|
|
|
|
!strconcat(cmd, " -E $INFILE")),
|
|
|
|
(default),
|
|
|
|
!strconcat(cmd, " -emit-llvm-bc $INFILE -o $OUTFILE"))),
|
2008-12-07 16:43:17 +00:00
|
|
|
(actions (case (switch_on "E"),
|
|
|
|
[(stop_compilation), (output_suffix "i")])),
|
2008-05-30 06:16:32 +00:00
|
|
|
(sink)
|
|
|
|
]>;
|
|
|
|
|
2008-11-28 00:14:11 +00:00
|
|
|
def clang_c : clang_based<"c", "clang -x c">;
|
|
|
|
def clang_cpp : clang_based<"c++", "clang -x c++">;
|
|
|
|
def clang_objective_c : clang_based<"objective-c", "clang -x objective-c">;
|
|
|
|
def clang_objective_cpp : clang_based<"objective-c++",
|
|
|
|
"clang -x objective-c++">;
|
2008-05-30 06:26:08 +00:00
|
|
|
|
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"),
|
2008-12-07 16:43:17 +00:00
|
|
|
(actions (case (not_empty "L"), (forward "L"))),
|
2008-05-30 06:16:32 +00:00
|
|
|
(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-12-07 16:43:17 +00:00
|
|
|
OptionalEdge<"root", "clang_c",
|
|
|
|
(case (switch_on "clang"), (inc_weight))>,
|
|
|
|
OptionalEdge<"root", "clang_cpp",
|
|
|
|
(case (switch_on "clang"), (inc_weight))>,
|
|
|
|
OptionalEdge<"root", "clang_objective_c",
|
|
|
|
(case (switch_on "clang"), (inc_weight))>,
|
2008-11-17 17:29:18 +00:00
|
|
|
Edge<"clang_c", "llvm_ld">,
|
|
|
|
Edge<"clang_cpp", "llvm_ld">,
|
|
|
|
Edge<"clang_objective_c", "llvm_ld">
|
2008-05-30 06:16:32 +00:00
|
|
|
]>;
|