Allow rules to specify order-only dependencies

Commands that contain tools that don't affect the build results
may want an order-only dependency on the tool.  Allow rules
to specify order-only dependencies the same way they specify
implicit dependencies.

Test: builds
Change-Id: I3e0f886ae047b0fadf7a5c0dfeb9827d2c5c411d
This commit is contained in:
Colin Cross 2017-10-17 13:49:28 -07:00
parent afa12b4744
commit 47113641cd
2 changed files with 19 additions and 6 deletions

View file

@ -109,6 +109,11 @@ func (l *liveTracker) addRule(r Rule) (def *ruleDef, err error) {
return nil, err
}
err = l.addNinjaStringListDeps(def.CommandOrderOnly)
if err != nil {
return nil, err
}
for _, value := range def.Variables {
err = l.addNinjaStringDeps(value)
if err != nil {

View file

@ -67,8 +67,9 @@ type RuleParams struct {
RspfileContent string // The response file content.
// These fields are used internally in Blueprint
CommandDeps []string // Command-specific implicit dependencies to prepend to builds
Comment string // The comment that will appear above the definition.
CommandDeps []string // Command-specific implicit dependencies to prepend to builds
CommandOrderOnly []string // Command-specific order-only dependencies to prepend to builds
Comment string // The comment that will appear above the definition.
}
// A BuildParams object contains the set of parameters that make up a Ninja
@ -127,10 +128,11 @@ func (p *poolDef) WriteTo(nw *ninjaWriter, name string) error {
// A ruleDef describes a rule definition. It does not include the name of the
// rule.
type ruleDef struct {
CommandDeps []*ninjaString
Comment string
Pool Pool
Variables map[string]*ninjaString
CommandDeps []*ninjaString
CommandOrderOnly []*ninjaString
Comment string
Pool Pool
Variables map[string]*ninjaString
}
func parseRuleParams(scope scope, params *RuleParams) (*ruleDef,
@ -207,6 +209,11 @@ func parseRuleParams(scope scope, params *RuleParams) (*ruleDef,
return nil, fmt.Errorf("error parsing CommandDeps param: %s", err)
}
r.CommandOrderOnly, err = parseNinjaStrings(scope, params.CommandOrderOnly)
if err != nil {
return nil, fmt.Errorf("error parsing CommandDeps param: %s", err)
}
return r, nil
}
@ -370,6 +377,7 @@ func (b *buildDef) WriteTo(nw *ninjaWriter, pkgNames map[*packageContext]string)
if b.RuleDef != nil {
implicitDeps = append(valueList(b.RuleDef.CommandDeps, pkgNames, inputEscaper), implicitDeps...)
orderOnlyDeps = append(valueList(b.RuleDef.CommandOrderOnly, pkgNames, inputEscaper), orderOnlyDeps...)
}
err := nw.Build(comment, rule, outputs, implicitOuts, explicitDeps, implicitDeps, orderOnlyDeps)