Skip to content

Commit

Permalink
Check Windows registry for SDK path
Browse files Browse the repository at this point in the history
  • Loading branch information
eirnym committed Apr 1, 2024
1 parent 597dc0c commit 85ebd13
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions support/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ repository.workspace = true
dirs.workspace = true
log = { workspace = true, optional = true }

[target.'cfg(target_os = "windows")'.dependencies.windows-registry]
version = "0.1.0"

[features]
default = ["log", "cargo-message"]
Expand Down
10 changes: 10 additions & 0 deletions support/utils/src/toolchain/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ impl Sdk {
#[cfg(unix)]
let res = res.or_else(|_| try_with(Self::try_xdg_unix_path));

#[cfg(windows)]
let res = res.or_else(|_| try_with(Self::try_windows_registry));

res.or_else(|_| try_with(Self::try_from_default_path))
}

Expand All @@ -85,6 +88,13 @@ impl Sdk {
}
}

#[cfg(windows)]
pub fn try_windows_registry() -> Result<Self, Error> {
let key: String = windows_registry::CURRENT_USER.open(r#"Software\\PlaydateSDK"#)?
.get_string("")?;
return Self::try_new_exact(key);
}

/// Create new `Sdk` with default env var
pub fn try_from_default_env() -> Result<Self, Error> {
let sdk = std::env::var_os(SDK_ENV_VAR).map(PathBuf::from)
Expand Down

0 comments on commit 85ebd13

Please sign in to comment.