Add PathForGoBinary
Add PathForGoBinary that uses pathForInstall to return the install path of a GoBinaryTool. This will replace various places that used PathForOutput to reconstruct a path to a Go tool, and will support moving Go tools to the Make install directory outside of the PathForOutput directory in a future patch. Bug: 204136549 Test: m checkbuild Change-Id: I83a3be9f5c621975540f5ed601a0b9e2611c98b9
This commit is contained in:
@@ -462,6 +462,13 @@ func (p OutputPaths) Strings() []string {
|
||||
return ret
|
||||
}
|
||||
|
||||
// PathForGoBinary returns the path to the installed location of a bootstrap_go_binary module.
|
||||
func PathForGoBinary(ctx PathContext, goBinary bootstrap.GoBinaryTool) Path {
|
||||
goBinaryInstallDir := pathForInstall(ctx, ctx.Config().BuildOS, ctx.Config().BuildArch, "bin", false)
|
||||
rel := Rel(ctx, goBinaryInstallDir.String(), goBinary.InstallPath())
|
||||
return goBinaryInstallDir.Join(ctx, rel)
|
||||
}
|
||||
|
||||
// Expands Paths to a SourceFileProducer or OutputFileProducer module dependency referenced via ":name" or ":name{.tag}" syntax.
|
||||
// If the dependency is not found, a missingErrorDependency is returned.
|
||||
// If the module dependency is not a SourceFileProducer or OutputFileProducer, appropriate errors will be returned.
|
||||
@@ -482,11 +489,8 @@ func getPathsFromModuleDep(ctx ModuleWithDepsPathContext, path, moduleName, tag
|
||||
} else if tag != "" {
|
||||
return nil, fmt.Errorf("path dependency %q is not an output file producing module", path)
|
||||
} else if goBinary, ok := module.(bootstrap.GoBinaryTool); ok {
|
||||
if rel, err := filepath.Rel(PathForOutput(ctx).String(), goBinary.InstallPath()); err == nil {
|
||||
return Paths{PathForOutput(ctx, rel).WithoutRel()}, nil
|
||||
} else {
|
||||
return nil, fmt.Errorf("cannot find output path for %q: %w", goBinary.InstallPath(), err)
|
||||
}
|
||||
goBinaryPath := PathForGoBinary(ctx, goBinary)
|
||||
return Paths{goBinaryPath}, nil
|
||||
} else if srcProducer, ok := module.(SourceFileProducer); ok {
|
||||
return srcProducer.Srcs(), nil
|
||||
} else {
|
||||
|
@@ -1454,12 +1454,7 @@ func apexFileForPyBinary(ctx android.BaseModuleContext, py *python.Module) apexF
|
||||
|
||||
func apexFileForGoBinary(ctx android.BaseModuleContext, depName string, gb bootstrap.GoBinaryTool) apexFile {
|
||||
dirInApex := "bin"
|
||||
s, err := filepath.Rel(android.PathForOutput(ctx).String(), gb.InstallPath())
|
||||
if err != nil {
|
||||
ctx.ModuleErrorf("Unable to use compiled binary at %s", gb.InstallPath())
|
||||
return apexFile{}
|
||||
}
|
||||
fileToCopy := android.PathForOutput(ctx, s)
|
||||
fileToCopy := android.PathForGoBinary(ctx, gb)
|
||||
// NB: Since go binaries are static we don't need the module for anything here, which is
|
||||
// good since the go tool is a blueprint.Module not an android.Module like we would
|
||||
// normally use.
|
||||
|
@@ -336,14 +336,9 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
}
|
||||
case bootstrap.GoBinaryTool:
|
||||
// A GoBinaryTool provides the install path to a tool, which will be copied.
|
||||
if s, err := filepath.Rel(android.PathForOutput(ctx).String(), t.InstallPath()); err == nil {
|
||||
toolPath := android.PathForOutput(ctx, s)
|
||||
tools = append(tools, toolPath)
|
||||
addLocationLabel(tag.label, toolLocation{android.Paths{toolPath}})
|
||||
} else {
|
||||
ctx.ModuleErrorf("cannot find path for %q: %v", tool, err)
|
||||
return
|
||||
}
|
||||
p := android.PathForGoBinary(ctx, t)
|
||||
tools = append(tools, p)
|
||||
addLocationLabel(tag.label, toolLocation{android.Paths{p}})
|
||||
default:
|
||||
ctx.ModuleErrorf("%q is not a host tool provider", tool)
|
||||
return
|
||||
|
Reference in New Issue
Block a user