-
Notifications
You must be signed in to change notification settings - Fork 177
/
buck.rb
70 lines (64 loc) · 2.39 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
# frozen_string_literal: true
class Buck < Formula
BUCK_VERSION = "2022.05.05.01"
BUCK_RELEASE_TIMESTAMP = "1651780996"
desc "Facebook's Buck build system"
homepage "https://buckbuild.com/"
url "https://github.com/facebook/buck/archive/v#{BUCK_VERSION}.tar.gz"
sha256 "f047dd51f0b47f7f57ee329b6c96cdcd8228b1d55be31c563f007e283c16bb07"
license "Apache-2.0"
revision 0
head "https://github.com/facebook/buck.git", branch: "main"
bottle do
root_url "https://github.com/facebook/buck/releases/download/v#{BUCK_VERSION}"
sha256 cellar: :any_skip_relocation, yosemite: "84ed6c26e1796170bb1733c6ef8638099405a5007fc832d937a7c1e03ee337e2"
end
depends_on "[email protected]"
depends_on "openjdk@8"
def install
# First, bootstrap the build by building Buck with Apache Ant.
ENV["JAVA_HOME"] = Formula["openjdk@8"].opt_libexec/"openjdk.jdk/Contents/Home"
ant_path = `"#{HOMEBREW_PREFIX}"/bin/brew --prefix [email protected]`
ant_1_9 = ant_path.strip + "/bin/ant"
ohai "Bootstrapping buck with ant using " + ant_1_9
system(
ant_1_9,
"-Drelease.version=#{BUCK_VERSION}",
"-Drelease.timestamp=#{BUCK_RELEASE_TIMESTAMP}",
)
# Mark the build as successful.
touch "ant-out/successful-build"
# Now, build the Buck PEX archive with the Buck bootstrap.
ohai "Building buck with buck"
mkdir_p bin
system(
"./bin/buck",
"build",
"-c",
"buck.release_version=#{BUCK_VERSION}",
"-c",
"buck.release_timestamp=#{BUCK_RELEASE_TIMESTAMP}",
"--out",
"#{bin}/buck",
"buck",
)
bin.env_script_all_files(libexec/"bin",
JAVA_HOME: Formula["openjdk@8"].opt_libexec/"openjdk.jdk/Contents/Home")
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 = shell_output("#{bin}/buck run :foo").chomp
ohai "Got output from binary: " + stdout
assert_equal "Hello world!", stdout
ohai "Test complete."
end
end