diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c59dd6f..b73074a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,5 @@ jobs: uses: dtolnay/rust-toolchain@stable - name: Install wasm-pack uses: taiki-e/install-action@wasm-pack - - name: Run wasm tests (`--no-default-features`) - run: wasm-pack test --node --no-default-features - - name: Run wasm tests (`--all-features`) - run: wasm-pack test --node --all-features + - name: Run wasm tests + run: wasm-pack test --node diff --git a/Cargo.lock b/Cargo.lock index 887068e..8dab8fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -334,7 +334,6 @@ dependencies = [ "keyvalues-parser", "keyvalues-serde", "serde", - "serde_derive", "wasm-bindgen-test", "winreg", ] diff --git a/Cargo.toml b/Cargo.toml index d7019ff..a9686fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,13 +14,8 @@ categories = ["config", "filesystem"] rust-version = "1.70.0" [package.metadata.docs.rs] -all-features = true rustdoc-args = ["--cfg", "docsrs"] -[features] -default = ["locate"] -locate = ["locate_backend"] - [dependencies] crc = "3.0" keyvalues-parser = "0.2" @@ -29,13 +24,9 @@ serde = { version = "1.0.0", features = ["derive"] } # Platform-specific dependencies used for locating the steam dir [target."cfg(target_os=\"windows\")".dependencies] -locate_backend = { package = "winreg", version = "0.51", optional = true } +winreg = "0.51" [target."cfg(any(target_os=\"macos\", target_os=\"linux\"))".dependencies] -locate_backend = { package = "home", version = "0.5.9", optional = true } -# Other platforms aren't supported for locating, so we use a dummy package that -# we already depend on since it won't be used for anything -[target."cfg(not(any(target_os=\"windows\", target_os=\"macos\", target_os=\"linux\")))".dependencies] -locate_backend = { package = "serde_derive", version = "1.0.0", optional = true } +home = "0.5.9" [dev-dependencies] insta = { version = "1.34.0", features = ["ron"] } @@ -43,12 +34,9 @@ wasm-bindgen-test = "0.3.39" [[example]] name = "appmanifest" -required-features = ["locate"] [[example]] name = "overview" -required-features = ["locate"] [[example]] name = "shortcuts" -required-features = ["locate"] diff --git a/README.md b/README.md index fe2a247..60f3637 100644 --- a/README.md +++ b/README.md @@ -24,14 +24,6 @@ Simply add `steamlocate` using $ cargo add steamlocate ``` -## Feature flags - -Default: `locate` - -| Feature flag | Description | -| :---: | :--- | -| `locate` | Enables automatically detecting the Steam installation on supported platforms (currently Windows, MacOS, and Linux). Unsupported platforms will return a runtime error. | - # Examples ## Locate the Steam installation and a specific game diff --git a/src/__private_tests/wasm.rs b/src/__private_tests/wasm.rs index 1cdef6d..1c61c19 100644 --- a/src/__private_tests/wasm.rs +++ b/src/__private_tests/wasm.rs @@ -1,10 +1,13 @@ use wasm_bindgen_test::wasm_bindgen_test; #[wasm_bindgen_test] -#[cfg_attr(not(feature = "locate"), ignore = "Needs `locate` feature")] +#[cfg_attr( + not(any(target_os = "windows", target_os = "macos", target_os = "linux")), + ignore = "Needs `locate` feature" +)] fn locate() { - #[cfg(not(feature = "locate"))] + #[cfg(any(target_os = "windows", target_os = "macos", target_os = "linux"))] unreachable!("Don't run ignored tests silly"); - #[cfg(feature = "locate")] + #[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux")))] let _ = crate::SteamDir::locate().unwrap_err(); } diff --git a/src/error.rs b/src/error.rs index ae6ead5..db1667f 100644 --- a/src/error.rs +++ b/src/error.rs @@ -53,7 +53,6 @@ impl fmt::Display for Error { impl std::error::Error for Error {} impl Error { - #[cfg(feature = "locate")] pub(crate) fn locate(locate: LocateError) -> Self { Self::FailedLocate(locate) } @@ -85,14 +84,14 @@ pub enum LocateError { } impl LocateError { - #[cfg(all(feature = "locate", target_os = "windows"))] + #[cfg(target_os = "windows")] pub(crate) fn winreg(io: io::Error) -> Self { Self::Backend(BackendError { inner: BackendErrorInner(std::sync::Arc::new(io)), }) } - #[cfg(all(feature = "locate", not(target_os = "windows")))] + #[cfg(any(target_os = "macos", target_os = "linux"))] pub(crate) fn no_home() -> Self { Self::Backend(BackendError { inner: BackendErrorInner::NoHome, @@ -111,24 +110,24 @@ impl fmt::Display for LocateError { #[derive(Clone, Debug)] pub struct BackendError { - #[cfg(feature = "locate")] + #[cfg(any(target_os = "windows", target_os = "macos", target_os = "linux"))] #[allow(dead_code)] // Only used for displaying currently inner: BackendErrorInner, } impl fmt::Display for BackendError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - #[cfg(all(feature = "locate", target_os = "windows"))] + #[cfg(target_os = "windows")] { write!(f, "{}", self.inner.0) } - #[cfg(all(feature = "locate", not(target_os = "windows")))] + #[cfg(any(target_os = "macos", target_os = "linux"))] { match self.inner { BackendErrorInner::NoHome => f.write_str("Unable to locate the user's $HOME"), } } - #[cfg(not(feature = "locate"))] + #[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux")))] { // "Use" the unused value let _ = f; @@ -140,10 +139,10 @@ impl fmt::Display for BackendError { // TODO: move all this conditional junk into different modules, so that I don't have to keep // repeating it everywhere #[derive(Clone, Debug)] -#[cfg(all(feature = "locate", target_os = "windows"))] +#[cfg(target_os = "windows")] struct BackendErrorInner(std::sync::Arc); #[derive(Clone, Debug)] -#[cfg(all(feature = "locate", not(target_os = "windows")))] +#[cfg(any(target_os = "macos", target_os = "linux"))] enum BackendErrorInner { NoHome, } diff --git a/src/lib.rs b/src/lib.rs index 1a8afd4..fc17849 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -102,7 +102,6 @@ pub mod app; pub mod config; pub mod error; pub mod library; -#[cfg(feature = "locate")] mod locate; pub mod shortcut; // NOTE: exposed publicly, so that we can use them in doctests @@ -170,7 +169,6 @@ impl SteamDir { /// [`LocateError::Unsupported`][error::LocateError::Unsupported] /// /// [See the struct docs][Self#example] for an example - #[cfg(feature = "locate")] pub fn locate() -> Result { let path = locate::locate_steam_dir()?; diff --git a/src/locate.rs b/src/locate.rs index de6ecc7..1848d99 100644 --- a/src/locate.rs +++ b/src/locate.rs @@ -16,7 +16,6 @@ fn locate_steam_dir_helper() -> Result { fn locate_steam_dir_helper() -> Result { use crate::error::{Error, LocateError}; - use locate_backend as winreg; use winreg::{ enums::{HKEY_LOCAL_MACHINE, KEY_READ}, RegKey, @@ -49,7 +48,6 @@ fn locate_steam_dir_helper() -> Result { #[cfg(target_os = "macos")] fn locate_steam_dir_helper() -> Result { use crate::{error::LocateError, Error}; - use locate_backend as home; // Steam's installation location is pretty easy to find on macOS, as it's always in // $USER/Library/Application Support let home_dir = home::home_dir().ok_or_else(|| Error::locate(LocateError::no_home()))?; @@ -65,8 +63,6 @@ fn locate_steam_dir_helper() -> Result { use crate::error::{Error, LocateError, ValidationError}; - use locate_backend as home; - // Steam's installation location is pretty easy to find on Linux, too, thanks to the symlink in $USER let home_dir = home::home_dir().ok_or_else(|| Error::locate(LocateError::no_home()))?; let snap_dir = match env::var("SNAP_USER_DATA") {