Add MissingDeps to RuleBuilder am: 0d2f40ae6c
am: 2950d40b76
Change-Id: Idf832a90670e636348f8e3af86686de03ced7544
This commit is contained in:
@@ -31,6 +31,7 @@ type RuleBuilder struct {
|
|||||||
installs []RuleBuilderInstall
|
installs []RuleBuilderInstall
|
||||||
temporariesSet map[string]bool
|
temporariesSet map[string]bool
|
||||||
restat bool
|
restat bool
|
||||||
|
missingDeps []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRuleBuilder returns a newly created RuleBuilder.
|
// NewRuleBuilder returns a newly created RuleBuilder.
|
||||||
@@ -45,6 +46,15 @@ type RuleBuilderInstall struct {
|
|||||||
From, To string
|
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.
|
// Restat marks the rule as a restat rule, which will be passed to ModuleContext.Rule in BuildParams.Restat.
|
||||||
func (r *RuleBuilder) Restat() *RuleBuilder {
|
func (r *RuleBuilder) Restat() *RuleBuilder {
|
||||||
r.restat = true
|
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 {
|
if len(r.Commands()) > 0 {
|
||||||
ctx.Build(pctx, BuildParams{
|
ctx.Build(pctx, BuildParams{
|
||||||
Rule: ctx.Rule(pctx, name, blueprint.RuleParams{
|
Rule: ctx.Rule(pctx, name, blueprint.RuleParams{
|
||||||
|
Reference in New Issue
Block a user