blob: bf3351ad85c3f51c2f3fa4e33a2774f3377eeec6 [file] [log] [blame]
Rupert Shuttleworth54e78412021-02-15 11:04:32 +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 (
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +020018 "testing"
19
Rupert Shuttleworth54e78412021-02-15 11:04:32 +000020 "android/soong/android"
21 "android/soong/cc"
Rupert Shuttleworth54e78412021-02-15 11:04:32 +000022)
23
24const (
25 // See cc/testing.go for more context
Jingwen Chen63930982021-03-24 10:04:33 -040026 soongCcLibraryHeadersPreamble = `
Rupert Shuttleworth54e78412021-02-15 11:04:32 +000027cc_defaults {
Liz Kammer8337ea42021-09-10 10:06:32 -040028 name: "linux_bionic_supported",
Rupert Shuttleworth54e78412021-02-15 11:04:32 +000029}`
30)
31
32func TestCcLibraryHeadersLoadStatement(t *testing.T) {
33 testCases := []struct {
34 bazelTargets BazelTargets
35 expectedLoadStatements string
36 }{
37 {
38 bazelTargets: BazelTargets{
39 BazelTarget{
40 name: "cc_library_headers_target",
41 ruleClass: "cc_library_headers",
42 // Note: no bzlLoadLocation for native rules
43 },
44 },
45 expectedLoadStatements: ``,
46 },
47 }
48
49 for _, testCase := range testCases {
50 actual := testCase.bazelTargets.LoadStatements()
51 expected := testCase.expectedLoadStatements
52 if actual != expected {
53 t.Fatalf("Expected load statements to be %s, got %s", expected, actual)
54 }
55 }
Rupert Shuttleworth54e78412021-02-15 11:04:32 +000056}
57
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +020058func registerCcLibraryHeadersModuleTypes(ctx android.RegistrationContext) {
59 cc.RegisterCCBuildComponents(ctx)
Liz Kammer86a407f2023-09-18 09:23:38 -040060 cc.RegisterLibraryHeadersBuildComponents(ctx)
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +020061}
62
Sam Delmerico3177a6e2022-06-21 19:28:33 +000063func runCcLibraryHeadersTestCase(t *testing.T, tc Bp2buildTestCase) {
Liz Kammere4982e82021-05-25 10:39:35 -040064 t.Helper()
Sam Delmerico3177a6e2022-06-21 19:28:33 +000065 RunBp2BuildTestCase(t, registerCcLibraryHeadersModuleTypes, tc)
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +020066}
67
68func TestCcLibraryHeadersSimple(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +000069 runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Liz Kammer86a407f2023-09-18 09:23:38 -040070 Description: "cc_library_headers test",
Sam Delmerico3177a6e2022-06-21 19:28:33 +000071 Filesystem: map[string]string{
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +020072 "lib-1/lib1a.h": "",
73 "lib-1/lib1b.h": "",
74 "lib-2/lib2a.h": "",
75 "lib-2/lib2b.h": "",
76 "dir-1/dir1a.h": "",
77 "dir-1/dir1b.h": "",
78 "dir-2/dir2a.h": "",
79 "dir-2/dir2b.h": "",
80 "arch_arm64_exported_include_dir/a.h": "",
81 "arch_x86_exported_include_dir/b.h": "",
82 "arch_x86_64_exported_include_dir/c.h": "",
83 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +000084 Blueprint: soongCcLibraryHeadersPreamble + `
Rupert Shuttleworth54e78412021-02-15 11:04:32 +000085cc_library_headers {
Rupert Shuttleworth54e78412021-02-15 11:04:32 +000086 name: "foo_headers",
87 export_include_dirs: ["dir-1", "dir-2"],
88 header_libs: ["lib-1", "lib-2"],
Rupert Shuttleworth095081c2021-03-25 09:06:03 +000089
Rupert Shuttleworthb8151682021-04-06 20:06:21 +000090 arch: {
91 arm64: {
Liz Kammer8337ea42021-09-10 10:06:32 -040092 // We expect dir-1 headers to be dropped, because dir-1 is already in export_include_dirs
Rupert Shuttleworthb8151682021-04-06 20:06:21 +000093 export_include_dirs: ["arch_arm64_exported_include_dir", "dir-1"],
94 },
95 x86: {
96 export_include_dirs: ["arch_x86_exported_include_dir"],
97 },
98 x86_64: {
99 export_include_dirs: ["arch_x86_64_exported_include_dir"],
100 },
101 },
Yu Liufc603162022-03-01 15:44:08 -0800102 sdk_version: "current",
103 min_sdk_version: "29",
Rupert Shuttleworthb8151682021-04-06 20:06:21 +0000104
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000105 // TODO: Also support export_header_lib_headers
Rupert Shuttleworth54e78412021-02-15 11:04:32 +0000106}`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000107 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000108 MakeBazelTarget("cc_library_headers", "foo_headers", AttrNameToString{
Zi Wang1cb11802022-12-09 16:08:54 -0800109 "export_includes": `select({
Jingwen Chenb4628eb2021-04-08 14:40:57 +0000110 "//build/bazel/platforms/arch:arm64": ["arch_arm64_exported_include_dir"],
111 "//build/bazel/platforms/arch:x86": ["arch_x86_exported_include_dir"],
112 "//build/bazel/platforms/arch:x86_64": ["arch_x86_64_exported_include_dir"],
Rupert Shuttleworthb8151682021-04-06 20:06:21 +0000113 "//conditions:default": [],
Zi Wang1cb11802022-12-09 16:08:54 -0800114 }) + [
115 "dir-1",
116 "dir-2",
117 ]`,
Trevor Radcliffefb6c5222022-06-17 19:42:28 +0000118 "sdk_version": `"current"`,
119 "min_sdk_version": `"29"`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500120 }),
121 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200122 })
123}
124
Zi Wang9f609db2023-01-04 11:06:54 -0800125// header_libs has "variant_prepend" tag. In bp2build output,
126// variant info(select) should go before general info.
Liz Kammer8337ea42021-09-10 10:06:32 -0400127func TestCcLibraryHeadersOsSpecificHeader(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000128 runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Liz Kammer86a407f2023-09-18 09:23:38 -0400129 Description: "cc_library_headers test with os-specific header_libs props",
130 Filesystem: map[string]string{},
Chris Parsonscd209032023-09-19 01:12:48 +0000131 StubbedBuildDefinitions: []string{"android-lib", "base-lib", "darwin-lib",
132 "linux-lib", "linux_bionic-lib", "windows-lib"},
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000133 Blueprint: soongCcLibraryPreamble + `
Liz Kammer8337ea42021-09-10 10:06:32 -0400134cc_library_headers {
135 name: "android-lib",
Liz Kammer8337ea42021-09-10 10:06:32 -0400136}
137cc_library_headers {
138 name: "base-lib",
Liz Kammer8337ea42021-09-10 10:06:32 -0400139}
140cc_library_headers {
141 name: "darwin-lib",
Liz Kammer8337ea42021-09-10 10:06:32 -0400142}
143cc_library_headers {
144 name: "linux-lib",
Liz Kammer8337ea42021-09-10 10:06:32 -0400145}
146cc_library_headers {
147 name: "linux_bionic-lib",
Liz Kammer8337ea42021-09-10 10:06:32 -0400148}
149cc_library_headers {
150 name: "windows-lib",
Liz Kammer8337ea42021-09-10 10:06:32 -0400151}
Jingwen Chen91220d72021-03-24 02:18:33 -0400152cc_library_headers {
153 name: "foo_headers",
154 header_libs: ["base-lib"],
Trevor Radcliffefb6c5222022-06-17 19:42:28 +0000155 export_header_lib_headers: ["base-lib"],
Jingwen Chen91220d72021-03-24 02:18:33 -0400156 target: {
Trevor Radcliffefb6c5222022-06-17 19:42:28 +0000157 android: {
158 header_libs: ["android-lib"],
159 export_header_lib_headers: ["android-lib"],
160 },
161 darwin: {
162 header_libs: ["darwin-lib"],
163 export_header_lib_headers: ["darwin-lib"],
164 },
165 linux_bionic: {
166 header_libs: ["linux_bionic-lib"],
167 export_header_lib_headers: ["linux_bionic-lib"],
168 },
169 linux_glibc: {
170 header_libs: ["linux-lib"],
171 export_header_lib_headers: ["linux-lib"],
172 },
173 windows: {
174 header_libs: ["windows-lib"],
175 export_header_lib_headers: ["windows-lib"],
176 },
Jingwen Chen91220d72021-03-24 02:18:33 -0400177 },
Liz Kammer8337ea42021-09-10 10:06:32 -0400178 include_build_directory: false,
Jingwen Chen91220d72021-03-24 02:18:33 -0400179}`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000180 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000181 MakeBazelTarget("cc_library_headers", "foo_headers", AttrNameToString{
Zi Wang9f609db2023-01-04 11:06:54 -0800182 "deps": `select({
Jingwen Chenb4628eb2021-04-08 14:40:57 +0000183 "//build/bazel/platforms/os:android": [":android-lib"],
184 "//build/bazel/platforms/os:darwin": [":darwin-lib"],
Jingwen Chenb4628eb2021-04-08 14:40:57 +0000185 "//build/bazel/platforms/os:linux_bionic": [":linux_bionic-lib"],
Colin Cross133782e2022-12-20 15:29:31 -0800186 "//build/bazel/platforms/os:linux_glibc": [":linux-lib"],
Jingwen Chenb4628eb2021-04-08 14:40:57 +0000187 "//build/bazel/platforms/os:windows": [":windows-lib"],
Jingwen Chen91220d72021-03-24 02:18:33 -0400188 "//conditions:default": [],
Zi Wang9f609db2023-01-04 11:06:54 -0800189 }) + [":base-lib"]`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500190 }),
191 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200192 })
193}
194
195func TestCcLibraryHeadersOsSpecficHeaderLibsExportHeaderLibHeaders(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000196 runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Liz Kammer86a407f2023-09-18 09:23:38 -0400197 Description: "cc_library_headers test with os-specific header_libs and export_header_lib_headers props",
198 Filesystem: map[string]string{},
199 StubbedBuildDefinitions: []string{"android-lib", "exported-lib"},
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000200 Blueprint: soongCcLibraryPreamble + `
Liz Kammer8337ea42021-09-10 10:06:32 -0400201cc_library_headers {
202 name: "android-lib",
Liz Kammer8337ea42021-09-10 10:06:32 -0400203 }
204cc_library_headers {
205 name: "exported-lib",
Liz Kammer8337ea42021-09-10 10:06:32 -0400206}
Jingwen Chen91220d72021-03-24 02:18:33 -0400207cc_library_headers {
208 name: "foo_headers",
209 target: {
Liz Kammer7a210ac2021-09-22 15:52:58 -0400210 android: {
211 header_libs: ["android-lib", "exported-lib"],
212 export_header_lib_headers: ["exported-lib"]
213 },
Jingwen Chen91220d72021-03-24 02:18:33 -0400214 },
Liz Kammer8337ea42021-09-10 10:06:32 -0400215 include_build_directory: false,
Jingwen Chen91220d72021-03-24 02:18:33 -0400216}`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000217 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000218 MakeBazelTarget("cc_library_headers", "foo_headers", AttrNameToString{
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500219 "deps": `select({
Chris Parsonsd6358772021-05-18 18:35:24 -0400220 "//build/bazel/platforms/os:android": [":exported-lib"],
221 "//conditions:default": [],
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500222 })`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500223 }),
224 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200225 })
226}
227
228func TestCcLibraryHeadersArchAndTargetExportSystemIncludes(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000229 runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Liz Kammer86a407f2023-09-18 09:23:38 -0400230 Description: "cc_library_headers test with arch-specific and target-specific export_system_include_dirs props",
231 Filesystem: map[string]string{},
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000232 Blueprint: soongCcLibraryPreamble + `cc_library_headers {
Rupert Shuttleworth375451e2021-04-26 07:49:08 -0400233 name: "foo_headers",
234 export_system_include_dirs: [
Liz Kammer8337ea42021-09-10 10:06:32 -0400235 "shared_include_dir",
Rupert Shuttleworth375451e2021-04-26 07:49:08 -0400236 ],
237 target: {
Liz Kammer8337ea42021-09-10 10:06:32 -0400238 android: {
239 export_system_include_dirs: [
240 "android_include_dir",
Rupert Shuttleworth375451e2021-04-26 07:49:08 -0400241 ],
Liz Kammer8337ea42021-09-10 10:06:32 -0400242 },
Rupert Shuttleworth375451e2021-04-26 07:49:08 -0400243 linux_glibc: {
244 export_system_include_dirs: [
245 "linux_include_dir",
246 ],
247 },
248 darwin: {
249 export_system_include_dirs: [
250 "darwin_include_dir",
251 ],
252 },
253 },
254 arch: {
255 arm: {
Liz Kammer8337ea42021-09-10 10:06:32 -0400256 export_system_include_dirs: [
257 "arm_include_dir",
Rupert Shuttleworth375451e2021-04-26 07:49:08 -0400258 ],
Liz Kammer8337ea42021-09-10 10:06:32 -0400259 },
Rupert Shuttleworth375451e2021-04-26 07:49:08 -0400260 x86_64: {
261 export_system_include_dirs: [
262 "x86_64_include_dir",
263 ],
264 },
265 },
Liz Kammer8337ea42021-09-10 10:06:32 -0400266 include_build_directory: false,
Rupert Shuttleworth375451e2021-04-26 07:49:08 -0400267}`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000268 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000269 MakeBazelTarget("cc_library_headers", "foo_headers", AttrNameToString{
Zi Wang1cb11802022-12-09 16:08:54 -0800270 "export_system_includes": `select({
Rupert Shuttleworth375451e2021-04-26 07:49:08 -0400271 "//build/bazel/platforms/os:android": ["android_include_dir"],
272 "//build/bazel/platforms/os:darwin": ["darwin_include_dir"],
Colin Cross133782e2022-12-20 15:29:31 -0800273 "//build/bazel/platforms/os:linux_glibc": ["linux_include_dir"],
Rupert Shuttleworth375451e2021-04-26 07:49:08 -0400274 "//conditions:default": [],
Zi Wang1cb11802022-12-09 16:08:54 -0800275 }) + select({
276 "//build/bazel/platforms/arch:arm": ["arm_include_dir"],
277 "//build/bazel/platforms/arch:x86_64": ["x86_64_include_dir"],
278 "//conditions:default": [],
279 }) + ["shared_include_dir"]`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500280 }),
281 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200282 })
Rupert Shuttleworth54e78412021-02-15 11:04:32 +0000283}
Liz Kammerd366c902021-06-03 13:43:01 -0400284
285func TestCcLibraryHeadersNoCrtIgnored(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000286 runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Liz Kammer86a407f2023-09-18 09:23:38 -0400287 Description: "cc_library_headers test",
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000288 Filesystem: map[string]string{
Liz Kammerd366c902021-06-03 13:43:01 -0400289 "lib-1/lib1a.h": "",
290 "lib-1/lib1b.h": "",
291 "lib-2/lib2a.h": "",
292 "lib-2/lib2b.h": "",
293 "dir-1/dir1a.h": "",
294 "dir-1/dir1b.h": "",
295 "dir-2/dir2a.h": "",
296 "dir-2/dir2b.h": "",
297 "arch_arm64_exported_include_dir/a.h": "",
298 "arch_x86_exported_include_dir/b.h": "",
299 "arch_x86_64_exported_include_dir/c.h": "",
300 },
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000301 Blueprint: soongCcLibraryHeadersPreamble + `
Liz Kammerd366c902021-06-03 13:43:01 -0400302cc_library_headers {
303 name: "lib-1",
304 export_include_dirs: ["lib-1"],
305 no_libcrt: true,
Liz Kammer8337ea42021-09-10 10:06:32 -0400306 include_build_directory: false,
Liz Kammerd366c902021-06-03 13:43:01 -0400307}`,
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000308 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000309 MakeBazelTarget("cc_library_headers", "lib-1", AttrNameToString{
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500310 "export_includes": `["lib-1"]`,
311 }),
312 },
Liz Kammerd366c902021-06-03 13:43:01 -0400313 })
314}
Trevor Radcliffe2be7f542022-06-22 20:30:55 +0000315
316func TestCcLibraryHeadersExportedStaticLibHeadersReexported(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000317 runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Liz Kammer86a407f2023-09-18 09:23:38 -0400318 Description: "cc_library_headers exported_static_lib_headers is reexported",
319 Filesystem: map[string]string{},
320 StubbedBuildDefinitions: []string{"foo_export"},
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000321 Blueprint: soongCcLibraryHeadersPreamble + `
Trevor Radcliffe2be7f542022-06-22 20:30:55 +0000322cc_library_headers {
323 name: "foo_headers",
324 export_static_lib_headers: ["foo_export"],
325 static_libs: ["foo_export", "foo_no_reexport"],
326 bazel_module: { bp2build_available: true },
327}
Chris Parsonscd209032023-09-19 01:12:48 +0000328` + simpleModule("cc_library_headers", "foo_export"),
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000329 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000330 MakeBazelTarget("cc_library_headers", "foo_headers", AttrNameToString{
Trevor Radcliffe2be7f542022-06-22 20:30:55 +0000331 "deps": `[":foo_export"]`,
332 }),
333 },
334 })
335}
336
337func TestCcLibraryHeadersExportedSharedLibHeadersReexported(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000338 runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Liz Kammer86a407f2023-09-18 09:23:38 -0400339 Description: "cc_library_headers exported_shared_lib_headers is reexported",
340 Filesystem: map[string]string{},
341 StubbedBuildDefinitions: []string{"foo_export"},
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000342 Blueprint: soongCcLibraryHeadersPreamble + `
Trevor Radcliffe2be7f542022-06-22 20:30:55 +0000343cc_library_headers {
344 name: "foo_headers",
345 export_shared_lib_headers: ["foo_export"],
346 shared_libs: ["foo_export", "foo_no_reexport"],
347 bazel_module: { bp2build_available: true },
348}
Chris Parsonscd209032023-09-19 01:12:48 +0000349` + simpleModule("cc_library_headers", "foo_export"),
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000350 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000351 MakeBazelTarget("cc_library_headers", "foo_headers", AttrNameToString{
Trevor Radcliffe2be7f542022-06-22 20:30:55 +0000352 "deps": `[":foo_export"]`,
353 }),
354 },
355 })
356}
357
358func TestCcLibraryHeadersExportedHeaderLibHeadersReexported(t *testing.T) {
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000359 runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Liz Kammer86a407f2023-09-18 09:23:38 -0400360 Description: "cc_library_headers exported_header_lib_headers is reexported",
361 Filesystem: map[string]string{},
362 StubbedBuildDefinitions: []string{"foo_export"},
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000363 Blueprint: soongCcLibraryHeadersPreamble + `
Trevor Radcliffe2be7f542022-06-22 20:30:55 +0000364cc_library_headers {
365 name: "foo_headers",
366 export_header_lib_headers: ["foo_export"],
367 header_libs: ["foo_export", "foo_no_reexport"],
368 bazel_module: { bp2build_available: true },
369}
Chris Parsonscd209032023-09-19 01:12:48 +0000370` + simpleModule("cc_library_headers", "foo_export"),
Sam Delmerico3177a6e2022-06-21 19:28:33 +0000371 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000372 MakeBazelTarget("cc_library_headers", "foo_headers", AttrNameToString{
Trevor Radcliffe2be7f542022-06-22 20:30:55 +0000373 "deps": `[":foo_export"]`,
374 }),
375 },
376 })
377}
Trevor Radcliffe7f897fc2022-08-18 15:53:00 +0000378
379func TestCcLibraryHeadersWholeStaticLibsReexported(t *testing.T) {
380 runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
Liz Kammer86a407f2023-09-18 09:23:38 -0400381 Description: "cc_library_headers whole_static_libs is reexported",
382 Filesystem: map[string]string{},
383 StubbedBuildDefinitions: []string{"foo_export"},
Trevor Radcliffe7f897fc2022-08-18 15:53:00 +0000384 Blueprint: soongCcLibraryHeadersPreamble + `
385cc_library_headers {
386 name: "foo_headers",
387 whole_static_libs: ["foo_export"],
388 bazel_module: { bp2build_available: true },
389}
Chris Parsonscd209032023-09-19 01:12:48 +0000390` + simpleModule("cc_library_headers", "foo_export"),
Trevor Radcliffe7f897fc2022-08-18 15:53:00 +0000391 ExpectedBazelTargets: []string{
Alixe06d75b2022-08-31 18:28:19 +0000392 MakeBazelTarget("cc_library_headers", "foo_headers", AttrNameToString{
Trevor Radcliffe7f897fc2022-08-18 15:53:00 +0000393 "deps": `[":foo_export"]`,
394 }),
395 },
396 })
397}
Liz Kammer86a407f2023-09-18 09:23:38 -0400398
399func TestPrebuiltCcLibraryHeadersWholeStaticLibsReexported(t *testing.T) {
400 runCcLibraryHeadersTestCase(t, Bp2buildTestCase{
401 Description: "cc_library_headers whole_static_libs is reexported",
402 Filesystem: map[string]string{
403 "foo/bar/Android.bp": simpleModule("cc_library_headers", "foo_headers"),
404 },
405 StubbedBuildDefinitions: []string{"foo_export"},
406 Blueprint: soongCcLibraryHeadersPreamble + `
407cc_prebuilt_library_headers {
408 name: "foo_headers",
409 whole_static_libs: ["foo_export"],
410 bazel_module: { bp2build_available: true },
411}
412` + simpleModule("cc_library_headers", "foo_export"),
413 ExpectedBazelTargets: []string{
414 MakeBazelTarget("cc_library_headers", "foo_headers", AttrNameToString{
415 "deps": `[":foo_export"]`,
416 }),
417 },
418 })
419}