Comments (6)
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.
from cargo-bundle.
This is a very good idea. No concerns beyond distinguishing between cargo run
and direct execution come to mind.
from cargo-bundle.
Looks like cargo
sets several environment variables when executing commands (including cargo run
) that wouldn't normally be present when running the binary directly. So the library could check e.g. std::env::var_os("CARGO").is_some()
to determine if the binary is being run via cargo run
.
from cargo-bundle.
This feature is a must-be. Is there any ongoing development for this?
from cargo-bundle.
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:
- cargo-bundle could provide a companion library (since a single crate can have both a binary and a library) that programs can depend on for loading resources. Since this library would share code with the cargo-bundle binary, they'd be easy to keep in sync.
- The simplest API for this library that comes to mind would be function that takes a file path/URL as written in the
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.- Ideally, this library would also work correctly if you run your application via
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?
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 would like the application to have as current directory the folder from where I launch it.
from cargo-bundle.
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 cargo bundle
arguments. For example, for build deb
cargo bundle --format deb
- cargo bundle will then set a variable:
env::set_var(PACKAGE_TYPE, "DEB");
- the crate companion will then use it in its code (with a build.rs file). If the variable is not set, this means that cargo run was used
Notes:
- The variable in question could directly provide the full path, but it would need to be set in several places in the code
- I really like the idea of providing a library by adding a
lib.rs
file, but for now, this will add all the cargo-bundle dependencies to our applications, which seems very unnecessary.
refs:
- cargo issue : rust-lang/cargo#1982
- my app which use env var to do this: https://github.com/wiiznokes/fan-control
from cargo-bundle.
Related Issues (20)
- Add release binaries to github releases for easy use with github actions HOT 1
- Adding libvulkan.dylib to ios bundle
- Crashing while install iOS app to Simulator
- How can I use cross and cargo bundle together? HOT 1
- `cargo-bundle` doesn't find correct package in workspace
- `cargo-bundle` should use `bin` target name instead of package name
- Does not respect ~/.cargo/config.toml target-dir setting
- Changing executable and bundle names based on --example argument
- Support Virtual Workspaces (Bundling Multiple Binaries in One Installer)
- short_description is not optionnal HOT 1
- System category from xdg not working
- Icon not showing on Ubuntu 23.10 HOT 1
- Mac M1 termainal can run, but .app crash immediately HOT 3
- About getter pattern HOT 1
- path resolver is broken on nesting rust project HOT 3
- Menu Item name is not shown on macOS
- Linker error `ld: framework not found Security` HOT 1
- Implement Document Handling for macOS
- Support for iOS production bundles HOT 1
- macOS Bundle Icon color messed up HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cargo-bundle.