Error if vendor apex adds an LLNDK library
This is a common mistake when creating a vendor apex. They often try to
list all dependencies. Adding an LLNDK results in putting a stub library
in APEX, which simply doesn't work.
This change prevents stubs from being added to APEX.
Bug: 314033460
Test: go test ./apex
Change-Id: Ic3365047028d9ab6f06992d52aece5a3890177bb
diff --git a/apex/apex_test.go b/apex/apex_test.go
index f14ab8a..2f6acff 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -26,6 +26,7 @@
"testing"
"android/soong/aconfig/codegen"
+
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -960,6 +961,32 @@
ensureListContains(t, names(apexManifestRule.Args["requireNativeLibs"]), "libfoo.shared_from_rust.so")
}
+func TestApexShouldNotEmbedStubVariant(t *testing.T) {
+ testApexError(t, `module "myapex" .*: native_shared_libs: "libbar" is a stub`, `
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ vendor: true,
+ updatable: false,
+ native_shared_libs: ["libbar"], // should not add an LLNDK stub in a vendor apex
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+
+ cc_library {
+ name: "libbar",
+ srcs: ["mylib.cpp"],
+ llndk: {
+ symbol_file: "libbar.map.txt",
+ }
+ }
+ `)
+}
+
func TestApexCanUsePrivateApis(t *testing.T) {
ctx := testApex(t, `
apex {