tftsr-devops_investigation/src-tauri/build.rs
Shaun Arman e2e7b02a0e
Some checks failed
Test / frontend-tests (pull_request) Successful in 1m42s
Test / frontend-typecheck (pull_request) Successful in 1m51s
PR Review Automation / review (pull_request) Has been cancelled
Test / rust-fmt-check (pull_request) Successful in 12m47s
Test / rust-clippy (pull_request) Successful in 14m27s
Test / rust-tests (pull_request) Successful in 16m50s
fix(windows): link memset_shim object directly and suppress dead_code warning
- Use rustc-link-arg to directly link memset_shim.o object file
  instead of -l flag, ensuring symbol is available regardless of
  link order with libsodium_sys

- Add #[allow(dead_code)] to find_ollama_binary() which is only
  used inside cfg(target_os = "macos") and cfg(target_os = "linux")
  blocks, causing false positive warning when cross-compiling for Windows
2026-06-19 11:23:12 -05:00

53 lines
1.7 KiB
Rust

fn main() {
let version = get_version_from_git();
println!("cargo:rustc-env=APP_VERSION={version}");
println!("cargo:rerun-if-changed=.git/refs/heads/master");
println!("cargo:rerun-if-changed=.git/refs/tags");
// Compile memset_explicit shim for Windows MinGW
// libsodium-sys-stable uses memset_explicit which isn't available in MinGW
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
let target_env = std::env::var("CARGO_CFG_TARGET_ENV").unwrap_or_default();
if target_os == "windows" && target_env == "gnu" {
let out_dir = std::env::var("OUT_DIR").unwrap();
let obj_path = format!("{}/memset_shim.o", out_dir);
cc::Build::new()
.file("memset_s_shim.c")
.define("WIN32", None)
.define("__WIN32__", None)
.out_dir(&out_dir)
.compile("memset_shim");
println!("cargo:rerun-if-changed=memset_s_shim.c");
// Directly link the object file instead of using -l flag
// This ensures the symbol is available regardless of link order
println!("cargo:rustc-link-arg={}", obj_path);
}
tauri_build::build()
}
fn get_version_from_git() -> String {
if let Ok(output) = std::process::Command::new("git")
.arg("describe")
.arg("--tags")
.arg("--abbrev=0")
.output()
{
if output.status.success() {
let version = String::from_utf8_lossy(&output.stdout)
.trim()
.trim_start_matches('v')
.to_string();
if !version.is_empty() {
return version;
}
}
}
"0.2.50".to_string()
}