Implement plugins for bootstrap go modules
Now that we have multi-stage bootstrapping, we can make the primary
builder build more dynamic. Add the concept of plugins that will be
linked and loaded into bootstrap_go_binary or bootstrap_go_package
modules. It's expected that the plugin's init() functions will do
whatever registration is necessary.
Example Blueprint definition:
bootstrap_go_binary {
name: "builder",
...
}
bootstrap_go_package {
name: "plugin1",
pluginFor: ["builder"],
}
A package may specify more than one plugin if it will be inserted into
more than one go module.
Change-Id: I109835f444196b66fc4018c3fa36ba0875823184
diff --git a/module_ctx.go b/module_ctx.go
index 76d3977..6254596 100644
--- a/module_ctx.go
+++ b/module_ctx.go
@@ -359,8 +359,7 @@
type mutatorContext struct {
baseModuleContext
- name string
- dependenciesModified bool
+ name string
}
type baseMutatorContext interface {
@@ -389,6 +388,7 @@
baseMutatorContext
AddDependency(module Module, name string)
+ AddReverseDependency(module Module, name string)
CreateVariations(...string) []Module
CreateLocalVariations(...string) []Module
SetDependencyVariation(string)
@@ -464,8 +464,7 @@
return mctx.module.logicModule
}
-// Add a dependency to the given module. The depender can be a specific variant
-// of a module, but the dependee must be a module that has no variations.
+// Add a dependency to the given module.
// Does not affect the ordering of the current mutator pass, but will be ordered
// correctly for all future mutator passes.
func (mctx *mutatorContext) AddDependency(module Module, depName string) {
@@ -473,7 +472,16 @@
if len(errs) > 0 {
mctx.errs = append(mctx.errs, errs...)
}
- mctx.dependenciesModified = true
+}
+
+// Add a dependency from the destination to the given module.
+// Does not affect the ordering of the current mutator pass, but will be ordered
+// correctly for all future mutator passes.
+func (mctx *mutatorContext) AddReverseDependency(module Module, destName string) {
+ errs := mctx.context.addReverseDependency(mctx.context.moduleInfo[module], destName)
+ if len(errs) > 0 {
+ mctx.errs = append(mctx.errs, errs...)
+ }
}
func (mctx *mutatorContext) VisitDirectDeps(visit func(Module)) {