Merge "Make sh_binary a HostToolProvider"
am: 35a261de1f
Change-Id: I86da4e323d06c6c82232a15be3ce0b9fdebde6d9
This commit is contained in:
commit
00b8468d9c
1 changed files with 31 additions and 6 deletions
|
@ -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 a new issue