Seperate asflags and cflags
This fixes a bug which was a misunderstanding of soong properties:
Soong's cflags pertain only to C and C++ language, whereas bazel's copts
pertain to all three languages. This change ensures that asflags are
added as specifically asflags, and the 'copts' for the static library
macro pertains only to C and C++ languages.
This requires a somewhat hacky workaround for asflags, however: Since
assembly sources also need includepath-related flags, this duplicates
these flags between copts and asflags. To reduce verbosity of
bp2build-generated targets, this also ensures that asflags are omitted
in cases where there are no assembly sources.
Test: Mixed build droid CI
Change-Id: Ic0babed1f90d6dc82e5788638681ce5b995043f8
diff --git a/bp2build/cc_object_conversion_test.go b/bp2build/cc_object_conversion_test.go
index 8ede226..df4924b 100644
--- a/bp2build/cc_object_conversion_test.go
+++ b/bp2build/cc_object_conversion_test.go
@@ -211,6 +211,7 @@
asflags: ["-DPLATFORM_SDK_VERSION=%d"],
},
},
+ srcs: ["src.S"],
}
`,
expectedBazelTargets: []string{`cc_object(
@@ -220,6 +221,7 @@
"//conditions:default": [],
}),
copts = ["-fno-addrsig"],
+ srcs_as = ["src.S"],
)`,
},
})
@@ -240,7 +242,7 @@
cflags: ["-fPIC"], // string list
},
arm: {
- srcs: ["arch/arm/file.S"], // label list
+ srcs: ["arch/arm/file.cpp"], // label list
},
},
}
@@ -257,7 +259,7 @@
"//conditions:default": [],
}),
srcs = ["a.cpp"] + select({
- "//build/bazel/platforms/arch:arm": ["arch/arm/file.S"],
+ "//build/bazel/platforms/arch:arm": ["arch/arm/file.cpp"],
"//conditions:default": [],
}),
)`,