Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download correct Bazel binary on Linux #346

Merged
merged 1 commit into from
Aug 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions platforms/platforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,41 @@ package platforms

import (
"fmt"
semver "github.com/hashicorp/go-version"
"log"
"runtime"

semver "github.com/hashicorp/go-version"
)

var platforms = map[string]string{"darwin": "macos", "linux": "ubuntu1404", "windows": "windows"}
type platform struct {
Name string
HasArm64Binary bool
}

var supportedPlatforms = map[string]*platform{
"darwin": {
Name: "macos",
HasArm64Binary: true,
},
"linux": {
Name: "ubuntu1804",
HasArm64Binary: false,
},
"windows": {
Name: "windows",
HasArm64Binary: true,
},
}

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

// DetermineExecutableFilenameSuffix returns the extension for binaries on the current operating system.
Expand Down