Merge changes I65b06238,I1ebef60a into main am: 29deca77ce am: 206329779d am: c2c9ee6554

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2834992

Change-Id: I1c317bf07ddd80ffc0185e311a795e1528434986
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Colin Cross
2023-11-20 21:43:26 +00:00
committed by Automerger Merge Worker
2 changed files with 12 additions and 8 deletions

View File

@@ -2210,6 +2210,14 @@ type DataPath struct {
RelativeInstallPath string
}
func (d *DataPath) ToRelativeInstallPath() string {
relPath := d.SrcPath.Rel()
if d.RelativeInstallPath != "" {
relPath = filepath.Join(d.RelativeInstallPath, relPath)
}
return relPath
}
// PathsIfNonNil returns a Paths containing only the non-nil input arguments.
func PathsIfNonNil(paths ...Path) Paths {
if len(paths) == 0 {

View File

@@ -563,13 +563,8 @@ func (a *apexBundle) buildApex(ctx android.ModuleContext) {
// Copy the test files (if any)
for _, d := range fi.dataPaths {
// TODO(eakammer): This is now the third repetition of ~this logic for test paths, refactoring should be possible
relPath := d.SrcPath.Rel()
dataPath := d.SrcPath.String()
if !strings.HasSuffix(dataPath, relPath) {
panic(fmt.Errorf("path %q does not end with %q", dataPath, relPath))
}
dataDest := imageDir.Join(ctx, fi.apexRelativePath(relPath), d.RelativeInstallPath).String()
relPath := d.ToRelativeInstallPath()
dataDest := imageDir.Join(ctx, fi.apexRelativePath(relPath)).String()
copyCommands = append(copyCommands, "cp -f "+d.SrcPath.String()+" "+dataDest)
implicitInputs = append(implicitInputs, d.SrcPath)
@@ -1095,7 +1090,8 @@ func (a *apexBundle) buildCannedFsConfig(ctx android.ModuleContext) android.Outp
if f.installDir == "bin" || strings.HasPrefix(f.installDir, "bin/") {
executablePaths = append(executablePaths, pathInApex)
for _, d := range f.dataPaths {
readOnlyPaths = append(readOnlyPaths, filepath.Join(f.installDir, d.RelativeInstallPath, d.SrcPath.Rel()))
rel := d.ToRelativeInstallPath()
readOnlyPaths = append(readOnlyPaths, filepath.Join(f.installDir, rel))
}
for _, s := range f.symlinks {
executablePaths = append(executablePaths, filepath.Join(f.installDir, s))