1//
2// Copyright (C) 2010 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//      http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17cc_defaults {
18    name: "rs-version",
19    cflags: [
20        "-DRS_VERSION=24",
21    ],
22}
23
24cc_defaults {
25    name: "slang-defaults",
26    defaults: [
27        "clang-defaults",
28        "rs-version",
29    ],
30
31    cflags: [
32        "-Wall",
33        "-Werror",
34        "-std=c++11",
35
36        "-D__DISABLE_ASSERTS",
37
38        "-DTARGET_BUILD_VARIANT=user",
39    ],
40
41    product_variables: {
42        debuggable: {
43            cflags: [
44                "-U__DISABLE_ASSERTS",
45
46                "-UTARGET_BUILD_VARIANT",
47                "-DTARGET_BUILD_VARIANT=userdebug",
48            ],
49        },
50        eng: {
51            cflags: [
52                "-O0",
53                "-D__ENABLE_INTERNAL_OPTIONS",
54
55                "-UTARGET_BUILD_VARIANT",
56                "-DTARGET_BUILD_VARIANT=eng",
57            ],
58        },
59    },
60}
61
62static_libraries_needed_by_slang = [
63    "libLLVMBitWriter_2_9",
64    "libLLVMBitWriter_2_9_func",
65    "libLLVMBitWriter_3_2",
66    "libStripUnkAttr",
67]
68
69// Exported header files
70cc_library_headers {
71    name: "slang_headers",
72    vendor_available: true,
73    export_include_dirs: ["."],
74    host_supported: true,
75    // TODO(b/153609531): remove when no longer needed.
76    native_bridge_supported: true,
77    target: {
78        windows: {
79	    enabled: true,
80	},
81    },
82}
83
84// Static library libslang for host
85// ========================================================
86cc_library_host_static {
87    name: "libslang",
88    defaults: ["slang-defaults"],
89    compile_multilib: "first",
90
91    target: {
92        windows: {
93            // Skip missing-field-initializer warnings for mingw.
94            cflags: ["-Wno-error=missing-field-initializers"],
95        },
96    },
97
98    srcs: [
99        "slang.cpp",
100        "slang_bitcode_gen.cpp",
101        "slang_backend.cpp",
102        "slang_diagnostic_buffer.cpp",
103    ],
104
105    shared_libs: ["libbcinfo"],
106
107    product_variables: {
108        unbundled_build: {
109            enabled: false,
110        },
111    },
112}
113
114// ========================================================
115
116cc_binary_host {
117    name: "llvm-rs-as",
118    defaults: ["slang-defaults"],
119
120    srcs: ["llvm-rs-as.cpp"],
121
122    static_libs: ["libslang"] + static_libraries_needed_by_slang,
123    shared_libs: ["libLLVM_android"],
124
125    product_variables: {
126        unbundled_build: {
127            enabled: false,
128        },
129    },
130}
131
132// Executable llvm-rs-cc for host
133// ========================================================
134
135// For build RSCCOptions.inc from RSCCOptions.td
136llvm_tblgen {
137    name: "slang-gen-options",
138    in: "RSCCOptions.td",
139    outs: ["RSCCOptions.inc"],
140}
141
142cc_binary_host {
143    name: "llvm-rs-cc",
144    defaults: ["slang-defaults"],
145
146    generated_headers: ["slang-gen-options"],
147    srcs: [
148        "llvm-rs-cc.cpp",
149        "rs_cc_options.cpp",
150        "slang_rs_foreach_lowering.cpp",
151        "slang_rs_ast_replace.cpp",
152        "slang_rs_check_ast.cpp",
153        "slang_rs_context.cpp",
154        "slang_rs_pragma_handler.cpp",
155        "slang_rs_exportable.cpp",
156        "slang_rs_export_type.cpp",
157        "slang_rs_export_element.cpp",
158        "slang_rs_export_var.cpp",
159        "slang_rs_export_func.cpp",
160        "slang_rs_export_foreach.cpp",
161        "slang_rs_export_reduce.cpp",
162        "slang_rs_object_ref_count.cpp",
163        "slang_rs_reflection.cpp",
164        "slang_rs_reflection_cpp.cpp",
165        "slang_rs_reflection_state.cpp",
166        "slang_rs_reflect_utils.cpp",
167        "slang_rs_special_func.cpp",
168        "slang_rs_special_kernel_param.cpp",
169    ],
170
171    static_libs: ["libslang"] + static_libraries_needed_by_slang,
172
173    shared_libs: [
174        "libbcinfo",
175        "libclang_android",
176        "libLLVM_android",
177    ],
178
179    target: {
180        windows: {
181            host_ldlibs: [
182                "-limagehlp",
183                "-lpsapi",
184            ],
185            cflags: [
186                // Skip missing-field-initializer warnings for mingw.
187                "-Wno-error=missing-field-initializers",
188            ],
189        },
190    },
191
192    product_variables: {
193        unbundled_build: {
194            enabled: false,
195        },
196    },
197}
198
199cc_binary_host {
200    name: "lld",
201    srcs: ["lld_main.cpp"],
202    ldflags: ["-static"],
203    stl: "libc++_static",
204    target: {
205        darwin: {
206            enabled: false,
207        },
208        linux: {
209            enabled: false,
210        },
211        windows: {
212            enabled: true,
213        },
214    },
215}
216
217subdirs = [
218    "BitWriter_2_9",
219    "BitWriter_2_9_func",
220    "BitWriter_3_2",
221    "StripUnkAttr",
222]
223