Add MissingDeps to RuleBuilder
Add a method to be used when Config.AllowMissingDependencies() is true to produce an error rule when the rule is missing dependencies. Test: m checkbuild Change-Id: If370fbb2734237a84a100b99b5238c7a2256c405
This commit is contained in:
parent
4331334bdc
commit
0d2f40ae6c
1 changed files with 22 additions and 0 deletions
|
@ -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{
|
||||
|
|
Loading…
Reference in a new issue