Add DataPath.ToRelativeInstallPath
Add a method to DataPath that converts it to the relative install path in preparation for adding additional complexity to DataPath. Bug: 311428265 Test: builds Change-Id: I65b06238aafda2db72c6a253744a3087976451cd
This commit is contained in:
@@ -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 {
|
||||
|
@@ -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))
|
||||
|
Reference in New Issue
Block a user