-
Notifications
You must be signed in to change notification settings - Fork 697
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
Implementation Plan for Windows Resource Files (#142) #6939
Comments
@TravisWhitaker can you come up with a reason why this would be a bad idea? Otherwise, I’d say just go for it. |
Related #142 |
What one will do with Learned from the bad experiences, I'd want to see first an outline of documentation. (c.f. GHC-proposal.) |
Perhaps GHC itself should learn to handle RC files.
In the native case, there is nothing sensible to do with RC files and I suspect it should be a plan error. However, the mingw-w64 toolchain can be used as a cross-toolchain on Linux, so when cross compiling the cross-windres compiler can be used. So whether RC files are supported comes down to whether or not Windows is the target platform, and not necessarily the platform we're building on.
The C preprocessor is run on RC files before compilation. A common pattern is to assign names/numbers to Win32 resources in a C header file, which gets included in both the RC files (where the names are associated with the binary resources) and C files (where the names are passed to
They are a Win32-specific mechanism for including binary resources in a DSO or executable. You can read more about them here https://docs.microsoft.com/en-us/windows/win32/menurc/about-resource-files They are commonly used in the development of graphical Win32 applications. They serve a purpose somewhat similar to the XML files produced by Glade for GTK applications, or the nib files produced by Apple's Interface Builder, so one might ask why they deserve special treatment from the compiler. The key difference is that they are translated into object files at build time that are linked into the final binary, and share the symbol namespace as the other objects in the binary. In the context of their inclusion in a Haskell project, this makes them more like |
Are resource scripts completely windows specific, or could there in theory be a linux variant of it? The #6096 issue seems related, and RC is windows specific solution for that. I wonder if https://stackoverflow.com/questions/2627004/embedding-binary-blobs-using-gcc-mingw & http://gareus.org/wiki/embedding_resources_in_executables#architecture_dependent_binary_linking would actually work for other platforms too. I.e. we could have |
EDIT: above means, please go ahead with implementing |
@phadej Do you have any thoughts on which approach might be better:
For a field like |
Would be easiest to start with
Cabal could generate stub module file with pointers to data. (c.f. Paths_packagename.hs) |
RC scripts are quite common for Win32 application development. It'd be nice if Cabal were able to compile and link resource scripts at build time. Since
windres.exe
comes with mingw-w64, all that's needed is to teach cabal how to use it generate object files from RC files. I'd like to propose the following:rc-sources
field to the cabal file spec, functioning just likec-sources
,asm-sources
, etc.rc-options
(or perhapswindres-options
) field to the cabal file spec, functioning just likecc-options
, etc.windres.exe
on all of therc-sources
with therc-options
, respecting theincludes
andinclude-dirs
fields, and the--extra-include-dirs
flag.c-sources
.If this is a reasonable path forward, I'd be happy to tackle the implementation.
The text was updated successfully, but these errors were encountered: