Browse Source

feat(tauri-build): add `config-json` feature flag (#8732)

* feat(tauri-build): add `config-json` feature flag

This allows disabling rebuilding when `tauri.conf.json` when using another config format

see https://github.com/tauri-apps/tauri/issues/8721

* document feature flag

* Update .changes/tauri-build-config-json.md [skip ci]

* Update core/tauri/src/lib.rs [skip ci]

* disable default features for tauri-build on tauri, plugins

* fmt

---------

Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
Amr Bashir 1 year ago
parent
commit
e8d3793c3c

+ 5 - 0
.changes/tauri-build-config-json.md

@@ -0,0 +1,5 @@
+---
+'tauri-build': 'patch:enhance'
+---
+
+Add `config-json` cargo feature flag (enabled by default) to. Disabling this feature flag will stop cargo from rebuilding when `tauri.conf.json` changes, see [#8721](https://github.com/tauri-apps/tauri/issues/8721) for more info.

+ 5 - 0
.changes/tauri-common-control.md

@@ -0,0 +1,5 @@
+---
+'tauri': 'patch:enhance'
+---
+
+Add `common-controls-v6` cargo feature flag (enabled by default).

+ 2 - 0
core/tauri-build/Cargo.toml

@@ -48,7 +48,9 @@ swift-rs = { version = "1.0.6", features = [ "build" ] }
 plist = "1"
 
 [features]
+default = [ "config-json" ]
 codegen = [ "tauri-codegen", "quote" ]
 isolation = [ "tauri-codegen/isolation", "tauri-utils/isolation" ]
+config-json = [ ]
 config-json5 = [ "tauri-utils/config-json5" ]
 config-toml = [ "tauri-utils/config-toml" ]

+ 1 - 0
core/tauri-build/src/lib.rs

@@ -412,6 +412,7 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
   use anyhow::anyhow;
 
   println!("cargo:rerun-if-env-changed=TAURI_CONFIG");
+  #[cfg(feature = "config-json")]
   println!("cargo:rerun-if-changed=tauri.conf.json");
   #[cfg(feature = "config-json5")]
   println!("cargo:rerun-if-changed=tauri.conf.json5");

+ 3 - 3
core/tauri/Cargo.toml

@@ -111,7 +111,7 @@ swift-rs = "1.0.6"
 
 [build-dependencies]
 heck = "0.4"
-tauri-build = { path = "../tauri-build/", version = "2.0.0-alpha.14" }
+tauri-build = { path = "../tauri-build/", default-features = false, version = "2.0.0-alpha.14" }
 tauri-utils = { path = "../tauri-utils/", version = "2.0.0-alpha.13", features = [ "build" ] }
 
 [dev-dependencies]
@@ -130,10 +130,10 @@ default = [
   "wry",
   "compression",
   "objc-exception",
-  "tray-icon?/common-controls-v6",
-  "muda/common-controls-v6"
+  "common-controls-v6"
 ]
 unstable = [ ]
+common-controls-v6 = [ "tray-icon?/common-controls-v6", "muda/common-controls-v6" ]
 tray-icon = [ "dep:tray-icon" ]
 tracing = [
   "dep:tracing",

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

@@ -13,6 +13,7 @@
 //! The following are a list of [Cargo features](https://doc.rust-lang.org/stable/cargo/reference/manifest.html#the-features-section) that can be enabled or disabled:
 //!
 //! - **wry** *(enabled by default)*: Enables the [wry](https://github.com/tauri-apps/wry) runtime. Only disable it if you want a custom runtime.
+//! - **common-controls-v6** *(enabled by default)*: Enables [Common Controls v6](https://learn.microsoft.com/en-us/windows/win32/controls/common-control-versions) support on Windows, mainly for the predefined `about` menu item.
 //! - **unstable**: Enables unstable features. Be careful, it might introduce breaking changes in future minor releases.
 //! - **tracing**: Enables [`tracing`](https://docs.rs/tracing/latest/tracing) for window startup, plugins, `Window::eval`, events, IPC, updater and custom protocol request handlers.
 //! - **test**: Enables the [`mod@test`] module exposing unit test helpers.

+ 1 - 1
examples/api/src-tauri/tauri-plugin-sample/Cargo.toml

@@ -11,5 +11,5 @@ serde = "1"
 thiserror = "1"
 
 [build-dependencies]
-tauri-build = { path = "../../../../core/tauri-build/" }
+tauri-build = { path = "../../../../core/tauri-build/", default-features = false }
 tauri-plugin = { path = "../../../../core/tauri-plugin", features = ["build"] }

+ 5 - 2
tooling/cli/src/plugin/init.rs

@@ -96,7 +96,7 @@ pub fn command(mut options: Options) -> Result<()> {
             resolve_tauri_path(&tauri_path, "core/tauri")
           ),
           format!(
-            "{{  path = {:?} }}",
+            "{{  path = {:?}, default-features = false }}",
             resolve_tauri_path(&tauri_path, "core/tauri-build")
           ),
           format!(
@@ -108,7 +108,10 @@ pub fn command(mut options: Options) -> Result<()> {
         (
           format!(r#"{{ version = "{}" }}"#, metadata.tauri),
           format!(r#"{{ version = "{}" }}"#, metadata.tauri),
-          format!(r#"{{ version = "{}" }}"#, metadata.tauri_build),
+          format!(
+            r#"{{ version = "{}", default-features = false }}"#,
+            metadata.tauri_build
+          ),
           format!(
             r#"{{ version = "{}", features = ["build"] }}"#,
             metadata.tauri_plugin