This repository has been archived on 2024-06-01. You can view files and clone it, but cannot push or open issues or pull requests.
rustboyadvance-ng/app/build.rs
Muhammad Nauman Raza d88e8ae514 refactor: restructure project
Former-commit-id: ac1eb2f7d5293d0566be14911ce5564576b508f2
Former-commit-id: 2f07af167b564620680a8a52280a5a6abbd6cec6
2024-03-23 20:15:48 +00:00

55 lines
1.8 KiB
Rust

#[cfg(windows)]
use std::env;
#[cfg(windows)]
use std::path::PathBuf;
#[cfg(windows)]
use winres;
#[cfg(windows)]
fn main() {
let mut res = winres::WindowsResource::new();
res.set_icon("../../assets/icon.ico");
res.compile().unwrap();
let target = env::var("TARGET").unwrap();
if target.contains("pc-windows") {
let manifest_dir = PathBuf::from(
env::var("CARGO_MANIFEST_DIR").expect("Failed to get CARGO_MANIFEST_DIR"),
);
let out_dir = PathBuf::from(env::var("OUT_DIR").expect("Failed to get OUT_DIR"));
let mut lib_dir = manifest_dir.clone();
let mut dll_dir = manifest_dir.clone();
if target.contains("msvc") {
lib_dir.push("msvc");
dll_dir.push("msvc");
} else {
panic!("mingw not supported");
}
if target.contains("x86_64") {
lib_dir.push("64");
dll_dir.push("64");
} else {
lib_dir.push("32");
dll_dir.push("32");
}
println!("cargo:rustc-link-search=all={}", lib_dir.display());
for entry in std::fs::read_dir(dll_dir).expect("Can't read DLL dir") {
let entry_path = entry.expect("Invalid fs entry").path();
let file_name_result = entry_path.file_name();
let mut new_file_path = out_dir.clone();
if let Some(file_name) = file_name_result {
let file_name = file_name.to_str().unwrap();
if file_name.ends_with(".dll") {
new_file_path.push(file_name);
std::fs::copy(&entry_path, new_file_path.as_path())
.expect("Can't copy from DLL dir");
}
}
}
}
}
#[cfg(not(windows))]
fn main() {}