Repository navigation
feat: Expand locations in environment variables - #119
Merged
Ahajha merged 5 commits intoDec 3, 2026
Merged
Conversation
There was a problem hiding this comment.
🟡 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
Ahajha
deleted the
trotta/feat-expand-locations-in-environment-variables
branch
December 3, 2026 19:57
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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.