fix: Only enable path mapping if supported#1243
Conversation
|
970c84b to
3690617
Compare
Verified manually by running `bazel test //... --experimental_output_paths=strip`.
3690617 to
01ba0ec
Compare
There was a problem hiding this comment.
Pull request overview
This PR refines the path mapping support that was unconditionally enabled in PR #1217. It makes path mapping conditional, only enabling it when actions don't use location/make variable expansion or embed paths in configuration files or environment variables. This ensures compatibility with Bazel's --experimental_output_paths=strip flag.
Changes:
- Added conditional path mapping to
run_binaryandexpand_templaterules based on whether expansion occurs - Removed path mapping support from
copy_to_directorydue to paths embedded in JSON config - Renamed
COPY_EXECUTION_REQUIREMENTStoSUPPORTS_PATH_MAPPINGfor clarity
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| lib/private/copy_common.bzl | Renamed constant from COPY_EXECUTION_REQUIREMENTS to SUPPORTS_PATH_MAPPING for better clarity |
| lib/private/copy_file.bzl | Updated to use renamed constant; continues to support path mapping |
| lib/private/copy_directory.bzl | Updated to use renamed constant; continues to support path mapping |
| lib/private/copy_to_directory.bzl | Removed path mapping support and added TODO comment explaining the JSON config prevents path mapping |
| lib/private/expand_template.bzl | Added logic to conditionally enable path mapping only when substitutions don't use expansion |
| lib/private/run_binary.bzl | Added logic to conditionally enable path mapping based on args/env expansion and stamping usage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@alexeagle Could you cut a release with this change? |


#1217 unconditionally enabled support for path mapping for rules that may use location expansion or hardcode paths in other ways. Instead, only enable it when it is clearly safe to do so.
Verified manually by running
bazel test //... --experimental_output_paths=strip.Work towards cerisier/toolchains_llvm_bootstrapped#334