Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2003-02

Package System

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mattias Gaertner

Hi all,

This mail should start the discussion how to implement the package system for lazarus. Everyone is invited to join the discussion and comment it.

What is a package:
- Delphi: a package is a specially compiled library used by applications, the IDE or both. Delphi packages require compiler magic, which fpc is not capable of at the moment and of course this magic is not OS independent.
- a lazarus package is a collection of units and components, containing information how they can be compiled and how they can be used by projects or other packages or the IDE. In contrary to Delphi, packages are not limited to libraries and they can be OS independent.

A package contains:
- name (valid pascal identifier)
- title, author, description
- version: major + minor + release + build
- filenames plus file type (unit, text)
- icon file
- information how to compile/update the package:
- compiler options to compile the package
- codetools defines
- package dependencies (= required packages)
- information how to be used in projects, other packages, IDE:
- compiler options (e.g. path additions and linker options)
- flag 'auto update'. Automatically compile package, when one of its required packages have changed.
- this information is stored in an xml file and will have the ending .lpk for Lazarus PacKage.

Example:
To compile a lcl package there will be compiler options to add the lcl paths and to put the .ppu/.ppw files into the output directory. Delphi defines one output directory for all packages. Let's call the macro $(PkgDir). I think, we should also support subdirectories. For instance, Tony can specify for his package the output directory $(PkgDir)/tony. The IDE will auto create this directory before package compilation. The package directory can be set in the environment options.

Notes:

- package dependencies:
When a project/package is to be compiled, the IDE should automatically check if a required package has changed and should auto compile till it gets a consistent state. For example: Project A depends on package B, B depends on C, C was recompiled and A should be compiled. Then the IDE should ask the user if package B should be recompiled (unless the auto update flag for package B is set). To accelerate this step the IDE will save information, when each package was compiled.

=============================================

Here are some ideas about the registration:

For Delphi compatibility we should support the 'register' procedure. That means the user adds a 'procedure register;' into the interface section of a unit, which register components, component editors, property editors, ... . Delphi packages automatically call these procedures via compiler magic. fpc can't do this magic for us, so we do lazarus magic:

When a package is compiled, the IDE automaticaly creates/updates the package unit. This package unit looks somewhat like this:

--------------------------------
{ automatically created by lazarus - do not edit } unit LPK_packagename;

{$mode objfpc}{$H+}
interface
uses
  // all units in the package
  ComponentUnit1, ComponentUnit2, Unit3, Unit4,
  // the lazarus package registration unit
  LazPkgReg;
implementation
procedure Register;
begin
  // all units with 'register'
  ComponentUnit1.Register;
  ComponentUnit2.Register;
end;
initialization
  LazPkgSystem.RegisterPackage('packagename',@Register);
end.
--------------------------------

This package unit is only useful for the IDE and is not needed by applications unless they need the package registration.

I suggest to create a <lazarusdir>/package sub directory and put all units of the package system and also the LazPkgReg unit there.

=============================================

Installing a package:
Because fpc does not fully support libs, we can't add/remove components at runtime. We have
to restart the IDE. Gladly lazarus starts a lot quicker than Delphi. The installation itself is done internally by adding the package unit to a uses section. The IDE will have dialogs and will handle most of this automatically just like Delphi.
For example:
To install a package the following five steps are needed: Open a package file, compile it, install it, compile IDE and restart. Normally a user will simply open the package file and click 'install'. The IDE will automatically compile the package, then ask the user if the IDE should be recompiled. After that the IDE gives a note, that the user can now restart the IDE.

=============================================
Projects will get 'package dependencies'. This is simply a list of package names plus minimum versions.

=============================================
Missing points:
- design time / run time packages. Do we need this distinction?
- component icons: The current solution is to add a lazarus resource with the classname.
Sufficient? Or is the risk of redefinition too big?
- Naming. For example: Maybe 'package dependencies' is not as readable as 'package requirements' or 'required packages'.
- IDE front end
- other things ...

I hope I did not forget too much,
Mattias

Reply by email

Mattias Gaertner
to Mattias Gaertner
Show quoted text 22 lines
[cut] > > Installing a package: > Because fpc does not fully support libs, we can't add/remove components > at runtime. We have > to restart the IDE. Gladly lazarus starts a lot quicker than Delphi. The > installation itself is done internally by adding the package unit to a > uses section. The IDE will have dialogs and will handle most of this > automatically just like Delphi. > For example: > To install a package the following five steps are needed: > Open a package file, compile it, install it, compile IDE and restart. > Normally a user will simply open the package file and click 'install'. > The IDE will automatically compile the package, then ask the user if the > IDE should be recompiled. After that the IDE gives a note, that the user > can now restart the IDE. 1. Note that under windows the compile will fail, because a running binary is locked by windows.

Ok, so we have to give a different target to fpc for the IDE executable. Maybe 'newlazarus'. And then we need an alias program 'startlazarus' to delete the old exe, rename the new and start it.

2. It would be a good idea to have most IDE units in compiled form on a separate location, to speed up compilation.

What do you mean with separate location?

Show quoted text 14 lines
> ============================================= > Projects will get 'package dependencies'. This is simply a list of > package names plus minimum versions. > > > ============================================= > Missing points: > - design time / run time packages. Do we need this distinction? _Absolutely_ I have gained lots of experience with packages at work, and you should definitely make the distinction. Not only because users are forced to make a clean design, but also because it makes run-time binaries smaller. You wouldn't want half of lazarus ending up in a user binary...

