From 0b24c74fcbb37628f2e6f9eb54d82586a27d41dc Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Tue, 4 Oct 2016 15:13:37 -0700 Subject: [PATCH] Disable cc_benchmark for Darwin hosts The google-benchmark library is disabled on Darwin, so we cannot create host benchmarks. Instead of having every user specify this, put the logic in Soong. Then if we decide to support it later, it's an easier switch. Test: build.ninja identical before/after on Linux Test: Ignores failing cc_benchmark_host on Darwin Change-Id: I61f3a571fd160d8e479a512992bc68601f1c9b28 --- android/arch.go | 6 +++--- android/module.go | 7 +++++++ cc/test.go | 11 +++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/android/arch.go b/android/arch.go index 7ccd003bd..606de48bd 100644 --- a/android/arch.go +++ b/android/arch.go @@ -267,12 +267,12 @@ func ArchMutator(mctx BottomUpMutatorContext) { return } - osClasses := module.base().OsClassSupported() - - if len(osClasses) == 0 { + if !module.base().ArchSpecific() { return } + osClasses := module.base().OsClassSupported() + var moduleTargets []Target primaryModules := make(map[int]bool) diff --git a/android/module.go b/android/module.go index f815ced7f..00219aec6 100644 --- a/android/module.go +++ b/android/module.go @@ -152,6 +152,7 @@ type commonProperties struct { // Set by InitAndroidModule HostOrDeviceSupported HostOrDeviceSupported `blueprint:"mutated"` + ArchSpecific bool `blueprint:"mutated"` } type hostAndDeviceProperties struct { @@ -176,6 +177,7 @@ const ( DeviceSupported HostAndDeviceSupported HostAndDeviceDefault + NeitherHostNorDeviceSupported ) func InitAndroidModule(m Module, @@ -197,6 +199,7 @@ func InitAndroidArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib base := m.base() base.commonProperties.HostOrDeviceSupported = hod base.commonProperties.Default_multilib = string(defaultMultilib) + base.commonProperties.ArchSpecific = true switch hod { case HostAndDeviceSupported: @@ -305,6 +308,10 @@ func (a *ModuleBase) Arch() Arch { return a.Target().Arch } +func (a *ModuleBase) ArchSpecific() bool { + return a.commonProperties.ArchSpecific +} + func (a *ModuleBase) OsClassSupported() []OsClass { switch a.commonProperties.HostOrDeviceSupported { case HostSupported: diff --git a/cc/test.go b/cc/test.go index 5a34d1ddf..9c7c0de4a 100644 --- a/cc/test.go +++ b/cc/test.go @@ -16,6 +16,7 @@ package cc import ( "path/filepath" + "runtime" "strings" "github.com/google/blueprint" @@ -301,6 +302,16 @@ func (benchmark *benchmarkDecorator) install(ctx ModuleContext, file android.Pat } func NewBenchmark(hod android.HostOrDeviceSupported) *Module { + // Benchmarks aren't supported on Darwin + if runtime.GOOS == "darwin" { + switch hod { + case android.HostAndDeviceSupported: + hod = android.DeviceSupported + case android.HostSupported: + hod = android.NeitherHostNorDeviceSupported + } + } + module, binary := NewBinary(hod) module.multilib = android.MultilibBoth binary.baseInstaller = NewTestInstaller()