blob: 63a0b8a21153ecea1eaff08198abd8eb3bc2feb4 [file] [log] [blame]
Jingwen Chen8c1b97e2021-02-18 03:21:34 -05001// 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
Jingwen Chen8c1b97e2021-02-18 03:21:34 -050020 "android/soong/android"
21 "android/soong/cc"
Jingwen Chen8c1b97e2021-02-18 03:21:34 -050022)
23
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +020024func registerCcObjectModuleTypes(ctx android.RegistrationContext) {
25 // Always register cc_defaults module factory
26 ctx.RegisterModuleType("cc_defaults", func() android.Module { return cc.DefaultsFactory() })
27}
28
29func runCcObjectTestCase(t *testing.T, tc bp2buildTestCase) {
Liz Kammere4982e82021-05-25 10:39:35 -040030 t.Helper()
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +020031 runBp2BuildTestCase(t, registerCcObjectModuleTypes, tc)
32}
33
34func TestCcObjectSimple(t *testing.T) {
35 runCcObjectTestCase(t, bp2buildTestCase{
36 description: "simple cc_object generates cc_object with include header dep",
37 moduleTypeUnderTest: "cc_object",
38 moduleTypeUnderTestFactory: cc.ObjectFactory,
39 moduleTypeUnderTestBp2BuildMutator: cc.ObjectBp2Build,
40 filesystem: map[string]string{
41 "a/b/foo.h": "",
42 "a/b/bar.h": "",
43 "a/b/exclude.c": "",
44 "a/b/c.c": "",
45 },
46 blueprint: `cc_object {
Jingwen Chen8c1b97e2021-02-18 03:21:34 -050047 name: "foo",
48 local_include_dirs: ["include"],
Colin Cross6b8f4252021-07-22 11:39:44 -070049 system_shared_libs: [],
Jingwen Chen8c1b97e2021-02-18 03:21:34 -050050 cflags: [
51 "-Wno-gcc-compat",
52 "-Wall",
53 "-Werror",
54 ],
55 srcs: [
Jingwen Chendb120242021-02-23 00:46:47 -050056 "a/b/*.c"
Jingwen Chen8c1b97e2021-02-18 03:21:34 -050057 ],
Jingwen Chendb120242021-02-23 00:46:47 -050058 exclude_srcs: ["a/b/exclude.c"],
Jingwen Chen8c1b97e2021-02-18 03:21:34 -050059}
60`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +020061 expectedBazelTargets: []string{`cc_object(
Jingwen Chen8c1b97e2021-02-18 03:21:34 -050062 name = "foo",
63 copts = [
64 "-fno-addrsig",
65 "-Wno-gcc-compat",
66 "-Wall",
67 "-Werror",
Liz Kammer35687bc2021-09-10 10:07:07 -040068 ],
69 local_includes = [
70 "include",
71 ".",
Jingwen Chen8c1b97e2021-02-18 03:21:34 -050072 ],
Jingwen Chen882bcc12021-04-27 05:54:20 +000073 srcs = ["a/b/c.c"],
Chris Parsonsa37e1952021-09-28 16:47:36 -040074 system_dynamic_deps = [],
Jingwen Chen8c1b97e2021-02-18 03:21:34 -050075)`,
Jingwen Chen8c1b97e2021-02-18 03:21:34 -050076 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +020077 })
78}
79
80func TestCcObjectDefaults(t *testing.T) {
81 runCcObjectTestCase(t, bp2buildTestCase{
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +020082 moduleTypeUnderTest: "cc_object",
83 moduleTypeUnderTestFactory: cc.ObjectFactory,
84 moduleTypeUnderTestBp2BuildMutator: cc.ObjectBp2Build,
85 blueprint: `cc_object {
Jingwen Chen8c1b97e2021-02-18 03:21:34 -050086 name: "foo",
Colin Cross6b8f4252021-07-22 11:39:44 -070087 system_shared_libs: [],
Jingwen Chen8c1b97e2021-02-18 03:21:34 -050088 srcs: [
89 "a/b/*.h",
90 "a/b/c.c"
91 ],
92
93 defaults: ["foo_defaults"],
Jingwen Chen8c1b97e2021-02-18 03:21:34 -050094}
95
96cc_defaults {
97 name: "foo_defaults",
98 defaults: ["foo_bar_defaults"],
Jingwen Chen8c1b97e2021-02-18 03:21:34 -050099}
100
101cc_defaults {
102 name: "foo_bar_defaults",
103 cflags: [
104 "-Wno-gcc-compat",
105 "-Wall",
106 "-Werror",
107 ],
108}
109`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200110 expectedBazelTargets: []string{`cc_object(
Jingwen Chen8c1b97e2021-02-18 03:21:34 -0500111 name = "foo",
112 copts = [
113 "-Wno-gcc-compat",
114 "-Wall",
115 "-Werror",
116 "-fno-addrsig",
Jingwen Chen8c1b97e2021-02-18 03:21:34 -0500117 ],
Liz Kammer35687bc2021-09-10 10:07:07 -0400118 local_includes = ["."],
Jingwen Chenb4628eb2021-04-08 14:40:57 +0000119 srcs = ["a/b/c.c"],
Chris Parsonsa37e1952021-09-28 16:47:36 -0400120 system_dynamic_deps = [],
Jingwen Chen8c1b97e2021-02-18 03:21:34 -0500121)`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200122 }})
123}
124
125func TestCcObjectCcObjetDepsInObjs(t *testing.T) {
126 runCcObjectTestCase(t, bp2buildTestCase{
127 description: "cc_object with cc_object deps in objs props",
128 moduleTypeUnderTest: "cc_object",
129 moduleTypeUnderTestFactory: cc.ObjectFactory,
130 moduleTypeUnderTestBp2BuildMutator: cc.ObjectBp2Build,
131 filesystem: map[string]string{
132 "a/b/c.c": "",
133 "x/y/z.c": "",
Jingwen Chen8c1b97e2021-02-18 03:21:34 -0500134 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200135 blueprint: `cc_object {
Jingwen Chendb120242021-02-23 00:46:47 -0500136 name: "foo",
Colin Cross6b8f4252021-07-22 11:39:44 -0700137 system_shared_libs: [],
Jingwen Chendb120242021-02-23 00:46:47 -0500138 srcs: ["a/b/c.c"],
139 objs: ["bar"],
Liz Kammer8337ea42021-09-10 10:06:32 -0400140 include_build_directory: false,
Jingwen Chendb120242021-02-23 00:46:47 -0500141}
142
143cc_object {
144 name: "bar",
Colin Cross6b8f4252021-07-22 11:39:44 -0700145 system_shared_libs: [],
Jingwen Chendb120242021-02-23 00:46:47 -0500146 srcs: ["x/y/z.c"],
Liz Kammer8337ea42021-09-10 10:06:32 -0400147 include_build_directory: false,
Jingwen Chendb120242021-02-23 00:46:47 -0500148}
149`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200150 expectedBazelTargets: []string{`cc_object(
Jingwen Chendb120242021-02-23 00:46:47 -0500151 name = "bar",
Liz Kammer8337ea42021-09-10 10:06:32 -0400152 copts = ["-fno-addrsig"],
Jingwen Chenb4628eb2021-04-08 14:40:57 +0000153 srcs = ["x/y/z.c"],
Chris Parsonsa37e1952021-09-28 16:47:36 -0400154 system_dynamic_deps = [],
Jingwen Chendb120242021-02-23 00:46:47 -0500155)`, `cc_object(
156 name = "foo",
Liz Kammer8337ea42021-09-10 10:06:32 -0400157 copts = ["-fno-addrsig"],
Jingwen Chenb4628eb2021-04-08 14:40:57 +0000158 deps = [":bar"],
Jingwen Chenb4628eb2021-04-08 14:40:57 +0000159 srcs = ["a/b/c.c"],
Chris Parsonsa37e1952021-09-28 16:47:36 -0400160 system_dynamic_deps = [],
Liz Kammera4aa4302021-03-18 16:56:36 -0400161)`,
Liz Kammera4aa4302021-03-18 16:56:36 -0400162 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200163 })
164}
165
166func TestCcObjectIncludeBuildDirFalse(t *testing.T) {
167 runCcObjectTestCase(t, bp2buildTestCase{
168 description: "cc_object with include_build_dir: false",
169 moduleTypeUnderTest: "cc_object",
170 moduleTypeUnderTestFactory: cc.ObjectFactory,
171 moduleTypeUnderTestBp2BuildMutator: cc.ObjectBp2Build,
172 filesystem: map[string]string{
173 "a/b/c.c": "",
174 "x/y/z.c": "",
175 },
176 blueprint: `cc_object {
Liz Kammera4aa4302021-03-18 16:56:36 -0400177 name: "foo",
Colin Cross6b8f4252021-07-22 11:39:44 -0700178 system_shared_libs: [],
Liz Kammera4aa4302021-03-18 16:56:36 -0400179 srcs: ["a/b/c.c"],
180 include_build_directory: false,
Liz Kammera4aa4302021-03-18 16:56:36 -0400181}
182`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200183 expectedBazelTargets: []string{`cc_object(
Liz Kammera4aa4302021-03-18 16:56:36 -0400184 name = "foo",
Jingwen Chenb4628eb2021-04-08 14:40:57 +0000185 copts = ["-fno-addrsig"],
186 srcs = ["a/b/c.c"],
Chris Parsonsa37e1952021-09-28 16:47:36 -0400187 system_dynamic_deps = [],
Jingwen Chendb120242021-02-23 00:46:47 -0500188)`,
Jingwen Chendb120242021-02-23 00:46:47 -0500189 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200190 })
191}
192
193func TestCcObjectProductVariable(t *testing.T) {
194 runCcObjectTestCase(t, bp2buildTestCase{
195 description: "cc_object with product variable",
196 moduleTypeUnderTest: "cc_object",
197 moduleTypeUnderTestFactory: cc.ObjectFactory,
198 moduleTypeUnderTestBp2BuildMutator: cc.ObjectBp2Build,
199 blueprint: `cc_object {
Liz Kammera060c452021-03-24 10:14:47 -0400200 name: "foo",
Colin Cross6b8f4252021-07-22 11:39:44 -0700201 system_shared_libs: [],
Liz Kammera060c452021-03-24 10:14:47 -0400202 include_build_directory: false,
203 product_variables: {
204 platform_sdk_version: {
205 asflags: ["-DPLATFORM_SDK_VERSION=%d"],
206 },
207 },
Chris Parsons69fa9f92021-07-13 11:47:44 -0400208 srcs: ["src.S"],
Liz Kammera060c452021-03-24 10:14:47 -0400209}
210`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200211 expectedBazelTargets: []string{`cc_object(
Liz Kammera060c452021-03-24 10:14:47 -0400212 name = "foo",
Liz Kammer6fd7b3f2021-05-06 13:54:29 -0400213 asflags = select({
Liz Kammerba7a9c52021-05-26 08:45:30 -0400214 "//build/bazel/product_variables:platform_sdk_version": ["-DPLATFORM_SDK_VERSION=$(Platform_sdk_version)"],
Liz Kammer6fd7b3f2021-05-06 13:54:29 -0400215 "//conditions:default": [],
216 }),
Jingwen Chenb4628eb2021-04-08 14:40:57 +0000217 copts = ["-fno-addrsig"],
Chris Parsons69fa9f92021-07-13 11:47:44 -0400218 srcs_as = ["src.S"],
Chris Parsonsa37e1952021-09-28 16:47:36 -0400219 system_dynamic_deps = [],
Liz Kammera060c452021-03-24 10:14:47 -0400220)`,
Liz Kammera060c452021-03-24 10:14:47 -0400221 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200222 })
Jingwen Chen8c1b97e2021-02-18 03:21:34 -0500223}
Jingwen Chen5d864492021-02-24 07:20:12 -0500224
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200225func TestCcObjectCflagsOneArch(t *testing.T) {
226 runCcObjectTestCase(t, bp2buildTestCase{
227 description: "cc_object setting cflags for one arch",
228 moduleTypeUnderTest: "cc_object",
229 moduleTypeUnderTestFactory: cc.ObjectFactory,
230 moduleTypeUnderTestBp2BuildMutator: cc.ObjectBp2Build,
231 blueprint: `cc_object {
Jingwen Chen5d864492021-02-24 07:20:12 -0500232 name: "foo",
Colin Cross6b8f4252021-07-22 11:39:44 -0700233 system_shared_libs: [],
Jingwen Chen07027912021-03-15 06:02:43 -0400234 srcs: ["a.cpp"],
Jingwen Chen5d864492021-02-24 07:20:12 -0500235 arch: {
236 x86: {
Jingwen Chen07027912021-03-15 06:02:43 -0400237 cflags: ["-fPIC"], // string list
238 },
239 arm: {
Chris Parsons69fa9f92021-07-13 11:47:44 -0400240 srcs: ["arch/arm/file.cpp"], // label list
Jingwen Chen5d864492021-02-24 07:20:12 -0500241 },
242 },
Liz Kammer8337ea42021-09-10 10:06:32 -0400243 include_build_directory: false,
Jingwen Chen5d864492021-02-24 07:20:12 -0500244}
245`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200246 expectedBazelTargets: []string{
247 `cc_object(
Jingwen Chen5d864492021-02-24 07:20:12 -0500248 name = "foo",
Liz Kammer8337ea42021-09-10 10:06:32 -0400249 copts = ["-fno-addrsig"] + select({
Jingwen Chenb4628eb2021-04-08 14:40:57 +0000250 "//build/bazel/platforms/arch:x86": ["-fPIC"],
Jingwen Chen07027912021-03-15 06:02:43 -0400251 "//conditions:default": [],
Jingwen Chen5d864492021-02-24 07:20:12 -0500252 }),
Jingwen Chenb4628eb2021-04-08 14:40:57 +0000253 srcs = ["a.cpp"] + select({
Chris Parsons69fa9f92021-07-13 11:47:44 -0400254 "//build/bazel/platforms/arch:arm": ["arch/arm/file.cpp"],
Jingwen Chen07027912021-03-15 06:02:43 -0400255 "//conditions:default": [],
256 }),
Chris Parsonsa37e1952021-09-28 16:47:36 -0400257 system_dynamic_deps = [],
Jingwen Chen5d864492021-02-24 07:20:12 -0500258)`,
Jingwen Chen5d864492021-02-24 07:20:12 -0500259 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200260 })
261}
262
263func TestCcObjectCflagsFourArch(t *testing.T) {
264 runCcObjectTestCase(t, bp2buildTestCase{
265 description: "cc_object setting cflags for 4 architectures",
266 moduleTypeUnderTest: "cc_object",
267 moduleTypeUnderTestFactory: cc.ObjectFactory,
268 moduleTypeUnderTestBp2BuildMutator: cc.ObjectBp2Build,
269 blueprint: `cc_object {
Jingwen Chen5d864492021-02-24 07:20:12 -0500270 name: "foo",
Colin Cross6b8f4252021-07-22 11:39:44 -0700271 system_shared_libs: [],
Jingwen Chen07027912021-03-15 06:02:43 -0400272 srcs: ["base.cpp"],
Jingwen Chen5d864492021-02-24 07:20:12 -0500273 arch: {
274 x86: {
Jingwen Chen07027912021-03-15 06:02:43 -0400275 srcs: ["x86.cpp"],
Jingwen Chen5d864492021-02-24 07:20:12 -0500276 cflags: ["-fPIC"],
277 },
278 x86_64: {
Jingwen Chen07027912021-03-15 06:02:43 -0400279 srcs: ["x86_64.cpp"],
Jingwen Chen5d864492021-02-24 07:20:12 -0500280 cflags: ["-fPIC"],
281 },
282 arm: {
Jingwen Chen07027912021-03-15 06:02:43 -0400283 srcs: ["arm.cpp"],
Jingwen Chen5d864492021-02-24 07:20:12 -0500284 cflags: ["-Wall"],
285 },
286 arm64: {
Jingwen Chen07027912021-03-15 06:02:43 -0400287 srcs: ["arm64.cpp"],
Jingwen Chen5d864492021-02-24 07:20:12 -0500288 cflags: ["-Wall"],
289 },
290 },
Liz Kammer8337ea42021-09-10 10:06:32 -0400291 include_build_directory: false,
Jingwen Chen5d864492021-02-24 07:20:12 -0500292}
293`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200294 expectedBazelTargets: []string{
295 `cc_object(
Jingwen Chen5d864492021-02-24 07:20:12 -0500296 name = "foo",
Liz Kammer8337ea42021-09-10 10:06:32 -0400297 copts = ["-fno-addrsig"] + select({
Jingwen Chenb4628eb2021-04-08 14:40:57 +0000298 "//build/bazel/platforms/arch:arm": ["-Wall"],
299 "//build/bazel/platforms/arch:arm64": ["-Wall"],
300 "//build/bazel/platforms/arch:x86": ["-fPIC"],
301 "//build/bazel/platforms/arch:x86_64": ["-fPIC"],
Jingwen Chen07027912021-03-15 06:02:43 -0400302 "//conditions:default": [],
Jingwen Chen5d864492021-02-24 07:20:12 -0500303 }),
Jingwen Chenb4628eb2021-04-08 14:40:57 +0000304 srcs = ["base.cpp"] + select({
305 "//build/bazel/platforms/arch:arm": ["arm.cpp"],
306 "//build/bazel/platforms/arch:arm64": ["arm64.cpp"],
307 "//build/bazel/platforms/arch:x86": ["x86.cpp"],
308 "//build/bazel/platforms/arch:x86_64": ["x86_64.cpp"],
Jingwen Chen07027912021-03-15 06:02:43 -0400309 "//conditions:default": [],
310 }),
Chris Parsonsa37e1952021-09-28 16:47:36 -0400311 system_dynamic_deps = [],
Jingwen Chen5d864492021-02-24 07:20:12 -0500312)`,
Jingwen Chen5d864492021-02-24 07:20:12 -0500313 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200314 })
315}
316
Chris Parsonsa37e1952021-09-28 16:47:36 -0400317func TestCcObjectLinkerScript(t *testing.T) {
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200318 runCcObjectTestCase(t, bp2buildTestCase{
Chris Parsonsa37e1952021-09-28 16:47:36 -0400319 description: "cc_object setting linker_script",
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200320 moduleTypeUnderTest: "cc_object",
321 moduleTypeUnderTestFactory: cc.ObjectFactory,
322 moduleTypeUnderTestBp2BuildMutator: cc.ObjectBp2Build,
323 blueprint: `cc_object {
Jingwen Chenc1c26502021-04-05 10:35:13 +0000324 name: "foo",
Chris Parsonsa37e1952021-09-28 16:47:36 -0400325 srcs: ["base.cpp"],
326 linker_script: "bunny.lds",
327 include_build_directory: false,
328}
329`,
330 expectedBazelTargets: []string{
331 `cc_object(
332 name = "foo",
333 copts = ["-fno-addrsig"],
334 linker_script = "bunny.lds",
335 srcs = ["base.cpp"],
336)`,
337 },
338 })
339}
340
341func TestCcObjectDepsAndLinkerScriptSelects(t *testing.T) {
342 runCcObjectTestCase(t, bp2buildTestCase{
343 description: "cc_object setting deps and linker_script across archs",
344 moduleTypeUnderTest: "cc_object",
345 moduleTypeUnderTestFactory: cc.ObjectFactory,
346 moduleTypeUnderTestBp2BuildMutator: cc.ObjectBp2Build,
347 blueprint: `cc_object {
348 name: "foo",
349 srcs: ["base.cpp"],
350 arch: {
351 x86: {
352 objs: ["x86_obj"],
353 linker_script: "x86.lds",
354 },
355 x86_64: {
356 objs: ["x86_64_obj"],
357 linker_script: "x86_64.lds",
358 },
359 arm: {
360 objs: ["arm_obj"],
361 linker_script: "arm.lds",
362 },
363 },
364 include_build_directory: false,
365}
366
367cc_object {
368 name: "x86_obj",
Colin Cross6b8f4252021-07-22 11:39:44 -0700369 system_shared_libs: [],
Chris Parsonsa37e1952021-09-28 16:47:36 -0400370 srcs: ["x86.cpp"],
371 include_build_directory: false,
372 bazel_module: { bp2build_available: false },
373}
374
375cc_object {
376 name: "x86_64_obj",
377 system_shared_libs: [],
378 srcs: ["x86_64.cpp"],
379 include_build_directory: false,
380 bazel_module: { bp2build_available: false },
381}
382
383cc_object {
384 name: "arm_obj",
385 system_shared_libs: [],
386 srcs: ["arm.cpp"],
387 include_build_directory: false,
388 bazel_module: { bp2build_available: false },
389}
390`,
391 expectedBazelTargets: []string{
392 `cc_object(
393 name = "foo",
394 copts = ["-fno-addrsig"],
395 deps = select({
396 "//build/bazel/platforms/arch:arm": [":arm_obj"],
397 "//build/bazel/platforms/arch:x86": [":x86_obj"],
398 "//build/bazel/platforms/arch:x86_64": [":x86_64_obj"],
399 "//conditions:default": [],
400 }),
401 linker_script = select({
402 "//build/bazel/platforms/arch:arm": "arm.lds",
403 "//build/bazel/platforms/arch:x86": "x86.lds",
404 "//build/bazel/platforms/arch:x86_64": "x86_64.lds",
405 "//conditions:default": None,
406 }),
407 srcs = ["base.cpp"],
408)`,
409 },
410 })
411}
412
413func TestCcObjectSelectOnLinuxAndBionicArchs(t *testing.T) {
414 runCcObjectTestCase(t, bp2buildTestCase{
415 description: "cc_object setting srcs based on linux and bionic archs",
416 moduleTypeUnderTest: "cc_object",
417 moduleTypeUnderTestFactory: cc.ObjectFactory,
418 moduleTypeUnderTestBp2BuildMutator: cc.ObjectBp2Build,
419 blueprint: `cc_object {
420 name: "foo",
Jingwen Chenc1c26502021-04-05 10:35:13 +0000421 srcs: ["base.cpp"],
422 target: {
Chris Parsonsa37e1952021-09-28 16:47:36 -0400423 linux_arm64: {
424 srcs: ["linux_arm64.cpp",]
Jingwen Chenc1c26502021-04-05 10:35:13 +0000425 },
Chris Parsonsa37e1952021-09-28 16:47:36 -0400426 linux_x86: {
427 srcs: ["linux_x86.cpp",]
Jingwen Chenc1c26502021-04-05 10:35:13 +0000428 },
Chris Parsonsa37e1952021-09-28 16:47:36 -0400429 bionic_arm64: {
430 srcs: ["bionic_arm64.cpp",]
Jingwen Chenc1c26502021-04-05 10:35:13 +0000431 },
432 },
Liz Kammer8337ea42021-09-10 10:06:32 -0400433 include_build_directory: false,
Jingwen Chenc1c26502021-04-05 10:35:13 +0000434}
435`,
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200436 expectedBazelTargets: []string{
437 `cc_object(
Jingwen Chenc1c26502021-04-05 10:35:13 +0000438 name = "foo",
Chris Parsonsa37e1952021-09-28 16:47:36 -0400439 copts = ["-fno-addrsig"],
440 srcs = ["base.cpp"] + select({
441 "//build/bazel/platforms/os_arch:android_arm64": [
442 "bionic_arm64.cpp",
443 "linux_arm64.cpp",
444 ],
445 "//build/bazel/platforms/os_arch:android_x86": ["linux_x86.cpp"],
446 "//build/bazel/platforms/os_arch:linux_bionic_arm64": [
447 "bionic_arm64.cpp",
448 "linux_arm64.cpp",
449 ],
450 "//build/bazel/platforms/os_arch:linux_glibc_x86": ["linux_x86.cpp"],
451 "//build/bazel/platforms/os_arch:linux_musl_x86": ["linux_x86.cpp"],
Jingwen Chenc1c26502021-04-05 10:35:13 +0000452 "//conditions:default": [],
453 }),
Jingwen Chenc1c26502021-04-05 10:35:13 +0000454)`,
Jingwen Chenc1c26502021-04-05 10:35:13 +0000455 },
Lukacs T. Berkic1cc3b92021-05-21 09:37:00 +0200456 })
Jingwen Chen5d864492021-02-24 07:20:12 -0500457}