use std::env; use std::fs; use std::path::PathBuf; fn main() { let profile = env::var("PROFILE").unwrap(); let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); let target_dir = PathBuf::from(&manifest_dir).join("target").join(&profile); // Ensure target directory exists if !target_dir.exists() { fs::create_dir_all(&target_dir).ok(); } // Copy the file (e.g., config.json) to the target directory let source = PathBuf::from(&manifest_dir).join("src").join("kira_config.toml"); let dest = target_dir.join("kira_config.toml"); fs::copy(&source, &dest).expect("Failed to copy kira_config.toml"); // Optional: Tell Cargo to re-run this script if the source file changes println!("cargo:rerun-if-changed=src/kira_config.toml"); }