bp2build: handle system_shared_libs
- If no system_shared_libs is specified, bp2build writes no attribute
value. In this case, the bazel library macros determine the correct
default behavior.
- If any system_shared_libs is specified for any variant, then bp2build
writes the value verbatim. This includes if an empty list is specified,
as this should override defaulting behavior.
Note this defaulting behavior is incomplete and will be incorrect in
corner cases. For example, if, in an Android.bp, system_shared_libs is
specified for os.linux_bionic but not for os.android, then the bazel
default for os.android will be incorrect. However, there are no current
modules in AOSP which fit this case.
As a related fix, supports static struct for cc_library_static.
Also, removes some elements from the bp2build denylist.
Test: mixed_droid CI
Change-Id: Iee5feeaaf05e8e7209c7a90c913173832ad7bf91
diff --git a/cc/library.go b/cc/library.go
index 8f302fc..1478a16 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -23,13 +23,12 @@
"strings"
"sync"
- "github.com/google/blueprint"
- "github.com/google/blueprint/pathtools"
-
"android/soong/android"
"android/soong/bazel"
"android/soong/bazel/cquery"
"android/soong/cc/config"
+ "github.com/google/blueprint"
+ "github.com/google/blueprint/pathtools"
)
// LibraryProperties is a collection of properties shared by cc library rules.
@@ -233,6 +232,7 @@
Implementation_deps bazel.LabelListAttribute
Dynamic_deps bazel.LabelListAttribute
Whole_archive_deps bazel.LabelListAttribute
+ System_dynamic_deps bazel.LabelListAttribute
Includes bazel.StringListAttribute
Linkopts bazel.StringListAttribute
Use_libcrt bazel.BoolAttribute
@@ -319,6 +319,7 @@
Deps: linkerAttrs.exportedDeps,
Dynamic_deps: linkerAttrs.dynamicDeps,
Whole_archive_deps: linkerAttrs.wholeArchiveDeps,
+ System_dynamic_deps: linkerAttrs.systemDynamicDeps,
Includes: exportedIncludes,
Linkopts: linkerAttrs.linkopts,
Use_libcrt: linkerAttrs.useLibcrt,
@@ -2329,6 +2330,8 @@
Implementation_deps bazel.LabelListAttribute
Deps bazel.LabelListAttribute
Whole_archive_deps bazel.LabelListAttribute
+ Dynamic_deps bazel.LabelListAttribute
+ System_dynamic_deps bazel.LabelListAttribute
Linkopts bazel.StringListAttribute
Linkstatic bool
Use_libcrt bazel.BoolAttribute
@@ -2340,6 +2343,8 @@
Conlyflags bazel.StringListAttribute
Srcs_as bazel.LabelListAttribute
Asflags bazel.StringListAttribute
+
+ Static staticOrSharedAttributes
}
type bazelCcLibraryStatic struct {
@@ -2365,12 +2370,28 @@
asFlags = bazel.MakeStringListAttribute(nil)
}
+ // Append static{} stanza properties. These won't be specified on
+ // cc_library_static itself, but may be specified in cc_defaults that this module
+ // depends on.
+ staticAttrs := bp2BuildParseStaticProps(ctx, module)
+
+ compilerAttrs.srcs.Append(staticAttrs.Srcs)
+ compilerAttrs.cSrcs.Append(staticAttrs.Srcs_c)
+ compilerAttrs.asSrcs.Append(staticAttrs.Srcs_as)
+ compilerAttrs.copts.Append(staticAttrs.Copts)
+ linkerAttrs.exportedDeps.Append(staticAttrs.Static_deps)
+ linkerAttrs.dynamicDeps.Append(staticAttrs.Dynamic_deps)
+ linkerAttrs.wholeArchiveDeps.Append(staticAttrs.Whole_archive_deps)
+ linkerAttrs.systemDynamicDeps.Append(staticAttrs.System_dynamic_deps)
+
attrs := &bazelCcLibraryStaticAttributes{
Copts: compilerAttrs.copts,
Srcs: compilerAttrs.srcs,
Implementation_deps: linkerAttrs.deps,
Deps: linkerAttrs.exportedDeps,
Whole_archive_deps: linkerAttrs.wholeArchiveDeps,
+ Dynamic_deps: linkerAttrs.dynamicDeps,
+ System_dynamic_deps: linkerAttrs.systemDynamicDeps,
Linkopts: linkerAttrs.linkopts,
Linkstatic: true,