2024-03-01 11:29:01 +00:00
|
|
|
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
2021-04-10 22:09:09 +00:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
2024-08-26 22:25:36 +00:00
|
|
|
use tauri_build::WindowsAttributes;
|
|
|
|
|
|
2021-03-13 01:10:19 +00:00
|
|
|
fn main() {
|
2024-02-26 18:17:45 +00:00
|
|
|
tauri_build::try_build(
|
|
|
|
|
tauri_build::Attributes::new()
|
|
|
|
|
.codegen(tauri_build::CodegenContext::new())
|
2024-08-26 22:25:36 +00:00
|
|
|
.windows_attributes(WindowsAttributes::new_without_app_manifest())
|
2024-02-26 18:17:45 +00:00
|
|
|
.plugin(
|
|
|
|
|
"app-menu",
|
|
|
|
|
tauri_build::InlinedPlugin::new().commands(&["toggle", "popup"]),
|
2024-02-28 11:45:28 +00:00
|
|
|
)
|
2024-07-12 12:52:53 +00:00
|
|
|
.app_manifest(tauri_build::AppManifest::new().commands(&[
|
|
|
|
|
"log_operation",
|
|
|
|
|
"perform_request",
|
|
|
|
|
"echo",
|
2025-01-02 11:19:50 +00:00
|
|
|
"spam",
|
2024-07-12 12:52:53 +00:00
|
|
|
])),
|
2024-02-26 18:17:45 +00:00
|
|
|
)
|
2024-02-16 11:24:40 +00:00
|
|
|
.expect("failed to run tauri-build");
|
2024-08-26 22:25:36 +00:00
|
|
|
|
2025-04-13 21:46:14 +00:00
|
|
|
#[cfg(windows)]
|
|
|
|
|
{
|
|
|
|
|
// workaround needed to prevent `STATUS_ENTRYPOINT_NOT_FOUND` error in tests
|
|
|
|
|
// see https://github.com/tauri-apps/tauri/pull/4383#issuecomment-1212221864
|
|
|
|
|
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
|
|
|
|
|
let target_env = std::env::var("CARGO_CFG_TARGET_ENV");
|
|
|
|
|
let is_tauri_workspace = std::env::var("__TAURI_WORKSPACE__").is_ok_and(|v| v == "true");
|
|
|
|
|
if is_tauri_workspace && target_os == "windows" && Ok("msvc") == target_env.as_deref() {
|
|
|
|
|
embed_manifest_for_tests();
|
|
|
|
|
}
|
2024-08-26 22:25:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-13 21:46:14 +00:00
|
|
|
#[cfg(windows)]
|
2024-08-26 22:25:36 +00:00
|
|
|
fn embed_manifest_for_tests() {
|
|
|
|
|
static WINDOWS_MANIFEST_FILE: &str = "windows-app-manifest.xml";
|
|
|
|
|
|
|
|
|
|
let manifest = std::env::current_dir()
|
|
|
|
|
.unwrap()
|
2024-08-27 21:42:30 +00:00
|
|
|
.join("../../../crates/tauri-build/src")
|
2024-08-26 22:25:36 +00:00
|
|
|
.join(WINDOWS_MANIFEST_FILE);
|
|
|
|
|
|
|
|
|
|
println!("cargo:rerun-if-changed={}", manifest.display());
|
|
|
|
|
// Embed the Windows application manifest file.
|
|
|
|
|
println!("cargo:rustc-link-arg=/MANIFEST:EMBED");
|
|
|
|
|
println!(
|
|
|
|
|
"cargo:rustc-link-arg=/MANIFESTINPUT:{}",
|
|
|
|
|
manifest.to_str().unwrap()
|
|
|
|
|
);
|
|
|
|
|
// Turn linker warnings into errors.
|
|
|
|
|
println!("cargo:rustc-link-arg=/WX");
|
2021-03-13 01:10:19 +00:00
|
|
|
}
|