You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.5 KiB
Rust

3 weeks ago
/******************************************************************************
* @file build.rs
* @author Joey Pollack
* @date 2025/11/20 (y/m/d)
* @modified 2025/11/20 (y/m/d)
* @copyright Joseph R Pollack (2025)
* @brief
******************************************************************************/
// use std::process::Command;
use std::io::prelude::*;
use std::{env, fs, fs::File, path::Path};
3 weeks ago
fn main()
{
let name = env!("CARGO_PKG_NAME");
println!("{} build.rs started...", name);
let in_path = Path::new("input/");
let out_path = format!("target/{}", &env::var("PROFILE").unwrap());
let out_path = Path::new(&out_path).join("input/");
let test_file_name = out_path.join("foo.txt".to_string());
if !out_path.exists()
{
fs::create_dir(&out_path).expect("Failed to create the out directory");
}
if !in_path.exists()
{
fs::create_dir(&in_path).expect("failed to create dummy input path");
}
if !in_path.is_dir()
{
println!("in_path is not a directory");
}
// Test file
let mut file = File::create(test_file_name).expect("Failed to create test file");
file.write_all(b"Hello, world!").expect("Failed to write to test file");
// Copy input files
for f in in_path.read_dir().expect("Failed to parse directory entries")
{
let f = f.expect("failed to parse directly entry");
let dest = out_path.join(f.path().file_name().unwrap());
fs::copy(f.path(), &dest).expect(&format!("failed to copy file: {:#?}, to {:#?}", f, dest));
}
3 weeks ago
println!("{} build.rs finished", name);
}