Files
netrunner-app/src-tauri/build.rs
T

45 lines
1.5 KiB
Rust

use std::env;
use std::fs;
use std::path::Path;
fn main() {
// 1. Указываем Tauri сгенерировать конфигурацию
tauri_build::build();
// 2. Получаем целевую архитектуру (например, x86_64, aarch64, i686)
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").expect("No target arch");
// 3. Сопоставляем архитектуру Rust с вашей структурой папок
let arch_folder = match target_arch.as_str() {
"x86_64" => "amd64",
"aarch64" => "arm64",
"arm" => "arm",
"x86" => "x86",
_ => panic!("Unsupported architecture for Wintun: {}", target_arch),
};
// 4. Пути к файлам
let manifest_dir = env::var("CARGO_MANIFEST_DIR").expect("No manifest dir");
let dll_source = Path::new(&manifest_dir)
.join("bin")
.join(arch_folder)
.join("wintun.dll");
let out_dir = env::var("OUT_DIR").expect("No out dir");
let path = Path::new(&out_dir);
let target_dir = path
.parent()
.and_then(|p| p.parent())
.and_then(|p| p.parent())
.and_then(|p| p.parent())
.expect("Не удалось вычислить target/release");
let dest_path = target_dir.join("wintun.dll");
if dll_source.exists() {
fs::copy(&dll_source, &dest_path).expect("Failed to copy wintun.dll");
println!("cargo:warning=Wintun DLL copied to {:?}", dest_path);
}
}