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>
This commit is contained in:
David Anderson
2023-02-23 21:34:16 -08:00
committed by Dave Anderson
parent 66621ab38e
commit 64181e17c8
2 changed files with 34 additions and 18 deletions

View File

@@ -112,9 +112,18 @@ func ensureToolchain(cacheDir, toolchainDir string) error {
return err
}
if err := downloadCachedgo(toolchainDir, wantRev); err != nil {
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
}