90 lines
2.8 KiB
Ruby
90 lines
2.8 KiB
Ruby
class Bazel < Formula
|
|
desc "Google's own build tool"
|
|
homepage "https://bazel.build/"
|
|
url "https://github.com/bazelbuild/bazel/releases/download/3.7.0/bazel-3.7.0-dist.zip"
|
|
sha256 "63873623917c756d1be49ff4d5fc23049736180e6b9a7d5236c6f204eddae3cc"
|
|
license "Apache-2.0"
|
|
revision 1
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "08ad26b628f51fe93c8d4e3fd2f39adb9ab427201d7182ae28832a0df6a2a785" => :catalina
|
|
sha256 "981090cbfedb410ed6ee66b897cb6ec0c2eb57a2a0c4b8d7681bbbee5c2c2789" => :mojave
|
|
sha256 "12523b2d14f69127640b9f2b4507abf79698253c37830d64e5dd40e6f2432ff7" => :high_sierra
|
|
end
|
|
|
|
depends_on "python@3.9" => :build
|
|
depends_on "openjdk@11"
|
|
|
|
uses_from_macos "zip"
|
|
|
|
def install
|
|
ENV["EMBED_LABEL"] = "#{version}-homebrew"
|
|
# Force Bazel ./compile.sh to put its temporary files in the buildpath
|
|
ENV["BAZEL_WRKDIR"] = buildpath/"work"
|
|
# Force Bazel to use openjdk@11
|
|
ENV["JAVA_HOME"] = Formula["openjdk@11"].opt_libexec/"openjdk.jdk/Contents/Home"
|
|
ENV["EXTRA_BAZEL_ARGS"] = "--host_javabase=@local_jdk//:jdk"
|
|
|
|
(buildpath/"sources").install buildpath.children
|
|
|
|
cd "sources" do
|
|
system "./compile.sh"
|
|
system "./output/bazel",
|
|
"--output_user_root",
|
|
buildpath/"output_user_root",
|
|
"build",
|
|
"scripts:bash_completion"
|
|
|
|
bin.install "scripts/packages/bazel.sh" => "bazel"
|
|
ln_s libexec/"bin/bazel-real", bin/"bazel-#{version}"
|
|
(libexec/"bin").install "output/bazel" => "bazel-real"
|
|
bin.env_script_all_files(libexec/"bin",
|
|
JAVA_HOME: Formula["openjdk@11"].opt_libexec/"openjdk.jdk/Contents/Home")
|
|
|
|
bash_completion.install "bazel-bin/scripts/bazel-complete.bash"
|
|
zsh_completion.install "scripts/zsh_completion/_bazel"
|
|
|
|
prefix.install_metafiles
|
|
end
|
|
end
|
|
|
|
test do
|
|
touch testpath/"WORKSPACE"
|
|
|
|
(testpath/"ProjectRunner.java").write <<~EOS
|
|
public class ProjectRunner {
|
|
public static void main(String args[]) {
|
|
System.out.println("Hi!");
|
|
}
|
|
}
|
|
EOS
|
|
|
|
(testpath/"BUILD").write <<~EOS
|
|
java_binary(
|
|
name = "bazel-test",
|
|
srcs = glob(["*.java"]),
|
|
main_class = "ProjectRunner",
|
|
)
|
|
EOS
|
|
|
|
system bin/"bazel",
|
|
"build",
|
|
"//:bazel-test"
|
|
assert_equal "Hi!\n", pipe_output("bazel-bin/bazel-test")
|
|
|
|
# Verify that `bazel` invokes Bazel's wrapper script, which delegates to
|
|
# project-specific `tools/bazel` if present. Invoking `bazel-VERSION`
|
|
# bypasses this behavior.
|
|
(testpath/"tools"/"bazel").write <<~EOS
|
|
#!/bin/bash
|
|
echo "stub-wrapper"
|
|
exit 1
|
|
EOS
|
|
(testpath/"tools/bazel").chmod 0755
|
|
|
|
assert_equal "stub-wrapper\n", shell_output("#{bin}/bazel --version", 1)
|
|
assert_equal "bazel #{version}-homebrew\n", shell_output("#{bin}/bazel-#{version} --version")
|
|
end
|
|
end
|