Merge pull request #202 from danw/go1.10_goroot

Try to make GOROOT relative in Go 1.10
This commit is contained in:
Dan Willemsen 2018-03-02 15:59:17 -08:00 committed by GitHub
commit f75f4e9b7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,7 +15,10 @@
package bootstrap
import (
"os"
"path/filepath"
"runtime"
"strings"
"github.com/google/blueprint"
)
@ -39,7 +42,16 @@ var (
return NinjaBuildDir
})
goRoot = bootstrapVariable("goRoot", func() string {
return runtime.GOROOT()
goroot := runtime.GOROOT()
// Prefer to omit absolute paths from the ninja file
if cwd, err := os.Getwd(); err == nil {
if relpath, err := filepath.Rel(cwd, goroot); err == nil {
if !strings.HasPrefix(relpath, "../") {
goroot = relpath
}
}
}
return goroot
})
compileCmd = bootstrapVariable("compileCmd", func() string {
return "$goRoot/pkg/tool/" + runtime.GOOS + "_" + runtime.GOARCH + "/compile"