commit | 3a78d01631ea8c2f7b747f6f0e7b4d29c735371d | [log] [tgz] |
---|---|---|
author | Vinh Tran <vinhdaitran@google.com> | Tue Oct 17 12:52:37 2023 -0400 |
committer | GitHub <noreply@github.com> | Tue Oct 17 18:52:37 2023 +0200 |
tree | d4093f37c78e12ea367c90a85a6e4a59193efcb5 | |
parent | b4135d6a4a1dc330e132742e5cbf8f06b76d92a7 [diff] |
Refactor rustc_compile_action to construct CrateInfo internally (#2188) In #2161, I anticipated to make [create_crate_info_dict](https://github.com/bazelbuild/rules_rust/pull/2161/files#diff-b75adb75969318e09670c45b8eea5aaf147fdc1d2cf229a72a17bd39edf49163R853) reusable across all rules and aspects. The logic to construct `crate_info` is significantly different among the rules and aspects. As I tried to to expand the arguments to make `create_crate_info_dict` universally reusable, the arguments grow which make it not worth anymore. This PR changes the refactoring approach. Before (result from #2161) ``` def _rust_library_common() return rustc_compile_action( # the callback allows us to slowly refactor one rule or aspect at a time. create_crate_info_callback = create_crate_info_dict, ) def rustc_compile_action(create_crate_info_callback) if create_crate_info_callback: crate_info_dict = create_crate_info_callback() ``` After (result from this PR) ``` def _rust_library_common() # create crate_info_dict return rustc_compile_action( crate_info_dict = crate_info_dict, ) def rustc_compile_action(crate_info_dict) # crate_info_dict always exists ``` Instead of creating `crate_info_dict` at the beginning of `rustc_compile_action`, this PR lifted the creation logic to the rules and aspects completely so that they can add any custom logic without caring about the `rustc_compile_action`'s implementation. --------- 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.