blob: 770925466ea32641cca6afe78ea88f40e45a1f73 [file] [log] [blame]
Rupert Shuttleworth095081c2021-03-25 09:06:03 +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 "android/soong/android"
19 "android/soong/cc"
Chris Parsons484e50a2021-05-13 15:13:04 -040020 "android/soong/genrule"
21
Rupert Shuttleworth095081c2021-03-25 09:06:03 +000022 "testing"
23)
24
25const (
26 // See cc/testing.go for more context
27 soongCcLibraryStaticPreamble = `
28cc_defaults {
29 name: "linux_bionic_supported",
30}
31
32toolchain_library {
33 name: "libclang_rt.builtins-x86_64-android",
34 defaults: ["linux_bionic_supported"],
35 vendor_available: true,
36 vendor_ramdisk_available: true,
37 product_available: true,
38 recovery_available: true,
39 native_bridge_supported: true,
40 src: "",
Rupert Shuttleworth095081c2021-03-25 09:06:03 +000041}`
42)
43
44func TestCcLibraryStaticLoadStatement(t *testing.T) {
45 testCases := []struct {
46 bazelTargets BazelTargets
47 expectedLoadStatements string
48 }{
49 {
50 bazelTargets: BazelTargets{
51 BazelTarget{
52 name: "cc_library_static_target",
53 ruleClass: "cc_library_static",
54 // NOTE: No bzlLoadLocation for native rules
55 },
56 },
57 expectedLoadStatements: ``,
58 },
59 }
60
61 for _, testCase := range testCases {
62 actual := testCase.bazelTargets.LoadStatements()
63 expected := testCase.expectedLoadStatements
64 if actual != expected {
65 t.Fatalf("Expected load statements to be %s, got %s", expected, actual)
66 }
67 }
68
69}
70
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +020071func registerCcLibraryStaticModuleTypes(ctx android.RegistrationContext) {
72 cc.RegisterCCBuildComponents(ctx)
73 ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory)
74 ctx.RegisterModuleType("cc_library_headers", cc.LibraryHeaderFactory)
75 ctx.RegisterModuleType("genrule", genrule.GenRuleFactory)
76}
77
78func runCcLibraryStaticTestCase(t *testing.T, tc bp2buildTestCase) {
Liz Kammere4982e82021-05-25 10:39:35 -040079 t.Helper()
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +020080 runBp2BuildTestCase(t, registerCcLibraryStaticModuleTypes, tc)
81}
82
83func TestCcLibraryStaticSimple(t *testing.T) {
84 runCcLibraryStaticTestCase(t, bp2buildTestCase{
85 description: "cc_library_static test",
86 moduleTypeUnderTest: "cc_library_static",
87 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
88 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
89 filesystem: map[string]string{
90 // NOTE: include_dir headers *should not* appear in Bazel hdrs later (?)
91 "include_dir_1/include_dir_1_a.h": "",
92 "include_dir_1/include_dir_1_b.h": "",
93 "include_dir_2/include_dir_2_a.h": "",
94 "include_dir_2/include_dir_2_b.h": "",
95 // NOTE: local_include_dir headers *should not* appear in Bazel hdrs later (?)
96 "local_include_dir_1/local_include_dir_1_a.h": "",
97 "local_include_dir_1/local_include_dir_1_b.h": "",
98 "local_include_dir_2/local_include_dir_2_a.h": "",
99 "local_include_dir_2/local_include_dir_2_b.h": "",
100 // NOTE: export_include_dir headers *should* appear in Bazel hdrs later
101 "export_include_dir_1/export_include_dir_1_a.h": "",
102 "export_include_dir_1/export_include_dir_1_b.h": "",
103 "export_include_dir_2/export_include_dir_2_a.h": "",
104 "export_include_dir_2/export_include_dir_2_b.h": "",
105 // NOTE: Soong implicitly includes headers in the current directory
106 "implicit_include_1.h": "",
107 "implicit_include_2.h": "",
108 },
109 blueprint: soongCcLibraryStaticPreamble + `
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000110cc_library_headers {
111 name: "header_lib_1",
112 export_include_dirs: ["header_lib_1"],
113}
114
115cc_library_headers {
116 name: "header_lib_2",
117 export_include_dirs: ["header_lib_2"],
118}
119
120cc_library_static {
121 name: "static_lib_1",
122 srcs: ["static_lib_1.cc"],
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000123}
124
125cc_library_static {
126 name: "static_lib_2",
127 srcs: ["static_lib_2.cc"],
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000128}
129
130cc_library_static {
131 name: "whole_static_lib_1",
132 srcs: ["whole_static_lib_1.cc"],
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000133}
134
135cc_library_static {
136 name: "whole_static_lib_2",
137 srcs: ["whole_static_lib_2.cc"],
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000138}
139
140cc_library_static {
141 name: "foo_static",
142 srcs: [
143 "foo_static1.cc",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000144 "foo_static2.cc",
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000145 ],
146 cflags: [
147 "-Dflag1",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000148 "-Dflag2"
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000149 ],
150 static_libs: [
151 "static_lib_1",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000152 "static_lib_2"
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000153 ],
154 whole_static_libs: [
155 "whole_static_lib_1",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000156 "whole_static_lib_2"
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000157 ],
158 include_dirs: [
Jingwen Chened9c17d2021-04-13 07:14:55 +0000159 "include_dir_1",
160 "include_dir_2",
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000161 ],
162 local_include_dirs: [
163 "local_include_dir_1",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000164 "local_include_dir_2",
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000165 ],
166 export_include_dirs: [
Chris Parsonsd6358772021-05-18 18:35:24 -0400167 "export_include_dir_1",
168 "export_include_dir_2"
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000169 ],
170 header_libs: [
171 "header_lib_1",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000172 "header_lib_2"
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000173 ],
174
175 // TODO: Also support export_header_lib_headers
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000176}`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200177 expectedBazelTargets: []string{`cc_library_static(
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000178 name = "foo_static",
179 copts = [
180 "-Dflag1",
181 "-Dflag2",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000182 "-Iinclude_dir_1",
Chris Parsons484e50a2021-05-13 15:13:04 -0400183 "-I$(BINDIR)/include_dir_1",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000184 "-Iinclude_dir_2",
Chris Parsons484e50a2021-05-13 15:13:04 -0400185 "-I$(BINDIR)/include_dir_2",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000186 "-Ilocal_include_dir_1",
Chris Parsons484e50a2021-05-13 15:13:04 -0400187 "-I$(BINDIR)/local_include_dir_1",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000188 "-Ilocal_include_dir_2",
Chris Parsons484e50a2021-05-13 15:13:04 -0400189 "-I$(BINDIR)/local_include_dir_2",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000190 "-I.",
Chris Parsons484e50a2021-05-13 15:13:04 -0400191 "-I$(BINDIR)/.",
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000192 ],
Chris Parsonsd6358772021-05-18 18:35:24 -0400193 implementation_deps = [
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000194 ":header_lib_1",
195 ":header_lib_2",
196 ":static_lib_1",
197 ":static_lib_2",
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000198 ],
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000199 includes = [
200 "export_include_dir_1",
201 "export_include_dir_2",
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000202 ],
203 linkstatic = True,
204 srcs = [
205 "foo_static1.cc",
206 "foo_static2.cc",
207 ],
Chris Parsons08648312021-05-06 16:23:19 -0400208 whole_archive_deps = [
209 ":whole_static_lib_1",
210 ":whole_static_lib_2",
211 ],
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000212)`, `cc_library_static(
213 name = "static_lib_1",
Chris Parsons484e50a2021-05-13 15:13:04 -0400214 copts = [
215 "-I.",
216 "-I$(BINDIR)/.",
217 ],
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000218 linkstatic = True,
Jingwen Chen882bcc12021-04-27 05:54:20 +0000219 srcs = ["static_lib_1.cc"],
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000220)`, `cc_library_static(
221 name = "static_lib_2",
Chris Parsons484e50a2021-05-13 15:13:04 -0400222 copts = [
223 "-I.",
224 "-I$(BINDIR)/.",
225 ],
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000226 linkstatic = True,
Jingwen Chen882bcc12021-04-27 05:54:20 +0000227 srcs = ["static_lib_2.cc"],
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000228)`, `cc_library_static(
229 name = "whole_static_lib_1",
Chris Parsons484e50a2021-05-13 15:13:04 -0400230 copts = [
231 "-I.",
232 "-I$(BINDIR)/.",
233 ],
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000234 linkstatic = True,
Jingwen Chen882bcc12021-04-27 05:54:20 +0000235 srcs = ["whole_static_lib_1.cc"],
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000236)`, `cc_library_static(
237 name = "whole_static_lib_2",
Chris Parsons484e50a2021-05-13 15:13:04 -0400238 copts = [
239 "-I.",
240 "-I$(BINDIR)/.",
241 ],
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000242 linkstatic = True,
Jingwen Chen882bcc12021-04-27 05:54:20 +0000243 srcs = ["whole_static_lib_2.cc"],
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000244)`},
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200245 })
246}
247
248func TestCcLibraryStaticSubpackage(t *testing.T) {
249 runCcLibraryStaticTestCase(t, bp2buildTestCase{
250 description: "cc_library_static subpackage test",
251 moduleTypeUnderTest: "cc_library_static",
252 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
253 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
254 filesystem: map[string]string{
255 // subpackage with subdirectory
256 "subpackage/Android.bp": "",
257 "subpackage/subpackage_header.h": "",
258 "subpackage/subdirectory/subdirectory_header.h": "",
259 // subsubpackage with subdirectory
260 "subpackage/subsubpackage/Android.bp": "",
261 "subpackage/subsubpackage/subsubpackage_header.h": "",
262 "subpackage/subsubpackage/subdirectory/subdirectory_header.h": "",
263 // subsubsubpackage with subdirectory
264 "subpackage/subsubpackage/subsubsubpackage/Android.bp": "",
265 "subpackage/subsubpackage/subsubsubpackage/subsubsubpackage_header.h": "",
266 "subpackage/subsubpackage/subsubsubpackage/subdirectory/subdirectory_header.h": "",
Rupert Shuttleworth095081c2021-03-25 09:06:03 +0000267 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200268 blueprint: soongCcLibraryStaticPreamble + `
Rupert Shuttleworthc143cc52021-04-13 13:08:04 -0400269cc_library_static {
270 name: "foo_static",
271 srcs: [
272 ],
273 include_dirs: [
274 "subpackage",
275 ],
Rupert Shuttleworthc143cc52021-04-13 13:08:04 -0400276}`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200277 expectedBazelTargets: []string{`cc_library_static(
Rupert Shuttleworthc143cc52021-04-13 13:08:04 -0400278 name = "foo_static",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000279 copts = [
280 "-Isubpackage",
Chris Parsons484e50a2021-05-13 15:13:04 -0400281 "-I$(BINDIR)/subpackage",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000282 "-I.",
Chris Parsons484e50a2021-05-13 15:13:04 -0400283 "-I$(BINDIR)/.",
Rupert Shuttleworthc143cc52021-04-13 13:08:04 -0400284 ],
285 linkstatic = True,
Rupert Shuttleworthc143cc52021-04-13 13:08:04 -0400286)`},
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200287 })
288}
289
290func TestCcLibraryStaticExportIncludeDir(t *testing.T) {
291 runCcLibraryStaticTestCase(t, bp2buildTestCase{
292 description: "cc_library_static export include dir",
293 moduleTypeUnderTest: "cc_library_static",
294 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
295 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
296 filesystem: map[string]string{
297 // subpackage with subdirectory
298 "subpackage/Android.bp": "",
299 "subpackage/subpackage_header.h": "",
300 "subpackage/subdirectory/subdirectory_header.h": "",
Rupert Shuttleworthc143cc52021-04-13 13:08:04 -0400301 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200302 blueprint: soongCcLibraryStaticPreamble + `
Jingwen Chened9c17d2021-04-13 07:14:55 +0000303cc_library_static {
304 name: "foo_static",
305 export_include_dirs: ["subpackage"],
306}`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200307 expectedBazelTargets: []string{`cc_library_static(
Jingwen Chened9c17d2021-04-13 07:14:55 +0000308 name = "foo_static",
Chris Parsons484e50a2021-05-13 15:13:04 -0400309 copts = [
310 "-I.",
311 "-I$(BINDIR)/.",
312 ],
Jingwen Chened9c17d2021-04-13 07:14:55 +0000313 includes = ["subpackage"],
314 linkstatic = True,
Jingwen Chened9c17d2021-04-13 07:14:55 +0000315)`},
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200316 })
317}
318
319func TestCcLibraryStaticExportSystemIncludeDir(t *testing.T) {
320 runCcLibraryStaticTestCase(t, bp2buildTestCase{
321 description: "cc_library_static export system include dir",
322 moduleTypeUnderTest: "cc_library_static",
323 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
324 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
325 filesystem: map[string]string{
326 // subpackage with subdirectory
327 "subpackage/Android.bp": "",
328 "subpackage/subpackage_header.h": "",
329 "subpackage/subdirectory/subdirectory_header.h": "",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000330 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200331 blueprint: soongCcLibraryStaticPreamble + `
Jingwen Chened9c17d2021-04-13 07:14:55 +0000332cc_library_static {
333 name: "foo_static",
334 export_system_include_dirs: ["subpackage"],
335}`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200336 expectedBazelTargets: []string{`cc_library_static(
Jingwen Chened9c17d2021-04-13 07:14:55 +0000337 name = "foo_static",
Chris Parsons484e50a2021-05-13 15:13:04 -0400338 copts = [
339 "-I.",
340 "-I$(BINDIR)/.",
341 ],
Jingwen Chened9c17d2021-04-13 07:14:55 +0000342 includes = ["subpackage"],
343 linkstatic = True,
Jingwen Chened9c17d2021-04-13 07:14:55 +0000344)`},
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200345 })
346}
347
348func TestCcLibraryStaticManyIncludeDirs(t *testing.T) {
349 runCcLibraryStaticTestCase(t, bp2buildTestCase{
350 description: "cc_library_static include_dirs, local_include_dirs, export_include_dirs (b/183742505)",
351 moduleTypeUnderTest: "cc_library_static",
352 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
353 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
354 dir: "subpackage",
355 filesystem: map[string]string{
356 // subpackage with subdirectory
357 "subpackage/Android.bp": `
Jingwen Chened9c17d2021-04-13 07:14:55 +0000358cc_library_static {
359 name: "foo_static",
360 // include_dirs are workspace/root relative
361 include_dirs: [
362 "subpackage/subsubpackage",
363 "subpackage2",
364 "subpackage3/subsubpackage"
365 ],
366 local_include_dirs: ["subsubpackage2"], // module dir relative
367 export_include_dirs: ["./exported_subsubpackage"], // module dir relative
368 include_build_directory: true,
369 bazel_module: { bp2build_available: true },
370}`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200371 "subpackage/subsubpackage/header.h": "",
372 "subpackage/subsubpackage2/header.h": "",
373 "subpackage/exported_subsubpackage/header.h": "",
374 "subpackage2/header.h": "",
375 "subpackage3/subsubpackage/header.h": "",
376 },
377 blueprint: soongCcLibraryStaticPreamble,
378 expectedBazelTargets: []string{`cc_library_static(
Jingwen Chened9c17d2021-04-13 07:14:55 +0000379 name = "foo_static",
380 copts = [
381 "-Isubpackage/subsubpackage",
Chris Parsons484e50a2021-05-13 15:13:04 -0400382 "-I$(BINDIR)/subpackage/subsubpackage",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000383 "-Isubpackage2",
Chris Parsons484e50a2021-05-13 15:13:04 -0400384 "-I$(BINDIR)/subpackage2",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000385 "-Isubpackage3/subsubpackage",
Chris Parsons484e50a2021-05-13 15:13:04 -0400386 "-I$(BINDIR)/subpackage3/subsubpackage",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000387 "-Isubpackage/subsubpackage2",
Chris Parsons484e50a2021-05-13 15:13:04 -0400388 "-I$(BINDIR)/subpackage/subsubpackage2",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000389 "-Isubpackage",
Chris Parsons484e50a2021-05-13 15:13:04 -0400390 "-I$(BINDIR)/subpackage",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000391 ],
Jingwen Chened9c17d2021-04-13 07:14:55 +0000392 includes = ["./exported_subsubpackage"],
393 linkstatic = True,
Jingwen Chened9c17d2021-04-13 07:14:55 +0000394)`},
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200395 })
396}
397
398func TestCcLibraryStaticIncludeBuildDirectoryDisabled(t *testing.T) {
399 runCcLibraryStaticTestCase(t, bp2buildTestCase{
400 description: "cc_library_static include_build_directory disabled",
401 moduleTypeUnderTest: "cc_library_static",
402 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
403 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
404 filesystem: map[string]string{
405 // subpackage with subdirectory
406 "subpackage/Android.bp": "",
407 "subpackage/subpackage_header.h": "",
408 "subpackage/subdirectory/subdirectory_header.h": "",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000409 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200410 blueprint: soongCcLibraryStaticPreamble + `
Jingwen Chened9c17d2021-04-13 07:14:55 +0000411cc_library_static {
412 name: "foo_static",
413 include_dirs: ["subpackage"], // still used, but local_include_dirs is recommended
414 local_include_dirs: ["subpackage2"],
415 include_build_directory: false,
416}`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200417 expectedBazelTargets: []string{`cc_library_static(
Jingwen Chened9c17d2021-04-13 07:14:55 +0000418 name = "foo_static",
419 copts = [
420 "-Isubpackage",
Chris Parsons484e50a2021-05-13 15:13:04 -0400421 "-I$(BINDIR)/subpackage",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000422 "-Isubpackage2",
Chris Parsons484e50a2021-05-13 15:13:04 -0400423 "-I$(BINDIR)/subpackage2",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000424 ],
425 linkstatic = True,
426)`},
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200427 })
428}
429
430func TestCcLibraryStaticIncludeBuildDirectoryEnabled(t *testing.T) {
431 runCcLibraryStaticTestCase(t, bp2buildTestCase{
432 description: "cc_library_static include_build_directory enabled",
433 moduleTypeUnderTest: "cc_library_static",
434 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
435 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
436 filesystem: map[string]string{
437 // subpackage with subdirectory
438 "subpackage/Android.bp": "",
439 "subpackage/subpackage_header.h": "",
440 "subpackage2/Android.bp": "",
441 "subpackage2/subpackage2_header.h": "",
442 "subpackage/subdirectory/subdirectory_header.h": "",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000443 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200444 blueprint: soongCcLibraryStaticPreamble + `
Jingwen Chened9c17d2021-04-13 07:14:55 +0000445cc_library_static {
446 name: "foo_static",
447 include_dirs: ["subpackage"], // still used, but local_include_dirs is recommended
448 local_include_dirs: ["subpackage2"],
449 include_build_directory: true,
450}`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200451 expectedBazelTargets: []string{`cc_library_static(
Jingwen Chened9c17d2021-04-13 07:14:55 +0000452 name = "foo_static",
453 copts = [
454 "-Isubpackage",
Chris Parsons484e50a2021-05-13 15:13:04 -0400455 "-I$(BINDIR)/subpackage",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000456 "-Isubpackage2",
Chris Parsons484e50a2021-05-13 15:13:04 -0400457 "-I$(BINDIR)/subpackage2",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000458 "-I.",
Chris Parsons484e50a2021-05-13 15:13:04 -0400459 "-I$(BINDIR)/.",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000460 ],
461 linkstatic = True,
Jingwen Chened9c17d2021-04-13 07:14:55 +0000462)`},
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200463 })
464}
465
466func TestCcLibraryStaticArchSpecificStaticLib(t *testing.T) {
467 runCcLibraryStaticTestCase(t, bp2buildTestCase{
468 description: "cc_library_static arch-specific static_libs",
469 moduleTypeUnderTest: "cc_library_static",
470 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
471 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
472 depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build},
473 filesystem: map[string]string{},
474 blueprint: soongCcLibraryStaticPreamble + `
Jingwen Chened9c17d2021-04-13 07:14:55 +0000475cc_library_static { name: "static_dep" }
476cc_library_static { name: "static_dep2" }
477cc_library_static {
478 name: "foo_static",
479 arch: { arm64: { static_libs: ["static_dep"], whole_static_libs: ["static_dep2"] } },
480}`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200481 expectedBazelTargets: []string{`cc_library_static(
Jingwen Chened9c17d2021-04-13 07:14:55 +0000482 name = "foo_static",
Chris Parsons484e50a2021-05-13 15:13:04 -0400483 copts = [
484 "-I.",
485 "-I$(BINDIR)/.",
486 ],
Chris Parsonsd6358772021-05-18 18:35:24 -0400487 implementation_deps = select({
Chris Parsons08648312021-05-06 16:23:19 -0400488 "//build/bazel/platforms/arch:arm64": [":static_dep"],
Jingwen Chened9c17d2021-04-13 07:14:55 +0000489 "//conditions:default": [],
490 }),
491 linkstatic = True,
Chris Parsons08648312021-05-06 16:23:19 -0400492 whole_archive_deps = select({
493 "//build/bazel/platforms/arch:arm64": [":static_dep2"],
494 "//conditions:default": [],
495 }),
Jingwen Chened9c17d2021-04-13 07:14:55 +0000496)`, `cc_library_static(
497 name = "static_dep",
Chris Parsons484e50a2021-05-13 15:13:04 -0400498 copts = [
499 "-I.",
500 "-I$(BINDIR)/.",
501 ],
Jingwen Chened9c17d2021-04-13 07:14:55 +0000502 linkstatic = True,
503)`, `cc_library_static(
504 name = "static_dep2",
Chris Parsons484e50a2021-05-13 15:13:04 -0400505 copts = [
506 "-I.",
507 "-I$(BINDIR)/.",
508 ],
Jingwen Chened9c17d2021-04-13 07:14:55 +0000509 linkstatic = True,
510)`},
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200511 })
512}
513
514func TestCcLibraryStaticOsSpecificStaticLib(t *testing.T) {
515 runCcLibraryStaticTestCase(t, bp2buildTestCase{
516 description: "cc_library_static os-specific static_libs",
517 moduleTypeUnderTest: "cc_library_static",
518 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
519 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
520 depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build},
521 filesystem: map[string]string{},
522 blueprint: soongCcLibraryStaticPreamble + `
Jingwen Chened9c17d2021-04-13 07:14:55 +0000523cc_library_static { name: "static_dep" }
524cc_library_static { name: "static_dep2" }
525cc_library_static {
526 name: "foo_static",
527 target: { android: { static_libs: ["static_dep"], whole_static_libs: ["static_dep2"] } },
528}`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200529 expectedBazelTargets: []string{`cc_library_static(
Jingwen Chened9c17d2021-04-13 07:14:55 +0000530 name = "foo_static",
Chris Parsons484e50a2021-05-13 15:13:04 -0400531 copts = [
532 "-I.",
533 "-I$(BINDIR)/.",
534 ],
Chris Parsonsd6358772021-05-18 18:35:24 -0400535 implementation_deps = select({
Chris Parsons08648312021-05-06 16:23:19 -0400536 "//build/bazel/platforms/os:android": [":static_dep"],
Jingwen Chened9c17d2021-04-13 07:14:55 +0000537 "//conditions:default": [],
538 }),
539 linkstatic = True,
Chris Parsons08648312021-05-06 16:23:19 -0400540 whole_archive_deps = select({
541 "//build/bazel/platforms/os:android": [":static_dep2"],
542 "//conditions:default": [],
543 }),
Jingwen Chened9c17d2021-04-13 07:14:55 +0000544)`, `cc_library_static(
545 name = "static_dep",
Chris Parsons484e50a2021-05-13 15:13:04 -0400546 copts = [
547 "-I.",
548 "-I$(BINDIR)/.",
549 ],
Jingwen Chened9c17d2021-04-13 07:14:55 +0000550 linkstatic = True,
551)`, `cc_library_static(
552 name = "static_dep2",
Chris Parsons484e50a2021-05-13 15:13:04 -0400553 copts = [
554 "-I.",
555 "-I$(BINDIR)/.",
556 ],
Jingwen Chened9c17d2021-04-13 07:14:55 +0000557 linkstatic = True,
558)`},
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200559 })
560}
561
562func TestCcLibraryStaticBaseArchOsSpecificStaticLib(t *testing.T) {
563 runCcLibraryStaticTestCase(t, bp2buildTestCase{
564 description: "cc_library_static base, arch and os-specific static_libs",
565 moduleTypeUnderTest: "cc_library_static",
566 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
567 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
568 depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build},
569 filesystem: map[string]string{},
570 blueprint: soongCcLibraryStaticPreamble + `
Jingwen Chened9c17d2021-04-13 07:14:55 +0000571cc_library_static { name: "static_dep" }
572cc_library_static { name: "static_dep2" }
573cc_library_static { name: "static_dep3" }
574cc_library_static { name: "static_dep4" }
575cc_library_static {
576 name: "foo_static",
577 static_libs: ["static_dep"],
578 whole_static_libs: ["static_dep2"],
579 target: { android: { static_libs: ["static_dep3"] } },
580 arch: { arm64: { static_libs: ["static_dep4"] } },
581}`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200582 expectedBazelTargets: []string{`cc_library_static(
Jingwen Chened9c17d2021-04-13 07:14:55 +0000583 name = "foo_static",
Chris Parsons484e50a2021-05-13 15:13:04 -0400584 copts = [
585 "-I.",
586 "-I$(BINDIR)/.",
587 ],
Chris Parsonsd6358772021-05-18 18:35:24 -0400588 implementation_deps = [":static_dep"] + select({
Jingwen Chened9c17d2021-04-13 07:14:55 +0000589 "//build/bazel/platforms/arch:arm64": [":static_dep4"],
590 "//conditions:default": [],
591 }) + select({
592 "//build/bazel/platforms/os:android": [":static_dep3"],
593 "//conditions:default": [],
594 }),
595 linkstatic = True,
Chris Parsons08648312021-05-06 16:23:19 -0400596 whole_archive_deps = [":static_dep2"],
Jingwen Chened9c17d2021-04-13 07:14:55 +0000597)`, `cc_library_static(
598 name = "static_dep",
Chris Parsons484e50a2021-05-13 15:13:04 -0400599 copts = [
600 "-I.",
601 "-I$(BINDIR)/.",
602 ],
Jingwen Chened9c17d2021-04-13 07:14:55 +0000603 linkstatic = True,
604)`, `cc_library_static(
605 name = "static_dep2",
Chris Parsons484e50a2021-05-13 15:13:04 -0400606 copts = [
607 "-I.",
608 "-I$(BINDIR)/.",
609 ],
Jingwen Chened9c17d2021-04-13 07:14:55 +0000610 linkstatic = True,
611)`, `cc_library_static(
612 name = "static_dep3",
Chris Parsons484e50a2021-05-13 15:13:04 -0400613 copts = [
614 "-I.",
615 "-I$(BINDIR)/.",
616 ],
Jingwen Chened9c17d2021-04-13 07:14:55 +0000617 linkstatic = True,
618)`, `cc_library_static(
619 name = "static_dep4",
Chris Parsons484e50a2021-05-13 15:13:04 -0400620 copts = [
621 "-I.",
622 "-I$(BINDIR)/.",
623 ],
Jingwen Chened9c17d2021-04-13 07:14:55 +0000624 linkstatic = True,
625)`},
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200626 })
627}
628
629func TestCcLibraryStaticSimpleExcludeSrcs(t *testing.T) {
630 runCcLibraryStaticTestCase(t, bp2buildTestCase{
631 description: "cc_library_static simple exclude_srcs",
632 moduleTypeUnderTest: "cc_library_static",
633 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
634 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
635 depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build},
636 filesystem: map[string]string{
637 "common.c": "",
638 "foo-a.c": "",
639 "foo-excluded.c": "",
Jingwen Chened9c17d2021-04-13 07:14:55 +0000640 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200641 blueprint: soongCcLibraryStaticPreamble + `
Jingwen Chene32e9e02021-04-23 09:17:24 +0000642cc_library_static {
643 name: "foo_static",
644 srcs: ["common.c", "foo-*.c"],
645 exclude_srcs: ["foo-excluded.c"],
646}`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200647 expectedBazelTargets: []string{`cc_library_static(
Jingwen Chene32e9e02021-04-23 09:17:24 +0000648 name = "foo_static",
Chris Parsons484e50a2021-05-13 15:13:04 -0400649 copts = [
650 "-I.",
651 "-I$(BINDIR)/.",
652 ],
Jingwen Chene32e9e02021-04-23 09:17:24 +0000653 linkstatic = True,
Chris Parsons990c4f42021-05-25 12:10:58 -0400654 srcs_c = [
Jingwen Chene32e9e02021-04-23 09:17:24 +0000655 "common.c",
656 "foo-a.c",
657 ],
658)`},
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200659 })
660}
661
662func TestCcLibraryStaticOneArchSrcs(t *testing.T) {
663 runCcLibraryStaticTestCase(t, bp2buildTestCase{
664 description: "cc_library_static one arch specific srcs",
665 moduleTypeUnderTest: "cc_library_static",
666 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
667 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
668 depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build},
669 filesystem: map[string]string{
670 "common.c": "",
671 "foo-arm.c": "",
Jingwen Chene32e9e02021-04-23 09:17:24 +0000672 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200673 blueprint: soongCcLibraryStaticPreamble + `
Jingwen Chene32e9e02021-04-23 09:17:24 +0000674cc_library_static {
675 name: "foo_static",
676 srcs: ["common.c"],
677 arch: { arm: { srcs: ["foo-arm.c"] } }
678}`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200679 expectedBazelTargets: []string{`cc_library_static(
Jingwen Chene32e9e02021-04-23 09:17:24 +0000680 name = "foo_static",
Chris Parsons484e50a2021-05-13 15:13:04 -0400681 copts = [
682 "-I.",
683 "-I$(BINDIR)/.",
684 ],
Jingwen Chene32e9e02021-04-23 09:17:24 +0000685 linkstatic = True,
Chris Parsons990c4f42021-05-25 12:10:58 -0400686 srcs_c = ["common.c"] + select({
Jingwen Chene32e9e02021-04-23 09:17:24 +0000687 "//build/bazel/platforms/arch:arm": ["foo-arm.c"],
688 "//conditions:default": [],
689 }),
690)`},
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200691 })
692}
693
694func TestCcLibraryStaticOneArchSrcsExcludeSrcs(t *testing.T) {
695 runCcLibraryStaticTestCase(t, bp2buildTestCase{
696 description: "cc_library_static one arch specific srcs and exclude_srcs",
697 moduleTypeUnderTest: "cc_library_static",
698 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
699 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
700 depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build},
701 filesystem: map[string]string{
702 "common.c": "",
703 "for-arm.c": "",
704 "not-for-arm.c": "",
705 "not-for-anything.c": "",
Jingwen Chene32e9e02021-04-23 09:17:24 +0000706 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200707 blueprint: soongCcLibraryStaticPreamble + `
Jingwen Chene32e9e02021-04-23 09:17:24 +0000708cc_library_static {
709 name: "foo_static",
710 srcs: ["common.c", "not-for-*.c"],
711 exclude_srcs: ["not-for-anything.c"],
712 arch: {
713 arm: { srcs: ["for-arm.c"], exclude_srcs: ["not-for-arm.c"] },
714 },
715}`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200716 expectedBazelTargets: []string{`cc_library_static(
Jingwen Chene32e9e02021-04-23 09:17:24 +0000717 name = "foo_static",
Chris Parsons484e50a2021-05-13 15:13:04 -0400718 copts = [
719 "-I.",
720 "-I$(BINDIR)/.",
721 ],
Jingwen Chene32e9e02021-04-23 09:17:24 +0000722 linkstatic = True,
Chris Parsons990c4f42021-05-25 12:10:58 -0400723 srcs_c = ["common.c"] + select({
Jingwen Chene32e9e02021-04-23 09:17:24 +0000724 "//build/bazel/platforms/arch:arm": ["for-arm.c"],
725 "//conditions:default": ["not-for-arm.c"],
726 }),
727)`},
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200728 })
729}
730
731func TestCcLibraryStaticTwoArchExcludeSrcs(t *testing.T) {
732 runCcLibraryStaticTestCase(t, bp2buildTestCase{
733 description: "cc_library_static arch specific exclude_srcs for 2 architectures",
734 moduleTypeUnderTest: "cc_library_static",
735 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
736 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
737 depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build},
738 filesystem: map[string]string{
739 "common.c": "",
740 "for-arm.c": "",
741 "for-x86.c": "",
742 "not-for-arm.c": "",
743 "not-for-x86.c": "",
Jingwen Chene32e9e02021-04-23 09:17:24 +0000744 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200745 blueprint: soongCcLibraryStaticPreamble + `
Jingwen Chene32e9e02021-04-23 09:17:24 +0000746cc_library_static {
747 name: "foo_static",
748 srcs: ["common.c", "not-for-*.c"],
749 exclude_srcs: ["not-for-everything.c"],
750 arch: {
751 arm: { srcs: ["for-arm.c"], exclude_srcs: ["not-for-arm.c"] },
752 x86: { srcs: ["for-x86.c"], exclude_srcs: ["not-for-x86.c"] },
753 },
754} `,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200755 expectedBazelTargets: []string{`cc_library_static(
Jingwen Chene32e9e02021-04-23 09:17:24 +0000756 name = "foo_static",
Chris Parsons484e50a2021-05-13 15:13:04 -0400757 copts = [
758 "-I.",
759 "-I$(BINDIR)/.",
760 ],
Jingwen Chene32e9e02021-04-23 09:17:24 +0000761 linkstatic = True,
Chris Parsons990c4f42021-05-25 12:10:58 -0400762 srcs_c = ["common.c"] + select({
Jingwen Chene32e9e02021-04-23 09:17:24 +0000763 "//build/bazel/platforms/arch:arm": [
764 "for-arm.c",
765 "not-for-x86.c",
766 ],
767 "//build/bazel/platforms/arch:x86": [
768 "for-x86.c",
769 "not-for-arm.c",
770 ],
771 "//conditions:default": [
772 "not-for-arm.c",
773 "not-for-x86.c",
774 ],
775 }),
776)`},
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200777 })
778}
779func TestCcLibraryStaticFourArchExcludeSrcs(t *testing.T) {
780 runCcLibraryStaticTestCase(t, bp2buildTestCase{
781 description: "cc_library_static arch specific exclude_srcs for 4 architectures",
782 moduleTypeUnderTest: "cc_library_static",
783 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
784 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
785 depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build},
786 filesystem: map[string]string{
787 "common.c": "",
788 "for-arm.c": "",
789 "for-arm64.c": "",
790 "for-x86.c": "",
791 "for-x86_64.c": "",
792 "not-for-arm.c": "",
793 "not-for-arm64.c": "",
794 "not-for-x86.c": "",
795 "not-for-x86_64.c": "",
796 "not-for-everything.c": "",
Jingwen Chene32e9e02021-04-23 09:17:24 +0000797 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200798 blueprint: soongCcLibraryStaticPreamble + `
Jingwen Chene32e9e02021-04-23 09:17:24 +0000799cc_library_static {
800 name: "foo_static",
801 srcs: ["common.c", "not-for-*.c"],
802 exclude_srcs: ["not-for-everything.c"],
803 arch: {
804 arm: { srcs: ["for-arm.c"], exclude_srcs: ["not-for-arm.c"] },
805 arm64: { srcs: ["for-arm64.c"], exclude_srcs: ["not-for-arm64.c"] },
806 x86: { srcs: ["for-x86.c"], exclude_srcs: ["not-for-x86.c"] },
807 x86_64: { srcs: ["for-x86_64.c"], exclude_srcs: ["not-for-x86_64.c"] },
808 },
809} `,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200810 expectedBazelTargets: []string{`cc_library_static(
Jingwen Chene32e9e02021-04-23 09:17:24 +0000811 name = "foo_static",
Chris Parsons484e50a2021-05-13 15:13:04 -0400812 copts = [
813 "-I.",
814 "-I$(BINDIR)/.",
815 ],
Jingwen Chene32e9e02021-04-23 09:17:24 +0000816 linkstatic = True,
Chris Parsons990c4f42021-05-25 12:10:58 -0400817 srcs_c = ["common.c"] + select({
Jingwen Chene32e9e02021-04-23 09:17:24 +0000818 "//build/bazel/platforms/arch:arm": [
819 "for-arm.c",
820 "not-for-arm64.c",
821 "not-for-x86.c",
822 "not-for-x86_64.c",
823 ],
824 "//build/bazel/platforms/arch:arm64": [
825 "for-arm64.c",
826 "not-for-arm.c",
827 "not-for-x86.c",
828 "not-for-x86_64.c",
829 ],
830 "//build/bazel/platforms/arch:x86": [
831 "for-x86.c",
832 "not-for-arm.c",
833 "not-for-arm64.c",
834 "not-for-x86_64.c",
835 ],
836 "//build/bazel/platforms/arch:x86_64": [
837 "for-x86_64.c",
838 "not-for-arm.c",
839 "not-for-arm64.c",
840 "not-for-x86.c",
841 ],
842 "//conditions:default": [
843 "not-for-arm.c",
844 "not-for-arm64.c",
845 "not-for-x86.c",
846 "not-for-x86_64.c",
847 ],
848 }),
849)`},
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200850 })
851}
852
Liz Kammer2b07ec72021-05-26 15:08:27 -0400853func TestCcLibraryStaticOneArchEmpty(t *testing.T) {
854 runCcLibraryStaticTestCase(t, bp2buildTestCase{
855 description: "cc_library_static one arch empty",
856 moduleTypeUnderTest: "cc_library_static",
857 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
858 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
859 depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build},
860 filesystem: map[string]string{
861 "common.cc": "",
862 "foo-no-arm.cc": "",
863 "foo-excluded.cc": "",
864 },
865 blueprint: soongCcLibraryStaticPreamble + `
866cc_library_static {
867 name: "foo_static",
868 srcs: ["common.cc", "foo-*.cc"],
869 exclude_srcs: ["foo-excluded.cc"],
870 arch: {
871 arm: { exclude_srcs: ["foo-no-arm.cc"] },
872 },
873}`,
874 expectedBazelTargets: []string{`cc_library_static(
875 name = "foo_static",
876 copts = [
877 "-I.",
878 "-I$(BINDIR)/.",
879 ],
880 linkstatic = True,
881 srcs = ["common.cc"] + select({
882 "//build/bazel/platforms/arch:arm": [],
883 "//conditions:default": ["foo-no-arm.cc"],
884 }),
885)`},
886 })
887}
888
889func TestCcLibraryStaticOneArchEmptyOtherSet(t *testing.T) {
890 runCcLibraryStaticTestCase(t, bp2buildTestCase{
891 description: "cc_library_static one arch empty other set",
892 moduleTypeUnderTest: "cc_library_static",
893 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
894 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
895 depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build},
896 filesystem: map[string]string{
897 "common.cc": "",
898 "foo-no-arm.cc": "",
899 "x86-only.cc": "",
900 "foo-excluded.cc": "",
901 },
902 blueprint: soongCcLibraryStaticPreamble + `
903cc_library_static {
904 name: "foo_static",
905 srcs: ["common.cc", "foo-*.cc"],
906 exclude_srcs: ["foo-excluded.cc"],
907 arch: {
908 arm: { exclude_srcs: ["foo-no-arm.cc"] },
909 x86: { srcs: ["x86-only.cc"] },
910 },
911}`,
912 expectedBazelTargets: []string{`cc_library_static(
913 name = "foo_static",
914 copts = [
915 "-I.",
916 "-I$(BINDIR)/.",
917 ],
918 linkstatic = True,
919 srcs = ["common.cc"] + select({
920 "//build/bazel/platforms/arch:arm": [],
921 "//build/bazel/platforms/arch:x86": [
922 "foo-no-arm.cc",
923 "x86-only.cc",
924 ],
925 "//conditions:default": ["foo-no-arm.cc"],
926 }),
927)`},
928 })
929}
930
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200931func TestCcLibraryStaticMultipleDepSameName(t *testing.T) {
932 runCcLibraryStaticTestCase(t, bp2buildTestCase{
933 description: "cc_library_static multiple dep same name panic",
934 moduleTypeUnderTest: "cc_library_static",
935 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
936 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
937 depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build},
938 filesystem: map[string]string{},
939 blueprint: soongCcLibraryStaticPreamble + `
Liz Kammer2b50ce62021-04-26 15:47:28 -0400940cc_library_static { name: "static_dep" }
941cc_library_static {
942 name: "foo_static",
Chris Parsons08648312021-05-06 16:23:19 -0400943 static_libs: ["static_dep", "static_dep"],
Liz Kammer2b50ce62021-04-26 15:47:28 -0400944}`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200945 expectedBazelTargets: []string{`cc_library_static(
Liz Kammer2b50ce62021-04-26 15:47:28 -0400946 name = "foo_static",
Chris Parsons484e50a2021-05-13 15:13:04 -0400947 copts = [
948 "-I.",
949 "-I$(BINDIR)/.",
950 ],
Chris Parsonsd6358772021-05-18 18:35:24 -0400951 implementation_deps = [":static_dep"],
Liz Kammer2b50ce62021-04-26 15:47:28 -0400952 linkstatic = True,
953)`, `cc_library_static(
954 name = "static_dep",
Chris Parsons484e50a2021-05-13 15:13:04 -0400955 copts = [
956 "-I.",
957 "-I$(BINDIR)/.",
958 ],
Liz Kammer2b50ce62021-04-26 15:47:28 -0400959 linkstatic = True,
960)`},
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200961 })
962}
963
964func TestCcLibraryStaticOneMultilibSrcsExcludeSrcs(t *testing.T) {
965 runCcLibraryStaticTestCase(t, bp2buildTestCase{
966 description: "cc_library_static 1 multilib srcs and exclude_srcs",
967 moduleTypeUnderTest: "cc_library_static",
968 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
969 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
970 depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build},
971 filesystem: map[string]string{
972 "common.c": "",
973 "for-lib32.c": "",
974 "not-for-lib32.c": "",
Liz Kammer2b50ce62021-04-26 15:47:28 -0400975 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200976 blueprint: soongCcLibraryStaticPreamble + `
Chris Parsonsc424b762021-04-29 18:06:50 -0400977cc_library_static {
978 name: "foo_static",
979 srcs: ["common.c", "not-for-*.c"],
980 multilib: {
981 lib32: { srcs: ["for-lib32.c"], exclude_srcs: ["not-for-lib32.c"] },
982 },
983} `,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200984 expectedBazelTargets: []string{`cc_library_static(
Chris Parsonsc424b762021-04-29 18:06:50 -0400985 name = "foo_static",
Chris Parsons484e50a2021-05-13 15:13:04 -0400986 copts = [
987 "-I.",
988 "-I$(BINDIR)/.",
989 ],
Chris Parsonsc424b762021-04-29 18:06:50 -0400990 linkstatic = True,
Chris Parsons990c4f42021-05-25 12:10:58 -0400991 srcs_c = ["common.c"] + select({
Chris Parsonsc424b762021-04-29 18:06:50 -0400992 "//build/bazel/platforms/arch:arm": ["for-lib32.c"],
993 "//build/bazel/platforms/arch:x86": ["for-lib32.c"],
994 "//conditions:default": ["not-for-lib32.c"],
995 }),
996)`},
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200997 })
998}
999
1000func TestCcLibraryStaticTwoMultilibSrcsExcludeSrcs(t *testing.T) {
1001 runCcLibraryStaticTestCase(t, bp2buildTestCase{
1002 description: "cc_library_static 2 multilib srcs and exclude_srcs",
1003 moduleTypeUnderTest: "cc_library_static",
1004 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
1005 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
1006 depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build},
1007 filesystem: map[string]string{
1008 "common.c": "",
1009 "for-lib32.c": "",
1010 "for-lib64.c": "",
1011 "not-for-lib32.c": "",
1012 "not-for-lib64.c": "",
Chris Parsonsc424b762021-04-29 18:06:50 -04001013 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +02001014 blueprint: soongCcLibraryStaticPreamble + `
Chris Parsonsc424b762021-04-29 18:06:50 -04001015cc_library_static {
1016 name: "foo_static2",
1017 srcs: ["common.c", "not-for-*.c"],
1018 multilib: {
1019 lib32: { srcs: ["for-lib32.c"], exclude_srcs: ["not-for-lib32.c"] },
1020 lib64: { srcs: ["for-lib64.c"], exclude_srcs: ["not-for-lib64.c"] },
1021 },
1022} `,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +02001023 expectedBazelTargets: []string{`cc_library_static(
Chris Parsonsc424b762021-04-29 18:06:50 -04001024 name = "foo_static2",
Chris Parsons484e50a2021-05-13 15:13:04 -04001025 copts = [
1026 "-I.",
1027 "-I$(BINDIR)/.",
1028 ],
Chris Parsonsc424b762021-04-29 18:06:50 -04001029 linkstatic = True,
Chris Parsons990c4f42021-05-25 12:10:58 -04001030 srcs_c = ["common.c"] + select({
Chris Parsonsc424b762021-04-29 18:06:50 -04001031 "//build/bazel/platforms/arch:arm": [
1032 "for-lib32.c",
1033 "not-for-lib64.c",
1034 ],
1035 "//build/bazel/platforms/arch:arm64": [
1036 "for-lib64.c",
1037 "not-for-lib32.c",
1038 ],
1039 "//build/bazel/platforms/arch:x86": [
1040 "for-lib32.c",
1041 "not-for-lib64.c",
1042 ],
1043 "//build/bazel/platforms/arch:x86_64": [
1044 "for-lib64.c",
1045 "not-for-lib32.c",
1046 ],
1047 "//conditions:default": [
1048 "not-for-lib32.c",
1049 "not-for-lib64.c",
1050 ],
1051 }),
1052)`},
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +02001053 })
1054}
1055
1056func TestCcLibrarySTaticArchMultilibSrcsExcludeSrcs(t *testing.T) {
1057 runCcLibraryStaticTestCase(t, bp2buildTestCase{
1058 description: "cc_library_static arch and multilib srcs and exclude_srcs",
1059 moduleTypeUnderTest: "cc_library_static",
1060 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
1061 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
1062 depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build},
1063 filesystem: map[string]string{
1064 "common.c": "",
1065 "for-arm.c": "",
1066 "for-arm64.c": "",
1067 "for-x86.c": "",
1068 "for-x86_64.c": "",
1069 "for-lib32.c": "",
1070 "for-lib64.c": "",
1071 "not-for-arm.c": "",
1072 "not-for-arm64.c": "",
1073 "not-for-x86.c": "",
1074 "not-for-x86_64.c": "",
1075 "not-for-lib32.c": "",
1076 "not-for-lib64.c": "",
1077 "not-for-everything.c": "",
Chris Parsonsc424b762021-04-29 18:06:50 -04001078 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +02001079 blueprint: soongCcLibraryStaticPreamble + `
Chris Parsonsc424b762021-04-29 18:06:50 -04001080cc_library_static {
1081 name: "foo_static3",
1082 srcs: ["common.c", "not-for-*.c"],
1083 exclude_srcs: ["not-for-everything.c"],
1084 arch: {
1085 arm: { srcs: ["for-arm.c"], exclude_srcs: ["not-for-arm.c"] },
1086 arm64: { srcs: ["for-arm64.c"], exclude_srcs: ["not-for-arm64.c"] },
1087 x86: { srcs: ["for-x86.c"], exclude_srcs: ["not-for-x86.c"] },
1088 x86_64: { srcs: ["for-x86_64.c"], exclude_srcs: ["not-for-x86_64.c"] },
1089 },
1090 multilib: {
1091 lib32: { srcs: ["for-lib32.c"], exclude_srcs: ["not-for-lib32.c"] },
1092 lib64: { srcs: ["for-lib64.c"], exclude_srcs: ["not-for-lib64.c"] },
1093 },
1094}`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +02001095 expectedBazelTargets: []string{`cc_library_static(
Chris Parsonsc424b762021-04-29 18:06:50 -04001096 name = "foo_static3",
Chris Parsons484e50a2021-05-13 15:13:04 -04001097 copts = [
1098 "-I.",
1099 "-I$(BINDIR)/.",
1100 ],
Chris Parsonsc424b762021-04-29 18:06:50 -04001101 linkstatic = True,
Chris Parsons990c4f42021-05-25 12:10:58 -04001102 srcs_c = ["common.c"] + select({
Chris Parsonsc424b762021-04-29 18:06:50 -04001103 "//build/bazel/platforms/arch:arm": [
1104 "for-arm.c",
1105 "for-lib32.c",
1106 "not-for-arm64.c",
1107 "not-for-lib64.c",
1108 "not-for-x86.c",
1109 "not-for-x86_64.c",
1110 ],
1111 "//build/bazel/platforms/arch:arm64": [
1112 "for-arm64.c",
1113 "for-lib64.c",
1114 "not-for-arm.c",
1115 "not-for-lib32.c",
1116 "not-for-x86.c",
1117 "not-for-x86_64.c",
1118 ],
1119 "//build/bazel/platforms/arch:x86": [
1120 "for-lib32.c",
1121 "for-x86.c",
1122 "not-for-arm.c",
1123 "not-for-arm64.c",
1124 "not-for-lib64.c",
1125 "not-for-x86_64.c",
1126 ],
1127 "//build/bazel/platforms/arch:x86_64": [
1128 "for-lib64.c",
1129 "for-x86_64.c",
1130 "not-for-arm.c",
1131 "not-for-arm64.c",
1132 "not-for-lib32.c",
1133 "not-for-x86.c",
1134 ],
1135 "//conditions:default": [
1136 "not-for-arm.c",
1137 "not-for-arm64.c",
1138 "not-for-lib32.c",
1139 "not-for-lib64.c",
1140 "not-for-x86.c",
1141 "not-for-x86_64.c",
1142 ],
1143 }),
1144)`},
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +02001145 })
1146}
1147
1148func TestCcLibraryStaticArchSrcsExcludeSrcsGeneratedFiles(t *testing.T) {
1149 runCcLibraryStaticTestCase(t, bp2buildTestCase{
1150 description: "cc_library_static arch srcs/exclude_srcs with generated files",
1151 moduleTypeUnderTest: "cc_library_static",
1152 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
1153 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
1154 depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build},
1155 filesystem: map[string]string{
Chris Parsons990c4f42021-05-25 12:10:58 -04001156 "common.cpp": "",
1157 "for-x86.cpp": "",
1158 "not-for-x86.cpp": "",
1159 "not-for-everything.cpp": "",
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +02001160 "dep/Android.bp": `
Chris Parsons484e50a2021-05-13 15:13:04 -04001161genrule {
1162 name: "generated_src_other_pkg",
1163 out: ["generated_src_other_pkg.cpp"],
1164 cmd: "nothing to see here",
1165}
1166
1167genrule {
1168 name: "generated_hdr_other_pkg",
1169 out: ["generated_hdr_other_pkg.cpp"],
1170 cmd: "nothing to see here",
1171}
1172
1173genrule {
1174 name: "generated_hdr_other_pkg_x86",
1175 out: ["generated_hdr_other_pkg_x86.cpp"],
1176 cmd: "nothing to see here",
1177}`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +02001178 },
1179 blueprint: soongCcLibraryStaticPreamble + `
Chris Parsons484e50a2021-05-13 15:13:04 -04001180genrule {
1181 name: "generated_src",
1182 out: ["generated_src.cpp"],
1183 cmd: "nothing to see here",
1184}
1185
1186genrule {
1187 name: "generated_src_x86",
1188 out: ["generated_src_x86.cpp"],
1189 cmd: "nothing to see here",
1190}
1191
1192genrule {
1193 name: "generated_hdr",
1194 out: ["generated_hdr.h"],
1195 cmd: "nothing to see here",
1196}
1197
1198cc_library_static {
1199 name: "foo_static3",
Chris Parsons990c4f42021-05-25 12:10:58 -04001200 srcs: ["common.cpp", "not-for-*.cpp"],
1201 exclude_srcs: ["not-for-everything.cpp"],
Chris Parsons484e50a2021-05-13 15:13:04 -04001202 generated_sources: ["generated_src", "generated_src_other_pkg"],
1203 generated_headers: ["generated_hdr", "generated_hdr_other_pkg"],
1204 arch: {
1205 x86: {
Chris Parsons990c4f42021-05-25 12:10:58 -04001206 srcs: ["for-x86.cpp"],
1207 exclude_srcs: ["not-for-x86.cpp"],
Chris Parsons484e50a2021-05-13 15:13:04 -04001208 generated_sources: ["generated_src_x86"],
1209 generated_headers: ["generated_hdr_other_pkg_x86"],
1210 },
1211 },
1212}
1213`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +02001214 expectedBazelTargets: []string{`cc_library_static(
Chris Parsons484e50a2021-05-13 15:13:04 -04001215 name = "foo_static3",
1216 copts = [
1217 "-I.",
1218 "-I$(BINDIR)/.",
1219 ],
1220 linkstatic = True,
1221 srcs = [
1222 "//dep:generated_hdr_other_pkg",
1223 "//dep:generated_src_other_pkg",
1224 ":generated_hdr",
1225 ":generated_src",
Chris Parsons990c4f42021-05-25 12:10:58 -04001226 "common.cpp",
Chris Parsons484e50a2021-05-13 15:13:04 -04001227 ] + select({
1228 "//build/bazel/platforms/arch:x86": [
1229 "//dep:generated_hdr_other_pkg_x86",
1230 ":generated_src_x86",
Chris Parsons990c4f42021-05-25 12:10:58 -04001231 "for-x86.cpp",
Chris Parsons484e50a2021-05-13 15:13:04 -04001232 ],
Chris Parsons990c4f42021-05-25 12:10:58 -04001233 "//conditions:default": ["not-for-x86.cpp"],
Chris Parsons484e50a2021-05-13 15:13:04 -04001234 }),
1235)`},
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +02001236 })
Rupert Shuttleworth095081c2021-03-25 09:06:03 +00001237}
Liz Kammer6fd7b3f2021-05-06 13:54:29 -04001238
Rupert Shuttleworthc194ffb2021-05-19 06:49:02 -04001239func TestCcLibraryStaticGetTargetProperties(t *testing.T) {
1240 runCcLibraryStaticTestCase(t, bp2buildTestCase{
1241
1242 description: "cc_library_static complex GetTargetProperties",
1243 moduleTypeUnderTest: "cc_library_static",
1244 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
1245 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
1246 depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build},
1247 blueprint: soongCcLibraryStaticPreamble + `
1248cc_library_static {
1249 name: "foo_static",
1250 target: {
1251 android: {
1252 srcs: ["android_src.c"],
1253 },
1254 android_arm: {
1255 srcs: ["android_arm_src.c"],
1256 },
1257 android_arm64: {
1258 srcs: ["android_arm64_src.c"],
1259 },
1260 android_x86: {
1261 srcs: ["android_x86_src.c"],
1262 },
1263 android_x86_64: {
1264 srcs: ["android_x86_64_src.c"],
1265 },
1266 linux_bionic_arm64: {
1267 srcs: ["linux_bionic_arm64_src.c"],
1268 },
1269 linux_bionic_x86_64: {
1270 srcs: ["linux_bionic_x86_64_src.c"],
1271 },
1272 },
1273}`,
1274 expectedBazelTargets: []string{`cc_library_static(
1275 name = "foo_static",
1276 copts = [
1277 "-I.",
1278 "-I$(BINDIR)/.",
1279 ],
1280 linkstatic = True,
1281 srcs_c = select({
1282 "//build/bazel/platforms/os:android": ["android_src.c"],
1283 "//conditions:default": [],
1284 }) + select({
1285 "//build/bazel/platforms:android_arm": ["android_arm_src.c"],
1286 "//build/bazel/platforms:android_arm64": ["android_arm64_src.c"],
1287 "//build/bazel/platforms:android_x86": ["android_x86_src.c"],
1288 "//build/bazel/platforms:android_x86_64": ["android_x86_64_src.c"],
1289 "//conditions:default": [],
1290 }) + select({
1291 "//build/bazel/platforms:linux_bionic_arm64": ["linux_bionic_arm64_src.c"],
1292 "//build/bazel/platforms:linux_bionic_x86_64": ["linux_bionic_x86_64_src.c"],
1293 "//conditions:default": [],
1294 }),
1295)`},
1296 })
1297}
1298
Liz Kammer6fd7b3f2021-05-06 13:54:29 -04001299func TestCcLibraryStaticProductVariableSelects(t *testing.T) {
1300 runCcLibraryStaticTestCase(t, bp2buildTestCase{
1301 description: "cc_library_static product variable selects",
1302 moduleTypeUnderTest: "cc_library_static",
1303 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
1304 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
1305 depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build},
1306 filesystem: map[string]string{},
1307 blueprint: soongCcLibraryStaticPreamble + `
1308cc_library_static {
1309 name: "foo_static",
1310 srcs: ["common.c"],
1311 product_variables: {
1312 malloc_not_svelte: {
1313 cflags: ["-Wmalloc_not_svelte"],
1314 },
1315 malloc_zero_contents: {
1316 cflags: ["-Wmalloc_zero_contents"],
1317 },
1318 binder32bit: {
1319 cflags: ["-Wbinder32bit"],
1320 },
1321 },
1322} `,
1323 expectedBazelTargets: []string{`cc_library_static(
1324 name = "foo_static",
1325 copts = [
1326 "-I.",
1327 "-I$(BINDIR)/.",
1328 ] + select({
Liz Kammere3e4a5f2021-05-10 11:39:53 -04001329 "//build/bazel/product_variables:binder32bit": ["-Wbinder32bit"],
1330 "//conditions:default": [],
1331 }) + select({
Liz Kammer6fd7b3f2021-05-06 13:54:29 -04001332 "//build/bazel/product_variables:malloc_not_svelte": ["-Wmalloc_not_svelte"],
1333 "//conditions:default": [],
1334 }) + select({
1335 "//build/bazel/product_variables:malloc_zero_contents": ["-Wmalloc_zero_contents"],
1336 "//conditions:default": [],
Liz Kammere3e4a5f2021-05-10 11:39:53 -04001337 }),
1338 linkstatic = True,
Chris Parsons990c4f42021-05-25 12:10:58 -04001339 srcs_c = ["common.c"],
Liz Kammere3e4a5f2021-05-10 11:39:53 -04001340)`},
1341 })
1342}
1343
1344func TestCcLibraryStaticProductVariableArchSpecificSelects(t *testing.T) {
1345 runCcLibraryStaticTestCase(t, bp2buildTestCase{
1346 description: "cc_library_static arch-specific product variable selects",
1347 moduleTypeUnderTest: "cc_library_static",
1348 moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
1349 moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
1350 depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build},
1351 filesystem: map[string]string{},
1352 blueprint: soongCcLibraryStaticPreamble + `
1353cc_library_static {
1354 name: "foo_static",
1355 srcs: ["common.c"],
1356 product_variables: {
1357 malloc_not_svelte: {
1358 cflags: ["-Wmalloc_not_svelte"],
1359 },
1360 },
1361 arch: {
1362 arm64: {
1363 product_variables: {
1364 malloc_not_svelte: {
1365 cflags: ["-Warm64_malloc_not_svelte"],
1366 },
1367 },
1368 },
1369 },
1370 multilib: {
1371 lib32: {
1372 product_variables: {
1373 malloc_not_svelte: {
1374 cflags: ["-Wlib32_malloc_not_svelte"],
1375 },
1376 },
1377 },
1378 },
1379 target: {
1380 android: {
1381 product_variables: {
1382 malloc_not_svelte: {
1383 cflags: ["-Wandroid_malloc_not_svelte"],
1384 },
1385 },
1386 }
1387 },
1388} `,
1389 expectedBazelTargets: []string{`cc_library_static(
1390 name = "foo_static",
1391 copts = [
1392 "-I.",
1393 "-I$(BINDIR)/.",
1394 ] + select({
1395 "//build/bazel/product_variables:malloc_not_svelte": ["-Wmalloc_not_svelte"],
1396 "//conditions:default": [],
Liz Kammer6fd7b3f2021-05-06 13:54:29 -04001397 }) + select({
Liz Kammere3e4a5f2021-05-10 11:39:53 -04001398 "//build/bazel/product_variables:malloc_not_svelte-android": ["-Wandroid_malloc_not_svelte"],
1399 "//conditions:default": [],
1400 }) + select({
1401 "//build/bazel/product_variables:malloc_not_svelte-arm": ["-Wlib32_malloc_not_svelte"],
1402 "//conditions:default": [],
1403 }) + select({
1404 "//build/bazel/product_variables:malloc_not_svelte-arm64": ["-Warm64_malloc_not_svelte"],
1405 "//conditions:default": [],
1406 }) + select({
1407 "//build/bazel/product_variables:malloc_not_svelte-x86": ["-Wlib32_malloc_not_svelte"],
Liz Kammer6fd7b3f2021-05-06 13:54:29 -04001408 "//conditions:default": [],
1409 }),
1410 linkstatic = True,
Chris Parsons990c4f42021-05-25 12:10:58 -04001411 srcs_c = ["common.c"],
Liz Kammer6fd7b3f2021-05-06 13:54:29 -04001412)`},
1413 })
1414}