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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use std::process::Command;
fn main() {
match std::env::var("ONNXRUNTIME_LIB_PATH") {
Ok(_) => {
println!("cargo:rustc-cfg=onnx_runtime_env_var_set");
},
Err(_) => {
#[cfg(not(windows))]
{
let _ = Command::new("sh")
.arg("-c")
.arg("cargo new onnx_driver && cd onnx_driver && echo 'ort = \"1.16.2\"' >> Cargo.toml
")
.status()
.expect("failed to execute process");
}
#[cfg(windows)]
{
// let _ = Command::new("cmd")
// .args(&["/C", "cargo new onnx_driver && cd onnx_driver && echo ort = \"1.16.2\" >> Cargo.toml"])
// .status()
// .expect("failed to execute process");
let _ = Command::new("powershell")
.arg("-Command")
.arg("cargo new onnx_driver; Set-Location onnx_driver; Add-Content -Path .\\Cargo.toml -Value 'ort = \"1.16.2\"'")
.status()
.expect("failed to execute process");
}
#[cfg(not(windows))]
{
let _ = Command::new("sh")
.arg("-c")
.arg("cd onnx_driver && cargo build")
.status()
.expect("failed to execute process");
}
#[cfg(windows)]
{
let _ = Command::new("cmd")
.args(&["/C", "cd onnx_driver && cargo build"])
.status()
.expect("failed to execute process");
}
}
}
}
// fn main() {
// // println!("cargo:rustc-cfg=onnx_runtime_env_var_set");
// println!("test");
// }