Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ common --tool_java_runtime_version=remotejdk_25
# Match Gradle's manifest merger: plugin library permissions must reach the APK.
common --merge_android_manifest_permissions

# Hermeticity. Every toolchain (LLVM, Rust, JDK, Android SDK/NDK, Dart/Flutter,
# Go) is downloaded and checksummed, so no action needs the network, and no
# host C/C++ compiler may be autodetected as a fallback toolchain.
common --sandbox_default_allow_network=false
common --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
# Persistent workers (Javac, Kotlin, Android tools) otherwise run unsandboxed
# and can read undeclared inputs from the execroot.
common --worker_sandboxing

# A disk cache shared by every checkout and worktree on this machine: action
# keys are independent of the workspace path, so a fresh worktree reuses the
# outputs of all others instead of rebuilding from scratch.
common --disk_cache=~/.cache/bazel-disk-cache
common --experimental_disk_cache_gc_max_size=60G

# BuildBuddy is opt-in so a fresh clone works without credentials. See
# user.bazelrc.example; --config=remote also enables this cache/BES config.
build:buildbuddy --bes_backend=grpcs://remote.buildbuddy.io
Expand All @@ -20,7 +35,6 @@ build:buildbuddy --experimental_remote_downloader_local_fallback
build:buildbuddy --remote_timeout=10m
build:buildbuddy --remote_cache_compression
build:buildbuddy --remote_cache_async
build:buildbuddy --remote_download_toplevel
build:buildbuddy --nolegacy_important_outputs
build:buildbuddy --bes_upload_mode=fully_async

Expand All @@ -32,6 +46,14 @@ build:buildbuddy --build_metadata=REPO_URL=https://github.com/pawelchcki/razemif
# the workflow runner because this organization has no remote-executor pool.
build:ci --config=buildbuddy
build:ci --build_metadata=ROLE=CI
# The runner's output base and the BuildBuddy cache already cover what the
# local disk cache would, without spending runner disk on a third copy.
common:ci --disk_cache=
# Fail rather than silently re-resolve when MODULE.bazel.lock is stale.
common:ci --lockfile_mode=error
# Only download what a step inspects; steps that need artifacts on disk pass
# --remote_download_toplevel explicitly.
build:ci --remote_download_minimal

# //:clippy is a gate, so warnings must fail it -- the equivalent of
# `cargo clippy -- -D warnings`.
Expand Down
11 changes: 8 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,16 @@ register_toolchains(

# rules_rs is implemented on a patched compatibility repository. Keep that
# implementation detail behind a rules_rs-owned apparent name; Razemify's Rust
# build rules are loaded exclusively from @rules_rs. The local patch fixes
# response-file substitutions while rules_rs bootstraps its process wrapper.
# build rules are loaded exclusively from @rules_rs. The local patch redacts the
# exec root from build-script env output when it precedes `=`, as in the
# `--remap-path-prefix=<exec_root>=.` that rav1e and av-scenechange echo back
# from CARGO_ENCODED_RUSTFLAGS. Unpatched, those outputs embed the per-action
# sandbox path, so neither crate is ever a cache hit on a fresh output base.
# Drop once https://github.com/hermeticbuild/rules_rust/pull/84 reaches a
# rules_rs release.
rules_rs_internal = use_extension("@rules_rs//rs:rules_rust.bzl", "rules_rust")
rules_rs_internal.patch(
patches = ["//bazel:rules_rs_bootstrap_determinism.patch"],
patches = ["//bazel:rules_rs_build_script_env_determinism.patch"],
strip = 1,
)
use_repo(rules_rs_internal, rules_rs_internal = "rules_rust")
Expand Down
2 changes: 1 addition & 1 deletion bazel/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ exports_files([
"rules_android_desugar_memory.patch",
"rules_android_manifest_log_determinism.patch",
"rustix_determinism.patch",
"rules_rs_bootstrap_determinism.patch",
"rules_rs_build_script_env_determinism.patch",
])
64 changes: 0 additions & 64 deletions bazel/rules_rs_bootstrap_determinism.patch

This file was deleted.

14 changes: 14 additions & 0 deletions bazel/rules_rs_build_script_env_determinism.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- a/cargo/private/cargo_build_script_runner/lib.rs
+++ b/cargo/private/cargo_build_script_runner/lib.rs
@@ -340,6 +340,11 @@
value
.replace(&format!("{exec_root}/"), "${pwd}/")
.replace(&format!("{exec_root}\\"), "${pwd}\\")
+ // Flags such as `--remap-path-prefix=<exec_root>=.` (which build
+ // scripts see in CARGO_ENCODED_RUSTFLAGS and may echo back as
+ // `cargo:rustc-env`) follow the exec root with `=`. Leaving it
+ // unredacted bakes the per-action sandbox path into the output.
+ .replace(&format!("{exec_root}="), "${pwd}=")
}

/// Redact for env vars: uses the generic `${out_dir}` token, resolved
8 changes: 8 additions & 0 deletions buildbuddy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ actions:
- "*"
container_image: "ubuntu-24.04"
timeout: "30m"
# The default Linux workflow VM (3 CPU, 8GB RAM, 20GB disk) runs out of
# disk once the Android SDK/NDK, LLVM, Flutter and JDK repositories, the
# output tree, and the recycled runner's state add up, and 3 CPUs make
# every remote-cache miss slow.
resource_requests:
cpu: 16
memory: 32GB
disk: 60GB
steps:
- run: |
bazel test \
Expand Down