Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix xwin cross-compilation #21

Merged
merged 2 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
}
Loading