[fpc-devel] resources on non-windows platform

Adriaan van Os fpc at microbizz.nl
Tue Nov 22 12:53:07 CET 2016


Paul Ishenin wrote:
> 21.11.2016 21:13, Anton Kavalenka wrote:
>> Is not the time came for own resource compiler for limited type of 
>> resources (BITMAP, CURSOR, MANIFEST, VERSIONINFO)?
> It should not be a problem for a very limited syntax.

I have a Version.r file that does things like

#define __version_hi_num__  2
#define __version_mid_num__ 0
#define __version_lo_num__  5

I can include the defines in an .rc file

#include "Version.r"

The .rc file can be compiled to a .res with windres on various platforms, either cross or native. 
Note that when running windres, you can specify the preprocessor to use, e.g. gcc. The .res can 
then be linked into the application using fpc.

On Mac OS X, I can

#include "Version.r"

in a MacOS .r file. The .r can compiled with Rez to a flat resource file or into a resource fork. 
Also, I can use the version defines in a Mac OS X plist using sed and the output of a small C program

#include <stdio.h>

int main( void )
{
   printf( "s|__CFBundleExecutable__|"__product__"|g\n");
   printf( "s|__CFBundleGetInfoString__|"__product__" "__version_description__", 
"__written_by__"|g\n");
   printf( "s|__CFBundleIdentifier__|"__product_identifier__"|g\n");
   printf( "s|__CFBundleName__|"__product__"|g\n");
   return 0;
}

So, for me it works for all the platforms I need. Of course, the .rc would use the version defines 
differently than the MacOS version info or the plist, but that needs to be setup only once.

Yes, this is very much like C, I don't like that either, but it does work.

Regards,

Adriaan van Os



More information about the fpc-devel mailing list