diff options
| -rw-r--r-- | cc/installer.go | 4 | ||||
| -rw-r--r-- | cc/test.go | 24 | ||||
| -rw-r--r-- | tradefed/autogen.go | 1 |
3 files changed, 29 insertions, 0 deletions
diff --git a/cc/installer.go b/cc/installer.go index 30f9612d3..d7d8c6d22 100644 --- a/cc/installer.go +++ b/cc/installer.go @@ -107,6 +107,10 @@ func (installer *baseInstaller) installTestData(ctx ModuleContext, data []androi installer.installDeps = append(installer.installDeps, installedData...) } +func (installer *baseInstaller) installStandaloneTestDep(ctx ModuleContext, standaloneTestDep android.PackagingSpec) { + installer.installTestData(ctx, []android.DataPath{{SrcPath: standaloneTestDep.ToGob().SrcPath, RelativeInstallPath: "standalone-libs"}}) +} + func (installer *baseInstaller) everInstallable() bool { // Most cc modules are installable. return true diff --git a/cc/test.go b/cc/test.go index dad4afa47..9f86c7af3 100644 --- a/cc/test.go +++ b/cc/test.go @@ -18,6 +18,7 @@ import ( "path/filepath" "strconv" + "github.com/google/blueprint/depset" "github.com/google/blueprint/proptools" "android/soong/android" @@ -128,6 +129,13 @@ type TestBinaryProperties struct { // Install the test into a folder named for the module in all test suites. Per_testcase_directory *bool + + // Install the test's dependencies into a folder named standalone-libs relative to the + // test's installation path. ld-library-path will be set to this path in the test's + // auto-generated config. This way the dependencies can be used by the test without having + // to manually install them to the device. See more details in + // go/standalone-native-device-tests. + Standalone_test *bool } func init() { @@ -380,6 +388,7 @@ func (test *testBinary) install(ctx ModuleContext, file android.Path) { TestInstallBase: testInstallBase, DeviceTemplate: "${NativeTestConfigTemplate}", HostTemplate: "${NativeHostTestConfigTemplate}", + StandaloneTest: test.Properties.Standalone_test, }) test.extraTestConfigs = android.PathsForModuleSrc(ctx, test.Properties.Test_options.Extra_test_configs) @@ -421,6 +430,21 @@ func (test *testBinary) install(ctx ModuleContext, file android.Path) { test.binaryDecorator.baseInstaller.installTestData(ctx, test.data) test.binaryDecorator.baseInstaller.install(ctx, file) + if Bool(test.Properties.Standalone_test) { + packagingSpecsBuilder := depset.NewBuilder[android.PackagingSpec](depset.TOPOLOGICAL) + + ctx.VisitDirectDeps(func(dep android.Module) { + deps := android.OtherModuleProviderOrDefault(ctx, dep, android.InstallFilesProvider) + packagingSpecsBuilder.Transitive(deps.TransitivePackagingSpecs) + }) + + for _, standaloneTestDep := range packagingSpecsBuilder.Build().ToList() { + if standaloneTestDep.ToGob().SrcPath == nil { + continue + } + test.binaryDecorator.baseInstaller.installStandaloneTestDep(ctx, standaloneTestDep) + } + } } func getTestInstallBase(useVendor bool) string { diff --git a/tradefed/autogen.go b/tradefed/autogen.go index 8dd738174..f368ce9e3 100644 --- a/tradefed/autogen.go +++ b/tradefed/autogen.go @@ -160,6 +160,7 @@ type AutoGenTestConfigOptions struct { DeviceTemplate string HostTemplate string HostUnitTestTemplate string + StandaloneTest *bool } func AutoGenTestConfig(ctx android.ModuleContext, options AutoGenTestConfigOptions) android.Path { |