-
Notifications
You must be signed in to change notification settings - Fork 6
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
Finally fixed docs.rs #11
Conversation
Oh, forgot the context on why I'm making a PR here for my project not building. Meanwhile mircoseh docs only exist for unsupported platforms |
Oh hold up, doesn't build perfect just yet |
Is this a cheap hack? Yes. Do we care? I hope not! I use If docs.rs picks up the cfg directives, we still get the intended effect. And once we can figure out how to reliably pass cfg flags to doc builds, we can remove the oneliner |
Thank you for your work on this! I'm with you with the fact that we should find out if there is a way to remove that ugly HOST==gnu check, but if it works it's good enough for now. |
Version 1.0.4 has now been released! |
Hello, in the latest version I unified your docs.rs compile-time checks with the previously existing platform checks. (e.g. moved the WIN32 check from the C stub into the build.rs file) Would you mind testing it for your use case and letting me know if it shows any regression? |
does not work for me anymore on a Cross Compile from Linux to Windows MSVC using XWIN
it works fine when changing the build.rs to so maybe this is a better way to do it? use std::env::var;
#[cfg(all(windows, not(docsrs)))]
extern crate cc;
fn main() {
// TODO: 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_os("CARGO_CFG_DOCSRS").is_none() && std::env::var_os("CARGO_CFG_WINDOWS").is_some(){
cc::Build::new().file("src/stub.c").compile("sehstub");
return
}
println!("cargo:warning=building for a non-supported platform, exception handling will not be available");
return;
}
the check
fails always on linux since thats the build host, not the target
got the idea from https://users.rust-lang.org/t/compile-for-windows-from-linux-when-have-build-rs/76858 |
Thank you, that sounds promising! I put the changes in this branch: Everything seems to build correctly for me. |
Does XWIN still allow for a working form of SEH in any capacity then? If it does, that might be very useful both here and for the people running docs.rs! That aside, is there any reason to always check for the doc variable and the OS variable? If XWIN sets the OS one, keep it as is. If not, it might be cleaner to use a logical or, check the OS first, and short-circuit into printing the warning and doing an early return |
I just tested it and it does! I will definitely mention it in the README :)
From my quick tests XWIN seems to be setting the CARGO_CFG_WINDOWS var |
TL;DR:
microseh should build fine on docs.rs with this.
I've tried a few times to get winmmf docs to build, but (understandably) docs.rs cannot build an msvc-targeted binary in its containerized environment. Best it can do is cross-compile with the msvc target, which does not work with cc-rs as per rust-lang/cc-rs#523 for a variety of technical reasons. The most important being references to CRT/compiler-specific things going on that a Linux toolchain can't fully cover.
This PR, however, builds just fine on Linux machines. Even when the target isn't cross! As expected, all of the tests panic with an unsupported notice, as the goal of this PR isn't to get it to just run on Linux. But more importantly, all of the docs build too! So this benefits both you and any dependents, for a small compile-time check that I borrowed from Alice Rhyl's advice referencing Tokio. Last but not least, I've added the proper configuration to ensure docs.rs understands to only build docs for Windows targets