winresource
winresource copied to clipboard
Review all `cfg` usages for cross-compilation use-cases
Using #[cfg(target_os = "windows")]
in build.rs
(and its dependencies like lib.rs
of this crate) may not work as expected because build.rs
is executed on the host. This means that target_os
is always equal to host_os
when compiling build.rs
. E.g. if we use rustc
on Linux and want to cross-compile binaries that run on Windows, target_os
in build.rs
is "linux"
.
Instead, we have to use environment variables like CARGO_CFG_TARGET_OS
which are set to the actual build target properties.
This may also apply to other definitions like cfg!(target_arch = "x86_64")
, etc.