blob: 24468506f35334fc130aa8f72d33089006ec7b6a [file] [log] [blame]
Liz Kammer2b8004b2021-10-04 13:55:44 -04001// 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 "android/soong/android"
19 "android/soong/cc"
Liz Kammere6583482021-10-19 13:56:10 -040020 "android/soong/genrule"
Liz Kammer2b8004b2021-10-04 13:55:44 -040021 "fmt"
22 "strings"
23 "testing"
24)
25
26const (
Liz Kammer12615db2021-09-28 09:19:17 -040027 ccBinaryTypePlaceHolder = "{rule_name}"
Liz Kammer2b8004b2021-10-04 13:55:44 -040028)
29
Liz Kammer78cfdaa2021-11-08 12:56:31 -050030type testBazelTarget struct {
31 typ string
32 name string
33 attrs attrNameToString
34}
35
36func generateBazelTargetsForTest(targets []testBazelTarget) []string {
37 ret := make([]string, 0, len(targets))
38 for _, t := range targets {
39 ret = append(ret, makeBazelTarget(t.typ, t.name, t.attrs))
40 }
41 return ret
42}
43
44type ccBinaryBp2buildTestCase struct {
45 description string
46 blueprint string
47 targets []testBazelTarget
48}
49
Liz Kammer2b8004b2021-10-04 13:55:44 -040050func registerCcBinaryModuleTypes(ctx android.RegistrationContext) {
51 cc.RegisterCCBuildComponents(ctx)
52 ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
53 ctx.RegisterModuleType("cc_library_static", cc.LibraryStaticFactory)
54 ctx.RegisterModuleType("cc_library", cc.LibraryFactory)
Liz Kammere6583482021-10-19 13:56:10 -040055 ctx.RegisterModuleType("genrule", genrule.GenRuleFactory)
Liz Kammer2b8004b2021-10-04 13:55:44 -040056}
57
Liz Kammer78cfdaa2021-11-08 12:56:31 -050058var binaryReplacer = strings.NewReplacer(ccBinaryTypePlaceHolder, "cc_binary")
59var hostBinaryReplacer = strings.NewReplacer(ccBinaryTypePlaceHolder, "cc_binary_host")
Liz Kammer2b8004b2021-10-04 13:55:44 -040060
Liz Kammer78cfdaa2021-11-08 12:56:31 -050061func runCcBinaryTests(t *testing.T, tc ccBinaryBp2buildTestCase) {
Liz Kammer2b8004b2021-10-04 13:55:44 -040062 t.Helper()
63 runCcBinaryTestCase(t, tc)
64 runCcHostBinaryTestCase(t, tc)
65}
66
Liz Kammer78cfdaa2021-11-08 12:56:31 -050067func runCcBinaryTestCase(t *testing.T, tc ccBinaryBp2buildTestCase) {
Liz Kammer2b8004b2021-10-04 13:55:44 -040068 t.Helper()
Liz Kammer78cfdaa2021-11-08 12:56:31 -050069 moduleTypeUnderTest := "cc_binary"
70 testCase := bp2buildTestCase{
71 expectedBazelTargets: generateBazelTargetsForTest(tc.targets),
72 moduleTypeUnderTest: moduleTypeUnderTest,
73 moduleTypeUnderTestFactory: cc.BinaryFactory,
74 moduleTypeUnderTestBp2BuildMutator: cc.BinaryBp2build,
75 description: fmt.Sprintf("%s %s", moduleTypeUnderTest, tc.description),
76 blueprint: binaryReplacer.Replace(tc.blueprint),
Liz Kammer2b8004b2021-10-04 13:55:44 -040077 }
78 t.Run(testCase.description, func(t *testing.T) {
79 runBp2BuildTestCase(t, registerCcBinaryModuleTypes, testCase)
80 })
81}
82
Liz Kammer78cfdaa2021-11-08 12:56:31 -050083func runCcHostBinaryTestCase(t *testing.T, tc ccBinaryBp2buildTestCase) {
Liz Kammer2b8004b2021-10-04 13:55:44 -040084 t.Helper()
85 testCase := tc
Liz Kammer12615db2021-09-28 09:19:17 -040086 for i, tar := range testCase.targets {
87 if tar.typ != "cc_binary" {
88 continue
89 }
90 tar.attrs["target_compatible_with"] = `select({
Liz Kammer78cfdaa2021-11-08 12:56:31 -050091 "//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
92 "//conditions:default": [],
93 })`
Liz Kammer12615db2021-09-28 09:19:17 -040094 testCase.targets[i] = tar
Liz Kammer2b8004b2021-10-04 13:55:44 -040095 }
Liz Kammer78cfdaa2021-11-08 12:56:31 -050096 moduleTypeUnderTest := "cc_binary_host"
Liz Kammer2b8004b2021-10-04 13:55:44 -040097 t.Run(testCase.description, func(t *testing.T) {
Liz Kammer78cfdaa2021-11-08 12:56:31 -050098 runBp2BuildTestCase(t, registerCcBinaryModuleTypes, bp2buildTestCase{
99 expectedBazelTargets: generateBazelTargetsForTest(testCase.targets),
100 moduleTypeUnderTest: moduleTypeUnderTest,
101 moduleTypeUnderTestFactory: cc.BinaryHostFactory,
102 moduleTypeUnderTestBp2BuildMutator: cc.BinaryHostBp2build,
103 description: fmt.Sprintf("%s %s", moduleTypeUnderTest, tc.description),
104 blueprint: hostBinaryReplacer.Replace(testCase.blueprint),
105 })
Liz Kammer2b8004b2021-10-04 13:55:44 -0400106 })
107}
108
109func TestBasicCcBinary(t *testing.T) {
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500110 runCcBinaryTests(t, ccBinaryBp2buildTestCase{
Liz Kammer2b8004b2021-10-04 13:55:44 -0400111 description: "basic -- properties -> attrs with little/no transformation",
112 blueprint: `
113{rule_name} {
114 name: "foo",
115 srcs: ["a.cc"],
116 local_include_dirs: ["dir"],
117 include_dirs: ["absolute_dir"],
118 cflags: ["-Dcopt"],
119 cppflags: ["-Dcppflag"],
120 conlyflags: ["-Dconlyflag"],
121 asflags: ["-Dasflag"],
122 ldflags: ["ld-flag"],
123 rtti: true,
124 strip: {
125 all: true,
126 keep_symbols: true,
127 keep_symbols_and_debug_frame: true,
128 keep_symbols_list: ["symbol"],
129 none: true,
130 },
131}
132`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500133 targets: []testBazelTarget{
134 {"cc_binary", "foo", attrNameToString{
135 "absolute_includes": `["absolute_dir"]`,
136 "asflags": `["-Dasflag"]`,
137 "conlyflags": `["-Dconlyflag"]`,
138 "copts": `["-Dcopt"]`,
139 "cppflags": `["-Dcppflag"]`,
140 "linkopts": `["ld-flag"]`,
141 "local_includes": `[
Liz Kammer2b8004b2021-10-04 13:55:44 -0400142 "dir",
143 ".",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500144 ]`,
145 "rtti": `True`,
146 "srcs": `["a.cc"]`,
147 "strip": `{
Liz Kammer2b8004b2021-10-04 13:55:44 -0400148 "all": True,
149 "keep_symbols": True,
150 "keep_symbols_and_debug_frame": True,
151 "keep_symbols_list": ["symbol"],
152 "none": True,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500153 }`,
154 },
155 },
156 },
Liz Kammer2b8004b2021-10-04 13:55:44 -0400157 })
158}
159
160func TestCcBinaryWithSharedLdflagDisableFeature(t *testing.T) {
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500161 runCcBinaryTests(t, ccBinaryBp2buildTestCase{
Liz Kammer2b8004b2021-10-04 13:55:44 -0400162 description: `ldflag "-shared" disables static_flag feature`,
163 blueprint: `
164{rule_name} {
165 name: "foo",
166 ldflags: ["-shared"],
167 include_build_directory: false,
168}
169`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500170 targets: []testBazelTarget{
171 {"cc_binary", "foo", attrNameToString{
172 "features": `["-static_flag"]`,
173 "linkopts": `["-shared"]`,
174 },
175 },
176 },
Liz Kammer2b8004b2021-10-04 13:55:44 -0400177 })
178}
179
180func TestCcBinaryWithLinkStatic(t *testing.T) {
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500181 runCcBinaryTests(t, ccBinaryBp2buildTestCase{
Liz Kammer2b8004b2021-10-04 13:55:44 -0400182 description: "link static",
183 blueprint: `
184{rule_name} {
185 name: "foo",
186 static_executable: true,
187 include_build_directory: false,
188}
189`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500190 targets: []testBazelTarget{
191 {"cc_binary", "foo", attrNameToString{
192 "linkshared": `False`,
193 },
194 },
195 },
Liz Kammer2b8004b2021-10-04 13:55:44 -0400196 })
197}
198
199func TestCcBinaryVersionScript(t *testing.T) {
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500200 runCcBinaryTests(t, ccBinaryBp2buildTestCase{
Liz Kammer2b8004b2021-10-04 13:55:44 -0400201 description: `version script`,
202 blueprint: `
203{rule_name} {
204 name: "foo",
205 include_build_directory: false,
206 version_script: "vs",
207}
208`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500209 targets: []testBazelTarget{
210 {"cc_binary", "foo", attrNameToString{
211 "additional_linker_inputs": `["vs"]`,
212 "linkopts": `["-Wl,--version-script,$(location vs)"]`,
213 },
214 },
215 },
Liz Kammer2b8004b2021-10-04 13:55:44 -0400216 })
217}
218
219func TestCcBinarySplitSrcsByLang(t *testing.T) {
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500220 runCcHostBinaryTestCase(t, ccBinaryBp2buildTestCase{
Liz Kammer2b8004b2021-10-04 13:55:44 -0400221 description: "split srcs by lang",
222 blueprint: `
223{rule_name} {
224 name: "foo",
225 srcs: [
226 "asonly.S",
227 "conly.c",
228 "cpponly.cpp",
229 ":fg_foo",
230 ],
231 include_build_directory: false,
232}
233` + simpleModuleDoNotConvertBp2build("filegroup", "fg_foo"),
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500234 targets: []testBazelTarget{
235 {"cc_binary", "foo", attrNameToString{
236 "srcs": `[
Liz Kammer2b8004b2021-10-04 13:55:44 -0400237 "cpponly.cpp",
238 ":fg_foo_cpp_srcs",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500239 ]`,
240 "srcs_as": `[
Liz Kammer2b8004b2021-10-04 13:55:44 -0400241 "asonly.S",
242 ":fg_foo_as_srcs",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500243 ]`,
244 "srcs_c": `[
Liz Kammer2b8004b2021-10-04 13:55:44 -0400245 "conly.c",
246 ":fg_foo_c_srcs",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500247 ]`,
248 },
249 },
250 },
Liz Kammer2b8004b2021-10-04 13:55:44 -0400251 })
252}
253
254func TestCcBinaryDoNotDistinguishBetweenDepsAndImplementationDeps(t *testing.T) {
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500255 runCcBinaryTestCase(t, ccBinaryBp2buildTestCase{
Liz Kammer2b8004b2021-10-04 13:55:44 -0400256 description: "no implementation deps",
257 blueprint: `
Liz Kammere6583482021-10-19 13:56:10 -0400258genrule {
259 name: "generated_hdr",
260 cmd: "nothing to see here",
261}
262
263genrule {
264 name: "export_generated_hdr",
265 cmd: "nothing to see here",
266}
267
Liz Kammer2b8004b2021-10-04 13:55:44 -0400268{rule_name} {
269 name: "foo",
Liz Kammere6583482021-10-19 13:56:10 -0400270 srcs: ["foo.cpp"],
Liz Kammer2b8004b2021-10-04 13:55:44 -0400271 shared_libs: ["implementation_shared_dep", "shared_dep"],
272 export_shared_lib_headers: ["shared_dep"],
273 static_libs: ["implementation_static_dep", "static_dep"],
274 export_static_lib_headers: ["static_dep", "whole_static_dep"],
275 whole_static_libs: ["not_explicitly_exported_whole_static_dep", "whole_static_dep"],
276 include_build_directory: false,
Liz Kammere6583482021-10-19 13:56:10 -0400277 generated_headers: ["generated_hdr", "export_generated_hdr"],
278 export_generated_headers: ["export_generated_hdr"],
Liz Kammer2b8004b2021-10-04 13:55:44 -0400279}
280` +
281 simpleModuleDoNotConvertBp2build("cc_library_static", "static_dep") +
282 simpleModuleDoNotConvertBp2build("cc_library_static", "implementation_static_dep") +
283 simpleModuleDoNotConvertBp2build("cc_library_static", "whole_static_dep") +
284 simpleModuleDoNotConvertBp2build("cc_library_static", "not_explicitly_exported_whole_static_dep") +
285 simpleModuleDoNotConvertBp2build("cc_library", "shared_dep") +
286 simpleModuleDoNotConvertBp2build("cc_library", "implementation_shared_dep"),
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500287 targets: []testBazelTarget{
288 {"cc_binary", "foo", attrNameToString{
289 "deps": `[
Liz Kammer2b8004b2021-10-04 13:55:44 -0400290 ":implementation_static_dep",
291 ":static_dep",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500292 ]`,
293 "dynamic_deps": `[
Liz Kammer2b8004b2021-10-04 13:55:44 -0400294 ":implementation_shared_dep",
295 ":shared_dep",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500296 ]`,
297 "srcs": `[
Liz Kammere6583482021-10-19 13:56:10 -0400298 "foo.cpp",
299 ":generated_hdr",
300 ":export_generated_hdr",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500301 ]`,
302 "whole_archive_deps": `[
Liz Kammer2b8004b2021-10-04 13:55:44 -0400303 ":not_explicitly_exported_whole_static_dep",
304 ":whole_static_dep",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500305 ]`,
306 },
307 },
308 },
Liz Kammer2b8004b2021-10-04 13:55:44 -0400309 })
310}
311
312func TestCcBinaryNocrtTests(t *testing.T) {
313 baseTestCases := []struct {
314 description string
315 soongProperty string
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500316 bazelAttr attrNameToString
Liz Kammer2b8004b2021-10-04 13:55:44 -0400317 }{
318 {
319 description: "nocrt: true",
320 soongProperty: `nocrt: true,`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500321 bazelAttr: attrNameToString{"link_crt": `False`},
Liz Kammer2b8004b2021-10-04 13:55:44 -0400322 },
323 {
324 description: "nocrt: false",
325 soongProperty: `nocrt: false,`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500326 bazelAttr: attrNameToString{},
Liz Kammer2b8004b2021-10-04 13:55:44 -0400327 },
328 {
329 description: "nocrt: not set",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500330 bazelAttr: attrNameToString{},
Liz Kammer2b8004b2021-10-04 13:55:44 -0400331 },
332 }
333
334 baseBlueprint := `{rule_name} {
335 name: "foo",%s
336 include_build_directory: false,
337}
338`
339
Liz Kammer2b8004b2021-10-04 13:55:44 -0400340 for _, btc := range baseTestCases {
341 prop := btc.soongProperty
342 if len(prop) > 0 {
343 prop = "\n" + prop
344 }
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500345 runCcBinaryTests(t, ccBinaryBp2buildTestCase{
Liz Kammer2b8004b2021-10-04 13:55:44 -0400346 description: btc.description,
347 blueprint: fmt.Sprintf(baseBlueprint, prop),
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500348 targets: []testBazelTarget{
349 {"cc_binary", "foo", btc.bazelAttr},
Liz Kammer2b8004b2021-10-04 13:55:44 -0400350 },
351 })
352 }
353}
354
355func TestCcBinaryNo_libcrtTests(t *testing.T) {
356 baseTestCases := []struct {
357 description string
358 soongProperty string
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500359 bazelAttr attrNameToString
Liz Kammer2b8004b2021-10-04 13:55:44 -0400360 }{
361 {
362 description: "no_libcrt: true",
363 soongProperty: `no_libcrt: true,`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500364 bazelAttr: attrNameToString{"use_libcrt": `False`},
Liz Kammer2b8004b2021-10-04 13:55:44 -0400365 },
366 {
367 description: "no_libcrt: false",
368 soongProperty: `no_libcrt: false,`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500369 bazelAttr: attrNameToString{"use_libcrt": `True`},
Liz Kammer2b8004b2021-10-04 13:55:44 -0400370 },
371 {
372 description: "no_libcrt: not set",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500373 bazelAttr: attrNameToString{},
Liz Kammer2b8004b2021-10-04 13:55:44 -0400374 },
375 }
376
377 baseBlueprint := `{rule_name} {
378 name: "foo",%s
379 include_build_directory: false,
380}
381`
382
Liz Kammer2b8004b2021-10-04 13:55:44 -0400383 for _, btc := range baseTestCases {
384 prop := btc.soongProperty
385 if len(prop) > 0 {
386 prop = "\n" + prop
387 }
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500388 runCcBinaryTests(t, ccBinaryBp2buildTestCase{
Liz Kammer2b8004b2021-10-04 13:55:44 -0400389 description: btc.description,
390 blueprint: fmt.Sprintf(baseBlueprint, prop),
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500391 targets: []testBazelTarget{
392 {"cc_binary", "foo", btc.bazelAttr},
Liz Kammer2b8004b2021-10-04 13:55:44 -0400393 },
394 })
395 }
396}
397
398func TestCcBinaryPropertiesToFeatures(t *testing.T) {
399 baseTestCases := []struct {
400 description string
401 soongProperty string
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500402 bazelAttr attrNameToString
Liz Kammer2b8004b2021-10-04 13:55:44 -0400403 }{
404 {
405 description: "pack_relocation: true",
406 soongProperty: `pack_relocations: true,`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500407 bazelAttr: attrNameToString{},
Liz Kammer2b8004b2021-10-04 13:55:44 -0400408 },
409 {
410 description: "pack_relocations: false",
411 soongProperty: `pack_relocations: false,`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500412 bazelAttr: attrNameToString{"features": `["disable_pack_relocations"]`},
Liz Kammer2b8004b2021-10-04 13:55:44 -0400413 },
414 {
415 description: "pack_relocations: not set",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500416 bazelAttr: attrNameToString{},
Liz Kammer2b8004b2021-10-04 13:55:44 -0400417 },
418 {
419 description: "pack_relocation: true",
420 soongProperty: `allow_undefined_symbols: true,`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500421 bazelAttr: attrNameToString{"features": `["-no_undefined_symbols"]`},
Liz Kammer2b8004b2021-10-04 13:55:44 -0400422 },
423 {
424 description: "allow_undefined_symbols: false",
425 soongProperty: `allow_undefined_symbols: false,`,
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500426 bazelAttr: attrNameToString{},
Liz Kammer2b8004b2021-10-04 13:55:44 -0400427 },
428 {
429 description: "allow_undefined_symbols: not set",
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500430 bazelAttr: attrNameToString{},
Liz Kammer2b8004b2021-10-04 13:55:44 -0400431 },
432 }
433
434 baseBlueprint := `{rule_name} {
435 name: "foo",%s
436 include_build_directory: false,
437}
438`
Liz Kammer2b8004b2021-10-04 13:55:44 -0400439 for _, btc := range baseTestCases {
440 prop := btc.soongProperty
441 if len(prop) > 0 {
442 prop = "\n" + prop
443 }
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500444 runCcBinaryTests(t, ccBinaryBp2buildTestCase{
Liz Kammer2b8004b2021-10-04 13:55:44 -0400445 description: btc.description,
446 blueprint: fmt.Sprintf(baseBlueprint, prop),
Liz Kammer78cfdaa2021-11-08 12:56:31 -0500447 targets: []testBazelTarget{
448 {"cc_binary", "foo", btc.bazelAttr},
Liz Kammer2b8004b2021-10-04 13:55:44 -0400449 },
450 })
451 }
452}
Liz Kammer12615db2021-09-28 09:19:17 -0400453
454func TestCcBinarySharedProto(t *testing.T) {
455 runCcBinaryTests(t, ccBinaryBp2buildTestCase{
456 blueprint: soongCcProtoLibraries + `{rule_name} {
457 name: "foo",
458 srcs: ["foo.proto"],
459 proto: {
460 canonical_path_from_root: false,
461 },
462 include_build_directory: false,
463}`,
464 targets: []testBazelTarget{
465 {"proto_library", "foo_proto", attrNameToString{
466 "srcs": `["foo.proto"]`,
467 }}, {"cc_lite_proto_library", "foo_cc_proto_lite", attrNameToString{
468 "deps": `[":foo_proto"]`,
469 }}, {"cc_binary", "foo", attrNameToString{
470 "dynamic_deps": `[":libprotobuf-cpp-lite"]`,
471 "whole_archive_deps": `[":foo_cc_proto_lite"]`,
472 }},
473 },
474 })
475}
476
477func TestCcBinaryStaticProto(t *testing.T) {
478 runCcBinaryTests(t, ccBinaryBp2buildTestCase{
479 blueprint: soongCcProtoLibraries + `{rule_name} {
480 name: "foo",
481 srcs: ["foo.proto"],
482 static_executable: true,
483 proto: {
484 canonical_path_from_root: false,
485 },
486 include_build_directory: false,
487}`,
488 targets: []testBazelTarget{
489 {"proto_library", "foo_proto", attrNameToString{
490 "srcs": `["foo.proto"]`,
491 }}, {"cc_lite_proto_library", "foo_cc_proto_lite", attrNameToString{
492 "deps": `[":foo_proto"]`,
493 }}, {"cc_binary", "foo", attrNameToString{
494 "deps": `[":libprotobuf-cpp-lite"]`,
495 "whole_archive_deps": `[":foo_cc_proto_lite"]`,
496 "linkshared": `False`,
497 }},
498 },
499 })
500}