Revert "Add data bin and lib properties to sh_test"
This reverts commit 91dbd520de
.
Reason for revert: Fix CLs didn't completely fix the builds.
Test: sh_binary_test.go
Bug: 156980228
Bug: 164465992
Change-Id: I1ed214c2ea6cd460db909a103c4b3a9a895ad9f7
This commit is contained in:
116
sh/sh_binary.go
116
sh/sh_binary.go
@@ -17,14 +17,11 @@ package sh
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
"github.com/google/blueprint/proptools"
|
||||
|
||||
"android/soong/android"
|
||||
"android/soong/cc"
|
||||
"android/soong/tradefed"
|
||||
)
|
||||
|
||||
@@ -91,20 +88,6 @@ type TestProperties struct {
|
||||
// doesn't exist next to the Android.bp, this attribute doesn't need to be set to true
|
||||
// explicitly.
|
||||
Auto_gen_config *bool
|
||||
|
||||
// list of binary modules that should be installed alongside the test
|
||||
Data_bins []string `android:"path,arch_variant"`
|
||||
|
||||
// list of library modules that should be installed alongside the test
|
||||
Data_libs []string `android:"path,arch_variant"`
|
||||
|
||||
// list of device binary modules that should be installed alongside the test.
|
||||
// Only available for host sh_test modules.
|
||||
Data_device_bins []string `android:"path,arch_variant"`
|
||||
|
||||
// list of device library modules that should be installed alongside the test.
|
||||
// Only available for host sh_test modules.
|
||||
Data_device_libs []string `android:"path,arch_variant"`
|
||||
}
|
||||
|
||||
type ShBinary struct {
|
||||
@@ -128,8 +111,6 @@ type ShTest struct {
|
||||
|
||||
data android.Paths
|
||||
testConfig android.Path
|
||||
|
||||
dataModules map[string]android.Path
|
||||
}
|
||||
|
||||
func (s *ShBinary) HostToolPath() android.OptionalPath {
|
||||
@@ -211,50 +192,6 @@ func (s *ShBinary) customAndroidMkEntries(entries *android.AndroidMkEntries) {
|
||||
}
|
||||
}
|
||||
|
||||
type dependencyTag struct {
|
||||
blueprint.BaseDependencyTag
|
||||
name string
|
||||
}
|
||||
|
||||
var (
|
||||
shTestDataBinsTag = dependencyTag{name: "dataBins"}
|
||||
shTestDataLibsTag = dependencyTag{name: "dataLibs"}
|
||||
shTestDataDeviceBinsTag = dependencyTag{name: "dataDeviceBins"}
|
||||
shTestDataDeviceLibsTag = dependencyTag{name: "dataDeviceLibs"}
|
||||
)
|
||||
|
||||
var sharedLibVariations = []blueprint.Variation{{Mutator: "link", Variation: "shared"}}
|
||||
|
||||
func (s *ShTest) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
s.ShBinary.DepsMutator(ctx)
|
||||
|
||||
ctx.AddFarVariationDependencies(ctx.Target().Variations(), shTestDataBinsTag, s.testProperties.Data_bins...)
|
||||
ctx.AddFarVariationDependencies(append(ctx.Target().Variations(), sharedLibVariations...),
|
||||
shTestDataLibsTag, s.testProperties.Data_libs...)
|
||||
if ctx.Target().Os.Class == android.Host && len(ctx.Config().Targets[android.Android]) > 0 {
|
||||
deviceVariations := ctx.Config().Targets[android.Android][0].Variations()
|
||||
ctx.AddFarVariationDependencies(deviceVariations, shTestDataDeviceBinsTag, s.testProperties.Data_device_bins...)
|
||||
ctx.AddFarVariationDependencies(append(deviceVariations, sharedLibVariations...),
|
||||
shTestDataDeviceLibsTag, s.testProperties.Data_device_libs...)
|
||||
} else if ctx.Target().Os.Class != android.Host {
|
||||
if len(s.testProperties.Data_device_bins) > 0 {
|
||||
ctx.PropertyErrorf("data_device_bins", "only available for host modules")
|
||||
}
|
||||
if len(s.testProperties.Data_device_libs) > 0 {
|
||||
ctx.PropertyErrorf("data_device_libs", "only available for host modules")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ShTest) addToDataModules(ctx android.ModuleContext, relPath string, path android.Path) {
|
||||
if _, exists := s.dataModules[relPath]; exists {
|
||||
ctx.ModuleErrorf("data modules have a conflicting installation path, %v - %s, %s",
|
||||
relPath, s.dataModules[relPath].String(), path.String())
|
||||
return
|
||||
}
|
||||
s.dataModules[relPath] = path
|
||||
}
|
||||
|
||||
func (s *ShTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
s.ShBinary.generateAndroidBuildActions(ctx)
|
||||
testDir := "nativetest"
|
||||
@@ -286,50 +223,6 @@ func (s *ShTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
}
|
||||
s.testConfig = tradefed.AutoGenShellTestConfig(ctx, s.testProperties.Test_config,
|
||||
s.testProperties.Test_config_template, s.testProperties.Test_suites, configs, s.testProperties.Auto_gen_config, s.outputFilePath.Base())
|
||||
|
||||
s.dataModules = make(map[string]android.Path)
|
||||
ctx.VisitDirectDeps(func(dep android.Module) {
|
||||
depTag := ctx.OtherModuleDependencyTag(dep)
|
||||
switch depTag {
|
||||
case shTestDataBinsTag, shTestDataDeviceBinsTag:
|
||||
if cc, isCc := dep.(*cc.Module); isCc {
|
||||
s.addToDataModules(ctx, cc.OutputFile().Path().Base(), cc.OutputFile().Path())
|
||||
return
|
||||
}
|
||||
property := "data_bins"
|
||||
if depTag == shTestDataDeviceBinsTag {
|
||||
property = "data_device_bins"
|
||||
}
|
||||
ctx.PropertyErrorf(property, "%q of type %q is not supported", dep.Name(), ctx.OtherModuleType(dep))
|
||||
case shTestDataLibsTag, shTestDataDeviceLibsTag:
|
||||
if cc, isCc := dep.(*cc.Module); isCc {
|
||||
// Copy to an intermediate output directory to append "lib[64]" to the path,
|
||||
// so that it's compatible with the default rpath values.
|
||||
var relPath string
|
||||
if cc.Arch().ArchType.Multilib == "lib64" {
|
||||
relPath = filepath.Join("lib64", cc.OutputFile().Path().Base())
|
||||
} else {
|
||||
relPath = filepath.Join("lib", cc.OutputFile().Path().Base())
|
||||
}
|
||||
if _, exist := s.dataModules[relPath]; exist {
|
||||
return
|
||||
}
|
||||
relocatedLib := android.PathForModuleOut(ctx, "relocated", relPath)
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
Rule: android.Cp,
|
||||
Input: cc.OutputFile().Path(),
|
||||
Output: relocatedLib,
|
||||
})
|
||||
s.addToDataModules(ctx, relPath, relocatedLib)
|
||||
return
|
||||
}
|
||||
property := "data_libs"
|
||||
if depTag == shTestDataDeviceBinsTag {
|
||||
property = "data_device_libs"
|
||||
}
|
||||
ctx.PropertyErrorf(property, "%q of type %q is not supported", dep.Name(), ctx.OtherModuleType(dep))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (s *ShTest) InstallInData() bool {
|
||||
@@ -358,15 +251,6 @@ func (s *ShTest) AndroidMkEntries() []android.AndroidMkEntries {
|
||||
path = strings.TrimSuffix(path, rel)
|
||||
entries.AddStrings("LOCAL_TEST_DATA", path+":"+rel)
|
||||
}
|
||||
relPaths := make([]string, 0)
|
||||
for relPath, _ := range s.dataModules {
|
||||
relPaths = append(relPaths, relPath)
|
||||
}
|
||||
sort.Strings(relPaths)
|
||||
for _, relPath := range relPaths {
|
||||
dir := strings.TrimSuffix(s.dataModules[relPath].String(), relPath)
|
||||
entries.AddStrings("LOCAL_TEST_DATA", dir+":"+relPath)
|
||||
}
|
||||
},
|
||||
},
|
||||
}}
|
||||
|
Reference in New Issue
Block a user