MCPcopy Index your code
hub / github.com/RizeCrime/linuxblaster_control / main

Function main

build.rs:39–257  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

37}
38
39fn main() {
40 println!("cargo:rerun-if-changed=build.rs");
41 println!("cargo:rerun-if-env-changed=AUTOEQ_REPO_DIR");
42
43 let env_path = env::var("AUTOEQ_REPO_DIR").ok();
44
45 let binding = env_path.clone().unwrap_or("/tmp/autoeq_repo".to_string());
46
47 let repo_url = "https://github.com/jaakkopasanen/AutoEq";
48 let repo_dir = Path::new(&binding);
49
50 let out_dir = env::var("OUT_DIR").unwrap();
51 let dest_path = Path::new(&out_dir).join("autoeq_db.rs");
52
53 if env_path.is_none() {
54 let mut output: std::process::Output;
55
56 if !repo_dir.exists() {
57 output = std::process::Command::new("git")
58 .arg("clone")
59 .arg("--depth=1")
60 .arg(repo_url)
61 .arg(repo_dir)
62 .output()
63 .expect("Failed to clone AutoEq repository");
64 } else {
65 output = std::process::Command::new("git")
66 .current_dir(repo_dir)
67 .arg("pull")
68 .output()
69 .expect("Failed to pull AutoEq repository");
70 }
71
72 if !output.status.success() {
73 eprintln!(
74 "cargo:error=Failed to clone or update AutoEq repository"
75 );
76 panic!("Failed to clone or update AutoEq repository");
77 }
78 }
79
80 let index_path = repo_dir.join("results/INDEX.md");
81 if !index_path.exists() {
82 eprintln!("cargo:error=INDEX.md not found in AutoEq repo");
83 panic!("INDEX.md not found in AutoEq repo");
84 }
85
86 let index = std::fs::read_to_string(index_path).unwrap();
87 let mut entries: HashMap<String, Vec<HeadphoneResult>> = HashMap::new();
88
89 for line in index.lines() {
90 // example line:
91 // - [1MORE Aero (ANC Off)](./HypetheSonics/GRAS%20RA0045%20in-ear/1MORE%20Aero%20(ANC%20Off)) by HypetheSonics on GRAS RA0045
92 // => transforms have been "compiled" in my head; might be wrong :)
93
94 // all lines of interest start with "- ["
95 if !line.starts_with("- [") {
96 continue;

Callers

nothing calls this directly

Calls 2

url_decodeFunction · 0.85
cloneMethod · 0.80

Tested by

no test coverage detected