Support data properties for test binaries

Allow tests to specify a data property that lists files or filegroup
modules that will be packaged alongside the test.  Also add a path
property to filegroup modules to allow shifting the path of the
packaged files, and add ExpandSourcesSubDir to expand the filegroup
sources while including a shifted relative path in the Paths objects.

Test: soong tests, manually adding data to a module
Change-Id: I52a48942660e12755d313ef13279313361b4fc35
This commit is contained in:
Colin Cross
2017-02-01 14:12:44 -08:00
parent 294941bee9
commit faeb7aa135
7 changed files with 289 additions and 15 deletions

View File

@@ -19,9 +19,8 @@ import (
"runtime"
"strings"
"github.com/google/blueprint"
"android/soong/android"
"github.com/google/blueprint"
)
type TestProperties struct {
@@ -38,6 +37,10 @@ type TestBinaryProperties struct {
// relative_install_path. Useful if several tests need to be in the same
// directory, but test_per_src doesn't work.
No_named_install_directory *bool
// list of files or filegroup modules that provide data that should be installed alongside
// the test
Data []string
}
func init() {
@@ -191,6 +194,7 @@ type testBinary struct {
*binaryDecorator
*baseCompiler
Properties TestBinaryProperties
data android.Paths
}
func (test *testBinary) linkerProps() []interface{} {
@@ -205,6 +209,8 @@ func (test *testBinary) linkerInit(ctx BaseModuleContext) {
}
func (test *testBinary) linkerDeps(ctx DepsContext, deps Deps) Deps {
android.ExtractSourcesDeps(ctx, test.Properties.Data)
deps = test.testDecorator.linkerDeps(ctx, deps)
deps = test.binaryDecorator.linkerDeps(ctx, deps)
return deps
@@ -217,6 +223,8 @@ func (test *testBinary) linkerFlags(ctx ModuleContext, flags Flags) Flags {
}
func (test *testBinary) install(ctx ModuleContext, file android.Path) {
test.data = ctx.ExpandSources(test.Properties.Data, nil)
test.binaryDecorator.baseInstaller.dir = "nativetest"
test.binaryDecorator.baseInstaller.dir64 = "nativetest64"