mirror of
https://github.com/bherbruck/solidcraft.git
synced 2026-11-16 05:31:02 +00:00
3ad0008052
* Windows: link the app and the CLI with an 8 MiB main stack (#15438) Windows gives a main thread 1 MiB unless the exe asks for more; design changes run on the window thread and the CLI evaluates on its main thread, while the kernel asks for 8 MiB and fillet certification overflows 1 MiB. Each Windows MSVC binary now links with /STACK:8388608 from its own build.rs (rustc-link-arg-bins), so test binaries are unchanged. A test checks the CLI binaries' PE stack reserve. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(cli): the main-stack test reads PE32 images too A 32-bit MSVC build writes a PE32 image (optional-header magic 0x10b), whose SizeOfStackReserve is 4 bytes at offset 72; the test asserted PE32+ only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: bherbruck <brennen.herbruck@gmail.com>
39 lines
2.6 KiB
Rust
39 lines
2.6 KiB
Rust
#![forbid(unsafe_code)]
|
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
let icon = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../assets/icons/app/windows/exports/solidcraft-executable.ico");
|
|
println!("cargo:rerun-if-changed={}", icon.display());
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
println!("cargo:rerun-if-env-changed=CARGO_PKG_VERSION");
|
|
if std::env::var("CARGO_CFG_TARGET_OS")? != "windows" {
|
|
return Ok(());
|
|
}
|
|
// Design changes run on the window thread, and Windows gives a main thread 1 MiB of stack unless
|
|
// the binary asks for more: the kernel asks for 8 MiB (`KERNEL_STACK`), and fillet certification
|
|
// overflows 1 MiB (#15438).
|
|
if std::env::var("CARGO_CFG_TARGET_ENV")? == "msvc" {
|
|
println!("cargo:rustc-link-arg-bins=/STACK:8388608");
|
|
}
|
|
let out = std::path::PathBuf::from(std::env::var_os("OUT_DIR").ok_or("missing OUT_DIR")?);
|
|
let copy = out.join("solidcraft.ico");
|
|
std::fs::copy(icon, ©)?;
|
|
let rc = out.join("solidcraft.rc");
|
|
let icon_line = format!("1 ICON \"{}\"\n", copy.display().to_string().replace('\\', "/"));
|
|
std::fs::write(&rc, format!("{icon_line}{}", version_resource(&std::env::var("CARGO_PKG_VERSION")?)))?;
|
|
embed_resource::compile_for(&rc, ["solidcraft"], embed_resource::NONE).manifest_required()?;
|
|
Ok(())
|
|
}
|
|
|
|
/// The Windows version resource (what Explorer's Details tab shows and what a launcher reads).
|
|
/// `FileVersion` and `ProductVersion` are the package version verbatim (`0.25.1`, `0.26.0-rc.1`):
|
|
/// ArtCraft's launcher parses the `ProductVersion` string as semver, so a fourth `.0` would not
|
|
/// read. The binary `FILEVERSION` fields need four numbers and take the leading `major.minor.patch`.
|
|
fn version_resource(version: &str) -> String {
|
|
let mut numbers = version.split(['-', '+']).next().unwrap_or("").split('.').map(|p| p.parse::<u16>().unwrap_or(0));
|
|
let mut next = || numbers.next().unwrap_or(0);
|
|
let (major, minor, patch) = (next(), next(), next());
|
|
format!(
|
|
"1 VERSIONINFO\nFILEVERSION {major},{minor},{patch},0\nPRODUCTVERSION {major},{minor},{patch},0\nFILEOS 0x40004\nFILETYPE 0x1\n{{\nBLOCK \"StringFileInfo\"\n{{\nBLOCK \"040904B0\"\n{{\nVALUE \"CompanyName\", \"SolidCraft contributors\"\nVALUE \"FileDescription\", \"SolidCraft, parametric 3D CAD\"\nVALUE \"FileVersion\", \"{version}\"\nVALUE \"InternalName\", \"solidcraft\"\nVALUE \"OriginalFilename\", \"solidcraft.exe\"\nVALUE \"ProductName\", \"SolidCraft\"\nVALUE \"ProductVersion\", \"{version}\"\n}}\n}}\nBLOCK \"VarFileInfo\"\n{{\nVALUE \"Translation\", 0x0409, 1200\n}}\n}}\n"
|
|
)
|
|
}
|