2023-02-19 16:17:49 +03:00
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
2021-04-11 01:09:09 +03:00
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
2023-06-20 03:51:05 +03:00
//! [![](https://github.com/tauri-apps/tauri/raw/dev/.github/splash.png)](https://tauri.app)
//!
//! This applies the macros at build-time in order to rig some special features needed by `cargo`.
#![ doc(
html_logo_url = " https://github.com/tauri-apps/tauri/raw/dev/app-icon.png " ,
html_favicon_url = " https://github.com/tauri-apps/tauri/raw/dev/app-icon.png "
) ]
2021-03-13 04:10:19 +03:00
#![ cfg_attr(doc_cfg, feature(doc_cfg)) ]
2023-02-22 19:57:19 +03:00
use anyhow ::Context ;
2021-03-13 04:10:19 +03:00
pub use anyhow ::Result ;
2023-06-15 15:52:33 +03:00
use cargo_toml ::Manifest ;
2022-07-11 22:07:39 +03:00
use heck ::AsShoutySnakeCase ;
2023-01-26 16:47:23 +03:00
use tauri_utils ::{
config ::Config ,
resources ::{ external_binaries , resource_relpath , ResourcePaths } ,
} ;
2021-03-13 04:10:19 +03:00
2023-02-22 19:57:19 +03:00
use std ::{
env ::var_os ,
path ::{ Path , PathBuf } ,
} ;
2021-05-03 16:42:29 +03:00
2023-06-15 15:52:33 +03:00
mod allowlist ;
2021-03-13 04:10:19 +03:00
#[ cfg(feature = " codegen " ) ]
mod codegen ;
2023-07-18 17:04:15 +03:00
/// Tauri configuration functions.
pub mod config ;
2023-02-06 14:56:00 +03:00
/// Mobile build functions.
pub mod mobile ;
2022-05-27 20:33:04 +03:00
mod static_vcruntime ;
2021-03-13 04:10:19 +03:00
#[ cfg(feature = " codegen " ) ]
2021-08-13 17:40:57 +03:00
#[ cfg_attr(doc_cfg, doc(cfg(feature = " codegen " ))) ]
2021-03-13 04:10:19 +03:00
pub use codegen ::context ::CodegenContext ;
2022-02-08 19:13:21 +03:00
fn copy_file ( from : impl AsRef < Path > , to : impl AsRef < Path > ) -> Result < ( ) > {
let from = from . as_ref ( ) ;
let to = to . as_ref ( ) ;
if ! from . exists ( ) {
return Err ( anyhow ::anyhow! ( " {:?} does not exist " , from ) ) ;
}
if ! from . is_file ( ) {
return Err ( anyhow ::anyhow! ( " {:?} is not a file " , from ) ) ;
}
2022-02-10 17:21:02 +03:00
let dest_dir = to . parent ( ) . expect ( " No data in parent " ) ;
std ::fs ::create_dir_all ( dest_dir ) ? ;
2022-02-08 19:13:21 +03:00
std ::fs ::copy ( from , to ) ? ;
Ok ( ( ) )
}
2022-12-15 23:56:23 +03:00
fn copy_binaries (
binaries : ResourcePaths ,
2022-08-02 16:37:16 +03:00
target_triple : & str ,
path : & Path ,
package_name : Option < & String > ,
) -> Result < ( ) > {
2022-02-08 19:13:21 +03:00
for src in binaries {
let src = src ? ;
2022-02-15 00:33:40 +03:00
println! ( " cargo:rerun-if-changed= {} " , src . display ( ) ) ;
2022-08-02 16:37:16 +03:00
let file_name = src
. file_name ( )
. expect ( " failed to extract external binary filename " )
. to_string_lossy ( )
2022-12-15 23:56:23 +03:00
. replace ( & format! ( " - {target_triple} " ) , " " ) ;
2022-08-02 16:37:16 +03:00
if package_name . map_or ( false , | n | n = = & file_name ) {
return Err ( anyhow ::anyhow! (
" Cannot define a sidecar with the same name as the Cargo package name `{}`. Please change the sidecar name in the filesystem and the Tauri configuration. " ,
file_name
) ) ;
}
let dest = path . join ( file_name ) ;
2022-05-19 04:49:53 +03:00
if dest . exists ( ) {
std ::fs ::remove_file ( & dest ) . unwrap ( ) ;
}
2022-02-08 19:13:21 +03:00
copy_file ( & src , & dest ) ? ;
}
Ok ( ( ) )
}
/// Copies resources to a path.
fn copy_resources ( resources : ResourcePaths < '_ > , path : & Path ) -> Result < ( ) > {
for src in resources {
let src = src ? ;
2022-02-15 00:33:40 +03:00
println! ( " cargo:rerun-if-changed= {} " , src . display ( ) ) ;
2022-02-08 19:13:21 +03:00
let dest = path . join ( resource_relpath ( & src ) ) ;
2022-12-15 23:56:23 +03:00
copy_file ( & src , dest ) ? ;
2022-02-08 19:13:21 +03:00
}
Ok ( ( ) )
}
2022-05-25 16:51:33 +03:00
// checks if the given Cargo feature is enabled.
fn has_feature ( feature : & str ) -> bool {
// when a feature is enabled, Cargo sets the `CARGO_FEATURE_<name` env var to 1
// https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts
2022-07-11 22:07:39 +03:00
std ::env ::var ( format! ( " CARGO_FEATURE_ {} " , AsShoutySnakeCase ( feature ) ) )
. map ( | x | x = = " 1 " )
. unwrap_or ( false )
2022-05-25 16:51:33 +03:00
}
// creates a cfg alias if `has_feature` is true.
// `alias` must be a snake case string.
fn cfg_alias ( alias : & str , has_feature : bool ) {
if has_feature {
2022-12-15 23:56:23 +03:00
println! ( " cargo:rustc-cfg= {alias} " ) ;
2022-05-25 16:51:33 +03:00
}
}
2021-05-03 16:42:29 +03:00
/// Attributes used on Windows.
#[ allow(dead_code) ]
2022-05-13 16:39:04 +03:00
#[ derive(Debug, Default) ]
2021-05-03 16:42:29 +03:00
pub struct WindowsAttributes {
2022-05-13 16:39:04 +03:00
window_icon_path : Option < PathBuf > ,
2022-12-14 18:18:46 +03:00
/// A string containing an [application manifest] to be included with the application on Windows.
///
/// Defaults to:
Merge remote-tracking branch 'origin/dev' into next (#7067)
Co-authored-by: wusyong <wusyong@users.noreply.github.com>
Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de>
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
Co-authored-by: Simon Hyll <hyllsimon@gmail.com>
Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>
Co-authored-by: Lucas Nogueira <lucas@tauri.app>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.studio>
Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: chip <chip@chip.sh>
Co-authored-by: Raphii <iam@raphii.co>
Co-authored-by: Ronie Martinez <ronmarti18@gmail.com>
Co-authored-by: hanaTsuk1 <101488209+hanaTsuk1@users.noreply.github.com>
Co-authored-by: nathan-fall <39990940+nathan-fall@users.noreply.github.com>
Co-authored-by: Akshay <nerdy@peppe.rs>
Co-authored-by: KurikoMoe <kurikomoe@gmail.com>
Co-authored-by: Guilherme Oenning <me@goenning.net>
Co-authored-by: Pierre Cashon <biaocy91@gmail.com>
Co-authored-by: Jack Wills <32690432+mrjackwills@users.noreply.github.com>
Co-authored-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
Co-authored-by: Risto Stevcev <me@risto.codes>
Co-authored-by: Soumt <rltks1305@naver.com>
Co-authored-by: yutotnh <57719497+yutotnh@users.noreply.github.com>
Co-authored-by: Gökçe Merdun <agmmnn@gmail.com>
Co-authored-by: Nathanael Rea <Nathan@NathanaelRea.com>
Co-authored-by: Usman Rajab <usman.rajab@gmail.com>
Co-authored-by: Francis The Basilisk <36006338+snorkysnark@users.noreply.github.com>
Co-authored-by: Lej77 <31554212+Lej77@users.noreply.github.com>
Co-authored-by: Tomáš Diblík <dibla.tomas@post.cz>
Co-authored-by: Jonas Kruckenberg <iterpre@protonmail.com>
Co-authored-by: Pascal Sommer <Pascal-So@users.noreply.github.com>
Co-authored-by: Bo <bertonzh@gmail.com>
Co-authored-by: Kevin Yue <k3vinyue@gmail.com>
fixed grammar and typos (#6937)
Fix api.js docs pipeline with updated typedoc dependencies (#6945)
closes #6887 (#6922)
fix(core): Fix `WindowBuilder::on_navigation` handler never registerd, closes #6865 (#6921)
fix(core): Fix `WindowBuilder::on_navigation` handler never registerd, closes #6865
fix broken symlinks in license files (#6336)
fix(cli): fix cli connection timeout to dev server (fix #6045) (#6046)
fix(bundler): ensure that there are no duplicate extension arguments when bundling on Windows, fixes #6103 (#6917)
fix(bundler): ensure that there are no duplicate extension arguments during bundling on Windows (fix #6103)
closes #5491 (#6408)
fix(nsis): prefill $INSTDIR with previous install path and respect `/D` flag, closes #6928 (#6935)
fix(nsis): prefill $INSTDIR with previous install path and respect `/D` flag, closes #6928
fix(updater): emit `UPTODATE` when server responds with 204, closes #6934 (#6970)
fix(core): unpin all dependencies, closes #6944 (#6966)
fix(bundler): Add new lang_file option in persian variant. (#6972)
fix(core/ipc): access url through webview native object, closes #6889 (#6976)
fix(core): remove trailing slash in http scope url, closes #5208 (#6974)
fix(core): remove trailing slash in http scope url, closes #5208
fix(cli): find correct binary when `--profile` is used, closes #6954 (#6979)
fix(cli): find correct binary when `--profile` is used, closes #6954
closes #6955 (#6987)
closes #6955
closes #6158 (#6969)
closes #6158
fix(cli): improve vs build tools detection (#6982)
fix: updated appimage script to follow symlinks for /usr/lib* (fix: #6992) (#6996)
fix(cli): correctly remove Cargo features (#7013)
Fix typo (#7012)
fix(cli): revert metadata.json field rename from #6795 (#7029)
closes #6732 (#6736)
fix: add missing file properties on Windows, closes #6676 (#6693)
fix(cli.js): detect node-20 binary (#6667)
fix version-or-publish workflow (#7031)
fix(cli/devserver): inject autoreload into HTML only, closes #6997 (#7032)
fix(bundler/nsis): write installer templates UTF16LE encoded, closes #7036 (#7040)
fix(bundler/nsis): write installer templates UTF16LE encoded, closes #7036
fix(core): rewrite `asset` protocol streaming, closes #6375 (#6390)
closes #5939 (#5960)
fix(core): use `safe_block_on` (#7047)
closes #6859 (#6933)
closes #6955 (#6998)
fix(core): populate webview_attrs from config, closes #6794 (#6797)
closes #5176 (#5180)
fix: sound for notifications on windows (fix #6652) (#6680)
close native window's buttons, closes #2353 (#6665)
fix(bundler/nsis): calculate accurate app size, closes #7056 (#7057)
fix(tests): only download update when it is available (#7061)
closes #6706 (#6712)
fix(doc): correct the doc of `content_protected()` (#7065)
closes #6472 (#6530)
fix(macros): use full path to Result to avoid issues with type aliases (#7071)
2023-05-30 03:29:24 +03:00
/// ```text
2022-12-14 18:18:46 +03:00
#[ doc = include_str!( " window-app-manifest.xml " ) ]
/// ```
///
Merge remote-tracking branch 'origin/dev' into next (#7067)
Co-authored-by: wusyong <wusyong@users.noreply.github.com>
Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de>
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
Co-authored-by: Simon Hyll <hyllsimon@gmail.com>
Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>
Co-authored-by: Lucas Nogueira <lucas@tauri.app>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.studio>
Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: chip <chip@chip.sh>
Co-authored-by: Raphii <iam@raphii.co>
Co-authored-by: Ronie Martinez <ronmarti18@gmail.com>
Co-authored-by: hanaTsuk1 <101488209+hanaTsuk1@users.noreply.github.com>
Co-authored-by: nathan-fall <39990940+nathan-fall@users.noreply.github.com>
Co-authored-by: Akshay <nerdy@peppe.rs>
Co-authored-by: KurikoMoe <kurikomoe@gmail.com>
Co-authored-by: Guilherme Oenning <me@goenning.net>
Co-authored-by: Pierre Cashon <biaocy91@gmail.com>
Co-authored-by: Jack Wills <32690432+mrjackwills@users.noreply.github.com>
Co-authored-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
Co-authored-by: Risto Stevcev <me@risto.codes>
Co-authored-by: Soumt <rltks1305@naver.com>
Co-authored-by: yutotnh <57719497+yutotnh@users.noreply.github.com>
Co-authored-by: Gökçe Merdun <agmmnn@gmail.com>
Co-authored-by: Nathanael Rea <Nathan@NathanaelRea.com>
Co-authored-by: Usman Rajab <usman.rajab@gmail.com>
Co-authored-by: Francis The Basilisk <36006338+snorkysnark@users.noreply.github.com>
Co-authored-by: Lej77 <31554212+Lej77@users.noreply.github.com>
Co-authored-by: Tomáš Diblík <dibla.tomas@post.cz>
Co-authored-by: Jonas Kruckenberg <iterpre@protonmail.com>
Co-authored-by: Pascal Sommer <Pascal-So@users.noreply.github.com>
Co-authored-by: Bo <bertonzh@gmail.com>
Co-authored-by: Kevin Yue <k3vinyue@gmail.com>
fixed grammar and typos (#6937)
Fix api.js docs pipeline with updated typedoc dependencies (#6945)
closes #6887 (#6922)
fix(core): Fix `WindowBuilder::on_navigation` handler never registerd, closes #6865 (#6921)
fix(core): Fix `WindowBuilder::on_navigation` handler never registerd, closes #6865
fix broken symlinks in license files (#6336)
fix(cli): fix cli connection timeout to dev server (fix #6045) (#6046)
fix(bundler): ensure that there are no duplicate extension arguments when bundling on Windows, fixes #6103 (#6917)
fix(bundler): ensure that there are no duplicate extension arguments during bundling on Windows (fix #6103)
closes #5491 (#6408)
fix(nsis): prefill $INSTDIR with previous install path and respect `/D` flag, closes #6928 (#6935)
fix(nsis): prefill $INSTDIR with previous install path and respect `/D` flag, closes #6928
fix(updater): emit `UPTODATE` when server responds with 204, closes #6934 (#6970)
fix(core): unpin all dependencies, closes #6944 (#6966)
fix(bundler): Add new lang_file option in persian variant. (#6972)
fix(core/ipc): access url through webview native object, closes #6889 (#6976)
fix(core): remove trailing slash in http scope url, closes #5208 (#6974)
fix(core): remove trailing slash in http scope url, closes #5208
fix(cli): find correct binary when `--profile` is used, closes #6954 (#6979)
fix(cli): find correct binary when `--profile` is used, closes #6954
closes #6955 (#6987)
closes #6955
closes #6158 (#6969)
closes #6158
fix(cli): improve vs build tools detection (#6982)
fix: updated appimage script to follow symlinks for /usr/lib* (fix: #6992) (#6996)
fix(cli): correctly remove Cargo features (#7013)
Fix typo (#7012)
fix(cli): revert metadata.json field rename from #6795 (#7029)
closes #6732 (#6736)
fix: add missing file properties on Windows, closes #6676 (#6693)
fix(cli.js): detect node-20 binary (#6667)
fix version-or-publish workflow (#7031)
fix(cli/devserver): inject autoreload into HTML only, closes #6997 (#7032)
fix(bundler/nsis): write installer templates UTF16LE encoded, closes #7036 (#7040)
fix(bundler/nsis): write installer templates UTF16LE encoded, closes #7036
fix(core): rewrite `asset` protocol streaming, closes #6375 (#6390)
closes #5939 (#5960)
fix(core): use `safe_block_on` (#7047)
closes #6859 (#6933)
closes #6955 (#6998)
fix(core): populate webview_attrs from config, closes #6794 (#6797)
closes #5176 (#5180)
fix: sound for notifications on windows (fix #6652) (#6680)
close native window's buttons, closes #2353 (#6665)
fix(bundler/nsis): calculate accurate app size, closes #7056 (#7057)
fix(tests): only download update when it is available (#7061)
closes #6706 (#6712)
fix(doc): correct the doc of `content_protected()` (#7065)
closes #6472 (#6530)
fix(macros): use full path to Result to avoid issues with type aliases (#7071)
2023-05-30 03:29:24 +03:00
/// ## Warning
///
/// if you are using tauri's dialog APIs, you need to specify a dependency on Common Control v6 by adding the following to your custom manifest:
/// ```text
/// <dependency>
/// <dependentAssembly>
/// <assemblyIdentity
/// type="win32"
/// name="Microsoft.Windows.Common-Controls"
/// version="6.0.0.0"
/// processorArchitecture="*"
/// publicKeyToken="6595b64144ccf1df"
/// language="*"
/// />
/// </dependentAssembly>
/// </dependency>
/// ```
///
2022-12-14 18:18:46 +03:00
/// [application manifest]: https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests
app_manifest : Option < String > ,
2021-05-03 16:42:29 +03:00
}
impl WindowsAttributes {
/// Creates the default attribute set.
pub fn new ( ) -> Self {
Self ::default ( )
}
/// Sets the icon to use on the window. Currently only used on Windows.
/// It must be in `ico` format. Defaults to `icons/icon.ico`.
2022-01-17 16:46:14 +03:00
#[ must_use ]
2021-05-03 16:42:29 +03:00
pub fn window_icon_path < P : AsRef < Path > > ( mut self , window_icon_path : P ) -> Self {
2022-05-13 16:39:04 +03:00
self
. window_icon_path
. replace ( window_icon_path . as_ref ( ) . into ( ) ) ;
2021-05-03 16:42:29 +03:00
self
}
2021-11-16 17:18:13 +03:00
Merge remote-tracking branch 'origin/dev' into next (#7067)
Co-authored-by: wusyong <wusyong@users.noreply.github.com>
Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de>
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
Co-authored-by: Simon Hyll <hyllsimon@gmail.com>
Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>
Co-authored-by: Lucas Nogueira <lucas@tauri.app>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.studio>
Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: chip <chip@chip.sh>
Co-authored-by: Raphii <iam@raphii.co>
Co-authored-by: Ronie Martinez <ronmarti18@gmail.com>
Co-authored-by: hanaTsuk1 <101488209+hanaTsuk1@users.noreply.github.com>
Co-authored-by: nathan-fall <39990940+nathan-fall@users.noreply.github.com>
Co-authored-by: Akshay <nerdy@peppe.rs>
Co-authored-by: KurikoMoe <kurikomoe@gmail.com>
Co-authored-by: Guilherme Oenning <me@goenning.net>
Co-authored-by: Pierre Cashon <biaocy91@gmail.com>
Co-authored-by: Jack Wills <32690432+mrjackwills@users.noreply.github.com>
Co-authored-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
Co-authored-by: Risto Stevcev <me@risto.codes>
Co-authored-by: Soumt <rltks1305@naver.com>
Co-authored-by: yutotnh <57719497+yutotnh@users.noreply.github.com>
Co-authored-by: Gökçe Merdun <agmmnn@gmail.com>
Co-authored-by: Nathanael Rea <Nathan@NathanaelRea.com>
Co-authored-by: Usman Rajab <usman.rajab@gmail.com>
Co-authored-by: Francis The Basilisk <36006338+snorkysnark@users.noreply.github.com>
Co-authored-by: Lej77 <31554212+Lej77@users.noreply.github.com>
Co-authored-by: Tomáš Diblík <dibla.tomas@post.cz>
Co-authored-by: Jonas Kruckenberg <iterpre@protonmail.com>
Co-authored-by: Pascal Sommer <Pascal-So@users.noreply.github.com>
Co-authored-by: Bo <bertonzh@gmail.com>
Co-authored-by: Kevin Yue <k3vinyue@gmail.com>
fixed grammar and typos (#6937)
Fix api.js docs pipeline with updated typedoc dependencies (#6945)
closes #6887 (#6922)
fix(core): Fix `WindowBuilder::on_navigation` handler never registerd, closes #6865 (#6921)
fix(core): Fix `WindowBuilder::on_navigation` handler never registerd, closes #6865
fix broken symlinks in license files (#6336)
fix(cli): fix cli connection timeout to dev server (fix #6045) (#6046)
fix(bundler): ensure that there are no duplicate extension arguments when bundling on Windows, fixes #6103 (#6917)
fix(bundler): ensure that there are no duplicate extension arguments during bundling on Windows (fix #6103)
closes #5491 (#6408)
fix(nsis): prefill $INSTDIR with previous install path and respect `/D` flag, closes #6928 (#6935)
fix(nsis): prefill $INSTDIR with previous install path and respect `/D` flag, closes #6928
fix(updater): emit `UPTODATE` when server responds with 204, closes #6934 (#6970)
fix(core): unpin all dependencies, closes #6944 (#6966)
fix(bundler): Add new lang_file option in persian variant. (#6972)
fix(core/ipc): access url through webview native object, closes #6889 (#6976)
fix(core): remove trailing slash in http scope url, closes #5208 (#6974)
fix(core): remove trailing slash in http scope url, closes #5208
fix(cli): find correct binary when `--profile` is used, closes #6954 (#6979)
fix(cli): find correct binary when `--profile` is used, closes #6954
closes #6955 (#6987)
closes #6955
closes #6158 (#6969)
closes #6158
fix(cli): improve vs build tools detection (#6982)
fix: updated appimage script to follow symlinks for /usr/lib* (fix: #6992) (#6996)
fix(cli): correctly remove Cargo features (#7013)
Fix typo (#7012)
fix(cli): revert metadata.json field rename from #6795 (#7029)
closes #6732 (#6736)
fix: add missing file properties on Windows, closes #6676 (#6693)
fix(cli.js): detect node-20 binary (#6667)
fix version-or-publish workflow (#7031)
fix(cli/devserver): inject autoreload into HTML only, closes #6997 (#7032)
fix(bundler/nsis): write installer templates UTF16LE encoded, closes #7036 (#7040)
fix(bundler/nsis): write installer templates UTF16LE encoded, closes #7036
fix(core): rewrite `asset` protocol streaming, closes #6375 (#6390)
closes #5939 (#5960)
fix(core): use `safe_block_on` (#7047)
closes #6859 (#6933)
closes #6955 (#6998)
fix(core): populate webview_attrs from config, closes #6794 (#6797)
closes #5176 (#5180)
fix: sound for notifications on windows (fix #6652) (#6680)
close native window's buttons, closes #2353 (#6665)
fix(bundler/nsis): calculate accurate app size, closes #7056 (#7057)
fix(tests): only download update when it is available (#7061)
closes #6706 (#6712)
fix(doc): correct the doc of `content_protected()` (#7065)
closes #6472 (#6530)
fix(macros): use full path to Result to avoid issues with type aliases (#7071)
2023-05-30 03:29:24 +03:00
/// Sets the [application manifest] to be included with the application on Windows.
///
/// Defaults to:
/// ```text
#[ doc = include_str!( " window-app-manifest.xml " ) ]
/// ```
///
/// ## Warning
///
/// if you are using tauri's dialog APIs, you need to specify a dependency on Common Control v6 by adding the following to your custom manifest:
/// ```text
/// <dependency>
/// <dependentAssembly>
/// <assemblyIdentity
/// type="win32"
/// name="Microsoft.Windows.Common-Controls"
/// version="6.0.0.0"
/// processorArchitecture="*"
/// publicKeyToken="6595b64144ccf1df"
/// language="*"
/// />
/// </dependentAssembly>
/// </dependency>
/// ```
2022-12-14 18:18:46 +03:00
///
/// # Example
///
/// The following manifest will brand the exe as requesting administrator privileges.
/// Thus, everytime it is executed, a Windows UAC dialog will appear.
///
/// ```rust,no_run
/// let mut windows = tauri_build::WindowsAttributes::new();
/// windows = windows.app_manifest(r#"
/// <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
Merge remote-tracking branch 'origin/dev' into next (#7067)
Co-authored-by: wusyong <wusyong@users.noreply.github.com>
Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de>
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
Co-authored-by: Simon Hyll <hyllsimon@gmail.com>
Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>
Co-authored-by: Lucas Nogueira <lucas@tauri.app>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.studio>
Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: chip <chip@chip.sh>
Co-authored-by: Raphii <iam@raphii.co>
Co-authored-by: Ronie Martinez <ronmarti18@gmail.com>
Co-authored-by: hanaTsuk1 <101488209+hanaTsuk1@users.noreply.github.com>
Co-authored-by: nathan-fall <39990940+nathan-fall@users.noreply.github.com>
Co-authored-by: Akshay <nerdy@peppe.rs>
Co-authored-by: KurikoMoe <kurikomoe@gmail.com>
Co-authored-by: Guilherme Oenning <me@goenning.net>
Co-authored-by: Pierre Cashon <biaocy91@gmail.com>
Co-authored-by: Jack Wills <32690432+mrjackwills@users.noreply.github.com>
Co-authored-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
Co-authored-by: Risto Stevcev <me@risto.codes>
Co-authored-by: Soumt <rltks1305@naver.com>
Co-authored-by: yutotnh <57719497+yutotnh@users.noreply.github.com>
Co-authored-by: Gökçe Merdun <agmmnn@gmail.com>
Co-authored-by: Nathanael Rea <Nathan@NathanaelRea.com>
Co-authored-by: Usman Rajab <usman.rajab@gmail.com>
Co-authored-by: Francis The Basilisk <36006338+snorkysnark@users.noreply.github.com>
Co-authored-by: Lej77 <31554212+Lej77@users.noreply.github.com>
Co-authored-by: Tomáš Diblík <dibla.tomas@post.cz>
Co-authored-by: Jonas Kruckenberg <iterpre@protonmail.com>
Co-authored-by: Pascal Sommer <Pascal-So@users.noreply.github.com>
Co-authored-by: Bo <bertonzh@gmail.com>
Co-authored-by: Kevin Yue <k3vinyue@gmail.com>
fixed grammar and typos (#6937)
Fix api.js docs pipeline with updated typedoc dependencies (#6945)
closes #6887 (#6922)
fix(core): Fix `WindowBuilder::on_navigation` handler never registerd, closes #6865 (#6921)
fix(core): Fix `WindowBuilder::on_navigation` handler never registerd, closes #6865
fix broken symlinks in license files (#6336)
fix(cli): fix cli connection timeout to dev server (fix #6045) (#6046)
fix(bundler): ensure that there are no duplicate extension arguments when bundling on Windows, fixes #6103 (#6917)
fix(bundler): ensure that there are no duplicate extension arguments during bundling on Windows (fix #6103)
closes #5491 (#6408)
fix(nsis): prefill $INSTDIR with previous install path and respect `/D` flag, closes #6928 (#6935)
fix(nsis): prefill $INSTDIR with previous install path and respect `/D` flag, closes #6928
fix(updater): emit `UPTODATE` when server responds with 204, closes #6934 (#6970)
fix(core): unpin all dependencies, closes #6944 (#6966)
fix(bundler): Add new lang_file option in persian variant. (#6972)
fix(core/ipc): access url through webview native object, closes #6889 (#6976)
fix(core): remove trailing slash in http scope url, closes #5208 (#6974)
fix(core): remove trailing slash in http scope url, closes #5208
fix(cli): find correct binary when `--profile` is used, closes #6954 (#6979)
fix(cli): find correct binary when `--profile` is used, closes #6954
closes #6955 (#6987)
closes #6955
closes #6158 (#6969)
closes #6158
fix(cli): improve vs build tools detection (#6982)
fix: updated appimage script to follow symlinks for /usr/lib* (fix: #6992) (#6996)
fix(cli): correctly remove Cargo features (#7013)
Fix typo (#7012)
fix(cli): revert metadata.json field rename from #6795 (#7029)
closes #6732 (#6736)
fix: add missing file properties on Windows, closes #6676 (#6693)
fix(cli.js): detect node-20 binary (#6667)
fix version-or-publish workflow (#7031)
fix(cli/devserver): inject autoreload into HTML only, closes #6997 (#7032)
fix(bundler/nsis): write installer templates UTF16LE encoded, closes #7036 (#7040)
fix(bundler/nsis): write installer templates UTF16LE encoded, closes #7036
fix(core): rewrite `asset` protocol streaming, closes #6375 (#6390)
closes #5939 (#5960)
fix(core): use `safe_block_on` (#7047)
closes #6859 (#6933)
closes #6955 (#6998)
fix(core): populate webview_attrs from config, closes #6794 (#6797)
closes #5176 (#5180)
fix: sound for notifications on windows (fix #6652) (#6680)
close native window's buttons, closes #2353 (#6665)
fix(bundler/nsis): calculate accurate app size, closes #7056 (#7057)
fix(tests): only download update when it is available (#7061)
closes #6706 (#6712)
fix(doc): correct the doc of `content_protected()` (#7065)
closes #6472 (#6530)
fix(macros): use full path to Result to avoid issues with type aliases (#7071)
2023-05-30 03:29:24 +03:00
/// <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
/// <security>
/// <requestedPrivileges>
/// <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
/// </requestedPrivileges>
/// </security>
/// </trustInfo>
2022-12-14 18:18:46 +03:00
/// </assembly>
/// "#);
Merge remote-tracking branch 'origin/dev' into next (#7067)
Co-authored-by: wusyong <wusyong@users.noreply.github.com>
Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de>
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
Co-authored-by: Simon Hyll <hyllsimon@gmail.com>
Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>
Co-authored-by: Lucas Nogueira <lucas@tauri.app>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.studio>
Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: chip <chip@chip.sh>
Co-authored-by: Raphii <iam@raphii.co>
Co-authored-by: Ronie Martinez <ronmarti18@gmail.com>
Co-authored-by: hanaTsuk1 <101488209+hanaTsuk1@users.noreply.github.com>
Co-authored-by: nathan-fall <39990940+nathan-fall@users.noreply.github.com>
Co-authored-by: Akshay <nerdy@peppe.rs>
Co-authored-by: KurikoMoe <kurikomoe@gmail.com>
Co-authored-by: Guilherme Oenning <me@goenning.net>
Co-authored-by: Pierre Cashon <biaocy91@gmail.com>
Co-authored-by: Jack Wills <32690432+mrjackwills@users.noreply.github.com>
Co-authored-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
Co-authored-by: Risto Stevcev <me@risto.codes>
Co-authored-by: Soumt <rltks1305@naver.com>
Co-authored-by: yutotnh <57719497+yutotnh@users.noreply.github.com>
Co-authored-by: Gökçe Merdun <agmmnn@gmail.com>
Co-authored-by: Nathanael Rea <Nathan@NathanaelRea.com>
Co-authored-by: Usman Rajab <usman.rajab@gmail.com>
Co-authored-by: Francis The Basilisk <36006338+snorkysnark@users.noreply.github.com>
Co-authored-by: Lej77 <31554212+Lej77@users.noreply.github.com>
Co-authored-by: Tomáš Diblík <dibla.tomas@post.cz>
Co-authored-by: Jonas Kruckenberg <iterpre@protonmail.com>
Co-authored-by: Pascal Sommer <Pascal-So@users.noreply.github.com>
Co-authored-by: Bo <bertonzh@gmail.com>
Co-authored-by: Kevin Yue <k3vinyue@gmail.com>
fixed grammar and typos (#6937)
Fix api.js docs pipeline with updated typedoc dependencies (#6945)
closes #6887 (#6922)
fix(core): Fix `WindowBuilder::on_navigation` handler never registerd, closes #6865 (#6921)
fix(core): Fix `WindowBuilder::on_navigation` handler never registerd, closes #6865
fix broken symlinks in license files (#6336)
fix(cli): fix cli connection timeout to dev server (fix #6045) (#6046)
fix(bundler): ensure that there are no duplicate extension arguments when bundling on Windows, fixes #6103 (#6917)
fix(bundler): ensure that there are no duplicate extension arguments during bundling on Windows (fix #6103)
closes #5491 (#6408)
fix(nsis): prefill $INSTDIR with previous install path and respect `/D` flag, closes #6928 (#6935)
fix(nsis): prefill $INSTDIR with previous install path and respect `/D` flag, closes #6928
fix(updater): emit `UPTODATE` when server responds with 204, closes #6934 (#6970)
fix(core): unpin all dependencies, closes #6944 (#6966)
fix(bundler): Add new lang_file option in persian variant. (#6972)
fix(core/ipc): access url through webview native object, closes #6889 (#6976)
fix(core): remove trailing slash in http scope url, closes #5208 (#6974)
fix(core): remove trailing slash in http scope url, closes #5208
fix(cli): find correct binary when `--profile` is used, closes #6954 (#6979)
fix(cli): find correct binary when `--profile` is used, closes #6954
closes #6955 (#6987)
closes #6955
closes #6158 (#6969)
closes #6158
fix(cli): improve vs build tools detection (#6982)
fix: updated appimage script to follow symlinks for /usr/lib* (fix: #6992) (#6996)
fix(cli): correctly remove Cargo features (#7013)
Fix typo (#7012)
fix(cli): revert metadata.json field rename from #6795 (#7029)
closes #6732 (#6736)
fix: add missing file properties on Windows, closes #6676 (#6693)
fix(cli.js): detect node-20 binary (#6667)
fix version-or-publish workflow (#7031)
fix(cli/devserver): inject autoreload into HTML only, closes #6997 (#7032)
fix(bundler/nsis): write installer templates UTF16LE encoded, closes #7036 (#7040)
fix(bundler/nsis): write installer templates UTF16LE encoded, closes #7036
fix(core): rewrite `asset` protocol streaming, closes #6375 (#6390)
closes #5939 (#5960)
fix(core): use `safe_block_on` (#7047)
closes #6859 (#6933)
closes #6955 (#6998)
fix(core): populate webview_attrs from config, closes #6794 (#6797)
closes #5176 (#5180)
fix: sound for notifications on windows (fix #6652) (#6680)
close native window's buttons, closes #2353 (#6665)
fix(bundler/nsis): calculate accurate app size, closes #7056 (#7057)
fix(tests): only download update when it is available (#7061)
closes #6706 (#6712)
fix(doc): correct the doc of `content_protected()` (#7065)
closes #6472 (#6530)
fix(macros): use full path to Result to avoid issues with type aliases (#7071)
2023-05-30 03:29:24 +03:00
/// let attrs = tauri_build::Attributes::new().windows_attributes(windows);
/// tauri_build::try_build(attrs).expect("failed to run build script");
2022-12-14 18:18:46 +03:00
/// ```
///
Merge remote-tracking branch 'origin/dev' into next (#7067)
Co-authored-by: wusyong <wusyong@users.noreply.github.com>
Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de>
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
Co-authored-by: Simon Hyll <hyllsimon@gmail.com>
Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>
Co-authored-by: Lucas Nogueira <lucas@tauri.app>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.studio>
Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: chip <chip@chip.sh>
Co-authored-by: Raphii <iam@raphii.co>
Co-authored-by: Ronie Martinez <ronmarti18@gmail.com>
Co-authored-by: hanaTsuk1 <101488209+hanaTsuk1@users.noreply.github.com>
Co-authored-by: nathan-fall <39990940+nathan-fall@users.noreply.github.com>
Co-authored-by: Akshay <nerdy@peppe.rs>
Co-authored-by: KurikoMoe <kurikomoe@gmail.com>
Co-authored-by: Guilherme Oenning <me@goenning.net>
Co-authored-by: Pierre Cashon <biaocy91@gmail.com>
Co-authored-by: Jack Wills <32690432+mrjackwills@users.noreply.github.com>
Co-authored-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
Co-authored-by: Risto Stevcev <me@risto.codes>
Co-authored-by: Soumt <rltks1305@naver.com>
Co-authored-by: yutotnh <57719497+yutotnh@users.noreply.github.com>
Co-authored-by: Gökçe Merdun <agmmnn@gmail.com>
Co-authored-by: Nathanael Rea <Nathan@NathanaelRea.com>
Co-authored-by: Usman Rajab <usman.rajab@gmail.com>
Co-authored-by: Francis The Basilisk <36006338+snorkysnark@users.noreply.github.com>
Co-authored-by: Lej77 <31554212+Lej77@users.noreply.github.com>
Co-authored-by: Tomáš Diblík <dibla.tomas@post.cz>
Co-authored-by: Jonas Kruckenberg <iterpre@protonmail.com>
Co-authored-by: Pascal Sommer <Pascal-So@users.noreply.github.com>
Co-authored-by: Bo <bertonzh@gmail.com>
Co-authored-by: Kevin Yue <k3vinyue@gmail.com>
fixed grammar and typos (#6937)
Fix api.js docs pipeline with updated typedoc dependencies (#6945)
closes #6887 (#6922)
fix(core): Fix `WindowBuilder::on_navigation` handler never registerd, closes #6865 (#6921)
fix(core): Fix `WindowBuilder::on_navigation` handler never registerd, closes #6865
fix broken symlinks in license files (#6336)
fix(cli): fix cli connection timeout to dev server (fix #6045) (#6046)
fix(bundler): ensure that there are no duplicate extension arguments when bundling on Windows, fixes #6103 (#6917)
fix(bundler): ensure that there are no duplicate extension arguments during bundling on Windows (fix #6103)
closes #5491 (#6408)
fix(nsis): prefill $INSTDIR with previous install path and respect `/D` flag, closes #6928 (#6935)
fix(nsis): prefill $INSTDIR with previous install path and respect `/D` flag, closes #6928
fix(updater): emit `UPTODATE` when server responds with 204, closes #6934 (#6970)
fix(core): unpin all dependencies, closes #6944 (#6966)
fix(bundler): Add new lang_file option in persian variant. (#6972)
fix(core/ipc): access url through webview native object, closes #6889 (#6976)
fix(core): remove trailing slash in http scope url, closes #5208 (#6974)
fix(core): remove trailing slash in http scope url, closes #5208
fix(cli): find correct binary when `--profile` is used, closes #6954 (#6979)
fix(cli): find correct binary when `--profile` is used, closes #6954
closes #6955 (#6987)
closes #6955
closes #6158 (#6969)
closes #6158
fix(cli): improve vs build tools detection (#6982)
fix: updated appimage script to follow symlinks for /usr/lib* (fix: #6992) (#6996)
fix(cli): correctly remove Cargo features (#7013)
Fix typo (#7012)
fix(cli): revert metadata.json field rename from #6795 (#7029)
closes #6732 (#6736)
fix: add missing file properties on Windows, closes #6676 (#6693)
fix(cli.js): detect node-20 binary (#6667)
fix version-or-publish workflow (#7031)
fix(cli/devserver): inject autoreload into HTML only, closes #6997 (#7032)
fix(bundler/nsis): write installer templates UTF16LE encoded, closes #7036 (#7040)
fix(bundler/nsis): write installer templates UTF16LE encoded, closes #7036
fix(core): rewrite `asset` protocol streaming, closes #6375 (#6390)
closes #5939 (#5960)
fix(core): use `safe_block_on` (#7047)
closes #6859 (#6933)
closes #6955 (#6998)
fix(core): populate webview_attrs from config, closes #6794 (#6797)
closes #5176 (#5180)
fix: sound for notifications on windows (fix #6652) (#6680)
close native window's buttons, closes #2353 (#6665)
fix(bundler/nsis): calculate accurate app size, closes #7056 (#7057)
fix(tests): only download update when it is available (#7061)
closes #6706 (#6712)
fix(doc): correct the doc of `content_protected()` (#7065)
closes #6472 (#6530)
fix(macros): use full path to Result to avoid issues with type aliases (#7071)
2023-05-30 03:29:24 +03:00
/// Note that you can move the manifest contents to a separate file and use `include_str!("manifest.xml")`
/// instead of the inline string.
///
2022-12-14 18:18:46 +03:00
/// [manifest]: https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests
#[ must_use ]
pub fn app_manifest < S : AsRef < str > > ( mut self , manifest : S ) -> Self {
self . app_manifest = Some ( manifest . as_ref ( ) . to_string ( ) ) ;
self
}
2021-05-03 16:42:29 +03:00
}
/// The attributes used on the build.
2021-08-11 08:07:39 +03:00
#[ derive(Debug, Default) ]
2021-05-03 16:42:29 +03:00
pub struct Attributes {
#[ allow(dead_code) ]
windows_attributes : WindowsAttributes ,
}
impl Attributes {
/// Creates the default attribute set.
pub fn new ( ) -> Self {
Self ::default ( )
}
/// Sets the icon to use on the window. Currently only used on Windows.
2022-01-17 16:46:14 +03:00
#[ must_use ]
2021-05-03 16:42:29 +03:00
pub fn windows_attributes ( mut self , windows_attributes : WindowsAttributes ) -> Self {
self . windows_attributes = windows_attributes ;
self
}
}
2021-03-13 04:10:19 +03:00
/// Run all build time helpers for your Tauri Application.
///
/// The current helpers include the following:
/// * Generates a Windows Resource file when targeting Windows.
///
/// # Platforms
///
/// [`build()`] should be called inside of `build.rs` regardless of the platform:
/// * New helpers may target more platforms in the future.
/// * Platform specific code is handled by the helpers automatically.
/// * A build script is required in order to activate some cargo environmental variables that are
/// used when generating code and embedding assets - so [`build()`] may as well be called.
///
/// In short, this is saying don't put the call to [`build()`] behind a `#[cfg(windows)]`.
///
/// # Panics
///
/// If any of the build time helpers fail, they will [`std::panic!`] with the related error message.
/// This is typically desirable when running inside a build script; see [`try_build`] for no panics.
pub fn build ( ) {
2021-05-03 16:42:29 +03:00
if let Err ( error ) = try_build ( Attributes ::default ( ) ) {
2022-12-15 23:56:23 +03:00
let error = format! ( " {error:#} " ) ;
println! ( " {error} " ) ;
2022-07-06 16:33:45 +03:00
if error . starts_with ( " unknown field " ) {
print! ( " found an unknown configuration field. This usually means that you are using a CLI version that is newer than `tauri-build` and is incompatible. " ) ;
println! (
" Please try updating the Rust crates by running `cargo update` in the Tauri app folder. "
) ;
}
std ::process ::exit ( 1 ) ;
2021-03-13 04:10:19 +03:00
}
}
/// Non-panicking [`build()`].
2021-05-03 16:42:29 +03:00
#[ allow(unused_variables) ]
pub fn try_build ( attributes : Attributes ) -> Result < ( ) > {
2022-01-09 16:55:09 +03:00
use anyhow ::anyhow ;
2022-04-27 02:02:06 +03:00
println! ( " cargo:rerun-if-env-changed=TAURI_CONFIG " ) ;
2022-02-03 16:15:32 +03:00
println! ( " cargo:rerun-if-changed=tauri.conf.json " ) ;
#[ cfg(feature = " config-json5 " ) ]
println! ( " cargo:rerun-if-changed=tauri.conf.json5 " ) ;
2022-08-02 20:12:26 +03:00
#[ cfg(feature = " config-toml " ) ]
println! ( " cargo:rerun-if-changed=Tauri.toml " ) ;
2022-02-03 16:15:32 +03:00
2022-08-02 17:25:28 +03:00
let target_os = std ::env ::var ( " CARGO_CFG_TARGET_OS " ) . unwrap ( ) ;
let mobile = target_os = = " ios " | | target_os = = " android " ;
cfg_alias ( " desktop " , ! mobile ) ;
cfg_alias ( " mobile " , mobile ) ;
2022-07-06 15:29:26 +03:00
let mut config = serde_json ::from_value ( tauri_utils ::config ::parse ::read_from (
2023-09-12 19:18:23 +03:00
tauri_utils ::platform ::Target ::from_triple ( & std ::env ::var ( " TARGET " ) . unwrap ( ) ) ,
2022-07-06 15:29:26 +03:00
std ::env ::current_dir ( ) . unwrap ( ) ,
) ? ) ? ;
if let Ok ( env ) = std ::env ::var ( " TAURI_CONFIG " ) {
let merge_config : serde_json ::Value = serde_json ::from_str ( & env ) ? ;
json_patch ::merge ( & mut config , & merge_config ) ;
}
let config : Config = serde_json ::from_value ( config ) ? ;
2022-01-09 16:55:09 +03:00
2022-08-21 16:35:34 +03:00
let s = config . tauri . bundle . identifier . split ( '.' ) ;
let last = s . clone ( ) . count ( ) - 1 ;
2022-12-28 00:12:01 +03:00
let mut android_package_prefix = String ::new ( ) ;
2022-08-21 16:35:34 +03:00
for ( i , w ) in s . enumerate ( ) {
2023-02-19 17:12:04 +03:00
if i = = 0 | | i ! = last {
2022-12-28 00:12:01 +03:00
android_package_prefix . push_str ( w ) ;
android_package_prefix . push ( '_' ) ;
2022-08-21 16:35:34 +03:00
}
}
2022-12-28 00:12:01 +03:00
android_package_prefix . pop ( ) ;
println! ( " cargo:rustc-env=TAURI_ANDROID_PACKAGE_PREFIX= {android_package_prefix} " ) ;
2022-08-21 16:35:34 +03:00
2023-02-22 19:57:19 +03:00
if let Some ( project_dir ) = var_os ( " TAURI_ANDROID_PROJECT_PATH " ) . map ( PathBuf ::from ) {
2023-05-16 16:22:46 +03:00
mobile ::generate_gradle_files ( project_dir ) ? ;
2023-02-22 19:57:19 +03:00
}
2022-05-25 16:51:33 +03:00
cfg_alias ( " dev " , ! has_feature ( " custom-protocol " ) ) ;
2023-01-26 16:47:23 +03:00
let ws_path = get_workspace_dir ( ) ? ;
let mut manifest =
Manifest ::< cargo_toml ::Value > ::from_slice_with_metadata ( & std ::fs ::read ( " Cargo.toml " ) ? ) ? ;
if let Ok ( ws_manifest ) = Manifest ::from_path ( ws_path . join ( " Cargo.toml " ) ) {
Manifest ::complete_from_path_and_workspace (
& mut manifest ,
Path ::new ( " Cargo.toml " ) ,
Some ( ( & ws_manifest , ws_path . as_path ( ) ) ) ,
) ? ;
} else {
Manifest ::complete_from_path ( & mut manifest , Path ::new ( " Cargo.toml " ) ) ? ;
}
2023-06-15 15:52:33 +03:00
allowlist ::check ( & config , & mut manifest ) ? ;
2022-01-09 16:55:09 +03:00
2022-02-08 19:13:21 +03:00
let target_triple = std ::env ::var ( " TARGET " ) . unwrap ( ) ;
2022-08-30 19:22:26 +03:00
2023-10-19 16:46:04 +03:00
println! ( " cargo:rustc-env=TAURI_ENV_TARGET_TRIPLE= {target_triple} " ) ;
2022-08-30 19:22:26 +03:00
2022-06-12 20:06:15 +03:00
let out_dir = PathBuf ::from ( std ::env ::var ( " OUT_DIR " ) . unwrap ( ) ) ;
2022-02-08 19:13:21 +03:00
// TODO: far from ideal, but there's no other way to get the target dir, see <https://github.com/rust-lang/cargo/issues/5457>
2022-06-12 20:06:15 +03:00
let target_dir = out_dir
2022-02-08 19:13:21 +03:00
. parent ( )
. unwrap ( )
. parent ( )
. unwrap ( )
. parent ( )
. unwrap ( ) ;
2022-05-13 16:39:04 +03:00
if let Some ( paths ) = & config . tauri . bundle . external_bin {
2022-02-08 19:13:21 +03:00
copy_binaries (
2022-05-13 16:39:04 +03:00
ResourcePaths ::new ( external_binaries ( paths , & target_triple ) . as_slice ( ) , true ) ,
2022-02-08 19:13:21 +03:00
& target_triple ,
target_dir ,
2022-08-02 16:37:16 +03:00
manifest . package . as_ref ( ) . map ( | p | & p . name ) ,
2022-02-08 19:13:21 +03:00
) ? ;
}
2022-04-19 23:33:17 +03:00
2022-06-14 23:50:15 +03:00
#[ allow(unused_mut, clippy::redundant_clone) ]
2022-05-13 16:39:04 +03:00
let mut resources = config . tauri . bundle . resources . clone ( ) . unwrap_or_default ( ) ;
2023-01-19 21:42:40 +03:00
if target_triple . contains ( " windows " ) {
if let Some ( fixed_webview2_runtime_path ) =
& config . tauri . bundle . windows . webview_fixed_runtime_path
{
resources . push ( fixed_webview2_runtime_path . display ( ) . to_string ( ) ) ;
}
2022-06-10 22:40:16 +03:00
}
2022-04-19 23:33:17 +03:00
copy_resources ( ResourcePaths ::new ( resources . as_slice ( ) , true ) , target_dir ) ? ;
2022-02-08 19:13:21 +03:00
2023-01-19 21:42:40 +03:00
if target_triple . contains ( " darwin " ) {
if let Some ( version ) = & config . tauri . bundle . macos . minimum_system_version {
2023-02-15 03:36:44 +03:00
println! ( " cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET= {version} " ) ;
2022-02-18 01:00:19 +03:00
}
}
2023-01-19 21:42:40 +03:00
if target_triple . contains ( " windows " ) {
2022-05-03 20:04:23 +03:00
use semver ::Version ;
2023-01-19 21:42:40 +03:00
use tauri_winres ::{ VersionInfo , WindowsResource } ;
2021-03-13 04:10:19 +03:00
2022-05-13 16:39:04 +03:00
fn find_icon < F : Fn ( & & String ) -> bool > ( config : & Config , predicate : F , default : & str ) -> PathBuf {
let icon_path = config
. tauri
. bundle
. icon
. iter ( )
. find ( | i | predicate ( i ) )
. cloned ( )
. unwrap_or_else ( | | default . to_string ( ) ) ;
icon_path . into ( )
}
let window_icon_path = attributes
2021-05-03 16:42:29 +03:00
. windows_attributes
. window_icon_path
2022-05-13 16:39:04 +03:00
. unwrap_or_else ( | | find_icon ( & config , | i | i . ends_with ( " .ico " ) , " icons/icon.ico " ) ) ;
2021-05-03 16:42:29 +03:00
2022-11-20 15:49:23 +03:00
if target_triple . contains ( " windows " ) {
if window_icon_path . exists ( ) {
let mut res = WindowsResource ::new ( ) ;
2022-08-03 00:53:34 +03:00
2023-02-15 03:36:44 +03:00
if let Some ( manifest ) = attributes . windows_attributes . app_manifest {
res . set_manifest ( & manifest ) ;
} else {
res . set_manifest ( include_str! ( " window-app-manifest.xml " ) ) ;
}
2022-11-20 15:49:23 +03:00
Merge remote-tracking branch 'origin/dev' into next (#7067)
Co-authored-by: wusyong <wusyong@users.noreply.github.com>
Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de>
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
Co-authored-by: Simon Hyll <hyllsimon@gmail.com>
Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>
Co-authored-by: Lucas Nogueira <lucas@tauri.app>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.studio>
Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: chip <chip@chip.sh>
Co-authored-by: Raphii <iam@raphii.co>
Co-authored-by: Ronie Martinez <ronmarti18@gmail.com>
Co-authored-by: hanaTsuk1 <101488209+hanaTsuk1@users.noreply.github.com>
Co-authored-by: nathan-fall <39990940+nathan-fall@users.noreply.github.com>
Co-authored-by: Akshay <nerdy@peppe.rs>
Co-authored-by: KurikoMoe <kurikomoe@gmail.com>
Co-authored-by: Guilherme Oenning <me@goenning.net>
Co-authored-by: Pierre Cashon <biaocy91@gmail.com>
Co-authored-by: Jack Wills <32690432+mrjackwills@users.noreply.github.com>
Co-authored-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
Co-authored-by: Risto Stevcev <me@risto.codes>
Co-authored-by: Soumt <rltks1305@naver.com>
Co-authored-by: yutotnh <57719497+yutotnh@users.noreply.github.com>
Co-authored-by: Gökçe Merdun <agmmnn@gmail.com>
Co-authored-by: Nathanael Rea <Nathan@NathanaelRea.com>
Co-authored-by: Usman Rajab <usman.rajab@gmail.com>
Co-authored-by: Francis The Basilisk <36006338+snorkysnark@users.noreply.github.com>
Co-authored-by: Lej77 <31554212+Lej77@users.noreply.github.com>
Co-authored-by: Tomáš Diblík <dibla.tomas@post.cz>
Co-authored-by: Jonas Kruckenberg <iterpre@protonmail.com>
Co-authored-by: Pascal Sommer <Pascal-So@users.noreply.github.com>
Co-authored-by: Bo <bertonzh@gmail.com>
Co-authored-by: Kevin Yue <k3vinyue@gmail.com>
fixed grammar and typos (#6937)
Fix api.js docs pipeline with updated typedoc dependencies (#6945)
closes #6887 (#6922)
fix(core): Fix `WindowBuilder::on_navigation` handler never registerd, closes #6865 (#6921)
fix(core): Fix `WindowBuilder::on_navigation` handler never registerd, closes #6865
fix broken symlinks in license files (#6336)
fix(cli): fix cli connection timeout to dev server (fix #6045) (#6046)
fix(bundler): ensure that there are no duplicate extension arguments when bundling on Windows, fixes #6103 (#6917)
fix(bundler): ensure that there are no duplicate extension arguments during bundling on Windows (fix #6103)
closes #5491 (#6408)
fix(nsis): prefill $INSTDIR with previous install path and respect `/D` flag, closes #6928 (#6935)
fix(nsis): prefill $INSTDIR with previous install path and respect `/D` flag, closes #6928
fix(updater): emit `UPTODATE` when server responds with 204, closes #6934 (#6970)
fix(core): unpin all dependencies, closes #6944 (#6966)
fix(bundler): Add new lang_file option in persian variant. (#6972)
fix(core/ipc): access url through webview native object, closes #6889 (#6976)
fix(core): remove trailing slash in http scope url, closes #5208 (#6974)
fix(core): remove trailing slash in http scope url, closes #5208
fix(cli): find correct binary when `--profile` is used, closes #6954 (#6979)
fix(cli): find correct binary when `--profile` is used, closes #6954
closes #6955 (#6987)
closes #6955
closes #6158 (#6969)
closes #6158
fix(cli): improve vs build tools detection (#6982)
fix: updated appimage script to follow symlinks for /usr/lib* (fix: #6992) (#6996)
fix(cli): correctly remove Cargo features (#7013)
Fix typo (#7012)
fix(cli): revert metadata.json field rename from #6795 (#7029)
closes #6732 (#6736)
fix: add missing file properties on Windows, closes #6676 (#6693)
fix(cli.js): detect node-20 binary (#6667)
fix version-or-publish workflow (#7031)
fix(cli/devserver): inject autoreload into HTML only, closes #6997 (#7032)
fix(bundler/nsis): write installer templates UTF16LE encoded, closes #7036 (#7040)
fix(bundler/nsis): write installer templates UTF16LE encoded, closes #7036
fix(core): rewrite `asset` protocol streaming, closes #6375 (#6390)
closes #5939 (#5960)
fix(core): use `safe_block_on` (#7047)
closes #6859 (#6933)
closes #6955 (#6998)
fix(core): populate webview_attrs from config, closes #6794 (#6797)
closes #5176 (#5180)
fix: sound for notifications on windows (fix #6652) (#6680)
close native window's buttons, closes #2353 (#6665)
fix(bundler/nsis): calculate accurate app size, closes #7056 (#7057)
fix(tests): only download update when it is available (#7061)
closes #6706 (#6712)
fix(doc): correct the doc of `content_protected()` (#7065)
closes #6472 (#6530)
fix(macros): use full path to Result to avoid issues with type aliases (#7071)
2023-05-30 03:29:24 +03:00
if let Some ( version_str ) = & config . package . version {
if let Ok ( v ) = Version ::parse ( version_str ) {
2022-11-20 15:49:23 +03:00
let version = v . major < < 48 | v . minor < < 32 | v . patch < < 16 ;
res . set_version_info ( VersionInfo ::FILEVERSION , version ) ;
res . set_version_info ( VersionInfo ::PRODUCTVERSION , version ) ;
}
Merge remote-tracking branch 'origin/dev' into next (#7067)
Co-authored-by: wusyong <wusyong@users.noreply.github.com>
Co-authored-by: Fabian-Lars <fabianlars@fabianlars.de>
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
Co-authored-by: Simon Hyll <hyllsimon@gmail.com>
Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>
Co-authored-by: Lucas Nogueira <lucas@tauri.app>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.studio>
Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: chip <chip@chip.sh>
Co-authored-by: Raphii <iam@raphii.co>
Co-authored-by: Ronie Martinez <ronmarti18@gmail.com>
Co-authored-by: hanaTsuk1 <101488209+hanaTsuk1@users.noreply.github.com>
Co-authored-by: nathan-fall <39990940+nathan-fall@users.noreply.github.com>
Co-authored-by: Akshay <nerdy@peppe.rs>
Co-authored-by: KurikoMoe <kurikomoe@gmail.com>
Co-authored-by: Guilherme Oenning <me@goenning.net>
Co-authored-by: Pierre Cashon <biaocy91@gmail.com>
Co-authored-by: Jack Wills <32690432+mrjackwills@users.noreply.github.com>
Co-authored-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
Co-authored-by: Risto Stevcev <me@risto.codes>
Co-authored-by: Soumt <rltks1305@naver.com>
Co-authored-by: yutotnh <57719497+yutotnh@users.noreply.github.com>
Co-authored-by: Gökçe Merdun <agmmnn@gmail.com>
Co-authored-by: Nathanael Rea <Nathan@NathanaelRea.com>
Co-authored-by: Usman Rajab <usman.rajab@gmail.com>
Co-authored-by: Francis The Basilisk <36006338+snorkysnark@users.noreply.github.com>
Co-authored-by: Lej77 <31554212+Lej77@users.noreply.github.com>
Co-authored-by: Tomáš Diblík <dibla.tomas@post.cz>
Co-authored-by: Jonas Kruckenberg <iterpre@protonmail.com>
Co-authored-by: Pascal Sommer <Pascal-So@users.noreply.github.com>
Co-authored-by: Bo <bertonzh@gmail.com>
Co-authored-by: Kevin Yue <k3vinyue@gmail.com>
fixed grammar and typos (#6937)
Fix api.js docs pipeline with updated typedoc dependencies (#6945)
closes #6887 (#6922)
fix(core): Fix `WindowBuilder::on_navigation` handler never registerd, closes #6865 (#6921)
fix(core): Fix `WindowBuilder::on_navigation` handler never registerd, closes #6865
fix broken symlinks in license files (#6336)
fix(cli): fix cli connection timeout to dev server (fix #6045) (#6046)
fix(bundler): ensure that there are no duplicate extension arguments when bundling on Windows, fixes #6103 (#6917)
fix(bundler): ensure that there are no duplicate extension arguments during bundling on Windows (fix #6103)
closes #5491 (#6408)
fix(nsis): prefill $INSTDIR with previous install path and respect `/D` flag, closes #6928 (#6935)
fix(nsis): prefill $INSTDIR with previous install path and respect `/D` flag, closes #6928
fix(updater): emit `UPTODATE` when server responds with 204, closes #6934 (#6970)
fix(core): unpin all dependencies, closes #6944 (#6966)
fix(bundler): Add new lang_file option in persian variant. (#6972)
fix(core/ipc): access url through webview native object, closes #6889 (#6976)
fix(core): remove trailing slash in http scope url, closes #5208 (#6974)
fix(core): remove trailing slash in http scope url, closes #5208
fix(cli): find correct binary when `--profile` is used, closes #6954 (#6979)
fix(cli): find correct binary when `--profile` is used, closes #6954
closes #6955 (#6987)
closes #6955
closes #6158 (#6969)
closes #6158
fix(cli): improve vs build tools detection (#6982)
fix: updated appimage script to follow symlinks for /usr/lib* (fix: #6992) (#6996)
fix(cli): correctly remove Cargo features (#7013)
Fix typo (#7012)
fix(cli): revert metadata.json field rename from #6795 (#7029)
closes #6732 (#6736)
fix: add missing file properties on Windows, closes #6676 (#6693)
fix(cli.js): detect node-20 binary (#6667)
fix version-or-publish workflow (#7031)
fix(cli/devserver): inject autoreload into HTML only, closes #6997 (#7032)
fix(bundler/nsis): write installer templates UTF16LE encoded, closes #7036 (#7040)
fix(bundler/nsis): write installer templates UTF16LE encoded, closes #7036
fix(core): rewrite `asset` protocol streaming, closes #6375 (#6390)
closes #5939 (#5960)
fix(core): use `safe_block_on` (#7047)
closes #6859 (#6933)
closes #6955 (#6998)
fix(core): populate webview_attrs from config, closes #6794 (#6797)
closes #5176 (#5180)
fix: sound for notifications on windows (fix #6652) (#6680)
close native window's buttons, closes #2353 (#6665)
fix(bundler/nsis): calculate accurate app size, closes #7056 (#7057)
fix(tests): only download update when it is available (#7061)
closes #6706 (#6712)
fix(doc): correct the doc of `content_protected()` (#7065)
closes #6472 (#6530)
fix(macros): use full path to Result to avoid issues with type aliases (#7071)
2023-05-30 03:29:24 +03:00
res . set ( " FileVersion " , version_str ) ;
res . set ( " ProductVersion " , version_str ) ;
2022-11-20 15:49:23 +03:00
}
2023-06-15 15:52:33 +03:00
if let Some ( product_name ) = & config . package . product_name {
res . set ( " ProductName " , product_name ) ;
}
if let Some ( short_description ) = & config . tauri . bundle . short_description {
res . set ( " FileDescription " , short_description ) ;
}
if let Some ( copyright ) = & config . tauri . bundle . copyright {
res . set ( " LegalCopyright " , copyright ) ;
}
res . set_icon_with_id ( & window_icon_path . display ( ) . to_string ( ) , " 32512 " ) ;
res . compile ( ) . with_context ( | | {
format! (
" failed to compile `{}` into a Windows Resource file during tauri-build " ,
window_icon_path . display ( )
)
} ) ? ;
2022-11-20 15:49:23 +03:00
} else {
return Err ( anyhow! ( format! (
" `{}` not found; required for generating a Windows Resource file during tauri-build " ,
2022-05-13 16:39:04 +03:00
window_icon_path . display ( )
2022-11-20 15:49:23 +03:00
) ) ) ;
}
2021-03-13 04:10:19 +03:00
}
2022-06-12 20:06:15 +03:00
let target_env = std ::env ::var ( " CARGO_CFG_TARGET_ENV " ) . unwrap ( ) ;
match target_env . as_str ( ) {
" gnu " = > {
let target_arch = match std ::env ::var ( " CARGO_CFG_TARGET_ARCH " ) . unwrap ( ) . as_str ( ) {
" x86_64 " = > Some ( " x64 " ) ,
" x86 " = > Some ( " x86 " ) ,
" aarch64 " = > Some ( " arm64 " ) ,
arch = > None ,
} ;
if let Some ( target_arch ) = target_arch {
for entry in std ::fs ::read_dir ( target_dir . join ( " build " ) ) ? {
let path = entry ? . path ( ) ;
let webview2_loader_path = path
. join ( " out " )
. join ( target_arch )
. join ( " WebView2Loader.dll " ) ;
if path . to_string_lossy ( ) . contains ( " webview2-com-sys " ) & & webview2_loader_path . exists ( )
{
std ::fs ::copy ( webview2_loader_path , target_dir . join ( " WebView2Loader.dll " ) ) ? ;
break ;
}
}
}
}
" msvc " = > {
if std ::env ::var ( " STATIC_VCRUNTIME " ) . map_or ( false , | v | v = = " true " ) {
static_vcruntime ::build ( ) ;
}
}
_ = > ( ) ,
}
2021-03-13 04:10:19 +03:00
}
Ok ( ( ) )
}
2022-02-04 19:37:23 +03:00
2023-01-26 16:47:23 +03:00
#[ derive(serde::Deserialize) ]
struct CargoMetadata {
workspace_root : PathBuf ,
}
fn get_workspace_dir ( ) -> Result < PathBuf > {
let output = std ::process ::Command ::new ( " cargo " )
. args ( [ " metadata " , " --no-deps " , " --format-version " , " 1 " ] )
. output ( ) ? ;
if ! output . status . success ( ) {
return Err ( anyhow ::anyhow! (
" cargo metadata command exited with a non zero exit code: {} " ,
String ::from_utf8 ( output . stderr ) ?
) ) ;
}
Ok ( serde_json ::from_slice ::< CargoMetadata > ( & output . stdout ) ? . workspace_root )
}