1#[cfg(target_os = "windows")]
2pub fn auto_sense_llvm() {
3 use std::process::Command;
4 use which::which;
5
6 if which("choco").is_err() {
8 eprintln!("Chocolatey (choco) is not installed.");
9 println!("Please install Chocolatey from https://chocolatey.org/install to proceed with LLVM installation.");
10 return;
11 }
12
13 println!("libclang is missing. You can install LLVM using Chocolatey (choco).");
14 println!("Suggestion: choco install llvm");
15
16 match crate::e_prompts::yesno(
17 "Do you want to install LLVM using choco?",
18 Some(true), ) {
20 Ok(Some(true)) => {
21 println!("Installing LLVM...");
22 match Command::new("choco")
23 .args(["install", "llvm", "-y"])
24 .spawn()
25 {
26 Ok(mut child) => {
27 child.wait().ok(); println!("LLVM installation completed.");
29 }
30 Err(e) => {
31 eprintln!("Error installing LLVM via choco: {}", e);
32 }
33 }
34 }
35 Ok(Some(false)) => {
36 println!("LLVM installation skipped.");
37 }
38 Ok(None) => {
39 println!("Installation cancelled (timeout or invalid input).");
40 }
41 Err(e) => {
42 eprintln!("Error during prompt: {}", e);
43 }
44 }
45}
46
47#[cfg(not(target_os = "windows"))]
48pub fn auto_sense_llvm() {
49 println!("auto_sense_llvm is only supported on Windows with Chocolatey.");
50}