Make sh_binary a HostToolProvider
sh_binary modules should implement HostToolProvider so that they can be used in genrules. Install the script and then return the installed path. Also remove the unused SourceFilePath method. Bug: 122332855 Fixes: 146496647 Test: m checkbuild Change-Id: I191ce4eef1d50ac0b6a296b819feec6d6a18e753
This commit is contained in:
parent
a03edbeddc
commit
7c7c11445b
|
@ -16,6 +16,7 @@ package android
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -74,8 +75,11 @@ type ShBinary struct {
|
||||||
|
|
||||||
sourceFilePath Path
|
sourceFilePath Path
|
||||||
outputFilePath OutputPath
|
outputFilePath OutputPath
|
||||||
|
installedFile InstallPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ HostToolProvider = (*ShBinary)(nil)
|
||||||
|
|
||||||
type ShTest struct {
|
type ShTest struct {
|
||||||
ShBinary
|
ShBinary
|
||||||
|
|
||||||
|
@ -84,16 +88,16 @@ type ShTest struct {
|
||||||
data Paths
|
data Paths
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *ShBinary) HostToolPath() OptionalPath {
|
||||||
|
return OptionalPathForPath(s.installedFile)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *ShBinary) DepsMutator(ctx BottomUpMutatorContext) {
|
func (s *ShBinary) DepsMutator(ctx BottomUpMutatorContext) {
|
||||||
if s.properties.Src == nil {
|
if s.properties.Src == nil {
|
||||||
ctx.PropertyErrorf("src", "missing prebuilt source file")
|
ctx.PropertyErrorf("src", "missing prebuilt source file")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ShBinary) SourceFilePath(ctx ModuleContext) Path {
|
|
||||||
return PathForModuleSrc(ctx, String(s.properties.Src))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *ShBinary) OutputFile() OutputPath {
|
func (s *ShBinary) OutputFile() OutputPath {
|
||||||
return s.outputFilePath
|
return s.outputFilePath
|
||||||
}
|
}
|
||||||
|
@ -110,7 +114,7 @@ func (s *ShBinary) Symlinks() []string {
|
||||||
return s.properties.Symlinks
|
return s.properties.Symlinks
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ShBinary) GenerateAndroidBuildActions(ctx ModuleContext) {
|
func (s *ShBinary) generateAndroidBuildActions(ctx ModuleContext) {
|
||||||
s.sourceFilePath = PathForModuleSrc(ctx, String(s.properties.Src))
|
s.sourceFilePath = PathForModuleSrc(ctx, String(s.properties.Src))
|
||||||
filename := String(s.properties.Filename)
|
filename := String(s.properties.Filename)
|
||||||
filename_from_src := Bool(s.properties.Filename_from_src)
|
filename_from_src := Bool(s.properties.Filename_from_src)
|
||||||
|
@ -135,6 +139,12 @@ func (s *ShBinary) GenerateAndroidBuildActions(ctx ModuleContext) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *ShBinary) GenerateAndroidBuildActions(ctx ModuleContext) {
|
||||||
|
s.generateAndroidBuildActions(ctx)
|
||||||
|
installDir := PathForModuleInstall(ctx, "bin", String(s.properties.Sub_dir))
|
||||||
|
s.installedFile = ctx.InstallExecutable(installDir, s.outputFilePath.Base(), s.outputFilePath)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *ShBinary) AndroidMkEntries() []AndroidMkEntries {
|
func (s *ShBinary) AndroidMkEntries() []AndroidMkEntries {
|
||||||
return []AndroidMkEntries{AndroidMkEntries{
|
return []AndroidMkEntries{AndroidMkEntries{
|
||||||
Class: "EXECUTABLES",
|
Class: "EXECUTABLES",
|
||||||
|
@ -158,11 +168,26 @@ func (s *ShBinary) customAndroidMkEntries(entries *AndroidMkEntries) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ShTest) GenerateAndroidBuildActions(ctx ModuleContext) {
|
func (s *ShTest) GenerateAndroidBuildActions(ctx ModuleContext) {
|
||||||
s.ShBinary.GenerateAndroidBuildActions(ctx)
|
s.ShBinary.generateAndroidBuildActions(ctx)
|
||||||
|
testDir := "nativetest"
|
||||||
|
if ctx.Target().Arch.ArchType.Multilib == "lib64" {
|
||||||
|
testDir = "nativetest64"
|
||||||
|
}
|
||||||
|
if ctx.Target().NativeBridge == NativeBridgeEnabled {
|
||||||
|
testDir = filepath.Join(testDir, ctx.Target().NativeBridgeRelativePath)
|
||||||
|
} else if !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
|
||||||
|
testDir = filepath.Join(testDir, ctx.Arch().ArchType.String())
|
||||||
|
}
|
||||||
|
installDir := PathForModuleInstall(ctx, testDir, String(s.properties.Sub_dir))
|
||||||
|
s.installedFile = ctx.InstallExecutable(installDir, s.outputFilePath.Base(), s.outputFilePath)
|
||||||
|
|
||||||
s.data = PathsForModuleSrc(ctx, s.testProperties.Data)
|
s.data = PathsForModuleSrc(ctx, s.testProperties.Data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *ShTest) InstallInData() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (s *ShTest) AndroidMkEntries() []AndroidMkEntries {
|
func (s *ShTest) AndroidMkEntries() []AndroidMkEntries {
|
||||||
return []AndroidMkEntries{AndroidMkEntries{
|
return []AndroidMkEntries{AndroidMkEntries{
|
||||||
Class: "NATIVE_TESTS",
|
Class: "NATIVE_TESTS",
|
||||||
|
|
Loading…
Reference in New Issue