Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2009-11

first results of using fpc resources instead of lazarus resources

14 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Paul Ishenin

Hello, FPC developers' list.

This weekend Mattias has implemented an option for the IDE to use FPC resources for projects and packages. Loading of forms from such resources were made before so there are no more limitations to start use them instead of LRS files.

So I converted one our work project units to {R *.lfm} directive instead of {$I *.lrs}. And as soon as I tried to compile I've got an error: "Error while compiling resources". Not scanned the compiler sources for this error and found with what arguments fpcres was started.

I started it from the command line and found the real error: "No known file format detected for file
'C:\paul\projects\medavia\lib\i386-win32\fr_page_request2.lfm'"

Can compiler show me 2 errors instead of one:

Error while compiling resources:
No known file format detected for file
'C:\paul\projects\medavia\lib\i386-win32\fr_page_request2.lfm'

Of course I checked what is so uniques in that fr_page_request2.lfm and found utf8 BOM at the beginning of the file. I can't find whether this was lazarus or fpc who writes the BOM. I also can't understand why only one file has it. I compared with other lfm files - they also have russian strings and they have no BOM.

So if BOM can present in the LFM then fpcres detection method needs to be adjusted or in other case writer needs to be fixed.

Best regards, Paul Ishenin.

Reply by email

Paul Ishenin
to Paul Ishenin
Paul Ishenin wrote 5 lines
Of course I checked what is so uniques in that fr_page_request2.lfm and found utf8 BOM at the beginning of the file. I can't find whether this was lazarus or fpc who writes the BOM. I also can't understand why only one file has it. I compared with other lfm files - they also have russian strings and they have no BOM.

Further research shown that codetools saves LFM with UTF8 bom if previosly LFM had UTF8 bom. Probably I've got the BOM when edited the LFM file in the source editor. So this is not the FPC issue.

Anyway, FPC does not report which lfm file has problems and manual search for the problem file is not trivial. Error reporting must be improved.

Best regards,
Paul Ishenin.

Reply by email

Michael Van Canneyt
to Paul Ishenin: Hello, FPC developers' list. This weekend Mattias has implemented an option for the IDE…
Paul Ishenin wrote 22 lines
Hello, FPC developers' list. This weekend Mattias has implemented an option for the IDE to use FPC resources for projects and packages. Loading of forms from such resources were made before so there are no more limitations to start use them instead of LRS files. So I converted one our work project units to {R *.lfm} directive instead of {$I *.lrs}. And as soon as I tried to compile I've got an error: "Error while compiling resources". Not scanned the compiler sources for this error and found with what arguments fpcres was started. I started it from the command line and found the real error: "No known file format detected for file 'C:\paul\projects\medavia\lib\i386-win32\fr_page_request2.lfm'" Can compiler show me 2 errors instead of one: Error while compiling resources: No known file format detected for file 'C:\paul\projects\medavia\lib\i386-win32\fr_page_request2.lfm'

Some questions:
1. Isn't it lazarus that eats the error ?
2. Is the error you show here a FPCres error ?
If 2 is correct (and I think it is), the compiler has no power over what fpcres outputs to screen.

Michael.

Reply by email

Paul Ishenin
to Michael Van Canneyt
Michael Van Canneyt wrote
Some questions: 1. Isn't it lazarus that eats the error ?

no

Show quoted text 5 lines
2. Is the error you show here a FPCres error ? If 2 is correct (and I think it is), the compiler has no power over what fpcres outputs to screen.

First error "Error while compiling resources" is a compiler error. The error I want to see "No known file format detected for file 'C:\paul\projects\medavia\lib\i386-win32\fr_page_request2.lfm'" is a fpcres error.

I think that showing fpcres error must be somehow possible since fpc has both sources of fpc and fpcres.

How to find the source of the error in other case? It is even imposible to see that error happens while fpcres execution.

Best regards,
Paul Ishenin.

Reply by email

Michael Van Canneyt
to Paul Ishenin
Paul Ishenin wrote 15 lines
Michael Van Canneyt wrote: > Some questions: > 1. Isn't it lazarus that eats the error ? no > 2. Is the error you show here a FPCres error ? > If 2 is correct (and I think it is), the compiler has no power over what > fpcres outputs to > screen. First error "Error while compiling resources" is a compiler error. The error I want to see "No known file format detected for file 'C:\paul\projects\medavia\lib\i386-win32\fr_page_request2.lfm'" is a fpcres error.

This is understood :-)

I think that showing fpcres error must be somehow possible since fpc has both sources of fpc and fpcres.

But fpcres just writes all messages to standard error/output (the console). To my knowledge, the compiler doesn't do anything with that.

How to find the source of the error in other case? It is even imposible to see that error happens while fpcres execution.

Like I said, to my knowledge the compiler doesn't do anything with the output of the tools it uses. not 'as', not 'ld', and also not fpcres...

Are you doing this on windows or on linux ?
Can you provide a small test program, so I can test ?

Michael.

Reply by email

Mattias Gaertner
to Paul Ishenin: Hello, FPC developers' list. This weekend Mattias has implemented an option for the IDE…
Show quoted text 6 lines
Hello, FPC developers' list. This weekend Mattias has implemented an option for the IDE to use FPC resources for projects and packages. Loading of forms from such resources were made before so there are no more limitations to start use them instead of LRS files.

Some clarifications:
The option does nothing at the moment.
The IDE auto detects if an unit uses $R or $I .lrs. If it uses $R then the IDE will not update/create the .lrs file. So the fpc resources work even if you do not set the option or if you mix resource types. Eventually the option should be used when creating new forms.

Mattias

Reply by email

Michael Van Canneyt
to Paul Ishenin: On windows. Small test is in the attachment. Paul Ishenin.
Paul Ishenin wrote 5 lines
Michael Van Canneyt wrote: > Are you doing this on windows or on linux ? Can you provide a small test > program, so I can test ? On windows. Small test is in the attachment.

I found a hint.

When Lazbuild is used to build the project, fpcres doesn't write any output to the console, (I verified this with strace) but exits with exit code 2:

gru:>~/lazarus/lazbuild project1.lpi
TCompiler.Compile WorkingDir="/home/michael/Documents/source/testres/" CompilerFilename="/usr/local/bin/ppcx64" CompilerParams=" -MObjFPC -Scgi -O1 -gl -WG -vewnhi -l -Filib/x86_64-linux/
-Fu../../../fpc/lazarus/lcl/units/x86_64-linux/
-Fu../../../fpc/lazarus/lcl/units/x86_64-linux/gtk2/ -Fu../../../fpc/lazarus/packager/units/x86_64-linux/ -Fu. -FUlib/x86_64-linux/ -oproject1 -dLCL -dLCLgtk2 project1.lpr" [TCompiler.Compile] CmdLine="/usr/local/bin/ppcx64 -MObjFPC -Scgi -O1 -gl -WG -vewnhi -l -Filib/x86_64-linux/
-Fu../../../fpc/lazarus/lcl/units/x86_64-linux/
-Fu../../../fpc/lazarus/lcl/units/x86_64-linux/gtk2/ -Fu../../../fpc/lazarus/packager/units/x86_64-linux/ -Fu. -FUlib/x86_64-linux/ -oproject1 -dLCL -dLCLgtk2 project1.lpr" Hint: Start of reading config file /home/michael/.fpc.cfg Hint: End of reading config file /home/michael/.fpc.cfg Free Pascal Compiler version 2.3.1 [2009/07/03] for x86_64 Copyright (c) 1993-2009 by Florian Klaempfl
Target OS: Linux for x86-64
Compiling project1.lpr
Compiling resource lib/x86_64-linux/project1.or
project1.lpr(16,1) Error: Error while compiling resources project1.lpr(16,1) Fatal: There were 1 errors compiling module, stopping ERROR: failed compiling of project
/home/michael/Documents/source/testres/project1.lpi gru: >

When the compiler command-line is executed directly, fpcres does output a message:

gru: >/usr/local/bin/ppcx64 -MObjFPC -Scgi -O1 -gl -WG -vewnhi -l -Filib/x86_64-linux/ -Fu../../../fpc/lazarus/lcl/units/x86_64-linux/ -Fu../../../fpc/lazarus/lcl/units/x86_64-linux/gtk2/ -Fu../../../fpc/lazarus/packager/units/x86_64-linux/ -Fu. -FUlib/x86_64-linux/ -oproject1 -dLCL -dLCLgtk2 project1.lpr Hint: Start of reading config file /home/michael/.fpc.cfg Hint: End of reading config file /home/michael/.fpc.cfg Free Pascal Compiler version 2.3.1 [2009/07/03] for x86_64 Copyright (c) 1993-2009 by Florian Klaempfl
Target OS: Linux for x86-64
Compiling project1.lpr
Compiling resource lib/x86_64-linux/project1.or
Error: No known file format detected for file 'lib/x86_64-linux/unit1.lfm' project1.lpr(16,1) Error: Error while compiling resources project1.lpr(16,1) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted
gru: >

So it is lazarus/lazbuild (probably the TProcess class) that causes the message to be "eaten" by somehow not treating the standard error file descriptor correctly.

I verified that the FPC compiler does not change any of the file descriptors when executing fpcres.

Michael.

Reply by email

