Handle cc_library shared/static only properties
Also handle whole_static_libs via a different attribute
(whole_archive_deps), separating these dependencies from regular static
deps.
Test: Build //bionic/libdl with bazel in conjunction with bzl
changes
Change-Id: I45019b6127a0d2731592ec35537ca15e77001cc2
diff --git a/bp2build/cc_library_static_conversion_test.go b/bp2build/cc_library_static_conversion_test.go
index bff9b07..d082db1 100644
--- a/bp2build/cc_library_static_conversion_test.go
+++ b/bp2build/cc_library_static_conversion_test.go
@@ -189,8 +189,6 @@
":header_lib_2",
":static_lib_1",
":static_lib_2",
- ":whole_static_lib_1",
- ":whole_static_lib_2",
],
includes = [
"export_include_dir_1",
@@ -201,6 +199,10 @@
"foo_static1.cc",
"foo_static2.cc",
],
+ whole_archive_deps = [
+ ":whole_static_lib_1",
+ ":whole_static_lib_2",
+ ],
)`, `cc_library_static(
name = "static_lib_1",
copts = ["-I."],
@@ -423,13 +425,14 @@
name = "foo_static",
copts = ["-I."],
deps = select({
- "//build/bazel/platforms/arch:arm64": [
- ":static_dep",
- ":static_dep2",
- ],
+ "//build/bazel/platforms/arch:arm64": [":static_dep"],
"//conditions:default": [],
}),
linkstatic = True,
+ whole_archive_deps = select({
+ "//build/bazel/platforms/arch:arm64": [":static_dep2"],
+ "//conditions:default": [],
+ }),
)`, `cc_library_static(
name = "static_dep",
copts = ["-I."],
@@ -458,13 +461,14 @@
name = "foo_static",
copts = ["-I."],
deps = select({
- "//build/bazel/platforms/os:android": [
- ":static_dep",
- ":static_dep2",
- ],
+ "//build/bazel/platforms/os:android": [":static_dep"],
"//conditions:default": [],
}),
linkstatic = True,
+ whole_archive_deps = select({
+ "//build/bazel/platforms/os:android": [":static_dep2"],
+ "//conditions:default": [],
+ }),
)`, `cc_library_static(
name = "static_dep",
copts = ["-I."],
@@ -497,10 +501,7 @@
expectedBazelTargets: []string{`cc_library_static(
name = "foo_static",
copts = ["-I."],
- deps = [
- ":static_dep",
- ":static_dep2",
- ] + select({
+ deps = [":static_dep"] + select({
"//build/bazel/platforms/arch:arm64": [":static_dep4"],
"//conditions:default": [],
}) + select({
@@ -508,6 +509,7 @@
"//conditions:default": [],
}),
linkstatic = True,
+ whole_archive_deps = [":static_dep2"],
)`, `cc_library_static(
name = "static_dep",
copts = ["-I."],
@@ -732,8 +734,7 @@
cc_library_static { name: "static_dep" }
cc_library_static {
name: "foo_static",
- static_libs: ["static_dep"],
- whole_static_libs: ["static_dep"],
+ static_libs: ["static_dep", "static_dep"],
}`,
expectedBazelTargets: []string{`cc_library_static(
name = "foo_static",