You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
corrosion_import_crate(
MANIFEST_PATH example_path/Cargo.toml
FEATURES interop) # Note this feature flag here
corrosion_add_cxxbridge(example-bridge
CRATE example
MANIFEST_PATH example_path
FILES ffi.rs)
[package]
name = "example"version = "0.1.0"edition = "2021"
[lib]
crate-type = ["cdylib", "lib"]
[features]
interop = ["dep:cxx", "dep:cxx-build"] # We lock cxx features behind this feature flag.
[dependencies]
cxx = { version = "1.0.135", optional = true }
[build-dependencies]
cxx-build = { version = "1.0.135", optional = true }
The command that is run in the code linked above (/Users/.../.rustup/toolchains/nightly-aarch64-apple-darwin/bin/cargo tree -i cxx --depth=0) returns the error described below, because cxx is locked behind the interop feature flag.
error: package ID specification 'cxx' did not match any packages
Did you mean 'syn'?
It can be fixed by adding the features that are passed to corrosion_import_crate to the cargo tree command, so it looks like this: /Users/.../.rustup/toolchains/nightly-aarch64-apple-darwin/bin/cargo tree -i cxx --features interop --depth=0 which then returns the correct cxx version: cxx v1.0.135
Why lock cxx behind a feature flag?
My crate is being cross-compiled to many different platforms and contains lots of shared code for either WebAssembly (wasm-bindgen) and C++ (cxx) which needs to be toggled based on where it's built.
The text was updated successfully, but these errors were encountered:
My crate is being cross-compiled to many different platforms and contains lots of shared code for either WebAssembly (wasm-bindgen) and C++ (cxx) which needs to be toggled based on where it's built.
The same use case could also be solved by dependencies conditional per target-triple, so I guess we should also respect the target / or pass --target all
https://github.com/corrosion-rs/corrosion/blob/999f93b98e965dc418b43854ad321a4e45385983/cmake/Corrosion.cmake#L1674C1-L1680C6
The command that is run in the code linked above (
/Users/.../.rustup/toolchains/nightly-aarch64-apple-darwin/bin/cargo tree -i cxx --depth=0
) returns the error described below, because cxx is locked behind theinterop
feature flag.It can be fixed by adding the features that are passed to
corrosion_import_crate
to thecargo tree
command, so it looks like this:/Users/.../.rustup/toolchains/nightly-aarch64-apple-darwin/bin/cargo tree -i cxx --features interop --depth=0
which then returns the correct cxx version:cxx v1.0.135
Why lock cxx behind a feature flag?
My crate is being cross-compiled to many different platforms and contains lots of shared code for either WebAssembly (wasm-bindgen) and C++ (cxx) which needs to be toggled based on where it's built.
The text was updated successfully, but these errors were encountered: