Skip to content

feat: Expand locations in environment variables - #119

Merged
Ahajha merged 5 commits into
mainfrom
trotta/feat-expand-locations-in-environment-variables
Dec 3, 2026
Merged

Ahajha merged 5 commits into
mainfrom
trotta/feat-expand-locations-in-environment-variables

Conversation

@Ahajha

@Ahajha Ahajha commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

This follows similar support in copts. Bazel doesn't (yet) support environment variable path mapping, so we add a shim script that is passed env vars as args (which do get path mapped), and turns them into actual env vars.

This also adds support for having multiple locations in a single env var, which extends to copts as well.

I can't add tests here as none of the use cases are public and packaged yet, but we should be able to in the future.

@Ahajha
Ahajha marked this pull request as ready for review December 3, 2026 19:47
@Ahajha
Ahajha requested a review from a team as a code owner December 3, 2026 19:47
@Ahajha
Ahajha requested a balanced review from Copilot December 3, 2026 19:47

Copilot AI 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.

🟡 Changes recommended

Environment preprocessing rejects valid make-variable expressions, and directory-artifact expansion produces incorrect paths in compiler options and environment values.

2 open issues
What changed in this PR

Adds location expansion to Mojo toolchain environment variables, using a shell shim to support Bazel path mapping.

Changes:

  • Parses multiple location references in environment values and compiler options.
  • Routes compilation through an environment-setting shim.
  • Resolves runtime environment paths relative to runfiles.
File Description
mojo/​toolchain.bzl Preprocesses environments and documents location support.
mojo/​providers.bzl Adds preprocessed environment fields.
mojo/​private/​utils.bzl Adds shared parsing, resolution, and shim helpers.
mojo/​private/​mojo_binary_test.bzl Integrates the shim and runtime environment resolution.
mojo/​private/​env_shim.sh Exports supplied variables before executing Mojo.
mojo/​private/​BUILD.bazel Exposes the shim script.
mojo/​mojo_library.bzl Uses the shim for library precompilation.

Review effort: Balanced

Comment thread mojo/private/utils.bzl Resolved
Comment thread mojo/toolchain.bzl Resolved
@Ahajha
Ahajha merged commit 3c0f2f2 into main Dec 3, 2026
25 checks passed
@Ahajha
Ahajha deleted the trotta/feat-expand-locations-in-environment-variables branch December 3, 2026 19:57
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