From b3f96c3306b94ba2ccf5777e7bc6d43b6d060460 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 17 May 2016 17:37:16 -0700 Subject: [PATCH] Add OtherModuleExists Allow dependency modifying mutators to check if another module exists based on its name. Allows primary builders to have custom handling for missing-module errors, for example by falling back to another module. Change-Id: I04ddd66be43c514f1f8928e15b2a79cadebcfc17 --- module_ctx.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/module_ctx.go b/module_ctx.go index 673a1c0..1767224 100644 --- a/module_ctx.go +++ b/module_ctx.go @@ -456,6 +456,7 @@ type mutatorContext struct { type baseMutatorContext interface { BaseModuleContext + OtherModuleExists(name string) bool Module() Module } @@ -651,6 +652,10 @@ func (mctx *mutatorContext) AddInterVariantDependency(tag DependencyTag, from, t mctx.context.addInterVariantDependency(mctx.module, tag, from, to) } +func (mctx *mutatorContext) OtherModuleExists(name string) bool { + return mctx.context.moduleNames[name] != nil +} + // SimpleName is an embeddable object to implement the ModuleContext.Name method using a property // called "name". Modules that embed it must also add SimpleName.Properties to their property // structure list.