Lazarus

Announcements => Free Pascal => Topic started by: PascalDragon on August 12, 2020, 11:36:31 pm

Title: fpcres now supports compilation of RC files
Post by: PascalDragon on August 12, 2020, 11:36:31 pm
Hello together!

Thanks to the work of Martok (https://lists.freepascal.org/pipermail/fpc-pascal/2019-January/055476.html) 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 <path> 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.
Title: Re: fpcres now supports compilation of RC files
Post by: Fred vS on August 13, 2020, 12:45:19 am
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
Title: Re: fpcres now supports compilation of RC files
Post by: ASBzone on August 13, 2020, 01:30:14 am
Hello together!

Thanks to the work of Martok (https://lists.freepascal.org/pipermail/fpc-pascal/2019-January/055476.html) 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 <path> 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...
Title: Re: fpcres now supports compilation of RC files
Post by: olly on August 13, 2020, 03:10:59 am
https://forum.lazarus.freepascal.org/index.php/topic,50796.msg371698.html#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.  :)

Title: Re: fpcres now supports compilation of RC files
Post by: PascalDragon on August 13, 2020, 09:08:03 am
Would 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.

Off 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.
Title: Re: fpcres now supports compilation of RC files
Post by: Fred vS on August 13, 2020, 12:39:08 pm
Would 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
Title: Re: fpcres now supports compilation of RC files
Post by: Polarx79 on August 13, 2020, 07:44:29 pm
Thanks for all the hard work !! Blessings  :D
Title: Re: fpcres now supports compilation of RC files
Post by: Fred vS on December 16, 2020, 03:05:14 am
Hello.

Quote
However 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][+][-]
  1. Error: (11006) Illegal parameter: -FF


Title: Re: fpcres now supports compilation of RC files
Post by: marcov on December 16, 2020, 08:11:11 am
It is 3.2.1 plus.  Some fixes haven't been merged for non mainstream targets.
Title: Re: fpcres now supports compilation of RC files
Post by: PascalDragon on December 16, 2020, 09:13:36 am
Is it possible to try it with fpc 3.2.0 ?

No, as marcov said it's only part of 3.2.1.

Adding that parameter:  -FF

Gives that error at compilation:

Code: Pascal  [Select][+][-]
  1. 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.
Title: Re: fpcres now supports compilation of RC files
Post by: marcov on December 16, 2020, 10:19:23 am
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
Title: Re: fpcres now supports compilation of RC files
Post by: PascalDragon on December 16, 2020, 01:53:51 pm
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.
Title: Re: fpcres now supports compilation of RC files
Post by: marcov on December 16, 2020, 02:41:42 pm
Probably that rev wouldn't merge earlier because riscv was merged inbetween, it needs manual merging
Title: Re: fpcres now supports compilation of RC files
Post by: Fred vS on December 16, 2020, 03:21:12 pm
@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][+][-]
  1. fpcres myresource.rc

That will produce a myresource.res.

And so first produce the .res , and in code, just use:

Code: Pascal  [Select][+][-]
  1. {$R *.res}

instead of

Code: Pascal  [Select][+][-]
  1. {$R *.rc}

?

Thanks.

[EDIT]

I did try this without luck:

Code: Pascal  [Select][+][-]
  1. fpcres /lazpaint-master/lazpaint/lazpaint.rc
  2. Error: No known file format detected for file /lazpaint-master/lazpaint/lazpaint.rc'
  3.  

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


Title: Re: fpcres now supports compilation of RC files
Post by: Fred vS on December 16, 2020, 04:07:44 pm
Hello.

OK, I get it, this works perfectly on Linux (note the last parameters):

Code: Pascal  [Select][+][-]
  1. 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
Title: Re: fpcres now supports compilation of RC files
Post by: lucamar on December 16, 2020, 04:13:06 pm
But is it possible to use fpcres as stand-alone, something like:
Code: Pascal  [Select][+][-]
  1. fpcres myresource.rc
That will produce a myresource.res.

And so first produce the .res , and in code, just use:

Code: Pascal  [Select][+][-]
  1. {$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 :)
Title: Re: fpcres now supports compilation of RC files
Post by: Fred vS on December 16, 2020, 04:42:06 pm
But is it possible to use fpcres as stand-alone, something like:
Code: Pascal  [Select][+][-]
  1. fpcres myresource.rc
That will produce a myresource.res.

And so first produce the .res , and in code, just use:

Code: Pascal  [Select][+][-]
  1. {$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



Title: Re: fpcres now supports compilation of RC files
Post by: PascalDragon on December 17, 2020, 09:23:36 am
OK, I get it, this works perfectly on Linux (note the last parameters):

Code: Pascal  [Select][+][-]
  1. 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.
Title: Re: fpcres now supports compilation of RC files
Post by: lucamar on December 17, 2020, 09:59:48 am
Yes, 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.
Title: Re: fpcres now supports compilation of RC files
Post by: marcov on December 17, 2020, 10:50:06 am
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"

Title: Re: fpcres now supports compilation of RC files
Post by: PascalDragon on December 17, 2020, 01:14:13 pm
Yes, 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.

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.

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.).

I 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.
Title: Re: fpcres now supports compilation of RC files
Post by: marcov on December 17, 2020, 01:35:16 pm
Ok, if you don't immediately recognize it, it is a bug. Filed as 38228
TinyPortal © 2005-2018