From fc754581fc1bbc42586a7ac6df3f9eddcbb6955f Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 17 May 2016 16:34:16 -0700 Subject: [PATCH] Add a Name property Blueprint is going to abdicate responsibility for determining the name of a module. Add a name property, and a method to retreive the name. Test: build.ninja identical Change-Id: I09c6f5283cd6e28ad4b04c24c5ab8b00f71ae2ab --- android/defaults.go | 15 ++++++++++++++- android/module.go | 17 ++++++++++++++--- cc/cc.go | 3 --- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/android/defaults.go b/android/defaults.go index 11ce09976..df1409e8d 100644 --- a/android/defaults.go +++ b/android/defaults.go @@ -80,7 +80,20 @@ func (d *DefaultsModule) properties() []interface{} { } func InitDefaultsModule(module Module, d Defaults, props ...interface{}) (blueprint.Module, []interface{}) { - return InitDefaultableModule(module, d, props...) + props = append(props, + &hostAndDeviceProperties{}, + &commonProperties{}, + &variableProperties{}) + + _, props = InitArchModule(module, props...) + + _, props = InitDefaultableModule(module, d, props...) + + props = append(props, &module.base().nameProperties) + + module.base().module = module + + return module, props } var _ Defaults = (*DefaultsModule)(nil) diff --git a/android/module.go b/android/module.go index 06f1fca7c..52280d242 100644 --- a/android/module.go +++ b/android/module.go @@ -99,9 +99,12 @@ type Module interface { InstallInData() bool } -type commonProperties struct { +type nameProperties struct { + // The name of the module. Must be unique across all modules. Name string - Deps []string +} + +type commonProperties struct { Tags []string // emit build rules for this module @@ -177,7 +180,10 @@ func InitAndroidModule(m Module, base := m.base() base.module = m - propertyStructs = append(propertyStructs, &base.commonProperties, &base.variableProperties) + propertyStructs = append(propertyStructs, + &base.nameProperties, + &base.commonProperties, + &base.variableProperties) return m, propertyStructs } @@ -250,6 +256,7 @@ type ModuleBase struct { // the thing pattern to good use. module Module + nameProperties nameProperties commonProperties commonProperties variableProperties variableProperties hostAndDeviceProperties hostAndDeviceProperties @@ -270,6 +277,10 @@ type ModuleBase struct { hooks hooks } +func (a *ModuleBase) Name() string { + return a.nameProperties.Name +} + func (a *ModuleBase) base() *ModuleBase { return a } diff --git a/cc/cc.go b/cc/cc.go index 5811b0ac1..b51e13c5a 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -935,9 +935,6 @@ func DefaultsFactory(props ...interface{}) (blueprint.Module, []interface{}) { &InstallerProperties{}, ) - _, props = android.InitAndroidArchModule(module, android.HostAndDeviceDefault, - android.MultilibDefault, props...) - return android.InitDefaultsModule(module, module, props...) }