1 // A (first stab at a) replacement for the Clang's ccc script.
2 // To compile, use this command:
3 // make TOOLNAME=ccc GRAPH=examples/Clang.td
8 // TOFIX: Add an explicit option list for aliases and things like this.
9 def Options : OptionList<[
11 (help "Stop after the preprocessing stage, do not run the compiler"))
14 class clang_base<string language, dag cmdline> : Tool<
15 [(in_language language),
16 (out_language "llvm-bitcode"),
19 (switch_option "E", (stop_compilation), (output_suffix "i")),
23 def clang_c : clang_base<"c",
28 "clang -E -x c $INFILE -o $OUTFILE",
30 "clang -E -x c $INFILE"),
32 "clang -emit-llvm-bc -x c $INFILE -o $OUTFILE")>;
34 def clang_cpp : clang_base<"c++",
39 "clang -E -x c++ $INFILE -o $OUTFILE",
41 "clang -E -x c++ $INFILE"),
43 "clang -emit-llvm-bc -x c++ $INFILE -o $OUTFILE")>;
45 def clang_objective_c : clang_base<"objective-c",
50 "clang -E -x objective-c $INFILE -o $OUTFILE",
52 "clang -E -x objective-c $INFILE"),
54 "clang -emit-llvm-bc -x objective-c $INFILE -o $OUTFILE")>;
58 [(in_language "llvm-bitcode"),
59 (out_language "executable"),
60 (output_suffix "out"),
61 (cmd_line "llvm-ld -native -disable-internalize $INFILE -o $OUTFILE"),
62 (prefix_list_option "L", (forward), (help "Specify a library search path")),
68 def LanguageMap : LanguageMap<
69 [LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>,
70 LangToSuffixes<"c", ["c"]>,
71 LangToSuffixes<"objective-c", ["m"]>,
72 LangToSuffixes<"c-cpp-output", ["i"]>,
73 LangToSuffixes<"objective-c-cpp-output", ["mi"]>
78 def CompilationGraph : CompilationGraph<[
80 Edge<root, clang_cpp>,
81 Edge<root, clang_objective_c>,
82 Edge<clang_c, llvm_ld>,
83 Edge<clang_cpp, llvm_ld>,
84 Edge<clang_objective_c, llvm_ld>