Skip to content
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

Add support for compiling .rc files into Windows .res files #3702

Closed
AlexMax opened this issue Nov 16, 2019 · 5 comments · Fixed by #17069
Closed

Add support for compiling .rc files into Windows .res files #3702

AlexMax opened this issue Nov 16, 2019 · 5 comments · Fixed by #17069
Labels
accepted This proposal is planned. enhancement Solving this issue will likely involve adding new logic or components to the codebase. os-windows proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone

Comments

@AlexMax
Copy link

AlexMax commented Nov 16, 2019

I tried to compile an old Win32 C program with a build.zig and didn't see an obvious happy path to compile an .rc file into a .res file and add it to the build. These seem to be somewhat common in Win32 projects, so I think that if the intention is to support gradually converting Win32 C programs to Zig, being able to easily compile resource files and add them to the target should be part of that.

LLVM comes with llvm-rc, and it worked for me, but unlike windres and whatever the MSVC resource compiler is, llvm-rc doesn't run the preprocessor against the source file, so a preprocessing step with clang -E is also necessary. However, once you get a .res file out of it, it can be added to the build with addObjectFile.

@Sahnvour Sahnvour added contributor friendly This issue is limited in scope and/or knowledge of Zig internals. zig build system std.Build, the build runner, `zig build` subcommand, package management labels Nov 16, 2019
@andrewrk andrewrk added proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. and removed contributor friendly This issue is limited in scope and/or knowledge of Zig internals. zig build system std.Build, the build runner, `zig build` subcommand, package management labels Nov 27, 2019
@andrewrk andrewrk changed the title No "happy path" for compiling .rc files in build system Add support for compiling .rc files into Windows .res files Nov 27, 2019
@andrewrk andrewrk added this to the 0.7.0 milestone Nov 27, 2019
@andrewrk andrewrk added os-windows enhancement Solving this issue will likely involve adding new logic or components to the codebase. labels Nov 27, 2019
@adontz
Copy link

adontz commented Feb 21, 2020

For now (0.5.0+652efe38b), using addObjectFile breaks debugging in Visual Studio Code with C/C++ (ms-vscode.cpptools) extension. I am not sure why, but I'll be happy to provide any information.

@mlarouche
Copy link
Contributor

LLVM has a mostly complete RC compiler that we could port to Zig and improve compatiblity https://github.com/llvm/llvm-project/tree/master/llvm/tools/llvm-rc

@adontz
Copy link

adontz commented Feb 22, 2020

There are some free standalone editors (http://www.resedit.net/, http://angusj.com/resourcehacker/) so just being able to compile rc files will be good enough experience.

@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Oct 17, 2020
@zx2c4
Copy link

zx2c4 commented Feb 18, 2021

The typical tool for this is binutils' windres. There's a port of that to llvm's separate tools here: https://github.com/mstorsjo/llvm-mingw/blob/master/wrappers/windres-wrapper.c . It essentially pipes llvm-rc to llvm-cvtres. Having something like that available as a zig subcommand would allow zig to be used as a drop-in compiler suite for win32 C development and more.

@andrewrk andrewrk added the accepted This proposal is planned. label Feb 18, 2021
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Feb 18, 2021
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
@squeek502
Copy link
Collaborator

squeek502 commented Nov 1, 2022

I've started working on this here: https://github.com/squeek502/resinator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted This proposal is planned. enhancement Solving this issue will likely involve adding new logic or components to the codebase. os-windows proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants