Saturday, April 02, 2016

Rain causes Rust

One thing that the wet weather in recent weeks accomplished was to give me some time to play with Rust again, after a go-round a couple of years back, when it still needed to run in an mingw prompt, the code was full of sigils, and I couldn't get an executable to link against advapi32.dll; then again towards the end of 2014 when I migrated a fork of the rust-windows project to the then-current version.

Last year was a bit of a wash all over, coding for fun being one of the major casualties of the year, so it was pretty much a start anew, to build myself a simple "hello world", porting a simple Win32 program to the new language.

It was reasonably easy to find useful samples and fragments from which to Frankenstein together a working program. What I did not find, however, was any good guide to adding resources to the project using the native (rather than the foreign) tool-chain. So I cast around a bit and hacked this together:


It's hacky, since it builds the .rc file to a .res file that actually calls itself a .lib, so that the cargo tool will add the extensionless name as a .lib to the linker, and the linker, fortunately, ignores the file extension and just looks at the file content. It's also hacky in that it hardcodes the path to a local rc.exe, and works arounf the fact that that tool does not offer an output directory parameter by treewalking from the directory where we want to place the output to where the source resides.

I'm sure there must be a better way, but this works. Apart from the fact that a VERSIONINFO compiles OK into the resulting .exe (as can be seen by opening it in Visual Studio), but doesn't show in the file properties. Application icons work just fine, though.

No comments :