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

Bundling another executable (ie, not the current executable) #29

Open
akazukin5151 opened this issue Jun 5, 2022 · 0 comments
Open

Comments

@akazukin5151
Copy link

See my fork. My primary usage was to bundle another executable, rather than bundling the current executable and then immediately launching the bundle. This is because I want to distribute a rust program to mac users in the form of a .app bundle. The current API requires the end user to run an executable (instead of .app).

My fork above moves the src_exe variable in self_bundle() and build() to the function's parameters. The code that immediately launches the bundle is now from a method of FruitApp instead of Trampoline.

The code for the bundler program would be like:

fn main() {
    fruitbasket::Trampoline::new("myapp", "myapp", "com.me.myapp")
    .resource(icon)
    .self_bundle("path/to/myapp", fruitbasket::InstallDir::Custom("dist".to_string()))
    .unwrap();
}

When the bundler program is run, it will bundle the myapp executable into a .app, which can be double clicked to launch.

The main app needs to be modified like this so that the resource path can be accessed etc:

fn main() {
    let app = fruitbasket::FruitApp::new();
    let bundle_path = std::path::Path::new("dist/myapp.app");
    fruitbasket::FruitApp::launch_bundle(bundle_path);

    let path = fruitbasket::FruitApp::bundled_resource_path("icon", "");
    original_main(path);

    fruitbasket::FruitApp::terminate(0);
}

I think letting the user to pass in src_exe will make this library more flexible - it's up to them if they want to bundle the current executable or another executable. Please let me know your thoughts on this.

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

1 participant