Skip to content

Commit

Permalink
use cfg_if
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Oct 16, 2022
1 parent ca8c2d0 commit 08a95e0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ walkdir = "2"
zip = "0.5.13"
semver = "1.0.14"
reqwest = { version = "0.11.12", features = ["json", "blocking"] }
cfg-if = "1.0.0"

[target.'cfg(windows)'.dependencies]
winreg = "0.7.0"
Expand Down
36 changes: 19 additions & 17 deletions src/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,26 +174,28 @@ fn install(config: &mut Config, path: PathBuf) {
update_submodules_recurse(&repo).nice_unwrap("Unable to update submodules!");

// set GEODE_SDK environment variable
if cfg!(windows) {
let hklm = RegKey::predef(winreg::enums::HKEY_CURRENT_USER);
if let Err(_) = hklm
.create_subkey("Environment")
.map(|(env, _)| env.set_value("GEODE_SDK", &path.to_str().unwrap().to_string()))
{
warn!(
"Unable to set the GEODE_SDK enviroment variable to {}, \
you will have to set it manually! (You may be missing Admin priviledges)",
cfg_if::cfg_if!(
if #[cfg(windows)] {
let hklm = RegKey::predef(winreg::enums::HKEY_CURRENT_USER);
if let Err(_) = hklm
.create_subkey("Environment")
.map(|(env, _)| env.set_value("GEODE_SDK", &path.to_str().unwrap().to_string()))
{
warn!(
"Unable to set the GEODE_SDK enviroment variable to {}, \
you will have to set it manually! (You may be missing Admin priviledges)",
path.to_str().unwrap()
);
} else {
info!("Set GEODE_SDK environment variable automatically");
}
} else {
info!(
"Please set the GEODE_SDK enviroment variable to {}",
path.to_str().unwrap()
);
} else {
info!("Set GEODE_SDK environment variable automatically");
}
} else {
info!(
"Please set the GEODE_SDK enviroment variable to {}",
path.to_str().unwrap()
);
}
);

switch_to_tag(config, &repo);

Expand Down

0 comments on commit 08a95e0

Please sign in to comment.