Prepend PATH (#202)

* refactor: ♻️ Prepend variables in PATH

* fix: 🐛 Fix Windows compilation
This commit is contained in:
Sergio Gasquez Arcos 2023-03-13 09:04:13 +01:00 committed by GitHub
parent 2a97a811f2
commit 2b4eb00bd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -115,10 +115,13 @@ impl Installable for Gcc {
#[cfg(windows)] #[cfg(windows)]
if cfg!(windows) { if cfg!(windows) {
exports.push(format!("$Env:PATH += \";{}\"", &self.get_bin_path())); exports.push(format!(
"$Env:PATH = \"{};\" + $Env:PATH",
&self.get_bin_path()
));
std::env::set_var( std::env::set_var(
"PATH", "PATH",
std::env::var("PATH").unwrap() + ";" + &self.get_bin_path().replace('/', "\\"), self.get_bin_path().replace('/', "\\") + ";" + &std::env::var("PATH").unwrap(),
); );
} }
#[cfg(unix)] #[cfg(unix)]

View File

@ -153,7 +153,10 @@ impl Installable for Llvm {
"$Env:LIBCLANG_PATH = \"{}/libclang.dll\"", "$Env:LIBCLANG_PATH = \"{}/libclang.dll\"",
self.get_lib_path() self.get_lib_path()
)); ));
exports.push(format!("$Env:PATH += \";{}\"", self.get_lib_path())); exports.push(format!(
"$Env:PATH = \"{};\" + $Env:PATH",
self.get_lib_path()
));
Command::new("setx") Command::new("setx")
.args([ .args([
"LIBCLANG_PATH", "LIBCLANG_PATH",
@ -164,7 +167,7 @@ impl Installable for Llvm {
.output()?; .output()?;
std::env::set_var( std::env::set_var(
"PATH", "PATH",
std::env::var("PATH").unwrap() + ";" + &self.get_lib_path().replace('/', "\\"), self.get_lib_path().replace('/', "\\") + ";" + &std::env::var("PATH").unwrap(),
); );
} }
#[cfg(unix)] #[cfg(unix)]