Skip to content

Commit 08a95e0

Browse files
committed
use cfg_if
1 parent ca8c2d0 commit 08a95e0

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ walkdir = "2"
2828
zip = "0.5.13"
2929
semver = "1.0.14"
3030
reqwest = { version = "0.11.12", features = ["json", "blocking"] }
31+
cfg-if = "1.0.0"
3132

3233
[target.'cfg(windows)'.dependencies]
3334
winreg = "0.7.0"

src/sdk.rs

+19-17
Original file line numberDiff line numberDiff line change
@@ -174,26 +174,28 @@ fn install(config: &mut Config, path: PathBuf) {
174174
update_submodules_recurse(&repo).nice_unwrap("Unable to update submodules!");
175175

176176
// set GEODE_SDK environment variable
177-
if cfg!(windows) {
178-
let hklm = RegKey::predef(winreg::enums::HKEY_CURRENT_USER);
179-
if let Err(_) = hklm
180-
.create_subkey("Environment")
181-
.map(|(env, _)| env.set_value("GEODE_SDK", &path.to_str().unwrap().to_string()))
182-
{
183-
warn!(
184-
"Unable to set the GEODE_SDK enviroment variable to {}, \
185-
you will have to set it manually! (You may be missing Admin priviledges)",
177+
cfg_if::cfg_if!(
178+
if #[cfg(windows)] {
179+
let hklm = RegKey::predef(winreg::enums::HKEY_CURRENT_USER);
180+
if let Err(_) = hklm
181+
.create_subkey("Environment")
182+
.map(|(env, _)| env.set_value("GEODE_SDK", &path.to_str().unwrap().to_string()))
183+
{
184+
warn!(
185+
"Unable to set the GEODE_SDK enviroment variable to {}, \
186+
you will have to set it manually! (You may be missing Admin priviledges)",
187+
path.to_str().unwrap()
188+
);
189+
} else {
190+
info!("Set GEODE_SDK environment variable automatically");
191+
}
192+
} else {
193+
info!(
194+
"Please set the GEODE_SDK enviroment variable to {}",
186195
path.to_str().unwrap()
187196
);
188-
} else {
189-
info!("Set GEODE_SDK environment variable automatically");
190197
}
191-
} else {
192-
info!(
193-
"Please set the GEODE_SDK enviroment variable to {}",
194-
path.to_str().unwrap()
195-
);
196-
}
198+
);
197199

198200
switch_to_tag(config, &repo);
199201

0 commit comments

Comments
 (0)