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>
This commit is contained in:
Amr Bashir 2024-02-02 19:11:59 +02:00 committed by GitHub
parent 95da1a2747
commit e8d3793c3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 23 additions and 6 deletions

View File

@ -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.

View File

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

View File

@ -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" ]

View File

@ -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");

View File

@ -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",

View File

@ -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.

View File

@ -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"] }

View File

@ -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