80 lines
2.6 KiB
Ruby
80 lines
2.6 KiB
Ruby
class Bazel < Formula
|
|
desc "Google's own build tool"
|
|
homepage "https://bazel.build/"
|
|
url "https://github.com/bazelbuild/bazel/releases/download/2.2.0/bazel-2.2.0-dist.zip"
|
|
sha256 "9379878a834d105a47a87d3d7b981852dd9f64bc16620eacd564b48533e169a7"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "8aeeb7493f11cfdfaa119f75d8d342a548d97a29460aa46653a709c80393d943" => :catalina
|
|
sha256 "2b3f486f6c65fb311675a025945a33c8befc23a69d93a154d2d05814b8f42aeb" => :mojave
|
|
sha256 "9a564791d72d672671f0ced58f343ab84a345374cf44badbdbbc73a18332e95d" => :high_sierra
|
|
end
|
|
|
|
depends_on "python@3.8" => :build
|
|
depends_on :java => "1.8"
|
|
depends_on :macos => :yosemite
|
|
|
|
uses_from_macos "zip"
|
|
|
|
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"
|
|
ln_s bin/"bazel", bin/"bazel-#{version}"
|
|
(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
|