forked from maxcurzi/tplay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
53 lines (48 loc) · 1.87 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
use std::env;
// use std::process::Command;
fn main() {
let user_mpv_0_34 = env::var("CARGO_FEATURE_MPV_0_34").is_ok();
let user_mpv_0_35 = env::var("CARGO_FEATURE_MPV_0_35").is_ok();
let user_rodio_audio = env::var("CARGO_FEATURE_RODIO_AUDIO").is_ok();
let enabled_count = [user_mpv_0_34, user_mpv_0_35, user_rodio_audio]
.iter()
.filter(|&&x| x)
.count();
if enabled_count > 1 {
eprintln!("Error: At most one of the following features can be enabled at a time: mpv_0_34, mpv_0_35, rodio_audio.");
std::process::exit(1);
}
if user_mpv_0_34 || user_mpv_0_35 || user_rodio_audio {
if user_mpv_0_34 {
println!("cargo:rustc-cfg=feature=\"mpv_0_34\"");
} else if user_mpv_0_35 {
println!("cargo:rustc-cfg=feature=\"mpv_0_35\"");
} else {
println!("cargo:rustc-cfg=feature=\"rodio_audio\"");
}
}
// else {
// let output = Command::new("mpv").arg("--version").output();
// if let Ok(output) = output {
// let version_string = String::from_utf8_lossy(&output.stdout);
// let version = version_string
// .lines()
// .next()
// .unwrap_or("")
// .split_whitespace()
// .nth(1)
// .unwrap_or("");
// if version.starts_with("0.34") {
// println!("cargo:rustc-cfg=feature=\"mpv_0_34\"");
// } else if version.starts_with("0.35") {
// println!("cargo:rustc-cfg=feature=\"mpv_0_35\"");
// } else {
// // fallback to rodio
// println!("cargo:rustc-cfg=feature=\"rodio_audio\"");
// }
// } else {
// // fallback to rodio
// println!("cargo:rustc-cfg=feature=\"rodio_audio\"");
// }
// }
}