Packages

This is an old revision of Packages, edited by Marcov at . The current revision is 38366.

FPC/Lazarus unfortunately are a bit ambiguous with respect to the term packages. In general it is a collection of units, but the precise way they are related varies. The most common definitions:

  1. A set of units in FPC that are treated together. Both in the fpcmake as the newer fppkg packagemanager contexts.
  2. A set of units in Lazarus (with designtime parts that require registration into the DLL). See Lazarus Packages
  3. A set of units compiled into a DLL with some extra features that make the package a logical part of the main program, instead of an "external" part. Also called Delphi package. I call this Library package from now on.

This article is meant as a brainstorm session about the latter, one of the missing pieces of the Delphi compability. Most created from browsing an hour on the web, looking at articles about fixes and modding the packages system

Note that in time Lazarus packages might be implemented as Delphi packages.

Delphi packages

Maybe Delphi packages is a bad name btw. Library package would be better? I'll at least use it for this article till something better comes up.

A Library-package can be seen from an implementation point, then it is essentially a DLL with some extra's, or from a language point, then it is a library that consists out of a couple of units, and the library itself (the package) is also an own entity with respect to dependancies. (have a dep on the lib, then you have a dep on all units in it)

Some implementation points:

References

What needs to be done

This roughly splits into three or four parts: (note that afaik Delphi supports all this)

  1. Be able to create and use packages on all platforms. (statically)
    1. RTL into a DLL
    2. mainprogram uses RTL, and can access all symbols it could without. (properties, vars, typed constants, functions, RTTI)
    3. Add another package to the mix. (and multiple in general)
  2. Be able to use package dynamically
    1. Make sure the RTL checks all required packages for a dynloaded package are loaded.
  3. Implement the language/semantic parts.
    1. language and compiler support for package dependancies (requires etc)
    2. Some way to handle versioning (PPL versioning?)
    3. Delphi's "build with packages" and the package list to link is signaled from outside the source. IOW cmdline parameters or a small file with data in the FPC case.

The language support requires a new concept above mere ppu level, that of collection of ppus, that is crosslinked to ppu level. This because on package level, the dependancies are administrated on package level, and in the source on unit level. (the keywords of a "library" unit explicit hint on this "requires" is for package level dependancies, and the unit list is the unit list the package supports). However instead of "requires" this can also be done using cmdline parameters (toggling "build with packages" and specifying the package list in the Delphi IDE)

Lazarus and Library packages

Even though Delphi uses this system for its packages, it doesn't mean Lazarus should also. Borland was mostly fixed on one platform (this is pre-Kylix) when they designed this.

Since we need packages regardless of what Lazarus does,

Versioning

A somewhat harder nut to crack is library versioning. Borland only released a dozen delphi's over more than a decade (updates are apparantly kept compatible), which keeps the versioning problem somewhat managable.

We all know the notorious cygwin, but also cygwin only releases an incompatible DLL every two months. Granted, currently we don't make a semiannual schedule, but we are also not THAT far from such frequency.

I don't have any ready made proposals here. It will probably need evaluation after the initial implementation period, how easy it is to make incompatible versions.

During a quick brainstorm at a FPC meeting possible problems are: