feat: Add bundled feature - #65
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds an optional bundled Cargo feature to the simdutf crate so that consumers (e.g. the workerd Node API port) can link against an externally provided simdutf library instead of compiling the vendored amalgamation, avoiding a duplicate copy of simdutf. When bundled is enabled (the default), the crate compiles the vendored simdutf.cpp; when disabled, it includes only simdutf.h and relies on SIMDUTF_LIB_DIR/SIMDUTF_LIB_NAME to locate/link an existing library. As noted in the description, this is a breaking change for users who disable default features.
Changes:
- Introduce a
bundledfeature (default-on) and alinks = "simdutf"key inCargo.toml. - Guard the vendored
#include "simdutf.cpp"behindSIMDUTFRS_BUNDLED, falling back to#include "simdutf.h"(in both the generatedsimdutfrs.cppand its codegen source). - Update
build.rsto defineSIMDUTFRS_BUNDLEDfor bundled builds and emit link search/lib directives fromSIMDUTF_LIB_DIR/SIMDUTF_LIB_NAMEotherwise.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Cargo.toml | Adds bundled feature (default-on) and links = "simdutf" metadata. |
| build.rs | Conditionally defines SIMDUTFRS_BUNDLED and wires up external lib search/link env vars; contains a build-script feature-detection bug. |
| cpp/simdutfrs.cpp | Wraps the vendored simdutf.cpp include in an SIMDUTFRS_BUNDLED guard with a simdutf.h fallback. |
| codegen/src/bindings.rs | Updates the codegen template to emit the same conditional include block. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Hello! I'm working on porting node API's to Rust in workerd. I'd like to use these Rust bindings, but they pull in an additional copy of
simdutf. This PR adds abundledfeature which when off, allows for linking against an existingsimdutfinstead.The
bundledfeature is on by default. Any users who have default features off will need to explicitly add thebundledfeature, so this is a breaking change.