tool/gocross: support local toolchain for development

This makes gocross and its bootstrap script understand an absolute
path in go.toolchain.rev to mean "use the given toolchain directly".

Signed-off-by: David Anderson <danderson@tailscale.com>
pull/6914/merge
David Anderson 2 years ago committed by Dave Anderson
parent 66621ab38e
commit 64181e17c8

@ -31,6 +31,11 @@ if [ ! -d "$toolchain" ]; then
# updates.
read -r REV <$repo_root/go.toolchain.rev
case "$REV" in
/*)
toolchain="$REV"
;;
*)
# This works for linux and darwin, which is sufficient
# (we do not build tailscale-go for other targets).
HOST_OS=$(uname -s | tr A-Z a-z)
@ -48,6 +53,8 @@ if [ ! -d "$toolchain" ]; then
mkdir -p "$toolchain"
(cd "$toolchain" && tar --strip-components=1 -xf "$toolchain.tar.gz")
echo "$REV" >"$toolchain.extracted"
;;
esac
fi
# Binaries run with `gocross run` can reinvoke gocross, resulting in a

@ -112,9 +112,18 @@ func ensureToolchain(cacheDir, toolchainDir string) error {
return err
}
if filepath.IsAbs(wantRev) {
// Local dev toolchain.
if err := os.Symlink(wantRev, toolchainDir); err != nil {
return err
}
return nil
} else {
if err := downloadCachedgo(toolchainDir, wantRev); err != nil {
return err
}
}
if err := os.WriteFile(stampFile, []byte(wantRev), 0644); err != nil {
return err
}

Loading…
Cancel
Save