1cc_defaults {
2    name: "clang-defaults",
3    defaults: [
4        "llvm-defaults",
5    ],
6
7    header_libs: ["clang-headers"],
8
9    cflags: [
10        "-pedantic",
11        "-Wno-cast-qual",
12        "-Wno-long-long",
13        "-Wno-unused-private-field",
14        "-Wno-unused-lambda-capture",
15    ],
16
17    include_dirs: [
18        "external/clang/include",
19        "external/clang/lib/CodeGen",
20    ],
21
22    tidy_checks: [
23        "-google-runtime-member-string-references",
24    ],
25
26    target: {
27        windows: {
28            enabled: true,
29            cflags: [
30                // This triggers an assertion on cross Windows builds.
31                "-Wno-error=uninitialized",
32            ],
33        },
34        not_windows: {
35            cflags: [
36                "-Wno-unused-lambda-capture",
37            ],
38        },
39    },
40
41}
42
43clang_generated_headers = [
44    "clang-gen-options",
45    "clang-gen-attributes",
46    "clang-gen-checkers",
47    "clang-gen-comment-commands",
48    "clang-gen-comment-html-named-character-references",
49    "clang-gen-html-tags",
50    "clang-gen-comment-nodes",
51    "clang-gen-diagnostics",
52    "clang-gen-declnodes",
53    "clang-gen-statnodes",
54    "clang-gen-arm-neon",
55    "clang-version",
56    "llvm-gen-attributes",
57    "llvm-gen-intrinsics",
58]
59
60cc_library_headers {
61    name: "clang-headers",
62    vendor_available: true,
63    host_supported: true,
64    // TODO(b/153609531): remove when no longer needed.
65    native_bridge_supported: true,
66    generated_headers: clang_generated_headers,
67    export_include_dirs: ["include"],
68    export_generated_headers: clang_generated_headers,
69    target: {
70        windows: {
71            enabled: true,
72        },
73    },
74}
75
76llvm_tblgen {
77    name: "clang-gen-options",
78    in: "include/clang/Driver/Options.td",
79    outs: ["clang/Driver/Options.inc"],
80}
81
82clang_tblgen {
83    name: "clang-gen-attributes",
84    in: "include/clang/Basic/Attr.td",
85    outs: [
86        "clang/AST/AttrDump.inc",
87        "clang/AST/AttrImpl.inc",
88        "clang/AST/Attrs.inc",
89        "clang/AST/AttrVisitor.inc",
90        "clang/Basic/AttrHasAttributeImpl.inc",
91        "clang/Basic/AttrList.inc",
92        "clang/Parse/AttrParserStringSwitches.inc",
93        "clang/Sema/AttrParsedAttrImpl.inc",
94        "clang/Sema/AttrParsedAttrKinds.inc",
95        "clang/Sema/AttrParsedAttrList.inc",
96        "clang/Sema/AttrSpellingListIndex.inc",
97        "clang/Sema/AttrTemplateInstantiate.inc",
98        "clang/Serialization/AttrPCHRead.inc",
99        "clang/Serialization/AttrPCHWrite.inc",
100    ],
101}
102
103clang_tblgen {
104    name: "clang-gen-checkers",
105    in: "include/clang/StaticAnalyzer/Checkers/Checkers.td",
106    outs: ["clang/StaticAnalyzer/Checkers/Checkers.inc"],
107}
108
109clang_tblgen {
110    name: "clang-gen-comment-commands",
111    in: "include/clang/AST/CommentCommands.td",
112    outs: [
113        "clang/AST/CommentCommandInfo.inc",
114        "clang/AST/CommentCommandList.inc",
115    ],
116}
117
118clang_tblgen {
119    name: "clang-gen-comment-html-named-character-references",
120    in: "include/clang/AST/CommentHTMLNamedCharacterReferences.td",
121    outs: ["clang/AST/CommentHTMLNamedCharacterReferences.inc"],
122}
123
124clang_tblgen {
125    name: "clang-gen-html-tags",
126    in: "include/clang/AST/CommentHTMLTags.td",
127    outs: [
128        "clang/AST/CommentHTMLTagsProperties.inc",
129        "clang/AST/CommentHTMLTags.inc",
130    ],
131}
132
133clang_tblgen {
134    name: "clang-gen-comment-nodes",
135    in: "include/clang/Basic/CommentNodes.td",
136    outs: ["clang/AST/CommentNodes.inc"],
137}
138
139clang_tblgen {
140    name: "clang-gen-diagnostics",
141    in: "include/clang/Basic/Diagnostic.td",
142    outs: [
143        "clang/Basic/DiagnosticAnalysisKinds.inc",
144        "clang/Basic/DiagnosticASTKinds.inc",
145        "clang/Basic/DiagnosticCommentKinds.inc",
146        "clang/Basic/DiagnosticCommonKinds.inc",
147        "clang/Basic/DiagnosticDriverKinds.inc",
148        "clang/Basic/DiagnosticFrontendKinds.inc",
149        "clang/Basic/DiagnosticLexKinds.inc",
150        "clang/Basic/DiagnosticParseKinds.inc",
151        "clang/Basic/DiagnosticSemaKinds.inc",
152        "clang/Basic/DiagnosticSerializationKinds.inc",
153        "clang/Basic/DiagnosticGroups.inc",
154        "clang/Basic/DiagnosticIndexName.inc",
155    ],
156}
157
158clang_tblgen {
159    name: "clang-gen-declnodes",
160    in: "include/clang/Basic/DeclNodes.td",
161    outs: ["clang/AST/DeclNodes.inc"],
162}
163
164clang_tblgen {
165    name: "clang-gen-statnodes",
166    in: "include/clang/Basic/StmtNodes.td",
167    outs: ["clang/AST/StmtNodes.inc"],
168}
169
170clang_tblgen {
171    name: "clang-gen-arm-neon",
172    in: "include/clang/Basic/arm_neon.td",
173    outs: [
174        "clang/Basic/arm_neon.inc",
175        "clang/Basic/arm_neon.h",
176    ],
177}
178
179genrule {
180    name: "clang-version",
181    cmd: "$(location) $(in) > $(out)",
182    tool_files: [
183        "clang-version-inc.py",
184        "version.py",
185    ],
186    srcs: [
187        "include/clang/Basic/Version.inc.in",
188    ],
189    out: ["clang/Basic/Version.inc"],
190}
191
192cc_library_shared {
193    name: "libclang_android",
194    defaults: [
195        "clang-defaults",
196        "force_build_llvm_components",
197    ],
198
199    host_supported: true,
200
201    whole_static_libs: [
202        "libclangAnalysis",
203        "libclangAST",
204        "libclangASTMatchers",
205        "libclangBasic",
206        "libclangCodeGen",
207        "libclangDriver",
208        "libclangEdit",
209        "libclangFormat",
210        "libclangFrontend",
211        "libclangIndex",
212        "libclangLex",
213        "libclangLibclang",
214        "libclangParse",
215        "libclangRewrite",
216        "libclangRewriteFrontend",
217        "libclangSema",
218        "libclangSerialization",
219        "libclangTooling",
220        "libclangToolingCore",
221    ],
222
223    export_shared_lib_headers: ["libLLVM_android"],
224    shared_libs: ["libLLVM_android"],
225    export_header_lib_headers: ["clang-headers"],
226
227    target: {
228        windows: {
229            host_ldlibs: [
230                "-limagehlp",
231                "-lpsapi",
232                "-lversion",
233            ],
234        },
235        not_windows: {
236            shared_libs: ["libc++"],
237        },
238    },
239
240    product_variables: {
241        unbundled_build: {
242            // Don't build the library in unbundled branches.
243            enabled: false,
244        },
245    },
246}
247
248subdirs = [
249    "lib",
250    "soong",
251    "utils/TableGen",
252    "tools/clang-check",
253    "tools/clang-format",
254    "tools/driver",
255    "tools/libclang",
256]
257