On 30/09/13 20:50, Mattias Gaertner wrote:
On Mon, 30 Sep 2013 20:25:03 +0300
patspiper <patspi...@gmail.com> wrote:


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.

I am contemplating solution 1 because the include file is usually shared among packages, but not the project. Maybe a wiki page/paragraph for IDE myths is due. I'll list what I have in mind now. Pls correct as needed.

General guidelines:
- The project/package directory is implicitly added to the Other unit files (-Fu) of that project/package. - Always add the directories of added units to the project/package to the Other unit files (-Fu) of that project/package. The IDE will prompt the user in such cases. - A dot (.) can be used to add the project/package folder to the 'Include Files' or other path setting.
- There is no need to add lfm files to projects/packages.
- Never add a unit to several packages.
- Never add a unit to a package and a project.
- ToDo: sharing of folders between packages

What triggers automatic recompilation of a project/package:
- Modifying units added to the project/package.
- Modifying include files included in units added to the project/package, provided they are located in the 'Include Files' folders (-Fi).
- ToDo: Changing project options

What does not trigger automatic recompilation of a project/package:
- Modifying units not added to the project/package, even if they are located in the 'Other Unit Files' folders. - Modifying include files included in units added to the project/package but that are not located in the 'Include Files' folders (-Fi).
- Modifying lfm files without a corresponding pas file modification.
- Modifying res files.

Note: Modification is a change of file timestamp.


What triggers automatic reloading of files in the IDE:
- Modifying units added to the project/package.
- Modifying include files included in units added to the project/package, irrespective if they are located in the 'Include Files' folders (-Fi) or not
- Modifying lfm files with or without a corresponding pas file modification.
- Modifying the project/package main file.

What does not trigger automatic reloading of files in the IDE:
- Modifying units not added to the project/package, even if they are located in the 'Other Unit Files' folders.

Note: Modification is a change of file timestamp (unless a special IDE option is set).

Stephano


--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to