Skip to content

Commit

Permalink
Download native macOS arm64 binary on M1 (bazelbuild#303)
Browse files Browse the repository at this point in the history
* Download native macOS arm64 binary on M1

* Move logic to platforms.go

* Support declared platforms with arm64

* Minor fixes
  • Loading branch information
codeman9 authored Jun 15, 2022
1 parent 294c839 commit 40d8ae3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
7 changes: 6 additions & 1 deletion platforms/platforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ var platforms = map[string]string{"darwin": "macos", "linux": "ubuntu1404", "win
// GetPlatform returns a Bazel CI-compatible platform identifier for the current operating system.
// TODO(fweikert): raise an error for unsupported platforms
func GetPlatform() string {
return platforms[runtime.GOOS]
platform := platforms[runtime.GOOS]
arch := runtime.GOARCH
if arch == "arm64" {
platform = platform + "_arm64"
}
return platform
}

// DetermineExecutableFilenameSuffix returns the extension for binaries on the current operating system.
Expand Down
16 changes: 9 additions & 7 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
set -euxo pipefail

rm -rf "$HOME/Library/Caches/bazelisk"
env -u USE_BAZEL_VERSION ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="latest" ./bin/bazelisk-darwin-amd64 version

arch=$(uname -m)
env -u USE_BAZEL_VERSION ./bin/bazelisk-darwin-"$arch" version
USE_BAZEL_VERSION="latest" ./bin/bazelisk-darwin-"$arch" version
USE_BAZEL_VERSION="0.28.0" ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="last_green" ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="last_downstream_green" ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="last_rc" ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="bazelbuild/latest" ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="last_green" ./bin/bazelisk-darwin-"$arch" version
USE_BAZEL_VERSION="last_downstream_green" ./bin/bazelisk-darwin-"$arch" version
USE_BAZEL_VERSION="last_rc" ./bin/bazelisk-darwin-"$arch" version
USE_BAZEL_VERSION="bazelbuild/latest" ./bin/bazelisk-darwin-"$arch" version
USE_BAZEL_VERSION="bazelbuild/0.27.0" ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="philwo/latest" ./bin/bazelisk-darwin-amd64 version
USE_BAZEL_VERSION="philwo/latest" ./bin/bazelisk-darwin-"$arch" version
USE_BAZEL_VERSION="philwo/0.25.0" ./bin/bazelisk-darwin-amd64 version

0 comments on commit 40d8ae3

Please sign in to comment.