|
1
|
fn main() { |
|
2
|
// SDK credentials |
|
3
|
// Load .env from the onde crate root so pulse/client.rs can read these |
|
4
|
// through option_env!(). Consumer apps do not set them. They belong to |
|
5
|
// Onde Inference's own infrastructure. |
|
6
|
println!("cargo:rerun-if-changed=.env"); |
|
7
|
let _ = dotenvy::from_filename( |
|
8
|
std::path::Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap()).join(".env"), |
|
9
|
); |
|
10
|
for var in [ |
|
11
|
"GRESIQ_API_KEY_DEV", |
|
12
|
"GRESIQ_API_SECRET_DEV", |
|
13
|
"GRESIQ_API_KEY_PRODUCTION", |
|
14
|
"GRESIQ_API_SECRET_PRODUCTION", |
|
15
|
"HF_TOKEN", |
|
16
|
] { |
|
17
|
println!("cargo:rerun-if-env-changed={var}"); |
|
18
|
if let Ok(val) = std::env::var(var) { |
|
19
|
if !val.is_empty() { |
|
20
|
println!("cargo:rustc-env={var}={val}"); |
|
21
|
} |
|
22
|
} |
|
23
|
} |
|
24
|
|
|
25
|
// UniFFI scaffolding |
|
26
|
// `uniffi::setup_scaffolding!()` in lib.rs already covers the proc-macro |
|
27
|
// path, but keeping this here still exercises the build dependency and |
|
28
|
// leaves us room to switch back to UDL-based generation later. |
|
29
|
|
|
30
|
// Apple targets: provide a missing ___chkstk_darwin symbol |
|
31
|
// |
|
32
|
// On macOS, `___chkstk_darwin` is exported by libSystem as a stack |
|
33
|
// probing function. On arm64 the kernel grows the stack via guard |
|
34
|
// pages so the probe is effectively a no-op `ret`. |
|
35
|
// |
|
36
|
// tvOS, visionOS, and watchOS do NOT export this symbol at all. |
|
37
|
// |
|
38
|
// iOS does export it in libSystem, but deployment-target mismatches |
|
39
|
// between dependencies (for example onig_sys built for iOS 26.0 linked |
|
40
|
// against a min-target of iOS 10.0) can still make the linker miss it. |
|
41
|
// Shipping the stub on iOS is harmless. If libSystem already provides the |
|
42
|
// symbol, the linker uses that. If not, our stub covers the reference. |
|
43
|
// |
|
44
|
// `aws-lc-sys` assembly (transitive via reqwest -> rustls -> aws-lc-rs) |
|
45
|
// always references ___chkstk_darwin, so we compile a tiny `ret` stub for |
|
46
|
// all non-macOS Apple targets. |
|
47
|
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default(); |
|
48
|
|
|
49
|
if target_os == "ios" |
|
50
|
|| target_os == "tvos" |
|
51
|
|| target_os == "visionos" |
|
52
|
|| target_os == "watchos" |
|
53
|
{ |
|
54
|
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set"); |
|
55
|
let asm_path = std::path::Path::new(&manifest_dir).join("scripts/tvos_chkstk.s"); |
|
56
|
|
|
57
|
if asm_path.exists() { |
|
58
|
// Use `cc` to assemble the stub into a static library the linker |
|
59
|
// can pick up. `cc` is already in the build graph through crates |
|
60
|
// like aws-lc-sys and ring, so we just use it directly. |
|
61
|
cc::Build::new().file(&asm_path).compile("tvos_chkstk"); |
|
62
|
|
|
63
|
println!("cargo:rerun-if-changed=scripts/tvos_chkstk.s"); |
|
64
|
} else { |
|
65
|
println!( |
|
66
|
"cargo:warning=tvos_chkstk.s not found at {}. \ |
|
67
|
___chkstk_darwin will stay unresolved on tvOS", |
|
68
|
asm_path.display() |
|
69
|
); |
|
70
|
} |
|
71
|
} |
|
72
|
} |