浏览代码

refactor(core): drop `ayatana-tray` and `gtk-tray` Cargo features (#4247)

Lucas Fernandes Nogueira 3 年之前
父节点
当前提交
6216eb49e7

+ 6 - 0
.changes/remove-tray-features.md

@@ -0,0 +1,6 @@
+---
+"tauri": patch
+"tauri-runtime-wry": patch
+---
+
+**Breaking change**: Removed the `gtk-tray` and `ayatana-tray` Cargo features.

+ 6 - 0
.changes/tauri-tray-env-var.md

@@ -0,0 +1,6 @@
+---
+"cli.rs": patch
+"cli.js": patch
+---
+
+Use the `TAURI_TRAY` environment variable to determine which package should be added to the Debian `depends` section. Possible values are `ayatana` and `gtk`.

+ 1 - 5
.github/workflows/lint-fmt-core.yml

@@ -50,13 +50,9 @@ jobs:
         clippy:
           - { args: '', key: 'empty' }
           - {
-              args: '--features compression,wry,isolation,custom-protocol,api-all,cli,updater,system-tray,ayatana-tray,http-multipart',
+              args: '--features compression,wry,isolation,custom-protocol,api-all,cli,updater,system-tray,http-multipart',
               key: 'all'
             }
-          - {
-              args: '--no-default-features --features ayatana-tray',
-              key: 'no-default'
-            }
           - { args: '--features custom-protocol', key: 'custom-protocol' }
           - { args: '--features api-all', key: 'api-all' }
 

+ 1 - 1
.github/workflows/test-core.yml

@@ -89,4 +89,4 @@ jobs:
         run: |
           cargo test
           cargo test --features api-all
-          cargo test --features compression,wry,isolation,custom-protocol,api-all,cli,updater,system-tray,ayatana-tray,http-multipart
+          cargo test --features compression,wry,isolation,custom-protocol,api-all,cli,updater,system-tray,http-multipart

+ 2 - 2
.github/workflows/udeps.yml

@@ -29,7 +29,7 @@ jobs:
         clippy:
           - {
               path: './core/tauri/Cargo.toml',
-              args: '--features compression,wry,isolation,custom-protocol,api-all,cli,updater,system-tray,ayatana-tray,http-multipart'
+              args: '--features compression,wry,isolation,custom-protocol,api-all,cli,updater,system-tray,http-multipart'
             }
           - { path: './core/tauri-build/Cargo.toml', args: '--all-features' }
           - { path: './core/tauri-codegen/Cargo.toml', args: '--all-features' }
@@ -37,7 +37,7 @@ jobs:
           - { 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'
+              args: '--features devtools,system-tray,macos-private-api,objc-exception'
             }
           - { path: './core/tauri-utils/Cargo.toml', args: '--all-features' }
           - { path: './tooling/bundler/Cargo.toml', args: '--all-features' }

+ 1 - 3
core/tauri-runtime-wry/Cargo.toml

@@ -13,7 +13,7 @@ exclude = [ ".license_template", "CHANGELOG.md", "/target" ]
 readme = "README.md"
 
 [dependencies]
-wry = { version = "0.17.0", default-features = false, features = [ "file-drop", "protocol" ] }
+wry = { version = "0.18.1", default-features = false, features = [ "file-drop", "protocol" ] }
 tauri-runtime = { version = "0.6.0", path = "../tauri-runtime" }
 tauri-utils = { version = "1.0.0-rc.8", path = "../tauri-utils" }
 uuid = { version = "1", features = [ "v4" ] }
@@ -44,7 +44,5 @@ macos-private-api = [
   "tauri-runtime/macos-private-api"
 ]
 objc-exception = [ "wry/objc-exception" ]
-gtk-tray = [ "wry/gtk-tray" ]
-ayatana-tray = [ "wry/ayatana-tray" ]
 global-shortcut = [ "tauri-runtime/global-shortcut" ]
 clipboard = [ "tauri-runtime/clipboard" ]

+ 0 - 2
core/tauri/Cargo.toml

@@ -133,8 +133,6 @@ default = [ "wry", "compression", "objc-exception" ]
 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 = [

+ 0 - 3
core/tauri/src/lib.rs

@@ -31,9 +31,6 @@
 //! - **fs-extract-api**: Enabled the `tauri::api::file::Extract` API.
 //! - **cli**: Enables usage of `clap` for CLI argument parsing. Enabled by default if the `cli` config is defined on the `tauri.conf.json` file.
 //! - **system-tray**: Enables application system tray API. Enabled by default if the `systemTray` config is defined on the `tauri.conf.json` file.
-//! Note that you must select one of `ayatana-tray` and `gtk-tray` features on Linux.
-//! - **ayatana-tray**: Use libayatana-appindicator for system tray on Linux.
-//! - **gtk-tray**: Use libappindicator3-1 for system tray on Linux. To enable this, you need to disable the default features.
 //! - **macos-private-api**: Enables features only available in **macOS**'s private APIs, currently the `transparent` window functionality and the `fullScreenEnabled` preference setting to `true`. Enabled by default if the `tauri > macosPrivateApi` config flag is set to `true` on the `tauri.conf.json` file.
 //! - **window-data-url**: Enables usage of data URLs on the webview.
 //! - **compression** *(enabled by default): Enables asset compression. You should only disable this if you want faster compile times in release builds - it produces larger binaries.

+ 4 - 17
examples/api/src-tauri/Cargo.lock

@@ -1548,18 +1548,6 @@ 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.126"
@@ -2983,9 +2971,9 @@ dependencies = [
 
 [[package]]
 name = "tao"
-version = "0.9.1"
+version = "0.10.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "53da5dd98a3c605a3ca8fe967d7c50eba8a36072ff13e04e24402b2c492ac55a"
+checksum = "d2497feadd60f2a5a7f124572d7a44b2aba589a0ad2a65d3aaf2d073c327c3b8"
 dependencies = [
  "bitflags",
  "cairo-rs",
@@ -3007,7 +2995,6 @@ dependencies = [
  "jni 0.19.0",
  "lazy_static",
  "libappindicator",
- "libayatana-appindicator",
  "libc",
  "log",
  "ndk",
@@ -4081,9 +4068,9 @@ dependencies = [
 
 [[package]]
 name = "wry"
-version = "0.17.0"
+version = "0.18.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "38425583b1f8c16c074fa4f962f7f0ddd5cb2f6b241a494a26db5eca3ccd4fd7"
+checksum = "434a873bb73c16365dc83ccc8a4d39f4b93344b82cdb90f76ffcfdf2bc76ca5b"
 dependencies = [
  "block",
  "cocoa",

+ 1 - 2
examples/api/src-tauri/Cargo.toml

@@ -16,9 +16,8 @@ tauri = { path = "../../../core/tauri", features = ["api-all", "cli", "global-sh
 tiny_http = "0.11"
 
 [features]
-default = [ "custom-protocol", "tauri/ayatana-tray" ]
+default = [ "custom-protocol" ]
 custom-protocol = [ "tauri/custom-protocol" ]
-gtk-tray = [ "tauri/gtk-tray" ]
 
 # default to small, optimized release binaries
 [profile.release]

+ 3 - 2
tooling/cli/src/info.rs

@@ -12,6 +12,7 @@ use serde::Deserialize;
 
 use std::{
   collections::HashMap,
+  fmt::Write,
   fs::{read_dir, read_to_string},
   panic,
   path::{Path, PathBuf},
@@ -461,9 +462,9 @@ fn crate_version(
                 is_git = true;
                 let mut v = format!("git:{}", g);
                 if let Some(branch) = p.branch {
-                  v.push_str(&format!("&branch={}", branch));
+                  let _ = write!(v, "&branch={}", branch);
                 } else if let Some(rev) = p.rev {
-                  v.push_str(&format!("#{}", rev));
+                  let _ = write!(v, "#{}", rev);
                 }
                 v
               } else {

+ 5 - 3
tooling/cli/src/interface/rust.rs

@@ -416,10 +416,12 @@ 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());
-      if enabled_features.contains(&"tauri/gtk-tray".into()) {
-        depends.push("libappindicator3-1".into());
-      } else {
+      depends.push("pkg-config".to_string());
+      let tray = std::env::var("TAURI_TRAY").unwrap_or_else(|_| "ayatana".to_string());
+      if tray == "ayatana" {
         depends.push("libayatana-appindicator3-1".into());
+      } else {
+        depends.push("libappindicator3-1".into());
       }
     }