Resource compilation

classic Classic list List threaded Threaded
47 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Resource compilation

Martok
Hi all,

the $R directive accepts resource scripts (RC) and compiles the RES file from it
on demand.

However, that only happens if the RES file does not exist - if it does, the
resource compiler is never invoked. Even clean-building the unit from source
does not recompile the resource file. This is a bit awkward when the resource
script (or any of the linked files) is changed: the only way to recreate the
resource unit appears to be removing both the compiled unit and resource file.

Is there some sort of flag for this? I'd be fine with just recompiling the
resource file every time the unit is compiled, windres is fast enough...

Thanks,
Martok

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Resource compilation

Graeme Geldenhuys-6
On 2017-09-23 21:31, Martok wrote:
> the $R directive accepts resource scripts (RC) and compiles the RES file from it
> on demand.

Also note that that is only true for Windows. FPC doesn't include a
resource compiler for any other platforms. So if no resource compiler
exists, you will get a compilation error until you make other plans.
Another FPC limitation that really should be resolved.

Regards,
   Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Resource compilation

Free Pascal - General mailing list
On 24.09.2017 12:12, Graeme Geldenhuys wrote:
> On 2017-09-23 21:31, Martok wrote:
>> the $R directive accepts resource scripts (RC) and compiles the RES
>> file from it
>> on demand.
>
> Also note that that is only true for Windows. FPC doesn't include a
> resource compiler for any other platforms. So if no resource compiler
> exists, you will get a compilation error until you make other plans.
> Another FPC limitation that really should be resolved.

You are aware that FPC supports resources on basically all platforms?
After all it was introduced for Lazarus back before 1.0 or so.

Regards,
Sven

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Resource compilation

Free Pascal - General mailing list
In reply to this post by Martok
On 23.09.2017 22:31, Martok wrote:

> Hi all,
>
> the $R directive accepts resource scripts (RC) and compiles the RES file from it
> on demand.
>
> However, that only happens if the RES file does not exist - if it does, the
> resource compiler is never invoked. Even clean-building the unit from source
> does not recompile the resource file. This is a bit awkward when the resource
> script (or any of the linked files) is changed: the only way to recreate the
> resource unit appears to be removing both the compiled unit and resource file.
>
> Is there some sort of flag for this? I'd be fine with just recompiling the
> resource file every time the unit is compiled, windres is fast enough...

Please report a bug.

Regards,
Sven

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Resource compilation

Graeme Geldenhuys-6
In reply to this post by Free Pascal - General mailing list
On 2017-09-24 13:50, Sven Barth via fpc-pascal wrote:
> You are aware that FPC supports resources on basically all platforms?

I know that. What I meant is that FPC only ships with a Windows resource
compiler - ability to compile RC files to RES files. All other platforms
you have to find your own Resource Compiler. So on a clean system with a
fresh FPC install, only under Windows will you have the ability to
compile source code that references .rc files.

Regards,
   Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Resource compilation

Free Pascal - General mailing list
On 24.09.2017 17:15, Graeme Geldenhuys wrote:
> On 2017-09-24 13:50, Sven Barth via fpc-pascal wrote:
>> You are aware that FPC supports resources on basically all platforms?
>
> I know that. What I meant is that FPC only ships with a Windows resource
> compiler - ability to compile RC files to RES files. All other platforms
> you have to find your own Resource Compiler. So on a clean system with a
> fresh FPC install, only under Windows will you have the ability to
> compile source code that references .rc files.

Because it's only Windows that we provide a setup for. If someone would
provide an FPC implemented resource compiler we'd include it.

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Resource compilation

Graeme Geldenhuys-6
On 2017-09-24 16:49, Sven Barth via fpc-pascal wrote:
> Because it's only Windows that we provide a setup for.


Huh?  I've been downloading the official FPC console installers for
FreeBSD and Linux since 6 years ago. I never use distro packages
managers for FPC.

Regards,
   Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Resource compilation

Giulio Bernardi
I think that what Sven meant is that fpc's Windows installers include binutils,
while this is not true for other platforms: that is, you need to have ld on your
system if you want to use it as a linker, fpc does not provide it.

Same as for windres: if you need it, usually you can install it from mingw's
binutils. In fedora I can install it from mingw32-binutils (or mingw64-binutils).
I see that a package with the same name also exists in FreeBSD, so I assume it
will contain windres as well.

