1
0
mirror of https://github.com/golang/go synced 2024-11-25 04:27:56 -07:00

cmd/go: fix import directory list for compilation

This fixes the most annoying bug in the go command,
that 'go build' sometimes ignored packages it had just
rebuilt in favor of stale installed ones.

This part of the code needs more thought, but this small
change is an important improvement.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5531053
This commit is contained in:
Russ Cox 2012-01-09 15:38:07 -08:00
parent 1421b4ceff
commit 0ad241dd55

View File

@ -509,9 +509,9 @@ func (b *builder) build(a *action) error {
incMap[build.Path[0].PkgDir()] = true // goroot incMap[build.Path[0].PkgDir()] = true // goroot
incMap[""] = true // ignore empty strings incMap[""] = true // ignore empty strings
// build package directories of dependencies // temporary build package directories of dependencies.
for _, a1 := range a.deps { for _, a1 := range a.deps {
if pkgdir := a1.pkgdir; !incMap[pkgdir] { if pkgdir := a1.pkgdir; pkgdir != a1.p.t.PkgDir() && !incMap[pkgdir] {
incMap[pkgdir] = true incMap[pkgdir] = true
inc = append(inc, "-I", pkgdir) inc = append(inc, "-I", pkgdir)
} }
@ -522,7 +522,7 @@ func (b *builder) build(a *action) error {
// then installed package directories of dependencies // then installed package directories of dependencies
for _, a1 := range a.deps { for _, a1 := range a.deps {
if pkgdir := a1.p.t.PkgDir(); !incMap[pkgdir] { if pkgdir := a1.p.t.PkgDir(); pkgdir == a1.pkgdir && !incMap[pkgdir] {
incMap[pkgdir] = true incMap[pkgdir] = true
inc = append(inc, "-I", pkgdir) inc = append(inc, "-I", pkgdir)
} }