mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-05 10:13:00 +02:00
copy cef files to out dir
This commit is contained in:
@@ -4,7 +4,7 @@ use crate::interface::{
|
||||
rust::{DevChild, RustupTarget},
|
||||
AppSettings, ExitReason, Options,
|
||||
};
|
||||
use crate::{error::ErrorExt, CommandExt};
|
||||
use crate::{error::ErrorExt, CommandExt, helpers::fs::copy_dir_all};
|
||||
|
||||
use serde::Serialize;
|
||||
use shared_child::SharedChild;
|
||||
@@ -93,24 +93,6 @@ fn write_info_plist(
|
||||
.map_err(|e| crate::Error::GenericError(e.to_string()))
|
||||
}
|
||||
|
||||
fn copy_dir_all(src: &Path, dst: &Path) -> crate::Result<()> {
|
||||
std::fs::create_dir_all(dst).fs_context("failed to create directory", dst.to_path_buf())?;
|
||||
for entry in std::fs::read_dir(src).fs_context("failed to read directory", src.to_path_buf())? {
|
||||
let entry = entry.map_err(|e| crate::Error::GenericError(e.to_string()))?;
|
||||
let dst_path = dst.join(entry.file_name());
|
||||
let file_type = entry
|
||||
.file_type()
|
||||
.map_err(|e| crate::Error::GenericError(e.to_string()))?;
|
||||
if file_type.is_dir() {
|
||||
copy_dir_all(&entry.path(), &dst_path)?;
|
||||
} else {
|
||||
std::fs::copy(entry.path(), &dst_path)
|
||||
.map_err(|e| crate::Error::GenericError(e.to_string()))?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn run_dev_cef_macos<A: AppSettings, F: Fn(Option<i32>, ExitReason) + Send + Sync + 'static>(
|
||||
app_settings: &A,
|
||||
options: Options,
|
||||
|
||||
@@ -53,3 +53,21 @@ pub fn find_in_directory(path: &Path, glob_pattern: &str) -> crate::Result<PathB
|
||||
glob_pattern
|
||||
)
|
||||
}
|
||||
|
||||
pub fn copy_dir_all(src: &Path, dst: &Path) -> crate::Result<()> {
|
||||
std::fs::create_dir_all(dst).fs_context("failed to create directory", dst.to_path_buf())?;
|
||||
for entry in std::fs::read_dir(src).fs_context("failed to read directory", src.to_path_buf())? {
|
||||
let entry = entry.map_err(|e| crate::Error::GenericError(e.to_string()))?;
|
||||
let dst_path = dst.join(entry.file_name());
|
||||
let file_type = entry
|
||||
.file_type()
|
||||
.map_err(|e| crate::Error::GenericError(e.to_string()))?;
|
||||
if file_type.is_dir() {
|
||||
copy_dir_all(&entry.path(), &dst_path)?;
|
||||
} else {
|
||||
std::fs::copy(entry.path(), &dst_path)
|
||||
.map_err(|e| crate::Error::GenericError(e.to_string()))?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -29,12 +29,10 @@ use tauri_utils::config::{parse::is_configuration_file, DeepLinkProtocol, Runner
|
||||
|
||||
use super::{AppSettings, DevProcess, ExitReason, Interface};
|
||||
use crate::{
|
||||
error::{Context, Error, ErrorExt},
|
||||
helpers::{
|
||||
ConfigValue, error::{Context, Error, ErrorExt}, helpers::{
|
||||
app_paths::{frontend_dir, tauri_dir},
|
||||
config::{nsis_settings, reload as reload_config, wix_settings, BundleResources, Config},
|
||||
},
|
||||
ConfigValue,
|
||||
config::{BundleResources, Config, nsis_settings, reload as reload_config, wix_settings}, fs::copy_dir_all,
|
||||
}
|
||||
};
|
||||
use tauri_utils::{display_path, platform::Target as TargetPlatform};
|
||||
|
||||
@@ -192,6 +190,7 @@ impl Interface for Rust {
|
||||
fn build(&mut self, options: Options) -> crate::Result<PathBuf> {
|
||||
ensure_cef_directory_if_needed(
|
||||
&self.app_settings,
|
||||
&options,
|
||||
self.config_features.clone(),
|
||||
options.target.as_deref(),
|
||||
&options.features,
|
||||
@@ -212,6 +211,7 @@ impl Interface for Rust {
|
||||
) -> crate::Result<()> {
|
||||
ensure_cef_directory_if_needed(
|
||||
&self.app_settings,
|
||||
&options,
|
||||
self.config_features.clone(),
|
||||
options.target.as_deref(),
|
||||
&options.features,
|
||||
@@ -514,6 +514,7 @@ fn get_watch_folders(additional_watch_folders: &[PathBuf]) -> crate::Result<Vec<
|
||||
|
||||
fn ensure_cef_directory_if_needed(
|
||||
app_settings: &RustAppSettings,
|
||||
options: &Options,
|
||||
config_features: Vec<String>,
|
||||
target: Option<&str>,
|
||||
features: &Option<Vec<String>>,
|
||||
@@ -533,8 +534,20 @@ fn ensure_cef_directory_if_needed(
|
||||
.build()
|
||||
.target()
|
||||
});
|
||||
if let Err(e) = crate::cef::exporter::ensure_cef_directory(target_triple, &enabled_features) {
|
||||
log::warn!(action = "CEF"; "Failed to ensure CEF directory: {}. Continuing anyway.", e);
|
||||
match crate::cef::exporter::ensure_cef_directory(target_triple, &enabled_features) {
|
||||
// cef not enabled
|
||||
Ok(None) => {}
|
||||
#[cfg(not(windows))]
|
||||
Ok(Some(_cef_dir)) => {}
|
||||
// on Windows we must copy the cef files next to the executable
|
||||
#[cfg(windows)]
|
||||
Ok(Some(cef_dir)) => {
|
||||
let out_dir = app_settings.out_dir(options)?;
|
||||
copy_dir_all(&cef_dir, &out_dir)?;
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!(action = "CEF"; "Failed to ensure CEF directory: {}. Continuing anyway.", e);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user