Merge changes I65b06238,I1ebef60a into main

* changes:
  Add DataPath.ToRelativeInstallPath
  Change deps of ctx.Install* from Paths to InstallPaths
This commit is contained in:
Colin Cross
2023-11-20 19:38:57 +00:00
committed by Gerrit Code Review
9 changed files with 31 additions and 27 deletions

View File

@@ -114,7 +114,7 @@ type ModuleContext interface {
// installed file will be returned by PackagingSpecs() on this module or by
// TransitivePackagingSpecs() on modules that depend on this module through dependency tags
// for which IsInstallDepNeeded returns true.
InstallExecutable(installPath InstallPath, name string, srcPath Path, deps ...Path) InstallPath
InstallExecutable(installPath InstallPath, name string, srcPath Path, deps ...InstallPath) InstallPath
// InstallFile creates a rule to copy srcPath to name in the installPath directory,
// with the given additional dependencies.
@@ -123,7 +123,7 @@ type ModuleContext interface {
// installed file will be returned by PackagingSpecs() on this module or by
// TransitivePackagingSpecs() on modules that depend on this module through dependency tags
// for which IsInstallDepNeeded returns true.
InstallFile(installPath InstallPath, name string, srcPath Path, deps ...Path) InstallPath
InstallFile(installPath InstallPath, name string, srcPath Path, deps ...InstallPath) InstallPath
// InstallFileWithExtraFilesZip creates a rule to copy srcPath to name in the installPath
// directory, and also unzip a zip file containing extra files to install into the same
@@ -133,7 +133,7 @@ type ModuleContext interface {
// installed file will be returned by PackagingSpecs() on this module or by
// TransitivePackagingSpecs() on modules that depend on this module through dependency tags
// for which IsInstallDepNeeded returns true.
InstallFileWithExtraFilesZip(installPath InstallPath, name string, srcPath Path, extraZip Path, deps ...Path) InstallPath
InstallFileWithExtraFilesZip(installPath InstallPath, name string, srcPath Path, extraZip Path, deps ...InstallPath) InstallPath
// InstallSymlink creates a rule to create a symlink from src srcPath to name in the installPath
// directory.
@@ -451,17 +451,17 @@ func (m *moduleContext) skipInstall() bool {
}
func (m *moduleContext) InstallFile(installPath InstallPath, name string, srcPath Path,
deps ...Path) InstallPath {
deps ...InstallPath) InstallPath {
return m.installFile(installPath, name, srcPath, deps, false, nil)
}
func (m *moduleContext) InstallExecutable(installPath InstallPath, name string, srcPath Path,
deps ...Path) InstallPath {
deps ...InstallPath) InstallPath {
return m.installFile(installPath, name, srcPath, deps, true, nil)
}
func (m *moduleContext) InstallFileWithExtraFilesZip(installPath InstallPath, name string, srcPath Path,
extraZip Path, deps ...Path) InstallPath {
extraZip Path, deps ...InstallPath) InstallPath {
return m.installFile(installPath, name, srcPath, deps, false, &extraFilesZip{
zip: extraZip,
dir: installPath,
@@ -487,23 +487,23 @@ func (m *moduleContext) packageFile(fullInstallPath InstallPath, srcPath Path, e
return spec
}
func (m *moduleContext) installFile(installPath InstallPath, name string, srcPath Path, deps []Path,
func (m *moduleContext) installFile(installPath InstallPath, name string, srcPath Path, deps []InstallPath,
executable bool, extraZip *extraFilesZip) InstallPath {
fullInstallPath := installPath.Join(m, name)
m.module.base().hooks.runInstallHooks(m, srcPath, fullInstallPath, false)
if !m.skipInstall() {
deps = append(deps, InstallPaths(m.module.base().installFilesDepSet.ToList()).Paths()...)
deps = append(deps, InstallPaths(m.module.base().installFilesDepSet.ToList())...)
var implicitDeps, orderOnlyDeps Paths
if m.Host() {
// Installed host modules might be used during the build, depend directly on their
// dependencies so their timestamp is updated whenever their dependency is updated
implicitDeps = deps
implicitDeps = InstallPaths(deps).Paths()
} else {
orderOnlyDeps = deps
orderOnlyDeps = InstallPaths(deps).Paths()
}
if m.Config().KatiEnabled() {

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

@@ -1890,7 +1890,7 @@ func (a *apexBundle) ProcessBazelQueryResponse(ctx android.ModuleContext) {
installSuffix = imageCapexSuffix
}
a.installedFile = ctx.InstallFile(a.installDir, a.Name()+installSuffix, a.outputFile,
a.compatSymlinks.Paths()...)
a.compatSymlinks...)
// filesInfo in mixed mode must retrieve all information about the apex's
// contents completely from the Starlark providers. It should never rely on

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)
@@ -956,7 +951,7 @@ func (a *apexBundle) buildApex(ctx android.ModuleContext) {
// Install to $OUT/soong/{target,host}/.../apex.
a.installedFile = ctx.InstallFile(a.installDir, a.Name()+installSuffix, a.outputFile,
a.compatSymlinks.Paths()...)
a.compatSymlinks...)
// installed-files.txt is dist'ed
a.installedFilesFile = a.buildInstalledFilesFile(ctx, a.outputFile, imageDir)
@@ -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))

View File

@@ -794,7 +794,7 @@ func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
if p.installable() {
p.installedFile = ctx.InstallFile(p.installDir, p.installFilename, p.inputApex, p.compatSymlinks.Paths()...)
p.installedFile = ctx.InstallFile(p.installDir, p.installFilename, p.inputApex, p.compatSymlinks...)
p.provenanceMetaDataFile = provenance.GenerateArtifactProvenanceMetaData(ctx, p.inputApex, p.installedFile)
}
}

View File

@@ -869,7 +869,7 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
ctx.InstallFile(allowlistInstallPath, allowlistInstallFilename, a.privAppAllowlist.Path())
}
var extraInstalledPaths android.Paths
var extraInstalledPaths android.InstallPaths
for _, extra := range a.extraOutputFiles {
installed := ctx.InstallFile(a.installDir, extra.Base(), extra)
extraInstalledPaths = append(extraInstalledPaths, installed)

View File

@@ -641,7 +641,7 @@ type Library struct {
exportedProguardFlagFiles android.Paths
InstallMixin func(ctx android.ModuleContext, installPath android.Path) (extraInstallDeps android.Paths)
InstallMixin func(ctx android.ModuleContext, installPath android.Path) (extraInstallDeps android.InstallPaths)
}
var _ android.ApexModule = (*Library)(nil)
@@ -722,7 +722,7 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
exclusivelyForApex := !apexInfo.IsForPlatform()
if (Bool(j.properties.Installable) || ctx.Host()) && !exclusivelyForApex {
var extraInstallDeps android.Paths
var extraInstallDeps android.InstallPaths
if j.InstallMixin != nil {
extraInstallDeps = j.InstallMixin(ctx, j.outputFile)
}

View File

@@ -226,7 +226,7 @@ func (r *robolectricTest) GenerateAndroidBuildActions(ctx android.ModuleContext)
}
installPath := android.PathForModuleInstall(ctx, r.BaseModuleName())
var installDeps android.Paths
var installDeps android.InstallPaths
if r.manifest != nil {
r.data = append(r.data, r.manifest)

View File

@@ -30,8 +30,8 @@ func tradefedJavaLibraryFactory() android.Module {
return module
}
func tradefedJavaLibraryInstall(ctx android.ModuleContext, path android.Path) android.Paths {
func tradefedJavaLibraryInstall(ctx android.ModuleContext, path android.Path) android.InstallPaths {
installedPath := ctx.InstallFile(android.PathForModuleInstall(ctx, "tradefed"),
ctx.ModuleName()+".jar", path)
return android.Paths{installedPath}
return android.InstallPaths{installedPath}
}