Skip to content

Commit

Permalink
Adding a builtinPool type
Browse files Browse the repository at this point in the history
This implements the Pool interface. An instance of a builtinPool
is created for the Console pool.

Change-Id: I03334c25495dc573aef2c0e62415352a0b10d6fd
  • Loading branch information
kenoslund-google authored and Jamie Gennis committed Apr 16, 2015
1 parent adccb7f commit 4b9a051
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
4 changes: 4 additions & 0 deletions live_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
29 changes: 29 additions & 0 deletions package_ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4b9a051

Please sign in to comment.