Skip to content

Commit

Permalink
Merge pull request #21 from sonodima/fix/win-cross-compile
Browse files Browse the repository at this point in the history
fix xwin cross-compilation
  • Loading branch information
sonodima authored Oct 6, 2024
2 parents 1695c95 + 24f43fe commit 5543522
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
18 changes: 7 additions & 11 deletions build.rs
Original file line number Diff line number Diff line change
@@ -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");
}

0 comments on commit 5543522

Please sign in to comment.