mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-11-29 13:03:09 +03:00
This commit is contained in:
parent
a2b29949b7
commit
7e7b43cef3
@ -104,7 +104,10 @@ pub fn generate_folders(settings: &Settings, package_dir: &Path) -> crate::Resul
|
||||
generate_icon_files(settings, &data_dir).chain_err(|| "Failed to create icon files")?;
|
||||
generate_desktop_file(settings, &data_dir).chain_err(|| "Failed to create desktop file")?;
|
||||
|
||||
generate_bootstrap_file(settings, &data_dir).chain_err(|| "Failed to generate bootstrap file")?;
|
||||
let use_bootstrapper = settings.debian_use_bootstrapper();
|
||||
if use_bootstrapper {
|
||||
generate_bootstrap_file(settings, &data_dir).chain_err(|| "Failed to generate bootstrap file")?;
|
||||
}
|
||||
|
||||
Ok(data_dir)
|
||||
}
|
||||
@ -187,7 +190,12 @@ fn generate_desktop_file(settings: &Settings, data_dir: &Path) -> crate::Result<
|
||||
if !settings.short_description().is_empty() {
|
||||
write!(file, "Comment={}\n", settings.short_description())?;
|
||||
}
|
||||
write!(file, "Exec=__{}-bootstrapper\n", bin_name)?;
|
||||
let use_bootstrapper = settings.debian_use_bootstrapper();
|
||||
write!(
|
||||
file,
|
||||
"Exec={}\n",
|
||||
if use_bootstrapper { format!("__{}-bootstrapper", bin_name) } else { bin_name.to_string() }
|
||||
)?;
|
||||
write!(file, "Icon={}\n", bin_name)?;
|
||||
write!(file, "Name={}\n", settings.bundle_name())?;
|
||||
write!(file, "Terminal=false\n")?;
|
||||
|
@ -74,8 +74,10 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
||||
copy_binary_to_bundle(&bundle_directory, settings)
|
||||
.chain_err(|| format!("Failed to copy binary from {:?}", settings.binary_path()))?;
|
||||
|
||||
create_path_hook(&bundle_directory, settings).chain_err(|| "Failed to create _boot wrapper")?;
|
||||
|
||||
let use_bootstrapper = settings.osx_use_bootstrapper();
|
||||
if use_bootstrapper {
|
||||
create_bootstrapper(&bundle_directory, settings).chain_err(|| "Failed to create OSX bootstrapper")?;
|
||||
}
|
||||
Ok(vec![app_bundle_path])
|
||||
}
|
||||
|
||||
@ -87,7 +89,7 @@ fn copy_binary_to_bundle(bundle_directory: &Path, settings: &Settings) -> crate:
|
||||
)
|
||||
}
|
||||
|
||||
fn create_path_hook(bundle_dir: &Path, settings: &Settings) -> crate::Result<()> {
|
||||
fn create_bootstrapper(bundle_dir: &Path, settings: &Settings) -> crate::Result<()> {
|
||||
let file = &mut common::create_file(&bundle_dir.join("MacOS/__bootstrapper"))?;
|
||||
// Create a shell script to bootstrap the $PATH for Tauri, so environments like node are available.
|
||||
write!(
|
||||
@ -146,6 +148,7 @@ fn create_info_plist(
|
||||
) -> crate::Result<()> {
|
||||
let build_number = chrono::Utc::now().format("%Y%m%d.%H%M%S");
|
||||
let file = &mut common::create_file(&bundle_dir.join("Info.plist"))?;
|
||||
let use_bootstrapper = settings.osx_use_bootstrapper();
|
||||
write!(
|
||||
file,
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
|
||||
@ -166,9 +169,8 @@ fn create_info_plist(
|
||||
)?;
|
||||
write!(
|
||||
file,
|
||||
// Here we should only use this technique if they have specified
|
||||
// that they want to use the resources
|
||||
" <key>CFBundleExecutable</key>\n <string>__bootstrapper</string>\n"
|
||||
" <key>CFBundleExecutable</key>\n <string>{}</string>\n",
|
||||
if use_bootstrapper { "__bootstrapper" } else { settings.binary_name() }
|
||||
)?;
|
||||
if let Some(path) = bundle_icon_file {
|
||||
write!(
|
||||
|
@ -95,9 +95,11 @@ struct BundleSettings {
|
||||
script: Option<PathBuf>,
|
||||
// OS-specific settings:
|
||||
deb_depends: Option<Vec<String>>,
|
||||
deb_use_bootstrapper: Option<bool>,
|
||||
osx_frameworks: Option<Vec<String>>,
|
||||
osx_minimum_system_version: Option<String>,
|
||||
osx_license: Option<String>,
|
||||
osx_use_bootstrapper: Option<bool>,
|
||||
// Bundles for other binaries/examples:
|
||||
bin: Option<HashMap<String, BundleSettings>>,
|
||||
example: Option<HashMap<String, BundleSettings>>,
|
||||
@ -457,7 +459,7 @@ impl Settings {
|
||||
}
|
||||
|
||||
pub fn exception_domain(&self) -> Option<&String> {
|
||||
return self.bundle_settings.exception_domain.as_ref();
|
||||
self.bundle_settings.exception_domain.as_ref()
|
||||
}
|
||||
|
||||
// copy external binaries to a path.
|
||||
@ -550,6 +552,13 @@ impl Settings {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn debian_use_bootstrapper(&self) -> bool {
|
||||
self
|
||||
.bundle_settings
|
||||
.deb_use_bootstrapper
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
pub fn osx_frameworks(&self) -> &[String] {
|
||||
match self.bundle_settings.osx_frameworks {
|
||||
Some(ref frameworks) => frameworks.as_slice(),
|
||||
@ -572,6 +581,13 @@ impl Settings {
|
||||
.as_ref()
|
||||
.map(String::as_str)
|
||||
}
|
||||
|
||||
pub fn osx_use_bootstrapper(&self) -> bool {
|
||||
self
|
||||
.bundle_settings
|
||||
.osx_use_bootstrapper
|
||||
.unwrap_or(false)
|
||||
}
|
||||
}
|
||||
|
||||
fn bundle_settings_from_table(
|
||||
@ -638,12 +654,14 @@ fn merge_settings(
|
||||
long_description: options_value(config.long_description, bundle_settings.long_description),
|
||||
script: options_value(config.script, bundle_settings.script),
|
||||
deb_depends: options_value(config.deb.depends, bundle_settings.deb_depends),
|
||||
deb_use_bootstrapper: Some(config.deb.use_bootstrapper),
|
||||
osx_frameworks: options_value(config.osx.frameworks, bundle_settings.osx_frameworks),
|
||||
osx_minimum_system_version: options_value(
|
||||
config.osx.minimum_system_version,
|
||||
bundle_settings.osx_minimum_system_version,
|
||||
),
|
||||
osx_license: options_value(config.osx.license, bundle_settings.osx_license),
|
||||
osx_use_bootstrapper: Some(config.osx.use_bootstrapper),
|
||||
external_bin: options_value(config.external_bin, bundle_settings.external_bin),
|
||||
exception_domain: options_value(
|
||||
config.osx.exception_domain,
|
||||
|
@ -8,6 +8,8 @@ use std::fs;
|
||||
#[serde(tag = "deb", rename_all = "camelCase")]
|
||||
pub struct DebConfig {
|
||||
pub depends: Option<Vec<String>>,
|
||||
#[serde(default)]
|
||||
pub use_bootstrapper: bool,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Deserialize, Clone, Debug, Default)]
|
||||
@ -17,6 +19,8 @@ pub struct OsxConfig {
|
||||
pub minimum_system_version: Option<String>,
|
||||
pub exception_domain: Option<String>,
|
||||
pub license: Option<String>,
|
||||
#[serde(default)]
|
||||
pub use_bootstrapper: bool,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Deserialize, Clone, Debug, Default)]
|
||||
|
@ -32,7 +32,16 @@ const getTauriConfig = (cfg: Partial<TauriConfig>): TauriConfig => {
|
||||
active: true
|
||||
},
|
||||
bundle: {
|
||||
active: true
|
||||
active: true,
|
||||
icon: [],
|
||||
resources: [],
|
||||
externalBin: [],
|
||||
deb: {
|
||||
depends: []
|
||||
},
|
||||
osx: {
|
||||
frameworks: []
|
||||
}
|
||||
},
|
||||
whitelist: {
|
||||
all: false
|
||||
|
@ -22,11 +22,13 @@ export default {
|
||||
shortDescription: '',
|
||||
longDescription: '',
|
||||
deb: {
|
||||
depends: []
|
||||
depends: [],
|
||||
useBootstrapper: false
|
||||
},
|
||||
osx: {
|
||||
frameworks: [],
|
||||
minimumSystemVersion: ''
|
||||
minimumSystemVersion: '',
|
||||
useBootstrapper: false
|
||||
},
|
||||
exceptionDomain: ''
|
||||
},
|
||||
|
@ -35,11 +35,13 @@ export interface TauriConfig {
|
||||
longDescription?: string
|
||||
deb?: {
|
||||
depends?: string[]
|
||||
useBootstrapper: boolean
|
||||
}
|
||||
osx?: {
|
||||
frameworks?: string[]
|
||||
minimumSystemVersion?: string
|
||||
license?: string
|
||||
useBootstrapper: boolean
|
||||
}
|
||||
exceptionDomain?: string
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user