blob: d470810fb724ef9b2b3883e5697edbcba7cfd61b [file] [log] [blame]
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +00001// Copyright 2021 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package bp2build
16
17import (
18 "testing"
19
20 "android/soong/android"
21 "android/soong/cc"
22)
23
24const (
25 // See cc/testing.go for more context
26 // TODO(alexmarquez): Split out the preamble into common code?
27 soongCcLibrarySharedPreamble = soongCcLibraryStaticPreamble
28)
29
30func registerCcLibrarySharedModuleTypes(ctx android.RegistrationContext) {
31 cc.RegisterCCBuildComponents(ctx)
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +000032 ctx.RegisterModuleType("cc_library_headers", cc.LibraryHeaderFactory)
33 ctx.RegisterModuleType("cc_library_static", cc.LibraryStaticFactory)
Liz Kammer12615db2021-09-28 09:19:17 -040034 ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +000035}
36
Sam Delmerico3177a6e2022-06-21 19:28:33 +000037func runCcLibrarySharedTestCase(t *testing.T, tc Bp2buildTestCase) {
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +000038 t.Helper()
Alex Márquez Pérez Muñíz Díaz Puras Thaureauxc641cc42023-03-16 17:03:43 +000039 t.Parallel()
Sam Delmerico3177a6e2022-06-21 19:28:33 +000040 (&tc).ModuleTypeUnderTest = "cc_library_shared"
41 (&tc).ModuleTypeUnderTestFactory = cc.LibrarySharedFactory
42 RunBp2BuildTestCase(t, registerCcLibrarySharedModuleTypes, tc)
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +000043}
44
45func TestCcLibrarySharedSimple(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +000046 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
47 Description: "cc_library_shared simple overall test",
48 Filesystem: map[string]string{
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +000049 // NOTE: include_dir headers *should not* appear in Bazel hdrs later (?)
50 "include_dir_1/include_dir_1_a.h": "",
51 "include_dir_1/include_dir_1_b.h": "",
52 "include_dir_2/include_dir_2_a.h": "",
53 "include_dir_2/include_dir_2_b.h": "",
54 // NOTE: local_include_dir headers *should not* appear in Bazel hdrs later (?)
55 "local_include_dir_1/local_include_dir_1_a.h": "",
56 "local_include_dir_1/local_include_dir_1_b.h": "",
57 "local_include_dir_2/local_include_dir_2_a.h": "",
58 "local_include_dir_2/local_include_dir_2_b.h": "",
59 // NOTE: export_include_dir headers *should* appear in Bazel hdrs later
60 "export_include_dir_1/export_include_dir_1_a.h": "",
61 "export_include_dir_1/export_include_dir_1_b.h": "",
62 "export_include_dir_2/export_include_dir_2_a.h": "",
63 "export_include_dir_2/export_include_dir_2_b.h": "",
64 // NOTE: Soong implicitly includes headers in the current directory
65 "implicit_include_1.h": "",
66 "implicit_include_2.h": "",
67 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +000068 Blueprint: soongCcLibrarySharedPreamble + `
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +000069cc_library_headers {
70 name: "header_lib_1",
71 export_include_dirs: ["header_lib_1"],
72 bazel_module: { bp2build_available: false },
73}
74
75cc_library_headers {
76 name: "header_lib_2",
77 export_include_dirs: ["header_lib_2"],
78 bazel_module: { bp2build_available: false },
79}
80
81cc_library_shared {
82 name: "shared_lib_1",
83 srcs: ["shared_lib_1.cc"],
84 bazel_module: { bp2build_available: false },
85}
86
87cc_library_shared {
88 name: "shared_lib_2",
89 srcs: ["shared_lib_2.cc"],
90 bazel_module: { bp2build_available: false },
91}
92
93cc_library_static {
94 name: "whole_static_lib_1",
95 srcs: ["whole_static_lib_1.cc"],
96 bazel_module: { bp2build_available: false },
97}
98
99cc_library_static {
100 name: "whole_static_lib_2",
101 srcs: ["whole_static_lib_2.cc"],
102 bazel_module: { bp2build_available: false },
103}
104
105cc_library_shared {
106 name: "foo_shared",
107 srcs: [
108 "foo_shared1.cc",
109 "foo_shared2.cc",
110 ],
111 cflags: [
112 "-Dflag1",
113 "-Dflag2"
114 ],
115 shared_libs: [
116 "shared_lib_1",
117 "shared_lib_2"
118 ],
119 whole_static_libs: [
120 "whole_static_lib_1",
121 "whole_static_lib_2"
122 ],
123 include_dirs: [
124 "include_dir_1",
125 "include_dir_2",
126 ],
127 local_include_dirs: [
128 "local_include_dir_1",
129 "local_include_dir_2",
130 ],
131 export_include_dirs: [
132 "export_include_dir_1",
133 "export_include_dir_2"
134 ],
135 header_libs: [
136 "header_lib_1",
137 "header_lib_2"
138 ],
Yu Liufc603162022-03-01 15:44:08 -0800139 sdk_version: "current",
140 min_sdk_version: "29",
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000141
142 // TODO: Also support export_header_lib_headers
143}`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000144 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000145 MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500146 "absolute_includes": `[
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000147 "include_dir_1",
148 "include_dir_2",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500149 ]`,
150 "copts": `[
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000151 "-Dflag1",
152 "-Dflag2",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500153 ]`,
154 "export_includes": `[
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000155 "export_include_dir_1",
156 "export_include_dir_2",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500157 ]`,
158 "implementation_deps": `[
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000159 ":header_lib_1",
160 ":header_lib_2",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500161 ]`,
162 "implementation_dynamic_deps": `[
Liz Kammer7a210ac2021-09-22 15:52:58 -0400163 ":shared_lib_1",
164 ":shared_lib_2",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500165 ]`,
166 "local_includes": `[
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000167 "local_include_dir_1",
168 "local_include_dir_2",
169 ".",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500170 ]`,
171 "srcs": `[
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000172 "foo_shared1.cc",
173 "foo_shared2.cc",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500174 ]`,
175 "whole_archive_deps": `[
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000176 ":whole_static_lib_1",
177 ":whole_static_lib_2",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500178 ]`,
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux126bd582022-04-21 15:19:27 +0000179 "sdk_version": `"current"`,
180 "min_sdk_version": `"29"`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500181 }),
182 },
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000183 })
184}
185
186func TestCcLibrarySharedArchSpecificSharedLib(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000187 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
188 Description: "cc_library_shared arch-specific shared_libs with whole_static_libs",
189 Filesystem: map[string]string{},
190 Blueprint: soongCcLibrarySharedPreamble + `
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000191cc_library_static {
192 name: "static_dep",
193 bazel_module: { bp2build_available: false },
194}
195cc_library_shared {
196 name: "shared_dep",
197 bazel_module: { bp2build_available: false },
198}
199cc_library_shared {
200 name: "foo_shared",
201 arch: { arm64: { shared_libs: ["shared_dep"], whole_static_libs: ["static_dep"] } },
202 include_build_directory: false,
203}`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000204 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000205 MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500206 "implementation_dynamic_deps": `select({
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000207 "//build/bazel/platforms/arch:arm64": [":shared_dep"],
208 "//conditions:default": [],
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500209 })`,
210 "whole_archive_deps": `select({
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000211 "//build/bazel/platforms/arch:arm64": [":static_dep"],
212 "//conditions:default": [],
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500213 })`,
214 }),
215 },
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000216 })
217}
218
219func TestCcLibrarySharedOsSpecificSharedLib(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000220 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
221 Description: "cc_library_shared os-specific shared_libs",
222 Filesystem: map[string]string{},
223 Blueprint: soongCcLibrarySharedPreamble + `
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000224cc_library_shared {
225 name: "shared_dep",
226 bazel_module: { bp2build_available: false },
227}
228cc_library_shared {
229 name: "foo_shared",
230 target: { android: { shared_libs: ["shared_dep"], } },
231 include_build_directory: false,
232}`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000233 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000234 MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500235 "implementation_dynamic_deps": `select({
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000236 "//build/bazel/platforms/os:android": [":shared_dep"],
237 "//conditions:default": [],
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500238 })`,
239 }),
240 },
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000241 })
242}
243
244func TestCcLibrarySharedBaseArchOsSpecificSharedLib(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000245 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
246 Description: "cc_library_shared base, arch, and os-specific shared_libs",
247 Filesystem: map[string]string{},
248 Blueprint: soongCcLibrarySharedPreamble + `
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000249cc_library_shared {
250 name: "shared_dep",
251 bazel_module: { bp2build_available: false },
252}
253cc_library_shared {
254 name: "shared_dep2",
255 bazel_module: { bp2build_available: false },
256}
257cc_library_shared {
258 name: "shared_dep3",
259 bazel_module: { bp2build_available: false },
260}
261cc_library_shared {
262 name: "foo_shared",
263 shared_libs: ["shared_dep"],
264 target: { android: { shared_libs: ["shared_dep2"] } },
265 arch: { arm64: { shared_libs: ["shared_dep3"] } },
266 include_build_directory: false,
267}`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000268 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000269 MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500270 "implementation_dynamic_deps": `[":shared_dep"] + select({
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000271 "//build/bazel/platforms/arch:arm64": [":shared_dep3"],
272 "//conditions:default": [],
273 }) + select({
274 "//build/bazel/platforms/os:android": [":shared_dep2"],
275 "//conditions:default": [],
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500276 })`,
277 }),
278 },
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000279 })
280}
281
282func TestCcLibrarySharedSimpleExcludeSrcs(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000283 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
284 Description: "cc_library_shared simple exclude_srcs",
285 Filesystem: map[string]string{
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000286 "common.c": "",
287 "foo-a.c": "",
288 "foo-excluded.c": "",
289 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000290 Blueprint: soongCcLibrarySharedPreamble + `
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000291cc_library_shared {
292 name: "foo_shared",
293 srcs: ["common.c", "foo-*.c"],
294 exclude_srcs: ["foo-excluded.c"],
295 include_build_directory: false,
296}`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000297 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000298 MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500299 "srcs_c": `[
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000300 "common.c",
301 "foo-a.c",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500302 ]`,
303 }),
304 },
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000305 })
306}
307
308func TestCcLibrarySharedStrip(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000309 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
310 Description: "cc_library_shared stripping",
311 Filesystem: map[string]string{},
312 Blueprint: soongCcLibrarySharedPreamble + `
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000313cc_library_shared {
314 name: "foo_shared",
315 strip: {
316 keep_symbols: false,
317 keep_symbols_and_debug_frame: true,
318 keep_symbols_list: ["sym", "sym2"],
319 all: true,
320 none: false,
321 },
322 include_build_directory: false,
323}`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000324 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000325 MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500326 "strip": `{
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000327 "all": True,
328 "keep_symbols": False,
329 "keep_symbols_and_debug_frame": True,
330 "keep_symbols_list": [
331 "sym",
332 "sym2",
333 ],
334 "none": False,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500335 }`,
336 }),
337 },
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000338 })
339}
340
Trevor Radcliffe37ec2f72022-09-27 01:46:01 +0000341func TestCcLibrarySharedVersionScriptAndDynamicList(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000342 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
Trevor Radcliffe37ec2f72022-09-27 01:46:01 +0000343 Description: "cc_library_shared version script and dynamic list",
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000344 Filesystem: map[string]string{
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000345 "version_script": "",
Trevor Radcliffe37ec2f72022-09-27 01:46:01 +0000346 "dynamic.list": "",
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000347 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000348 Blueprint: soongCcLibrarySharedPreamble + `
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000349cc_library_shared {
350 name: "foo_shared",
351 version_script: "version_script",
Trevor Radcliffe37ec2f72022-09-27 01:46:01 +0000352 dynamic_list: "dynamic.list",
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000353 include_build_directory: false,
354}`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000355 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000356 MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
Trevor Radcliffe37ec2f72022-09-27 01:46:01 +0000357 "additional_linker_inputs": `[
358 "version_script",
359 "dynamic.list",
360 ]`,
361 "linkopts": `[
362 "-Wl,--version-script,$(location version_script)",
363 "-Wl,--dynamic-list,$(location dynamic.list)",
364 ]`,
Trevor Radcliffef06dd912023-05-19 14:51:41 +0000365 "features": `["android_cfi_exports_map"]`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500366 }),
367 },
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxac5097f2021-09-01 21:22:09 +0000368 })
369}
Jingwen Chen6ada5892021-09-17 11:38:09 +0000370
Trevor Radcliffeea6a45d2022-09-20 18:58:01 +0000371func TestCcLibraryLdflagsSplitBySpaceSoongAdded(t *testing.T) {
372 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
373 Description: "ldflags are split by spaces except for the ones added by soong (version script and dynamic list)",
374 Filesystem: map[string]string{
375 "version_script": "",
376 "dynamic.list": "",
377 },
378 Blueprint: `
379cc_library_shared {
380 name: "foo",
381 ldflags: [
382 "--nospace_flag",
383 "-z spaceflag",
384 ],
385 version_script: "version_script",
386 dynamic_list: "dynamic.list",
387 include_build_directory: false,
388}`,
389 ExpectedBazelTargets: []string{
390 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
391 "additional_linker_inputs": `[
392 "version_script",
393 "dynamic.list",
394 ]`,
395 "linkopts": `[
396 "--nospace_flag",
397 "-z",
398 "spaceflag",
399 "-Wl,--version-script,$(location version_script)",
400 "-Wl,--dynamic-list,$(location dynamic.list)",
401 ]`,
Trevor Radcliffef06dd912023-05-19 14:51:41 +0000402 "features": `["android_cfi_exports_map"]`,
Trevor Radcliffeea6a45d2022-09-20 18:58:01 +0000403 }),
404 },
405 })
406}
407
Jingwen Chen6ada5892021-09-17 11:38:09 +0000408func TestCcLibrarySharedNoCrtTrue(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000409 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
Alex Márquez Pérez Muñíz Díaz Puras Thaureaux01ec55e2023-01-30 22:53:04 +0000410 Description: "cc_library_shared - nocrt: true disables feature",
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000411 Filesystem: map[string]string{
Jingwen Chen6ada5892021-09-17 11:38:09 +0000412 "impl.cpp": "",
413 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000414 Blueprint: soongCcLibraryPreamble + `
Jingwen Chen6ada5892021-09-17 11:38:09 +0000415cc_library_shared {
416 name: "foo_shared",
417 srcs: ["impl.cpp"],
418 nocrt: true,
419 include_build_directory: false,
420}
421`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000422 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000423 MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
Alex Márquez Pérez Muñíz Díaz Puras Thaureaux01ec55e2023-01-30 22:53:04 +0000424 "features": `["-link_crt"]`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500425 "srcs": `["impl.cpp"]`,
426 }),
427 },
428 })
Jingwen Chen6ada5892021-09-17 11:38:09 +0000429}
430
431func TestCcLibrarySharedNoCrtFalse(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000432 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
Alex Márquez Pérez Muñíz Díaz Puras Thaureaux01ec55e2023-01-30 22:53:04 +0000433 Description: "cc_library_shared - nocrt: false doesn't disable feature",
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000434 Filesystem: map[string]string{
Jingwen Chen6ada5892021-09-17 11:38:09 +0000435 "impl.cpp": "",
436 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000437 Blueprint: soongCcLibraryPreamble + `
Jingwen Chen6ada5892021-09-17 11:38:09 +0000438cc_library_shared {
439 name: "foo_shared",
440 srcs: ["impl.cpp"],
441 nocrt: false,
442 include_build_directory: false,
443}
444`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000445 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000446 MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500447 "srcs": `["impl.cpp"]`,
448 }),
449 },
450 })
Jingwen Chen6ada5892021-09-17 11:38:09 +0000451}
452
453func TestCcLibrarySharedNoCrtArchVariant(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000454 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
455 Description: "cc_library_shared - nocrt in select",
456 Filesystem: map[string]string{
Jingwen Chen6ada5892021-09-17 11:38:09 +0000457 "impl.cpp": "",
458 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000459 Blueprint: soongCcLibraryPreamble + `
Jingwen Chen6ada5892021-09-17 11:38:09 +0000460cc_library_shared {
461 name: "foo_shared",
462 srcs: ["impl.cpp"],
463 arch: {
464 arm: {
465 nocrt: true,
466 },
467 x86: {
468 nocrt: false,
469 },
470 },
471 include_build_directory: false,
472}
473`,
Alex Márquez Pérez Muñíz Díaz Puras Thaureaux01ec55e2023-01-30 22:53:04 +0000474 ExpectedBazelTargets: []string{
475 MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
476 "features": `select({
477 "//build/bazel/platforms/arch:arm": ["-link_crt"],
478 "//conditions:default": [],
479 })`,
480 "srcs": `["impl.cpp"]`,
481 }),
482 },
Jingwen Chen6ada5892021-09-17 11:38:09 +0000483 })
484}
Liz Kammer12615db2021-09-28 09:19:17 -0400485
486func TestCcLibrarySharedProto(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000487 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
488 Blueprint: soongCcProtoPreamble + `cc_library_shared {
Liz Kammer12615db2021-09-28 09:19:17 -0400489 name: "foo",
490 srcs: ["foo.proto"],
491 proto: {
Liz Kammer12615db2021-09-28 09:19:17 -0400492 export_proto_headers: true,
493 },
494 include_build_directory: false,
495}`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000496 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000497 MakeBazelTarget("proto_library", "foo_proto", AttrNameToString{
Liz Kammer12615db2021-09-28 09:19:17 -0400498 "srcs": `["foo.proto"]`,
Alixe06d75b2022-08-31 18:28:19 +0000499 }), MakeBazelTarget("cc_lite_proto_library", "foo_cc_proto_lite", AttrNameToString{
Liz Kammer12615db2021-09-28 09:19:17 -0400500 "deps": `[":foo_proto"]`,
Alixe06d75b2022-08-31 18:28:19 +0000501 }), MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
Liz Kammer12615db2021-09-28 09:19:17 -0400502 "dynamic_deps": `[":libprotobuf-cpp-lite"]`,
503 "whole_archive_deps": `[":foo_cc_proto_lite"]`,
504 }),
505 },
506 })
507}
Rupert Shuttleworth484aa252021-12-10 07:22:53 -0500508
509func TestCcLibrarySharedUseVersionLib(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000510 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
Liz Kammerbaced712022-09-16 09:01:29 -0400511 Filesystem: map[string]string{
512 soongCcVersionLibBpPath: soongCcVersionLibBp,
513 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000514 Blueprint: soongCcProtoPreamble + `cc_library_shared {
Rupert Shuttleworth484aa252021-12-10 07:22:53 -0500515 name: "foo",
516 use_version_lib: true,
517 include_build_directory: false,
518}`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000519 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000520 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
Yu Liufe978fd2023-04-24 16:37:18 -0700521 "use_version_lib": "True",
522 "whole_archive_deps": `["//build/soong/cc/libbuildversion:libbuildversion"]`,
Rupert Shuttleworth484aa252021-12-10 07:22:53 -0500523 }),
524 },
525 })
526}
Jingwen Chen0ee88a62022-01-07 14:55:29 +0000527
528func TestCcLibrarySharedStubs(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000529 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
530 Description: "cc_library_shared stubs",
531 ModuleTypeUnderTest: "cc_library_shared",
532 ModuleTypeUnderTestFactory: cc.LibrarySharedFactory,
533 Dir: "foo/bar",
534 Filesystem: map[string]string{
Jingwen Chen0ee88a62022-01-07 14:55:29 +0000535 "foo/bar/Android.bp": `
536cc_library_shared {
537 name: "a",
538 stubs: { symbol_file: "a.map.txt", versions: ["28", "29", "current"] },
539 bazel_module: { bp2build_available: true },
540 include_build_directory: false,
541}
542`,
543 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000544 Blueprint: soongCcLibraryPreamble,
Trevor Radcliffef19d8a72022-09-20 23:04:39 +0000545 ExpectedBazelTargets: []string{makeCcStubSuiteTargets("a", AttrNameToString{
Spandan Das04f9f4c2023-09-13 23:59:05 +0000546 "api_surface": `"module-libapi"`,
Sam Delmerico5f906492023-03-15 18:06:18 -0400547 "soname": `"a.so"`,
548 "source_library_label": `"//foo/bar:a"`,
549 "stubs_symbol_file": `"a.map.txt"`,
Trevor Radcliffef19d8a72022-09-20 23:04:39 +0000550 "stubs_versions": `[
Trevor Radcliffe087af542022-09-16 15:36:10 +0000551 "28",
552 "29",
553 "current",
554 ]`,
Trevor Radcliffef19d8a72022-09-20 23:04:39 +0000555 }),
556 MakeBazelTarget("cc_library_shared", "a", AttrNameToString{
Yu Liu56ccb1a2022-11-12 10:47:07 -0800557 "stubs_symbol_file": `"a.map.txt"`,
Trevor Radcliffe087af542022-09-16 15:36:10 +0000558 }),
Jingwen Chen0ee88a62022-01-07 14:55:29 +0000559 },
Trevor Radcliffef19d8a72022-09-20 23:04:39 +0000560 })
Jingwen Chen0ee88a62022-01-07 14:55:29 +0000561}
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux126bd582022-04-21 15:19:27 +0000562
Liz Kammer48cdbeb2023-03-17 10:17:50 -0400563func TestCcLibrarySharedStubs_UseImplementationInSameApex(t *testing.T) {
564 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
565 Description: "cc_library_shared stubs",
566 ModuleTypeUnderTest: "cc_library_shared",
567 ModuleTypeUnderTestFactory: cc.LibrarySharedFactory,
568 Blueprint: soongCcLibrarySharedPreamble + `
569cc_library_shared {
570 name: "a",
571 stubs: { symbol_file: "a.map.txt", versions: ["28", "29", "current"] },
572 bazel_module: { bp2build_available: false },
573 include_build_directory: false,
574 apex_available: ["made_up_apex"],
575}
576cc_library_shared {
577 name: "b",
578 shared_libs: [":a"],
579 include_build_directory: false,
580 apex_available: ["made_up_apex"],
581}
582`,
583 ExpectedBazelTargets: []string{
584 MakeBazelTarget("cc_library_shared", "b", AttrNameToString{
585 "implementation_dynamic_deps": `[":a"]`,
586 "tags": `["apex_available=made_up_apex"]`,
587 }),
588 },
589 })
590}
591
592func TestCcLibrarySharedStubs_UseStubsInDifferentApex(t *testing.T) {
593 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
594 Description: "cc_library_shared stubs",
595 ModuleTypeUnderTest: "cc_library_shared",
596 ModuleTypeUnderTestFactory: cc.LibrarySharedFactory,
597 Blueprint: soongCcLibrarySharedPreamble + `
598cc_library_shared {
599 name: "a",
600 stubs: { symbol_file: "a.map.txt", versions: ["28", "29", "current"] },
601 bazel_module: { bp2build_available: false },
602 include_build_directory: false,
603 apex_available: ["apex_a"],
604}
605cc_library_shared {
606 name: "b",
607 shared_libs: [":a"],
608 include_build_directory: false,
609 apex_available: ["apex_b"],
610}
611`,
612 ExpectedBazelTargets: []string{
613 MakeBazelTarget("cc_library_shared", "b", AttrNameToString{
614 "implementation_dynamic_deps": `select({
Spandan Das6d4d9da2023-04-18 06:20:40 +0000615 "//build/bazel/rules/apex:apex_b": ["@api_surfaces//module-libapi/current:a"],
616 "//build/bazel/rules/apex:system": ["@api_surfaces//module-libapi/current:a"],
Liz Kammer48cdbeb2023-03-17 10:17:50 -0400617 "//conditions:default": [":a"],
618 })`,
619 "tags": `["apex_available=apex_b"]`,
620 }),
621 },
622 })
623}
624
Spandan Das6d4d9da2023-04-18 06:20:40 +0000625// Tests that library in apexfoo links against stubs of platform_lib and otherapex_lib
626func TestCcLibrarySharedStubs_UseStubsFromMultipleApiDomains(t *testing.T) {
627 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
628 Description: "cc_library_shared stubs",
629 ModuleTypeUnderTest: "cc_library_shared",
630 ModuleTypeUnderTestFactory: cc.LibrarySharedFactory,
631 Blueprint: soongCcLibrarySharedPreamble + `
632cc_library_shared {
633 name: "libplatform_stable",
634 stubs: { symbol_file: "libplatform_stable.map.txt", versions: ["28", "29", "current"] },
635 apex_available: ["//apex_available:platform"],
636 bazel_module: { bp2build_available: false },
637 include_build_directory: false,
638}
639cc_library_shared {
640 name: "libapexfoo_stable",
641 stubs: { symbol_file: "libapexfoo_stable.map.txt", versions: ["28", "29", "current"] },
642 apex_available: ["apexfoo"],
643 bazel_module: { bp2build_available: false },
644 include_build_directory: false,
645}
646cc_library_shared {
647 name: "libutils",
648 shared_libs: ["libplatform_stable", "libapexfoo_stable",],
649 apex_available: ["//apex_available:platform", "apexfoo", "apexbar"],
650 include_build_directory: false,
651}
652`,
653 ExpectedBazelTargets: []string{
654 MakeBazelTarget("cc_library_shared", "libutils", AttrNameToString{
655 "implementation_dynamic_deps": `select({
656 "//build/bazel/rules/apex:apexbar": [
657 "@api_surfaces//module-libapi/current:libplatform_stable",
658 "@api_surfaces//module-libapi/current:libapexfoo_stable",
659 ],
660 "//build/bazel/rules/apex:apexfoo": [
661 "@api_surfaces//module-libapi/current:libplatform_stable",
662 ":libapexfoo_stable",
663 ],
664 "//build/bazel/rules/apex:system": [
Spandan Dasf7bae9a2023-09-06 22:07:15 +0000665 ":libplatform_stable",
Spandan Das6d4d9da2023-04-18 06:20:40 +0000666 "@api_surfaces//module-libapi/current:libapexfoo_stable",
667 ],
668 "//conditions:default": [
669 ":libplatform_stable",
670 ":libapexfoo_stable",
671 ],
672 })`,
673 "tags": `[
674 "apex_available=//apex_available:platform",
675 "apex_available=apexfoo",
676 "apex_available=apexbar",
677 ]`,
678 }),
679 },
680 })
681}
682
Liz Kammer48cdbeb2023-03-17 10:17:50 -0400683func TestCcLibrarySharedStubs_IgnorePlatformAvailable(t *testing.T) {
684 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
685 Description: "cc_library_shared stubs",
686 ModuleTypeUnderTest: "cc_library_shared",
687 ModuleTypeUnderTestFactory: cc.LibrarySharedFactory,
688 Blueprint: soongCcLibrarySharedPreamble + `
689cc_library_shared {
690 name: "a",
691 stubs: { symbol_file: "a.map.txt", versions: ["28", "29", "current"] },
692 bazel_module: { bp2build_available: false },
693 include_build_directory: false,
694 apex_available: ["//apex_available:platform", "apex_a"],
695}
696cc_library_shared {
697 name: "b",
698 shared_libs: [":a"],
699 include_build_directory: false,
700 apex_available: ["//apex_available:platform", "apex_b"],
701}
702`,
703 ExpectedBazelTargets: []string{
704 MakeBazelTarget("cc_library_shared", "b", AttrNameToString{
705 "implementation_dynamic_deps": `select({
Spandan Das6d4d9da2023-04-18 06:20:40 +0000706 "//build/bazel/rules/apex:apex_b": ["@api_surfaces//module-libapi/current:a"],
707 "//build/bazel/rules/apex:system": ["@api_surfaces//module-libapi/current:a"],
Liz Kammer48cdbeb2023-03-17 10:17:50 -0400708 "//conditions:default": [":a"],
709 })`,
710 "tags": `[
711 "apex_available=//apex_available:platform",
712 "apex_available=apex_b",
713 ]`,
714 }),
715 },
716 })
717}
718
Spandan Das6d4d9da2023-04-18 06:20:40 +0000719func TestCcLibraryDoesNotDropStubDepIfNoVariationAcrossAxis(t *testing.T) {
720 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
721 Description: "cc_library depeends on impl for all configurations",
722 ModuleTypeUnderTest: "cc_library_shared",
723 ModuleTypeUnderTestFactory: cc.LibrarySharedFactory,
724 Blueprint: soongCcLibrarySharedPreamble + `
725cc_library_shared {
726 name: "a",
727 stubs: { symbol_file: "a.map.txt", versions: ["28", "29", "current"] },
728 bazel_module: { bp2build_available: false },
729 apex_available: ["//apex_available:platform"],
730}
731cc_library_shared {
732 name: "b",
733 shared_libs: [":a"],
734 include_build_directory: false,
735 apex_available: ["//apex_available:platform"],
736}
737`,
738 ExpectedBazelTargets: []string{
739 MakeBazelTarget("cc_library_shared", "b", AttrNameToString{
740 "implementation_dynamic_deps": `[":a"]`,
741 "tags": `["apex_available=//apex_available:platform"]`,
742 }),
743 },
744 })
745}
746
Liz Kammer48cdbeb2023-03-17 10:17:50 -0400747func TestCcLibrarySharedStubs_MultipleApexAvailable(t *testing.T) {
748 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
749 ModuleTypeUnderTest: "cc_library_shared",
750 ModuleTypeUnderTestFactory: cc.LibrarySharedFactory,
751 Blueprint: soongCcLibrarySharedPreamble + `
752cc_library_shared {
753 name: "a",
754 stubs: { symbol_file: "a.map.txt", versions: ["28", "29", "current"] },
755 bazel_module: { bp2build_available: false },
756 include_build_directory: false,
757 apex_available: ["//apex_available:platform", "apex_a", "apex_b"],
758}
759cc_library_shared {
760 name: "b",
761 shared_libs: [":a"],
762 include_build_directory: false,
763 apex_available: ["//apex_available:platform", "apex_b"],
764}
765
766cc_library_shared {
767 name: "c",
768 shared_libs: [":a"],
769 include_build_directory: false,
770 apex_available: ["//apex_available:platform", "apex_a", "apex_b"],
771}
772`,
773 ExpectedBazelTargets: []string{
774 MakeBazelTarget("cc_library_shared", "b", AttrNameToString{
775 "implementation_dynamic_deps": `select({
Spandan Das6d4d9da2023-04-18 06:20:40 +0000776 "//build/bazel/rules/apex:system": ["@api_surfaces//module-libapi/current:a"],
Liz Kammer48cdbeb2023-03-17 10:17:50 -0400777 "//conditions:default": [":a"],
778 })`,
779 "tags": `[
780 "apex_available=//apex_available:platform",
781 "apex_available=apex_b",
782 ]`,
783 }),
784 MakeBazelTarget("cc_library_shared", "c", AttrNameToString{
785 "implementation_dynamic_deps": `[":a"]`,
786 "tags": `[
787 "apex_available=//apex_available:platform",
788 "apex_available=apex_a",
789 "apex_available=apex_b",
790 ]`,
791 }),
792 },
793 })
794}
795
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux126bd582022-04-21 15:19:27 +0000796func TestCcLibrarySharedSystemSharedLibsSharedEmpty(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000797 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
798 Description: "cc_library_shared system_shared_libs empty shared default",
799 ModuleTypeUnderTest: "cc_library_shared",
800 ModuleTypeUnderTestFactory: cc.LibrarySharedFactory,
801 Blueprint: soongCcLibrarySharedPreamble + `
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux126bd582022-04-21 15:19:27 +0000802cc_defaults {
803 name: "empty_defaults",
804 shared: {
805 system_shared_libs: [],
806 },
807 include_build_directory: false,
808}
809cc_library_shared {
810 name: "empty",
811 defaults: ["empty_defaults"],
812}
813`,
Alixe06d75b2022-08-31 18:28:19 +0000814 ExpectedBazelTargets: []string{MakeBazelTarget("cc_library_shared", "empty", AttrNameToString{
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux126bd582022-04-21 15:19:27 +0000815 "system_dynamic_deps": "[]",
816 })},
817 })
818}
Trevor Radcliffeef9c9002022-05-13 20:55:35 +0000819
820func TestCcLibrarySharedConvertLex(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000821 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
822 Description: "cc_library_shared with lex files",
823 ModuleTypeUnderTest: "cc_library_shared",
824 ModuleTypeUnderTestFactory: cc.LibrarySharedFactory,
825 Filesystem: map[string]string{
Trevor Radcliffeef9c9002022-05-13 20:55:35 +0000826 "foo.c": "",
827 "bar.cc": "",
828 "foo1.l": "",
829 "bar1.ll": "",
830 "foo2.l": "",
831 "bar2.ll": "",
832 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000833 Blueprint: `cc_library_shared {
Trevor Radcliffeef9c9002022-05-13 20:55:35 +0000834 name: "foo_lib",
835 srcs: ["foo.c", "bar.cc", "foo1.l", "foo2.l", "bar1.ll", "bar2.ll"],
836 lex: { flags: ["--foo_flags"] },
837 include_build_directory: false,
838 bazel_module: { bp2build_available: true },
839}`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000840 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000841 MakeBazelTarget("genlex", "foo_lib_genlex_l", AttrNameToString{
Trevor Radcliffeef9c9002022-05-13 20:55:35 +0000842 "srcs": `[
843 "foo1.l",
844 "foo2.l",
845 ]`,
846 "lexopts": `["--foo_flags"]`,
847 }),
Alixe06d75b2022-08-31 18:28:19 +0000848 MakeBazelTarget("genlex", "foo_lib_genlex_ll", AttrNameToString{
Trevor Radcliffeef9c9002022-05-13 20:55:35 +0000849 "srcs": `[
850 "bar1.ll",
851 "bar2.ll",
852 ]`,
853 "lexopts": `["--foo_flags"]`,
854 }),
Alixe06d75b2022-08-31 18:28:19 +0000855 MakeBazelTarget("cc_library_shared", "foo_lib", AttrNameToString{
Trevor Radcliffeef9c9002022-05-13 20:55:35 +0000856 "srcs": `[
857 "bar.cc",
858 ":foo_lib_genlex_ll",
859 ]`,
860 "srcs_c": `[
861 "foo.c",
862 ":foo_lib_genlex_l",
863 ]`,
864 }),
865 },
866 })
867}
Alix1be00d42022-05-16 22:56:04 +0000868
869func TestCcLibrarySharedClangUnknownFlags(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000870 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
871 Blueprint: soongCcProtoPreamble + `cc_library_shared {
Alix1be00d42022-05-16 22:56:04 +0000872 name: "foo",
873 conlyflags: ["-a", "-finline-functions"],
874 cflags: ["-b","-finline-functions"],
875 cppflags: ["-c", "-finline-functions"],
876 ldflags: ["-d","-finline-functions", "-e"],
877 include_build_directory: false,
878}`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000879 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000880 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
Alix1be00d42022-05-16 22:56:04 +0000881 "conlyflags": `["-a"]`,
882 "copts": `["-b"]`,
883 "cppflags": `["-c"]`,
884 "linkopts": `[
885 "-d",
886 "-e",
887 ]`,
888 }),
889 },
890 })
891}
892
893func TestCCLibraryFlagSpaceSplitting(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000894 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
895 Blueprint: soongCcProtoPreamble + `cc_library_shared {
Alix1be00d42022-05-16 22:56:04 +0000896 name: "foo",
897 conlyflags: [ "-include header.h"],
898 cflags: ["-include header.h"],
899 cppflags: ["-include header.h"],
900 version_script: "version_script",
901 include_build_directory: false,
902}`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000903 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000904 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
Alix1be00d42022-05-16 22:56:04 +0000905 "additional_linker_inputs": `["version_script"]`,
906 "conlyflags": `[
907 "-include",
908 "header.h",
909 ]`,
910 "copts": `[
911 "-include",
912 "header.h",
913 ]`,
914 "cppflags": `[
915 "-include",
916 "header.h",
917 ]`,
918 "linkopts": `["-Wl,--version-script,$(location version_script)"]`,
Trevor Radcliffef06dd912023-05-19 14:51:41 +0000919 "features": `["android_cfi_exports_map"]`,
Alix1be00d42022-05-16 22:56:04 +0000920 }),
921 },
922 })
923}
Cole Faust6b29f592022-08-09 09:50:56 -0700924
925func TestCCLibrarySharedRuntimeDeps(t *testing.T) {
926 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
927 Blueprint: `cc_library_shared {
928 name: "bar",
929}
930
931cc_library_shared {
932 name: "foo",
933 runtime_libs: ["foo"],
934}`,
935 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000936 MakeBazelTarget("cc_library_shared", "bar", AttrNameToString{
Cole Faust6b29f592022-08-09 09:50:56 -0700937 "local_includes": `["."]`,
938 }),
Alixe06d75b2022-08-31 18:28:19 +0000939 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
Cole Faust6b29f592022-08-09 09:50:56 -0700940 "runtime_deps": `[":foo"]`,
941 "local_includes": `["."]`,
942 }),
943 },
944 })
945}
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxa56e9702022-02-23 18:39:59 -0500946
947func TestCcLibrarySharedEmptySuffix(t *testing.T) {
948 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
949 Description: "cc_library_shared with empty suffix",
950 Filesystem: map[string]string{
951 "foo.c": "",
952 },
953 Blueprint: soongCcLibrarySharedPreamble + `
954cc_library_shared {
955 name: "foo_shared",
956 suffix: "",
957 srcs: ["foo.c"],
958 include_build_directory: false,
959}`,
960 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000961 MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxa56e9702022-02-23 18:39:59 -0500962 "srcs_c": `["foo.c"]`,
963 "suffix": `""`,
964 }),
965 },
966 })
967}
968
969func TestCcLibrarySharedSuffix(t *testing.T) {
970 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
971 Description: "cc_library_shared with suffix",
972 Filesystem: map[string]string{
973 "foo.c": "",
974 },
975 Blueprint: soongCcLibrarySharedPreamble + `
976cc_library_shared {
977 name: "foo_shared",
978 suffix: "-suf",
979 srcs: ["foo.c"],
980 include_build_directory: false,
981}`,
982 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000983 MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxa56e9702022-02-23 18:39:59 -0500984 "srcs_c": `["foo.c"]`,
985 "suffix": `"-suf"`,
986 }),
987 },
988 })
989}
990
991func TestCcLibrarySharedArchVariantSuffix(t *testing.T) {
992 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
993 Description: "cc_library_shared with arch-variant suffix",
994 Filesystem: map[string]string{
995 "foo.c": "",
996 },
997 Blueprint: soongCcLibrarySharedPreamble + `
998cc_library_shared {
999 name: "foo_shared",
1000 arch: {
1001 arm64: { suffix: "-64" },
1002 arm: { suffix: "-32" },
1003 },
1004 srcs: ["foo.c"],
1005 include_build_directory: false,
1006}`,
1007 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +00001008 MakeBazelTarget("cc_library_shared", "foo_shared", AttrNameToString{
Alex Márquez Pérez Muñíz Díaz Púras Thaureauxa56e9702022-02-23 18:39:59 -05001009 "srcs_c": `["foo.c"]`,
1010 "suffix": `select({
1011 "//build/bazel/platforms/arch:arm": "-32",
1012 "//build/bazel/platforms/arch:arm64": "-64",
1013 "//conditions:default": None,
1014 })`,
1015 }),
1016 },
1017 })
1018}
Trevor Radcliffecee4e052022-09-06 19:31:25 +00001019
1020func TestCcLibrarySharedWithSyspropSrcs(t *testing.T) {
1021 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
1022 Description: "cc_library_shared with sysprop sources",
1023 Blueprint: `
1024cc_library_shared {
1025 name: "foo",
1026 srcs: [
1027 "bar.sysprop",
1028 "baz.sysprop",
1029 "blah.cpp",
1030 ],
1031 min_sdk_version: "5",
1032}`,
1033 ExpectedBazelTargets: []string{
1034 MakeBazelTarget("sysprop_library", "foo_sysprop_library", AttrNameToString{
1035 "srcs": `[
1036 "bar.sysprop",
1037 "baz.sysprop",
1038 ]`,
1039 }),
1040 MakeBazelTarget("cc_sysprop_library_static", "foo_cc_sysprop_library_static", AttrNameToString{
1041 "dep": `":foo_sysprop_library"`,
1042 "min_sdk_version": `"5"`,
1043 }),
1044 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
1045 "srcs": `["blah.cpp"]`,
1046 "local_includes": `["."]`,
1047 "min_sdk_version": `"5"`,
1048 "whole_archive_deps": `[":foo_cc_sysprop_library_static"]`,
1049 }),
1050 },
1051 })
1052}
1053
1054func TestCcLibrarySharedWithSyspropSrcsSomeConfigs(t *testing.T) {
1055 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
1056 Description: "cc_library_shared with sysprop sources in some configs but not others",
1057 Blueprint: `
1058cc_library_shared {
1059 name: "foo",
1060 srcs: [
1061 "blah.cpp",
1062 ],
1063 target: {
1064 android: {
1065 srcs: ["bar.sysprop"],
1066 },
1067 },
1068 min_sdk_version: "5",
1069}`,
1070 ExpectedBazelTargets: []string{
1071 MakeBazelTarget("sysprop_library", "foo_sysprop_library", AttrNameToString{
1072 "srcs": `select({
1073 "//build/bazel/platforms/os:android": ["bar.sysprop"],
1074 "//conditions:default": [],
1075 })`,
1076 }),
1077 MakeBazelTarget("cc_sysprop_library_static", "foo_cc_sysprop_library_static", AttrNameToString{
1078 "dep": `":foo_sysprop_library"`,
1079 "min_sdk_version": `"5"`,
1080 }),
1081 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
1082 "srcs": `["blah.cpp"]`,
1083 "local_includes": `["."]`,
1084 "min_sdk_version": `"5"`,
1085 "whole_archive_deps": `select({
1086 "//build/bazel/platforms/os:android": [":foo_cc_sysprop_library_static"],
1087 "//conditions:default": [],
1088 })`,
1089 }),
1090 },
1091 })
1092}
Yu Liu56ccb1a2022-11-12 10:47:07 -08001093
1094func TestCcLibrarySharedHeaderAbiChecker(t *testing.T) {
1095 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
1096 Description: "cc_library_shared with header abi checker",
1097 Blueprint: `cc_library_shared {
1098 name: "foo",
1099 header_abi_checker: {
1100 enabled: true,
1101 symbol_file: "a.map.txt",
1102 exclude_symbol_versions: [
1103 "29",
1104 "30",
1105 ],
1106 exclude_symbol_tags: [
1107 "tag1",
1108 "tag2",
1109 ],
1110 check_all_apis: true,
1111 diff_flags: ["-allow-adding-removing-weak-symbols"],
1112 },
1113 include_build_directory: false,
1114}`,
1115 ExpectedBazelTargets: []string{
1116 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
1117 "abi_checker_enabled": `True`,
1118 "abi_checker_symbol_file": `"a.map.txt"`,
1119 "abi_checker_exclude_symbol_versions": `[
1120 "29",
1121 "30",
1122 ]`,
1123 "abi_checker_exclude_symbol_tags": `[
1124 "tag1",
1125 "tag2",
1126 ]`,
1127 "abi_checker_check_all_apis": `True`,
1128 "abi_checker_diff_flags": `["-allow-adding-removing-weak-symbols"]`,
1129 }),
1130 },
1131 })
1132}
Trevor Radcliffedb7e0262022-10-28 16:48:18 +00001133
1134func TestCcLibrarySharedWithIntegerOverflowProperty(t *testing.T) {
1135 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
1136 Description: "cc_library_shared has correct features when integer_overflow property is provided",
1137 Blueprint: `
1138cc_library_shared {
1139 name: "foo",
1140 sanitize: {
1141 integer_overflow: true,
1142 },
1143}
1144`,
1145 ExpectedBazelTargets: []string{
1146 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
1147 "features": `["ubsan_integer_overflow"]`,
1148 "local_includes": `["."]`,
1149 }),
1150 },
1151 })
1152}
1153
1154func TestCcLibrarySharedWithMiscUndefinedProperty(t *testing.T) {
1155 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
1156 Description: "cc_library_shared has correct features when misc_undefined property is provided",
1157 Blueprint: `
1158cc_library_shared {
1159 name: "foo",
1160 sanitize: {
1161 misc_undefined: ["undefined", "nullability"],
1162 },
1163}
1164`,
1165 ExpectedBazelTargets: []string{
1166 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
1167 "features": `[
1168 "ubsan_undefined",
1169 "ubsan_nullability",
1170 ]`,
1171 "local_includes": `["."]`,
1172 }),
1173 },
1174 })
1175}
1176
1177func TestCcLibrarySharedWithUBSanPropertiesArchSpecific(t *testing.T) {
1178 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
1179 Description: "cc_library_shared has correct feature select when UBSan props are specified in arch specific blocks",
1180 Blueprint: `
1181cc_library_shared {
1182 name: "foo",
1183 sanitize: {
1184 misc_undefined: ["undefined", "nullability"],
1185 },
1186 target: {
1187 android: {
1188 sanitize: {
1189 misc_undefined: ["alignment"],
1190 },
1191 },
1192 linux_glibc: {
1193 sanitize: {
1194 integer_overflow: true,
1195 },
1196 },
1197 },
1198}
1199`,
1200 ExpectedBazelTargets: []string{
1201 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
1202 "features": `[
1203 "ubsan_undefined",
1204 "ubsan_nullability",
1205 ] + select({
1206 "//build/bazel/platforms/os:android": ["ubsan_alignment"],
1207 "//build/bazel/platforms/os:linux_glibc": ["ubsan_integer_overflow"],
1208 "//conditions:default": [],
1209 })`,
1210 "local_includes": `["."]`,
1211 }),
1212 },
1213 })
1214}
Trevor Radcliffe56b1a2b2023-02-06 21:58:30 +00001215
Trevor Radcliffeded095c2023-06-12 19:18:28 +00001216func TestCcLibrarySharedWithSanitizerBlocklist(t *testing.T) {
1217 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
1218 Description: "cc_library_shared has correct features when sanitize.blocklist is provided",
1219 Blueprint: `
1220cc_library_shared {
1221 name: "foo",
1222 sanitize: {
1223 blocklist: "foo_blocklist.txt",
1224 },
1225}
1226`,
1227 ExpectedBazelTargets: []string{
1228 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
Trevor Radcliffed9b7f172023-08-09 22:21:38 +00001229 "copts": `select({
1230 "//build/bazel/rules/cc:sanitizers_enabled": ["-fsanitize-ignorelist=$(location foo_blocklist.txt)"],
1231 "//conditions:default": [],
1232 })`,
1233 "additional_compiler_inputs": `select({
1234 "//build/bazel/rules/cc:sanitizers_enabled": [":foo_blocklist.txt"],
1235 "//conditions:default": [],
1236 })`,
Trevor Radcliffeded095c2023-06-12 19:18:28 +00001237 "local_includes": `["."]`,
1238 }),
1239 },
1240 })
1241}
1242
Trevor Radcliffe56b1a2b2023-02-06 21:58:30 +00001243func TestCcLibrarySharedWithThinLto(t *testing.T) {
1244 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
1245 Description: "cc_library_shared has correct features when thin lto is enabled",
1246 Blueprint: `
1247cc_library_shared {
1248 name: "foo",
1249 lto: {
1250 thin: true,
1251 },
1252}
1253`,
1254 ExpectedBazelTargets: []string{
1255 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
1256 "features": `["android_thin_lto"]`,
1257 "local_includes": `["."]`,
1258 }),
1259 },
1260 })
1261}
1262
1263func TestCcLibrarySharedWithLtoNever(t *testing.T) {
1264 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
1265 Description: "cc_library_shared has correct features when thin lto is enabled",
1266 Blueprint: `
1267cc_library_shared {
1268 name: "foo",
1269 lto: {
1270 never: true,
1271 },
1272}
1273`,
1274 ExpectedBazelTargets: []string{
1275 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
1276 "features": `["-android_thin_lto"]`,
1277 "local_includes": `["."]`,
1278 }),
1279 },
1280 })
1281}
1282
1283func TestCcLibrarySharedWithThinLtoArchSpecific(t *testing.T) {
1284 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
1285 Description: "cc_library_shared has correct features when LTO differs across arch and os variants",
1286 Blueprint: `
1287cc_library_shared {
1288 name: "foo",
1289 target: {
1290 android: {
1291 lto: {
1292 thin: true,
1293 },
1294 },
1295 },
1296 arch: {
1297 riscv64: {
1298 lto: {
1299 thin: false,
1300 },
1301 },
1302 },
1303}`,
1304 ExpectedBazelTargets: []string{
1305 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
1306 "local_includes": `["."]`,
1307 "features": `select({
1308 "//build/bazel/platforms/os_arch:android_arm": ["android_thin_lto"],
1309 "//build/bazel/platforms/os_arch:android_arm64": ["android_thin_lto"],
1310 "//build/bazel/platforms/os_arch:android_riscv64": ["-android_thin_lto"],
1311 "//build/bazel/platforms/os_arch:android_x86": ["android_thin_lto"],
1312 "//build/bazel/platforms/os_arch:android_x86_64": ["android_thin_lto"],
1313 "//conditions:default": [],
1314 })`}),
1315 },
1316 })
1317}
1318
1319func TestCcLibrarySharedWithThinLtoDisabledDefaultEnabledVariant(t *testing.T) {
1320 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
1321 Description: "cc_library_shared with thin lto disabled by default but enabled on a particular variant",
1322 Blueprint: `
1323cc_library_shared {
1324 name: "foo",
1325 lto: {
1326 never: true,
1327 },
1328 target: {
1329 android: {
1330 lto: {
1331 thin: true,
1332 never: false,
1333 },
1334 },
1335 },
1336}`,
1337 ExpectedBazelTargets: []string{
1338 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
1339 "local_includes": `["."]`,
1340 "features": `select({
1341 "//build/bazel/platforms/os:android": ["android_thin_lto"],
1342 "//conditions:default": ["-android_thin_lto"],
1343 })`,
1344 }),
1345 },
1346 })
1347}
1348
1349func TestCcLibrarySharedWithThinLtoAndWholeProgramVtables(t *testing.T) {
1350 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
1351 Description: "cc_library_shared has correct features when thin LTO is enabled with whole_program_vtables",
1352 Blueprint: `
1353cc_library_shared {
1354 name: "foo",
1355 lto: {
1356 thin: true,
1357 },
1358 whole_program_vtables: true,
1359}
1360`,
1361 ExpectedBazelTargets: []string{
1362 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
1363 "features": `[
1364 "android_thin_lto",
1365 "android_thin_lto_whole_program_vtables",
1366 ]`,
1367 "local_includes": `["."]`,
1368 }),
1369 },
1370 })
1371}
Trevor Radcliffea8b44162023-04-14 18:25:24 +00001372
1373func TestCcLibrarySharedHiddenVisibilityConvertedToFeature(t *testing.T) {
1374 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
1375 Description: "cc_library_shared changes hidden visibility flag to feature",
1376 Blueprint: `
1377cc_library_shared{
1378 name: "foo",
1379 cflags: ["-fvisibility=hidden"],
1380}`,
1381 ExpectedBazelTargets: []string{
1382 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
1383 "features": `["visibility_hidden"]`,
1384 "local_includes": `["."]`,
1385 }),
1386 },
1387 })
1388}
1389
1390func TestCcLibrarySharedHiddenVisibilityConvertedToFeatureOsSpecific(t *testing.T) {
1391 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
1392 Description: "cc_library_shared changes hidden visibility flag to feature for specific os",
1393 Blueprint: `
1394cc_library_shared{
1395 name: "foo",
1396 target: {
1397 android: {
1398 cflags: ["-fvisibility=hidden"],
1399 },
1400 },
1401}`,
1402 ExpectedBazelTargets: []string{
1403 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
1404 "features": `select({
1405 "//build/bazel/platforms/os:android": ["visibility_hidden"],
1406 "//conditions:default": [],
1407 })`,
1408 "local_includes": `["."]`,
1409 }),
1410 },
1411 })
1412}
Sam Delmerico75dbca22023-04-20 13:13:25 +00001413
1414func TestCcLibrarySharedStubsDessertVersionConversion(t *testing.T) {
1415 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
1416 Description: "cc_library_shared converts dessert codename versions to numerical versions",
1417 Blueprint: `
1418cc_library_shared {
1419 name: "a",
1420 include_build_directory: false,
1421 stubs: {
1422 symbol_file: "a.map.txt",
1423 versions: [
1424 "Q",
1425 "R",
1426 "31",
1427 ],
1428 },
1429}
1430cc_library_shared {
1431 name: "b",
1432 include_build_directory: false,
1433 stubs: {
1434 symbol_file: "b.map.txt",
1435 versions: [
1436 "Q",
1437 "R",
1438 "31",
1439 "current",
1440 ],
1441 },
1442}
1443`,
1444 ExpectedBazelTargets: []string{
1445 makeCcStubSuiteTargets("a", AttrNameToString{
Spandan Das04f9f4c2023-09-13 23:59:05 +00001446 "api_surface": `"module-libapi"`,
Sam Delmerico75dbca22023-04-20 13:13:25 +00001447 "soname": `"a.so"`,
1448 "source_library_label": `"//:a"`,
1449 "stubs_symbol_file": `"a.map.txt"`,
1450 "stubs_versions": `[
1451 "29",
1452 "30",
1453 "31",
1454 "current",
1455 ]`,
1456 }),
1457 MakeBazelTarget("cc_library_shared", "a", AttrNameToString{
1458 "stubs_symbol_file": `"a.map.txt"`,
1459 }),
1460 makeCcStubSuiteTargets("b", AttrNameToString{
Spandan Das04f9f4c2023-09-13 23:59:05 +00001461 "api_surface": `"module-libapi"`,
Sam Delmerico75dbca22023-04-20 13:13:25 +00001462 "soname": `"b.so"`,
1463 "source_library_label": `"//:b"`,
1464 "stubs_symbol_file": `"b.map.txt"`,
1465 "stubs_versions": `[
1466 "29",
1467 "30",
1468 "31",
1469 "current",
1470 ]`,
1471 }),
1472 MakeBazelTarget("cc_library_shared", "b", AttrNameToString{
1473 "stubs_symbol_file": `"b.map.txt"`,
1474 }),
1475 },
1476 })
1477}
Trevor Radcliffe27669c02023-03-28 20:47:10 +00001478
1479func TestCcLibrarySharedWithCfi(t *testing.T) {
1480 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
1481 Description: "cc_library_shared has correct features when cfi is enabled for specific variants",
1482 Blueprint: `
1483cc_library_shared {
1484 name: "foo",
1485 sanitize: {
1486 cfi: true,
1487 },
1488}`,
1489 ExpectedBazelTargets: []string{
1490 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
1491 "features": `["android_cfi"]`,
1492 "local_includes": `["."]`,
1493 }),
1494 },
1495 })
1496}
1497
1498func TestCcLibrarySharedWithCfiOsSpecific(t *testing.T) {
1499 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
1500 Description: "cc_library_shared has correct features when cfi is enabled",
1501 Blueprint: `
1502cc_library_shared {
1503 name: "foo",
1504 target: {
1505 android: {
1506 sanitize: {
1507 cfi: true,
1508 },
1509 },
1510 },
1511}`,
1512 ExpectedBazelTargets: []string{
1513 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
1514 "features": `select({
1515 "//build/bazel/platforms/os:android": ["android_cfi"],
1516 "//conditions:default": [],
1517 })`,
1518 "local_includes": `["."]`,
1519 }),
1520 },
1521 })
1522}
1523
1524func TestCcLibrarySharedWithCfiAndCfiAssemblySupport(t *testing.T) {
1525 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
1526 Description: "cc_library_shared has correct features when cfi is enabled with cfi assembly support",
1527 Blueprint: `
1528cc_library_static {
1529 name: "foo",
1530 sanitize: {
1531 cfi: true,
1532 config: {
1533 cfi_assembly_support: true,
1534 },
1535 },
1536}`,
1537 ExpectedBazelTargets: []string{
1538 MakeBazelTarget("cc_library_static", "foo", AttrNameToString{
1539 "features": `[
1540 "android_cfi",
1541 "android_cfi_assembly_support",
1542 ]`,
1543 "local_includes": `["."]`,
1544 }),
1545 },
1546 })
1547}
Trevor Radcliffe523c5c62023-06-16 20:15:45 +00001548
1549func TestCcLibrarySharedExplicitlyDisablesCfiWhenFalse(t *testing.T) {
1550 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
1551 Description: "cc_library_shared disables cfi when explciitly set to false in the bp",
1552 Blueprint: `
1553cc_library_shared {
1554 name: "foo",
1555 sanitize: {
1556 cfi: false,
1557 },
1558}
1559`,
1560 ExpectedBazelTargets: []string{
1561 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
1562 "features": `["-android_cfi"]`,
1563 "local_includes": `["."]`,
1564 }),
1565 },
1566 })
1567}
Alixe2667872023-04-24 14:57:32 +00001568
1569func TestCCLibrarySharedRscriptSrc(t *testing.T) {
1570 runCcLibrarySharedTestCase(t, Bp2buildTestCase{
1571 Description: ``,
1572 Blueprint: `
1573cc_library_shared{
1574 name : "foo",
1575 srcs : [
1576 "ccSrc.cc",
1577 "rsSrc.rscript",
1578 ],
1579 include_build_directory: false,
1580}
1581`,
1582 ExpectedBazelTargets: []string{
1583 MakeBazelTarget("rscript_to_cpp", "foo_renderscript", AttrNameToString{
1584 "srcs": `["rsSrc.rscript"]`,
1585 }),
1586 MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
1587 "absolute_includes": `[
1588 "frameworks/rs",
1589 "frameworks/rs/cpp",
1590 ]`,
1591 "local_includes": `["."]`,
1592 "srcs": `[
1593 "ccSrc.cc",
1594 "foo_renderscript",
1595 ]`,
1596 })}})
1597}