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>
181 lines
7.1 KiB
Diff
181 lines
7.1 KiB
Diff
Subject: [PATCH 0006] build.rs: pick the platform from the target, not the build host; build Windows/GNU (mingw wxMSW) through wx-config like GTK
|
|
|
|
--- a/build.rs
|
|
+++ b/build.rs
|
|
@@ -12,22 +12,42 @@
|
|
const WX_SOURCE: &str =
|
|
"https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.2.1/wxWidgets-3.2.2.1.tar.bz2";
|
|
|
|
+// alkane-toolkit patch: decide the platform from the TARGET. A build script is
|
|
+// compiled for and runs on the build host, so `cfg!(windows)` etc. here describe
|
|
+// the host -- which made a Linux -> Windows cross build take the GTK path.
|
|
+// Cargo exposes the real target through CARGO_CFG_TARGET_* instead.
|
|
+fn target_os() -> String {
|
|
+ env::var("CARGO_CFG_TARGET_OS").unwrap_or_default()
|
|
+}
|
|
+
|
|
+fn target_env() -> String {
|
|
+ env::var("CARGO_CFG_TARGET_ENV").unwrap_or_default()
|
|
+}
|
|
+
|
|
fn is_windows() -> bool {
|
|
- cfg!(windows)
|
|
+ target_os() == "windows"
|
|
}
|
|
|
|
fn is_msvc() -> bool {
|
|
- cfg!(target_env = "msvc")
|
|
+ is_windows() && target_env() == "msvc"
|
|
}
|
|
|
|
fn is_osx() -> bool {
|
|
- cfg!(target_os = "macos")
|
|
+ target_os() == "macos"
|
|
}
|
|
|
|
// alkane-toolkit patch: real wxGTK3 support on Linux via wx-config
|
|
// (upstream stubbed every non-Windows/macOS target).
|
|
fn is_linux() -> bool {
|
|
- cfg!(target_os = "linux")
|
|
+ target_os() == "linux"
|
|
+}
|
|
+
|
|
+// alkane-toolkit patch: Linux (wxGTK) and Windows/GNU (wxMSW built with
|
|
+// mingw-w64, natively or cross from Linux) both build against a wx prefix
|
|
+// described by its wx-config script, so they share one code path. Upstream's
|
|
+// MSVC/nmake and macOS download-and-build paths are left as they were.
|
|
+fn uses_wx_config() -> bool {
|
|
+ is_linux() || (is_windows() && !is_msvc())
|
|
}
|
|
|
|
fn is_stub() -> bool {
|
|
@@ -41,8 +61,8 @@
|
|
if is_stub() {
|
|
return Ok(());
|
|
}
|
|
- if is_linux() {
|
|
- return Ok(()); // libs are linked inside build_linux()
|
|
+ if uses_wx_config() {
|
|
+ return Ok(()); // libs are linked inside build_with_wx_config()
|
|
}
|
|
|
|
let wx_libs = get_libs(&wx_path)?;
|
|
@@ -89,7 +109,7 @@
|
|
fn download_dist() -> Result<PathBuf, Box<dyn Error>> {
|
|
let dist_path = Path::new("./dist/");
|
|
let wx_path = PathBuf::from(format!("./dist/{}", WX_PATH));
|
|
- if wx_path.exists() || is_stub() || is_linux() {
|
|
+ if wx_path.exists() || is_stub() || uses_wx_config() {
|
|
return Ok(wx_path);
|
|
}
|
|
println!("cargo:warning=wx-rs: Downloading source to './dist/");
|
|
@@ -120,8 +140,8 @@
|
|
|
|
// alkane-toolkit patch: compile the bridge (upstream + widgets extension)
|
|
// against the wx shown by $WX_RS_WXCONFIG (default `wx-config`).
|
|
- if is_linux() {
|
|
- return build_linux();
|
|
+ if uses_wx_config() {
|
|
+ return build_with_wx_config();
|
|
}
|
|
|
|
if is_windows() {
|
|
@@ -232,25 +252,27 @@
|
|
)?)
|
|
}
|
|
|
|
-fn build_linux() -> Result<(), Box<dyn Error>> {
|
|
- // alkane-toolkit patch: GTK3 build driven entirely by wx-config, so the
|
|
- // same code builds against our vendored static wx 3.3.3 (WX_RS_WXCONFIG
|
|
- // pointing at its prefix) or any system wxGTK3.
|
|
+fn build_with_wx_config() -> Result<(), Box<dyn Error>> {
|
|
+ // alkane-toolkit patch: build driven entirely by wx-config, so the same code
|
|
+ // builds against our vendored static wx 3.3.3 (WX_RS_WXCONFIG pointing at its
|
|
+ // GTK or mingw prefix) or any system wx. wx-config is a POSIX shell script;
|
|
+ // cross builds run it on the Linux host, native mingw builds under MSYS2.
|
|
+ println!("cargo:rerun-if-env-changed=WX_RS_WXCONFIG");
|
|
let wxconfig = env::var("WX_RS_WXCONFIG").unwrap_or_else(|_| String::from("wx-config"));
|
|
- let cxxflags = String::from_utf8(
|
|
- Command::new(&wxconfig).arg("--cxxflags").output()?.stdout,
|
|
- )?;
|
|
- let libs = String::from_utf8(Command::new(&wxconfig).arg("--libs").output()?.stdout)?;
|
|
- // The widget bridge uses GTK directly (zebra-striping CSS), so add GTK's own
|
|
- // include paths. Best-effort: if pkg-config or gtk3-dev is missing the flags
|
|
- // are simply empty and the GTK-only code stays disabled.
|
|
- let gtk_cflags = Command::new("pkg-config")
|
|
- .args(["--cflags", "gtk+-3.0"])
|
|
- .output()
|
|
- .ok()
|
|
- .filter(|o| o.status.success())
|
|
- .and_then(|o| String::from_utf8(o.stdout).ok())
|
|
- .unwrap_or_default();
|
|
+ let wx_config = |arg: &str| -> Result<String, Box<dyn Error>> {
|
|
+ let out = Command::new(&wxconfig).arg(arg).output().map_err(|e| {
|
|
+ format!("wx-rs: cannot run {wxconfig} {arg} (set WX_RS_WXCONFIG): {e}")
|
|
+ })?;
|
|
+ if !out.status.success() {
|
|
+ return Err(format!("wx-rs: {wxconfig} {arg} failed").into());
|
|
+ }
|
|
+ Ok(String::from_utf8(out.stdout)?)
|
|
+ };
|
|
+ let cxxflags = wx_config("--cxxflags")?;
|
|
+ let libs = wx_config("--libs")?;
|
|
+ if is_windows() && !cxxflags.contains("__WXMSW__") {
|
|
+ return Err(format!("wx-rs: {wxconfig} is not a wxMSW build").into());
|
|
+ }
|
|
|
|
let mut build = cc::Build::new();
|
|
build.cpp(true)
|
|
@@ -259,15 +281,37 @@
|
|
for f in cxxflags.split_whitespace() {
|
|
build.flag(f);
|
|
}
|
|
- for f in gtk_cflags.split_whitespace() {
|
|
- build.flag(f);
|
|
+ if is_linux() {
|
|
+ // The widget bridge uses GTK directly (native rubber-band selection,
|
|
+ // tooltips, themed colours), so add GTK's own include paths.
|
|
+ // Best-effort: if pkg-config or gtk3-dev is missing the flags are simply
|
|
+ // empty and the GTK-only code stays disabled.
|
|
+ let gtk_cflags = Command::new("pkg-config")
|
|
+ .args(["--cflags", "gtk+-3.0"])
|
|
+ .output()
|
|
+ .ok()
|
|
+ .filter(|o| o.status.success())
|
|
+ .and_then(|o| String::from_utf8(o.stdout).ok())
|
|
+ .unwrap_or_default();
|
|
+ for f in gtk_cflags.split_whitespace() {
|
|
+ build.flag(f);
|
|
+ }
|
|
+ }
|
|
+ if is_windows() {
|
|
+ // Ship one self-contained .exe: link the C++ runtime statically rather
|
|
+ // than depending on the toolchain's libstdc++-6.dll/libgcc_s_seh-1.dll/
|
|
+ // libwinpthread-1.dll, which no Windows machine has. `-bundle` hands the
|
|
+ // archives to the final link instead of copying them into this rlib.
|
|
+ build.cpp_link_stdlib(None);
|
|
+ println!("cargo:rustc-link-lib=static:-bundle=stdc++");
|
|
+ println!("cargo:rustc-link-lib=static:-bundle=winpthread");
|
|
}
|
|
build.compile("wxbridge");
|
|
|
|
for flag in libs.split_whitespace() {
|
|
- if flag.starts_with('/') && flag.ends_with(".a") {
|
|
+ if flag.ends_with(".a") && Path::new(flag).is_absolute() {
|
|
// static wx builds: wx-config emits the archive as a full path
|
|
- let file = flag.rsplit('/').next().unwrap_or(flag);
|
|
+ let file = Path::new(flag).file_name().and_then(|f| f.to_str()).unwrap_or(flag);
|
|
let stem = file
|
|
.strip_prefix("lib")
|
|
.unwrap_or(file)
|
|
@@ -281,6 +325,9 @@
|
|
} else if flag == "-pthread" {
|
|
println!("cargo:rustc-link-arg=-pthread");
|
|
}
|
|
+ // `-mwindows` / `-Wl,--subsystem,windows` are deliberately dropped: the
|
|
+ // console-vs-GUI subsystem is the application's decision
|
|
+ // (`#![windows_subsystem]`), not the GUI library's.
|
|
}
|
|
Ok(())
|
|
}
|