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/cc/object.go b/cc/object.go
index 9f2db2e..5ded0e9 100644
--- a/cc/object.go
+++ b/cc/object.go
@@ -123,6 +123,7 @@
// For bp2build conversion.
type bazelObjectAttributes struct {
Srcs bazel.LabelListAttribute
+ Srcs_as bazel.LabelListAttribute
Hdrs bazel.LabelListAttribute
Deps bazel.LabelListAttribute
Copts bazel.StringListAttribute
@@ -179,13 +180,19 @@
// and this isn't typically done for cc_object.
srcs := compilerAttrs.srcs
srcs.Append(compilerAttrs.cSrcs)
- srcs.Append(compilerAttrs.asSrcs)
+
+ asFlags := compilerAttrs.asFlags
+ if compilerAttrs.asSrcs.IsEmpty() {
+ // Skip asflags for BUILD file simplicity if there are no assembly sources.
+ asFlags = bazel.MakeStringListAttribute(nil)
+ }
attrs := &bazelObjectAttributes{
Srcs: srcs,
+ Srcs_as: compilerAttrs.asSrcs,
Deps: deps,
Copts: compilerAttrs.copts,
- Asflags: compilerAttrs.asFlags,
+ Asflags: asFlags,
}
props := bazel.BazelTargetModuleProperties{