blob: f57c7266a34538f823a97f215c8eaf9a3111ad28 [file] [log] [blame]
Mikhail Glushenkov163dc1e2008-05-30 06:16:32 +00001// 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
4
5include "Common.td"
6
Mikhail Glushenkov163dc1e2008-05-30 06:16:32 +00007def clang : Tool<
Mikhail Glushenkovffcf3a12008-05-30 06:18:16 +00008[(in_language ["c", "c++", "objective-c"]),
Mikhail Glushenkov163dc1e2008-05-30 06:16:32 +00009 (out_language "llvm-bitcode"),
10 (output_suffix "bc"),
Mikhail Glushenkovef4160d2008-05-30 06:18:50 +000011 (cmd_line (case (switch_on "E"), "clang -E $INFILE",
Mikhail Glushenkov2e73e852008-05-30 06:19:52 +000012 (in_language "c"),
13 "clang -emit-llvm-bc -x c $INFILE -o $OUTFILE",
14 (in_language "c++"),
15 "clang -emit-llvm-bc -x c++ $INFILE -o $OUTFILE",
16 (in_language "objective-c"),
17 "clang -emit-llvm-bc -x objective-c$INFILE -o $OUTFILE")),
Mikhail Glushenkov163dc1e2008-05-30 06:16:32 +000018 (switch_option "E", (stop_compilation), (output_suffix "i"),
19 (help "Stop after the preprocessing stage, do not run the compiler")),
20 (sink)
21]>;
22
23// Default linker
24def llvm_ld : Tool<
25[(in_language "llvm-bitcode"),
26 (out_language "executable"),
27 (output_suffix "out"),
28 (cmd_line "llvm-ld -native -disable-internalize $INFILE -o $OUTFILE"),
29 (prefix_list_option "L", (forward), (help "Specify a library search path")),
30 (join)
31]>;
32
33// Language map
34
35def LanguageMap : LanguageMap<
36 [LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>,
37 LangToSuffixes<"c", ["c"]>,
38 LangToSuffixes<"objective-c", ["m"]>,
39 LangToSuffixes<"c-cpp-output", ["i"]>,
40 LangToSuffixes<"objective-c-cpp-output", ["mi"]>
41 ]>;
42
43// Compilation graph
44
45def CompilationGraph : CompilationGraph<[
46 Edge<root, clang>,
47 Edge<clang, llvm_ld>
48 ]>;
49