76 lines
2.5 KiB
Ruby
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/0.22.0/bazel-0.22.0-dist.zip"
|
|
sha256 "6860a226c8123770b122189636fb0c156c6e5c9027b5b245ac3b2315b7b55641"
|
|
revision 1
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "36d594b71ab010c6b28fe6b3470ccc5623cce7b8eca1197ec914e3378e4f1420" => :mojave
|
|
sha256 "4c6bc36e50b25fbf63c07d7192aabf596a2be7b3df39310636f3ac5e69817f3e" => :high_sierra
|
|
sha256 "47ee1cc2a98454185c2710802b48883ed7a9c1ea57f61fb9634be8248816f088" => :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
|