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_conversion_test.go b/bp2build/cc_library_conversion_test.go
index c543ef8..407073a 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -257,24 +257,74 @@
depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build},
dir: "foo/bar",
filesystem: map[string]string{
- "foo/bar/a.cpp": "",
+ "foo/bar/both.cpp": "",
+ "foo/bar/sharedonly.cpp": "",
+ "foo/bar/staticonly.cpp": "",
"foo/bar/Android.bp": `
cc_library {
name: "a",
- shared: { whole_static_libs: ["b"] },
- static: { srcs: ["a.cpp"] },
+ srcs: ["both.cpp"],
+ cflags: ["bothflag"],
+ shared_libs: ["shared_dep_for_both"],
+ static_libs: ["static_dep_for_both"],
+ whole_static_libs: ["whole_static_lib_for_both"],
+ static: {
+ srcs: ["staticonly.cpp"],
+ cflags: ["staticflag"],
+ shared_libs: ["shared_dep_for_static"],
+ static_libs: ["static_dep_for_static"],
+ whole_static_libs: ["whole_static_lib_for_static"],
+ },
+ shared: {
+ srcs: ["sharedonly.cpp"],
+ cflags: ["sharedflag"],
+ shared_libs: ["shared_dep_for_shared"],
+ static_libs: ["static_dep_for_shared"],
+ whole_static_libs: ["whole_static_lib_for_shared"],
+ },
bazel_module: { bp2build_available: true },
}
-cc_library_static { name: "b" }
+cc_library_static { name: "static_dep_for_shared" }
+
+cc_library_static { name: "static_dep_for_static" }
+
+cc_library_static { name: "static_dep_for_both" }
+
+cc_library_static { name: "whole_static_lib_for_shared" }
+
+cc_library_static { name: "whole_static_lib_for_static" }
+
+cc_library_static { name: "whole_static_lib_for_both" }
+
+cc_library { name: "shared_dep_for_shared" }
+
+cc_library { name: "shared_dep_for_static" }
+
+cc_library { name: "shared_dep_for_both" }
`,
},
bp: soongCcLibraryPreamble,
expectedBazelTargets: []string{`cc_library(
name = "a",
- copts = ["-Ifoo/bar"],
- srcs = ["a.cpp"],
- static_deps_for_shared = [":b"],
+ copts = [
+ "bothflag",
+ "-Ifoo/bar",
+ ],
+ deps = [":static_dep_for_both"],
+ dynamic_deps = [":shared_dep_for_both"],
+ dynamic_deps_for_shared = [":shared_dep_for_shared"],
+ dynamic_deps_for_static = [":shared_dep_for_static"],
+ shared_copts = ["sharedflag"],
+ shared_srcs = ["sharedonly.cpp"],
+ srcs = ["both.cpp"],
+ static_copts = ["staticflag"],
+ static_deps_for_shared = [":static_dep_for_shared"],
+ static_deps_for_static = [":static_dep_for_static"],
+ static_srcs = ["staticonly.cpp"],
+ whole_archive_deps = [":whole_static_lib_for_both"],
+ whole_archive_deps_for_shared = [":whole_static_lib_for_shared"],
+ whole_archive_deps_for_static = [":whole_static_lib_for_static"],
)`},
},
{