Skip to content

Commit

Permalink
feat(tauri-build): add config-json feature flag (#8732)
Browse files Browse the repository at this point in the history
* feat(tauri-build): add `config-json` feature flag

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

see #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>
  • Loading branch information
3 people authored Feb 2, 2024
1 parent 95da1a2 commit e8d3793
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changes/tauri-build-config-json.md
Original file line number Diff line number Diff line change
@@ -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 changes: 5 additions & 0 deletions .changes/tauri-common-control.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tauri': 'patch:enhance'
---

Add `common-controls-v6` cargo feature flag (enabled by default).
2 changes: 2 additions & 0 deletions core/tauri-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 change: 1 addition & 0 deletions core/tauri-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
6 changes: 3 additions & 3 deletions core/tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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",
Expand Down
1 change: 1 addition & 0 deletions core/tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion examples/api/src-tauri/tauri-plugin-sample/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
7 changes: 5 additions & 2 deletions tooling/cli/src/plugin/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand All @@ -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
Expand Down

0 comments on commit e8d3793

Please sign in to comment.