Files
Home/src-tauri/build.rs

35 lines
1.1 KiB
Rust

use std::env;
use std::fs;
use std::path::PathBuf;
fn main() {
tauri_build::build();
if env::var("CARGO_CFG_TARGET_OS").unwrap_or_default() == "windows" {
let target_dir = PathBuf::from(env::var("OUT_DIR").unwrap())
.ancestors()
.nth(3)
.unwrap()
.to_path_buf();
let build_dir = PathBuf::from(env::var("OUT_DIR").unwrap())
.ancestors()
.nth(2)
.unwrap()
.to_path_buf();
if let Ok(entries) = fs::read_dir(&build_dir) {
for entry in entries.flatten() {
let name = entry.file_name().to_string_lossy().to_string();
if name.starts_with("webview2-com-sys-") {
let dll_path = entry.path().join("out").join("x64").join("WebView2Loader.dll");
if dll_path.exists() {
let _ = fs::copy(&dll_path, target_dir.join("WebView2Loader.dll"));
let _ = fs::copy(&dll_path, PathBuf::from("../bin").join("WebView2Loader.dll"));
break;
}
}
}
}
}
}