Closed rhysd closed 1 year ago
Unfortunately, this doesn't work. The crate can be used in cross-compile scenarios, so what matters is the target operating system. However, even #[cfg(windows)]
or #[cfg(target_os = "windows")]
is not the proper condition attribute, as a build for Windows, compiled on Linux, will compile build.rs
with target operating system Linux, hence not compiling the Windows part. This is also explained in the Readme. The examples in the Readme and the implementation of this detail are actually very carefully chosen to work around all these annoying corner cases. I know it's not perfect, and it sometimes compiles too much, but it's the best that can be done to work in a broad set of circumstances. Unfortunately, in cross-compilation scenarios, there is no way to use conditional compilation for the actual target we are compiling the library for when building build.rs
, that is the root cause of the issue.
Indeed, the extern crate
statement seems superfluous now. That change makes sense and I would merge that.
Thank you for the point. Honestly I didn't consider cross-compilation at all. I'll update this branch tomorrow.
I removed extern crate
from document at c5e3473.
And I also fixed some typos which I found in API documents and sources at dd11dc1.
Please note, I haven't forgotten about your PR. I will look into it as soon as I have time.
Yes, please take your pace. This PR isn't urgent.
Nice catch on the typos. Seems like this repository was plagued with typos, which can also be seen in the commit history. It's good to get rid of those.
Merged. Thank you for your contribution.
This PR improves usage document in README.md.
#[cfg(windows)]
attribute is compiled only on Windows. This speeds up compilation of build.rs.extern crate
is no longer necessary after Rust 2018. When runningcargo new
, the default edition is Rust 2021.