Home

Awesome

Cargo bundle

Build Status

Wrap Rust executables in OS-specific app bundles

About

cargo-bundle is a tool used to generate installers or app bundles for GUI executables built with cargo. It can create .app bundles for Mac OS X and iOS, .deb packages for Linux, and .msi installers for Windows (note however that iOS and Windows support is still experimental). Support for creating .rpm packages (for Linux) and .apk packages (for Android) is still pending.

To install cargo bundle, run cargo install cargo-bundle. This will add the most recent version of cargo-bundle published to crates.io as a subcommand to your default cargo installation.

To start using cargo bundle, add a [package.metadata.bundle] section to your project's Cargo.toml file. This section describes various attributes of the generated bundle, such as its name, icon, description, copyright, as well as any packaging scripts you need to generate extra data. The full manifest format is described below.

To build a bundle for the OS you're on, simply run cargo bundle in your project's directory (where the Cargo.toml is placed). If you would like to bundle a release build, you must add the --release flag to your call. To cross-compile and bundle an application for another OS, add an appropriate --target flag, just as you would for cargo build.

Flags

--all-features           Build a bundle with all crate features.
--bin <NAME>             Bundle the specified binary
--example <NAME>         Bundle the specified example
--features <FEATURES>    Set crate features for the bundle. Eg: `--features "f1 f2"`
--format <FORMAT>        Which bundle format to produce [possible values: deb, ios, msi, osx, rpm]
-h, --help                   Prints help information
--no-default-features    Build a bundle without the default crate features.
--profile <NAME>         Build a bundle from a target build using the given profile
--release                Build a bundle from a target built in release mode
--target <TRIPLE>        Build a bundle for the target triple

Targets

aarch64-unknown-linux-gnu	ARM64 Linux (kernel 4.1, glibc 2.17+) 1
i686-pc-windows-gnu	        32-bit MinGW (Windows 7+) 2 3
i686-pc-windows-msvc	    32-bit MSVC (Windows 7+) 2 3
i686-unknown-linux-gnu	    32-bit Linux (kernel 3.2+, glibc 2.17+) 3
x86_64-apple-darwin	        64-bit macOS (10.12+, Sierra+)
x86_64-pc-windows-gnu	    64-bit MinGW (Windows 7+) 2
x86_64-pc-windows-msvc	    64-bit MSVC (Windows 7+) 2
x86_64-unknown-linux-gnu	64-bit Linux (kernel 3.2+, glibc 2.17+)

Bundle manifest format

There are several fields in the [package.metadata.bundle] section.

General settings

These settings apply to bundles for all (or most) OSes.

note: description is also required in the [package] section.

Linux-specific settings

These settings are used only when bundling Linux compatible packages (currently deb only).

Debian-specific settings

These settings are used only when bundling deb packages.

Mac OS X-specific settings

These settings are used only when bundling osx packages.

Settings for specified binary

[package.metadata.bundle] only applies to the main executable. Settings for other binaries can be specified in a [package.metadata.bundle.bin.<binary name>] section.

[package]
# other fields...

[package.metadata.bundle.bin.foo]
icon = ["icons/foo32x32.png"]
# other fields...

[[bin]]
name = "foo"
path = "src/bin/foo.rs"
# other fields...

Example Cargo.toml:

[package]
name = "example"
# ...other fields...

[package.metadata.bundle]
name = "ExampleApplication"
identifier = "com.doe.exampleapplication"
icon = ["32x32.png", "128x128.png", "128x128@2x.png"]
version = "1.0.0"
resources = ["assets", "images/**/*.png", "secrets/public_key.txt"]
copyright = "Copyright (c) Jane Doe 2016. All rights reserved."
category = "Developer Tool"
short_description = "An example application."
long_description = """
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.  Ut
enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat.
"""
deb_depends = ["libgl1-mesa-glx", "libsdl2-2.0-0 (>= 2.0.5)"]
osx_frameworks = ["SDL2"]
osx_url_schemes = ["com.doe.exampleapplication"]

Contributing

cargo-bundle has ambitions to be inclusive project and welcome contributions from anyone. Please abide by the Rust code of conduct.

Status

Very early alpha. Expect the format of the [package.metadata.bundle] section to change, and there is no guarantee of stability.

License

This program is licensed either under the terms of the Apache Software License, or the MIT License.