VSDK: use relative install path when generating snapshots

Without respecting the relative install path, the snapshot install
path may collide when they use the same stem name.
To avoid this, respect the relative install path when generating the
snapshots.

Bug: 279652606
Test: RECOVERY_SNAPSHOT_VERSION=current m recovery-snapshot
Merged-In: Ic70a5855aeb2a6eda397b4dd06113dddb6ef70f4
Change-Id: Ic70a5855aeb2a6eda397b4dd06113dddb6ef70f4
(cherry picked from commit 17d0ee2160)
This commit is contained in:
Justin Yun
2023-05-02 14:56:38 +09:00
parent e03c3bb67c
commit 38dfc1d7c1
2 changed files with 68 additions and 2 deletions

View File

@@ -324,13 +324,13 @@ var ccSnapshotAction snapshot.GenerateSnapshotAction = func(s snapshot.SnapshotS
}
}
}
snapshotLibOut := filepath.Join(snapshotArchDir, targetArch, libType, stem)
snapshotLibOut := filepath.Join(snapshotArchDir, targetArch, libType, m.RelativeInstallPath(), stem)
ret = append(ret, copyFile(ctx, libPath, snapshotLibOut, fake))
} else {
stem = ctx.ModuleName(m)
}
propOut = filepath.Join(snapshotArchDir, targetArch, libType, stem+".json")
propOut = filepath.Join(snapshotArchDir, targetArch, libType, m.RelativeInstallPath(), stem+".json")
} else if m.Binary() {
// binary flags
prop.Symlinks = m.Symlinks()

View File

@@ -1657,3 +1657,69 @@ func TestRecoverySnapshotDirected(t *testing.T) {
}
}
}
func TestSnapshotInRelativeInstallPath(t *testing.T) {
bp := `
cc_library {
name: "libvendor_available",
vendor_available: true,
nocrt: true,
}
cc_library {
name: "libvendor_available_var",
vendor_available: true,
stem: "libvendor_available",
relative_install_path: "var",
nocrt: true,
}
`
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
config.TestProductVariables.Platform_vndk_version = StringPtr("29")
ctx := testCcWithConfig(t, config)
// Check Vendor snapshot output.
snapshotDir := "vendor-snapshot"
snapshotVariantPath := filepath.Join("out/soong", snapshotDir, "arm64")
snapshotSingleton := ctx.SingletonForTests("vendor-snapshot")
var jsonFiles []string
for _, arch := range [][]string{
[]string{"arm64", "armv8-a"},
[]string{"arm", "armv7-a-neon"},
} {
archType := arch[0]
archVariant := arch[1]
archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant)
// For shared libraries, only non-VNDK vendor_available modules are captured
sharedVariant := fmt.Sprintf("android_vendor.29_%s_%s_shared", archType, archVariant)
sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared")
sharedDirVar := filepath.Join(sharedDir, "var")
CheckSnapshot(t, ctx, snapshotSingleton, "libvendor_available", "libvendor_available.so", sharedDir, sharedVariant)
CheckSnapshot(t, ctx, snapshotSingleton, "libvendor_available_var", "libvendor_available.so", sharedDirVar, sharedVariant)
jsonFiles = append(jsonFiles,
filepath.Join(sharedDir, "libvendor_available.so.json"),
filepath.Join(sharedDirVar, "libvendor_available.so.json"))
}
for _, jsonFile := range jsonFiles {
// verify all json files exist
if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil {
t.Errorf("%q expected but not found", jsonFile)
}
}
// fake snapshot should have all outputs in the normal snapshot.
fakeSnapshotSingleton := ctx.SingletonForTests("vendor-fake-snapshot")
for _, output := range snapshotSingleton.AllOutputs() {
fakeOutput := strings.Replace(output, "/vendor-snapshot/", "/fake/vendor-snapshot/", 1)
if fakeSnapshotSingleton.MaybeOutput(fakeOutput).Rule == nil {
t.Errorf("%q expected but not found", fakeOutput)
}
}
}