commit | 8b548d2432d3958e69093c7a0eb5d5550e067347 | [log] [tgz] |
---|---|---|
author | Vinh Tran <vinhdaitran@google.com> | Fri Oct 06 17:18:35 2023 -0400 |
committer | GitHub <noreply@github.com> | Fri Oct 06 23:18:35 2023 +0200 |
tree | aa0501642e785d285aed75f904a360b998a7145c | |
parent | a4587571817d3e920f78c877e4a372f73dd38062 [diff] |
Refactor CrateInfo construction (#2161) ## Description This PR addresses https://github.com/bazelbuild/rules_rust/issues/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 <rosica@google.com>
This repository provides rules for building Rust projects with Bazel.
General discussions and announcements take place in the GitHub Discussions, but there are additional places where community members gather to discuss rules_rust
.
Please refer to the full documentation.