Skip to content

Instantly share code, notes, and snippets.

View rrbutani's full-sized avatar
🐢
slowly but surely

Rahul Butani rrbutani

🐢
slowly but surely
  • 19:06 (UTC -07:00)
View GitHub Profile
`bazel query 'deps(:_version_is_at_most_9_7)' --output=graph`
@rrbutani
rrbutani / ..double_exec_transition
Last active May 23, 2024 21:30
bazel double exec transition test
.
{
inputs = {
nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
flake-utils.url = github:numtide/flake-utils;
};
outputs = { nixpkgs, flake-utils, self }: flake-utils.lib.eachDefaultSystem (system: let
np = nixpkgs.legacyPackages.${system};
inherit (np) lib;
# TODO: macOS..
Rules for invoking patchelf in Bazel
@rrbutani
rrbutani / .bazel-toolchain-transitions.md
Last active October 28, 2023 22:32
.bazel-toolchain-transitions

September 5th, 2023

having a bit of a crisis

runfiles are broken

using platforms to model build environments is broken because of how strategies interact with platforms

bzlmod is conceptually pretty excellent but still has tons of warts and weird limitations that require lots of creative workarounds

"""Workarounds for https://github.com/bazelbuild/bazel/issues/19055."""
# TODO(build, bazel, blzmod): if new APIs are introduced resolving this issue:
# https://github.com/bazelbuild/bazel/issues/19055, use them in lieu of this
# function.
def get_sibling_repo_in_module_extension(rctx, repo_name):
"""Gets the _canonical_ name for a sibling repo in the module extension.
## Background
@rrbutani
rrbutani / starlark_new_local_repository.bzl
Created August 28, 2023 03:40
starlark_new_local_repository.bzl
"""Starlark version of `new_local_repository` for module extensions.
Currently `native.new_local_repository` cannot be called from Bazel module
extensions: https://github.com/bazelbuild/bazel/issues/15412
The plan is to eventually "starlark-ify" this rule:
- https://docs.google.com/document/d/17RZKMuMjAIgNfFdrsLhqNsMTQDSS-BBA-S-fCSBPV7M/edit
- https://github.com/bazelbuild/bazel/issues/18285
In the interim we've got our own Starlark-native `new_local_repository`
@rrbutani
rrbutani / .bazel-spawn-strategy-selection-for-non-host-exec-platform
Last active September 2, 2023 04:45
Bazel spawn strategy selection for non-host exec platforms
We couldn’t find that file to show.
Meant to be used together with this Bazel fork:
- https://github.com/rrbutani/bazel/compare/70fc57d29ce21204f28f8462627badbd5b750787...b8553d4fcf157acddbac855a3945c74d0f962c27
@rrbutani
rrbutani / find_package.bzl
Last active August 13, 2023 06:52
find_package.bzl
"""Helper functions for repository rules that ensure labels are well-formed.
Labels constructed and used within repository rules do not have their name (the
part after `:`) checked against the package structure of the repo they point to;
they are allowed to refer to source artifacts via paths that do not respect the
package structure or visibility.
For example, for a source file that lives at `@foo//bar/baz:some/file/path`, all
of the following — when passed to repository context functions like `rctx.path`
or `rctx.read` — will refer to the file, without error: