aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Yun <justinyun@google.com>2023-05-08 21:06:59 +0900
committerJustin Yun <justinyun@google.com>2023-05-09 07:48:33 +0000
commit6bd266b3ec571d02d062e0d1d896123a434bc1d8 (patch)
tree55ea5996338e13e78ec69e009abf3a18ce2ec6be
parentc21c1e4dbf56cf8a3fb95bdd6a71132dbb23d25a (diff)
downloadsoong-6bd266b3ec571d02d062e0d1d896123a434bc1d8.tar.gz
APEX can use any Prebuilt libraries
Vendor snapshot libraries generated from prebuilt libraries set "apex_inherit" to their min_sdk_version property to allow them to be used by vendor APEXes. Bug: 277403349 Test: m vendor-snapshot Merged-In: Idd9e5f8e94b3fa2adf47a04507bf0c50c59edfb7 Change-Id: Idd9e5f8e94b3fa2adf47a04507bf0c50c59edfb7 (cherry picked from commit 3cc7846b5887c130ba5ccb5a8f77d8a1a7358ab2)
-rw-r--r--cc/vendor_snapshot.go6
-rw-r--r--cc/vendor_snapshot_test.go15
2 files changed, 20 insertions, 1 deletions
diff --git a/cc/vendor_snapshot.go b/cc/vendor_snapshot.go
index e6e566025..22bf3bf91 100644
--- a/cc/vendor_snapshot.go
+++ b/cc/vendor_snapshot.go
@@ -250,7 +250,11 @@ var ccSnapshotAction snapshot.GenerateSnapshotAction = func(s snapshot.SnapshotS
for _, path := range m.VintfFragments() {
prop.VintfFragments = append(prop.VintfFragments, filepath.Join("configs", path.Base()))
}
- prop.MinSdkVersion = m.MinSdkVersion()
+ if m.IsPrebuilt() {
+ prop.MinSdkVersion = "apex_inherit"
+ } else {
+ prop.MinSdkVersion = m.MinSdkVersion()
+ }
// install config files. ignores any duplicates.
for _, path := range append(m.InitRc(), m.VintfFragments()...) {
diff --git a/cc/vendor_snapshot_test.go b/cc/vendor_snapshot_test.go
index 619500e1d..aa9963301 100644
--- a/cc/vendor_snapshot_test.go
+++ b/cc/vendor_snapshot_test.go
@@ -23,6 +23,17 @@ import (
"testing"
)
+func checkJsonContents(t *testing.T, ctx android.TestingSingleton, jsonPath string, key string, value string) {
+ jsonOut := ctx.MaybeOutput(jsonPath)
+ if jsonOut.Rule == nil {
+ t.Errorf("%q expected but not found", jsonPath)
+ return
+ }
+ if !strings.Contains(jsonOut.Args["content"], fmt.Sprintf("%q:%q", key, value)) {
+ t.Errorf("%q must include %q:%q but it only has %v", jsonPath, key, value, jsonOut.Args["content"])
+ }
+}
+
func TestVendorSnapshotCapture(t *testing.T) {
bp := `
cc_library {
@@ -52,6 +63,7 @@ func TestVendorSnapshotCapture(t *testing.T) {
name: "libvendor_available",
vendor_available: true,
nocrt: true,
+ min_sdk_version: "29",
}
cc_library_headers {
@@ -155,6 +167,9 @@ func TestVendorSnapshotCapture(t *testing.T) {
filepath.Join(staticDir, "libvendor_available.a.json"),
filepath.Join(staticDir, "libvendor_available.cfi.a.json"))
+ checkJsonContents(t, snapshotSingleton, filepath.Join(staticDir, "libb.a.json"), "MinSdkVersion", "apex_inherit")
+ checkJsonContents(t, snapshotSingleton, filepath.Join(staticDir, "libvendor_available.a.json"), "MinSdkVersion", "29")
+
// For binary executables, all vendor:true and vendor_available modules are captured.
if archType == "arm64" {
binaryVariant := fmt.Sprintf("android_vendor.29_%s_%s", archType, archVariant)