dtolnay / cxx

Safe interop between Rust and C++
https://cxx.rs
Apache License 2.0
5.68k stars 322 forks source link

Provide cfg option to disable use of cc. #1284

Closed adetaylor closed 8 months ago

adetaylor commented 8 months ago

In the Chromium build system, we automatically convert Cargo.toml rules into rules for our build system, gn. We also run build.rs files as part of the Chromium build (because it turns out that the vast majority of them just set some feature flags for feature detection).

The build.rs for cxx does more sophisticated things - including building C++ code using cc. That's appropriate in a cargo context, but presents difficulty for our build system where C++ must be built using static build rules beyond the realm of cargo. At the moment we carry a patch for this, but it would be great not to have to do so.

This patch would enable us to use the Cargo.toml and build.rs for cxx without change. It's only one out of four patches we currently carry for cxx, but it would be great to get rid of it! Obviously this may seem like a bit of a niche use-case, but hopefully this helps anyone else who builds cxx using non-Cargo build systems, but reusing the Cargo.toml and build.rs.

The intention is that this change is a no-op except for folks who disable default features.

adetaylor commented 8 months ago

Thanks. Option 2 sounds especially encouraging, I will take a look. I'll close this for now.