Skip to content

Commit

Permalink
Handle an additional vendor directory
Browse files Browse the repository at this point in the history
Additional gb.cfg config
pkgdir=vendor

When building the workspace $pkgdir will removed from
the packages target

W/$pkgdir/a/b/c -> a/b/c
  • Loading branch information
davecheney committed Jan 26, 2012
1 parent 6ef1858 commit 79ed48f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions gb/config.go
Expand Up @@ -79,6 +79,11 @@ func (cfg Config) GCFlags() (gcflags string, set bool) {
return
}

func (cfg Config) Pkgdir() (pkgdir string, set bool) {
pkgdir, set = cfg["pkgdir"]
return
}

func (cfg Config) Write(dir string) (err error) {
path := filepath.Join(dir, "gb.cfg")
var fout *os.File
Expand Down Expand Up @@ -118,6 +123,7 @@ var knownKeys = map[string]bool{
"ignore": true,
"ignoreall": true,
"gcflags": true,
"pkgdir": true,
}

func ReadConfig(dir string) (cfg Config) {
Expand Down
11 changes: 10 additions & 1 deletion gb/pkg.go
Expand Up @@ -584,7 +584,16 @@ func (this *Package) GetTarget() (err error) {
}
return false
}
_ = tryFixPrefix(path.Join("src", "pkg")) || tryFixPrefix("pkg") || tryFixPrefix("src")
fixed := tryFixPrefix(path.Join("src", "pkg")) || tryFixPrefix("pkg") || tryFixPrefix("src")

for t := this; t != nil; t = t.Parent {
if pkgdir, set := t.Cfg.Pkgdir(); set {
if !fixed {
tryFixPrefix(pkgdir)
}
break
}
}
}
} else {
this.Base = this.Target
Expand Down

0 comments on commit 79ed48f

Please sign in to comment.