Merge pull request #202 from danw/go1.10_goroot
Try to make GOROOT relative in Go 1.10
This commit is contained in:
commit
f75f4e9b7b
1 changed files with 13 additions and 1 deletions
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue