Skip to content
Browse files

Handle an additional vendor directory

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...
1 parent 6ef1858 commit 79ed48f815cf3d02519e396cb560d95050036cc4 @davecheney committed Jan 26, 2012
Showing with 16 additions and 1 deletion.
  1. +6 −0 gb/config.go
  2. +10 −1 gb/pkg.go
View
6 gb/config.go
@@ -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
@@ -118,6 +123,7 @@ var knownKeys = map[string]bool{
"ignore": true,
"ignoreall": true,
"gcflags": true,
+ "pkgdir": true,
}
func ReadConfig(dir string) (cfg Config) {
View
11 gb/pkg.go
@@ -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

0 comments on commit 79ed48f

Please sign in to comment.
Something went wrong with that request. Please try again.