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 (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -74,8 +75,11 @@ type ShBinary struct {
|
|||
|
||||
sourceFilePath Path
|
||||
outputFilePath OutputPath
|
||||
installedFile InstallPath
|
||||
}
|
||||
|
||||
var _ HostToolProvider = (*ShBinary)(nil)
|
||||
|
||||
type ShTest struct {
|
||||
ShBinary
|
||||
|
||||
|
@ -84,16 +88,16 @@ type ShTest struct {
|
|||
data Paths
|
||||
}
|
||||
|
||||
func (s *ShBinary) HostToolPath() OptionalPath {
|
||||
return OptionalPathForPath(s.installedFile)
|
||||
}
|
||||
|
||||
func (s *ShBinary) DepsMutator(ctx BottomUpMutatorContext) {
|
||||
if s.properties.Src == nil {
|
||||
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 {
|
||||
return s.outputFilePath
|
||||
}
|
||||
|
@ -110,7 +114,7 @@ func (s *ShBinary) Symlinks() []string {
|
|||
return s.properties.Symlinks
|
||||
}
|
||||
|
||||
func (s *ShBinary) GenerateAndroidBuildActions(ctx ModuleContext) {
|
||||
func (s *ShBinary) generateAndroidBuildActions(ctx ModuleContext) {
|
||||
s.sourceFilePath = PathForModuleSrc(ctx, String(s.properties.Src))
|
||||
filename := String(s.properties.Filename)
|
||||
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 {
|
||||
return []AndroidMkEntries{AndroidMkEntries{
|
||||
Class: "EXECUTABLES",
|
||||
|
@ -158,11 +168,26 @@ func (s *ShBinary) customAndroidMkEntries(entries *AndroidMkEntries) {
|
|||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
func (s *ShTest) InstallInData() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (s *ShTest) AndroidMkEntries() []AndroidMkEntries {
|
||||
return []AndroidMkEntries{AndroidMkEntries{
|
||||
Class: "NATIVE_TESTS",
|
||||
|
|
Loading…
Reference in New Issue