Support path mapping in Rust Starlark actions#4063
Conversation
|
Wasn't this done in #4011 ? Is there a gap in the regression testing? |
|
#4011 seems have covered most things. We just noticed that target_flag_value was not updated to pass in File object instead of path (as string). When doing e2e testing for some of our targets this was causing failures for us |
Fixes are welcome but can you also add regression testing for the missed case? |
e8974e3 to
c170e7b
Compare
Transition from passing raw string paths (`.path`) to passing `File` objects directly to action arguments (`Args`). This allows Bazel to mutate paths during execution, which is required for path mapping compatibility. For more details on path mapping best practices, see: bazelbuild/bazel#22658
c170e7b to
096ab91
Compare
|
I'm not familiar with this codebase, so the best way I could find to do this was to add an assertion on the flag type which implies that path mapping is supported. Let me know if that works. |
| def _will_emit_object_file(emit): | ||
| for e in emit: | ||
| if e == "obj" or e.startswith("obj="): | ||
| # If 'e' is a File object (not a string), it represents an object file |
There was a problem hiding this comment.
Could we model such elements of emit as (string, Path) tuples?
We've got some in-progress extensions internally that we'd like to upstream as soon as we're confident they work properly that use a similar pattern, such as --emit=thin-link-bitcode=<path>
I think an integration test would be best here. Can you define some target that naturally triggers this code path? |
To provide more context as someone on both sides -- Internally we define rust_toolchains manually; we use the target_json functionality. To get to a behavior that this changes, you need something like that: a rust library that's set up to use a rust toolchain that uses a target json: I don't know of a good way to spawn such a custom toolchain. @UebelAndre -- do you have suggestions? |
Transition from passing raw string paths (
.path) to passingFileobjects directly to action arguments (Args). This allows Bazel to mutate paths during execution, which is required for path mapping compatibility.For more details on path mapping best practices, see: bazelbuild/bazel#22658