-
Notifications
You must be signed in to change notification settings - Fork 78
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
Provide a cross-platform way to load bundled resources #12
Comments
This is a very good idea. No concerns beyond distinguishing between |
Looks like |
This feature is a must-be. Is there any ongoing development for this? |
I'm not aware of any work being done on this. If you'd like to try to implement it, pull-requests would be welcome. |
…tory-url, r=jdm Add CFBundleCopyResourcesDirectoryURL I need this because of burtonageo/cargo-bundle#12.
Initially, the game will be distributed through itch.io [^1], a platform for indie games. itch.io provides tools that make it easy to publish and distribute a game to players, which massively reduces the burden on us to produce builds and installers for the different platforms. A new GitHub Action has been created that runs when a new release is created. Pre-releases are pushed to a beta channel on itch.io, while regular releases are pushed to the main channel. Releasing the game for macOS requires us to create an app bundle [^2], which is done with `cargo-bundle`. `cargo-bundle` can automatically copy resources into the bundle, but it is missing an API to access them dynamically from the program [^3]. For this reason, the GitHub Action moves the resources back so that they are next to the binary. [^1]: https://jdno.itch.io/auto-traffic-control [^2]: https://itch.io/docs/itch/integrating/platforms/macos.html [^3]: burtonageo/cargo-bundle#12
As of today, is it possible to load bundled resources at runtime? Also, when I run the bundle application, the current directory seems to be the root (/), no matter where the bundle is launched. I got this information with the command std::env::current_dir(). |
I think this should be handled primarily with environment variables. Since there can be several types of packages on the same OS, we are forced to depend on the
Notes:
refs:
|
Seems like one of the strengths of cargo-bundle is being able to easily handle resource files in a cross-platform way (something I've found to be a pain to deal with on previous, non-Rust projects). While it already provides an easy way to include arbitrary resource files in the bundle, that still leaves the other half of the job: finding and loading those resources once the application is running.
A few ideas for what this could look like:
resources
field of the bundle spec, and returns a path to where that file was actually placed by the bundle, depending on what system you're running on (so on OSX it would use e.g.CFBundleCopyResourcesDirectoryURL
, on Debian it would look in/usr/lib/package_name/
, etc). That way your actual application code doesn't need to care about what OS it's running on.cargo run
rather than bundling it first, in which case it would load the resources from their original location as written in theresources
field of the bundle spec. (Although I'm not sure off the top of my head what is the best way for the library to detect this situation).Thoughts?
The text was updated successfully, but these errors were encountered: