mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-08-17 03:40:23 +03:00
refactor(cli&bundler): avoid renaming main executable and preserve cargo name (#9375)
* refactor(cli&bundler): avoid renaming main executable and reserve cargo name closes #8109 closes #8349 * fix bundler * fix test * Discard changes to core/tauri-build/Cargo.toml * revert Cargo.toml changes * Discard changes to Cargo.lock * Discard changes to tooling/cli/Cargo.lock * lock file * use product name for installers * only warn for sign on windows --------- Co-authored-by: Lucas Nogueira <lucas@tauri.studio> Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>
This commit is contained in:
parent
e8f6eb59a5
commit
265c23886e
7
.changes/cli-perserve-cargo-bin-name.md
Normal file
7
.changes/cli-perserve-cargo-bin-name.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
"tauri-cli": "patch:breaking"
|
||||||
|
"@tauri-apps/cli": "patch:breaking"
|
||||||
|
---
|
||||||
|
|
||||||
|
Avoid renaming main binary to product name and perserve the name generated by cargo.
|
||||||
|
|
6
.changes/tauri-utils-package-name-removed.md
Normal file
6
.changes/tauri-utils-package-name-removed.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"tauri-utils": "patch:breaking"
|
||||||
|
---
|
||||||
|
|
||||||
|
Removed `Config::binary_name` and `PackageInfo::package_name`
|
||||||
|
|
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -3720,7 +3720,6 @@ dependencies = [
|
|||||||
"dunce",
|
"dunce",
|
||||||
"getrandom 0.2.12",
|
"getrandom 0.2.12",
|
||||||
"glob",
|
"glob",
|
||||||
"heck 0.5.0",
|
|
||||||
"html5ever",
|
"html5ever",
|
||||||
"infer",
|
"infer",
|
||||||
"json-patch",
|
"json-patch",
|
||||||
|
@ -43,9 +43,6 @@ dunce = "1"
|
|||||||
log = "0.4.21"
|
log = "0.4.21"
|
||||||
cargo_metadata = { version = "0.18", optional = true }
|
cargo_metadata = { version = "0.18", optional = true }
|
||||||
|
|
||||||
[target."cfg(target_os = \"linux\")".dependencies]
|
|
||||||
heck = "0.5"
|
|
||||||
|
|
||||||
[target."cfg(target_os = \"macos\")".dependencies]
|
[target."cfg(target_os = \"macos\")".dependencies]
|
||||||
swift-rs = { version = "1.0.6", optional = true, features = [ "build" ] }
|
swift-rs = { version = "1.0.6", optional = true, features = [ "build" ] }
|
||||||
|
|
||||||
|
@ -10,8 +10,6 @@
|
|||||||
//! This is a core functionality that is not considered part of the stable API.
|
//! This is a core functionality that is not considered part of the stable API.
|
||||||
//! If you use it, note that it may include breaking changes in the future.
|
//! If you use it, note that it may include breaking changes in the future.
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
use heck::ToKebabCase;
|
|
||||||
#[cfg(feature = "schema")]
|
#[cfg(feature = "schema")]
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use semver::Version;
|
use semver::Version;
|
||||||
@ -2115,21 +2113,6 @@ pub struct Config {
|
|||||||
pub plugins: PluginConfig,
|
pub plugins: PluginConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
|
||||||
/// The binary name. Returns the product name as kebab-case on Linux,
|
|
||||||
/// and returns it as is on all other platforms.
|
|
||||||
pub fn binary_name(&self) -> Option<String> {
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
{
|
|
||||||
self.product_name.as_ref().map(|n| n.to_kebab_case())
|
|
||||||
}
|
|
||||||
#[cfg(not(target_os = "linux"))]
|
|
||||||
{
|
|
||||||
self.product_name.clone()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The plugin configs holds a HashMap mapping a plugin name to its configuration object.
|
/// The plugin configs holds a HashMap mapping a plugin name to its configuration object.
|
||||||
///
|
///
|
||||||
/// See more: <https://tauri.app/v1/api/config#pluginconfig>
|
/// See more: <https://tauri.app/v1/api/config#pluginconfig>
|
||||||
|
@ -57,20 +57,6 @@ pub struct PackageInfo {
|
|||||||
pub crate_name: &'static str,
|
pub crate_name: &'static str,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PackageInfo {
|
|
||||||
/// Returns the application package name.
|
|
||||||
/// On macOS and Windows it's the `name` field, and on Linux it's the `name` in `kebab-case`.
|
|
||||||
pub fn package_name(&self) -> String {
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
{
|
|
||||||
use heck::ToKebabCase;
|
|
||||||
self.name.clone().to_kebab_case()
|
|
||||||
}
|
|
||||||
#[cfg(not(target_os = "linux"))]
|
|
||||||
self.name.clone()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
mod window_effects {
|
mod window_effects {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -292,7 +292,7 @@ fn resource_dir_from<P: AsRef<Path>>(
|
|||||||
res = if curr_dir.ends_with("/data/usr/bin") {
|
res = if curr_dir.ends_with("/data/usr/bin") {
|
||||||
// running from the deb bundle dir
|
// running from the deb bundle dir
|
||||||
exe_dir
|
exe_dir
|
||||||
.join(format!("../lib/{}", package_info.package_name()))
|
.join(format!("../lib/{}", package_info.crate_name))
|
||||||
.canonicalize()
|
.canonicalize()
|
||||||
.map_err(Into::into)
|
.map_err(Into::into)
|
||||||
} else if let Some(appdir) = &env.appdir {
|
} else if let Some(appdir) = &env.appdir {
|
||||||
@ -300,13 +300,13 @@ fn resource_dir_from<P: AsRef<Path>>(
|
|||||||
Ok(PathBuf::from(format!(
|
Ok(PathBuf::from(format!(
|
||||||
"{}/usr/lib/{}",
|
"{}/usr/lib/{}",
|
||||||
appdir.display(),
|
appdir.display(),
|
||||||
package_info.package_name()
|
package_info.crate_name
|
||||||
)))
|
)))
|
||||||
} else {
|
} else {
|
||||||
// running bundle
|
// running bundle
|
||||||
Ok(PathBuf::from(format!(
|
Ok(PathBuf::from(format!(
|
||||||
"/usr/lib/{}",
|
"/usr/lib/{}",
|
||||||
package_info.package_name()
|
package_info.crate_name
|
||||||
)))
|
)))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -357,7 +357,7 @@ mod tests {
|
|||||||
version: "1.0.0".parse().unwrap(),
|
version: "1.0.0".parse().unwrap(),
|
||||||
authors: "",
|
authors: "",
|
||||||
description: "",
|
description: "",
|
||||||
crate_name: "",
|
crate_name: "my-app",
|
||||||
};
|
};
|
||||||
let env = Env::default();
|
let env = Env::default();
|
||||||
|
|
||||||
|
@ -1991,16 +1991,7 @@ tauri::Builder::default()
|
|||||||
.set_progress_bar(crate::runtime::ProgressBarState {
|
.set_progress_bar(crate::runtime::ProgressBarState {
|
||||||
status: progress_state.status,
|
status: progress_state.status,
|
||||||
progress: progress_state.progress,
|
progress: progress_state.progress,
|
||||||
desktop_filename: Some(format!(
|
desktop_filename: Some(format!("{}.desktop", self.package_info().crate_name)),
|
||||||
"{}.desktop",
|
|
||||||
heck::AsKebabCase(
|
|
||||||
self
|
|
||||||
.config()
|
|
||||||
.product_name
|
|
||||||
.as_deref()
|
|
||||||
.unwrap_or_else(|| self.package_info().crate_name)
|
|
||||||
)
|
|
||||||
)),
|
|
||||||
})
|
})
|
||||||
.map_err(Into::into)
|
.map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
1
examples/api/src-tauri/Cargo.lock
generated
1
examples/api/src-tauri/Cargo.lock
generated
@ -3189,7 +3189,6 @@ dependencies = [
|
|||||||
"dunce",
|
"dunce",
|
||||||
"getrandom 0.2.15",
|
"getrandom 0.2.15",
|
||||||
"glob",
|
"glob",
|
||||||
"heck 0.5.0",
|
|
||||||
"html5ever",
|
"html5ever",
|
||||||
"infer",
|
"infer",
|
||||||
"json-patch",
|
"json-patch",
|
||||||
|
@ -63,35 +63,38 @@ pub fn bundle_project(settings: Settings) -> crate::Result<Vec<Bundle>> {
|
|||||||
log::warn!("Cross-platform compilation is experimental and does not support all features. Please use a matching host system for full compatibility.");
|
log::warn!("Cross-platform compilation is experimental and does not support all features. Please use a matching host system for full compatibility.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if settings.can_sign() {
|
// Sign windows binaries before the bundling step in case neither wix and nsis bundles are enabled
|
||||||
// Sign windows binaries before the bundling step in case neither wix and nsis bundles are enabled
|
if target_os == "windows" {
|
||||||
for bin in settings.binaries() {
|
if settings.can_sign() {
|
||||||
let bin_path = settings.binary_path(bin);
|
for bin in settings.binaries() {
|
||||||
windows::sign::try_sign(&bin_path, &settings)?;
|
let bin_path = settings.binary_path(bin);
|
||||||
}
|
windows::sign::try_sign(&bin_path, &settings)?;
|
||||||
|
|
||||||
// Sign the sidecar binaries
|
|
||||||
for bin in settings.external_binaries() {
|
|
||||||
let path = bin?;
|
|
||||||
let skip = std::env::var("TAURI_SKIP_SIDECAR_SIGNATURE_CHECK").map_or(false, |v| v == "true");
|
|
||||||
if skip {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
// Sign the sidecar binaries
|
||||||
if windows::sign::verify(&path)? {
|
for bin in settings.external_binaries() {
|
||||||
log::info!(
|
let path = bin?;
|
||||||
"sidecar at \"{}\" already signed. Skipping...",
|
let skip =
|
||||||
path.display()
|
std::env::var("TAURI_SKIP_SIDECAR_SIGNATURE_CHECK").map_or(false, |v| v == "true");
|
||||||
);
|
if skip {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
windows::sign::try_sign(&path, &settings)?;
|
#[cfg(windows)]
|
||||||
|
if windows::sign::verify(&path)? {
|
||||||
|
log::info!(
|
||||||
|
"sidecar at \"{}\" already signed. Skipping...",
|
||||||
|
path.display()
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
windows::sign::try_sign(&path, &settings)?;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
log::warn!("Signing, by default, is only supported on Windows hosts, but you can specify a custom signing command in `bundler > windows > sign_command`, for now, skipping signing the installer...");
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
|
||||||
log::warn!("Signing, by default, is only supported on Windows hosts, but you can specify a custom signing command in `bundler > windows > sign_command`, for now, skipping signing the installer...");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for package_type in &package_types {
|
for package_type in &package_types {
|
||||||
|
@ -42,22 +42,22 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
|||||||
remove_dir_all(&output_path)?;
|
remove_dir_all(&output_path)?;
|
||||||
}
|
}
|
||||||
std::fs::create_dir_all(output_path.clone())?;
|
std::fs::create_dir_all(output_path.clone())?;
|
||||||
let app_dir_path = output_path.join(format!("{}.AppDir", settings.main_binary_name()));
|
let app_dir_path = output_path.join(format!("{}.AppDir", settings.product_name()));
|
||||||
let appimage_filename = format!(
|
let appimage_filename = format!(
|
||||||
"{}_{}_{}.AppImage",
|
"{}_{}_{}.AppImage",
|
||||||
settings.main_binary_name(),
|
settings.product_name(),
|
||||||
settings.version_string(),
|
settings.version_string(),
|
||||||
arch
|
arch
|
||||||
);
|
);
|
||||||
let appimage_path = output_path.join(&appimage_filename);
|
let appimage_path = output_path.join(&appimage_filename);
|
||||||
path_utils::create(app_dir_path, true)?;
|
path_utils::create(app_dir_path, true)?;
|
||||||
|
|
||||||
let upcase_app_name = settings.main_binary_name().to_uppercase();
|
let upcase_app_name = settings.product_name().to_uppercase();
|
||||||
|
|
||||||
// setup data to insert into shell script
|
// setup data to insert into shell script
|
||||||
let mut sh_map = BTreeMap::new();
|
let mut sh_map = BTreeMap::new();
|
||||||
sh_map.insert("arch", settings.target().split('-').next().unwrap());
|
sh_map.insert("arch", settings.target().split('-').next().unwrap());
|
||||||
sh_map.insert("app_name", settings.main_binary_name());
|
sh_map.insert("app_name", settings.product_name());
|
||||||
sh_map.insert("app_name_uppercase", &upcase_app_name);
|
sh_map.insert("app_name_uppercase", &upcase_app_name);
|
||||||
sh_map.insert("appimage_filename", &appimage_filename);
|
sh_map.insert("appimage_filename", &appimage_filename);
|
||||||
let tauri_tools_path = dirs_next::cache_dir().map_or_else(
|
let tauri_tools_path = dirs_next::cache_dir().map_or_else(
|
||||||
|
@ -27,7 +27,6 @@ use super::{super::common, freedesktop};
|
|||||||
use crate::Settings;
|
use crate::Settings;
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use flate2::{write::GzEncoder, Compression};
|
use flate2::{write::GzEncoder, Compression};
|
||||||
use heck::AsKebabCase;
|
|
||||||
use tar::HeaderMode;
|
use tar::HeaderMode;
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
@ -51,7 +50,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
|||||||
};
|
};
|
||||||
let package_base_name = format!(
|
let package_base_name = format!(
|
||||||
"{}_{}_{}",
|
"{}_{}_{}",
|
||||||
settings.main_binary_name(),
|
settings.product_name(),
|
||||||
settings.version_string(),
|
settings.version_string(),
|
||||||
arch
|
arch
|
||||||
);
|
);
|
||||||
@ -158,7 +157,8 @@ fn generate_control_file(
|
|||||||
// https://www.debian.org/doc/debian-policy/ch-controlfields.html
|
// https://www.debian.org/doc/debian-policy/ch-controlfields.html
|
||||||
let dest_path = control_dir.join("control");
|
let dest_path = control_dir.join("control");
|
||||||
let mut file = common::create_file(&dest_path)?;
|
let mut file = common::create_file(&dest_path)?;
|
||||||
writeln!(file, "Package: {}", AsKebabCase(settings.product_name()))?;
|
let package = heck::AsKebabCase(settings.product_name());
|
||||||
|
writeln!(file, "Package: {}", package)?;
|
||||||
writeln!(file, "Version: {}", settings.version_string())?;
|
writeln!(file, "Version: {}", settings.version_string())?;
|
||||||
writeln!(file, "Architecture: {arch}")?;
|
writeln!(file, "Architecture: {arch}")?;
|
||||||
// Installed-Size must be divided by 1024, see https://www.debian.org/doc/debian-policy/ch-controlfields.html#installed-size
|
// Installed-Size must be divided by 1024, see https://www.debian.org/doc/debian-policy/ch-controlfields.html#installed-size
|
||||||
|
@ -80,7 +80,7 @@ pub fn list_icon_files(
|
|||||||
|
|
||||||
/// Generate the icon files and store them under the `data_dir`.
|
/// Generate the icon files and store them under the `data_dir`.
|
||||||
pub fn copy_icon_files(settings: &Settings, data_dir: &Path) -> crate::Result<Vec<Icon>> {
|
pub fn copy_icon_files(settings: &Settings, data_dir: &Path) -> crate::Result<Vec<Icon>> {
|
||||||
let icons = self::list_icon_files(settings, data_dir)?;
|
let icons = list_icon_files(settings, data_dir)?;
|
||||||
for (icon, src) in &icons {
|
for (icon, src) in &icons {
|
||||||
common::copy_file(src, &icon.path)?;
|
common::copy_file(src, &icon.path)?;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ pub fn bundle_project(settings: &Settings, bundles: &[Bundle]) -> crate::Result<
|
|||||||
let output_path = settings.project_out_directory().join("bundle/dmg");
|
let output_path = settings.project_out_directory().join("bundle/dmg");
|
||||||
let package_base_name = format!(
|
let package_base_name = format!(
|
||||||
"{}_{}_{}",
|
"{}_{}_{}",
|
||||||
settings.main_binary_name(),
|
settings.product_name(),
|
||||||
settings.version_string(),
|
settings.version_string(),
|
||||||
match settings.binary_arch() {
|
match settings.binary_arch() {
|
||||||
"x86_64" => "x64",
|
"x86_64" => "x64",
|
||||||
@ -50,7 +50,7 @@ pub fn bundle_project(settings: &Settings, bundles: &[Bundle]) -> crate::Result<
|
|||||||
let dmg_name = format!("{}.dmg", &package_base_name);
|
let dmg_name = format!("{}.dmg", &package_base_name);
|
||||||
let dmg_path = output_path.join(&dmg_name);
|
let dmg_path = output_path.join(&dmg_name);
|
||||||
|
|
||||||
let product_name = settings.main_binary_name();
|
let product_name = settings.product_name();
|
||||||
let bundle_file_name = format!("{}.app", product_name);
|
let bundle_file_name = format!("{}.app", product_name);
|
||||||
let bundle_dir = settings.project_out_directory().join("bundle/macos");
|
let bundle_dir = settings.project_out_directory().join("bundle/macos");
|
||||||
|
|
||||||
|
@ -606,6 +606,15 @@ impl BundleBinary {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates a new bundle binary with path.
|
||||||
|
pub fn with_path(name: String, main: bool, src_path: Option<String>) -> Self {
|
||||||
|
Self {
|
||||||
|
name,
|
||||||
|
src_path,
|
||||||
|
main,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Sets the src path of the binary.
|
/// Sets the src path of the binary.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn set_src_path(mut self, src_path: Option<String>) -> Self {
|
pub fn set_src_path(mut self, src_path: Option<String>) -> Self {
|
||||||
|
@ -21,7 +21,7 @@ use regex::Regex;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{
|
use std::{
|
||||||
collections::{BTreeMap, HashMap, HashSet},
|
collections::{BTreeMap, HashMap, HashSet},
|
||||||
fs::{create_dir_all, read_to_string, remove_dir_all, rename, write, File},
|
fs::{self, File},
|
||||||
io::Write,
|
io::Write,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
process::Command,
|
process::Command,
|
||||||
@ -155,7 +155,7 @@ fn copy_icon(settings: &Settings, filename: &str, path: &Path) -> crate::Result<
|
|||||||
let base_dir = settings.project_out_directory();
|
let base_dir = settings.project_out_directory();
|
||||||
|
|
||||||
let resource_dir = base_dir.join("resources");
|
let resource_dir = base_dir.join("resources");
|
||||||
create_dir_all(&resource_dir)?;
|
fs::create_dir_all(&resource_dir)?;
|
||||||
let icon_target_path = resource_dir.join(filename);
|
let icon_target_path = resource_dir.join(filename);
|
||||||
|
|
||||||
let icon_path = std::env::current_dir()?.join(path);
|
let icon_path = std::env::current_dir()?.join(path);
|
||||||
@ -192,7 +192,7 @@ fn app_installer_output_path(
|
|||||||
|
|
||||||
let package_base_name = format!(
|
let package_base_name = format!(
|
||||||
"{}_{}_{}_{}",
|
"{}_{}_{}_{}",
|
||||||
settings.main_binary_name().replace(".exe", ""),
|
settings.product_name(),
|
||||||
version,
|
version,
|
||||||
arch,
|
arch,
|
||||||
language,
|
language,
|
||||||
@ -411,9 +411,9 @@ pub fn build_wix_app_installer(
|
|||||||
let output_path = settings.project_out_directory().join("wix").join(arch);
|
let output_path = settings.project_out_directory().join("wix").join(arch);
|
||||||
|
|
||||||
if output_path.exists() {
|
if output_path.exists() {
|
||||||
remove_dir_all(&output_path)?;
|
fs::remove_dir_all(&output_path)?;
|
||||||
}
|
}
|
||||||
create_dir_all(&output_path)?;
|
fs::create_dir_all(&output_path)?;
|
||||||
|
|
||||||
let mut data = BTreeMap::new();
|
let mut data = BTreeMap::new();
|
||||||
|
|
||||||
@ -484,7 +484,7 @@ pub fn build_wix_app_installer(
|
|||||||
if license.ends_with(".rtf") {
|
if license.ends_with(".rtf") {
|
||||||
data.insert("license", to_json(license));
|
data.insert("license", to_json(license));
|
||||||
} else {
|
} else {
|
||||||
let license_contents = read_to_string(license)?;
|
let license_contents = fs::read_to_string(license)?;
|
||||||
let license_rtf = format!(
|
let license_rtf = format!(
|
||||||
r#"{{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{{\fonttbl{{\f0\fnil\fcharset0 Calibri;}}}}
|
r#"{{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{{\fonttbl{{\f0\fnil\fcharset0 Calibri;}}}}
|
||||||
{{\*\generator Riched20 10.0.18362}}\viewkind4\uc1
|
{{\*\generator Riched20 10.0.18362}}\viewkind4\uc1
|
||||||
@ -629,7 +629,7 @@ pub fn build_wix_app_installer(
|
|||||||
|
|
||||||
if let Some(path) = custom_template_path {
|
if let Some(path) = custom_template_path {
|
||||||
handlebars
|
handlebars
|
||||||
.register_template_string("main.wxs", read_to_string(path)?)
|
.register_template_string("main.wxs", fs::read_to_string(path)?)
|
||||||
.map_err(|e| e.to_string())
|
.map_err(|e| e.to_string())
|
||||||
.expect("Failed to setup custom handlebar template");
|
.expect("Failed to setup custom handlebar template");
|
||||||
} else {
|
} else {
|
||||||
@ -660,7 +660,7 @@ pub fn build_wix_app_installer(
|
|||||||
.expect("Failed to setup Update Task handlebars");
|
.expect("Failed to setup Update Task handlebars");
|
||||||
let temp_xml_path = output_path.join("update.xml");
|
let temp_xml_path = output_path.join("update.xml");
|
||||||
let update_content = skip_uac_task.render("update.xml", &data)?;
|
let update_content = skip_uac_task.render("update.xml", &data)?;
|
||||||
write(temp_xml_path, update_content)?;
|
fs::write(temp_xml_path, update_content)?;
|
||||||
|
|
||||||
// Create the Powershell script to install the task
|
// Create the Powershell script to install the task
|
||||||
let mut skip_uac_task_installer = Handlebars::new();
|
let mut skip_uac_task_installer = Handlebars::new();
|
||||||
@ -672,7 +672,7 @@ pub fn build_wix_app_installer(
|
|||||||
.expect("Failed to setup Update Task Installer handlebars");
|
.expect("Failed to setup Update Task Installer handlebars");
|
||||||
let temp_ps1_path = output_path.join("install-task.ps1");
|
let temp_ps1_path = output_path.join("install-task.ps1");
|
||||||
let install_script_content = skip_uac_task_installer.render("install-task.ps1", &data)?;
|
let install_script_content = skip_uac_task_installer.render("install-task.ps1", &data)?;
|
||||||
write(temp_ps1_path, install_script_content)?;
|
fs::write(temp_ps1_path, install_script_content)?;
|
||||||
|
|
||||||
// Create the Powershell script to uninstall the task
|
// Create the Powershell script to uninstall the task
|
||||||
let mut skip_uac_task_uninstaller = Handlebars::new();
|
let mut skip_uac_task_uninstaller = Handlebars::new();
|
||||||
@ -684,13 +684,13 @@ pub fn build_wix_app_installer(
|
|||||||
.expect("Failed to setup Update Task Uninstaller handlebars");
|
.expect("Failed to setup Update Task Uninstaller handlebars");
|
||||||
let temp_ps1_path = output_path.join("uninstall-task.ps1");
|
let temp_ps1_path = output_path.join("uninstall-task.ps1");
|
||||||
let install_script_content = skip_uac_task_uninstaller.render("uninstall-task.ps1", &data)?;
|
let install_script_content = skip_uac_task_uninstaller.render("uninstall-task.ps1", &data)?;
|
||||||
write(temp_ps1_path, install_script_content)?;
|
fs::write(temp_ps1_path, install_script_content)?;
|
||||||
|
|
||||||
data.insert("enable_elevated_update_task", to_json(true));
|
data.insert("enable_elevated_update_task", to_json(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
let main_wxs_path = output_path.join("main.wxs");
|
let main_wxs_path = output_path.join("main.wxs");
|
||||||
write(main_wxs_path, handlebars.render("main.wxs", &data)?)?;
|
fs::write(main_wxs_path, handlebars.render("main.wxs", &data)?)?;
|
||||||
|
|
||||||
let mut candle_inputs = vec![("main.wxs".into(), Vec::new())];
|
let mut candle_inputs = vec![("main.wxs".into(), Vec::new())];
|
||||||
|
|
||||||
@ -698,7 +698,7 @@ pub fn build_wix_app_installer(
|
|||||||
let extension_regex = Regex::new("\"http://schemas.microsoft.com/wix/(\\w+)\"")?;
|
let extension_regex = Regex::new("\"http://schemas.microsoft.com/wix/(\\w+)\"")?;
|
||||||
for fragment_path in fragment_paths {
|
for fragment_path in fragment_paths {
|
||||||
let fragment_path = current_dir.join(fragment_path);
|
let fragment_path = current_dir.join(fragment_path);
|
||||||
let fragment = read_to_string(&fragment_path)?;
|
let fragment = fs::read_to_string(&fragment_path)?;
|
||||||
let mut extensions = Vec::new();
|
let mut extensions = Vec::new();
|
||||||
for cap in extension_regex.captures_iter(&fragment) {
|
for cap in extension_regex.captures_iter(&fragment) {
|
||||||
extensions.push(wix_toolset_path.join(format!("Wix{}.dll", &cap[1])));
|
extensions.push(wix_toolset_path.join(format!("Wix{}.dll", &cap[1])));
|
||||||
@ -734,7 +734,7 @@ pub fn build_wix_app_installer(
|
|||||||
});
|
});
|
||||||
|
|
||||||
let locale_contents = match language_config.locale_path {
|
let locale_contents = match language_config.locale_path {
|
||||||
Some(p) => read_to_string(p)?,
|
Some(p) => fs::read_to_string(p)?,
|
||||||
None => format!(
|
None => format!(
|
||||||
r#"<WixLocalization Culture="{}" xmlns="http://schemas.microsoft.com/wix/2006/localization"></WixLocalization>"#,
|
r#"<WixLocalization Culture="{}" xmlns="http://schemas.microsoft.com/wix/2006/localization"></WixLocalization>"#,
|
||||||
language.to_lowercase(),
|
language.to_lowercase(),
|
||||||
@ -786,7 +786,7 @@ pub fn build_wix_app_installer(
|
|||||||
let msi_output_path = output_path.join("output.msi");
|
let msi_output_path = output_path.join("output.msi");
|
||||||
let msi_path =
|
let msi_path =
|
||||||
app_installer_output_path(settings, &language, settings.version_string(), updater)?;
|
app_installer_output_path(settings, &language, settings.version_string(), updater)?;
|
||||||
create_dir_all(msi_path.parent().unwrap())?;
|
fs::create_dir_all(msi_path.parent().unwrap())?;
|
||||||
|
|
||||||
log::info!(action = "Running"; "light to produce {}", display_path(&msi_path));
|
log::info!(action = "Running"; "light to produce {}", display_path(&msi_path));
|
||||||
|
|
||||||
@ -797,7 +797,7 @@ pub fn build_wix_app_installer(
|
|||||||
&(fragment_extensions.clone().into_iter().collect()),
|
&(fragment_extensions.clone().into_iter().collect()),
|
||||||
&msi_output_path,
|
&msi_output_path,
|
||||||
)?;
|
)?;
|
||||||
rename(&msi_output_path, &msi_path)?;
|
fs::rename(&msi_output_path, &msi_path)?;
|
||||||
|
|
||||||
if settings.can_sign() {
|
if settings.can_sign() {
|
||||||
try_sign(&msi_path, settings)?;
|
try_sign(&msi_path, settings)?;
|
||||||
|
@ -22,7 +22,7 @@ use tauri_utils::config::{NSISInstallerMode, NsisCompression, WebviewInstallMode
|
|||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::{BTreeMap, HashMap},
|
collections::{BTreeMap, HashMap},
|
||||||
fs::{create_dir_all, remove_dir_all, rename, write},
|
fs,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
process::Command,
|
process::Command,
|
||||||
};
|
};
|
||||||
@ -67,7 +67,7 @@ pub fn bundle_project(settings: &Settings, updater: bool) -> crate::Result<Vec<P
|
|||||||
let nsis_toolset_path = tauri_tools_path.join("NSIS");
|
let nsis_toolset_path = tauri_tools_path.join("NSIS");
|
||||||
|
|
||||||
if !nsis_toolset_path.exists() {
|
if !nsis_toolset_path.exists() {
|
||||||
create_dir_all(&nsis_toolset_path)?;
|
fs::create_dir_all(&nsis_toolset_path)?;
|
||||||
get_and_extract_nsis(&nsis_toolset_path, &tauri_tools_path)?;
|
get_and_extract_nsis(&nsis_toolset_path, &tauri_tools_path)?;
|
||||||
} else if NSIS_REQUIRED_FILES
|
} else if NSIS_REQUIRED_FILES
|
||||||
.iter()
|
.iter()
|
||||||
@ -88,7 +88,7 @@ pub fn bundle_project(settings: &Settings, updater: bool) -> crate::Result<Vec<P
|
|||||||
log::warn!("NSIS directory contains mis-hashed files. Redownloading them.");
|
log::warn!("NSIS directory contains mis-hashed files. Redownloading them.");
|
||||||
for (path, url, hash, hash_algorithim) in mismatched {
|
for (path, url, hash, hash_algorithim) in mismatched {
|
||||||
let data = download_and_verify(url, hash, *hash_algorithim)?;
|
let data = download_and_verify(url, hash, *hash_algorithim)?;
|
||||||
write(nsis_toolset_path.join(path), data)?;
|
fs::write(nsis_toolset_path.join(path), data)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,7 +105,7 @@ fn get_and_extract_nsis(nsis_toolset_path: &Path, _tauri_tools_path: &Path) -> c
|
|||||||
let data = download_and_verify(NSIS_URL, NSIS_SHA1, HashAlgorithm::Sha1)?;
|
let data = download_and_verify(NSIS_URL, NSIS_SHA1, HashAlgorithm::Sha1)?;
|
||||||
log::info!("extracting NSIS");
|
log::info!("extracting NSIS");
|
||||||
crate::bundle::windows::util::extract_zip(&data, _tauri_tools_path)?;
|
crate::bundle::windows::util::extract_zip(&data, _tauri_tools_path)?;
|
||||||
rename(_tauri_tools_path.join("nsis-3.08"), nsis_toolset_path)?;
|
fs::rename(_tauri_tools_path.join("nsis-3.08"), nsis_toolset_path)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let nsis_plugins = nsis_toolset_path.join("Plugins");
|
let nsis_plugins = nsis_toolset_path.join("Plugins");
|
||||||
@ -117,8 +117,8 @@ fn get_and_extract_nsis(nsis_toolset_path: &Path, _tauri_tools_path: &Path) -> c
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
let target_folder = nsis_plugins.join("x86-unicode");
|
let target_folder = nsis_plugins.join("x86-unicode");
|
||||||
create_dir_all(&target_folder)?;
|
fs::create_dir_all(&target_folder)?;
|
||||||
write(target_folder.join("nsis_tauri_utils.dll"), data)?;
|
fs::write(target_folder.join("nsis_tauri_utils.dll"), data)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -164,9 +164,9 @@ fn build_nsis_app_installer(
|
|||||||
|
|
||||||
let output_path = settings.project_out_directory().join("nsis").join(arch);
|
let output_path = settings.project_out_directory().join("nsis").join(arch);
|
||||||
if output_path.exists() {
|
if output_path.exists() {
|
||||||
remove_dir_all(&output_path)?;
|
fs::remove_dir_all(&output_path)?;
|
||||||
}
|
}
|
||||||
create_dir_all(&output_path)?;
|
fs::create_dir_all(&output_path)?;
|
||||||
|
|
||||||
let mut data = BTreeMap::new();
|
let mut data = BTreeMap::new();
|
||||||
|
|
||||||
@ -475,7 +475,7 @@ fn build_nsis_app_installer(
|
|||||||
|
|
||||||
let package_base_name = format!(
|
let package_base_name = format!(
|
||||||
"{}_{}_{}-setup",
|
"{}_{}_{}-setup",
|
||||||
main_binary.name().replace(".exe", ""),
|
settings.product_name(),
|
||||||
settings.version_string(),
|
settings.version_string(),
|
||||||
arch,
|
arch,
|
||||||
);
|
);
|
||||||
@ -490,7 +490,7 @@ fn build_nsis_app_installer(
|
|||||||
},
|
},
|
||||||
package_base_name
|
package_base_name
|
||||||
));
|
));
|
||||||
create_dir_all(nsis_installer_path.parent().unwrap())?;
|
fs::create_dir_all(nsis_installer_path.parent().unwrap())?;
|
||||||
|
|
||||||
log::info!(action = "Running"; "makensis.exe to produce {}", display_path(&nsis_installer_path));
|
log::info!(action = "Running"; "makensis.exe to produce {}", display_path(&nsis_installer_path));
|
||||||
|
|
||||||
@ -513,7 +513,7 @@ fn build_nsis_app_installer(
|
|||||||
.piped()
|
.piped()
|
||||||
.context("error running makensis.exe")?;
|
.context("error running makensis.exe")?;
|
||||||
|
|
||||||
rename(nsis_output_path, &nsis_installer_path)?;
|
fs::rename(nsis_output_path, &nsis_installer_path)?;
|
||||||
|
|
||||||
if settings.can_sign() {
|
if settings.can_sign() {
|
||||||
try_sign(&nsis_installer_path, settings)?;
|
try_sign(&nsis_installer_path, settings)?;
|
||||||
|
1
tooling/cli/Cargo.lock
generated
1
tooling/cli/Cargo.lock
generated
@ -5002,7 +5002,6 @@ dependencies = [
|
|||||||
"dunce",
|
"dunce",
|
||||||
"getrandom 0.2.12",
|
"getrandom 0.2.12",
|
||||||
"glob",
|
"glob",
|
||||||
"heck 0.5.0",
|
|
||||||
"html5ever",
|
"html5ever",
|
||||||
"infer 0.15.0",
|
"infer 0.15.0",
|
||||||
"json-patch",
|
"json-patch",
|
||||||
|
@ -117,6 +117,10 @@ native-tls = [
|
|||||||
native-tls-vendored = [ "native-tls", "tauri-bundler/native-tls-vendored" ]
|
native-tls-vendored = [ "native-tls", "tauri-bundler/native-tls-vendored" ]
|
||||||
rustls = [ "tauri-bundler/rustls", "cargo-mobile2/rustls", "ureq/tls" ]
|
rustls = [ "tauri-bundler/rustls", "cargo-mobile2/rustls", "ureq/tls" ]
|
||||||
|
|
||||||
|
# optimize flate2 on debug
|
||||||
|
[profile.dev.package.miniz_oxide]
|
||||||
|
opt-level = 3
|
||||||
|
|
||||||
[profile.release-size-optimized]
|
[profile.release-size-optimized]
|
||||||
inherits = "release"
|
inherits = "release"
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
|
@ -31,11 +31,7 @@ pub trait AppSettings {
|
|||||||
features: &[String],
|
features: &[String],
|
||||||
) -> crate::Result<tauri_bundler::BundleSettings>;
|
) -> crate::Result<tauri_bundler::BundleSettings>;
|
||||||
fn app_binary_path(&self, options: &Options) -> crate::Result<PathBuf>;
|
fn app_binary_path(&self, options: &Options) -> crate::Result<PathBuf>;
|
||||||
fn get_binaries(
|
fn get_binaries(&self, target: &str) -> crate::Result<Vec<tauri_bundler::BundleBinary>>;
|
||||||
&self,
|
|
||||||
config: &Config,
|
|
||||||
target: &str,
|
|
||||||
) -> crate::Result<Vec<tauri_bundler::BundleBinary>>;
|
|
||||||
fn app_name(&self) -> Option<String>;
|
fn app_name(&self) -> Option<String>;
|
||||||
fn lib_name(&self) -> Option<String>;
|
fn lib_name(&self) -> Option<String>;
|
||||||
|
|
||||||
@ -61,7 +57,7 @@ pub trait AppSettings {
|
|||||||
SettingsBuilder::new()
|
SettingsBuilder::new()
|
||||||
.package_settings(self.get_package_settings())
|
.package_settings(self.get_package_settings())
|
||||||
.bundle_settings(self.get_bundle_settings(config, &enabled_features)?)
|
.bundle_settings(self.get_bundle_settings(config, &enabled_features)?)
|
||||||
.binaries(self.get_binaries(config, &target)?)
|
.binaries(self.get_binaries(&target)?)
|
||||||
.project_out_directory(out_dir)
|
.project_out_directory(out_dir)
|
||||||
.target(target)
|
.target(target)
|
||||||
.package_types(package_types)
|
.package_types(package_types)
|
||||||
|
@ -16,7 +16,6 @@ use std::{
|
|||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use glob::glob;
|
use glob::glob;
|
||||||
use heck::ToKebabCase;
|
|
||||||
use ignore::gitignore::{Gitignore, GitignoreBuilder};
|
use ignore::gitignore::{Gitignore, GitignoreBuilder};
|
||||||
use notify::RecursiveMode;
|
use notify::RecursiveMode;
|
||||||
use notify_debouncer_mini::new_debouncer;
|
use notify_debouncer_mini::new_debouncer;
|
||||||
@ -114,7 +113,6 @@ pub struct RustupTarget {
|
|||||||
pub struct Rust {
|
pub struct Rust {
|
||||||
app_settings: Arc<RustAppSettings>,
|
app_settings: Arc<RustAppSettings>,
|
||||||
config_features: Vec<String>,
|
config_features: Vec<String>,
|
||||||
product_name: Option<String>,
|
|
||||||
available_targets: Option<Vec<RustupTarget>>,
|
available_targets: Option<Vec<RustupTarget>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +154,6 @@ impl Interface for Rust {
|
|||||||
Ok(Self {
|
Ok(Self {
|
||||||
app_settings: Arc::new(app_settings),
|
app_settings: Arc::new(app_settings),
|
||||||
config_features: config.build.features.clone().unwrap_or_default(),
|
config_features: config.build.features.clone().unwrap_or_default(),
|
||||||
product_name: config.product_name.clone(),
|
|
||||||
available_targets: None,
|
available_targets: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -169,7 +166,6 @@ impl Interface for Rust {
|
|||||||
desktop::build(
|
desktop::build(
|
||||||
options,
|
options,
|
||||||
&self.app_settings,
|
&self.app_settings,
|
||||||
self.product_name.clone(),
|
|
||||||
&mut self.available_targets,
|
&mut self.available_targets,
|
||||||
self.config_features.clone(),
|
self.config_features.clone(),
|
||||||
)?;
|
)?;
|
||||||
@ -496,7 +492,6 @@ impl Rust {
|
|||||||
&mut self.available_targets,
|
&mut self.available_targets,
|
||||||
self.config_features.clone(),
|
self.config_features.clone(),
|
||||||
&self.app_settings,
|
&self.app_settings,
|
||||||
self.product_name.clone(),
|
|
||||||
on_exit,
|
on_exit,
|
||||||
)
|
)
|
||||||
.map(|c| Box::new(c) as Box<dyn DevProcess + Send>)
|
.map(|c| Box::new(c) as Box<dyn DevProcess + Send>)
|
||||||
@ -672,7 +667,7 @@ struct BinarySettings {
|
|||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub struct CargoPackageSettings {
|
pub struct CargoPackageSettings {
|
||||||
/// the package's name.
|
/// the package's name.
|
||||||
pub name: Option<String>,
|
pub name: String,
|
||||||
/// the package's version.
|
/// the package's version.
|
||||||
pub version: Option<MaybeWorkspace<String>>,
|
pub version: Option<MaybeWorkspace<String>>,
|
||||||
/// the package's description.
|
/// the package's description.
|
||||||
@ -848,11 +843,7 @@ impl AppSettings for RustAppSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn app_binary_path(&self, options: &Options) -> crate::Result<PathBuf> {
|
fn app_binary_path(&self, options: &Options) -> crate::Result<PathBuf> {
|
||||||
let bin_name = self
|
let bin_name = self.cargo_package_settings().name.clone();
|
||||||
.cargo_package_settings()
|
|
||||||
.name
|
|
||||||
.clone()
|
|
||||||
.expect("Cargo manifest must have the `package.name` field");
|
|
||||||
|
|
||||||
let out_dir = self
|
let out_dir = self
|
||||||
.out_dir(options.target.clone(), get_profile_dir(options).to_string())
|
.out_dir(options.target.clone(), get_profile_dir(options).to_string())
|
||||||
@ -868,7 +859,7 @@ impl AppSettings for RustAppSettings {
|
|||||||
Ok(out_dir.join(bin_name).with_extension(binary_extension))
|
Ok(out_dir.join(bin_name).with_extension(binary_extension))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_binaries(&self, config: &Config, target: &str) -> crate::Result<Vec<BundleBinary>> {
|
fn get_binaries(&self, target: &str) -> crate::Result<Vec<BundleBinary>> {
|
||||||
let mut binaries: Vec<BundleBinary> = vec![];
|
let mut binaries: Vec<BundleBinary> = vec![];
|
||||||
|
|
||||||
let binary_extension: String = if target.contains("windows") {
|
let binary_extension: String = if target.contains("windows") {
|
||||||
@ -878,35 +869,17 @@ impl AppSettings for RustAppSettings {
|
|||||||
}
|
}
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
let target_os = target.split('-').nth(2).unwrap_or(std::env::consts::OS);
|
if let Some(bins) = &self.cargo_settings.bin {
|
||||||
|
|
||||||
if let Some(bin) = &self.cargo_settings.bin {
|
|
||||||
let default_run = self
|
let default_run = self
|
||||||
.package_settings
|
.package_settings
|
||||||
.default_run
|
.default_run
|
||||||
.clone()
|
.clone()
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
for binary in bin {
|
for bin in bins {
|
||||||
binaries.push(
|
let name = format!("{}{}", bin.name, binary_extension);
|
||||||
if Some(&binary.name) == self.cargo_package_settings.name.as_ref()
|
let is_main =
|
||||||
|| binary.name.as_str() == default_run
|
bin.name == self.cargo_package_settings.name || bin.name.as_str() == default_run;
|
||||||
{
|
binaries.push(BundleBinary::with_path(name, is_main, bin.path.clone()))
|
||||||
BundleBinary::new(
|
|
||||||
format!(
|
|
||||||
"{}{}",
|
|
||||||
config.binary_name().unwrap_or_else(|| binary.name.clone()),
|
|
||||||
&binary_extension
|
|
||||||
),
|
|
||||||
true,
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
BundleBinary::new(
|
|
||||||
format!("{}{}", binary.name.clone(), &binary_extension),
|
|
||||||
false,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
.set_src_path(binary.path.clone()),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -930,38 +903,17 @@ impl AppSettings for RustAppSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(default_run) = self.package_settings.default_run.as_ref() {
|
if let Some(default_run) = self.package_settings.default_run.as_ref() {
|
||||||
match binaries.iter_mut().find(|bin| bin.name() == default_run) {
|
if !binaries.iter_mut().any(|bin| bin.name() == default_run) {
|
||||||
Some(bin) => {
|
binaries.push(BundleBinary::new(
|
||||||
if let Some(bin_name) = config.binary_name() {
|
format!("{}{}", default_run, binary_extension),
|
||||||
bin.set_name(bin_name);
|
true,
|
||||||
}
|
));
|
||||||
}
|
|
||||||
None => {
|
|
||||||
binaries.push(BundleBinary::new(
|
|
||||||
format!(
|
|
||||||
"{}{}",
|
|
||||||
config
|
|
||||||
.binary_name()
|
|
||||||
.unwrap_or_else(|| default_run.to_string()),
|
|
||||||
&binary_extension
|
|
||||||
),
|
|
||||||
true,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match binaries.len() {
|
match binaries.len() {
|
||||||
0 => binaries.push(BundleBinary::new(
|
0 => binaries.push(BundleBinary::new(
|
||||||
if target_os == "linux" {
|
format!("{}{}", self.cargo_package_settings.name, &binary_extension),
|
||||||
self.package_settings.product_name.to_kebab_case()
|
|
||||||
} else {
|
|
||||||
format!(
|
|
||||||
"{}{}",
|
|
||||||
self.package_settings.product_name.clone(),
|
|
||||||
&binary_extension
|
|
||||||
)
|
|
||||||
},
|
|
||||||
true,
|
true,
|
||||||
)),
|
)),
|
||||||
1 => binaries.get_mut(0).unwrap().set_main(true),
|
1 => binaries.get_mut(0).unwrap().set_main(true),
|
||||||
@ -1019,12 +971,10 @@ impl RustAppSettings {
|
|||||||
.and_then(|v| v.package);
|
.and_then(|v| v.package);
|
||||||
|
|
||||||
let package_settings = PackageSettings {
|
let package_settings = PackageSettings {
|
||||||
product_name: config.product_name.clone().unwrap_or_else(|| {
|
product_name: config
|
||||||
cargo_package_settings
|
.product_name
|
||||||
.name
|
.clone()
|
||||||
.clone()
|
.unwrap_or_else(|| cargo_package_settings.name.clone()),
|
||||||
.expect("Cargo manifest must have the `package.name` field")
|
|
||||||
}),
|
|
||||||
version: config.version.clone().unwrap_or_else(|| {
|
version: config.version.clone().unwrap_or_else(|| {
|
||||||
cargo_package_settings
|
cargo_package_settings
|
||||||
.version
|
.version
|
||||||
|
@ -6,15 +6,11 @@ use super::{
|
|||||||
get_profile_dir, AppSettings, DevProcess, ExitReason, Options, RustAppSettings, RustupTarget,
|
get_profile_dir, AppSettings, DevProcess, ExitReason, Options, RustAppSettings, RustupTarget,
|
||||||
};
|
};
|
||||||
use crate::CommandExt;
|
use crate::CommandExt;
|
||||||
use tauri_utils::display_path;
|
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use heck::ToKebabCase;
|
|
||||||
use shared_child::SharedChild;
|
use shared_child::SharedChild;
|
||||||
use std::{
|
use std::{
|
||||||
fs::rename,
|
|
||||||
io::{BufReader, ErrorKind, Write},
|
io::{BufReader, ErrorKind, Write},
|
||||||
path::{Path, PathBuf},
|
|
||||||
process::{Command, ExitStatus, Stdio},
|
process::{Command, ExitStatus, Stdio},
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicBool, Ordering},
|
atomic::{AtomicBool, Ordering},
|
||||||
@ -70,16 +66,9 @@ pub fn run_dev<F: Fn(Option<i32>, ExitReason) + Send + Sync + 'static>(
|
|||||||
available_targets: &mut Option<Vec<RustupTarget>>,
|
available_targets: &mut Option<Vec<RustupTarget>>,
|
||||||
config_features: Vec<String>,
|
config_features: Vec<String>,
|
||||||
app_settings: &RustAppSettings,
|
app_settings: &RustAppSettings,
|
||||||
product_name: Option<String>,
|
|
||||||
on_exit: F,
|
on_exit: F,
|
||||||
) -> crate::Result<impl DevProcess> {
|
) -> crate::Result<impl DevProcess> {
|
||||||
let bin_path = app_settings.app_binary_path(&options)?;
|
let bin_path = app_settings.app_binary_path(&options)?;
|
||||||
let target_os = options
|
|
||||||
.target
|
|
||||||
.as_ref()
|
|
||||||
.and_then(|t| t.split('-').nth(2))
|
|
||||||
.unwrap_or(std::env::consts::OS)
|
|
||||||
.replace("darwin", "macos");
|
|
||||||
|
|
||||||
let manually_killed_app = Arc::new(AtomicBool::default());
|
let manually_killed_app = Arc::new(AtomicBool::default());
|
||||||
let manually_killed_app_ = manually_killed_app.clone();
|
let manually_killed_app_ = manually_killed_app.clone();
|
||||||
@ -92,8 +81,6 @@ pub fn run_dev<F: Fn(Option<i32>, ExitReason) + Send + Sync + 'static>(
|
|||||||
config_features,
|
config_features,
|
||||||
move |status, reason| {
|
move |status, reason| {
|
||||||
if status == Some(0) {
|
if status == Some(0) {
|
||||||
let bin_path =
|
|
||||||
rename_app(target_os, &bin_path, product_name.as_deref()).expect("failed to rename app");
|
|
||||||
let mut app = Command::new(bin_path);
|
let mut app = Command::new(bin_path);
|
||||||
app.stdout(os_pipe::dup_stdout().unwrap());
|
app.stdout(os_pipe::dup_stdout().unwrap());
|
||||||
app.stderr(os_pipe::dup_stderr().unwrap());
|
app.stderr(os_pipe::dup_stderr().unwrap());
|
||||||
@ -132,7 +119,6 @@ pub fn run_dev<F: Fn(Option<i32>, ExitReason) + Send + Sync + 'static>(
|
|||||||
pub fn build(
|
pub fn build(
|
||||||
options: Options,
|
options: Options,
|
||||||
app_settings: &RustAppSettings,
|
app_settings: &RustAppSettings,
|
||||||
product_name: Option<String>,
|
|
||||||
available_targets: &mut Option<Vec<RustupTarget>>,
|
available_targets: &mut Option<Vec<RustupTarget>>,
|
||||||
config_features: Vec<String>,
|
config_features: Vec<String>,
|
||||||
) -> crate::Result<()> {
|
) -> crate::Result<()> {
|
||||||
@ -145,13 +131,6 @@ pub fn build(
|
|||||||
std::env::set_var("STATIC_VCRUNTIME", "true");
|
std::env::set_var("STATIC_VCRUNTIME", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
let target_os = options
|
|
||||||
.target
|
|
||||||
.as_ref()
|
|
||||||
.and_then(|t| t.split('-').nth(2))
|
|
||||||
.unwrap_or(std::env::consts::OS)
|
|
||||||
.replace("darwin", "macos");
|
|
||||||
|
|
||||||
if options.target == Some("universal-apple-darwin".into()) {
|
if options.target == Some("universal-apple-darwin".into()) {
|
||||||
std::fs::create_dir_all(out_dir).with_context(|| "failed to create project out directory")?;
|
std::fs::create_dir_all(out_dir).with_context(|| "failed to create project out directory")?;
|
||||||
|
|
||||||
@ -185,8 +164,6 @@ pub fn build(
|
|||||||
.with_context(|| "failed to build app")?;
|
.with_context(|| "failed to build app")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
rename_app(target_os, &bin_path, product_name.as_deref())?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,37 +365,6 @@ fn validate_target(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rename_app(
|
|
||||||
target_os: String,
|
|
||||||
bin_path: &Path,
|
|
||||||
product_name: Option<&str>,
|
|
||||||
) -> crate::Result<PathBuf> {
|
|
||||||
if let Some(product_name) = product_name {
|
|
||||||
let product_name = if target_os == "linux" {
|
|
||||||
product_name.to_kebab_case()
|
|
||||||
} else {
|
|
||||||
product_name.into()
|
|
||||||
};
|
|
||||||
|
|
||||||
let product_path = bin_path
|
|
||||||
.parent()
|
|
||||||
.unwrap()
|
|
||||||
.join(product_name)
|
|
||||||
.with_extension(bin_path.extension().unwrap_or_default());
|
|
||||||
|
|
||||||
rename(bin_path, &product_path).with_context(|| {
|
|
||||||
format!(
|
|
||||||
"failed to rename `{}` to `{}`",
|
|
||||||
display_path(bin_path),
|
|
||||||
display_path(&product_path),
|
|
||||||
)
|
|
||||||
})?;
|
|
||||||
Ok(product_path)
|
|
||||||
} else {
|
|
||||||
Ok(bin_path.to_path_buf())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// taken from https://github.com/rust-lang/cargo/blob/78b10d4e611ab0721fc3aeaf0edd5dd8f4fdc372/src/cargo/core/shell.rs#L514
|
// taken from https://github.com/rust-lang/cargo/blob/78b10d4e611ab0721fc3aeaf0edd5dd8f4fdc372/src/cargo/core/shell.rs#L514
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
mod terminal {
|
mod terminal {
|
||||||
|
Loading…
Reference in New Issue
Block a user