-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
31 lines (25 loc) · 923 Bytes
/
build.rs
File metadata and controls
31 lines (25 loc) · 923 Bytes
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
use std::env;
use std::fs;
use std::path::PathBuf;
fn main() {
let profile = env::var("PROFILE").unwrap_or_default();
if profile != "release" {
return;
}
// Specify your binary name manually if CARGO_BIN_NAME is missing
let target_name = env::var("CARGO_BIN_NAME").unwrap_or_else(|_| "pyo3-hint-transpiler".to_string());
let mut bin_path = PathBuf::from("target").join("release").join(&target_name);
if cfg!(windows) {
bin_path.set_extension("exe");
}
if !bin_path.exists() {
eprintln!("Warning: release binary not found at {:?}", bin_path);
return;
}
let mut out_path = PathBuf::from(&target_name);
out_path.set_extension(bin_path.extension().unwrap());
match fs::copy(&bin_path, &out_path) {
Ok(_) => println!("Copied {:?} to {:?}", bin_path, out_path),
Err(e) => eprintln!("Failed to copy binary: {}", e),
}
}