Replace PropertyCustomizer with hooks

Replace PropertyCustomizer with a more extensible hooks mechanism.
Instead of passing an object that satisifies an interface, pass a
function pointer that takes a context interface as an argument.  Callers
can use lambdas to capture any other necessary parameters like property
structs.

Also add two new hooks, arch hooks that occur after splitting modules
into arch variants, and install hooks that occur each time a file is
installed to the output directory.

Change-Id: I3a3e34aa97f1a92d3a31e5004b4b1ba68869d242
This commit is contained in:
Colin Cross
2016-09-13 13:42:32 -07:00
parent b4ce0ecad6
commit 178a509855
4 changed files with 182 additions and 85 deletions

View File

@@ -26,11 +26,12 @@ import (
)
func init() {
RegisterTopDownMutator("customizer", customizerMutator).Parallel()
RegisterTopDownMutator("load_hooks", loadHookMutator).Parallel()
RegisterBottomUpMutator("defaults_deps", defaultsDepsMutator).Parallel()
RegisterTopDownMutator("defaults", defaultsMutator).Parallel()
RegisterBottomUpMutator("arch", ArchMutator).Parallel()
RegisterTopDownMutator("arch_hooks", archHookMutator).Parallel()
}
var (
@@ -210,11 +211,6 @@ func InitAndroidArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib
return InitArchModule(m, propertyStructs...)
}
func AddCustomizer(m blueprint.Module, c PropertyCustomizer) {
base := m.(Module).base()
base.customizers = append(base.customizers, c)
}
// A AndroidModuleBase object contains the properties that are common to all Android
// modules. It should be included as an anonymous field in every module
// struct definition. InitAndroidModule should then be called from the module's
@@ -277,7 +273,7 @@ type ModuleBase struct {
checkbuildTarget string
blueprintDir string
customizers []PropertyCustomizer
hooks hooks
}
func (a *ModuleBase) base() *ModuleBase {
@@ -597,6 +593,7 @@ func (a *androidModuleContext) InstallFileName(installPath OutputPath, name stri
deps ...Path) OutputPath {
fullInstallPath := installPath.Join(a, name)
a.module.base().hooks.runInstallHooks(a, fullInstallPath, false)
if a.Host() || !a.AConfig().SkipDeviceInstall() {
deps = append(deps, a.installDeps...)
@@ -621,6 +618,7 @@ func (a *androidModuleContext) InstallFile(installPath OutputPath, srcPath Path,
func (a *androidModuleContext) InstallSymlink(installPath OutputPath, name string, srcPath OutputPath) OutputPath {
fullInstallPath := installPath.Join(a, name)
a.module.base().hooks.runInstallHooks(a, fullInstallPath, true)
if a.Host() || !a.AConfig().SkipDeviceInstall() {
a.ModuleBuild(pctx, ModuleBuildParams{