Why is the user forced to do this? The default under Delphi is a combined design+runtime package. And AFAIK the distinction is an artificial one. You can create small binaries without the Usage options. I also vote to force the user to make a clean design, but I don't see how Delphi helps here. Most lazy users will simply create combined packages, don't they.

Show quoted text 11 lines
> - component icons: The current solution is to add a lazarus > resource with the classname. > Sufficient? Or is the risk of redefinition too big? Sufficient, Delphi uses this too. > - Naming. For example: Maybe 'package dependencies' is not as > readable as 'package requirements' or 'required packages'. > - IDE front end You mean a kind of 'Open Tools API ?'

This can come later. I was asking if the Delphi dialogs and options for packages are intuitive, efficient and sufficient or if lazarus should do it differently.

Mattias

Reply by email

Unknown author
to Mattias Gaertner: This mail should start the discussion how to implement the package system for lazarus.…

[cut]

Show quoted text 15 lines
Installing a package: Because fpc does not fully support libs, we can't add/remove components at runtime. We have to restart the IDE. Gladly lazarus starts a lot quicker than Delphi. The installation itself is done internally by adding the package unit to a uses section. The IDE will have dialogs and will handle most of this automatically just like Delphi. For example: To install a package the following five steps are needed: Open a package file, compile it, install it, compile IDE and restart. Normally a user will simply open the package file and click 'install'. The IDE will automatically compile the package, then ask the user if the IDE should be recompiled. After that the IDE gives a note, that the user can now restart the IDE.

1. Note that under windows the compile will fail, because a running binary is locked by windows.

2. It would be a good idea to have most IDE units in compiled form on a separate location, to speed up compilation.

Show quoted text 10 lines
============================================= Projects will get 'package dependencies'. This is simply a list of package names plus minimum versions. ============================================= Missing points: - design time / run time packages. Do we need this distinction?

_Absolutely_
I have gained lots of experience with packages at work, and you should definitely make the distinction. Not only because users are forced to make a clean design, but also because it makes run-time binaries smaller. You wouldn't want half of lazarus ending up in a user binary...

- component icons: The current solution is to add a lazarus resource with the classname. Sufficient? Or is the risk of redefinition too big?

Sufficient, Delphi uses this too.

- Naming. For example: Maybe 'package dependencies' is not as readable as 'package requirements' or 'required packages'. - IDE front end

You mean a kind of 'Open Tools API ?'

Michael.

Reply by email

Marc Weustink
to Unknown author
Mattias Gaertner wrote
On Sun, 2 Feb 2003 18:20:24 +0100 (CET) wrote:

[snip]

Show quoted text 20 lines
> > ============================================= > > Projects will get 'package dependencies'. This is simply a list of > > package names plus minimum versions. > > > > > > ============================================= > > Missing points: > > - design time / run time packages. Do we need this distinction? > > _Absolutely_ > I have gained lots of experience with packages at work, and you should > definitely make the distinction. Not only because users are forced to make > a clean design, but also because it makes run-time binaries smaller. > You wouldn't want half of lazarus ending up in a user binary... Why is the user forced to do this? The default under Delphi is a combined design+runtime package. And AFAIK the distinction is an artificial one. You can create small binaries without the Usage options. I also vote to force the user to make a clean design, but I don't see how Delphi helps here. Most lazy users will simply create combined packages, don't they.

They might do, but the nice thing of spliting them up is that you can put the design stuff of your component (editors/dialogs etc) in a designtime only package and the component parts in a design/runtime package.

Show quoted text 6 lines
> > You mean a kind of 'Open Tools API ?' This can come later. I was asking if the Delphi dialogs and options for packages are intuitive, efficient and sufficient or if lazarus should do it differently.

I think the dialogs are OK, one thing that can be improved is the usage of directives ($IFDEF or $I) in the package file. Delphi overwrites this info. (prety annoying if you have a package that is compatible with D4,5,6 but requires vcl40, vcl50 or vcl )

Marc

Reply by email

Unknown author
to Marc Weustink
Marc Weustink wrote 30 lines
At 00:43 3-2-2003 +0100, Mattias Gaertner wrote: >On Sun, 2 Feb 2003 18:20:24 +0100 (CET) > wrote: [snip] > > > ============================================= > > > Projects will get 'package dependencies'. This is simply a list of > > > package names plus minimum versions. > > > > > > > > > ============================================= > > > Missing points: > > > - design time / run time packages. Do we need this distinction? > > > > _Absolutely_ > > I have gained lots of experience with packages at work, and you should > > definitely make the distinction. Not only because users are forced to make > > a clean design, but also because it makes run-time binaries smaller. > > You wouldn't want half of lazarus ending up in a user binary... > >Why is the user forced to do this? The default under Delphi is a combined >design+runtime package. And AFAIK the distinction is an artificial one. You >can create small binaries without the Usage options. I also vote to force >the user to make a clean design, but I don't see how Delphi helps here. Most >lazy users will simply create combined packages, don't they. They might do, but the nice thing of spliting them up is that you can put the design stuff of your component (editors/dialogs etc) in a designtime only package and the component parts in a design/runtime package.

What is more, as of Delphi 6 it is MANDATORY.
Design-time packages will no longer of the few improvements in Delphi 6, in my opinion.

Michael.

Reply by email