forked from facebook/homebrew-fb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buck.rb
55 lines (50 loc) · 1.89 KB
/
buck.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require "open3"
class Buck < Formula
@@buck_version = "2016.11.11.01"
desc "The Buck build system"
homepage "https://buckbuild.com/"
head "https://github.com/facebook/buck.git"
version @@buck_version
url "https://api.github.com/repos/facebook/buck/tarball/v2016.11.11.01"
sha256 "5b27696a8eb532fa7fecbff458bfd406de861dfc8ef5f551ee43c4c9b0c6efd8"
bottle do
root_url "https://github.com/facebook/buck/releases/download/v#{@@buck_version}"
cellar :any_skip_relocation
sha256 "d8ea7fd04d45e9d2ec63feaaee26fd0093ff6ccbc995672f179d86ae091d5bb9" => :yosemite_or_later
end
depends_on :java => "1.8+"
depends_on :ant
def install
# First, bootstrap the build by building Buck with Apache Ant.
system "ant"
# Mark the build as successful.
File.open("build/successful-build", "w") {}
# Now, build the Buck PEX archive with the Buck bootstrap.
system "./bin/buck", "build", "buck"
mkdir_p "#{bin}"
ohai "Finding PEX archive..."
stdout, stderr, status = Open3.capture3("./bin/buck", "targets", "--show_output", "buck")
if status == 0
stdout.chomp!
_, path = stdout.split(" ", 2)
ohai "Installing buck in #{bin}/buck..."
cp(path, "#{bin}/buck", :preserve => true)
ohai "Done."
else
onoe "Could not find location of built buck: " + stderr
end
end
test do
ohai "Setting up Buck repository in " + testpath
(testpath/".buckconfig").write("")
(testpath/"BUCK").write("cxx_binary(name = 'foo', srcs = ['foo.c'])")
(testpath/"foo.c").write("#include <stdio.h>\nint main(int argc, char **argv) { printf(\"Hello world!\\n\"); }\n")
ohai "Building and running C binary..."
stdout, stderr, status = Open3.capture3("#{bin}/buck", "run", ":foo")
stdout.chomp!
ohai "Got output from binary: " + stdout
assert_equal 0, status
assert_equal "Hello world!", stdout
ohai "Test complete."
end
end