Skip to content

Commit

Permalink
Interpolate in key_value_arg, such as --crate-map
Browse files Browse the repository at this point in the history
Summary:
`rustc_action.py` receives arguments like:

```
...
--crate-map=$(cat buck-out/v2/gen/fbcode/767cf7b4a84025eb/aiplatform/hpc_scheduler/if/__hpcscheduler-rust-crate__/out/types)=fbcode//aiplatform/hpc_scheduler/if:hpcscheduler-rust
...
buck-out/v2/gen/fbcode/99cab575c71b0a4b/tools/build/buck/wrappers/__rust-platform010-clang-15-compiler__/__command_alias_trampoline.sh
...
--extern=$(cat buck-out/v2/gen/fbcode/767cf7b4a84025eb/aiplatform/hpc_scheduler/if/__hpcscheduler-rust-crate__/out/types)=buck-out/v2/gen/fbcode/767cf7b4a84025eb/aiplatform/hpc_scheduler/if/__hpcscheduler-rust__/rlib-pic-static_pic-link/libhpcscheduler-02ee50c9.rlib
```

where the `--crate-map` flag (which comes before path/to/bin/rustc) is for our rustc_action.py, while `--extern` (which comes after) is a flag for rustc.

The `--crate-map` flags are used by rustc_action.py to remap crate **names** reported as unused by rustc into Buck **labels** to be removed from a target's `deps`.

Reviewed By: zertosh

Differential Revision: D58790339

fbshipit-source-id: 3b180529b388d893abbbf2bbcd192acbb23d44d1
  • Loading branch information
David Tolnay authored and facebook-github-bot committed Jun 19, 2024
1 parent 15feff9 commit ffe6782
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions prelude/rust/tools/rustc_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def eprint(*args: Any, **kwargs: Any) -> None:


def key_value_arg(s: str) -> Tuple[str, str]:
s = arg_eval(s)
key_value = s.split("=", maxsplit=1)
if len(key_value) == 2:
return (key_value[0], key_value[1])
Expand Down

0 comments on commit ffe6782

Please sign in to comment.