Add NewBuiltinRule and NewBuiltinPool

Allow Blueprint build statements and rules to reference rules and pools
defined outside of Blueprint.

Change-Id: I48644497d16a4c2bab88db400dbe7f7fe169d933
This commit is contained in:
Colin Cross 2016-08-29 15:07:16 -07:00
parent b9fb0ad53d
commit e0e473efb4

View file

@ -120,13 +120,9 @@ func NewPackageContext(pkgPath string) PackageContext {
return p
}
var Phony Rule = &builtinRule{
name_: "phony",
}
var Phony Rule = NewBuiltinRule("phony")
var Console Pool = &builtinPool{
name_: "console",
}
var Console Pool = NewBuiltinPool("console")
var errRuleIsBuiltin = errors.New("the rule is a built-in")
var errPoolIsBuiltin = errors.New("the pool is a built-in")
@ -608,6 +604,13 @@ func (p *builtinPool) def(config interface{}) (*poolDef, error) {
return nil, errPoolIsBuiltin
}
// NewBuiltinPool returns a Pool object that refers to a pool name created outside of Blueprint
func NewBuiltinPool(name string) Pool {
return &builtinPool{
name_: name,
}
}
func (p *builtinPool) String() string {
return "<builtin>:" + p.name_
}
@ -867,6 +870,13 @@ func (r *builtinRule) String() string {
return "<builtin>:" + r.name_
}
// NewBuiltinRule returns a Rule object that refers to a rule that was created outside of Blueprint
func NewBuiltinRule(name string) Rule {
return &builtinRule{
name_: name,
}
}
func (p *packageContext) AddNinjaFileDeps(deps ...string) {
p.ninjaFileDeps = append(p.ninjaFileDeps, deps...)
}