build: Warn when being executed outside of gopath

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4425
This commit is contained in:
Simon Frei 2017-10-20 23:10:55 +00:00 committed by Audrius Butkevicius
parent 55b63941b8
commit d84b6bb822
1 changed files with 9 additions and 2 deletions

View File

@ -45,7 +45,7 @@ var (
noBuildGopath bool
extraTags string
installSuffix string
pkgdir string
pkgdir string
)
type target struct {
@ -204,7 +204,7 @@ func main() {
}()
}
if gopath() == "" {
if gopath := gopath(); gopath == "" {
gopath, err := temporaryBuildDir()
if err != nil {
log.Fatal(err)
@ -217,6 +217,13 @@ func main() {
}
os.Setenv("GOPATH", gopath)
log.Println("GOPATH is", gopath)
} else {
gopath, _ = filepath.EvalSymlinks(gopath)
wd, _ := os.Getwd()
wd, _ = filepath.EvalSymlinks(wd)
if filepath.Join(gopath, "src/github.com/syncthing/syncthing") != wd {
fmt.Println("You are running this outside of GOPATH/src/github.com/syncthing/syncthing, this might cause failure!")
}
}
// Set path to $GOPATH/bin:$PATH so that we can for sure find tools we