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
17package {
18    default_applicable_licenses: ["frameworks_compile_slang_license"],
19}
20
21// Added automatically by a large-scale-change that took the approach of
22// 'apply every license found to every target'. While this makes sure we respect
23// every license restriction, it may not be entirely correct.
24//
25// e.g. GPL in an MIT project might only apply to the contrib/ directory.
26//
27// Please consider splitting the single license below into multiple licenses,
28// taking care not to lose any license_kind information, and overriding the
29// default license using the 'licenses: [...]' property on targets as needed.
30//
31// For unused files, consider creating a 'fileGroup' with "//visibility:private"
32// to attach the license to, and including a comment whether the files may be
33// used in the current project.
34// See: http://go/android-license-faq
35license {
36    name: "frameworks_compile_slang_license",
37    visibility: [":__subpackages__"],
38    license_kinds: [
39        "SPDX-license-identifier-Apache-2.0",
40        "SPDX-license-identifier-BSD",
41        "SPDX-license-identifier-MIT",
42        "SPDX-license-identifier-NCSA",
43        "legacy_unencumbered",
44    ],
45    license_text: [
46        "NOTICE",
47    ],
48}
49
50cc_defaults {
51    name: "rs-version",
52    cflags: [
53        "-DRS_VERSION=24",
54    ],
55}
56
57cc_defaults {
58    name: "slang-defaults",
59    defaults: [
60        "clang-defaults",
61        "rs-version",
62    ],
63
64    cflags: [
65        "-std=c++11",
66        "-D__DISABLE_ASSERTS",
67        "-DTARGET_BUILD_VARIANT=user",
68    ],
69
70    product_variables: {
71        debuggable: {
72            cflags: [
73                "-U__DISABLE_ASSERTS",
74                "-UTARGET_BUILD_VARIANT",
75                "-DTARGET_BUILD_VARIANT=userdebug",
76            ],
77        },
78        eng: {
79            cflags: [
80                "-O0",
81                "-D__ENABLE_INTERNAL_OPTIONS",
82                "-UTARGET_BUILD_VARIANT",
83                "-DTARGET_BUILD_VARIANT=eng",
84            ],
85        },
86    },
87}
88
89static_libraries_needed_by_slang = [
90    "libLLVMBitWriter_2_9",
91    "libLLVMBitWriter_2_9_func",
92    "libLLVMBitWriter_3_2",
93    "libStripUnkAttr",
94]
95
96// Exported header files
97cc_library_headers {
98    name: "slang_headers",
99    vendor_available: true,
100    export_include_dirs: ["."],
101    host_supported: true,
102    // TODO(b/153609531): remove when no longer needed.
103    native_bridge_supported: true,
104    target: {
105        windows: {
106            enabled: true,
107        },
108    },
109}
110
111// Static library libslang for host
112// ========================================================
113cc_library_host_static {
114    name: "libslang",
115    defaults: ["slang-defaults"],
116    compile_multilib: "first",
117
118    target: {
119        windows: {
120            // Skip missing-field-initializer warnings for mingw.
121            cflags: ["-Wno-error=missing-field-initializers"],
122        },
123    },
124
125    srcs: [
126        "slang.cpp",
127        "slang_bitcode_gen.cpp",
128        "slang_backend.cpp",
129        "slang_diagnostic_buffer.cpp",
130    ],
131
132    shared_libs: ["libbcinfo"],
133}
134
135// ========================================================
136
137cc_binary_host {
138    name: "llvm-rs-as",
139    defaults: ["slang-defaults"],
140
141    srcs: ["llvm-rs-as.cpp"],
142
143    static_libs: ["libslang"] + static_libraries_needed_by_slang,
144    shared_libs: ["libLLVM_android"],
145
146    product_variables: {
147        unbundled_build: {
148            enabled: false,
149        },
150    },
151}
152
153// Executable llvm-rs-cc for host
154// ========================================================
155
156// For build RSCCOptions.inc from RSCCOptions.td
157llvm_tblgen {
158    name: "slang-gen-options",
159    in: "RSCCOptions.td",
160    outs: ["RSCCOptions.inc"],
161}
162
163cc_binary_host {
164    name: "llvm-rs-cc",
165    defaults: ["slang-defaults"],
166
167    generated_headers: ["slang-gen-options"],
168    srcs: [
169        "llvm-rs-cc.cpp",
170        "rs_cc_options.cpp",
171        "slang_rs_foreach_lowering.cpp",
172        "slang_rs_ast_replace.cpp",
173        "slang_rs_check_ast.cpp",
174        "slang_rs_context.cpp",
175        "slang_rs_pragma_handler.cpp",
176        "slang_rs_exportable.cpp",
177        "slang_rs_export_type.cpp",
178        "slang_rs_export_element.cpp",
179        "slang_rs_export_var.cpp",
180        "slang_rs_export_func.cpp",
181        "slang_rs_export_foreach.cpp",
182        "slang_rs_export_reduce.cpp",
183        "slang_rs_object_ref_count.cpp",
184        "slang_rs_reflection.cpp",
185        "slang_rs_reflection_cpp.cpp",
186        "slang_rs_reflection_state.cpp",
187        "slang_rs_reflect_utils.cpp",
188        "slang_rs_special_func.cpp",
189        "slang_rs_special_kernel_param.cpp",
190    ],
191
192    static_libs: ["libslang"] + static_libraries_needed_by_slang,
193
194    shared_libs: [
195        "libbcinfo",
196        "libclang_android",
197        "libLLVM_android",
198    ],
199
200    target: {
201        windows: {
202            host_ldlibs: [
203                "-limagehlp",
204                "-lpsapi",
205            ],
206            cflags: [
207                // Skip missing-field-initializer warnings for mingw.
208                "-Wno-error=missing-field-initializers",
209            ],
210        },
211    },
212}
213
214cc_binary_host {
215    name: "lld",
216    srcs: ["lld_main.cpp"],
217    ldflags: ["-static"],
218    stl: "libc++_static",
219    target: {
220        darwin: {
221            enabled: false,
222        },
223        linux: {
224            enabled: false,
225        },
226        windows: {
227            enabled: true,
228        },
229    },
230}
231
232subdirs = [
233    "BitWriter_2_9",
234    "BitWriter_2_9_func",
235    "BitWriter_3_2",
236    "StripUnkAttr",
237]
238