-
-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RECC is a compiler launcher that caches the results on compilation and link command, and optionally forward them to a remote execution service. Remove running launchctrl command in caveat Update Formula/r/recc.rb Co-authored-by: Carlo Cabrera <[email protected]> Update Formula/r/recc.rb Co-authored-by: Carlo Cabrera <[email protected]> Update Formula/r/recc.rb Co-authored-by: Carlo Cabrera <[email protected]> Update Formula/r/recc.rb Co-authored-by: Carlo Cabrera <[email protected]> recc 1.2.20 Address review comments recc 1.2.20 Add test recc 1.2.20 tests Added tests to start recc-server and run recc-cc command twice. The second run should result in a cache hit. Update test case
- Loading branch information
Showing
1 changed file
with
188 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
class Recc < Formula | ||
desc "Remote Execution Caching Compiler" | ||
homepage "https://buildgrid.gitlab.io/recc" | ||
url "https://gitlab.com/BuildGrid/buildbox/buildbox/-/archive/1.2.20/buildbox-1.2.20.tar.gz" | ||
sha256 "5ad5ccbad1250accc984823bd5d78604441c7711320b0569889f45f329ed6311" | ||
license "Apache-2.0" | ||
head "https://gitlab.com/BuildGrid/buildbox/buildbox.git", branch: "master" | ||
|
||
depends_on "cmake" => :build | ||
depends_on "tomlplusplus" => :build | ||
depends_on "abseil" | ||
depends_on "c-ares" | ||
depends_on "glog" | ||
depends_on "grpc" | ||
depends_on "openssl@3" | ||
depends_on "protobuf" | ||
depends_on "re2" | ||
uses_from_macos "zlib" | ||
|
||
on_macos do | ||
depends_on "gflags" | ||
end | ||
|
||
on_linux do | ||
depends_on "pkg-config" => :build | ||
depends_on "util-linux" => :build | ||
end | ||
|
||
def generate_recc_conf(config_directory) | ||
config_directory.mkpath | ||
(config_directory/"recc.conf").write <<~EOS | ||
## | ||
# For the list of configuration parameters please visit: | ||
# https://buildgrid.gitlab.io/recc/configuration-variables.html | ||
# | ||
# The configuration file settings use lowercase letters without the RECC_ prefix | ||
# By default recc reads the configuration options from the following places, | ||
# applying settings bottom-up, with 1 being the last applied configuration. | ||
# If an option is set in multiple places, the one higher on this list will be the | ||
# effective one | ||
# | ||
# 1. Environment variables | ||
# 2. ${cwd}/recc/recc.conf | ||
# 3. {$RECC_CONFIG_DIRECTORY}/recc.conf | ||
# 4. ~/.recc/recc.conf | ||
# 5. #{etc}/recc/recc.conf | ||
# 6. #{prefix}/etc/recc/recc.conf | ||
## | ||
# Protocol version used for communicating with the REAPI server | ||
reapi_version=2.2 | ||
# The URI of the server | ||
server=unix://#{var}/recc/casd/casd.sock | ||
# Instance name provided by the server | ||
instance=recc-server | ||
# Use cache-only mode, build anything not available in the cache locally | ||
cache_only=1 | ||
# Upload results from the local builds to cache | ||
cache_upload_local_build=1 | ||
# Upload failed results from the local builds to cache | ||
cache_upload_failed_build=1 | ||
# Enable for link commands | ||
link=1 | ||
# Use cache-only mode for link commands | ||
link_cache_only=1 | ||
# Report all entries returned by the dependency command, even if they are absolute paths | ||
deps_global_paths=1 | ||
# Do not rewrite absolute paths to be relative. | ||
no_path_rewrite=1 | ||
# Do not retry | ||
retry_limit=0 | ||
# Platform properties | ||
REMOTE_PLATFORM_OS=<%= platform_os %> | ||
REMOTE_PLATFORM_ISA=<%= Hardware::CPU.arch.to_s %> | ||
EOS | ||
end | ||
|
||
def generate_recc_server(bin_directory) | ||
(bin_directory / "recc-server").write <<~EOS | ||
#!/usr/bin/env sh | ||
#{bin}/buildbox-casd \ | ||
--local-server-instance=recc-server \ | ||
--protect-session-blobs \ | ||
${1:-#{var}/recc/casd} | ||
EOS | ||
end | ||
|
||
def generate_recc_wrapper(bin_directory, compiler) | ||
(bin_directory / "recc-#{compiler}").write <<~EOS | ||
#!/usr/bin/env sh | ||
#{bin}/recc $(command -v #{compiler}) $@ | ||
EOS | ||
end | ||
|
||
def buildbox_cmake_args | ||
%W[ | ||
-DCASD=ON | ||
-DCASD_BUILD_BENCHMARK=OFF | ||
-DCASDOWNLOAD=OFF | ||
-DCASUPLOAD=OFF | ||
-DFUSE=OFF | ||
-DLOGSTREAMRECEIVER=OFF | ||
-DLOGSTREAMTAIL=OFF | ||
-DOUTPUTSTREAMER=OFF | ||
-DRECC=ON | ||
-DREXPLORER=OFF | ||
-DRUMBA=OFF | ||
-DRUN_BUBBLEWRAP=OFF | ||
-DRUN_HOSTTOOLS=ON | ||
-DRUN_OCI=OFF | ||
-DRUN_USERCHROOT=OFF | ||
-DTREXE=OFF | ||
-DWORKER=OFF | ||
-DRECC_CONFIG_PREFIX_DIR=#{etc}/recc | ||
] | ||
end | ||
|
||
def install | ||
system "cmake", "-S", ".", "-B", "build", *buildbox_cmake_args, *std_cmake_args | ||
system "cmake", "--build", "build", "-j", ENV.make_jobs.to_s | ||
system "cmake", "--install", "build" | ||
|
||
generate_recc_wrapper bin, "cc" | ||
generate_recc_wrapper bin, "c++" | ||
generate_recc_wrapper bin, "gcc" | ||
generate_recc_wrapper bin, "g++" | ||
generate_recc_wrapper bin, "clang" | ||
generate_recc_wrapper bin, "clang++" | ||
|
||
generate_recc_server bin | ||
|
||
generate_recc_conf prefix/"etc/recc/" | ||
end | ||
|
||
def caveats | ||
on_macos do | ||
<<~EOS | ||
If you are starting the `recc` service via `brew service start`, please ensure the maxfiles limit | ||
for `launchctl` is larger than 364. If you are running `recc-server` directly, please ensure | ||
`ulimit -Sn` is larger than 364. | ||
To increase the limit and make the change persist across reboots, you can create a launch daemon | ||
using the following steps: | ||
sudo /usr/libexec/PlistBuddy /Library/LaunchDaemons/limit.maxfiles.plist \\ | ||
-c "add Label string com.launchd.maxfiles" \\ | ||
-c "add ProgramArguments array" \\ | ||
-c "add ProgramArguments: string launchctl" \\ | ||
-c "add ProgramArguments: string limit" \\ | ||
-c "add ProgramArguments: string maxfiles" \\ | ||
-c "add ProgramArguments: string 512" \\ | ||
-c "add ProgramArguments: string unlimited" \\ | ||
-c "add RunAtLoad bool true" && \\ | ||
sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist && \\ | ||
sudo chmod 644 /Library/LaunchDaemons/limit.maxfiles.plist && \\ | ||
sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist | ||
EOS | ||
end | ||
end | ||
|
||
service do | ||
run [opt_bin/"recc-server"] | ||
keep_alive true | ||
working_dir var/"recc" | ||
log_path var/"log/casd.log" | ||
error_log_path var/"log/casd-error.log" | ||
end | ||
|
||
test do | ||
Check failure on line 175 in Formula/r/recc.rb GitHub Actions / macOS 15-arm64`brew test --verbose recc` failed on macOS Sequoia (15) on Apple Silicon!
|
||
recc_cache_data_path=testpath/"recc_cache_data_path" | ||
test_dir.mkdir | ||
system bin/"recc-server #{recc_cache_data_path} &" | ||
"test.c".write <<~EOS | ||
int main() {} | ||
EOS | ||
ENV["RECC_SERVER"]=recc_cache_data_path/"casd.sock" | ||
ENV["RECC_LOG_LEVEL"]="info" | ||
system bin/"recc-cc", "-c", "test.c" | ||
output = shell_output(bin/"recc-cc -c test.c 2>&1") | ||
assert_match "Action Cache hit", output | ||
end | ||
end |