use std::{process::Command, path::PathBuf, fs::{self}}; fn main() { if !PathBuf::from("lib/detours.lib").exists() { Command::new("nmake") .arg("clean") .current_dir("detours") .status() .expect("You need to open Command Tools Command for VS 2022"); Command::new("nmake") .current_dir("detours/src") .status() .unwrap(); fs::create_dir("lib").unwrap_or(()); fs::rename(r#"detours/lib.x64/detours.lib"#, r#"lib/detours.lib"#).expect("Move detours.lib to lib folder."); Command::new("nmake") .arg("realclean") .current_dir("detours/src") .status() .unwrap(); Command::new("nmake") .arg("clean") .current_dir("detours/src") .status() .unwrap(); } println!("cargo:rustc-link-search=native=lib"); println!("cargo:rustc-link-lib=static=detours"); }