Skip to content

Commit

Permalink
Show error for unsupported arm64 platforms (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
fweikert authored Aug 17, 2022
1 parent 89dc94c commit da51894
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 8 additions & 4 deletions platforms/platforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ var supportedPlatforms = map[string]*platform{

// GetPlatform returns a Bazel CI-compatible platform identifier for the current operating system.
// TODO(fweikert): raise an error for unsupported platforms
func GetPlatform() string {
func GetPlatform() (string, error) {
platform := supportedPlatforms[runtime.GOOS]
arch := runtime.GOARCH
if arch == "arm64" && platform.HasArm64Binary {
return platform.Name + "_arm64"
if arch == "arm64" {
if platform.HasArm64Binary {
return platform.Name + "_arm64", nil
}
return "", fmt.Errorf("arm64 %s is unsupported", runtime.GOOS)
}
return platform.Name

return platform.Name, nil
}

// DetermineExecutableFilenameSuffix returns the extension for binaries on the current operating system.
Expand Down
6 changes: 5 additions & 1 deletion repositories/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,11 @@ func (gcs *GCSRepo) GetLastGreenCommit(bazeliskHome string, downstreamGreen bool
// DownloadAtCommit downloads a Bazel binary built at the given commit into the specified location and returns the absolute path.
func (gcs *GCSRepo) DownloadAtCommit(commit, destDir, destFile string) (string, error) {
log.Printf("Using unreleased version at commit %s", commit)
url := fmt.Sprintf("%s/%s/%s/bazel", nonCandidateBaseURL, platforms.GetPlatform(), commit)
platform, err := platforms.GetPlatform()
if err != nil {
return "", err
}
url := fmt.Sprintf("%s/%s/%s/bazel", nonCandidateBaseURL, platform, commit)
return httputil.DownloadBinary(url, destDir, destFile)
}

Expand Down

0 comments on commit da51894

Please sign in to comment.