From bb93ec5d320917178637529a97f9a27610ca6446 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 20 Oct 2023 11:39:13 -0700 Subject: [PATCH] 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 --- tool/gocross/gocross-wrapper.sh | 5 ++++- tool/gocross/toolchain.go | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tool/gocross/gocross-wrapper.sh b/tool/gocross/gocross-wrapper.sh index 6a9104dd1..f91d7e235 100755 --- a/tool/gocross/gocross-wrapper.sh +++ b/tool/gocross/gocross-wrapper.sh @@ -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 diff --git a/tool/gocross/toolchain.go b/tool/gocross/toolchain.go index 5980dff04..203262d0e 100644 --- a/tool/gocross/toolchain.go +++ b/tool/gocross/toolchain.go @@ -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. //