From e0e473efb4893d5d6e34e6a641465d48afa13cea Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 29 Aug 2016 15:07:16 -0700 Subject: [PATCH] Add NewBuiltinRule and NewBuiltinPool Allow Blueprint build statements and rules to reference rules and pools defined outside of Blueprint. Change-Id: I48644497d16a4c2bab88db400dbe7f7fe169d933 --- package_ctx.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/package_ctx.go b/package_ctx.go index 8e27150..0c64e45 100644 --- a/package_ctx.go +++ b/package_ctx.go @@ -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 ":" + p.name_ } @@ -867,6 +870,13 @@ func (r *builtinRule) String() string { return ":" + 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...) }