mirror of
https://github.com/luxfi/crypto.git
synced 2026-10-30 16:59:13 +00:00
Brand stays in import path only; symbols, env vars, and exports are brand-neutral. One-release backwards-compat shim reads deprecated LUX_ names with deprecation log. Env: CRYPTO_BACKEND, CRYPTO_DIR, CRYPTO_BUILD_DIR, CRYPTO_LIB_DIR, CRYPTO_LIB are canonical. Rust: idiomatic Secp256k1Status enum; extern fn names dropped lux_ prefix. TS/Python: cryptoAvailable / crypto_available; FFI symbol strings drop lux_ prefix to match renamed C-ABI in luxcpp/crypto. cabi/main.go: //export names drop lux_ prefix (mlkem768_*, mldsa65_*).
50 lines
1.6 KiB
Rust
50 lines
1.6 KiB
Rust
use std::env;
|
|
use std::path::PathBuf;
|
|
|
|
fn read_lib_dir() -> Option<String> {
|
|
if let Ok(v) = env::var("CRYPTO_LIB_DIR") {
|
|
return Some(v);
|
|
}
|
|
if let Ok(v) = env::var("LUX_CRYPTO_LIB_DIR") {
|
|
println!("cargo:warning=LUX_CRYPTO_LIB_DIR is deprecated; use CRYPTO_LIB_DIR");
|
|
return Some(v);
|
|
}
|
|
None
|
|
}
|
|
|
|
fn main() {
|
|
// Search order for libluxcrypto:
|
|
// 1. CRYPTO_LIB_DIR env var (deprecated alias: LUX_CRYPTO_LIB_DIR)
|
|
// 2. ~/work/lux/crypto/dist/
|
|
// 3. System library path
|
|
|
|
if let Some(lib_dir) = read_lib_dir() {
|
|
println!("cargo:rustc-link-search=native={lib_dir}");
|
|
} else {
|
|
// Dev default: ~/work/lux/crypto/dist/
|
|
if let Some(home) = env::var_os("HOME") {
|
|
let dist = PathBuf::from(home).join("work/lux/crypto/dist");
|
|
if dist.exists() {
|
|
println!("cargo:rustc-link-search=native={}", dist.display());
|
|
}
|
|
}
|
|
}
|
|
|
|
println!("cargo:rerun-if-env-changed=CRYPTO_LIB_DIR");
|
|
println!("cargo:rerun-if-env-changed=LUX_CRYPTO_LIB_DIR");
|
|
println!("cargo:rustc-link-lib=dylib=luxcrypto");
|
|
|
|
// macOS: set rpath for all link targets (binaries, tests, examples)
|
|
if cfg!(target_os = "macos") {
|
|
// Always include /usr/local/lib as rpath fallback
|
|
println!("cargo:rustc-link-arg=-Wl,-rpath,/usr/local/lib");
|
|
|
|
if let Some(home) = env::var_os("HOME") {
|
|
let dist = PathBuf::from(home).join("work/lux/crypto/dist");
|
|
if dist.exists() {
|
|
println!("cargo:rustc-link-arg=-Wl,-rpath,{}", dist.display());
|
|
}
|
|
}
|
|
}
|
|
}
|