1pub mod action;
2pub mod assets;
3pub mod comm;
4pub mod gui;
5pub mod launcher;
6pub mod resource;
7pub mod server;
8pub mod util;
9
10#[cfg(all(feature = "audio", not(any(feature = "rodio"))))]
11compile_error!("Cannot enable feature \"audio\" without a backend (\"rodio\").");
12
13#[cfg(all(
14 feature = "stream",
15 not(any(feature = "gstreamer", feature = "ffmpeg"))
16))]
17compile_error!("Cannot enable feature \"stream\" without a backend (\"gstreamer\" or \"ffmpeg\").");
18
19macro_rules! impl_verify_features {
20 ($($feature:literal),* $(,)?) => {
21 pub fn verify_features(content: &str) -> eyre::Result<()> {
22 use eyre::eyre;
23 use regex::Regex;
24
25 let re = Regex::new(r"^//@[ \t]*([[:alpha:]][[:word:]]*)[ \t]*$").unwrap();
26 let features: Vec<_> = content
27 .lines()
28 .map_while(|p| re.captures(p).map(|c| c[1].to_string()))
29 .collect();
30
31 for f in features {
32 match f.as_str() {
33 $(
34 $feature => {
35 #[cfg(not(feature = $feature))]
36 Err(eyre!("Task requires missing feature ({}).", $feature))?;
37 }
38 )*
39 f => {
40 Err(eyre!("Task requires unknown feature: {f}"))?;
41 }
42 }
43 }
44
45 Ok(())
46 }
47 };
48}
49
50impl_verify_features!(
51 "rodio",
52 "gstreamer",
53 "ffmpeg",
54 "savage",
55 "python",
56 "audio",
57 "stream"
58);