Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please consider removing the compile_error! macro call #48

Closed
mainrs opened this issue Nov 26, 2023 · 8 comments
Closed

Please consider removing the compile_error! macro call #48

mainrs opened this issue Nov 26, 2023 · 8 comments

Comments

@mainrs
Copy link

mainrs commented Nov 26, 2023

The crate would run under the was32-wasi target, since it can get filesystem access through the wasm runtime running the code.

steamlocate-rs/src/lib.rs

Lines 118 to 119 in 4982655

#[cfg(not(any(target_os = "windows", target_os = "macos", target_os = "linux")))]
compile_error!("Unsupported operating system!");

@CosmicHorrorDev
Copy link
Collaborator

Which platform implementation would it use for locating the steam install?

@mainrs
Copy link
Author

mainrs commented Nov 26, 2023

I just noticed the issue that you mentioned. Since the platform discovery logic is feature-gated behind compilation flags, there is none available for WASM. Meaning that it wouldn't even compile, since it wouldn't locate the locate_steam_dir function.

I guess my usecase is relatively specific, so I can write my own library for it. In my case, the logic would all have to reside in the library and I would have to use runtime detection to check the correct paths on the user's system. Another caveat is that the registry is not available in WASI. It could be made available, but that is done using host functions. Meaning that a runtime for WASM provides additional functions.

If something comes up during my library development, I can open an issue and share some thoughts. But as it is now, this library does a good job for major platforms. Maybe it's better to keep it taht way! :)

@CosmicHorrorDev
Copy link
Collaborator

Sure, feel free to open issues for anything later on

On the dev-2.0 branch there's also functionality for "locating" a steam install from an arbitrary path that gets passed in

https://github.com/WilliamVenner/steamlocate-rs/blob/dev-v2.0/src/lib.rs#L213-L223

Maybe that would be of help? I feel like we're pretty close to supporting what you want. I'd be open to seeing what more needs to be done to get something working

@mainrs
Copy link
Author

mainrs commented Nov 26, 2023

On the dev-2.0 branch there's also functionality for "locating" a steam install from an arbitrary path that gets passed in

That is actually enough for me, since I just scan known steam installation folders, even on Windows. Would be awesome if I could compile the library with cargo build --target wasm32-wasi and have that functionality available.

@CosmicHorrorDev
Copy link
Collaborator

I think it should be enough to feature-gate off locate(), and then other than that everything should work still

@CosmicHorrorDev
Copy link
Collaborator

I just opened #49 that should resolve this. @mainrs I would appreciate if you could take a look and let me know if there is anything else that you need

@mainrs
Copy link
Author

mainrs commented Nov 30, 2023

I tested it out. It works well!

Is it currently possible to get a list of user library folders without having steamlocate access files within them? My use case is really specific. I have two binaries. One is a bootstrapper that has access to all known steam installation directories. It's only task is to discover a user's library folders. I then have a restricted binary that has access to the user's library folders only and discovers all installed games.

How the library works right now is that, if I call the library folders method on a Steam, it tries to read from them. Given my situation it does not have filesystem access permission for those.

I can implement the library discovery myself. It's just reading a vdf file. What would be great is if I can instantiate a LibraryFolder for a given path the same way I can instantiate a Steam dir for a given path.

@CosmicHorrorDev
Copy link
Collaborator

I tested it out. It works well!

🥳

Is it currently possible to get a list of user library folders without having steamlocate access files within them?

...

What would be great is if I can instantiate a LibraryFolder for a given path the same way I can instantiate a Steam dir for a given path.

#51 reworked things so that you can get the listing of all the library paths using steam_dir.library_paths() and exposes Library::from_dir() for constructing a library from an arbitrary path. Let me know if those work for your needs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants