-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bazel Integration #478
Comments
@martinboehme do you have any advice you can offer here? |
If you want to do it right, it's a bit more involved, because you need to use I've got a proof of concept that does this in Starlark, and I've been considering submitting it to rules_rust or autocxx, but it still needs some cleaning up and some tests before it's ready for that. rules_rust is the most central place, but I think it only contains rules for relatively stable / canonical components. autocxx is still pretty experimental, so maybe the autocxx repo would be a better place for the rule to live, at least for now. @adetaylor , what do you think? |
I'm certainly open to having bazel rules in the autocxx repo, so long as they are tested in github actions - hopefully much of that can be copied from https://github.com/dtolnay/cxx/blob/master/.github/workflows/ci.yml? |
I'm going to close this for now, but I'm certainly happy to accept a pull request for bazel rules in future (on the condition that it's automatically tested on github CI - this is something that has been achieved for cxx, so it's obviously possible) |
I would be quite interested in implementing the autocxx equivalent of cxx's The use case is leveraging existing Bazel BUILD system in a large C++ codebase. The pathway I am thinking of for packaging the build in cargo is to first download and install As a matter of fact I am not even sure if this pathway is needed, since one is very likely autogenerating rust-side code and possibly no C++ at all for this use case. So do let me know if so, and one can skip the step of needing to build a |
Actually, thinking a bit further, this sort of defeats the purpose. The purpose of using bazel is to first resolve, download and build external C++ dependencies. Since neither autocxx nor cxx can function without those dependencies first available, I'm not sure how Bazel can be integrated with cxx/autocxx for them to do their work. If no C++ codegen is required, this may not be a problem. Bazel can include the C++ libs as a dependency to the Rust crate, for which there are bazel build rules, and which does Rust-side code gen via proc macros. If C++ codegen is required, then one might want an additional Bazel rule that can perform the codegen while leveraging Bazel to provide the external libs as dependencies. |
Hi, the equivalent of You use it exactly the same way as Good luck achieving the same for Bazel and I'm happy to answer any questions! |
Thanks @adetaylor ! Is that python script or the tool that leverages the data from I'd like to see if I can make it work for me and if so, perhaps later on it could be cleaned up for general use, living in this repo. I think for a test we'd want to at least have an external bazel dependency like boost or absl, to make sure that these dependencies and their paths after resolution can be passed on to the |
Actually, it was thankfully simple to get the include dirs from a bazel rule: However, this does not include all header files referenced. Meaning to say, that |
Leaving a note here that I'm working on this. I got a simple example working today, going to keep working on it. I'll share a link here when I've got something more fully working. |
I've got something that kinda-sorta works. However, I ran into an interesting problem: Bazel toolchains come with flags for a C++ compiler, not necessarily the same as the libclang that autocxx passes flags to. I'm currently using a libclang from most of my C++ toolchains, and the other C++ toolchain is a gcc of similar vintage that accepts most of the same flags, but I'm not sure how to solve this in general. Some ideas:
Warning flags are also interesting. My toolchain enables Anybody have thoughts on how to handle this? |
Sympathy, but not a lot in the way of concrete suggestions... I'm fortunate to be working with clang-based toolchains and are (theoretically) able to use a matching libclang. |
rules_rust
is the canonical bazel integration for rust. It looks like it would be pretty easy to patch something together withcargo_build_script
, but keeping paths relative during build looks like it might be a pain.Maybe it's easier than it looks? It'd just be nice to have a canonical example to reference, or a starlark rule I can blindlessly call.
The text was updated successfully, but these errors were encountered: