Merge "Fix and test vendor public libraries for product modules"
diff --git a/cc/cc.go b/cc/cc.go
index 98df545..260fcf1 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -2070,8 +2070,6 @@
nonvariantLibs = append(nonvariantLibs, rewriteSnapshotLib(entry, getSnapshot().SharedLibs))
} else if ctx.useSdk() && inList(name, *getNDKKnownLibs(ctx.Config())) {
variantLibs = append(variantLibs, name+ndkLibrarySuffix)
- } else if ctx.useVndk() {
- nonvariantLibs = append(nonvariantLibs, rewriteSnapshotLib(entry, getSnapshot().SharedLibs))
} else if (ctx.Platform() || ctx.ProductSpecific()) && inList(name, *vendorPublicLibraries) {
vendorPublicLib := name + vendorPublicLibrarySuffix
if actx.OtherModuleExists(vendorPublicLib) {
@@ -2082,6 +2080,8 @@
// link to the original library.
nonvariantLibs = append(nonvariantLibs, name)
}
+ } else if ctx.useVndk() {
+ nonvariantLibs = append(nonvariantLibs, rewriteSnapshotLib(entry, getSnapshot().SharedLibs))
} else {
// put name#version back
nonvariantLibs = append(nonvariantLibs, entry)
diff --git a/cc/vendor_public_library.go b/cc/vendor_public_library.go
index 85f514c..394e322 100644
--- a/cc/vendor_public_library.go
+++ b/cc/vendor_public_library.go
@@ -155,6 +155,7 @@
module.AddProperties(
&stub.Properties,
+ &module.VendorProperties,
&library.MutatedProperties,
&library.flagExporter.Properties)
diff --git a/cc/vendor_public_library_test.go b/cc/vendor_public_library_test.go
index ee9dc00..9f2accf 100644
--- a/cc/vendor_public_library_test.go
+++ b/cc/vendor_public_library_test.go
@@ -23,10 +23,12 @@
ctx := testCc(t, `
cc_library_headers {
name: "libvendorpublic_headers",
+ product_available: true,
export_include_dirs: ["my_include"],
}
vendor_public_library {
name: "libvendorpublic",
+ product_available: true,
symbol_file: "",
export_public_headers: ["libvendorpublic_headers"],
}
@@ -47,6 +49,14 @@
nocrt: true,
}
cc_library {
+ name: "libproduct",
+ shared_libs: ["libvendorpublic"],
+ product_specific: true,
+ srcs: ["foo.c"],
+ no_libcrt: true,
+ nocrt: true,
+ }
+ cc_library {
name: "libvendor",
shared_libs: ["libvendorpublic"],
vendor: true,
@@ -58,6 +68,7 @@
coreVariant := "android_arm64_armv8-a_shared"
vendorVariant := "android_vendor.29_arm64_armv8-a_shared"
+ productVariant := "android_product.29_arm64_armv8-a_shared"
// test if header search paths are correctly added
// _static variant is used since _shared reuses *.o from the static variant
@@ -75,6 +86,14 @@
t.Errorf("libflags for libsystem must contain %#v, but was %#v", stubPaths[0], libflags)
}
+ // test if libsystem is linked to the stub
+ ld = ctx.ModuleForTests("libproduct", productVariant).Rule("ld")
+ libflags = ld.Args["libFlags"]
+ stubPaths = getOutputPaths(ctx, productVariant, []string{"libvendorpublic" + vendorPublicLibrarySuffix})
+ if !strings.Contains(libflags, stubPaths[0].String()) {
+ t.Errorf("libflags for libproduct must contain %#v, but was %#v", stubPaths[0], libflags)
+ }
+
// test if libvendor is linked to the real shared lib
ld = ctx.ModuleForTests("libvendor", vendorVariant).Rule("ld")
libflags = ld.Args["libFlags"]
@@ -82,5 +101,4 @@
if !strings.Contains(libflags, stubPaths[0].String()) {
t.Errorf("libflags for libvendor must contain %#v, but was %#v", stubPaths[0], libflags)
}
-
}