Skip to content

Commit 080f639

Browse files
authored
refactor(bundler): specific settings on dedicated structs, update README (#1380)
1 parent f72b93b commit 080f639

File tree

17 files changed

+199
-219
lines changed

17 files changed

+199
-219
lines changed

.changes/bundle-macos-refactor.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri-bundler": minor
3+
"tauri": minor
4+
---
5+
6+
Rename macOS bundle settings from `osx` to `macOS`.

.github/workflows/build-smoke-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- platform: ubuntu-latest
4040
releaseFolder: target/release/bundle/deb
4141
- platform: macos-latest
42-
releaseFolder: target/release/bundle/osx
42+
releaseFolder: target/release/bundle/macos
4343
- platform: windows-latest
4444
releaseFolder: target/release/bundle/msi
4545

cli/core/config_definition.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
55
use serde_json::Value as JsonValue;
66
use serde_with::skip_serializing_none;
77

8-
use std::{collections::HashMap, path::PathBuf};
8+
use std::collections::HashMap;
99

1010
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize, JsonSchema)]
1111
#[serde(untagged)]
@@ -26,7 +26,7 @@ pub struct DebConfig {
2626
#[skip_serializing_none]
2727
#[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize, JsonSchema)]
2828
#[serde(rename_all = "camelCase", deny_unknown_fields)]
29-
pub struct OsxConfig {
29+
pub struct MacConfig {
3030
pub frameworks: Option<Vec<String>>,
3131
pub minimum_system_version: Option<String>,
3232
pub exception_domain: Option<String>,
@@ -51,7 +51,7 @@ pub struct PackageConfig {
5151
pub struct BundleConfig {
5252
/// Whether we should build your app with tauri-bundler or plain `cargo build`
5353
pub active: bool,
54-
/// The bundle targets, currently supports ["deb", "osx", "msi", "appimage", "dmg"] or "all"
54+
/// The bundle targets, currently supports ["deb", "app", "msi", "appimage", "dmg"] or "all"
5555
pub targets: Option<BundleTarget>,
5656
/// The app's identifier
5757
pub identifier: Option<String>,
@@ -65,11 +65,10 @@ pub struct BundleConfig {
6565
pub category: Option<String>,
6666
pub short_description: Option<String>,
6767
pub long_description: Option<String>,
68-
pub script: Option<PathBuf>,
6968
#[serde(default)]
7069
pub deb: DebConfig,
71-
#[serde(default)]
72-
pub osx: OsxConfig,
70+
#[serde(rename = "macOS", default)]
71+
pub macos: MacConfig,
7372
pub external_bin: Option<Vec<String>>,
7473
}
7574

cli/core/schema.json

+16-22
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"deb": {
8585
"useBootstrapper": false
8686
},
87-
"osx": {
87+
"macOS": {
8888
"useBootstrapper": false
8989
}
9090
},
@@ -296,13 +296,13 @@
296296
"null"
297297
]
298298
},
299-
"osx": {
299+
"macOS": {
300300
"default": {
301301
"useBootstrapper": false
302302
},
303303
"allOf": [
304304
{
305-
"$ref": "#/definitions/OsxConfig"
305+
"$ref": "#/definitions/MacConfig"
306306
}
307307
]
308308
},
@@ -316,20 +316,14 @@
316316
"type": "string"
317317
}
318318
},
319-
"script": {
320-
"type": [
321-
"string",
322-
"null"
323-
]
324-
},
325319
"shortDescription": {
326320
"type": [
327321
"string",
328322
"null"
329323
]
330324
},
331325
"targets": {
332-
"description": "The bundle targets, currently supports [\"deb\", \"osx\", \"msi\", \"appimage\", \"dmg\"] or \"all\"",
326+
"description": "The bundle targets, currently supports [\"deb\", \"app\", \"msi\", \"appimage\", \"dmg\"] or \"all\"",
333327
"anyOf": [
334328
{
335329
"$ref": "#/definitions/BundleTarget"
@@ -723,17 +717,7 @@
723717
},
724718
"additionalProperties": false
725719
},
726-
"NotificationAllowlistConfig": {
727-
"type": "object",
728-
"properties": {
729-
"all": {
730-
"default": false,
731-
"type": "boolean"
732-
}
733-
},
734-
"additionalProperties": false
735-
},
736-
"OsxConfig": {
720+
"MacConfig": {
737721
"type": "object",
738722
"properties": {
739723
"exceptionDomain": {
@@ -770,6 +754,16 @@
770754
},
771755
"additionalProperties": false
772756
},
757+
"NotificationAllowlistConfig": {
758+
"type": "object",
759+
"properties": {
760+
"all": {
761+
"default": false,
762+
"type": "boolean"
763+
}
764+
},
765+
"additionalProperties": false
766+
},
773767
"PackageConfig": {
774768
"type": "object",
775769
"properties": {
@@ -879,7 +873,7 @@
879873
"deb": {
880874
"useBootstrapper": false
881875
},
882-
"osx": {
876+
"macOS": {
883877
"useBootstrapper": false
884878
}
885879
},

cli/core/src/build/rust.rs

+14-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ use std::{fs::File, io::Read, path::PathBuf, process::Command, str::FromStr};
33
use serde::Deserialize;
44

55
use crate::helpers::{app_paths::tauri_dir, config::Config};
6-
use tauri_bundler::{AppCategory, BundleBinary, BundleSettings, PackageSettings};
6+
use tauri_bundler::{
7+
AppCategory, BundleBinary, BundleSettings, DebianSettings, MacOSSettings, PackageSettings,
8+
};
79

810
/// The `workspace` section of the app configuration (read from Cargo.toml).
911
#[derive(Clone, Debug, Deserialize)]
@@ -317,15 +319,18 @@ fn tauri_config_to_bundle_settings(
317319
},
318320
short_description: config.short_description,
319321
long_description: config.long_description,
320-
script: config.script,
321-
deb_depends: config.deb.depends,
322-
deb_use_bootstrapper: Some(config.deb.use_bootstrapper),
323-
osx_frameworks: config.osx.frameworks,
324-
osx_minimum_system_version: config.osx.minimum_system_version,
325-
osx_license: config.osx.license,
326-
osx_use_bootstrapper: Some(config.osx.use_bootstrapper),
327322
external_bin: config.external_bin,
328-
exception_domain: config.osx.exception_domain,
323+
deb: DebianSettings {
324+
depends: config.deb.depends,
325+
use_bootstrapper: Some(config.deb.use_bootstrapper),
326+
},
327+
macos: MacOSSettings {
328+
frameworks: config.macos.frameworks,
329+
minimum_system_version: config.macos.minimum_system_version,
330+
license: config.macos.license,
331+
use_bootstrapper: Some(config.macos.use_bootstrapper),
332+
exception_domain: config.macos.exception_domain,
333+
},
329334
..Default::default()
330335
})
331336
}

cli/core/templates/src-tauri/tauri.conf.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"depends": [],
3232
"useBootstrapper": false
3333
},
34-
"osx": {
34+
"macOS": {
3535
"frameworks": [],
3636
"minimumSystemVersion": "",
3737
"useBootstrapper": false,
@@ -54,4 +54,4 @@
5454
"csp": "default-src blob: data: filesystem: ws: http: https: 'unsafe-eval' 'unsafe-inline'"
5555
}
5656
}
57-
}
57+
}

cli/tauri-bundler/Readme.md cli/tauri-bundler/README.md

+56-68
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,14 @@
1-
# Cargo Tauri Bundle
1+
# Tauri Bundler
22

3-
Wrap Rust executables in OS-specific app bundles
3+
Wrap Rust executables in OS-specific app bundles.
44

55
## About
66

7-
`cargo tauri-bundle` is a tool used to generate installers or app bundles for GUI
8-
executables built with `cargo`. It can create `.app` bundles for Mac OS X and
9-
iOS, `.deb` packages for Linux, and `.msi` installers for Windows (note however
10-
that iOS and Windows support is still experimental). Support for creating
11-
`.rpm` packages (for Linux) and `.apk` packages (for Android) is still pending.
7+
This is a fork of the awesome [cargo-bundle](https://github.com/burtonageo/cargo-bundle), turned into a library used by the [Tauri CLI](../core).
128

13-
To install `cargo tauri-bundle`, run `cargo install cargo-tauri-bundle`. This will add the most recent version of `cargo-bundle`
14-
published to [crates.io](https://crates.io/crates/cargo-bundle) as a subcommand to your default `cargo` installation.
9+
## Configuration
1510

16-
To start using `cargo tauri-bundle`, add a `[package.metadata.bundle]` section to your project's `Cargo.toml` file. This
17-
section describes various attributes of the generated bundle, such as its name, icon, description, copyright, as well
18-
as any packaging scripts you need to generate extra data. The full manifest format is described below.
19-
20-
To build a bundle for the OS you're on, simply run `cargo tauri-bundle` in your
21-
project's directory (where the `Cargo.toml` is placed). If you would like to
22-
bundle a release build, you must add the `--release` flag to your call. To
23-
cross-compile and bundle an application for another OS, add an appropriate
24-
`--target` flag, just as you would for `cargo build`.
25-
26-
## Bundle manifest format
27-
28-
There are several fields in the `[package.metadata.bundle]` section.
11+
Tauri automatically loads configurations from the `tauri.conf.json > tauri > bundle` object, but this library doesn't rely on it and can be used by non-Tauri apps.
2912

3013
### General settings
3114

@@ -39,22 +22,20 @@ These settings apply to bundles for all (or most) OSes.
3922
bundle's `CFBundleIdentifier` value; for Windows, this is hashed to create
4023
an application GUID.
4124
* `icon`: [OPTIONAL] The icons used for your application. This should be an array of file paths or globs (with images
42-
in various sizes/formats); `cargo-bundle` will automatically convert between image formats as necessary for
25+
in various sizes/formats); `tauri-bundler` will automatically convert between image formats as necessary for
4326
different platforms. Supported formats include ICNS, ICO, PNG, and anything else that can be decoded by the
4427
[`image`](https://crates.io/crates/image) crate. Icons intended for high-resolution (e.g. Retina) displays
4528
should have a filename with `@2x` just before the extension (see example below).
4629
* `version`: [OPTIONAL] The version of the application. If this is not present, then it will use the `version`
4730
value from your `Cargo.toml` file.
4831
* `resources`: [OPTIONAL] List of files or directories which will be copied to the resources section of the
4932
bundle. Globs are supported.
50-
* `script`: [OPTIONAL] This is a reserved field; at the moment it is not used for anything, but may be used to
51-
run scripts while packaging the bundle (e.g. download files, compress and encrypt, etc.).
5233
* `copyright`: [OPTIONAL] This contains a copyright string associated with your application.
5334
* `category`: [OPTIONAL] What kind of application this is. This can
5435
be a human-readable string (e.g. `"Puzzle game"`), or a Mac OS X
5536
LSApplicationCategoryType value
5637
(e.g. `"public.app-category.puzzle-games"`), or a GNOME desktop
57-
file category name (e.g. `"LogicGame"`), and `cargo-bundle` will
38+
file category name (e.g. `"LogicGame"`), and `tauri-bundler` will
5839
automatically convert as needed for different platforms.
5940
* `short_description`: [OPTIONAL] A short, one-line description of the application. If this is not present, then it
6041
will use the `description` value from your `Cargo.toml` file.
@@ -64,72 +45,79 @@ These settings apply to bundles for all (or most) OSes.
6445

6546
These settings are used only when bundling `deb` packages.
6647

67-
* `deb_depends`: A list of strings indicating other packages (e.g. shared
48+
* `depends`: A list of strings indicating other packages (e.g. shared
6849
libraries) that this package depends on to be installed. If present, this
6950
forms the `Depends:` field of the `deb` package control file.
51+
* `use_bootstrapper`: Enables the bootstrapper script, which allows access to the environment variables.
7052

7153
### Mac OS X-specific settings
7254

73-
These settings are used only when bundling `osx` packages.
55+
These settings are used only when bundling `app` and `dmg` packages.
7456

75-
* `osx_frameworks`: A list of strings indicating any Mac OS X frameworks that
57+
* `frameworks`: A list of strings indicating any Mac OS X frameworks that
7658
need to be bundled with the app. Each string can either be the name of a
7759
framework (without the `.framework` extension, e.g. `"SDL2"`), in which case
78-
`cargo-bundle` will search for that framework in the standard install
60+
`tauri-bundler` will search for that framework in the standard install
7961
locations (`~/Library/Frameworks/`, `/Library/Frameworks/`, and
8062
`/Network/Library/Frameworks/`), or a path to a specific framework bundle
8163
(e.g. `./data/frameworks/SDL2.framework`). Note that this setting just makes
82-
`cargo-bundle` copy the specified frameworks into the OS X app bundle (under
64+
`tauri-bundler` copy the specified frameworks into the OS X app bundle (under
8365
`Foobar.app/Contents/Frameworks/`); you are still responsible for (1)
8466
arranging for the compiled binary to link against those frameworks (e.g. by
8567
emitting lines like `cargo:rustc-link-lib=framework=SDL2` from your
8668
`build.rs` script), and (2) embedding the correct rpath in your binary
8769
(e.g. by running `install_name_tool -add_rpath
8870
"@executable_path/../Frameworks" path/to/binary` after compiling).
89-
* `osx_minimum_system_version`: A version string indicating the minimum Mac OS
71+
* `minimum_system_version`: A version string indicating the minimum Mac OS
9072
X version that the bundled app supports (e.g. `"10.11"`). If you are using
9173
this config field, you may also want have your `build.rs` script emit
9274
`cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=10.11` (or whatever version number
9375
you want) to ensure that the compiled binary has the same minimum version.
94-
95-
### Example `Cargo.toml`:
96-
97-
```toml
98-
[package]
99-
name = "example"
100-
# ...other fields...
101-
102-
[package.metadata.bundle]
103-
name = "ExampleApplication"
104-
identifier = "com.doe.exampleapplication"
105-
icon = ["32x32.png", "128x128.png", "128x128@2x.png"]
106-
version = "1.0.0"
107-
resources = ["assets", "images/**/*.png", "secrets/public_key.txt"]
108-
copyright = "Copyright (c) Jane Doe 2016. All rights reserved."
109-
category = "Developer Tool"
110-
short_description = "An example application."
111-
long_description = """
112-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
113-
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
114-
enim ad minim veniam, quis nostrud exercitation ullamco laboris
115-
nisi ut aliquip ex ea commodo consequat.
116-
"""
117-
deb_depends = ["libgl1-mesa-glx", "libsdl2-2.0-0 (>= 2.0.5)"]
118-
osx_frameworks = ["SDL2"]
76+
* `license`: Path to the license file for the DMG bundle.
77+
* `exception_domain`: The exception domain to use on the macOS .app bundle. Allows communication to the outside world e.g. a web server you're shipping.
78+
* `use_bootstrapper`: Enables the bootstrapper script, which allows access to the environment variables.
79+
80+
### Example `tauri.conf.json`:
81+
82+
```json
83+
{
84+
"package": {
85+
"productName": "Your Awesome App",
86+
"version": "0.1.0"
87+
},
88+
"tauri": {
89+
"bundle": {
90+
"active": true,
91+
"identifier": "com.my.app",
92+
"shortDescription": "",
93+
"longDescription": "",
94+
"copyright": "Copyright (c) You 2021. All rights reserved.",
95+
"icon": [
96+
"icons/32x32.png",
97+
"icons/128x128.png",
98+
"icons/128x128@2x.png",
99+
"icons/icon.icns",
100+
"icons/icon.ico"
101+
],
102+
"resources": ["./assets/**/*.png"],
103+
"deb": {
104+
"depends": ["debian-dependency1", "debian-dependency2"],
105+
"useBootstrapper": true
106+
},
107+
"macOS": {
108+
"frameworks": [],
109+
"minimumSystemVersion": "10.11",
110+
"license": "./LICENSE",
111+
"useBootstrapper": true
112+
},
113+
"externalBin": ["./sidecar-app"]
114+
}
115+
}
116+
}
119117
```
120118

121-
## Contributing
122-
123-
`cargo-tauri-bundle` has ambitions to be inclusive project and welcome contributions from anyone. Please abide by the Rust
124-
code of conduct.
125-
126-
## Status
127-
128-
Very early alpha. Expect the format of the `[package.metadata.bundle]` section to change, and there is no guarantee of
129-
stability.
130-
131119
## License
132-
(c) 2017 - present, George Burton, Lucas Fernandes Gonçalves Nogueira, Daniel Thompson-Yvetot, Razvan Stoenescu
120+
(c) 2017 - present, George Burton, Tauri-Apps Organization
133121

134122
This program is licensed either under the terms of the
135123
[Apache Software License](http://www.apache.org/licenses/LICENSE-2.0), or the

0 commit comments

Comments
 (0)