Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ members = [
"crates/tauri-bundler",
"crates/tauri-macos-sign",
"crates/tauri-driver",
"crates/tauri-examples",

# @tauri-apps/cli rust project
"packages/cli",
Expand Down
7 changes: 5 additions & 2 deletions bench/tests/cpu_intensive/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ tauri-build = { path = "../../../../crates/tauri-build", features = [
serde_json = "1"
serde = { version = "1", features = ["derive"] }
tauri = { path = "../../../../crates/tauri", features = [] }
tauri-runtime-wry = { path = "../../../../crates/tauri-runtime-wry", optional = true }
tauri-runtime-cef = { path = "../../../../crates/tauri-runtime-cef", optional = true }

[features]
cef = ["tauri/cef"]
wry = ["tauri/wry"]
default = ["wry"]
wry = ["dep:tauri-runtime-wry"]
cef = ["dep:tauri-runtime-cef"]
6 changes: 3 additions & 3 deletions bench/tests/cpu_intensive/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ fn app_completed_successfully() {

#[cfg_attr(feature = "cef", tauri::cef_entry_point)]
fn main() {
#[cfg(feature = "wry")]
let builder = tauri::Builder::<tauri_runtime_wry::Wry<tauri::EventLoopMessage>>::new();
#[cfg(feature = "cef")]
let builder = tauri::Builder::<tauri::Cef>::default();
#[cfg(not(feature = "cef"))]
let builder = tauri::Builder::<tauri::Wry>::default();
let builder = tauri::Builder::<tauri_runtime_cef::CefRuntime<tauri::EventLoopMessage>>::new();

builder
.invoke_handler(tauri::generate_handler![app_completed_successfully])
Expand Down
7 changes: 5 additions & 2 deletions bench/tests/files_transfer/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ tauri-build = { path = "../../../../crates/tauri-build", features = [
serde_json = "1"
serde = { version = "1", features = ["derive"] }
tauri = { path = "../../../../crates/tauri", features = [] }
tauri-runtime-wry = { path = "../../../../crates/tauri-runtime-wry", optional = true }
tauri-runtime-cef = { path = "../../../../crates/tauri-runtime-cef", optional = true }

[features]
cef = ["tauri/cef"]
wry = ["tauri/wry"]
default = ["wry"]
wry = ["dep:tauri-runtime-wry"]
cef = ["dep:tauri-runtime-cef"]
6 changes: 3 additions & 3 deletions bench/tests/files_transfer/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ async fn read_file<R: Runtime>(app: AppHandle<R>) -> Result<Response, String> {

#[cfg_attr(feature = "cef", tauri::cef_entry_point)]
fn main() {
#[cfg(feature = "wry")]
let builder = tauri::Builder::<tauri_runtime_wry::Wry<tauri::EventLoopMessage>>::new();
#[cfg(feature = "cef")]
let builder = tauri::Builder::<tauri::Cef>::default();
#[cfg(not(feature = "cef"))]
let builder = tauri::Builder::<tauri::Wry>::new();
let builder = tauri::Builder::<tauri_runtime_cef::CefRuntime<tauri::EventLoopMessage>>::new();

builder
.invoke_handler(tauri::generate_handler![app_should_close, read_file])
Expand Down
7 changes: 5 additions & 2 deletions bench/tests/helloworld/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ tauri-build = { path = "../../../../crates/tauri-build", features = [
serde_json = "1"
serde = { version = "1", features = ["derive"] }
tauri = { path = "../../../../crates/tauri", features = [] }
tauri-runtime-wry = { path = "../../../../crates/tauri-runtime-wry", optional = true }
tauri-runtime-cef = { path = "../../../../crates/tauri-runtime-cef", optional = true }

[features]
cef = ["tauri/cef"]
wry = ["tauri/wry"]
default = ["wry"]
wry = ["dep:tauri-runtime-wry"]
cef = ["dep:tauri-runtime-cef"]
6 changes: 3 additions & 3 deletions bench/tests/helloworld/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ fn app_loaded_successfully() {

#[cfg_attr(feature = "cef", tauri::cef_entry_point)]
fn main() {
#[cfg(feature = "wry")]
let builder = tauri::Builder::<tauri_runtime_wry::Wry<tauri::EventLoopMessage>>::new();
#[cfg(feature = "cef")]
let builder = tauri::Builder::<tauri::Cef>::default();
#[cfg(not(feature = "cef"))]
let builder = tauri::Builder::<tauri::Wry>::new();
let builder = tauri::Builder::<tauri_runtime_cef::CefRuntime<tauri::EventLoopMessage>>::new();

builder
.invoke_handler(tauri::generate_handler![app_loaded_successfully])
Expand Down
4 changes: 2 additions & 2 deletions crates/tauri-cli/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
"type": "object",
"properties": {
"windows": {
"description": "The app windows configuration.\n\n## Example:\n\nTo create a window at app startup\n\n```json\n{\n \"app\": {\n \"windows\": [\n { \"width\": 800, \"height\": 600 }\n ]\n }\n}\n```\n\nIf not specified, the window's label (its identifier) defaults to \"main\",\nyou can use this label to get the window through\n`app.get_webview_window` in Rust or `WebviewWindow.getByLabel` in JavaScript\n\nWhen working with multiple windows, each window will need an unique label\n\n```json\n{\n \"app\": {\n \"windows\": [\n { \"label\": \"main\", \"width\": 800, \"height\": 600 },\n { \"label\": \"secondary\", \"width\": 800, \"height\": 600 }\n ]\n }\n}\n```\n\nYou can also set `create` to false and use this config through the Rust APIs\n\n```json\n{\n \"app\": {\n \"windows\": [\n { \"create\": false, \"width\": 800, \"height\": 600 }\n ]\n }\n}\n```\n\nand use it like this\n\n```rust\ntauri::Builder::<tauri::Wry>::new()\n .setup(|app| {\n tauri::WebviewWindowBuilder::from_config(app.handle(), &app.config().app.windows[0])?.build()?;\n Ok(())\n });\n```",
"description": "The app windows configuration.\n\n## Example:\n\nTo create a window at app startup\n\n```json\n{\n \"app\": {\n \"windows\": [\n { \"width\": 800, \"height\": 600 }\n ]\n }\n}\n```\n\nIf not specified, the window's label (its identifier) defaults to \"main\",\nyou can use this label to get the window through\n`app.get_webview_window` in Rust or `WebviewWindow.getByLabel` in JavaScript\n\nWhen working with multiple windows, each window will need an unique label\n\n```json\n{\n \"app\": {\n \"windows\": [\n { \"label\": \"main\", \"width\": 800, \"height\": 600 },\n { \"label\": \"secondary\", \"width\": 800, \"height\": 600 }\n ]\n }\n}\n```\n\nYou can also set `create` to false and use this config through the Rust APIs\n\n```json\n{\n \"app\": {\n \"windows\": [\n { \"create\": false, \"width\": 800, \"height\": 600 }\n ]\n }\n}\n```\n\nand use it like this\n\n```rust\n// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;\n# type TauriRuntime = tauri::test::MockRuntime;\ntauri::Builder::<TauriRuntime>::new()\n .setup(|app| {\n tauri::WebviewWindowBuilder::from_config(app.handle(), &app.config().app.windows[0])?.build()?;\n Ok(())\n });\n```",
"type": "array",
"items": {
"$ref": "#/definitions/WindowConfig"
Expand Down Expand Up @@ -231,7 +231,7 @@
"default": "main"
},
"create": {
"description": "Whether Tauri should create this window at app startup or not.\n\nWhen this is set to `false` you must manually grab the config object via `app.config().app.windows`\nand create it with [`WebviewWindowBuilder::from_config`](https://docs.rs/tauri/2/tauri/webview/struct.WebviewWindowBuilder.html#method.from_config).\n\n## Example:\n\n```rust\ntauri::Builder::<tauri::Wry>::new()\n .setup(|app| {\n tauri::WebviewWindowBuilder::from_config(app.handle(), &app.config().app.windows[0])?.build()?;\n Ok(())\n });\n```",
"description": "Whether Tauri should create this window at app startup or not.\n\nWhen this is set to `false` you must manually grab the config object via `app.config().app.windows`\nand create it with [`WebviewWindowBuilder::from_config`](https://docs.rs/tauri/2/tauri/webview/struct.WebviewWindowBuilder.html#method.from_config).\n\n## Example:\n\n```rust\n// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;\n# type TauriRuntime = tauri::test::MockRuntime;\ntauri::Builder::<TauriRuntime>::new()\n .setup(|app| {\n tauri::WebviewWindowBuilder::from_config(app.handle(), &app.config().app.windows[0])?.build()?;\n Ok(())\n });\n```",
"type": "boolean",
"default": true
},
Expand Down
18 changes: 3 additions & 15 deletions crates/tauri-cli/src/cef/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,20 +259,8 @@ fn check_archive_outdated(archive_json_path: &Path, required_version: &str) -> c
}
}

pub fn ensure_cef_directory(
target: Option<&str>,
enabled_features: &[String],
workspace_dir: &Path,
) -> crate::Result<Option<PathBuf>> {
// Check if cef feature is enabled
let cef_enabled = enabled_features
.iter()
.any(|f| f == "cef" || f == "tauri/cef");

if !cef_enabled {
return Ok(None);
}

/// Ensures the CEF directory is available. Returns `None` if CEF is not in use for this build.
pub fn ensure_cef_directory(target: Option<&str>, workspace_dir: &Path) -> crate::Result<PathBuf> {
let target = target.unwrap_or(DEFAULT_TARGET);
let os_arch = OsAndArch::try_from(target)
.map_err(|e| crate::Error::GenericError(format!("invalid target: {e}")))?;
Expand Down Expand Up @@ -313,5 +301,5 @@ pub fn ensure_cef_directory(
export_cef_library_path(&cef_dir);
log::info!(action = "CEF"; "CEF directory exported to: {}", cef_dir.display());

Ok(Some(cef_dir))
Ok(cef_dir)
}
1 change: 1 addition & 0 deletions crates/tauri-cli/src/cef/macos_dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ pub fn run_dev_cef_macos<F: Fn(Option<i32>, ExitReason) + Send + Sync + 'static>
config.bundle.clone(),
None, // No updater in dev mode
arch64bits,
Some(&target),
)?;
let mut settings = tauri_bundler::bundle::SettingsBuilder::new()
.package_settings(app_settings.get_package_settings())
Expand Down
57 changes: 28 additions & 29 deletions crates/tauri-cli/src/interface/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,27 +513,27 @@ fn ensure_cef_directory_if_needed(
if !no_default_features {
merged_features.push("default".into());
}
let enabled_features = app_settings
.manifest
.lock()
.unwrap()
.all_enabled_features(&merged_features);

let target_triple = target.or_else(|| app_settings.cargo_config.build().target());
match crate::cef::exporter::ensure_cef_directory(
target_triple,
&enabled_features,
&app_settings.workspace_dir,
) {
// cef not enabled
Ok(None) => {}
let is_cef_used = {
let manifest_guard = app_settings.manifest.lock().unwrap();
let enabled_features = manifest_guard.all_enabled_features(&merged_features);
manifest_guard.is_cef_runtime_used(&enabled_features, target_triple)
};

if !is_cef_used {
return Ok(());
}

match crate::cef::exporter::ensure_cef_directory(target_triple, &app_settings.workspace_dir) {
#[cfg(not(windows))]
Ok(Some(_cef_dir)) => {
Ok(_cef_dir) => {
let _options = options;
}
// on Windows we must copy the cef files next to the executable.
// We also do this for builds since we can't codesign the global cache.
#[cfg(windows)]
Ok(Some(cef_dir)) => {
Ok(cef_dir) => {
let out_dir = app_settings.out_dir(options, tauri_dir)?;
crate::helpers::fs::copy_dir_all(&cef_dir, &out_dir)?;
}
Expand Down Expand Up @@ -941,6 +941,7 @@ impl AppSettings for RustAppSettings {
config.bundle.clone(),
updater_settings,
arch64bits,
self.target(options),
)?;

settings.macos.skip_stapling = options.skip_stapling;
Expand Down Expand Up @@ -1425,7 +1426,7 @@ pub fn get_profile_dir(options: &Options) -> &str {
}
}

#[allow(unused_variables, deprecated)]
#[allow(unused_variables, deprecated, clippy::too_many_arguments)]
pub(crate) fn tauri_config_to_bundle_settings(
settings: &RustAppSettings,
features: &[String],
Expand All @@ -1434,12 +1435,13 @@ pub(crate) fn tauri_config_to_bundle_settings(
config: crate::helpers::config::BundleConfig,
updater_config: Option<UpdaterSettings>,
arch64bits: bool,
target_triple: Option<&str>,
) -> crate::Result<BundleSettings> {
let enabled_features = settings
.manifest
.lock()
.unwrap()
.all_enabled_features(features);
let is_cef_used = {
let manifest_guard = settings.manifest.lock().unwrap();
let enabled_features = manifest_guard.all_enabled_features(features);
manifest_guard.is_cef_runtime_used(&enabled_features, target_triple)
};

#[allow(unused_mut)]
let mut resources = config
Expand Down Expand Up @@ -1504,8 +1506,7 @@ pub(crate) fn tauri_config_to_bundle_settings(
}
}

if !enabled_features.contains(&"cef".into()) && !enabled_features.contains(&"tauri/cef".into())
{
if !is_cef_used {
depends_deb.push("libwebkit2gtk-4.1-0".to_string());
libs.push("libwebkit2gtk-4.1.so.0".into());
}
Expand Down Expand Up @@ -1561,10 +1562,10 @@ pub(crate) fn tauri_config_to_bundle_settings(
let entitlements = if let Some(user_provided_entitlements) = config.macos.entitlements {
crate::helpers::plist::merge_plist(vec![
PathBuf::from(user_provided_entitlements).into(),
plist::Value::Dictionary(required_entitlements(tauri_config, &enabled_features)?).into(),
plist::Value::Dictionary(required_entitlements(tauri_config, is_cef_used)?).into(),
])?
} else {
required_entitlements(tauri_config, &enabled_features)?.into()
required_entitlements(tauri_config, is_cef_used)?.into()
};

Some(tauri_bundler::bundle::Entitlements::Plist(entitlements))
Expand Down Expand Up @@ -1724,9 +1725,7 @@ pub(crate) fn tauri_config_to_bundle_settings(
}),
license_file: config.license_file.map(|l| tauri_dir.join(l)),
updater: updater_config,
cef_path: if enabled_features.contains(&"cef".into())
|| enabled_features.contains(&"tauri/cef".into())
{
cef_path: if is_cef_used {
std::env::var_os("CEF_PATH").map(PathBuf::from)
} else {
None
Expand All @@ -1738,7 +1737,7 @@ pub(crate) fn tauri_config_to_bundle_settings(
#[cfg(target_os = "macos")]
fn required_entitlements(
tauri_config: &Config,
enabled_features: &[String],
is_cef_used: bool,
) -> crate::Result<plist::Dictionary> {
let mut entitlements = plist::Dictionary::new();

Expand Down Expand Up @@ -1767,7 +1766,7 @@ fn required_entitlements(
}
}

if enabled_features.contains(&"cef".into()) || enabled_features.contains(&"tauri/cef".into()) {
if is_cef_used {
entitlements.insert("com.apple.security.cs.allow-jit".to_string(), true.into());
entitlements.insert(
"com.apple.security.cs.allow-unsigned-executable-memory".to_string(),
Expand Down
Loading
Loading