Teach GHC to Compile Windows Resource Files
We should teach GHC to compile rc files passed to it on the command line, in the same way it calls cc on passed in C files, cxx on passed in C++ files, and the assembler on passed in asm files.
What are Resource Files?
Resource files (sometimes called "rc scripts") are a Win32-specific mechanism for declaring and including various sorts of binary resources in DSOs or executables. They serve a loosely analogous purpose to the XML files generated by Glade for GTK interfaces, or the nib files generated by Apple's interface builder. Resource files are very common in Win32 application development.
Why should GHC care?
Unlike Glade XML or Apple nib files (which are read by applications at runtime), rc files are compiled into object files by a resource file compiler (The mingw-w64 toolchain provides one called windres.exe) that are linked into the final binary. The C preprocessor is also run on rc files before compilation. For these reasons, the build process for a Win32 application typically treats rc files like C/C++ source files.
Teaching GHC to run windres on rc files will allow an
rc-sources field to be added to cabal files, which would make building Win32 applications with plain cabal much easier. See https://github.com/haskell/cabal/issues/6939. Such a field could in principle be added to cabal without any GHC support, but cabal leans on GHC for handling the files in
asm-sources; I believe
rc-sources should work the same way.
Extend existing machinery in GHC for invoking cc on input C files, etc. to call
windres.exe on input rc files. Any options that affect how the C preprocessor runs should be passed to windres, as they are passed to cc/cxx.
winders.exe is provided with the mingw-w64 toolchain, so existing mechanisms for finding auxiliary compilers on the path can be reused. This functionality is only relevant when Win32 is the target platform for compilation; there's nothing sensible to do with rc files on other platforms (as far as I know).