nabijaczleweli / rust-embed-resource

A Cargo build script library to handle compilation and inclusion of Windows resources, in the most resilient fashion imaginable
MIT License
173 stars 29 forks source link

LLVM-RC support #30

Closed roblabla closed 3 years ago

roblabla commented 3 years ago

This is a bit of a rough draft implementing support for compiling resource files with llvm-rc, so we can cross-compile from linux to windows.

Something I noticed is that this crate will not embed the resource file when cross-compiling from linux with the MSVC target. The build won't fail, but the resulting executable won't have the resource. With this PR, cross-compiling for the windows targets will fail the build if the resource can't be embedded.

Fixes #29

nabijaczleweli commented 3 years ago

Okay so I uhh reorganised the thing, and it'd be great if you could test it on your end again.

Notably behaviourally:

roblabla commented 3 years ago

New version doesn't work, there's two problems:

  1. -xc is not recognized by clang-cl. This only causes a warning, e.g. clang: warning: unknown argument ignored in clang-cl: '-xc' [-Wunknown-argument], but I fear it might not be compatible with some compilers, e.g. people running cl.exe under wine.
  2. More importantly, the .preprocessed.rc file does not get created. It looks like clang-cl -E ignores -o, and always prints the preprocessed file to stdout? Running a quick test, clang --driver-mode=cl -E test.c -o test.lol.c on a simple C file did not create a test.lol.c file, and indeed printed to stdout the preprocessed contents.

EDIT: you can reproduce my toolchain with https://github.com/roblabla/msvc-wine#setting-up-this-toolchain-for-easy-cross-compilation-in-rust

nabijaczleweli commented 3 years ago

Ah, I missed that MSVC is incompatible as a feature. I fell back to your original preprocess to pipe + fs::write() method, could you try again, please?

roblabla commented 3 years ago

It works!

nabijaczleweli commented 3 years ago

Lovely, cheers!

nabijaczleweli commented 3 years ago

Released in v1.5.0!