Move/dedupe some host path functions in package_ctx.go.

These functions don't need a PackageContext object.

Test: m
Bug: 145934348
Change-Id: Ia1da2c76cbad292f9ca79617199b2b5b6b265568
This commit is contained in:
Martin Stjernholm
2019-12-09 21:47:14 +00:00
parent 3a7caaa80c
commit 7260d066ea
6 changed files with 23 additions and 28 deletions

View File

@@ -16,7 +16,6 @@ package android
import (
"fmt"
"runtime"
"strings"
"github.com/google/blueprint"
@@ -177,46 +176,30 @@ func (p PackageContext) SourcePathVariableWithEnvOverride(name, path, env string
// package-scoped variable's initialization.
func (p PackageContext) HostBinToolVariable(name, path string) blueprint.Variable {
return p.VariableFunc(name, func(ctx PackageVarContext) string {
return p.HostBinToolPath(ctx, path).String()
return ctx.Config().HostToolPath(ctx, path).String()
})
}
func (p PackageContext) HostBinToolPath(ctx PackageVarContext, path string) Path {
return PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "bin", path)
}
// HostJNIToolVariable returns a Variable whose value is the path to a host tool
// in the lib directory for host targets. It may only be called during a Go
// package's initialization - either from the init() function or as part of a
// package-scoped variable's initialization.
func (p PackageContext) HostJNIToolVariable(name, path string) blueprint.Variable {
return p.VariableFunc(name, func(ctx PackageVarContext) string {
return p.HostJNIToolPath(ctx, path).String()
return ctx.Config().HostJNIToolPath(ctx, path).String()
})
}
func (p PackageContext) HostJNIToolPath(ctx PackageVarContext, path string) Path {
ext := ".so"
if runtime.GOOS == "darwin" {
ext = ".dylib"
}
return PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "lib64", path+ext)
}
// HostJavaToolVariable returns a Variable whose value is the path to a host
// tool in the frameworks directory for host targets. It may only be called
// during a Go package's initialization - either from the init() function or as
// part of a package-scoped variable's initialization.
func (p PackageContext) HostJavaToolVariable(name, path string) blueprint.Variable {
return p.VariableFunc(name, func(ctx PackageVarContext) string {
return p.HostJavaToolPath(ctx, path).String()
return ctx.Config().HostJavaToolPath(ctx, path).String()
})
}
func (p PackageContext) HostJavaToolPath(ctx PackageVarContext, path string) Path {
return PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "framework", path)
}
// IntermediatesPathVariable returns a Variable whose value is the intermediate
// directory appended with the supplied path. It may only be called during a Go
// package's initialization - either from the init() function or as part of a