homebrew-core/Formula/bazel.rb
2018-09-28 13:29:09 +02:00

62 lines
1.9 KiB
Ruby

class Bazel < Formula
desc "Google's own build tool"
homepage "https://bazel.build/"
url "https://github.com/bazelbuild/bazel/releases/download/0.17.2/bazel-0.17.2-dist.zip"
sha256 "b6e87acfa0a405bb8b3417c58477b66d5bc27dc0d31ba6fa12bc255b9278d33b"
bottle do
cellar :any_skip_relocation
sha256 "d051825e74539f7ff4f0d131eb99b218eb78eef7162b56a9f8b40f62dcb26bc4" => :mojave
sha256 "c4196c2a274961c43bdecdd633e9e1e974e3b12450296b723bf1090f10b10425" => :high_sierra
sha256 "553d953d5a651403004297dc7a5415b2463d57f99380df2e2547ab92aa2d62f2" => :sierra
end
depends_on :java => "1.8"
depends_on :macos => :yosemite
def install
ENV["EMBED_LABEL"] = "#{version}-homebrew"
# Force Bazel ./compile.sh to put its temporary files in the buildpath
ENV["BAZEL_WRKDIR"] = buildpath/"work"
(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"
bin.install "output/bazel" => "bazel-real"
bin.env_script_all_files(libexec/"bin", Language::Java.java_home_env("1.8"))
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"
system "bazel-bin/bazel-test"
end
end