Add support for data field in cc_benchmark.
Test: mm -j at source root; Run on blueprint with data in cc_benchmark. Change-Id: I6647fe95c96a6df27a54633f6a520a032487ca97
This commit is contained in:
@@ -88,6 +88,25 @@ func (c *Module) AndroidMk() (ret android.AndroidMkData, err error) {
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func androidMkWriteTestData(data android.Paths, ctx AndroidMkContext, ret *android.AndroidMkData) {
|
||||||
|
var testFiles []string
|
||||||
|
for _, d := range data {
|
||||||
|
rel := d.Rel()
|
||||||
|
path := d.String()
|
||||||
|
if !strings.HasSuffix(path, rel) {
|
||||||
|
panic(fmt.Errorf("path %q does not end with %q", path, rel))
|
||||||
|
}
|
||||||
|
path = strings.TrimSuffix(path, rel)
|
||||||
|
testFiles = append(testFiles, path+":"+rel)
|
||||||
|
}
|
||||||
|
if len(testFiles) > 0 {
|
||||||
|
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error {
|
||||||
|
fmt.Fprintln(w, "LOCAL_TEST_DATA := "+strings.Join(testFiles, " "))
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (library *libraryDecorator) androidMkWriteExportedFlags(w io.Writer) {
|
func (library *libraryDecorator) androidMkWriteExportedFlags(w io.Writer) {
|
||||||
exportedFlags := library.exportedFlags()
|
exportedFlags := library.exportedFlags()
|
||||||
if len(exportedFlags) > 0 {
|
if len(exportedFlags) > 0 {
|
||||||
@@ -212,6 +231,8 @@ func (benchmark *benchmarkDecorator) AndroidMk(ctx AndroidMkContext, ret *androi
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
androidMkWriteTestData(benchmark.data, ctx, ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (test *testBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
|
func (test *testBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
|
||||||
@@ -229,22 +250,7 @@ func (test *testBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkDa
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
var testFiles []string
|
androidMkWriteTestData(test.data, ctx, ret)
|
||||||
for _, d := range test.data {
|
|
||||||
rel := d.Rel()
|
|
||||||
path := d.String()
|
|
||||||
if !strings.HasSuffix(path, rel) {
|
|
||||||
panic(fmt.Errorf("path %q does not end with %q", path, rel))
|
|
||||||
}
|
|
||||||
path = strings.TrimSuffix(path, rel)
|
|
||||||
testFiles = append(testFiles, path+":"+rel)
|
|
||||||
}
|
|
||||||
if len(testFiles) > 0 {
|
|
||||||
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error {
|
|
||||||
fmt.Fprintln(w, "LOCAL_TEST_DATA := "+strings.Join(testFiles, " "))
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (test *testLibrary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
|
func (test *testLibrary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
|
||||||
|
@@ -298,6 +298,10 @@ func NewTestLibrary(hod android.HostOrDeviceSupported) *Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type BenchmarkProperties struct {
|
type BenchmarkProperties struct {
|
||||||
|
// list of files or filegroup modules that provide data that should be installed alongside
|
||||||
|
// the test
|
||||||
|
Data []string
|
||||||
|
|
||||||
// list of compatibility suites (for example "cts", "vts") that the module should be
|
// list of compatibility suites (for example "cts", "vts") that the module should be
|
||||||
// installed into.
|
// installed into.
|
||||||
Test_suites []string
|
Test_suites []string
|
||||||
@@ -306,6 +310,7 @@ type BenchmarkProperties struct {
|
|||||||
type benchmarkDecorator struct {
|
type benchmarkDecorator struct {
|
||||||
*binaryDecorator
|
*binaryDecorator
|
||||||
Properties BenchmarkProperties
|
Properties BenchmarkProperties
|
||||||
|
data android.Paths
|
||||||
}
|
}
|
||||||
|
|
||||||
func (benchmark *benchmarkDecorator) linkerInit(ctx BaseModuleContext) {
|
func (benchmark *benchmarkDecorator) linkerInit(ctx BaseModuleContext) {
|
||||||
@@ -324,12 +329,14 @@ func (benchmark *benchmarkDecorator) linkerProps() []interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (benchmark *benchmarkDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
func (benchmark *benchmarkDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
||||||
|
android.ExtractSourcesDeps(ctx, benchmark.Properties.Data)
|
||||||
deps = benchmark.binaryDecorator.linkerDeps(ctx, deps)
|
deps = benchmark.binaryDecorator.linkerDeps(ctx, deps)
|
||||||
deps.StaticLibs = append(deps.StaticLibs, "libgoogle-benchmark")
|
deps.StaticLibs = append(deps.StaticLibs, "libgoogle-benchmark")
|
||||||
return deps
|
return deps
|
||||||
}
|
}
|
||||||
|
|
||||||
func (benchmark *benchmarkDecorator) install(ctx ModuleContext, file android.Path) {
|
func (benchmark *benchmarkDecorator) install(ctx ModuleContext, file android.Path) {
|
||||||
|
benchmark.data = ctx.ExpandSources(benchmark.Properties.Data, nil)
|
||||||
benchmark.binaryDecorator.baseInstaller.dir = filepath.Join("nativetest", ctx.ModuleName())
|
benchmark.binaryDecorator.baseInstaller.dir = filepath.Join("nativetest", ctx.ModuleName())
|
||||||
benchmark.binaryDecorator.baseInstaller.dir64 = filepath.Join("nativetest64", ctx.ModuleName())
|
benchmark.binaryDecorator.baseInstaller.dir64 = filepath.Join("nativetest64", ctx.ModuleName())
|
||||||
benchmark.binaryDecorator.baseInstaller.install(ctx, file)
|
benchmark.binaryDecorator.baseInstaller.install(ctx, file)
|
||||||
|
Reference in New Issue
Block a user