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/library.go b/cc/library.go
index 4fd7c74..56c460c 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -300,6 +300,12 @@
srcs := compilerAttrs.srcs
+ asFlags := compilerAttrs.asFlags
+ if compilerAttrs.asSrcs.IsEmpty() && sharedAttrs.Srcs_as.IsEmpty() && staticAttrs.Srcs_as.IsEmpty() {
+ // Skip asflags for BUILD file simplicity if there are no assembly sources.
+ asFlags = bazel.MakeStringListAttribute(nil)
+ }
+
attrs := &bazelCcLibraryAttributes{
Srcs: srcs,
Srcs_c: compilerAttrs.cSrcs,
@@ -308,7 +314,7 @@
Copts: compilerAttrs.copts,
Cppflags: compilerAttrs.cppFlags,
Conlyflags: compilerAttrs.conlyFlags,
- Asflags: compilerAttrs.asFlags,
+ Asflags: asFlags,
Implementation_deps: linkerAttrs.deps,
Deps: linkerAttrs.exportedDeps,
@@ -2370,6 +2376,12 @@
linkerAttrs := bp2BuildParseLinkerProps(ctx, module)
exportedIncludes := bp2BuildParseExportedIncludes(ctx, module)
+ asFlags := compilerAttrs.asFlags
+ if compilerAttrs.asSrcs.IsEmpty() {
+ // Skip asflags for BUILD file simplicity if there are no assembly sources.
+ asFlags = bazel.MakeStringListAttribute(nil)
+ }
+
attrs := &bazelCcLibraryStaticAttributes{
Copts: compilerAttrs.copts,
Srcs: compilerAttrs.srcs,
@@ -2386,7 +2398,7 @@
Srcs_c: compilerAttrs.cSrcs,
Conlyflags: compilerAttrs.conlyFlags,
Srcs_as: compilerAttrs.asSrcs,
- Asflags: compilerAttrs.asFlags,
+ Asflags: asFlags,
}
props := bazel.BazelTargetModuleProperties{