[Lazarus] unit on relative path is not recompile

Mattias Gaertner nc-gaertnma at netcologne.de
Mon Sep 30 19:50:55 CEST 2013


On Mon, 30 Sep 2013 20:25:03 +0300
patspiper <patspiper at gmail.com> wrote:

> On 30/09/13 19:53, Mattias Gaertner wrote:
> > On Mon, 30 Sep 2013 19:10:54 +0300
> > patspiper <patspiper at gmail.com> wrote:
> >
> >> [...]
> >> Should lfm's be added to projects and packages?
> > You don't need to add lfm files to projects.
> > Add them to packages.
> > You can add a feature request to let the IDE check lfm files for
> > packages.
> 
> Done:
> http://bugs.freepascal.org/view.php?id=25120
> >> Is it OK if include files are added by several packages and projects
> >> using these packages?
> > Add the include file to the package and remove it from all
> > packages/projects using that package.
> > Each file should have only one owner at a time.
> 
> The problem is with include files that hold for example global defines 
> and is used by several packages.

That's not a problem.

There are at least two solutions:

Solution  1:
The package can extend the include path of the project.
Package Editor / Options / Usage / Include Path. Use the point "." for
the directory where the myfile.lpk is.

It works like this:
You change the myfile.inc and compile the project.
The myfile.inc is part of the package B, which is used by the project.
The IDE detects, that myfile.inc is newer than the myfile.compiled file
and compiles the package.
Then the project.compiled file is older than the myfile.compiled and
therefore the IDE compiles the project.

Disadvantages:
- This does not work if you compile with the -Ur flag.
- Often such shared include files contain flags only needed by the
  package and only a few flags are needed by the project. So the
  project gets too many flags.


Solution  2:
Because packages can inherit flags as well, you don't need the
include file in Lazarus. Just add the flags to the usage options
of the package and all projects and packages using that package have the
defines. See the lcl.lpk for an example.

Advantages:
- This does work with the -Ur flag.
- Flags only used by the package are not defined for the project.


>[...]


Mattias




More information about the Lazarus mailing list