1
Overview over the lazarus package system
2
========================================
4
What is a lazarus package:
5
A lazarus package is a collection of units and components, containing
6
information how they can be compiled and how they can be used by projects or
7
other packages or the IDE. In contrary to Delphi, packages are not limited
8
to libraries and they can be OS independent.
9
(Delphi: a package is a specially compiled library used by applications,
10
the IDE or both. Delphi packages require compiler magic, which fpc is not
11
capable of at the moment and of course this magic is OS dependent.)
13
Currently the FreePascal compiler only supports static packages. Therefore
14
you must compile and restart the IDE, each time a package is installed or
17
A lazarus package is distinguished by the name and its version.
19
--------------------------------------------------------------------------------
24
To see the packagesystem in action and to get used to it, do the following:
26
- Create a new package:
27
File->New... -> Package -> Standard Package
28
A package editor opens
29
- Use the Save button at top left.
30
- Depending on your 'naming' setting in the 'environment options',
31
the IDE will ask you to save the file lowercase. Say yes.
32
- Congratulations: You have just created your first package.
35
- Add a new component:
36
- Use the Add button -> New component
37
- Choose a component in the ancestor type combobox.
40
The file will be added to the package and opened
42
- Install the package by clicking the 'install' button in the top of the
44
Lazarus will save the package and ask you,
45
if the IDE should be rebuilt. Say yes.
46
The packages are statically linked, so a restart of the IDE is needed.
47
- Restart Lazarus and see your new component in the component palette
48
(For example: A TBevel1 will be on the 'Additional' page).
49
- Congratulations: You have just installed your first package with your first
53
Now you can have a look at the new IDE items.
55
--------------------------------------------------------------------------------
58
The IDE menu items for packages:
59
================================
61
File->New... -> Package -> Standard Package
62
Creates a new package.
64
Project -> Project Inspector
65
Here you can see, what packages are required by the currently open project.
66
You can add new dependencies and remove unneeded ones.
68
Run -> Compiler options -> Inherited
69
Here you can see what compiler options are inherited from which package.
71
Components -> 5 new items
73
A dialog shows all open packages with their state.
78
- 'Open recent package'
79
Open a recently open package file (lpk file)
82
The package graph shows all open packages and their dependencies.
85
--------------------------------------------------------------------------------
90
- Each Lazarus package has a .lpk file. A package is identified by its name
91
and its version. The name must correspond to the lpk filename. For example:
92
Name: Package1, Version: 1.0, Filename: /home/.../package1.lpk.
93
The IDE automatically creates the main source file (package1.pas). See below.
95
- The lpk file contains information about the required packages, the files
96
it uses, how to compile them, and what is needed to use the package by
97
other packages/projects. The directory where the lpk file is, is called the
100
- The IDE maintains a list of all package files (packagelinks.xml). Everytime a
101
package is opened in the IDE it will be added to this list. When a package is
102
opened, the IDE automatically opens all required packages via this list.
104
- There are three base packages: FCL, LCL and SynEdit. These are parts of
105
the IDE and so they are autocreated, readonly and have no lpk file.
107
- Normally a package has a source directory with some pascal units. And
108
normally the lpk file will be there too. A package has also an output
109
directory. Default is the subdirectory 'lib' in the package directory.
111
- Before a package is compiled the IDE checks all required packages and if
112
they need update and have the auto update flag, they are compiled first.
113
Then the IDE creates the package main source file. If the lpk file was
114
package1.lpk, then the main source file is package1.pas. This file contains
115
all units in the uses section plus a 'Register' procedure, which is called in
116
the intialization section. For example:
118
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
119
{ This file was automatically created by Lazarus. Do not edit!
120
This source is only used to compile and install
121
the package GTKOpenGL 1.0.
129
GTKGLArea, GTKGLArea_Int, NVGL, NVGLX, LazarusPackageIntf;
135
RegisterUnit('GTKGLArea', @GTKGLArea.Register);
139
RegisterPackage('GTKOpenGL', @Register)
141
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
145
- Then the compiler is called and the package is compiled to the output
148
- After successful compilation the state file is created. The state file is put
149
into the output directory. It has the name <packagename>.compiled and contains
150
the information, how the package was compiled. This state file is used by
151
the IDE to check if update is needed. For example: gtkopengl.compiled:
153
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
154
<?xml version="1.0"?>
156
<Compiler Value="/usr/bin/ppc386" Date="781388725"/>
157
<Params Value=" -Rintel -S2cgi -CD -Ch8000000 -OG1p1
158
-Tlinux -gl -vewnhi -l -Fu../../../lcl/units
159
-Fu../../../lcl/units/gtk -Fu../../../packager/units
160
-Fu. -FElib/ gtkopengl.pas"/>
162
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
166
- The IDE opens all needed packages automatically. This means, it opens all
167
installed packages, all packages marked for installation (auto install), all
168
packages with an open Editor, all packages required by the project and all
169
packages required by one of the other packages. Unneeded packages are
170
automatically unloaded, when the IDE becomes idle.
172
- The IDE never opens two packages with the same name at the same time. When
173
the user opens another package file with the same name as an already opened
174
package the IDE will ask to replace the old one.
176
- The IDE maintains two extra sets of packages: The 'installed' packages and
177
the 'auto install' packages. The auto install packages will be linked into
178
the IDE on next compile. It creates two new files in the config directory:
179
staticpackages.inc and idemake.cfg. Then it calls
180
'make ide OPT=@/path/to/your/config/idemake.cfg' to compile itself.