Skip to content

Commit

Permalink
Merge pull request Homebrew#207822 from Homebrew/ibazel-bazel
Browse files Browse the repository at this point in the history
ibazel: build with `bazel@7` rather than pre-built
  • Loading branch information
BrewTestBot authored Feb 21, 2025
2 parents 9afd276 + 8596760 commit bd93190
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions Formula/i/ibazel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,25 @@ class Ibazel < Formula
sha256 cellar: :any_skip_relocation, x86_64_linux: "1dd9fbcb138b56677b3123f7194cb5d13675a5cdd6f8dcfd9a41f218b3b67828"
end

depends_on "bazelisk" => [:build, :test]
depends_on "bazel@7" => [:build, :test]
depends_on "go" => [:build, :test]

# bazel 6.x support issue, https://github.com/bazelbuild/bazel-watcher/issues/616
# patch to use bazel 6.4.0, upstream PR, https://github.com/bazelbuild/bazel-watcher/pull/575
patch :DATA

def install
# Bazel clears environment variables which breaks superenv shims
ENV.remove "PATH", Superenv.shims_path

# Allow using our bazel rather than pre-built from bazelisk
rm(".bazelversion")

system "bazel", "build", "--config=release", "--workspace_status_command", "echo STABLE_GIT_VERSION #{version}", "//cmd/ibazel:ibazel"
bin.install "bazel-bin/cmd/ibazel/ibazel_/ibazel"
end

test do
ENV.prepend_path "PATH", Formula["bazel@7"].bin

# Write MODULE.bazel with Bazel module dependencies
(testpath/"MODULE.bazel").write <<~BAZEL
(testpath/"MODULE.bazel").write <<~STARLARK
bazel_dep(name = "rules_go", version = "0.50.1")
bazel_dep(name = "gazelle", version = "0.40.0")
Expand All @@ -38,16 +42,16 @@ def install
# Register the Go SDK installed on the host.
go_sdk.host()
BAZEL
STARLARK

(testpath/"BUILD.bazel").write <<~BAZEL
(testpath/"BUILD.bazel").write <<~STARLARK
load("@rules_go//go:def.bzl", "go_binary")
go_binary(
name = "bazel-test",
srcs = ["test.go"],
)
BAZEL
STARLARK

(testpath/"test.go").write <<~GO
package main
Expand All @@ -57,7 +61,7 @@ def install
}
GO

pid = fork { exec("ibazel", "build", "//:bazel-test") }
pid = spawn("ibazel", "build", "//:bazel-test")
out_file = "bazel-bin/bazel-test_/bazel-test"
sleep 1 until File.exist?(out_file)
assert_equal "Hi!\n", shell_output(out_file)
Expand All @@ -67,12 +71,3 @@ def install
Process.kill("TERM", pid)
end
end

__END__
diff --git a/.bazelversion b/.bazelversion
index 8a30e8f..09b254e 100644
--- a/.bazelversion
+++ b/.bazelversion
@@ -1 +1 @@
-5.4.0
+6.4.0

0 comments on commit bd93190

Please sign in to comment.