This repository has been archived by the owner on Jan 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post_build.rs
42 lines (40 loc) · 1.64 KB
/
post_build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use serde::Deserialize;
use std::env;
use std::fs;
use std::path::PathBuf;
#[derive(Deserialize)]
struct Deployment {
pub target_dirs: Vec<String>,
}
fn main() {
match fs::read_to_string("./.deployment.toml") {
Ok(toml_string) => {
let deployment: Result<Deployment, _> = toml::from_str(&toml_string);
match deployment {
Ok(deployment) => {
let mut crate_out_dir = env::var("CRATE_OUT_DIR").unwrap();
crate_out_dir.push_str("/libinexor_rgf_plugin_*.*");
for target_dir in deployment.target_dirs {
for entry in glob::glob(crate_out_dir.as_str()).unwrap() {
if let Ok(source_path) = entry {
let file_name = source_path.file_name().unwrap().to_str().unwrap();
if file_name.ends_with(".so") || file_name.ends_with(".dll") {
let mut target_path = PathBuf::from(&target_dir);
target_path.push(file_name);
println!("Copy plugin from {} to {}", source_path.display(), target_path.display());
let _ = fs::copy(source_path, target_path);
}
}
}
}
}
Err(e) => {
eprintln!("Failed to parse .deployment.toml: {}", e);
}
}
}
Err(e) => {
eprintln!("Could not read .deployment.toml: {}", e);
}
}
}