Reland "Prevent statically linking to a lib providing stable C APIs"
This reverts commit 5b75774004f0dc26a6dfe5d62976e1d2af4bcff3.
Exempt-From-Owner-Approval: cherry-pick from internal
Bug: 151051671
Test: m
Merged-In: I05f0465976098941d47ecc06c978cfa116364d78
(cherry picked from commit af7ed39b062c534263ea3091250fd64964896e55)
Change-Id: I05f0465976098941d47ecc06c978cfa116364d78
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 5461deb..2d3f52f 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -4833,6 +4833,42 @@
}
}
+func TestNoStaticLinkingToStubsLib(t *testing.T) {
+ testApexError(t, `.*required by "mylib" is a native library providing stub.*`, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ native_shared_libs: ["mylib"],
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+
+ cc_library {
+ name: "mylib",
+ srcs: ["mylib.cpp"],
+ static_libs: ["otherlib"],
+ system_shared_libs: [],
+ stl: "none",
+ apex_available: [ "myapex" ],
+ }
+
+ cc_library {
+ name: "otherlib",
+ srcs: ["mylib.cpp"],
+ system_shared_libs: [],
+ stl: "none",
+ stubs: {
+ versions: ["1", "2", "3"],
+ },
+ apex_available: [ "myapex" ],
+ }
+ `)
+}
+
func TestMain(m *testing.M) {
run := func() int {
setUp()