Merge pull request #21 from jgennis/rbase

Adding a builtinPool type
This commit is contained in:
jgennis 2015-04-16 10:17:16 -07:00
commit efe578a605
3 changed files with 38 additions and 0 deletions

View file

@ -113,6 +113,10 @@ func (l *liveTracker) addPool(p Pool) error {
_, ok := l.pools[p]
if !ok {
def, err := p.def(l.config)
if err == errPoolIsBuiltin {
// No need to do anything for built-in rules.
return nil
}
if err != nil {
return err
}

View file

@ -98,7 +98,12 @@ var Phony Rule = &builtinRule{
name_: "phony",
}
var Console Pool = &builtinPool{
name_: "console",
}
var errRuleIsBuiltin = errors.New("the rule is a built-in")
var errPoolIsBuiltin = errors.New("the pool is a built-in")
var errVariableIsArg = errors.New("argument variables have no value")
// checkCalledFromInit panics if a Go package's init function is not on the
@ -557,6 +562,30 @@ func (p *poolFunc) String() string {
return p.pctx.pkgPath + "." + p.name_
}
type builtinPool struct {
name_ string
}
func (p *builtinPool) packageContext() *PackageContext {
return nil
}
func (p *builtinPool) name() string {
return p.name_
}
func (p *builtinPool) fullName(pkgNames map[*PackageContext]string) string {
return p.name_
}
func (p *builtinPool) def(config interface{}) (*poolDef, error) {
return nil, errPoolIsBuiltin
}
func (p *builtinPool) String() string {
return "<builtin>:" + p.name_
}
type staticRule struct {
pctx *PackageContext
name_ string

View file

@ -170,6 +170,11 @@ func (s *basicScope) IsRuleVisible(rule Rule) bool {
}
func (s *basicScope) IsPoolVisible(pool Pool) bool {
_, isBuiltin := pool.(*builtinPool)
if isBuiltin {
return true
}
name := pool.name()
for s != nil {