mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-01-31 00:35:19 +01:00
refactor(core): use ayatana appindicator by default, keep option to use gtk (#3916)
This commit is contained in:
committed by
GitHub
parent
c4320ed1bc
commit
f2a30d8bc5
5
.changes/ayatana-tray.md
Normal file
5
.changes/ayatana-tray.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri": patch
|
||||
---
|
||||
|
||||
**Breaking change:** Use ayatana-appindicator for Linux system tray by default. Use the `gtk-tray` Cargo feature to use `libappindicator` instead.
|
||||
@@ -8,7 +8,7 @@
|
||||
"getPublishedVersion": "cargo search ${ pkgFile.pkg.package.name } --limit 1 | sed -nE \"s/^[^\\\"]*\\\"//; s/\\\".*//1p\"",
|
||||
"prepublish": [
|
||||
"sudo apt-get update",
|
||||
"sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf",
|
||||
"sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf",
|
||||
"cargo install cargo-audit --features=fix",
|
||||
{
|
||||
"command": "cargo generate-lockfile",
|
||||
|
||||
6
.changes/dev-keep-default-features.md
Normal file
6
.changes/dev-keep-default-features.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"cli.rs": patch
|
||||
"cli.js": patch
|
||||
---
|
||||
|
||||
**Breaking change:** Enable default Cargo features except `tauri/custom-protocol` on the dev command.
|
||||
5
.changes/tauri-build-resources-linux.md
Normal file
5
.changes/tauri-build-resources-linux.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri-build": patch
|
||||
---
|
||||
|
||||
Copy system tray icon resource to the target directory on Linux.
|
||||
2
.github/workflows/artifacts-updater.yml
vendored
2
.github/workflows/artifacts-updater.yml
vendored
@@ -41,7 +41,7 @@ jobs:
|
||||
if: matrix.platform == 'ubuntu-latest'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||
|
||||
- name: Get current date
|
||||
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
|
||||
|
||||
2
.github/workflows/bench.yml
vendored
2
.github/workflows/bench.yml
vendored
@@ -43,7 +43,7 @@ jobs:
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf xvfb
|
||||
sudo apt-get install -y webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf xvfb
|
||||
wget https://github.com/sharkdp/hyperfine/releases/download/v1.11.0/hyperfine_1.11.0_amd64.deb
|
||||
sudo dpkg -i hyperfine_1.11.0_amd64.deb
|
||||
pip install memory_profiler
|
||||
|
||||
7
.github/workflows/lint-fmt-core.yml
vendored
7
.github/workflows/lint-fmt-core.yml
vendored
@@ -49,7 +49,10 @@ jobs:
|
||||
args: '--features compression,wry,isolation,custom-protocol,api-all,cli,updater,system-tray',
|
||||
key: 'all'
|
||||
}
|
||||
- { args: '--no-default-features', key: 'no-default' }
|
||||
- {
|
||||
args: '--no-default-features --features ayatana-tray',
|
||||
key: 'no-default'
|
||||
}
|
||||
- { args: '--features custom-protocol', key: 'custom-protocol' }
|
||||
- { args: '--features api-all', key: 'api-all' }
|
||||
|
||||
@@ -58,7 +61,7 @@ jobs:
|
||||
- name: install webkit2gtk
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
|
||||
4
.github/workflows/publish-cli.yml
vendored
4
.github/workflows/publish-cli.yml
vendored
@@ -255,7 +255,7 @@ jobs:
|
||||
- name: install system dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||
- name: Test bindings
|
||||
run: yarn test
|
||||
test-linux-x64-musl-binding:
|
||||
@@ -349,7 +349,7 @@ jobs:
|
||||
set -e
|
||||
export PATH=/usr/local/cargo/bin/:/usr/local/fnm:$PATH
|
||||
apt-get update
|
||||
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install --no-install-recommends -y unzip libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
|
||||
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install --no-install-recommends -y unzip libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||
bash
|
||||
curl https://sh.rustup.rs -sSf | bash -s -- -y
|
||||
curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir "/usr/local/fnm" --skip-shell
|
||||
|
||||
2
.github/workflows/test-cli.yml
vendored
2
.github/workflows/test-cli.yml
vendored
@@ -106,7 +106,7 @@ jobs:
|
||||
if: matrix.platform == 'ubuntu-latest'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||
|
||||
- name: Get current date
|
||||
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
|
||||
|
||||
2
.github/workflows/test-core.yml
vendored
2
.github/workflows/test-core.yml
vendored
@@ -40,7 +40,7 @@ jobs:
|
||||
if: matrix.platform == 'ubuntu-latest'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||
|
||||
- name: Get current date
|
||||
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
|
||||
|
||||
32
.github/workflows/udeps.yml
vendored
32
.github/workflows/udeps.yml
vendored
@@ -20,6 +20,24 @@ env:
|
||||
jobs:
|
||||
udeps:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
clippy:
|
||||
- {
|
||||
path: './core/tauri/Cargo.toml',
|
||||
args: '--features compression,wry,isolation,custom-protocol,api-all,cli,updater,system-tray'
|
||||
}
|
||||
- { path: './core/tauri-build/Cargo.toml', args: '--all-features' }
|
||||
- { path: './core/tauri-codegen/Cargo.toml', args: '--all-features' }
|
||||
- { path: './core/tauri-macros/Cargo.toml', args: '--all-features' }
|
||||
- { path: './core/tauri-runtime/Cargo.toml', args: '--all-features' }
|
||||
- {
|
||||
path: './core/tauri-runtime-wry/Cargo.toml',
|
||||
args: '--features devtools,system-tray,macos-private-api,objc-exception,ayatana-tray'
|
||||
}
|
||||
- { path: './core/tauri-utils/Cargo.toml', args: '--all-features' }
|
||||
- { path: './tooling/bundler/Cargo.toml', args: '--all-features' }
|
||||
- { path: './tooling/cli/Cargo.toml', args: '--all-features' }
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
@@ -101,19 +119,9 @@ jobs:
|
||||
- name: Install required packages
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
|
||||
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libayatana-appindicator3-dev librsvg2-dev patchelf
|
||||
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: udeps
|
||||
args: --all-targets --all-features
|
||||
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: udeps
|
||||
args: --manifest-path ./tooling/bundler/Cargo.toml --all-targets --all-features
|
||||
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: udeps
|
||||
args: --manifest-path ./tooling/cli/Cargo.toml --all-targets --all-features
|
||||
args: --manifest-path ${{ matrix.clippy.path }} --all-targets ${{ matrix.clippy.args }}
|
||||
|
||||
@@ -236,9 +236,14 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
|
||||
target_dir,
|
||||
)?;
|
||||
}
|
||||
if let Some(paths) = config.tauri.bundle.resources {
|
||||
copy_resources(ResourcePaths::new(paths.as_slice(), true), target_dir)?;
|
||||
|
||||
#[allow(unused_mut)]
|
||||
let mut resources = config.tauri.bundle.resources.unwrap_or_default();
|
||||
#[cfg(target_os = "linux")]
|
||||
if let Some(tray) = config.tauri.system_tray {
|
||||
resources.push(tray.icon_path.display().to_string());
|
||||
}
|
||||
copy_resources(ResourcePaths::new(resources.as_slice(), true), target_dir)?;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
|
||||
@@ -32,10 +32,12 @@ gtk = { version = "0.15", features = [ "v3_20" ] }
|
||||
[features]
|
||||
dox = [ "wry/dox" ]
|
||||
devtools = [ "wry/devtools", "tauri-runtime/devtools" ]
|
||||
system-tray = [ "wry/tray", "tauri-runtime/system-tray" ]
|
||||
system-tray = [ "tauri-runtime/system-tray", "wry/tray" ]
|
||||
macos-private-api = [
|
||||
"wry/fullscreen",
|
||||
"wry/transparent",
|
||||
"tauri-runtime/macos-private-api"
|
||||
]
|
||||
objc-exception = [ "wry/objc-exception" ]
|
||||
gtk-tray = [ "wry/gtk-tray" ]
|
||||
ayatana-tray = [ "wry/ayatana-tray" ]
|
||||
|
||||
@@ -26,7 +26,7 @@ schemars = { version = "0.8", features = [ "url" ], optional = true }
|
||||
serde_with = "1.12"
|
||||
aes-gcm = { version = "0.9", optional = true }
|
||||
getrandom = { version = "0.2", optional = true, features = [ "std" ] }
|
||||
serialize-to-javascript = "=0.1.1"
|
||||
serialize-to-javascript = { version = "=0.1.1", optional = true }
|
||||
ctor = "0.1"
|
||||
json5 = { version = "0.4", optional = true }
|
||||
json-patch = "0.2"
|
||||
@@ -40,7 +40,7 @@ heck = "0.4"
|
||||
build = [ "proc-macro2", "quote" ]
|
||||
compression = [ "brotli" ]
|
||||
schema = [ "schemars" ]
|
||||
isolation = [ "aes-gcm", "getrandom" ]
|
||||
isolation = [ "aes-gcm", "getrandom", "serialize-to-javascript" ]
|
||||
process-relaunch-dangerous-allow-symlink-macos = [ ]
|
||||
config-json5 = [ "json5" ]
|
||||
resources = [ "glob", "walkdir" ]
|
||||
|
||||
@@ -118,10 +118,12 @@ tokio-test = "0.4.2"
|
||||
tokio = { version = "1.16", features = [ "full" ] }
|
||||
|
||||
[features]
|
||||
default = [ "wry", "compression", "objc-exception" ]
|
||||
default = [ "wry", "compression", "objc-exception", "ayatana-tray" ]
|
||||
compression = [ "tauri-macros/compression", "tauri-utils/compression" ]
|
||||
wry = [ "tauri-runtime-wry" ]
|
||||
objc-exception = [ "tauri-runtime-wry/objc-exception" ]
|
||||
ayatana-tray = [ "tauri-runtime-wry/ayatana-tray" ]
|
||||
gtk-tray = [ "tauri-runtime-wry/gtk-tray" ]
|
||||
isolation = [ "tauri-utils/isolation", "tauri-macros/isolation" ]
|
||||
custom-protocol = [ "tauri-macros/custom-protocol" ]
|
||||
updater = [
|
||||
|
||||
@@ -29,7 +29,7 @@ fn main() {
|
||||
window_create: { any(window_all, feature = "window-create") },
|
||||
window_center: { any(window_all, feature = "window-center") },
|
||||
window_request_user_attention: { any(window_all, feature = "window-request-user-attention") },
|
||||
window_set_resizable: { any(window_all, feature = "window-set-resizable") },
|
||||
window_set_izable: { any(window_all, feature = "window-set-resizable") },
|
||||
window_set_title: { any(window_all, feature = "window-set-title") },
|
||||
window_maximize: { any(window_all, feature = "window-maximize") },
|
||||
window_unmaximize: { any(window_all, feature = "window-unmaximize") },
|
||||
|
||||
@@ -1294,41 +1294,23 @@ impl<R: Runtime> Builder<R> {
|
||||
if let Some(menu) = system_tray.menu() {
|
||||
tray::get_menu_ids(&mut ids, menu);
|
||||
}
|
||||
let mut tray = tray::SystemTray::new();
|
||||
let mut tray = tray::SystemTray::new().with_icon(
|
||||
system_tray
|
||||
.icon
|
||||
.or(system_tray_icon)
|
||||
.expect("tray icon not found; please configure it on tauri.conf.json"),
|
||||
);
|
||||
if let Some(menu) = system_tray.menu {
|
||||
tray = tray.with_menu(menu);
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
let tray_handler = app
|
||||
.runtime
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.system_tray(
|
||||
tray.with_icon(
|
||||
system_tray
|
||||
.icon
|
||||
.or(system_tray_icon)
|
||||
.expect("tray icon not found; please configure it on tauri.conf.json"),
|
||||
),
|
||||
)
|
||||
.expect("failed to run tray");
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
let tray = tray.with_icon_as_template(system_tray_icon_as_template);
|
||||
|
||||
let tray_handler = app
|
||||
.runtime
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.system_tray(
|
||||
tray
|
||||
.with_icon(
|
||||
system_tray
|
||||
.icon
|
||||
.or(system_tray_icon)
|
||||
.expect("tray icon not found; please configure it on tauri.conf.json"),
|
||||
)
|
||||
.with_icon_as_template(system_tray_icon_as_template),
|
||||
)
|
||||
.system_tray(tray)
|
||||
.expect("failed to run tray");
|
||||
|
||||
let tray_handle = tray::SystemTrayHandle {
|
||||
|
||||
@@ -404,7 +404,7 @@
|
||||
//!
|
||||
//! The *Private key* (privkey) is used to sign your update and should NEVER be shared with anyone. Also, if you lost this key, you'll NOT be able to publish a new update to the current user base (if pubkey is set in tauri.conf.json). It's important to save it at a safe place and you can always access it.
|
||||
//!
|
||||
//! To generate your keys you need to use the Tauri cli.
|
||||
//! To generate your keys you need to use the Tauri cli.
|
||||
//!
|
||||
//! ```bash
|
||||
//! # Generate the keys, follow the instructions
|
||||
|
||||
58
examples/api/dist/assets/index.js
vendored
58
examples/api/dist/assets/index.js
vendored
File diff suppressed because one or more lines are too long
20
examples/api/dist/assets/vendor.js
vendored
20
examples/api/dist/assets/vendor.js
vendored
File diff suppressed because one or more lines are too long
21
examples/api/src-tauri/Cargo.lock
generated
21
examples/api/src-tauri/Cargo.lock
generated
@@ -1658,6 +1658,18 @@ dependencies = [
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libayatana-appindicator"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0379d22a323947cb27b4dbe3b14fc1dcde07c9e9c3eca52ddf97ca0819c28cc4"
|
||||
dependencies = [
|
||||
"glib",
|
||||
"gtk",
|
||||
"gtk-sys",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.121"
|
||||
@@ -3106,9 +3118,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tao"
|
||||
version = "0.7.0"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b6a3359088d4c4735a13f933202f4ecd91f5991b41a8eb757f2449c044ce925"
|
||||
checksum = "1fd4af2c14087bc642585cf84e3f122d6d120836e08b813991491cb6d3e1cf63"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cairo-rs",
|
||||
@@ -3129,6 +3141,7 @@ dependencies = [
|
||||
"instant",
|
||||
"lazy_static",
|
||||
"libappindicator",
|
||||
"libayatana-appindicator",
|
||||
"libc",
|
||||
"log",
|
||||
"ndk",
|
||||
@@ -4090,9 +4103,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wry"
|
||||
version = "0.14.0"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6fd09ffc86ecea0a0d5f50cc8e4a8121a1bfc0b0825a160f86ac39e86979344c"
|
||||
checksum = "1f3d0f8b0ab2ab364d3caf29ce6a8101841e42196ad634f9222c4ebed91dd250"
|
||||
dependencies = [
|
||||
"block",
|
||||
"cocoa",
|
||||
|
||||
@@ -12,11 +12,12 @@ tauri-build = { path = "../../../core/tauri-build", features = ["isolation"] }
|
||||
[dependencies]
|
||||
serde_json = "1.0"
|
||||
serde = { version = "1.0", features = [ "derive" ] }
|
||||
tauri = { path = "../../../core/tauri", features = ["api-all", "cli", "icon-ico", "icon-png", "isolation", "macos-private-api", "system-tray", "updater"] }
|
||||
tauri = { path = "../../../core/tauri", default-features = false, features = ["api-all", "cli", "compression", "icon-ico", "icon-png", "isolation", "macos-private-api", "objc-exception", "system-tray", "updater", "wry"] }
|
||||
|
||||
[features]
|
||||
default = [ "custom-protocol" ]
|
||||
default = [ "custom-protocol", "tauri/ayatana-tray" ]
|
||||
custom-protocol = [ "tauri/custom-protocol" ]
|
||||
gtk-tray = [ "tauri/gtk-tray" ]
|
||||
|
||||
# default to small, optimized release binaries
|
||||
[profile.release]
|
||||
|
||||
@@ -161,14 +161,14 @@ fn main() {
|
||||
"icon_1" => app
|
||||
.tray_handle()
|
||||
.set_icon(tauri::TrayIcon::File(PathBuf::from(
|
||||
"../../../.icons/tray_icon_with_transparency.png",
|
||||
"../../.icons/tray_icon_with_transparency.png",
|
||||
)))
|
||||
.unwrap(),
|
||||
#[cfg(target_os = "linux")]
|
||||
"icon_2" => app
|
||||
.tray_handle()
|
||||
.set_icon(tauri::TrayIcon::File(PathBuf::from(
|
||||
"../../../.icons/tray_icon.png",
|
||||
"../../.icons/tray_icon.png",
|
||||
)))
|
||||
.unwrap(),
|
||||
#[cfg(target_os = "windows")]
|
||||
|
||||
7
tooling/cli/Cargo.lock
generated
7
tooling/cli/Cargo.lock
generated
@@ -992,12 +992,6 @@ dependencies = [
|
||||
"itoa 1.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "humansize"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "02296996cb8796d7c6e3bc2d9211b7802812d36999a51bb754123ead7d37d026"
|
||||
|
||||
[[package]]
|
||||
name = "icns"
|
||||
version = "0.3.1"
|
||||
@@ -2728,7 +2722,6 @@ dependencies = [
|
||||
"glob",
|
||||
"handlebars",
|
||||
"heck",
|
||||
"humansize",
|
||||
"ignore",
|
||||
"include_dir",
|
||||
"json-patch",
|
||||
|
||||
@@ -67,9 +67,6 @@ ctrlc = "3.2"
|
||||
[target."cfg(windows)".dependencies]
|
||||
encode_unicode = "0.3"
|
||||
|
||||
[target."cfg(not(windows))".dependencies]
|
||||
humansize = "1.1"
|
||||
|
||||
[target."cfg(target_os = \"linux\")".build-dependencies]
|
||||
heck = "0.4"
|
||||
|
||||
|
||||
@@ -173,6 +173,8 @@ pub fn command(options: Options) -> Result<()> {
|
||||
#[cfg(not(windows))]
|
||||
let bin_path = out_dir.join(&bin_name);
|
||||
|
||||
let no_default_features = args.contains(&"--no-default-features".into());
|
||||
|
||||
if options.target == Some("universal-apple-darwin".into()) {
|
||||
std::fs::create_dir_all(&out_dir).with_context(|| "failed to create project out directory")?;
|
||||
|
||||
@@ -306,9 +308,14 @@ pub fn command(options: Options) -> Result<()> {
|
||||
None
|
||||
};
|
||||
|
||||
let mut enabled_features = features.clone();
|
||||
if !no_default_features {
|
||||
enabled_features.push("default".into());
|
||||
}
|
||||
let settings = crate::interface::get_bundler_settings(
|
||||
app_settings,
|
||||
options.target.clone(),
|
||||
&enabled_features,
|
||||
&manifest,
|
||||
config_,
|
||||
&out_dir,
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::{
|
||||
app_paths::{app_dir, tauri_dir},
|
||||
command_env,
|
||||
config::{get as get_config, reload as reload_config, AppUrl, WindowUrl},
|
||||
manifest::{get_workspace_members, rewrite_manifest},
|
||||
manifest::{get_workspace_members, rewrite_manifest, Manifest},
|
||||
Logger,
|
||||
},
|
||||
CommandExt, Result,
|
||||
@@ -151,17 +151,18 @@ pub fn command(options: Options) -> Result<()> {
|
||||
.or(runner_from_config)
|
||||
.unwrap_or_else(|| "cargo".to_string());
|
||||
|
||||
{
|
||||
let mut manifest = {
|
||||
let (tx, rx) = channel();
|
||||
let mut watcher = watcher(tx, Duration::from_secs(1)).unwrap();
|
||||
watcher.watch(tauri_path.join("Cargo.toml"), RecursiveMode::Recursive)?;
|
||||
rewrite_manifest(config.clone())?;
|
||||
let manifest = rewrite_manifest(config.clone())?;
|
||||
loop {
|
||||
if let Ok(DebouncedEvent::NoticeWrite(_)) = rx.recv() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
manifest
|
||||
};
|
||||
|
||||
let mut cargo_features = config
|
||||
.lock()
|
||||
@@ -238,7 +239,13 @@ pub fn command(options: Options) -> Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
let mut process = start_app(&options, &runner, &cargo_features, child_wait_rx.clone())?;
|
||||
let mut process = start_app(
|
||||
&options,
|
||||
&runner,
|
||||
&manifest,
|
||||
&cargo_features,
|
||||
child_wait_rx.clone(),
|
||||
)?;
|
||||
|
||||
let (tx, rx) = channel();
|
||||
|
||||
@@ -266,7 +273,7 @@ pub fn command(options: Options) -> Result<()> {
|
||||
if let Some(event_path) = event_path {
|
||||
if event_path.file_name() == Some(OsStr::new("tauri.conf.json")) {
|
||||
reload_config(merge_config.as_deref())?;
|
||||
rewrite_manifest(config.clone())?;
|
||||
manifest = rewrite_manifest(config.clone())?;
|
||||
} else {
|
||||
// When tauri.conf.json is changed, rewrite_manifest will be called
|
||||
// which will trigger the watcher again
|
||||
@@ -281,7 +288,13 @@ pub fn command(options: Options) -> Result<()> {
|
||||
break;
|
||||
}
|
||||
}
|
||||
process = start_app(&options, &runner, &cargo_features, child_wait_rx.clone())?;
|
||||
process = start_app(
|
||||
&options,
|
||||
&runner,
|
||||
&manifest,
|
||||
&cargo_features,
|
||||
child_wait_rx.clone(),
|
||||
)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -326,11 +339,33 @@ fn kill_before_dev_process() {
|
||||
fn start_app(
|
||||
options: &Options,
|
||||
runner: &str,
|
||||
manifest: &Manifest,
|
||||
features: &[String],
|
||||
child_wait_rx: Arc<Mutex<Receiver<()>>>,
|
||||
) -> Result<Arc<SharedChild>> {
|
||||
let mut command = Command::new(runner);
|
||||
command.args(&["run", "--no-default-features"]);
|
||||
command.arg("run");
|
||||
|
||||
if !options.args.contains(&"--no-default-features".into()) {
|
||||
let manifest_features = manifest.features();
|
||||
let enable_features: Vec<String> = manifest_features
|
||||
.get("default")
|
||||
.cloned()
|
||||
.unwrap_or_default()
|
||||
.into_iter()
|
||||
.filter(|feature| {
|
||||
if let Some(manifest_feature) = manifest_features.get(feature) {
|
||||
!manifest_feature.contains(&"tauri/custom-protocol".into())
|
||||
} else {
|
||||
feature != "tauri/custom-protocol"
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
command.arg("--no-default-features");
|
||||
if !enable_features.is_empty() {
|
||||
command.args(&["--features", &enable_features.join(",")]);
|
||||
}
|
||||
}
|
||||
|
||||
if options.release_mode {
|
||||
command.args(&["--release"]);
|
||||
|
||||
@@ -11,7 +11,7 @@ use anyhow::Context;
|
||||
use toml_edit::{Array, Document, InlineTable, Item, Table, Value};
|
||||
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
collections::{HashMap, HashSet},
|
||||
fs::File,
|
||||
io::{Read, Write},
|
||||
iter::FromIterator,
|
||||
@@ -20,7 +20,66 @@ use std::{
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Manifest {
|
||||
pub features: HashSet<String>,
|
||||
pub inner: Document,
|
||||
pub tauri_features: HashSet<String>,
|
||||
}
|
||||
|
||||
impl Manifest {
|
||||
pub fn features(&self) -> HashMap<String, Vec<String>> {
|
||||
let mut f = HashMap::new();
|
||||
|
||||
if let Some(features) = self
|
||||
.inner
|
||||
.as_table()
|
||||
.get("features")
|
||||
.and_then(|f| f.as_table())
|
||||
{
|
||||
for (feature, enabled_features) in features.into_iter() {
|
||||
if let Item::Value(Value::Array(enabled_features)) = enabled_features {
|
||||
let mut enabled = Vec::new();
|
||||
for value in enabled_features {
|
||||
if let Value::String(s) = value {
|
||||
enabled.push(s.value().clone());
|
||||
}
|
||||
}
|
||||
f.insert(feature.to_string(), enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
f
|
||||
}
|
||||
|
||||
pub fn all_enabled_features(&self, enabled_features: &[String]) -> Vec<String> {
|
||||
let mut all_enabled_features: Vec<String> = self
|
||||
.tauri_features
|
||||
.iter()
|
||||
.map(|f| format!("tauri/{}", f))
|
||||
.collect();
|
||||
|
||||
let manifest_features = self.features();
|
||||
for f in enabled_features {
|
||||
all_enabled_features.extend(get_enabled_features(&manifest_features, f));
|
||||
}
|
||||
|
||||
all_enabled_features
|
||||
}
|
||||
}
|
||||
|
||||
fn get_enabled_features(list: &HashMap<String, Vec<String>>, feature: &str) -> Vec<String> {
|
||||
let mut f = Vec::new();
|
||||
|
||||
if let Some(enabled_features) = list.get(feature) {
|
||||
for enabled in enabled_features {
|
||||
if list.contains_key(enabled) {
|
||||
f.extend(get_enabled_features(list, enabled));
|
||||
} else {
|
||||
f.push(enabled.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
f
|
||||
}
|
||||
|
||||
fn read_manifest(manifest_path: &Path) -> crate::Result<Document> {
|
||||
@@ -164,11 +223,13 @@ pub fn rewrite_manifest(config: ConfigHandle) -> crate::Result<Manifest> {
|
||||
)?;
|
||||
manifest_file.flush()?;
|
||||
Ok(Manifest {
|
||||
features: tauri_features,
|
||||
inner: manifest,
|
||||
tauri_features,
|
||||
})
|
||||
}
|
||||
Ok(false) => Ok(Manifest {
|
||||
features: tauri_features,
|
||||
inner: manifest,
|
||||
tauri_features,
|
||||
}),
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
|
||||
@@ -9,9 +9,11 @@ use std::path::Path;
|
||||
use crate::helpers::{config::Config, manifest::Manifest};
|
||||
use tauri_bundler::bundle::{PackageType, Settings, SettingsBuilder};
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn get_bundler_settings(
|
||||
app_settings: rust::AppSettings,
|
||||
target: Option<String>,
|
||||
features: &[String],
|
||||
manifest: &Manifest,
|
||||
config: &Config,
|
||||
out_dir: &Path,
|
||||
@@ -20,7 +22,7 @@ pub fn get_bundler_settings(
|
||||
) -> crate::Result<Settings> {
|
||||
let mut settings_builder = SettingsBuilder::new()
|
||||
.package_settings(app_settings.get_package_settings())
|
||||
.bundle_settings(app_settings.get_bundle_settings(config, manifest)?)
|
||||
.bundle_settings(app_settings.get_bundle_settings(config, manifest, features)?)
|
||||
.binaries(app_settings.get_binaries(config)?)
|
||||
.project_out_directory(out_dir);
|
||||
|
||||
|
||||
@@ -177,9 +177,11 @@ impl AppSettings {
|
||||
&self,
|
||||
config: &Config,
|
||||
manifest: &Manifest,
|
||||
features: &[String],
|
||||
) -> crate::Result<BundleSettings> {
|
||||
tauri_config_to_bundle_settings(
|
||||
manifest,
|
||||
features,
|
||||
config.tauri.bundle.clone(),
|
||||
config.tauri.system_tray.clone(),
|
||||
config.tauri.updater.clone(),
|
||||
@@ -369,10 +371,13 @@ pub fn get_workspace_dir(current_dir: &Path) -> PathBuf {
|
||||
#[allow(unused_variables)]
|
||||
fn tauri_config_to_bundle_settings(
|
||||
manifest: &Manifest,
|
||||
features: &[String],
|
||||
config: crate::helpers::config::BundleConfig,
|
||||
system_tray_config: Option<crate::helpers::config::SystemTrayConfig>,
|
||||
updater_config: crate::helpers::config::UpdaterConfig,
|
||||
) -> crate::Result<BundleSettings> {
|
||||
let enabled_features = manifest.all_enabled_features(features);
|
||||
|
||||
#[cfg(windows)]
|
||||
let windows_icon_path = PathBuf::from(
|
||||
config
|
||||
@@ -396,7 +401,11 @@ fn tauri_config_to_bundle_settings(
|
||||
let mut icon_path = system_tray_config.icon_path.clone();
|
||||
icon_path.set_extension("png");
|
||||
resources.push(icon_path.display().to_string());
|
||||
depends.push("libappindicator3-1".to_string());
|
||||
if enabled_features.contains(&"tauri/gtk-tray".into()) {
|
||||
depends.push("libappindicator3-1".into());
|
||||
} else {
|
||||
depends.push("libayatana-appindicator3-1".into());
|
||||
}
|
||||
}
|
||||
|
||||
// provides `libwebkit2gtk-4.0.so.37` and all `4.0` versions have the -37 package name
|
||||
|
||||
Reference in New Issue
Block a user