Add feature cxxbridge
to allow user manually compile it
#1243
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Sometimes we want to manually compile the
cxxbridge
(e.g., we use our own toolchain for embedded devices). Thus we introduce acxxbridge
which is enabled by default and users can disable it and generate and compile their own bridges using customized toolchains.I saw #1196 (review) but I still think this feature is necessary. For example, if I have multiple static libraries and need to integrate some Rust codes into them. If I am not able to disable compelling
cxxbridge
, I will have multiplecxxbridge
on different static libraries. And linking will fail with duplicate symbols. If I could disablecxxbridge
, I can only compile it on a commonly linked library.In this patch, I also export two functions (i.e.,
export_cxx_bridge
andgenerate_header_and_cc_with_path
) for c build systems (like cmake or gnumake). There are many reasons that we still need a c build system (e.g., cargo does not support post-build scripts). With the two newly exported functions, we can integrate rust codes into c build systems.