Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ keywords = ["utf8", "unicode", "string", "validation", "simd"]
categories = ["encoding", "algorithms", "no-std", "text-processing"]
readme = "README.md"
rust-version = "1.78.0"
links = "simdutf"

[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]

[features]
default = ["detect_encoding", "ascii", "latin1", "utf8", "utf16", "utf32", "base64"]
default = ["bundled", "detect_encoding", "ascii", "latin1", "utf8", "utf16", "utf32", "base64"]
bundled = []
detect_encoding = []
ascii = []
latin1 = []
Expand Down
15 changes: 15 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,20 @@ fn main() {
feature_define(&mut cc, "UTF32", "SIMDUTF_FEATURE_UTF32");
feature_define(&mut cc, "BASE64", "SIMDUTF_FEATURE_BASE64");

println!("cargo:rerun-if-env-changed=SIMDUTF_LIB_DIR");
println!("cargo:rerun-if-env-changed=SIMDUTF_LIB_NAME");
if cfg!(feature = "bundled") {
Comment thread
logan-gatlin marked this conversation as resolved.
cc.define("SIMDUTFRS_BUNDLED", None);
} else {
if let Some(dir) = std::env::var_os("SIMDUTF_LIB_DIR") {
println!("cargo:rustc-link-search=native={}", std::path::Path::new(&dir).display());
}
if let Ok(name) = std::env::var("SIMDUTF_LIB_NAME") {
if !name.is_empty() {
println!("cargo:rustc-link-lib={name}");
}
}
}

cc.file("cpp/simdutfrs.cpp").compile("simdutfrs");
}
4 changes: 4 additions & 0 deletions codegen/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ fn decl_cpp_endif2(from: &str, to: &str) {
pub fn codegen_cpp() {
glines![
"// Auto generated by codegen/src/bindings.rs"
"#ifdef SIMDUTFRS_BUNDLED"
"#include \"simdutf.cpp\""
"#else"
"#include \"simdutf.h\""
"#endif"
"#include \"simdutfrs_extra.cpp\""
""
"extern \"C\" {"
Expand Down
4 changes: 4 additions & 0 deletions cpp/simdutfrs.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// Auto generated by codegen/src/bindings.rs
#ifdef SIMDUTFRS_BUNDLED
#include "simdutf.cpp"
#else
#include "simdutf.h"
#endif
#include "simdutfrs_extra.cpp"

extern "C" {
Expand Down