Add rb-sys-env
to ease integration pains
#99
Merged
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.
Why
So after working to make
rb-sys
seamless withmagnus
, there are a number of integration pain points I've stumbled across:This means that means the link-args set by rb-sys do not automatically propagated to magnus. This can cause unexpected breakage (especially on windows)
More info: (rust-lang/cargo#9554)
This like the
ruby_gte_3_0
, andruby_use_flonum
are examples of this. Exposing this information in an easy way would alleviate a lot of headaches.How
This PR adds a lightweight, dependency-free
rb-sys-env
crate to glue high level bindings crates together properly. IMPORTANT: This crate is only needed if you are wrapping rb-sys to make a high-level bindings crate (i.e. this is not needed if you are a gem author)!At it's core, all it does is properly set cargo configuration based on the
DEP_RB_*
environment variables which are already set byrb-sys
. This means this crate does not have to depend onrb-sys
directly, and as such builds quickly.Usage
In your high-level Ruby library that wraps rb-sys
Add this to your
Cargo.toml
:Then, just add this your
build.rs
:What it configures
Anytime you want to see what is being set by
rb-sys-env
, you can runRB_SYS_ENV_DEBUG=1 cargo test
...👉 Click here to see an example output