homebrew-core/Formula/bazelisk.rb

50 lines
1.7 KiB
Ruby

class Bazelisk < Formula
desc "User-friendly launcher for Bazel"
homepage "https://github.com/bazelbuild/bazelisk/"
url "https://github.com/bazelbuild/bazelisk.git",
tag: "v1.6.1",
revision: "6f5ce4b2ec4110bbaa9a43ec1b054af7504887d5"
license "Apache-2.0"
head "https://github.com/bazelbuild/bazelisk.git"
bottle do
cellar :any_skip_relocation
sha256 "a12a97c1d1092c7411b965d7f58962853f7599ff986d923ba87e237b1f00d3ba" => :catalina
sha256 "1df6a3ae85d691e38a1ce4964b94c1fc429e41eaf2d25d0d666a43293ab5097c" => :mojave
sha256 "0a3870c3f3eeb7f71b67b0001a0605380113001ff63d53bec9dbf92bc4ad5415" => :high_sierra
end
depends_on "go" => :build
conflicts_with "bazel", because: "Bazelisk replaces the bazel binary"
resource "bazel_zsh_completion" do
url "https://raw.githubusercontent.com/bazelbuild/bazel/3.4.1/scripts/zsh_completion/_bazel"
sha256 "4094dc84add2f23823bc341186adf6b8487fbd5d4164bd52d98891c41511eba4"
end
def install
ENV["GOOS"] = "darwin"
ENV["GOARCH"] = "amd64"
system "go", "build", *std_go_args, "-ldflags", "-X main.BazeliskVersion=#{version}"
bin.install_symlink "bazelisk" => "bazel"
resource("bazel_zsh_completion").stage do
zsh_completion.install "_bazel"
end
end
test do
ENV["USE_BAZEL_VERSION"] = Formula["bazel"].version
assert_match /Bazelisk version: #{version}/, shell_output("#{bin}/bazelisk version")
# This is an older than current version, so that we can test that bazelisk
# will target an explicit version we specify. This version shouldn't need to
# be bumped.
ENV["USE_BAZEL_VERSION"] = "0.28.0"
assert_match /Build label: 0.28.0/, shell_output("#{bin}/bazelisk version")
end
end