diff --git a/android/rule_builder.go b/android/rule_builder.go index d005839bd..38018be40 100644 --- a/android/rule_builder.go +++ b/android/rule_builder.go @@ -31,6 +31,7 @@ type RuleBuilder struct { installs []RuleBuilderInstall temporariesSet map[string]bool restat bool + missingDeps []string } // NewRuleBuilder returns a newly created RuleBuilder. @@ -45,6 +46,15 @@ type RuleBuilderInstall struct { From, To string } +// MissingDeps adds modules to the list of missing dependencies. If MissingDeps +// is called with a non-empty input, any call to Build will result in a rule +// that will print an error listing the missing dependencies and fail. +// MissingDeps should only be called if Config.AllowMissingDependencies() is +// true. +func (r *RuleBuilder) MissingDeps(missingDeps []string) { + r.missingDeps = append(r.missingDeps, missingDeps...) +} + // Restat marks the rule as a restat rule, which will be passed to ModuleContext.Rule in BuildParams.Restat. func (r *RuleBuilder) Restat() *RuleBuilder { r.restat = true @@ -219,6 +229,18 @@ func (r *RuleBuilder) Build(pctx PackageContext, ctx BuilderContext, name string } } + if len(r.missingDeps) > 0 { + ctx.Build(pctx, BuildParams{ + Rule: ErrorRule, + Outputs: outputs, + Description: desc, + Args: map[string]string{ + "error": "missing dependencies: " + strings.Join(r.missingDeps, ", "), + }, + }) + return + } + if len(r.Commands()) > 0 { ctx.Build(pctx, BuildParams{ Rule: ctx.Rule(pctx, name, blueprint.RuleParams{