75 lines
2.5 KiB
Ruby
75 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/0.23.2/bazel-0.23.2-dist.zip"
|
|
sha256 "293a5a7d851e0618eeb5e6958d94a11d45b6a00f2ba9376de61ac2bd5f917439"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "9e48330ced24e922d0bd82cb6458adb29b953f53642b3e5a71672d9607805483" => :mojave
|
|
sha256 "6c0a2979439e2d085d4186e4c6f3898b653e25d864eca7c5b85810da40335656" => :high_sierra
|
|
sha256 "98b0de9b3188a8fc9b4d8d92d47598299ec56ac17d1acb1e763fab34bdc672c3" => :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",
|
|
"--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
|