WASM Compatibility (no bindings) #35
Open
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.
When building for WASM targets we don't want to generate the bindings As compiling the project e.g. via wasm-pack, complains "stddef.h" isn't found.
We solve this by a feature flag "c_bindings", which will be enabled on non-wasm targets by default, thus when included in a project being built for wasm it will compile and work as expected when we use the library directly.
I also flagged the timer code in graph.rs as that's not compatible with wasm.
Example output without this patch:
Example output with this patch:
One note, in Cargo.toml, I took this approach:
Because I'm using
[patch.crates-io]
in the test project to override the dependency, and I can't setdefault-features = false
this way, so I ... defaulted it in a target-specific way.