Build: the wx-rs build script chose the platform with cfg!(), which in a build script describes the build host, so a Linux-to-Windows build took the GTK path. It now reads CARGO_CFG_TARGET_*, and Windows/GNU builds through wx-config exactly like GTK, against a static wxMSW from scripts/build-wx-windows.sh. The C++ runtime is linked statically, so the .exe imports only Windows system DLLs. crates/alkane-gui/build.rs embeds an application manifest (Common Controls v6, per-monitor DPI v2, UTF-8 code page, Windows 10/11), the icon and version info. Bridge on wxMSW (patches 0007/0008): - the upstream frame's invisible "OSX key events" child sat above the UI on MSW and swallowed every click and key; it is no longer created there - light/dark is chosen before the first window (wxMSW ignores it later) and follows the Windows app mode, with dark grid rules for the data view - the generic wxDataViewCtrl gets mouse input in its inner main window, so drag-select and the per-cell / per-icon tooltips bind there (GTK keeps its native GtkTreeView paths; the icon hit-test is shared) - sizes cross the Rust/C++ boundary in DIPs (identity on GTK), so columns, icons, KPI cards and the status bar scale at 125-200 % - vector shapes go through GDI+ (anti-aliased like Cairo on GTK); selected rows use the themed list-view text colour like the native renderer - the frame never opens larger than the monitor work area; title-bar icon from the executable; upstream menu insert no longer reads UTF-8 as UTF-16 App: OS differences live in alkane_core::platform (settings in %APPDATA%\alkane-toolkit, owner-only secret files, NUL, console-less helper processes). SSH password logins use SSH_ASKPASS with the toolkit itself as the helper on every platform, replacing sshpass, which Windows lacks. Release builds are GUI-subsystem; headless modes attach to the parent console. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
92 lines
3.6 KiB
Rust
92 lines
3.6 KiB
Rust
//! Build script for the alkane-toolkit binary. On Windows targets it compiles
|
|
//! windows/alkane-toolkit.rc (application manifest, icon, version info, and
|
|
//! wxMSW's stock resources) and links the result into the GUI executable only.
|
|
//! Other targets need nothing here.
|
|
|
|
use std::env;
|
|
use std::path::PathBuf;
|
|
use std::process::Command;
|
|
|
|
fn main() {
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
if env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("windows") {
|
|
return;
|
|
}
|
|
for f in [
|
|
"alkane-toolkit.rc",
|
|
"alkane-toolkit.exe.manifest",
|
|
"alkane-toolkit.ico",
|
|
] {
|
|
println!("cargo:rerun-if-changed=windows/{f}");
|
|
}
|
|
println!("cargo:rerun-if-env-changed=WX_RS_WXCONFIG");
|
|
if let Err(e) = compile_resources() {
|
|
panic!("alkane-gui: Windows resources: {e}");
|
|
}
|
|
}
|
|
|
|
fn compile_resources() -> Result<(), String> {
|
|
// The resource compiler and wx's resource include path come from the same
|
|
// wx-config the wx-rs bridge builds against, so they always match the
|
|
// linked wxMSW (and the mingw cross windres when cross-compiling).
|
|
let wxconfig = env::var("WX_RS_WXCONFIG").unwrap_or_else(|_| "wx-config".into());
|
|
let run = |arg: &str| -> Result<String, String> {
|
|
let out = Command::new(&wxconfig)
|
|
.arg(arg)
|
|
.output()
|
|
.map_err(|e| format!("cannot run {wxconfig} {arg}: {e}"))?;
|
|
if !out.status.success() {
|
|
return Err(format!("{wxconfig} {arg} failed"));
|
|
}
|
|
String::from_utf8(out.stdout).map_err(|e| e.to_string())
|
|
};
|
|
let rescomp = run("--rescomp")?;
|
|
let mut words = rescomp.split_whitespace();
|
|
let windres = words.next().ok_or("wx-config --rescomp printed nothing")?;
|
|
let mut args: Vec<String> = words.map(str::to_owned).collect();
|
|
// rcdefs.h lives in the build-specific setup directory, which --rescomp
|
|
// omits; it is the -I entry of --cxxflags.
|
|
for flag in run("--cxxflags")?.split_whitespace() {
|
|
if let Some(dir) = flag.strip_prefix("-I") {
|
|
args.push("--include-dir".into());
|
|
args.push(dir.into());
|
|
}
|
|
}
|
|
|
|
let version = env::var("CARGO_PKG_VERSION").unwrap_or_default();
|
|
let mut parts = version
|
|
.split(['.', '-', '+'])
|
|
.map(|p| p.parse::<u16>().unwrap_or(0));
|
|
let (major, minor, patch) = (
|
|
parts.next().unwrap_or(0),
|
|
parts.next().unwrap_or(0),
|
|
parts.next().unwrap_or(0),
|
|
);
|
|
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").map_err(|e| e.to_string())?);
|
|
let out =
|
|
PathBuf::from(env::var("OUT_DIR").map_err(|e| e.to_string())?).join("alkane-toolkit-res.o");
|
|
let status = Command::new(windres)
|
|
.args(&args)
|
|
.arg("--include-dir")
|
|
.arg(manifest_dir.join("windows"))
|
|
.arg(format!("--define=ALKANE_VER_MAJOR={major}"))
|
|
.arg(format!("--define=ALKANE_VER_MINOR={minor}"))
|
|
.arg(format!("--define=ALKANE_VER_PATCH={patch}"))
|
|
.arg(format!("--define=ALKANE_VER_STR=\\\"{version}\\\""))
|
|
.arg("--input")
|
|
.arg(manifest_dir.join("windows/alkane-toolkit.rc"))
|
|
.arg("--output-format=coff")
|
|
.arg("--output")
|
|
.arg(&out)
|
|
.status()
|
|
.map_err(|e| format!("cannot run {windres}: {e}"))?;
|
|
if !status.success() {
|
|
return Err(format!("{windres} failed ({status})"));
|
|
}
|
|
// Only the GUI binary carries the manifest/icon; miner_probe stays a plain
|
|
// console tool. A linked object (not an archive member) is never dropped by
|
|
// the linker, which is what keeps the resource section in the .exe.
|
|
println!("cargo:rustc-link-arg-bin=alkane-toolkit={}", out.display());
|
|
Ok(())
|
|
}
|