fpcres now supports compilation of RC files lazarus / 60-Free Pascal ---------------------------------------------------------------------- PascalDragon · 2020-08-12 21:36 Hello together! Thanks to the work of Martok the fpcres utility is now able to compile RC files into RES files. To compile an RC file to a RES file you need to pass the -of res argument as otherwise the RC reader won't be used (it's a "catch all" TResourceReader descendant and thus not registered by default). You can specify include paths for the preprocessor using --include and defines can be declared using -D sym (including defines with values using -D sym=val). The Free Pascal compiler is capable of using fpcres for resource compilation as well, but due to bootstrapping issues that currently needs to be enabled using a new option -FF. Once a FPC release with a fpcres supporting RC files is released we'll make that option the default and deprecate windres/gorc (I currently plan to merge this into 3.2.1, thus 3.2.2 would support this and future 3.3.1 (and thus 3.4) would then use fpcres by default). Please test this with your applications and report your problems as this is the biggest change regarding resource compilation since their introduction. Compatibility note: due to build dependencies the FileInfo unit was moved from fcl-base to fcl-extra, so please keep a look out for stale PPU files. ---------------------------------------------------------------------- Fred vS · 2020-08-12 22:45 Would it mean that fpc could produce now *.res resource files without the need of windres in Windows and Unix OS system too? If yes, wow and  many thanks. Fre;D ---------------------------------------------------------------------- ASBzone · 2020-08-12 23:30 Quote from: PascalDragon on August 12, 2020, 11:36:31 pmHello together! Thanks to the work of Martok the fpcres utility is now able to compile RC files into RES files. To compile an RC file to a RES file you need to pass the -of res argument as otherwise the RC reader won't be used (it's a "catch all" TResourceReader descendant and thus not registered by default). You can specify include paths for the preprocessor using --include and defines can be declared using -D sym (including defines with values using -D sym=val). ... Awesome news!   Thanks to Martok and everyone else involved... ---------------------------------------------------------------------- olly · 2020-08-13 01:10 https://forum.lazarus.freepascal.org/index.php/topic,50796.msg371698.h tml#msg371698 You weren't kidding! Good job to all! Off topic, but let's hope we don't have to wait a long time for this to make a official release. ---------------------------------------------------------------------- PascalDragon · 2020-08-13 07:08 Quote from: Fred vS on August 13, 2020, 12:45:19 amWould it mean that fpc could produce now *.res resource files without the need of windres in Windows and Unix OS system too? Yes, though for now you need to pass the parameter -FF to the compiler so that it uses fpcres instead of windres / gorc. Quote from: olly on August 13, 2020, 03:10:59 amOff topic, but let's hope we don't have to wait a long time for this to make a official release.  As said the plan is to merge this to 3.2.1, so that the next minor release will contain it, allowing us to switch 3.3.1 to use it by default. However to make it default we need people to test it with their projects now. It doesn't help if we make it default and later on people complain that we broke everything just because we weren't able to test whatever corner cases they have. ---------------------------------------------------------------------- Fred vS · 2020-08-13 10:39 Quote from: PascalDragon on August 13, 2020, 09:08:03 amQuote from: Fred vS on August 13, 2020, 12:45:19 amWould it mean that fpc could produce now *.res resource files without the need of windres in Windows and Unix OS system too? Yes, though for now you need to pass the parameter -FF to the compiler so that it uses fpcres instead of windres / gorc Excellent, one step forward for more autonomy, many thanks to Martok and Sven. Fre;D ---------------------------------------------------------------------- Polarx79 · 2020-08-13 17:44 Thanks for all the hard work !! Blessings ---------------------------------------------------------------------- Fred vS · 2020-12-16 02:05 Hello. QuoteHowever to make it default we need people to test it with their projects now Sorry, I few late... Is it possible to try it with fpc 3.2.0 ? Adding that parameter:  -FF Gives that error at compilation: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Error: (11006) Illegal parameter: -FF ---------------------------------------------------------------------- marcov · 2020-12-16 07:11 It is 3.2.1 plus.  Some fixes haven't been merged for non mainstream targets. ---------------------------------------------------------------------- PascalDragon · 2020-12-16 08:13 Quote from: Fred vS on December 16, 2020, 03:05:14 amIs it possible to try it with fpc 3.2.0 ? No, as marcov said it's only part of 3.2.1. Quote from: Fred vS on December 16, 2020, 03:05:14 amAdding that parameter:  -FF Gives that error at compilation: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Error: (11006) Illegal parameter: -FF Only the changes for the fpcres utility have been merged to 3.2.1, the support for the compiler to use fpcres for RC files has not been merged. This was done so that trunk can drop this parameter again once 3.2.2 (or 3.2.4) is released and instead make fpcres the default for RC files. ---------------------------------------------------------------------- marcov · 2020-12-16 09:19 I just checked what fcl-res unmerged revs there are, and one is the riscv merge (not important for fixes), the other is r40751 | florian | 2019-01-03 21:55:25 +0100 (Thu, 03 Jan 2019) | 1 line Changed paths:    M /trunk/packages/fcl-res/src/elfconsts.pp    M /trunk/packages/fcl-res/src/elfsubwriter.inc * set default abi to eabi5 on arm ---------------------------------------------------------------------- PascalDragon · 2020-12-16 12:53 That one could maybe be merged as well, but what is missing (by intention) are the changes for the compiler itself as the -FF option mentioned above is only intended to be temporary until we have a release with an updated fpcres out. ---------------------------------------------------------------------- marcov · 2020-12-16 13:41 Probably that rev wouldn't merge earlier because riscv was merged inbetween, it needs manual merging ---------------------------------------------------------------------- Fred vS · 2020-12-16 14:21 @PascalDragon and Marcov: thanks for your light. OK, I understand that fpcres will be implement by default later. But is it possible to use fpcres as stand-alone, something like: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fpcres myresource.rc That will produce a myresource.res. And so first produce the .res , and in code, just use: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$R *.res} instead of Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$R *.rc} ? Thanks. [EDIT] I did try this without luck: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fpcres /lazpaint-master/lazpaint/lazpaint.rcError: No known file format detected for file /lazpaint-master/lazpaint/lazpaint.rc'  Note that lazpaint.rc is perfectly recognized with windres and the lazpaint.res is produced. Code: [Select]windres /lazpaint-master/lazpaint/lazpaint.rc lazpaint.res ---------------------------------------------------------------------- Fred vS · 2020-12-16 15:07 Hello. OK, I get it, this works perfectly on Linux (note the last parameters): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fred@fiens ~/l/lazpaint> fpcres /home/fred/lazpaint-master/lazpaint/lazpaint.rc -o lazpaint.res -of res And the lazpaint.res produced seems perfectly the same as the one produced by windres. So, for me, ok, let's make it as default for the compiler. (And big WoW). Thanks. Fre;D ---------------------------------------------------------------------- lucamar · 2020-12-16 15:13 Quote from: Fred vS on December 16, 2020, 03:21:12 pmBut is it possible to use fpcres as stand-alone, something like: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fpcres myresource.rcThat will produce a myresource.res. And so first produce the .res , and in code, just use: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$R *.res} You can always add it as an "Execute before" command in the "Compiler Commands" options of the project but you need an fpcres able to deal with .rc files; the only thing the currently released version (2.0) is able to do is convert a .res, normally into .o to link into the executable. And even with the newish one you need to set all those options, as you have already discovered ---------------------------------------------------------------------- Fred vS · 2020-12-16 15:42 Quote from: lucamar on December 16, 2020, 04:13:06 pmQuote from: Fred vS on December 16, 2020, 03:21:12 pmBut is it possible to use fpcres as stand-alone, something like: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fpcres myresource.rcThat will produce a myresource.res. And so first produce the .res , and in code, just use: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$R *.res} You can always add it as an "Execute before" command in the "Compiler Commands" options of the project but you need an fpcres able to deal with .rc files; the only thing the currently released version (2.0) is able to do is convert a .res, normally into .o to link into the executable. And even with the newish one you need to set all those options, as you have already discovered Hello Lucamar. Indeed, I did try with fpcres from FPC 3.2.0 and FPC 3.2.1 but rc format is not recognized. But the one from FPC 3.3.1 trunk is working perfectly. Very great job Sven. Fre;D ---------------------------------------------------------------------- PascalDragon · 2020-12-17 08:23 Quote from: Fred vS on December 16, 2020, 04:07:44 pmOK, I get it, this works perfectly on Linux (note the last parameters): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fred@fiens ~/l/lazpaint> fpcres /home/fred/lazpaint-master/lazpaint/lazpaint.rc -o lazpaint.res -of res Yes, we've decided against enabling res output by default (or some auto magic) due to backwards compatibility. ---------------------------------------------------------------------- lucamar · 2020-12-17 08:59 Quote from: PascalDragon on December 17, 2020, 09:23:36 amYes, we've decided against enabling res output by default (or some auto magic) due to backwards compatibility. But, what about .rc input? Is it also disabled unless an output format is set? 'Cause that would kind of defeat the purpose of the new feature  ... whatever that is IMHO, when one adds a new input format one should also define a default output one for it, depending on the purpose of the tool. Since fpcres has 'most always been about creating an object for linking, it's understandable that res output be available only on demand, but the problem seems to be that there is no default support for rc input either. I'm not criticizing or anything ... well, yes, a little, but in a good way: I just would like some gleaming on your thougths about it. ---------------------------------------------------------------------- marcov · 2020-12-17 09:50 I tried on one of my RCs (which embed shader files as resource streams), and it gives an error. call:    Code: [Select]fpcres shadersrc.rc -o shadersrc.res -of res error: Code: [Select]#MAIN.RC(1:43): at "emptycirclevertex": syntax error vertexemptycircle RCDATA emptycirclevertex.ssrc                                           ^ that first line is as reproduced in the error : Code: [Select]vertexemptycircle RCDATA emptycirclevertex.ssrc which puts a shader source file as rcdata stream with name/ident vertexemptycircle. Note that some paths have windows style quoting, but it doesn't even get there: Code: [Select]thefontmeta RCDATA "c:\candelasvn\candelatex\pic\fonts\arial.fnt" ---------------------------------------------------------------------- PascalDragon · 2020-12-17 12:14 Quote from: lucamar on December 17, 2020, 09:59:48 amQuote from: PascalDragon on December 17, 2020, 09:23:36 amYes, we've decided against enabling res output by default (or some auto magic) due to backwards compatibility. But, what about .rc input? Is it also disabled unless an output format is set? 'Cause that would kind of defeat the purpose of the new feature  ... whatever that is The compiler knows that it needs to pass -of res. Quote from: lucamar on December 17, 2020, 09:59:48 amIMHO, when one adds a new input format one should also define a default output one for it, depending on the purpose of the tool. Since fpcres has 'most always been about creating an object for linking, it's understandable that res output be available only on demand, but the problem seems to be that there is no default support for rc input either. That is not how the classes in fcl-res work. Multiple different kinds of inputs can be used and their corresponding reader class is determined based on the content and not based on the file extension. The RC reader however is essentially a catch-all reader, thus it must not be enabled by default. And the output format of fpcres is by default the binary resource format for the target (e.g. ELF, COFF, etc.). Quote from: marcov on December 17, 2020, 10:50:06 amI tried on one of my RCs (which embed shader files as resource streams), and it gives an error. Best put that in a bug report with an example that can be used to reproduce this. ---------------------------------------------------------------------- marcov · 2020-12-17 12:35 Ok, if you don't immediately recognize it, it is a bug. Filed as 38228