mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-28 21:45:00 +03:00
refactor(bundler): specific settings on dedicated structs, update README (#1380)
This commit is contained in:
parent
f72b93b676
commit
080f6391ba
6
.changes/bundle-macos-refactor.md
Normal file
6
.changes/bundle-macos-refactor.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
"tauri-bundler": minor
|
||||
"tauri": minor
|
||||
---
|
||||
|
||||
Rename macOS bundle settings from `osx` to `macOS`.
|
2
.github/workflows/build-smoke-tests.yml
vendored
2
.github/workflows/build-smoke-tests.yml
vendored
@ -39,7 +39,7 @@ jobs:
|
||||
- platform: ubuntu-latest
|
||||
releaseFolder: target/release/bundle/deb
|
||||
- platform: macos-latest
|
||||
releaseFolder: target/release/bundle/osx
|
||||
releaseFolder: target/release/bundle/macos
|
||||
- platform: windows-latest
|
||||
releaseFolder: target/release/bundle/msi
|
||||
|
||||
|
@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value as JsonValue;
|
||||
use serde_with::skip_serializing_none;
|
||||
|
||||
use std::{collections::HashMap, path::PathBuf};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize, JsonSchema)]
|
||||
#[serde(untagged)]
|
||||
@ -26,7 +26,7 @@ pub struct DebConfig {
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize, JsonSchema)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub struct OsxConfig {
|
||||
pub struct MacConfig {
|
||||
pub frameworks: Option<Vec<String>>,
|
||||
pub minimum_system_version: Option<String>,
|
||||
pub exception_domain: Option<String>,
|
||||
@ -51,7 +51,7 @@ pub struct PackageConfig {
|
||||
pub struct BundleConfig {
|
||||
/// Whether we should build your app with tauri-bundler or plain `cargo build`
|
||||
pub active: bool,
|
||||
/// The bundle targets, currently supports ["deb", "osx", "msi", "appimage", "dmg"] or "all"
|
||||
/// The bundle targets, currently supports ["deb", "app", "msi", "appimage", "dmg"] or "all"
|
||||
pub targets: Option<BundleTarget>,
|
||||
/// The app's identifier
|
||||
pub identifier: Option<String>,
|
||||
@ -65,11 +65,10 @@ pub struct BundleConfig {
|
||||
pub category: Option<String>,
|
||||
pub short_description: Option<String>,
|
||||
pub long_description: Option<String>,
|
||||
pub script: Option<PathBuf>,
|
||||
#[serde(default)]
|
||||
pub deb: DebConfig,
|
||||
#[serde(default)]
|
||||
pub osx: OsxConfig,
|
||||
#[serde(rename = "macOS", default)]
|
||||
pub macos: MacConfig,
|
||||
pub external_bin: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@
|
||||
"deb": {
|
||||
"useBootstrapper": false
|
||||
},
|
||||
"osx": {
|
||||
"macOS": {
|
||||
"useBootstrapper": false
|
||||
}
|
||||
},
|
||||
@ -296,13 +296,13 @@
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"osx": {
|
||||
"macOS": {
|
||||
"default": {
|
||||
"useBootstrapper": false
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/OsxConfig"
|
||||
"$ref": "#/definitions/MacConfig"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -316,12 +316,6 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"script": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"shortDescription": {
|
||||
"type": [
|
||||
"string",
|
||||
@ -329,7 +323,7 @@
|
||||
]
|
||||
},
|
||||
"targets": {
|
||||
"description": "The bundle targets, currently supports [\"deb\", \"osx\", \"msi\", \"appimage\", \"dmg\"] or \"all\"",
|
||||
"description": "The bundle targets, currently supports [\"deb\", \"app\", \"msi\", \"appimage\", \"dmg\"] or \"all\"",
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/BundleTarget"
|
||||
@ -723,17 +717,7 @@
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"NotificationAllowlistConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"all": {
|
||||
"default": false,
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"OsxConfig": {
|
||||
"MacConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"exceptionDomain": {
|
||||
@ -770,6 +754,16 @@
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"NotificationAllowlistConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"all": {
|
||||
"default": false,
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"PackageConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -879,7 +873,7 @@
|
||||
"deb": {
|
||||
"useBootstrapper": false
|
||||
},
|
||||
"osx": {
|
||||
"macOS": {
|
||||
"useBootstrapper": false
|
||||
}
|
||||
},
|
||||
|
@ -3,7 +3,9 @@ use std::{fs::File, io::Read, path::PathBuf, process::Command, str::FromStr};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::helpers::{app_paths::tauri_dir, config::Config};
|
||||
use tauri_bundler::{AppCategory, BundleBinary, BundleSettings, PackageSettings};
|
||||
use tauri_bundler::{
|
||||
AppCategory, BundleBinary, BundleSettings, DebianSettings, MacOSSettings, PackageSettings,
|
||||
};
|
||||
|
||||
/// The `workspace` section of the app configuration (read from Cargo.toml).
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
@ -317,15 +319,18 @@ fn tauri_config_to_bundle_settings(
|
||||
},
|
||||
short_description: config.short_description,
|
||||
long_description: config.long_description,
|
||||
script: config.script,
|
||||
deb_depends: config.deb.depends,
|
||||
deb_use_bootstrapper: Some(config.deb.use_bootstrapper),
|
||||
osx_frameworks: config.osx.frameworks,
|
||||
osx_minimum_system_version: config.osx.minimum_system_version,
|
||||
osx_license: config.osx.license,
|
||||
osx_use_bootstrapper: Some(config.osx.use_bootstrapper),
|
||||
external_bin: config.external_bin,
|
||||
exception_domain: config.osx.exception_domain,
|
||||
deb: DebianSettings {
|
||||
depends: config.deb.depends,
|
||||
use_bootstrapper: Some(config.deb.use_bootstrapper),
|
||||
},
|
||||
macos: MacOSSettings {
|
||||
frameworks: config.macos.frameworks,
|
||||
minimum_system_version: config.macos.minimum_system_version,
|
||||
license: config.macos.license,
|
||||
use_bootstrapper: Some(config.macos.use_bootstrapper),
|
||||
exception_domain: config.macos.exception_domain,
|
||||
},
|
||||
..Default::default()
|
||||
})
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
"depends": [],
|
||||
"useBootstrapper": false
|
||||
},
|
||||
"osx": {
|
||||
"macOS": {
|
||||
"frameworks": [],
|
||||
"minimumSystemVersion": "",
|
||||
"useBootstrapper": false,
|
||||
@ -54,4 +54,4 @@
|
||||
"csp": "default-src blob: data: filesystem: ws: http: https: 'unsafe-eval' 'unsafe-inline'"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,31 +1,14 @@
|
||||
# Cargo Tauri Bundle
|
||||
# Tauri Bundler
|
||||
|
||||
Wrap Rust executables in OS-specific app bundles
|
||||
Wrap Rust executables in OS-specific app bundles.
|
||||
|
||||
## About
|
||||
|
||||
`cargo tauri-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.
|
||||
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).
|
||||
|
||||
To install `cargo tauri-bundle`, run `cargo install cargo-tauri-bundle`. This will add the most recent version of `cargo-bundle`
|
||||
published to [crates.io](https://crates.io/crates/cargo-bundle) as a subcommand to your default `cargo` installation.
|
||||
## Configuration
|
||||
|
||||
To start using `cargo tauri-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 tauri-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`.
|
||||
|
||||
## Bundle manifest format
|
||||
|
||||
There are several fields in the `[package.metadata.bundle]` section.
|
||||
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.
|
||||
|
||||
### General settings
|
||||
|
||||
@ -39,7 +22,7 @@ These settings apply to bundles for all (or most) OSes.
|
||||
bundle's `CFBundleIdentifier` value; for Windows, this is hashed to create
|
||||
an application GUID.
|
||||
* `icon`: [OPTIONAL] The icons used for your application. This should be an array of file paths or globs (with images
|
||||
in various sizes/formats); `cargo-bundle` will automatically convert between image formats as necessary for
|
||||
in various sizes/formats); `tauri-bundler` will automatically convert between image formats as necessary for
|
||||
different platforms. Supported formats include ICNS, ICO, PNG, and anything else that can be decoded by the
|
||||
[`image`](https://crates.io/crates/image) crate. Icons intended for high-resolution (e.g. Retina) displays
|
||||
should have a filename with `@2x` just before the extension (see example below).
|
||||
@ -47,14 +30,12 @@ These settings apply to bundles for all (or most) OSes.
|
||||
value from your `Cargo.toml` file.
|
||||
* `resources`: [OPTIONAL] List of files or directories which will be copied to the resources section of the
|
||||
bundle. Globs are supported.
|
||||
* `script`: [OPTIONAL] This is a reserved field; at the moment it is not used for anything, but may be used to
|
||||
run scripts while packaging the bundle (e.g. download files, compress and encrypt, etc.).
|
||||
* `copyright`: [OPTIONAL] This contains a copyright string associated with your application.
|
||||
* `category`: [OPTIONAL] What kind of application this is. This can
|
||||
be a human-readable string (e.g. `"Puzzle game"`), or a Mac OS X
|
||||
LSApplicationCategoryType value
|
||||
(e.g. `"public.app-category.puzzle-games"`), or a GNOME desktop
|
||||
file category name (e.g. `"LogicGame"`), and `cargo-bundle` will
|
||||
file category name (e.g. `"LogicGame"`), and `tauri-bundler` will
|
||||
automatically convert as needed for different platforms.
|
||||
* `short_description`: [OPTIONAL] A short, one-line description of the application. If this is not present, then it
|
||||
will use the `description` value from your `Cargo.toml` file.
|
||||
@ -64,72 +45,79 @@ These settings apply to bundles for all (or most) OSes.
|
||||
|
||||
These settings are used only when bundling `deb` packages.
|
||||
|
||||
* `deb_depends`: A list of strings indicating other packages (e.g. shared
|
||||
* `depends`: A list of strings indicating other packages (e.g. shared
|
||||
libraries) that this package depends on to be installed. If present, this
|
||||
forms the `Depends:` field of the `deb` package control file.
|
||||
* `use_bootstrapper`: Enables the bootstrapper script, which allows access to the environment variables.
|
||||
|
||||
### Mac OS X-specific settings
|
||||
|
||||
These settings are used only when bundling `osx` packages.
|
||||
These settings are used only when bundling `app` and `dmg` packages.
|
||||
|
||||
* `osx_frameworks`: A list of strings indicating any Mac OS X frameworks that
|
||||
* `frameworks`: A list of strings indicating any Mac OS X frameworks that
|
||||
need to be bundled with the app. Each string can either be the name of a
|
||||
framework (without the `.framework` extension, e.g. `"SDL2"`), in which case
|
||||
`cargo-bundle` will search for that framework in the standard install
|
||||
`tauri-bundler` will search for that framework in the standard install
|
||||
locations (`~/Library/Frameworks/`, `/Library/Frameworks/`, and
|
||||
`/Network/Library/Frameworks/`), or a path to a specific framework bundle
|
||||
(e.g. `./data/frameworks/SDL2.framework`). Note that this setting just makes
|
||||
`cargo-bundle` copy the specified frameworks into the OS X app bundle (under
|
||||
`tauri-bundler` copy the specified frameworks into the OS X app bundle (under
|
||||
`Foobar.app/Contents/Frameworks/`); you are still responsible for (1)
|
||||
arranging for the compiled binary to link against those frameworks (e.g. by
|
||||
emitting lines like `cargo:rustc-link-lib=framework=SDL2` from your
|
||||
`build.rs` script), and (2) embedding the correct rpath in your binary
|
||||
(e.g. by running `install_name_tool -add_rpath
|
||||
"@executable_path/../Frameworks" path/to/binary` after compiling).
|
||||
* `osx_minimum_system_version`: A version string indicating the minimum Mac OS
|
||||
* `minimum_system_version`: A version string indicating the minimum Mac OS
|
||||
X version that the bundled app supports (e.g. `"10.11"`). If you are using
|
||||
this config field, you may also want have your `build.rs` script emit
|
||||
`cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=10.11` (or whatever version number
|
||||
you want) to ensure that the compiled binary has the same minimum version.
|
||||
* `license`: Path to the license file for the DMG bundle.
|
||||
* `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.
|
||||
* `use_bootstrapper`: Enables the bootstrapper script, which allows access to the environment variables.
|
||||
|
||||
### Example `Cargo.toml`:
|
||||
### Example `tauri.conf.json`:
|
||||
|
||||
```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"]
|
||||
```json
|
||||
{
|
||||
"package": {
|
||||
"productName": "Your Awesome App",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"tauri": {
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"identifier": "com.my.app",
|
||||
"shortDescription": "",
|
||||
"longDescription": "",
|
||||
"copyright": "Copyright (c) You 2021. All rights reserved.",
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
],
|
||||
"resources": ["./assets/**/*.png"],
|
||||
"deb": {
|
||||
"depends": ["debian-dependency1", "debian-dependency2"],
|
||||
"useBootstrapper": true
|
||||
},
|
||||
"macOS": {
|
||||
"frameworks": [],
|
||||
"minimumSystemVersion": "10.11",
|
||||
"license": "./LICENSE",
|
||||
"useBootstrapper": true
|
||||
},
|
||||
"externalBin": ["./sidecar-app"]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
`cargo-tauri-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
|
||||
(c) 2017 - present, George Burton, Lucas Fernandes Gonçalves Nogueira, Daniel Thompson-Yvetot, Razvan Stoenescu
|
||||
(c) 2017 - present, George Burton, Tauri-Apps Organization
|
||||
|
||||
This program is licensed either under the terms of the
|
||||
[Apache Software License](http://www.apache.org/licenses/LICENSE-2.0), or the
|
@ -4,9 +4,9 @@ mod common;
|
||||
mod deb_bundle;
|
||||
mod dmg_bundle;
|
||||
mod ios_bundle;
|
||||
mod macos_bundle;
|
||||
#[cfg(target_os = "windows")]
|
||||
mod msi_bundle;
|
||||
mod osx_bundle;
|
||||
mod path_utils;
|
||||
mod platform;
|
||||
mod rpm_bundle;
|
||||
@ -18,7 +18,8 @@ pub use self::{
|
||||
category::AppCategory,
|
||||
common::{print_error, print_info},
|
||||
settings::{
|
||||
BundleBinary, BundleSettings, PackageSettings, PackageType, Settings, SettingsBuilder,
|
||||
BundleBinary, BundleSettings, DebianSettings, MacOSSettings, PackageSettings, PackageType,
|
||||
Settings, SettingsBuilder,
|
||||
},
|
||||
};
|
||||
use common::print_finished;
|
||||
@ -32,11 +33,11 @@ pub fn bundle_project(settings: Settings) -> crate::Result<Vec<PathBuf>> {
|
||||
let package_types = settings.package_types()?;
|
||||
for package_type in &package_types {
|
||||
let mut bundle_paths = match package_type {
|
||||
PackageType::OsxBundle => {
|
||||
PackageType::MacOSBundle => {
|
||||
if package_types.clone().iter().any(|&t| t == PackageType::Dmg) {
|
||||
vec![]
|
||||
} else {
|
||||
osx_bundle::bundle_project(&settings)?
|
||||
macos_bundle::bundle_project(&settings)?
|
||||
}
|
||||
}
|
||||
PackageType::IosBundle => ios_bundle::bundle_project(&settings)?,
|
||||
|
@ -2,7 +2,7 @@ use std::{fmt, str::FromStr};
|
||||
|
||||
const CONFIDENCE_THRESHOLD: f64 = 0.8;
|
||||
|
||||
const OSX_APP_CATEGORY_PREFIX: &str = "public.app-category.";
|
||||
const MACOS_APP_CATEGORY_PREFIX: &str = "public.app-category.";
|
||||
|
||||
// TODO: RIght now, these categories correspond to LSApplicationCategoryType
|
||||
// values for OS X. There are also some additional GNOME registered categories
|
||||
@ -61,8 +61,11 @@ impl FromStr for AppCategory {
|
||||
fn from_str(input: &str) -> Result<AppCategory, Self::Err> {
|
||||
// Canonicalize input:
|
||||
let mut input = input.to_ascii_lowercase();
|
||||
if input.starts_with(OSX_APP_CATEGORY_PREFIX) {
|
||||
input = input.split_at(OSX_APP_CATEGORY_PREFIX.len()).1.to_string();
|
||||
if input.starts_with(MACOS_APP_CATEGORY_PREFIX) {
|
||||
input = input
|
||||
.split_at(MACOS_APP_CATEGORY_PREFIX.len())
|
||||
.1
|
||||
.to_string();
|
||||
}
|
||||
input = input.replace(" ", "");
|
||||
input = input.replace("-", "");
|
||||
@ -181,7 +184,7 @@ impl AppCategory {
|
||||
|
||||
/// Map an AppCategory to the closest LSApplicationCategoryType value that
|
||||
/// matches that category.
|
||||
pub fn osx_application_category_type(self) -> &'static str {
|
||||
pub fn macos_application_category_type(self) -> &'static str {
|
||||
match &self {
|
||||
AppCategory::Business => "public.app-category.business",
|
||||
AppCategory::DeveloperTool => "public.app-category.developer-tools",
|
||||
@ -454,7 +457,7 @@ mod tests {
|
||||
// macOS app bundle LSApplicationCategoryType.
|
||||
for &value in values.iter() {
|
||||
let category = AppCategory::from_str(value).expect(value);
|
||||
assert_eq!(category.osx_application_category_type(), value);
|
||||
assert_eq!(category.macos_application_category_type(), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ pub fn generate_data(settings: &Settings, package_dir: &Path) -> crate::Result<P
|
||||
generate_icon_files(settings, &data_dir).with_context(|| "Failed to create icon files")?;
|
||||
generate_desktop_file(settings, &data_dir).with_context(|| "Failed to create desktop file")?;
|
||||
|
||||
let use_bootstrapper = settings.debian_use_bootstrapper();
|
||||
let use_bootstrapper = settings.deb().use_bootstrapper.unwrap_or_default();
|
||||
if use_bootstrapper {
|
||||
generate_bootstrap_file(settings, &data_dir)
|
||||
.with_context(|| "Failed to generate bootstrap file")?;
|
||||
@ -196,7 +196,7 @@ fn generate_desktop_file(settings: &Settings, data_dir: &Path) -> crate::Result<
|
||||
if !settings.short_description().is_empty() {
|
||||
writeln!(file, "Comment={}", settings.short_description())?;
|
||||
}
|
||||
let use_bootstrapper = settings.debian_use_bootstrapper();
|
||||
let use_bootstrapper = settings.deb().use_bootstrapper.unwrap_or_default();
|
||||
writeln!(
|
||||
file,
|
||||
"Exec={}",
|
||||
@ -239,7 +239,7 @@ fn generate_control_file(
|
||||
if !settings.homepage_url().is_empty() {
|
||||
writeln!(&mut file, "Homepage: {}", settings.homepage_url())?;
|
||||
}
|
||||
let dependencies = settings.debian_dependencies();
|
||||
let dependencies = settings.deb().depends.as_ref().cloned().unwrap_or_default();
|
||||
if !dependencies.is_empty() {
|
||||
writeln!(&mut file, "Depends: {}", dependencies.join(", "))?;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use super::{common, osx_bundle};
|
||||
use super::{common, macos_bundle};
|
||||
use crate::Settings;
|
||||
|
||||
use anyhow::Context;
|
||||
@ -14,7 +14,7 @@ use std::{
|
||||
/// Returns a vector of PathBuf that shows where the DMG was created.
|
||||
pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
||||
// generate the .app bundle
|
||||
osx_bundle::bundle_project(settings)?;
|
||||
macos_bundle::bundle_project(settings)?;
|
||||
|
||||
// get the target path
|
||||
let output_path = settings.project_out_directory().join("bundle/dmg");
|
||||
@ -31,7 +31,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
||||
let dmg_path = output_path.join(&dmg_name);
|
||||
|
||||
let product_name = &format!("{}.app", &package_base_name);
|
||||
let bundle_dir = settings.project_out_directory().join("bundle/osx");
|
||||
let bundle_dir = settings.project_out_directory().join("bundle/macos");
|
||||
let bundle_path = bundle_dir.join(&product_name.clone());
|
||||
|
||||
let support_directory_path = output_path.join("support");
|
||||
@ -96,7 +96,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
||||
&product_name,
|
||||
];
|
||||
|
||||
if let Some(license_path) = settings.osx_license() {
|
||||
if let Some(license_path) = &settings.macos().license {
|
||||
args.push("--eula");
|
||||
args.push(license_path);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// An OSX package is laid out like:
|
||||
// A macOS application bundle package is laid out like:
|
||||
//
|
||||
// foobar.app # Actually a directory
|
||||
// Contents # A further subdirectory
|
||||
@ -48,7 +48,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
||||
common::print_bundling(&app_product_name)?;
|
||||
let app_bundle_path = settings
|
||||
.project_out_directory()
|
||||
.join("bundle/osx")
|
||||
.join("bundle/macos")
|
||||
.join(&app_product_name);
|
||||
if app_bundle_path.exists() {
|
||||
fs::remove_dir_all(&app_bundle_path)
|
||||
@ -82,10 +82,10 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
||||
|
||||
copy_binaries_to_bundle(&bundle_directory, settings)?;
|
||||
|
||||
let use_bootstrapper = settings.osx_use_bootstrapper();
|
||||
let use_bootstrapper = settings.macos().use_bootstrapper.unwrap_or_default();
|
||||
if use_bootstrapper {
|
||||
create_bootstrapper(&bundle_directory, settings)
|
||||
.with_context(|| "Failed to create OSX bootstrapper")?;
|
||||
.with_context(|| "Failed to create macOS bootstrapper")?;
|
||||
}
|
||||
Ok(vec![app_bundle_path])
|
||||
}
|
||||
@ -162,7 +162,7 @@ fn create_info_plist(
|
||||
) -> crate::Result<()> {
|
||||
let build_number = chrono::Utc::now().format("%Y%m%d.%H%M%S");
|
||||
let file = &mut common::create_file(&bundle_dir.join("Info.plist"))?;
|
||||
let use_bootstrapper = settings.osx_use_bootstrapper();
|
||||
let use_bootstrapper = settings.macos().use_bootstrapper.unwrap_or_default();
|
||||
write!(
|
||||
file,
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
|
||||
@ -232,10 +232,10 @@ fn create_info_plist(
|
||||
file,
|
||||
" <key>LSApplicationCategoryType</key>\n \
|
||||
<string>{}</string>\n",
|
||||
category.osx_application_category_type()
|
||||
category.macos_application_category_type()
|
||||
)?;
|
||||
}
|
||||
if let Some(version) = settings.osx_minimum_system_version() {
|
||||
if let Some(version) = &settings.macos().minimum_system_version {
|
||||
write!(
|
||||
file,
|
||||
" <key>LSMinimumSystemVersion</key>\n \
|
||||
@ -254,7 +254,7 @@ fn create_info_plist(
|
||||
)?;
|
||||
}
|
||||
|
||||
if let Some(exception_domain) = settings.exception_domain() {
|
||||
if let Some(exception_domain) = &settings.macos().exception_domain {
|
||||
write!(
|
||||
file,
|
||||
" <key>NSAppTransportSecurity</key>\n \
|
||||
@ -291,9 +291,14 @@ fn copy_framework_from(dest_dir: &Path, framework: &str, src_dir: &Path) -> crat
|
||||
}
|
||||
}
|
||||
|
||||
// Copies the OSX bundle frameworks to the .app
|
||||
// Copies the macOS application bundle frameworks to the .app
|
||||
fn copy_frameworks_to_bundle(bundle_directory: &Path, settings: &Settings) -> crate::Result<()> {
|
||||
let frameworks = settings.osx_frameworks();
|
||||
let frameworks = settings
|
||||
.macos()
|
||||
.frameworks
|
||||
.as_ref()
|
||||
.cloned()
|
||||
.unwrap_or_default();
|
||||
if frameworks.is_empty() {
|
||||
return Ok(());
|
||||
}
|
@ -11,8 +11,8 @@ use std::{
|
||||
/// The type of the package we're bundling.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum PackageType {
|
||||
/// The macOS bundle (.app).
|
||||
OsxBundle,
|
||||
/// The macOS application bundle (.app).
|
||||
MacOSBundle,
|
||||
/// The iOS app bundle.
|
||||
IosBundle,
|
||||
/// The Windows bundle (.msi).
|
||||
@ -30,7 +30,7 @@ pub enum PackageType {
|
||||
|
||||
impl PackageType {
|
||||
/// Maps a short name to a PackageType.
|
||||
/// Possible values are "deb", "ios", "msi", "osx", "rpm", "appimage", "dmg".
|
||||
/// Possible values are "deb", "ios", "msi", "app", "rpm", "appimage", "dmg".
|
||||
pub fn from_short_name(name: &str) -> Option<PackageType> {
|
||||
// Other types we may eventually want to support: apk.
|
||||
match name {
|
||||
@ -38,7 +38,7 @@ impl PackageType {
|
||||
"ios" => Some(PackageType::IosBundle),
|
||||
#[cfg(target_os = "windows")]
|
||||
"msi" => Some(PackageType::WindowsMsi),
|
||||
"osx" => Some(PackageType::OsxBundle),
|
||||
"app" => Some(PackageType::MacOSBundle),
|
||||
"rpm" => Some(PackageType::Rpm),
|
||||
"appimage" => Some(PackageType::AppImage),
|
||||
"dmg" => Some(PackageType::Dmg),
|
||||
@ -54,7 +54,7 @@ impl PackageType {
|
||||
PackageType::IosBundle => "ios",
|
||||
#[cfg(target_os = "windows")]
|
||||
PackageType::WindowsMsi => "msi",
|
||||
PackageType::OsxBundle => "osx",
|
||||
PackageType::MacOSBundle => "app",
|
||||
PackageType::Rpm => "rpm",
|
||||
PackageType::AppImage => "appimage",
|
||||
PackageType::Dmg => "dmg",
|
||||
@ -72,7 +72,7 @@ const ALL_PACKAGE_TYPES: &[PackageType] = &[
|
||||
PackageType::IosBundle,
|
||||
#[cfg(target_os = "windows")]
|
||||
PackageType::WindowsMsi,
|
||||
PackageType::OsxBundle,
|
||||
PackageType::MacOSBundle,
|
||||
PackageType::Rpm,
|
||||
PackageType::Dmg,
|
||||
PackageType::AppImage,
|
||||
@ -95,6 +95,52 @@ pub struct PackageSettings {
|
||||
pub default_run: Option<String>,
|
||||
}
|
||||
|
||||
/// The Linux debian bundle settings.
|
||||
#[derive(Clone, Debug, Deserialize, Default)]
|
||||
pub struct DebianSettings {
|
||||
// OS-specific settings:
|
||||
/// the list of debian dependencies.
|
||||
pub depends: Option<Vec<String>>,
|
||||
/// whether we should use the bootstrap script on debian or not.
|
||||
///
|
||||
/// this script goal is to allow your app to access environment variables e.g $PATH.
|
||||
///
|
||||
/// without it, you can't run some applications installed by the user.
|
||||
pub use_bootstrapper: Option<bool>,
|
||||
}
|
||||
|
||||
/// The macOS bundle settings.
|
||||
#[derive(Clone, Debug, Deserialize, Default)]
|
||||
pub struct MacOSSettings {
|
||||
/// MacOS frameworks that need to be bundled with the app.
|
||||
///
|
||||
/// Each string can either be the name of a framework (without the `.framework` extension, e.g. `"SDL2"`),
|
||||
/// in which case we will search for that framework in the standard install locations (`~/Library/Frameworks/`, `/Library/Frameworks/`, and `/Network/Library/Frameworks/`),
|
||||
/// or a path to a specific framework bundle (e.g. `./data/frameworks/SDL2.framework`). Note that this setting just makes tauri-bundler copy the specified frameworks into the OS X app bundle
|
||||
/// (under `Foobar.app/Contents/Frameworks/`); you are still responsible for:
|
||||
///
|
||||
/// - arranging for the compiled binary to link against those frameworks (e.g. by emitting lines like `cargo:rustc-link-lib=framework=SDL2` from your `build.rs` script)
|
||||
///
|
||||
/// - embedding the correct rpath in your binary (e.g. by running `install_name_tool -add_rpath "@executable_path/../Frameworks" path/to/binary` after compiling)
|
||||
pub frameworks: Option<Vec<String>>,
|
||||
/// A version string indicating the minimum MacOS version that the bundled app supports (e.g. `"10.11"`).
|
||||
/// If you are using this config field, you may also want have your `build.rs` script emit `cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=10.11`.
|
||||
pub minimum_system_version: Option<String>,
|
||||
/// The path to the LICENSE file for macOS apps.
|
||||
/// Currently only used by the dmg bundle.
|
||||
pub license: Option<String>,
|
||||
/// whether we should use the bootstrap script on macOS .app or not.
|
||||
///
|
||||
/// this script goal is to allow your app to access environment variables e.g $PATH.
|
||||
///
|
||||
/// without it, you can't run some applications installed by the user.
|
||||
pub use_bootstrapper: Option<bool>,
|
||||
/// The exception domain to use on the macOS .app bundle.
|
||||
///
|
||||
/// This allows communication to the outside world e.g. a web server you're shipping.
|
||||
pub exception_domain: Option<String>,
|
||||
}
|
||||
|
||||
/// The bundle settings of the BuildArtifact we're bundling.
|
||||
#[derive(Clone, Debug, Deserialize, Default)]
|
||||
pub struct BundleSettings {
|
||||
@ -116,45 +162,9 @@ pub struct BundleSettings {
|
||||
pub short_description: Option<String>,
|
||||
/// the app's long description.
|
||||
pub long_description: Option<String>,
|
||||
/// the app's script to run when unpackaging the bundle.
|
||||
pub script: Option<PathBuf>,
|
||||
// OS-specific settings:
|
||||
/// the list of debian dependencies.
|
||||
pub deb_depends: Option<Vec<String>>,
|
||||
/// whether we should use the bootstrap script on debian or not.
|
||||
///
|
||||
/// this script goal is to allow your app to access environment variables e.g $PATH.
|
||||
///
|
||||
/// without it, you can't run some applications installed by the user.
|
||||
pub deb_use_bootstrapper: Option<bool>,
|
||||
/// Mac OS X frameworks that need to be bundled with the app.
|
||||
///
|
||||
/// Each string can either be the name of a framework (without the `.framework` extension, e.g. `"SDL2"`),
|
||||
/// in which case we will search for that framework in the standard install locations (`~/Library/Frameworks/`, `/Library/Frameworks/`, and `/Network/Library/Frameworks/`),
|
||||
/// or a path to a specific framework bundle (e.g. `./data/frameworks/SDL2.framework`). Note that this setting just makes tauri-bundler copy the specified frameworks into the OS X app bundle
|
||||
/// (under `Foobar.app/Contents/Frameworks/`); you are still responsible for:
|
||||
///
|
||||
/// - arranging for the compiled binary to link against those frameworks (e.g. by emitting lines like `cargo:rustc-link-lib=framework=SDL2` from your `build.rs` script)
|
||||
///
|
||||
/// - embedding the correct rpath in your binary (e.g. by running `install_name_tool -add_rpath "@executable_path/../Frameworks" path/to/binary` after compiling)
|
||||
pub osx_frameworks: Option<Vec<String>>,
|
||||
/// A version string indicating the minimum Mac OS X version that the bundled app supports (e.g. `"10.11"`).
|
||||
/// If you are using this config field, you may also want have your `build.rs` script emit `cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=10.11`.
|
||||
pub osx_minimum_system_version: Option<String>,
|
||||
/// The path to the LICENSE file for macOS apps.
|
||||
/// Currently only used by the dmg bundle.
|
||||
pub osx_license: Option<String>,
|
||||
/// whether we should use the bootstrap script on macOS .app or not.
|
||||
///
|
||||
/// this script goal is to allow your app to access environment variables e.g $PATH.
|
||||
///
|
||||
/// without it, you can't run some applications installed by the user.
|
||||
pub osx_use_bootstrapper: Option<bool>,
|
||||
// Bundles for other binaries/examples:
|
||||
// Bundles for other binaries:
|
||||
/// Configuration map for the possible [bin] apps to bundle.
|
||||
pub bin: Option<HashMap<String, BundleSettings>>,
|
||||
/// Configuration map for the possible example apps to bundle.
|
||||
pub example: Option<HashMap<String, BundleSettings>>,
|
||||
/// External binaries to add to the bundle.
|
||||
///
|
||||
/// Note that each binary name will have the target platform's target triple appended,
|
||||
@ -164,10 +174,10 @@ pub struct BundleSettings {
|
||||
///
|
||||
/// The possible target triples can be seen by running `$ rustup target list`.
|
||||
pub external_bin: Option<Vec<String>>,
|
||||
/// The exception domain to use on the macOS .app bundle.
|
||||
///
|
||||
/// This allows communication to the outside world e.g. a web server you're shipping.
|
||||
pub exception_domain: Option<String>,
|
||||
/// Debian-specific settings.
|
||||
pub deb: DebianSettings,
|
||||
/// MacOS-specific settings.
|
||||
pub macos: MacOSSettings,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
@ -349,7 +359,7 @@ impl Settings {
|
||||
pub fn package_types(&self) -> crate::Result<Vec<PackageType>> {
|
||||
let target_os = std::env::consts::OS;
|
||||
let platform_types = match target_os {
|
||||
"macos" => vec![PackageType::OsxBundle, PackageType::Dmg],
|
||||
"macos" => vec![PackageType::MacOSBundle, PackageType::Dmg],
|
||||
"ios" => vec![PackageType::IosBundle],
|
||||
"linux" => vec![PackageType::Deb, PackageType::AppImage],
|
||||
#[cfg(target_os = "windows")]
|
||||
@ -420,11 +430,6 @@ impl Settings {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the OSX exception domain.
|
||||
pub fn exception_domain(&self) -> Option<&String> {
|
||||
self.bundle_settings.exception_domain.as_ref()
|
||||
}
|
||||
|
||||
/// Copies external binaries to a path.
|
||||
pub fn copy_binaries(&self, path: &Path) -> crate::Result<()> {
|
||||
for src in self.external_binaries() {
|
||||
@ -501,40 +506,14 @@ impl Settings {
|
||||
self.bundle_settings.long_description.as_deref()
|
||||
}
|
||||
|
||||
/// Returns the dependencies of the debian bundle.
|
||||
pub fn debian_dependencies(&self) -> &[String] {
|
||||
match self.bundle_settings.deb_depends {
|
||||
Some(ref dependencies) => dependencies.as_slice(),
|
||||
None => &[],
|
||||
}
|
||||
/// Returns the debian settings.
|
||||
pub fn deb(&self) -> &DebianSettings {
|
||||
&self.bundle_settings.deb
|
||||
}
|
||||
|
||||
/// Returns whether the debian bundle should use the bootstrap script or not.
|
||||
pub fn debian_use_bootstrapper(&self) -> bool {
|
||||
self.bundle_settings.deb_use_bootstrapper.unwrap_or(false)
|
||||
}
|
||||
|
||||
/// Returns the frameworks to bundle with the macOS .app
|
||||
pub fn osx_frameworks(&self) -> &[String] {
|
||||
match self.bundle_settings.osx_frameworks {
|
||||
Some(ref frameworks) => frameworks.as_slice(),
|
||||
None => &[],
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the minimum system version of the macOS bundle.
|
||||
pub fn osx_minimum_system_version(&self) -> Option<&str> {
|
||||
self.bundle_settings.osx_minimum_system_version.as_deref()
|
||||
}
|
||||
|
||||
/// Returns the path to the DMG bundle license.
|
||||
pub fn osx_license(&self) -> Option<&str> {
|
||||
self.bundle_settings.osx_license.as_deref()
|
||||
}
|
||||
|
||||
/// Returns whether the macOS .app bundle should use the bootstrap script or not.
|
||||
pub fn osx_use_bootstrapper(&self) -> bool {
|
||||
self.bundle_settings.osx_use_bootstrapper.unwrap_or(false)
|
||||
/// Returns the MacOS settings.
|
||||
pub fn macos(&self) -> &MacOSSettings {
|
||||
&self.bundle_settings.macos
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ describe('[CLI] tauri.js template', () => {
|
||||
config: {
|
||||
tauri: {
|
||||
bundle: {
|
||||
targets: ['deb', 'osx', 'msi', 'appimage'] // we can't bundle dmg on CI so we remove it here
|
||||
targets: ['deb', 'app', 'msi', 'appimage'] // we can't bundle dmg on CI so we remove it here
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -27,7 +27,7 @@
|
||||
"depends": [],
|
||||
"useBootstrapper": false
|
||||
},
|
||||
"osx": {
|
||||
"macOS": {
|
||||
"frameworks": [],
|
||||
"minimumSystemVersion": "",
|
||||
"useBootstrapper": false,
|
||||
|
Loading…
Reference in New Issue
Block a user