diff --git a/README.md b/README.md index 4aa7e7c..06aa8c1 100755 --- a/README.md +++ b/README.md @@ -68,3 +68,11 @@ on Windows when using Microsoft Visual C++ (MSVC). MicroSEH is compatible with and has been tested on Windows platforms with the following architectures: **x86**, **x86_64** and **aarch64**. + +When building for other unsupported platforms, the library will disable exception +handling and panic when `try_seh` is called. + +## Cross-Compiling + +Cross-compiling for Windows is possible with full support for SEH using the +[cargo-xwin](https://github.com/rust-cross/cargo-xwin) project. diff --git a/build.rs b/build.rs index b8f6401..d83ce37 100755 --- a/build.rs +++ b/build.rs @@ -1,16 +1,12 @@ -#[cfg(all(windows, not(docsrs)))] -extern crate cc; - -#[cfg(all(windows, not(docsrs)))] fn main() { - // TODO: this is a hack to allow this crate to build on docs.rs. + // NOTE: this is a hack to allow this crate to build on docs.rs. // https://github.com/sonodima/microseh/pull/11#issuecomment-2385633164 - if !std::env::var("HOST").unwrap_or_default().contains("gnu") { - cc::Build::new().file("src/stub.c").compile("sehstub"); + if std::env::var_os("CARGO_CFG_DOCSRS").is_some() + || std::env::var_os("CARGO_CFG_WINDOWS").is_none() + { + println!("cargo:warning=building for a non-supported platform, exception handling will not be available"); + return; } -} -#[cfg(any(not(windows), docsrs))] -fn main() { - println!("cargo:warning=building for a non-supported platform, exception handling will not be available"); + cc::Build::new().file("src/stub.c").compile("sehstub"); }