https://www.freshports.org/devel/mingw32-binutils/

Giulio

On 24/09/17 16:53, Graeme Geldenhuys wrote:

> On 2017-09-24 16:49, Sven Barth via fpc-pascal wrote:
>> Because it's only Windows that we provide a setup for.
>
>
> Huh?  I've been downloading the official FPC console installers for FreeBSD and
> Linux since 6 years ago. I never use distro packages managers for FPC.
>
> Regards,
>   Graeme
>

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Resource compilation

Free Pascal - General mailing list

Am 24.09.2017 18:14 schrieb "Giulio Bernardi" <[hidden email]>:
>
> I think that what Sven meant is that fpc's Windows installers include binutils,
> while this is not true for other platforms: that is, you need to have ld on your
> system if you want to use it as a linker, fpc does not provide it.

Exactly.

Regards,
Sven


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Resource compilation

Martok
In reply to this post by Graeme Geldenhuys-6
> Also note that that is only true for Windows. FPC doesn't include a
> resource compiler for any other platforms. So if no resource compiler
> exists, you will get a compilation error until you make other plans.
AFAIK, windres is available for lots of other platforms. If you have to install
some package, that shoud not really surprise a developer?
I would assume that FPC just tries to call a resource compiler on all platforms
and fails with some error message if it isn't available?

If so, I wouldn't worry too much about having our own resource compiler. The RC
script language is actually quite complex, and there'd be next to no benefit to
reinventing the wheel.

--
Martok

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Resource compilation

Graeme Geldenhuys-6
In reply to this post by Free Pascal - General mailing list
On 2017-09-24 19:02, Sven Barth via fpc-pascal wrote:
>> system if you want to use it as a linker, fpc does not provide it.
> Exactly.

Exactly my point! Why? Why does the official FPC installer for Windows
give a more workable solution out of the box (1), but official
installers for other platforms don't?

And please don't tell me the usual "Delphi compatibility" for G*d sake.


1. Ability to compile source code with .RC reference and magically
    compile those to .RES as needed.


Regards,
   Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Resource compilation

Free Pascal - General mailing list
On 24.09.2017 22:55, Graeme Geldenhuys wrote:
> On 2017-09-24 19:02, Sven Barth via fpc-pascal wrote:
>>> system if you want to use it as a linker, fpc does not provide it.
>> Exactly.
>
> Exactly my point! Why? Why does the official FPC installer for Windows
> give a more workable solution out of the box (1), but official
> installers for other platforms don't?

Because on non-Windows systems (especially the *nix ones) we rely on
their package distributions systems and it's up to the package
maintainers to set up the packages accordingly for their distribution so
that they pull in the required packages. Such a system does not exist on
Windows however so we bundle everything there.

Regards,
Sven

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Resource compilation

Martok
In reply to this post by Free Pascal - General mailing list
Am 24.09.2017 um 14:50 schrieb Sven Barth via fpc-pascal:
> Please report a bug.

Well this is awkward - I tried to provide a test project for the report, and
couldn't get it to *not* work. The real-world project that has this issue for me
has the resource included from a file in a package, and it seems like this is
somehow significant. Might be more of a Lazarus issue then.

There is still a bug in that the RES is not recompiled if the PPU is present but
the RES is not (causes error 9029), but I'll report that separately, after
figuring out what is going on here...

--
Martok

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Resource compilation

Graeme Geldenhuys-6
In reply to this post by Martok
On 2017-09-24 20:52, Martok wrote:
> If so, I wouldn't worry too much about having our own resource compiler. The RC
> script language is actually quite complex, and there'd be next to no benefit to
> reinventing the wheel.

The same could be said about implementing a competing (alternatives to
C/C++ or Delphi) compiler. ;-) Yet FPC project took up that challenge.

Regards,
   Graeme

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Resource compilation

Martok
Am 25.09.2017 um 09:12 schrieb Graeme Geldenhuys:
> The same could be said about implementing a competing (alternatives to
> C/C++ or Delphi) compiler. ;-)
Not really though ;-)
Rewriting a resource compiler with the same input and output files as the
existing one is a bit different than writing a compiler for a new language and
targets...

