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
Is there currently a way to do conditional compilation? #989
Comments
This is definitely something we can support, but it's not implemented yet. Basically in Cargo-based builds For now the easiest workaround would be to move the android-specific signatures to a different cxx::bridge module in a different file, and gate that whole file with Something like: // lib.rs
#[cfg(target_os = "android")]
mod android; // android.rs
#[cxx::bridge]
mod ffi {
extern "C++" {
type CallInvokerHolder;
fn getCallInvoker(self: Pin<&mut CallInvokerHolder>) -> SharedPtr<CallInvoker>;
...
}
} // build.rs
let mut bridge_modules = vec!["src/lib.rs"];
if std::env::var_os("CARGO_CFG_TARGET_OS").unwrap() == "android" {
bridge_modules.push("src/android.rs");
}
cxx_build::bridges(bridge_modules)
...
.compile(...); |
Thanks for the tip! This is exactly what I ended up doing. |
I published an implementation of |
Just bumped my cxx version (build and non build versions) to 1.0.63. Then doing:
gives undefined reference error on
Edit: simply taking out |
There are a few special cfgs that Cargo conceals from build scripts. I added a workaround for that one in cxx-build 1.0.64. |
I want to bind to some C++ methods which only exist on Android. However, if I try to do something like this:
I get the following error:
Is there a workaround?
The text was updated successfully, but these errors were encountered: