diff options
author | 2021-11-04 14:09:38 -0400 | |
---|---|---|
committer | 2021-11-15 17:18:42 -0500 | |
commit | 4e5f07d27ba2e8ae460457a5a977478b9b2c96eb (patch) | |
tree | bc60672c4224d020a36995bf8d641ac84602af2c /rust/test.go | |
parent | 8d10fc39afdda6a9c3f27f3ed0999db9c8c2199a (diff) |
rust: Add data_libs and data_bins to rust_test
Allows defining data binaries and libraries that should be installed
alongside a rust_test module, similar to cc_test.
This refactors cc_test as well so it can define rust_ffi_shared and
rust_binary modules as data.
Bug: 171710847
Test: New Soong tests pass.
Test: Example module installs data appropriately.
Change-Id: I0b56098fb475ec54f9b7a761220d260fe68cbee1
Diffstat (limited to 'rust/test.go')
-rw-r--r-- | rust/test.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/rust/test.go b/rust/test.go index 56da509b5..021ead0f6 100644 --- a/rust/test.go +++ b/rust/test.go @@ -18,6 +18,7 @@ import ( "github.com/google/blueprint/proptools" "android/soong/android" + "android/soong/cc" "android/soong/tradefed" ) @@ -49,6 +50,12 @@ type TestProperties struct { // the test Data []string `android:"path,arch_variant"` + // list of shared library modules that should be installed alongside the test + Data_libs []string `android:"arch_variant"` + + // list of binary modules that should be installed alongside the test + Data_bins []string `android:"arch_variant"` + // Flag to indicate whether or not to create test config automatically. If AndroidTest.xml // doesn't exist next to the Android.bp, this attribute doesn't need to be set to true // explicitly. @@ -137,6 +144,32 @@ func (test *testDecorator) install(ctx ModuleContext) { dataSrcPaths := android.PathsForModuleSrc(ctx, test.Properties.Data) + ctx.VisitDirectDepsWithTag(dataLibDepTag, func(dep android.Module) { + depName := ctx.OtherModuleName(dep) + linkableDep, ok := dep.(cc.LinkableInterface) + if !ok { + ctx.ModuleErrorf("data_lib %q is not a linkable module", depName) + } + if linkableDep.OutputFile().Valid() { + test.data = append(test.data, + android.DataPath{SrcPath: linkableDep.OutputFile().Path(), + RelativeInstallPath: linkableDep.RelativeInstallPath()}) + } + }) + + ctx.VisitDirectDepsWithTag(dataBinDepTag, func(dep android.Module) { + depName := ctx.OtherModuleName(dep) + linkableDep, ok := dep.(cc.LinkableInterface) + if !ok { + ctx.ModuleErrorf("data_bin %q is not a linkable module", depName) + } + if linkableDep.OutputFile().Valid() { + test.data = append(test.data, + android.DataPath{SrcPath: linkableDep.OutputFile().Path(), + RelativeInstallPath: linkableDep.RelativeInstallPath()}) + } + }) + for _, dataSrcPath := range dataSrcPaths { test.data = append(test.data, android.DataPath{SrcPath: dataSrcPath}) } @@ -194,5 +227,8 @@ func (test *testDecorator) compilerDeps(ctx DepsContext, deps Deps) Deps { deps.Rustlibs = append(deps.Rustlibs, "libtest") + deps.DataLibs = append(deps.DataLibs, test.Properties.Data_libs...) + deps.DataBins = append(deps.DataBins, test.Properties.Data_bins...) + return deps } |