[Lazarus] Create a package - how?

Mattias Gaertner nc-gaertnma at netcologne.de
Fri Jun 5 09:10:41 CEST 2009


On Fri, 05 Jun 2009 03:19:19 +0200
Hans-Peter Diettrich <DrDiettrich1 at aol.com> wrote:

> Mattias Gaertner schrieb:
> 
> >> After some tries and assistance from the chat I've moved the
> >> package source files into a new directory dockmanager/package. Is
> >> that okay?
> > 
> > Yes, if this is an example package only used by the examples.
> 
> The package contains an docking manager (LDockTree replacement),
> useful in every application.

Then it should be moved to components.

 
> >> Next question: where to place the package project, into the
> >> dockmanager/ or dockmanager/package directory?
> > 
> > I don't know what you mean with "package project". An example
> > project for the package? Or the package main file (.lpk)?
> 
> In Delphi packages are projects, and the package projects (main
> files) frequently reside in dedicated directories, one for every
> compiler version.
> 
> Since Lazarus has not so many problems with compiler versions,
> the .lpk file better should reside in the directory with all the
> other package files.
> 
> IMO this difference between Delphi and Lazarus packages should be 
> mentioned in the documentation about creating Lazarus packages. I've 
> tried to collect all the issues, that currently are not clear to a 
> Lazarus package newbie, so that the documentation can be updated 
> accordingly.

I hope you collected them on our wiki site:
http://wiki.lazarus.freepascal.org/Lazarus_Packages

> 
> > Don't mix source directories. Every source directory should be
> > exactly in one project or in one package.
> 
> Another topic for the documentation. In Delphi I used to develop 
> packages together with a test application, with all the source files
> in the same directory. This procedure is not suitable for Lazarus
> packages, since the compiled files go into different directories for
> compilation of the test project and the package itself. The compiler
> later is confused by the duplicate files in different directories,
> what should be prevented by stricter separation of both "projects".

I wrote this many times in the wiki and the IDE has some checks.
Maybe some more warnings should be added.

 
> >> With the project in dockmanager/, adding files resulted in a dialog
> >> "New unit not in unitpath", suggesting "Add package/ to UnitPath".
> >> Of course the path should be added?
> > 
> > Not always.
> 
> When and when not?

For example for OS dependent units. Or for example units.

 
> As with the other pathes, the documentation does not shed enough
> light on the purpose of the different pathes. Eventually the option
> dialogs should show according hints for the various edit fields.

You are welcome to improve the wiki and make proposals for the hint
texts.

 
>[...]
> >> The remaining problems seem to be related to the package pathes.
> >> The "Package Options" dialog shows Unit = "$(PkgOutDir)". What's 
> >> "PkgOutDir", 
> > 
> > see
> > http://wiki.lazarus.freepascal.org/IDE_Window:_Package_Options#Unit
> 
> The description is hidden in
> <http://wiki.lazarus.freepascal.org/IDE_Macros_in_paths_and_filenames>
> in an unsorted list of many unrelated macros.
> 
> The wording "Unit Files" or "Other Unit Files" is very misleading, 
> because "unit" is associated with *source* files in the first place,
> not with *compiled* files. 

We could do a multiple choice test when starting the IDE to find out the
expectation of a user and personalize the IDE. ;)


> I already noticed that the Lazarus project
> has several unit/ directories for compiled files, where a Delphi user
> would expect that these directories contain source files (for e.g.
> packages).

Can you give an example?

 
> Descriptions like:
>  >>
> The unit path is used by the IDE and the compiler to search for
> pascal units (.pas, .pp, .ppu).
> <<
> are very confusing, because the locations for .pas and .ppu files are 
> (should be) different for packages, and the IDE will not have much
> use for .ppu files, I think.

Now I'm confused that you are confused.
Of course the compiler can do more with ppu files than the IDE. But the
IDE needs the path to the ppu as well.

 
> The "Other" attribute is useless as long as it is not clear what are 
> "non-Other" items.

Yes, I think so too. 

 
>[...]
> > here is the list of macros:
> > http://wiki.lazarus.freepascal.org/IDE_Macros_in_paths_and_filenames
> 
> IMO this list should be structured better, and/or sorted
> alphabetically. (see above)

Sure, feel free to sort them.
It's hard as developer to step back and see the things as beginner.
We need non developers that structure the documentation for beginners.

 
>[...]
> Yes and no. The path delimiter should be added *before* the path is 
> shown in the dialog, when a new package is created. (see below)

Please create a bug report.


> >> Should I check "Add package unit to uses section" - what's the
> >> purpose or benefit of this option?
> > 
> > I added some info to the wiki. Press F1.
> 
> Where?
> 
> This option should be listed as item 1.3 in
> <http://wiki.lazarus.freepascal.org/IDE_Window:_Package_Options>, but
> no such item exists there :-(

Ah, I misunderstood.
Added.


> >> After I created the package during above steps, and updated the
> >> original sample project to use the new package, everything worked
> >> fine on Linux. Not so on Windows :-(
> > 
> > You forgot to tell the error message.
> 
> This was a very weird thing, in the preceding version of the package. 
> The compiler could not find the required package SynEdit.
> 
> The reason for this error was the missing path delimiter in the Unit 
> path (see above). The compiler search path then contained an invalid 
> concatenation with the inherited pathes, hiding the path to the
> SynEdit unit files. AFAIR I noticed the bad path in the Compiler
> Options -> Inherited page, where the bottom pane showed the merged
> path in one line. Later, when the IDE really had added the delimiter,
> that line occured splitted into two lines, and the compilation error
> disappeared.
> 
> The package creation wizard should add the missing path delimiter, to 
> prevent such misleading compiler errors.

There is a probably misunderstanding.
There is a path delimiter (\ under windows) and there is a search path
delimiter (semicolon).
The IDE automatically appends path delimiters.
It never automatically adds search path delimiters.
Of course when concatenating two search paths it adds a search path
delimiter.
Please try to reproduce the error and get some more details. 


Mattias




More information about the Lazarus mailing list