From 2ba19d90c30046f57c8e3f34a7f7fdc5df2bd5bf Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 7 May 2015 15:44:20 -0700 Subject: [PATCH] Add cc_benchmark module type Change-Id: I83bed375fa77518baaab4260e714a9368761f0bc --- androidbp/cmd/soong.go | 2 ++ androidmk/cmd/androidmk/android.go | 2 ++ cc/cc.go | 39 ++++++++++++++++++++++++++++++ cmd/soong_build/main.go | 2 ++ 4 files changed, 45 insertions(+) diff --git a/androidbp/cmd/soong.go b/androidbp/cmd/soong.go index 488390fec..db2707100 100644 --- a/androidbp/cmd/soong.go +++ b/androidbp/cmd/soong.go @@ -71,6 +71,8 @@ var moduleTypes = map[string]string{ "cc_binary_host": "BUILD_HOST_EXECUTABLE", "cc_test": "BUILD_NATIVE_TEST", "cc_test_host": "BUILD_HOST_NATIVE_TEST", + "cc_benchmark": "BUILD_NATIVE_BENCHMARK", + "cc_benchmark_host": "BUILD_HOST_NATIVE_BENCHMARK", "java_library": "BUILD_JAVA_LIBRARY", "java_library_static": "BUILD_STATIC_JAVA_LIBRARY", "java_library_host": "BUILD_HOST_JAVA_LIBRARY", diff --git a/androidmk/cmd/androidmk/android.go b/androidmk/cmd/androidmk/android.go index 803847309..4d928b129 100644 --- a/androidmk/cmd/androidmk/android.go +++ b/androidmk/cmd/androidmk/android.go @@ -138,6 +138,8 @@ var moduleTypes = map[string]string{ "BUILD_HOST_EXECUTABLE": "cc_binary_host", "BUILD_NATIVE_TEST": "cc_test", "BUILD_HOST_NATIVE_TEST": "cc_test_host", + "BUILD_NATIVE_BENCHMARK": "cc_benchmark", + "BUILD_HOST_NATIVE_BENCHMARK": "cc_benchmark_host", "BUILD_JAVA_LIBRARY": "java_library", "BUILD_STATIC_JAVA_LIBRARY": "java_library_static", diff --git a/cc/cc.go b/cc/cc.go index 8032fe3a7..5d72097b0 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -1481,6 +1481,36 @@ func TestPerSrcMutator(mctx blueprint.EarlyMutatorContext) { } } +type CCBenchmark struct { + CCBinary +} + +func (c *CCBenchmark) depNames(ctx common.AndroidBaseContext, depNames CCDeps) CCDeps { + depNames = c.CCBinary.depNames(ctx, depNames) + depNames.StaticLibs = append(depNames.StaticLibs, "libbenchmark") + return depNames +} + +func (c *CCBenchmark) installModule(ctx common.AndroidModuleContext, flags CCFlags) { + if ctx.Device() { + ctx.InstallFile("../data/nativetest"+ctx.Arch().ArchType.Multilib[3:]+"/"+ctx.ModuleName(), c.out) + } else { + c.CCBinary.installModule(ctx, flags) + } +} + +func NewCCBenchmark(test *CCBenchmark, module CCModuleType, + hod common.HostOrDeviceSupported, props ...interface{}) (blueprint.Module, []interface{}) { + + return NewCCBinary(&test.CCBinary, module, hod, props...) +} + +func CCBenchmarkFactory() (blueprint.Module, []interface{}) { + module := &CCBenchmark{} + + return NewCCBenchmark(module, module, common.HostAndDeviceSupported) +} + // // Static library // @@ -1545,6 +1575,15 @@ func CCTestHostFactory() (blueprint.Module, []interface{}) { &module.TestProperties) } +// +// Host Benchmarks +// + +func CCBenchmarkHostFactory() (blueprint.Module, []interface{}) { + module := &CCBenchmark{} + return NewCCBinary(&module.CCBinary, module, common.HostSupported) +} + // // Device libraries shipped with gcc // diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go index 8f5fae718..f8c32cbfa 100644 --- a/cmd/soong_build/main.go +++ b/cmd/soong_build/main.go @@ -45,6 +45,7 @@ func main() { ctx.RegisterModuleType("cc_object", cc.CCObjectFactory) ctx.RegisterModuleType("cc_binary", cc.CCBinaryFactory) ctx.RegisterModuleType("cc_test", cc.CCTestFactory) + ctx.RegisterModuleType("cc_benchmark", cc.CCBenchmarkFactory) ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory) ctx.RegisterModuleType("ndk_prebuilt_library", cc.NdkPrebuiltLibraryFactory) @@ -56,6 +57,7 @@ func main() { ctx.RegisterModuleType("cc_library_host_shared", cc.CCLibraryHostSharedFactory) ctx.RegisterModuleType("cc_binary_host", cc.CCBinaryHostFactory) ctx.RegisterModuleType("cc_test_host", cc.CCTestHostFactory) + ctx.RegisterModuleType("cc_benchmark_host", cc.CCBenchmarkHostFactory) ctx.RegisterModuleType("gensrcs", genrule.GenSrcsFactory) ctx.RegisterModuleType("genrule", genrule.GenRuleFactory)