mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Fix cross compile build scripts
This commit is contained in:
21
Cargo.lock
generated
21
Cargo.lock
generated
@@ -321,7 +321,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"syn 2.0.101",
|
||||
"tempfile",
|
||||
"toml 0.8.22",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2050,15 +2050,6 @@ dependencies = [
|
||||
"zerovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.8.22"
|
||||
@@ -2327,7 +2318,6 @@ dependencies = [
|
||||
"walkdir",
|
||||
"webview2-com-sys",
|
||||
"windows",
|
||||
"winres",
|
||||
"winsafe",
|
||||
"zip",
|
||||
"zstd",
|
||||
@@ -2843,15 +2833,6 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winres"
|
||||
version = "0.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b68db261ef59e9e52806f688020631e987592bd83619edccda9c47d42cde4f6c"
|
||||
dependencies = [
|
||||
"toml 0.5.11",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winsafe"
|
||||
version = "0.0.20"
|
||||
|
||||
@@ -61,7 +61,6 @@ sha1_smol = "1.0"
|
||||
time = "0.3"
|
||||
os_info = "3.8"
|
||||
neon = "1"
|
||||
winres = "0.1"
|
||||
tempfile = "3.9"
|
||||
ntest = "0.9"
|
||||
pretty_assertions = "1.4"
|
||||
|
||||
@@ -126,7 +126,4 @@ ntest.workspace = true
|
||||
pretty_assertions.workspace = true
|
||||
|
||||
[build-dependencies]
|
||||
semver.workspace = true
|
||||
|
||||
[target.'cfg(windows)'.build-dependencies]
|
||||
winres.workspace = true
|
||||
semver.workspace = true
|
||||
@@ -1,33 +1,31 @@
|
||||
#![allow(unused_variables)]
|
||||
|
||||
use std::env;
|
||||
use std::{env, path::Path};
|
||||
|
||||
fn main() {
|
||||
#[cfg(target_os = "windows")]
|
||||
delay_load();
|
||||
|
||||
let version = env!("CARGO_PKG_VERSION");
|
||||
let ver = semver::Version::parse(&version).expect("Unable to parse ngbv output as semver version");
|
||||
let ver: u64 = ver.major << 48 | ver.minor << 32 | ver.patch << 16;
|
||||
let desc = format!("Velopack {}", version);
|
||||
|
||||
println!("cargo:rustc-env=NGBV_VERSION={}", version);
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
winres::WindowsResource::new()
|
||||
.set_manifest_file("app.manifest")
|
||||
.set_version_info(winres::VersionInfo::PRODUCTVERSION, ver)
|
||||
.set_version_info(winres::VersionInfo::FILEVERSION, ver)
|
||||
.set("CompanyName", "Velopack")
|
||||
.set("ProductName", "Velopack")
|
||||
.set("ProductVersion", &version)
|
||||
.set("FileDescription", &desc)
|
||||
.set("LegalCopyright", "Caelan Sayler (c) 2023, Velopack Ltd. (c) 2024")
|
||||
.compile()
|
||||
.unwrap();
|
||||
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
|
||||
if target_os == "windows" {
|
||||
delay_load();
|
||||
link_manifest_msvc(Path::new("app.manifest"));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn link_manifest_msvc(manifest_path: &Path) {
|
||||
println!("cargo:rustc-link-arg-bins=/MANIFEST:EMBED");
|
||||
println!(
|
||||
"cargo:rustc-link-arg-bins=/MANIFESTINPUT:{}",
|
||||
manifest_path.canonicalize().unwrap().display()
|
||||
);
|
||||
println!("cargo:rustc-link-arg-bins=/MANIFESTUAC:NO");
|
||||
}
|
||||
|
||||
|
||||
fn delay_load() {
|
||||
let features = env::var("CARGO_CFG_TARGET_FEATURE").unwrap_or_default();
|
||||
if features.contains("crt-static") {
|
||||
@@ -42,7 +40,6 @@ fn delay_load() {
|
||||
}
|
||||
|
||||
// https://github.com/rust-lang/rustup/blob/master/build.rs#L45
|
||||
#[cfg(target_os = "windows")]
|
||||
fn delay_load_exe(bin_name: &str) {
|
||||
// Only search system32 for DLLs
|
||||
// This applies to DLLs loaded at load time. However, this setting is ignored
|
||||
|
||||
@@ -3,16 +3,34 @@ extern crate cbindgen;
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||
cbindgen::Builder::new()
|
||||
.with_crate(crate_dir)
|
||||
.with_documentation(true)
|
||||
.with_language(cbindgen::Language::C)
|
||||
.with_autogen_warning("/* THIS FILE IS AUTO-GENERATED - DO NOT EDIT */")
|
||||
.with_include_guard("VELOPACK_H")
|
||||
.with_cpp_compat(true)
|
||||
.with_include_version(true)
|
||||
.generate()
|
||||
.expect("Unable to generate bindings")
|
||||
.write_to_file("include/Velopack.h");
|
||||
}
|
||||
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
|
||||
let host_triple = env::var("HOST").unwrap_or_default();
|
||||
|
||||
// Extract host OS from the host triple
|
||||
let host_os = if host_triple.contains("linux") {
|
||||
"linux"
|
||||
} else if host_triple.contains("windows") {
|
||||
"windows"
|
||||
} else if host_triple.contains("macos") || host_triple.contains("darwin") {
|
||||
"macos"
|
||||
} else {
|
||||
"unknown"
|
||||
};
|
||||
|
||||
if host_os == target_os {
|
||||
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||
cbindgen::Builder::new()
|
||||
.with_crate(crate_dir)
|
||||
.with_documentation(true)
|
||||
.with_language(cbindgen::Language::C)
|
||||
.with_autogen_warning("/* THIS FILE IS AUTO-GENERATED - DO NOT EDIT */")
|
||||
.with_include_guard("VELOPACK_H")
|
||||
.with_cpp_compat(true)
|
||||
.with_include_version(true)
|
||||
.generate()
|
||||
.expect("Unable to generate bindings")
|
||||
.write_to_file("include/Velopack.h");
|
||||
} else {
|
||||
println!("cargo:warning=Skipping cbindgen during cross-compilation (host OS: {}, target OS: {})", host_os, target_os);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user