Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Wire cpp_hdrs through the build system#445

Open
copybara-service[bot] wants to merge 1 commit intomainfrom
test_868278767
Open

Wire cpp_hdrs through the build system#445
copybara-service[bot] wants to merge 1 commit intomainfrom
test_868278767

Conversation

@copybara-service
Copy link

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:

  1. My motivation
  2. What I think I did

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 is

blaze test //third_party/crubit/rs_bindings_from_cc/test/consume_absl:uses_anyinvocable_test

So how did I get here? I initially just tried to wire these additional cpp_hdrs to the target they were on (absl/functional:any_invocable gets any_invocable_crubit_abi.h as 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 extra cpp_hdrs, like any_invocable_crubit_abi.h, are nowhere to be found in the transitive closure of includes in my_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.cc file. The way I did this is super messy.

I did some digging, and it seems like RustBindingsFromCcInfo is the provider that goes through all the reverse deps of a target, and AdditionalRustSrcsProviderInfo are the "leaf" providers that attach things along the way. So I added additional_cpp_hdrs to RustBindingsFromCcInfo, and cpp_hdrs to AdditionalRustSrcsProviderInfo. Then in _rust_bindings_from_cc_aspect_impl, I coalesced the additional_cpp_hdrs from any deps along with the cpp_hdrs from the AdditionalRustSrcsProviderInfo on this target, if there was one. Then when we go to call generate_and_compile_bindings, I ensure that public_hdrs also includes these extra C++ headers, put I also pass in the extra headers separately so they can be forwarded to the produced RustBindingsFromCcInfo.

PiperOrigin-RevId: 868278767
@google-cla
Copy link

google-cla bot commented Feb 10, 2026

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants