Sign in Join

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

Mailing lists / fpc-devel / 2012-01

Concerning compile options behavior

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Gennadiy Poryev

Hi, all.

(Question 1)

My library extensively uses $I directive to separate various aspects of a single unit, such that its source code looks like this:

Unit myunit;
interface
{$I myunit\branch_alpha.inc}
{$I myunit\branch_beta.inc}
{$I myunit\branch_gamma.inc}

{ etc … }

implementation
end.

This being so because each of the include file is quite large and need cross-references to-from the others, while all of them being essentially about the same subject.

What I’ve found is that if I change one of the INCs, the unit does not get rebuilt regardless of the “-B” option (and when Lazarus says “Options changed, recompiling clean with -B”) and Lazarus’ own setting about “Always build even if nothing changed”.

It is only getting rebuilt if I physically delete corresponding *.a, *.o and *.ppu prior to building. I surmise the underlying cause to be checking the last edit timestamp of the main unit file only, not every include that happen along its way.

Does it qualify as a bug or is it “by design” ?

(Question 2)

The same library source tree uses some subdirectories, so that each time I start a project using it, I have to manually include every subdir with its *.pas files into “-Fu” option, because the library sources are also being added and/or modified with each new project. As the library grows, this is starting to be discomforting. May be I’m just not educated enough in the ways of FPC and missing some obvious functionality, but would it not be nice if we have “Add <x> to unit path recursively” option (such as -Fx) ? That way I can only specify lib’s root directory and not care about how much subdirs it has.

Thanks in advance,

// Gennadiy.

Reply by email

Gennadiy Poryev
to Gennadiy Poryev

Hi, all.

(Question 1)
My library extensively uses $I directive to separate various aspects of a single unit, such that its source code looks like this:

Unit myunit;
interface
{$I myunit\branch_alpha.inc}
{$I myunit\branch_beta.inc}
{$I myunit\branch_gamma.inc}
{ etc … }
implementation
end.

This being so because each of the include file is quite large and need cross-references to-from the others, while all of them being essentially about the same subject. What I’ve found is that if I change one of the INCs, the unit does not get rebuilt regardless of the “-B” option (and when Lazarus says “Options changed, recompiling clean with -B”) and Lazarus’ own setting about “Always build even if nothing changed”. It is only getting rebuilt if I physically delete corresponding *.a, *.o and *.ppu prior to building. I surmise the underlying cause to be checking the last edit timestamp of the main unit file only, not every include that happen along its way. Does it qualify as a bug or is it “by design” ?

(Question 2)
The same library source tree uses some subdirectories, so that each time I start a project using it, I have to manually include every subdir with its *.pas files into “-Fu” option, because the library sources are also being added and/or modified with each new project. As the library grows, this is starting to be discomforting. May be I’m just not educated enough in the ways of FPC and missing some obvious functionality, but would it not be nice if we have “Add <x> to unit path recursively” option (such as -Fx) ? That way I can only specify lib’s root directory and not care about how much subdirs it has.

Thanks in advance,

// Gennadiy.

p.s. sorry for repost, I had an impression that my first message vanished into thin air.

Reply by email

Mark Morgan Lloyd
to Gennadiy Poryev
Gennadiy Poryev wrote 27 lines
Hi, all. (Question 1) My library extensively uses $I directive to separate various aspects of a single unit, such that its source code looks like this: Unit myunit; interface {$I myunit\branch_alpha.inc} {$I myunit\branch_beta.inc} {$I myunit\branch_gamma.inc} { etc … } implementation end. This being so because each of the include file is quite large and need cross-references to-from the others, while all of them being essentially about the same subject. What I’ve found is that if I change one of the INCs, the unit does not get rebuilt regardless of the “-B” option (and when Lazarus says “Options changed, recompiling clean with -B”) and Lazarus’ own setting about “Always build even if nothing changed”. It is only getting rebuilt if I physically delete corresponding *.a, *.o and *.ppu prior to building. I surmise the underlying cause to be checking the last edit timestamp of the main unit file only, not every include that happen along its way. Does it qualify as a bug or is it “by design” ? (Question 2) The same library source tree uses some subdirectories, so that each time I start a project using it, I have to manually include every subdir with its *.pas files into “-Fu” option, because the library sources are also being added and/or modified with each new project. As the library grows, this is starting to be discomforting. May be I’m just not educated enough in the ways of FPC and missing some obvious functionality, but would it not be nice if we have “Add <x> to unit path recursively” option (such as -Fx) ? That way I can only specify lib’s root directory and not care about how much subdirs it has. Thanks in advance, // Gennadiy. p.s. sorry for repost, I had an impression that my first message vanished into thin air.

This could be more appropriate in the fpc-pascal or lazarus mailing lists.

Another situation in which automatic rebuild fails is when Lazarus renames units, some of which are in a subdirectory. Hopefully somebody will be able to enlighten us, but I suspect that neither include files nor full path details are stored.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Sven Barth
to Gennadiy Poryev: Hi, all. (Question 1) My library extensively uses $I directive to separate various…
Gennadiy Poryev wrote
(Question 2) The same library source tree uses some subdirectories, so that each time I start a project using it, I have to manually include every subdir with its *.pas files into “-Fu” option, because the library sources are also being added and/or modified with each new project. As the library grows, this is starting to be discomforting. May be I’m just not educated enough in the ways of FPC and missing some obvious functionality, but would it not be nice if we have “Add<x> to unit path recursively” option (such as -Fx) ? That way I can only specify lib’s root directory and not care about how much subdirs it has.

There are three possibilities:

* If you reuse the units in the subdirectories often you can try to make Lazarus packages (see here:
http://wiki.lazarus.freepascal.org/Lazarus_Packages ) out of them. Then you just add the package dependency to your project.

* Add the "-Fu" options to a custom cfg file (e.g. myfpc.cfg) and add this to FPC's command line using "@". The configuration will be used additionally to the default configuration.

E.g. fpc @myfpc.cfg myprogram.pas

* Use the "*" in the "-Fu" path. This will include all subdirectories in the given path and is e.g. used in the default FPC config file to include all package units besides "rtl"

E.g. fpc -Fu./* myprogram.pas

You need to pay attention though as your shell might handle "*" itself. On systems using bash, sh, zsh, etc. you'll need to use the following to have the correct value passed to FPC: fpc -Fu./\* myprogram.pas

Regards,
Sven

Reply by email