1use {crate::config::QuasarConfig, std::path::PathBuf};
2
3pub fn find_so(config: &QuasarConfig, include_profile: bool) -> Option<PathBuf> {
5 let module = config.module_name();
6 let name = &config.project.name;
7
8 let mut candidates = vec![
9 format!("target/deploy/{name}.so"),
10 format!("target/deploy/{module}.so"),
11 format!("target/deploy/lib{module}.so"),
12 ];
13
14 if include_profile {
15 candidates.push(format!("target/profile/{module}.so"));
16 }
17
18 candidates
19 .into_iter()
20 .map(PathBuf::from)
21 .find(|p| p.exists())
22}
23
24pub fn snake_to_pascal(s: &str) -> String {
26 s.split('_')
27 .map(|word| {
28 let mut chars = word.chars();
29 match chars.next() {
30 None => String::new(),
31 Some(c) => c.to_uppercase().collect::<String>() + chars.as_str(),
32 }
33 })
34 .collect()
35}