Reland "Prevent statically linking to a lib providing stable C APIs"

This reverts commit 5b75774004.

Exempt-From-Owner-Approval: cherry-pick from internal

Bug: 151051671
Test: m
Merged-In: I05f0465976098941d47ecc06c978cfa116364d78
(cherry picked from commit af7ed39b06)
Change-Id: I05f0465976098941d47ecc06c978cfa116364d78
This commit is contained in:
Jiyong Park
2020-05-10 15:16:24 +09:00
parent a18abc2a61
commit 7d95a510cc
3 changed files with 85 additions and 0 deletions

View File

@@ -4833,6 +4833,42 @@ func TestApexSet(t *testing.T) {
}
}
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()