[Lazarus] Strange dependency of units
Mattias Gaertner
nc-gaertnma at netcologne.de
Sun Apr 1 12:10:04 CEST 2012
On Sun, 01 Apr 2012 11:04:23 +0200
Jürgen Hestermann <juergen.hestermann at gmx.de> wrote:
> Mattias Gaertner schrieb:
> > Each package has its own compiler options. For example the LCL units need
> > some flags like inlining and C style operators and some linker options.
>
> Why isn't this simply added to the source files (compiler switches)? It
> would be much easier, rock solid and would even allow different settings
> for each unit. No need for a complicated construct like packages.
Individual settings for hundreds of units?
No one can remember that.
It would mean every developer has to read the header of a unit every
time he wants to read/extend it.
> > When you copy a package to another machine you don't have to adapt any
> > search paths or compiler options.
>
> Realy? I think I have to somehow tell Lazarus about a new package, don't
> I?
Yes.
Or an installer can add a lpl file.
> So what is the advantage to clicking on "Load package" or whatever
> and specifying the location path of the package over copying the units
> into the directory where Lazarus expect them?
You are free to put the package anywhere you like.
You can easily switch between different versions.
> > When some compiler option changes or a sub directory is renamed or the
> > package is moved to another location on you disk, you don't have to
> > adapt all your projects that uses the package.
>
> I don't see this. When I rename a directory which Lazarus uses then I
> think it will fail. So in the end I need to tell Lararus about the
> change anyway. I have to find out how and where to do this. What is the
> difference to knowing where to specify search paths and change them?
When you rename a directory you have to adapt only one place.
Over the last years many directories and compiler options have
changed in the Lazarus sources and the biggest part of those changes
had no effect on the users' projects.
I other words: packages gives developers more freedom to refactor their
code.
> > Packages allow to share ppu files. You don't have to recompile
> > the LCL for every project. Each package has its own directory where its
> > ppu files are stored.
>
> That's the concept of units. I just wonder why this is/was not enough.
The concept/advantage of units is to share code.
The concept/advantage of ppu is to compile less.
The ppus do not store where they came from or how they were
compiled. This means for example when you change a flag the compiler can
not tell what ppu needs recompiling. You have to rebuild
everything manually.
With packages you know what ppu belongs to which unit and how
they were compiled. The IDE will automatically recompile packages clean
if you change flags.
Mattias
More information about the Lazarus
mailing list