homebrew-core/Formula/bazel.rb
2019-10-10 16:06:52 +02:00

76 lines
2.5 KiB
Ruby

class Bazel < Formula
desc "Google's own build tool"
homepage "https://bazel.build/"
url "https://github.com/bazelbuild/bazel/releases/download/1.0.0/bazel-1.0.0-dist.zip"
sha256 "c61daf0b69dd95205c695b2f9022d296d052c727062cfd396d54ffb2154f8cac"
bottle do
cellar :any_skip_relocation
sha256 "71b727a5d5f8202a359076123b5397211dcb94462816e234ec736721f281ca5f" => :catalina
sha256 "5101c7d6eabd530436a558566f2807c2bcc4d19b2325dd681df2792c0619b74e" => :mojave
sha256 "64678dbf69f2e07d52d749939ec03bcb5eeddb226535ac9fdb6b3b6e7920ab1d" => :high_sierra
end
depends_on "python" => :build
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",
"--host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8",
"--java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8",
"--host_javabase=@bazel_tools//tools/jdk:jdk",
"--javabase=@bazel_tools//tools/jdk:jdk",
"scripts:bash_completion"
bin.install "scripts/packages/bazel.sh" => "bazel"
(libexec/"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",
"--host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8",
"--java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8",
"--host_javabase=@bazel_tools//tools/jdk:jdk",
"--javabase=@bazel_tools//tools/jdk:jdk",
"//:bazel-test"
assert_equal "Hi!\n", pipe_output("bazel-bin/bazel-test")
end
end