homebrew-core/Formula/bazel.rb

63 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.15.0/bazel-0.15.0-dist.zip"
sha256 "c3b716e6625e6b8c323350c95cd3ae0f56aeb00458dddd10544d5bead8a7b602"
bottle do
cellar :any_skip_relocation
sha256 "334102ca196fbb576ae317587906cf520bab20af18aebe6a79c709e59c9494be" => :high_sierra
sha256 "fd3b5810bcb79c3ef45032a02901a2aed30a35152cc496103ea6c849849ad302" => :sierra
sha256 "47adb97fa15be20167d30c788b8f0b340c2a026ae063b28205189587221e4c89" => :el_capitan
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