Skip to content

feat: add $(rlocation ...) syntax as a cleaner alternative to $$RUNFILES_DIR/$(rlocationpath ...)#2873

Closed
acozzette wants to merge 10 commits into
aspect-build:mainfrom
acozzette:adamc/rlocation
Closed

feat: add $(rlocation ...) syntax as a cleaner alternative to $$RUNFILES_DIR/$(rlocationpath ...)#2873
acozzette wants to merge 10 commits into
aspect-build:mainfrom
acozzette:adamc/rlocation

Conversation

@acozzette

@acozzette acozzette commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

This change also exposes the expand_rlocation_refs helper function in js_lib_helpers so that we can reuse it in rules_webpack and possibly other rulesets where it might be useful.


Changes are visible to end-users: yes

  • Searched for relevant documentation and updated as needed: yes
  • Breaking change (forces users to change their own code or config): no
  • Suggested release notes appear below: yes

js_binary now supports the $(rlocation ...) syntax in fixed_args.

Test plan

  • Covered by existing test cases
  • New test cases added

acozzette and others added 3 commits June 3, 2026 10:33
…LES_DIR/$(rlocationpath ...)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
env values are quoted and stored as literal strings, so $RUNFILES_DIR
would not be evaluated at runtime.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
acozzette and others added 5 commits June 3, 2026 11:07
…lib_helpers

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@acozzette acozzette marked this pull request as ready for review June 3, 2026 21:30
@acozzette acozzette requested a review from jbedard June 3, 2026 21:31

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c8bcba6317

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread js/private/js_helpers.bzl
"build",
"--config",
"$$RUNFILES_DIR/$(rlocationpath :rspack_config)",
"$(rlocation :rspack_config)",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we are adding a magic $(rlocation) util in addition to the "standard" $() utils. Where/who defines those "standard" ones? Are they native bazel?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, this is our own magic one. The standard ones are native Bazel in ctx.expand_location(): https://bazel.build/rules/lib/builtins/ctx#expand_location

Comment thread js/private/js_helpers.bzl
@jbedard

jbedard commented Jun 4, 2026

Copy link
Copy Markdown
Member

@codex

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread js/private/js_helpers.bzl
result.append(remaining[:idx])
remaining = remaining[idx + len(prefix):]

# Parentheses are allowed in Bazel target names and could therefore

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can they!? I thought we exclusively escaped them in rules_js because they can't....

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, surprisingly they are explicitly allowed according to the documentation here: https://bazel.build/concepts/labels#target-names

@acozzette acozzette closed this Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants