Am Donnerstag, den 30.11.2006, 23:20 +0100 schrieb Michael Van Canneyt:
> 
> On Thu, 30 Nov 2006, Marc Santhoff wrote:
> 
> > Hi,
> > 
> > I know this is a question regarding fpc and lazarus, but I decided to
> > post to this list:
> > 
> > If one would want to run the complete sources of a project through a
> > preprocessor transparently when compiling in the lazarus IDE, would this
> > be possible with fpc and lazarus as they are now?
> 
> Well. I thought about this issue frequently.
> 
> FPC has no support for this currently. 
> It has only limited macro support, I'm sure you are aware of it, it's 
> documented.

Yes, I tried to achive it with macros, without success.

> > Or will it take implementing some pipeline hooks or the like in one or
> > both of them?
> > 
> > The goal in doing so would be using a specialized macro processor
> > replacing tags in the source code before feeding through fpc.
> 
> The issue is not so easy. My first thought would be that this is 
> something for the IDE, as it 'knows' which files should be 
> preprocessed and which not, but actually doing so would require
> a lot of filename juggling, as the files must exist on disk with
> known extensions. 

Interesting approach, since lazarus has the project list naming the
files directly belonging to the project. The second half has to be built
from the list of dependencies (files need to be recompiled because of
change).

> Leaving it to the compiler presents other problems: the compiler
> has no way to know which files should be preprocessed or not. 
> A second problem is that these hooks would seriously affect 
> speed, and I don't think anyone wishes to diminish the speed.

One possibility would be to create a new compiler switch working on unit
basis. If the switch is on, the preprocessor must be called, maybe only
on units having a second (or the same - parsing matter) switch set to
on.

In my case speed is less important than code quality resulting from the
preprocessor but YMMV.

> My conclusion was that such support should be implemented in
> the IDE. My idea was that in the 'File - New' dialog, a new
> item would appear: "Unit template". This would be treated as
> a regular unit, but would have a flag set causing the IDE
> 1. To change the extension to .tpp (or .tpa or whatever).
> 2. Whenever a change is detected to such a unit, the IDE 
>    runs it through the preprocessor (definable per project)
>    and saves the output with name .pp
> Obviously, the flag should be settable on any unit, at which
> point the IDE should offer to change the extension.

Yes, a new file type would be possible, too. Then unit not involved in
preprocessing (e.g. stable code libraries) could be left untouched by
using .pas/.pp.

> But that was just my idea. 
> Lack of time prohibited starting this topic :-)

As obvious. :)

My thoughts were going to fpc building up the list or queue of sources
to compile. I tried to find this part of the compiler, but it was not
easy to discover and I have no high priority on this idea.

The compiler has to go through the list of sources in any way (list all
first and compile one by one or compile one file, then list and
recompile dependencies if changed).

If fpc does the work there is no need to change lazarus and it is
guaranteed to work independently of the IDE.

Marc


_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to