Recent

Author Topic: fpcres now supports compilation of RC files  (Read 3162 times)

lucamar

  • Hero Member
  • *****
  • Posts: 3461
Re: fpcres now supports compilation of RC files
« Reply #15 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 :)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.10/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Fred vS

  • Hero Member
  • *****
  • Posts: 2038
    • StrumPract is the musicians best friend
Re: fpcres now supports compilation of RC files
« Reply #16 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



I use Lazarus 2.0.6 32/64 and FPC 3.2.0 32/64 on Debian 10.2 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs
https://gitlab.com/fredvs

PascalDragon

  • Hero Member
  • *****
  • Posts: 2629
  • Compiler Developer
Re: fpcres now supports compilation of RC files
« Reply #17 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.

lucamar

  • Hero Member
  • *****
  • Posts: 3461
Re: fpcres now supports compilation of RC files
« Reply #18 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.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.10/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 9032
  • FPC developer.
Re: fpcres now supports compilation of RC files
« Reply #19 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"

« Last Edit: December 17, 2020, 10:58:42 am by marcov »

PascalDragon

  • Hero Member
  • *****
  • Posts: 2629
  • Compiler Developer
Re: fpcres now supports compilation of RC files
« Reply #20 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.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 9032
  • FPC developer.
Re: fpcres now supports compilation of RC files
« Reply #21 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