Paul Ishenin
to Mattias Gaertner: On Mon, 30 Nov 2009 11:33:03 +0700 Some clarifications: The option does nothing at the…
Mattias Gaertner wrote 6 lines
Some clarifications: The option does nothing at the moment. The IDE auto detects if an unit uses $R or $I .lrs. If it uses $R then the IDE will not update/create the .lrs file. So the fpc resources work even if you do not set the option or if you mix resource types. Eventually the option should be used when creating new forms.

The most important for me is that it does not show errors and works perfectly now. Can it save without the BOM even if file had it before?

Best regards,
Paul Ishenin.

Reply by email

Mattias Gaertner
to Paul Ishenin
Show quoted text 11 lines
Mattias Gaertner wrote: > Some clarifications: > The option does nothing at the moment. > The IDE auto detects if an unit uses $R or $I .lrs. If it uses $R > then the IDE will not update/create the .lrs file. So the fpc resources > work even if you do not set the option or if you mix resource types. > Eventually the option should be used when creating new forms. The most important for me is that it does not show errors and works perfectly now. Can it save without the BOM even if file had it before?

Yes, that would be possible.

But I think this should be fixed in fpcres. Otherwise windows users editing the lfm files will easily run into this error.

Mattias

Reply by email

Giulio Bernardi
to Mattias Gaertner

Mattias Gaertner ha scritto:

Show quoted text 19 lines
On Mon, 30 Nov 2009 17:19:20 +0700 Paul Ishenin wrote: > Mattias Gaertner wrote: > >> Some clarifications: >> The option does nothing at the moment. >> The IDE auto detects if an unit uses $R or $I .lrs. If it uses $R >> then the IDE will not update/create the .lrs file. So the fpc resources >> work even if you do not set the option or if you mix resource types. >> Eventually the option should be used when creating new forms. > The most important for me is that it does not show errors and works > perfectly now. Can it save without the BOM even if file had it before? Yes, that would be possible. But I think this should be fixed in fpcres. Otherwise windows users editing the lfm files will easily run into this error.

Fixed in rev 14292.
I had to fix TParser too, since fcl-res uses ObjectTextToBinary to compile dfm/xfm/lfm files.

Giulio

Reply by email

Mattias Gaertner
to Giulio Bernardi
Show quoted text 23 lines
Mattias Gaertner ha scritto: > On Mon, 30 Nov 2009 17:19:20 +0700 > Paul Ishenin wrote: > >> Mattias Gaertner wrote: >> >>> Some clarifications: >>> The option does nothing at the moment. >>> The IDE auto detects if an unit uses $R or $I .lrs. If it uses $R >>> then the IDE will not update/create the .lrs file. So the fpc resources >>> work even if you do not set the option or if you mix resource types. >>> Eventually the option should be used when creating new forms. >> The most important for me is that it does not show errors and works >> perfectly now. Can it save without the BOM even if file had it before? > > Yes, that would be possible. > > But I think this should be fixed in fpcres. Otherwise windows > users editing the lfm files will easily run into this error. > Fixed in rev 14292. I had to fix TParser too, since fcl-res uses ObjectTextToBinary to compile dfm/xfm/lfm files.

Thanks.

Mattias

Reply by email

Marco van de Voort
to Giulio Bernardi: Mattias Gaertner ha scritto: Fixed in rev 14292. I had to fix TParser too, since fcl-res…
Giulio Bernardi wrote 10 lines
>> perfectly now. Can it save without the BOM even if file had it before? > > Yes, that would be possible. > > But I think this should be fixed in fpcres. Otherwise windows > users editing the lfm files will easily run into this error. > Fixed in rev 14292. I had to fix TParser too, since fcl-res uses ObjectTextToBinary to compile dfm/xfm/lfm files.

Is this a single revision and do you think it is mergable?

This is the last week that high-priority stuff can be merged to 2.4.0, and since the new resource support is a highlight of 2.4.0, this could be a candidate.

Reply by email

Giulio Bernardi
to Marco van de Voort

Marco van de Voort ha scritto:

Show quoted text 12 lines
On Mon, Nov 30, 2009 at 10:59:45PM +0100, Giulio Bernardi wrote: >>> perfectly now. Can it save without the BOM even if file had it before? >> Yes, that would be possible. >> >> But I think this should be fixed in fpcres. Otherwise windows >> users editing the lfm files will easily run into this error. >> > Fixed in rev 14292. > I had to fix TParser too, since fcl-res uses ObjectTextToBinary to compile > dfm/xfm/lfm files. Is this a single revision and do you think it is mergable?

Yes: http://svn.freepascal.org/cgi-bin/viewvc.cgi?view=rev&revision=14292

It is very simple. If the UTF-8 bom is found at the beginning, it is skipped. I think it shouldn't hurt: knowing that a file is utf-8 or not makes no difference for TParser.

Reply by email