Wire cpp_hdrs through the build system#445
Open
copybara-service[bot] wants to merge 1 commit intomainfrom
Open
Wire cpp_hdrs through the build system#445copybara-service[bot] wants to merge 1 commit intomainfrom
copybara-service[bot] wants to merge 1 commit intomainfrom
Conversation
PiperOrigin-RevId: 868278767
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wire cpp_hdrs through the build system
I have absolutely no idea what I'm doing but I have the desired end behavior, so instead I'll describe:
Please give me feedback on if there's a better way to do this.
Our story starts here: []
As you can see, this is the end CUJ I ended up with, as shown in
third_party/absl/functional/BUILD. You can just have that additional file on the Crubity thingy, and Crubit will understand what you want. The thing to test here isblaze test //third_party/crubit/rs_bindings_from_cc/test/consume_absl:uses_anyinvocable_testSo how did I get here? I initially just tried to wire these additional
cpp_hdrsto the target they were on (absl/functional:any_invocablegetsany_invocable_crubit_abi.has a public_hdr), but quickly realized this doesn't work because while they will be exposed to the clang invocation on that target, when it came time to generate bindings for a dependent, the extracpp_hdrs, likeany_invocable_crubit_abi.h, are nowhere to be found in the transitive closure of includes inmy_cpp_library_that_uses_any_invocable.h.This made me think that these headers need to be wired all the way though all the deps, and be considered as public headers on the top-level cc_library that we are running on to ensure they are being included in the
_rs_api_impl.ccfile. The way I did this is super messy.I did some digging, and it seems like
RustBindingsFromCcInfois the provider that goes through all the reverse deps of a target, andAdditionalRustSrcsProviderInfoare the "leaf" providers that attach things along the way. So I addedadditional_cpp_hdrstoRustBindingsFromCcInfo, andcpp_hdrstoAdditionalRustSrcsProviderInfo. Then in_rust_bindings_from_cc_aspect_impl, I coalesced theadditional_cpp_hdrsfrom any deps along with thecpp_hdrsfrom theAdditionalRustSrcsProviderInfoon this target, if there was one. Then when we go to callgenerate_and_compile_bindings, I ensure thatpublic_hdrsalso includes these extra C++ headers, put I also pass in the extra headers separately so they can be forwarded to the producedRustBindingsFromCcInfo.