tool/gocross: make gocross-wrapper use GOCROSS_WANTVER if set instead of git

To run tests in an environment without a git checkout and just the bare
files (from git archive)

Updates #9841

Change-Id: Ibaf5e230cd8e6af7b25540b773df54d3e1ac25e1
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick 2023-10-20 11:39:13 -07:00
parent 70f9c8a6ed
commit bb93ec5d32
2 changed files with 7 additions and 1 deletions

View File

@ -90,7 +90,10 @@ fi
# Anyway, build gocross in a stripped down universe.
gocross_path="gocross"
gocross_ok=0
wantver="$(git rev-parse HEAD)"
wantver="${GOCROSS_WANTVER:-}"
if [[ "$wantver" == "" ]]; then
wantver="$(git rev-parse HEAD)"
fi
if [[ -x "$gocross_path" ]]; then
gotver="$($gocross_path gocross-version 2>/dev/null || echo '')"
if [[ "$gotver" == "$wantver" ]]; then

View File

@ -15,6 +15,9 @@ import (
)
func toolchainRev() (string, error) {
if v := os.Getenv("GO_TOOLCHAIN_REV"); v != "" {
return v, nil
}
// gocross gets built in the root of the repo that has toolchain
// information, so we can use os.Args[0] to locate toolchain info.
//