Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add symlink to LLVM #380

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion src/toolchain/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ use crate::{
toolchain::{download_file, rust::RE_EXTENDED_SEMANTIC_VERSION, Installable},
};
use async_trait::async_trait;
#[cfg(unix)]
use directories::BaseDirs;
use log::{info, warn};
use miette::Result;
use regex::Regex;
#[cfg(unix)]
use std::{fs::create_dir_all, os::unix::fs::symlink};
use std::{
fs::remove_dir_all,
path::{Path, PathBuf},
Expand Down Expand Up @@ -135,6 +139,15 @@ impl Llvm {
);
set_environment_variable("PATH", &updated_path)?;
}
#[cfg(unix)]
if cfg!(unix) {
let espup_dir = BaseDirs::new().unwrap().home_dir().join(".espup");

if espup_dir.exists() {
remove_dir_all(espup_dir.display().to_string())
.map_err(|_| Error::RemoveDirectory(espup_dir.display().to_string()))?;
}
}
let path = toolchain_path.join(CLANG_NAME);
remove_dir_all(&path)
.map_err(|_| Error::RemoveDirectory(path.display().to_string()))?;
Expand Down Expand Up @@ -186,7 +199,26 @@ impl Installable for Llvm {
);
}
#[cfg(unix)]
exports.push(format!("export LIBCLANG_PATH=\"{}\"", self.get_lib_path()));
if cfg!(unix) {
exports.push(format!("export LIBCLANG_PATH=\"{}\"", self.get_lib_path()));
let espup_dir = BaseDirs::new().unwrap().home_dir().join(".espup");

if !espup_dir.exists() {
create_dir_all(espup_dir.display().to_string())
.map_err(|_| Error::CreateDirectory(espup_dir.display().to_string()))?;
}
let llvm_symlink_path = espup_dir.join("esp-clang");
if llvm_symlink_path.exists() {
remove_dir_all(&llvm_symlink_path)
.map_err(|_| Error::RemoveDirectory(llvm_symlink_path.display().to_string()))?;
}
info!(
"Creating symlink between {} and {}",
self.get_lib_path(),
llvm_symlink_path.display()
);
symlink(self.get_lib_path(), llvm_symlink_path)?;
}

if self.extended {
#[cfg(windows)]
Expand Down