-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor CrateInfo construction (#2161)
## Description This PR addresses #2013 to ensure rust-analyzer can access all the env vars the rust rules pass to `rustc` at compile time. This is a large refactoring in almost all the rules and aspects so I aim this PR to just fix `rust_library` rule. The follow-up PR will address the remaining rules and aspects. ## Summary * Create `create_crate_info_dict` function in `rust/private/utils.bzl` to create a mutable dict repsenting CrateInfo * Move `_determine_lib_name`, `get_edition`, `_transform_sources` functions to `rust/private/utils.bzl` to avoid cyclic dependency when `create_crate_info_dict` function use these * Introduce optional `create_crate_info_callback` attribute to `rustc_compile_action` to allow creating `CrateInfo` inside `rustc_compile_action`. This optional attribute allows scoping the refactoring in this PR to just `rust_library` rule. * Introduce optional `skip_expanding_rustc_env` attribute to `rustc_compile_action` to skip expanding `rustc_env` attr. This is useful for `clippy` aspect and `rust_test` rule because the `CrateInfo` provided from the depended `rust_library` already expands all the env vars before returning the provider downstream. ## Notes * `rustc_env_attr` is a temporary field in `CrateInfo` and needed by the rules and aspects not migrated to create `CrateInfo` in `rustc_compile_action` yet. It will be remove in the next PR after `CrateInfo.rustc_env` is always expanded. * `create_crate_info_callback` will be removed from `rustc_compile_action` after all `CrateInfo`s are created inside `rustc_compile_action`. --------- Co-authored-by: scentini <[email protected]>
- Loading branch information
Showing
15 changed files
with
279 additions
and
182 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.