diff --git a/cc/vendor_snapshot.go b/cc/vendor_snapshot.go index 51f23c57e..d2531c03d 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 5b69a10be..c5431b3d3 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)