However, it seems that for example in Debian, windres is only in the
crossbinutils package? That's not quite what I expected...
What we really need then is "only" a parser frontend for fpcres, fcl-res already
can do all the writing we might ever need. Could someone please check if there
exists an issue for it and if not, report it? Might have a poke at it, but I'll
probably forget before having the time ;-)

--
Martok

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Resource compilation

Free Pascal - General mailing list
In reply to this post by Martok

Am 25.09.2017 08:11 schrieb "Martok" <[hidden email]>:
>
> > Also note that that is only true for Windows. FPC doesn't include a
> > resource compiler for any other platforms. So if no resource compiler
> > exists, you will get a compilation error until you make other plans.
> AFAIK, windres is available for lots of other platforms. If you have to install
> some package, that shoud not really surprise a developer?
> I would assume that FPC just tries to call a resource compiler on all platforms
> and fails with some error message if it isn't available?
>
> If so, I wouldn't worry too much about having our own resource compiler. The RC
> script language is actually quite complex, and there'd be next to no benefit to
> reinventing the wheel.

The RC language itself isn't *that* difficult. Main difficulty would be to essentially implement a C-preprocessor-compatible preprocessor.

Regards,
Sven


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Resource compilation

Martok
Am 25.09.2017 um 14:24 schrieb Sven Barth via fpc-pascal:
> The RC language itself isn't *that* difficult. Main difficulty would be to
> essentially implement a C-preprocessor-compatible preprocessor.
As I have just discovered, the installer provides a (rather antique) gcc on
Windows and depends on build-essential on (all?) *nix platforms, so we don't
even need to do that - piping through "gcc -E -xc" should be all we need.
That just leaves a reader for fcl-res.

Hm.

--
Martok
Ceterum censeo b32079 esse sanandam.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Resource compilation

Free Pascal - General mailing list

Am 11.10.2017 08:11 schrieb "Martok" <[hidden email]>:
>
> Am 25.09.2017 um 14:24 schrieb Sven Barth via fpc-pascal:
> > The RC language itself isn't *that* difficult. Main difficulty would be to
> > essentially implement a C-preprocessor-compatible preprocessor.
> As I have just discovered, the installer provides a (rather antique) gcc on
> Windows and depends on build-essential on (all?) *nix platforms, so we don't
> even need to do that - piping through "gcc -E -xc" should be all we need.
> That just leaves a reader for fcl-res.

The point of our own resource compiler would be to avoid external dependencies. While me might ship with a gcc on Windows I nevertheless consider it as an external dependency and thus a preprocessor written in Pascal would be preferred.

Regards,
Sven


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Resource compilation

Martok
Am 11.10.2017 um 11:24 schrieb Sven Barth via fpc-pascal:
> The point of our own resource compiler would be to avoid external dependencies.
True. And having a general-purpose preprocessor would come in useful anyway.

Fun fact: windres also just calls gcc, which is probably why we deploy it:
   #define DEFAULT_PREPROCESSOR "gcc -E -xc -DRC_INVOKED"

But it would be a replacement of a somewhat obscure dependency (windres seems to
be a crossbinutils thing) with just keeping a standard one.

--
Regards,
Martok

Ceterum censeo b32079 esse sanandam.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Resource compilation

Martok
In reply to this post by Free Pascal - General mailing list
Am 25.09.2017 um 14:24 schrieb Sven Barth via fpc-pascal:
> The RC language itself isn't *that* difficult. Main difficulty would be to essentially implement a C-preprocessor-compatible
> preprocessor.

Just "a few" months later, I finally got around to checking this out.

You were completely right, the language itself is not very difficult, and can be processed into a TResource in one pass in a
tply-generated parser. The preprocessor is also just a subset of C's (i.e.: no macros), so it would not be too complicated (I've
done the same for idlproc before). There are dialect issues between windres and Microsoft RC, but they are minor.

The more difficult part is implementing the remaining resource access classes for fcl-res. Well, not difficult per se, but the
copy-on-write-sharing thing done there adds a lot of complexity for (IMHO) very little benefit and makes it a bit awkward to
work with. There's also a lot of endian conversions that could probably be factored out.

That sounds challenging. How much interest would there be in having a full resource compiler, with the appropriate
changes/extensions to fcl-res?

--
Regards,
Martok

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
123