Lazarus Packages/sk

From Free Pascal wiki
Revision as of 17:55, 2 January 2008 by Slavko (talk | contribs) (Preklad sekcie)
Jump to navigationJump to search

Deutsch (de) English (en) español (es) français (fr) 日本語 (ja) português (pt) русский (ru) slovenčina (sk)

Prehlad balíkového systému Lazarus

Čo je balík v Lazaruse?

Balíček v Lazarus je zoznam unít a komponentov, ktoré obsahujú informácie o tom ako majú byť skompilované a ako môžu byť použité inými balíkmi, alebo IDE. Oproti Delphi, balíky niesu obmedzené len na knižnice a môžu byť nezávislé od operačného systému. (Delphi: Balíček v Delphi je špecialne skompilovaná knižnica používaná aplikáciami, prostredím alebo obomi. Balíky Delphi vyžadujú od prekladača špeciálnu funkciu ktorú fpc v tomto momente ešte nemá a ktorá je závislá na operačnom systéme).

Momentálne podporuje prekladač Free Pascal len statické balíky. Kvôli tomu musíte skompilovať a reštartovať prostredie pri každej inštalácií alebo odinštalácií balíka.

Balík lazarusu je identifikovaný menom a verziou.

FAQ

Otázka: Potrebujem inštalovať balíček?

Odpoveď: Balíček potrebujete inštalovať len, ak obsahuje položky pre dobu návrhu (designtime), ako komponenty pre Paletu komponentov IDE. Ak tieto položky nepoužívate, balíček inštalovať nepotrebujete. Ak chcete len použiť balíček vo svojom projekte, neinštalujte ho.

Otázka: Nainštaloval som balíček, ale IDE nevie nájsť jednotky

Odpoveď: Inštalácia balíčka znamená, že balíček je integrovaný do IDE, nei do Vášho projektu. To sú dve odlišné veci. Pre použitie balíčka vo svojom projekte, použite Project -> Project Inspector -> Add -> New Requirement a odinštalujte balíček, ak neobsahuje žiadne rozšírenie IDE.

Rýchly štart

Aby ste videli balíkoví systém v akcií urobte následovné:

Vytváranie nového balíku:

  • File->New... -> Package -> Standard Package
  • Otvorí sa editor balíkov
  • Použite tlačidlo Save hore vlavo.
  • V závislosti od Vášho nastavenia 'naming' vo Voľbách prostredia sa vás IDE opýta, či má uložiť súbor s malými písmenami. Stlačte Áno.

Gratulujem: Práve ste vytvorili svôj prvý balík.

Pridávanie nového komponentu:

  • Použite tlačidlo Add -> New component
  • Vyberte si komponent v zozname predkov typu combobox. Napr.: TBevel.
  • Kliknite OK
  • Súbor bude pridaný do balíčka a otvorený v editore.
  • Nainštalujte balík pomocou tlačidla 'install' na vrchu editora balíkov.
  • Lazarus uloží balík a spýta sa či má byť IDE prebudované. Sltačte Áno.
  • Balíky sú staticky linkované takže je potrebný reštart IDE.
  • Reštartujte Lazarus a pozrite či máte svoj komponent v lište komponentov (Napr.: TBevel1 bude na 'Additional' stránke).

Gratulujem: Práve ste nainštalovaly svoj prvý balík so svojim prvým komponentom.

Položky menu IDE pre balíčky

File->New... -> Package -> Standard Package
  • vytvorí nový balíček
Project -> Project Inspector
  • zobrazuje, ktoré balíčky sú vyžadované projektom, ktorý je práve otvorený
  • môžete tu pridať/odobrať závislosti
Run -> Compiler options -> Inherited
  • zobrazuje voľby prekladača, a z ktorého balíčka sú zdedené
Components ->
  • Open loaded package: dialóg zobrazujúci všetky otvorené balíčky a ich stav
  • Open package file (.lpk): otvoriť súbor .lpk
  • Open package of current unit: otvoriť súbor .lpk, ktorý patrí súboru v Editore zdrojového kódu
  • Open recent package: otvoriť súbor naposledy otvoreného balíčka (súbor .lpk)
  • Add active unit to a package: pridá jednotku v Editore zdrojového kódu do balíčka
  • Package Graph: Diagram balíčkov, zobrazuje všetky otvorené balíčky a ich závislosti
  • Configure installed packages: upraviť zoznam balíčkov nainštalovaných v IDE - nainštalovať/odinštalovať viacero balíčkov naraz
Project -> Project Inspector
  • tu možno upravovať všetky balíčky použité projektom

The theory

Each Lazarus package has a .lpk file. A package is identified by its name and its version. The name must correspond to the lpk filename. For example:

Name: Package1, Version: 1.0, Filename: /home/.../package1.lpk.

Hint: To rename a package, use 'save as'.

  • The IDE automatically creates the main source file (package1.pas). See below. The lpk file contains information about the required packages, the files it uses, how to compile them, and what is needed to use the package by other packages/projects. The directory where the lpk file is, is called the "package directory".
  • The IDE maintains a list of all package files (packagelinks.xml). Everytime a package is opened in the IDE it will be added to this list. When a package is opened, the IDE automatically opens all required packages via this list.
  • There are three base packages: FCL, LCL and SynEdit. These are parts of the IDE and so they are autocreated, readonly and have no lpk file.
  • Normally a package has a source directory with some pascal units. And normally the lpk file will be there too. A package has also an output directory. Default is the subdirectory 'lib' in the package directory.
  • Before a package is compiled the IDE checks all required packages and if they need update and have the auto update flag, they are compiled first. Then the IDE creates the package main source file. If the lpk file was package1.lpk, then the main source file is package1.pas. This file contains all units in the uses section plus a 'Register' procedure, which is called in the intialization section.

For example:

This file was automatically created by Lazarus. Do not edit!
This source is only used to compile and install
the package GTKOpenGL 1.0.
unit GTKOpenGL; interface uses GTKGLArea, GTKGLArea_Int, NVGL, NVGLX, LazarusPackageIntf; implementation procedure Register; begin RegisterUnit('GTKGLArea', @GTKGLArea.Register); end; initialization RegisterPackage('GTKOpenGL', @Register) end.
  • Then the compiler is called and the package is compiled to the output directory.
  • After successful compilation the state file is created. The state file is put into the output directory. It has the name <packagename>.compiled and contains the information, how the package was compiled. This state file is used by the IDE to check if update is needed.

For example: gtkopengl.compiled:

<?xml version="1.0"?>
<CONFIG>
  <Compiler Value="/usr/bin/ppc386" Date="781388725"/>
  <Params Value=" -Rintel -S2cgi -CD -Ch8000000 -OG1p1
    -Tlinux -gl -vewnhi -l -Fu../../../lcl/units
    -Fu../../../lcl/units/gtk -Fu../../../packager/units
    -Fu. -FElib/ gtkopengl.pas"/>
</CONFIG>
  • The IDE opens all needed packages automatically. This means, it opens all installed packages, all packages marked for installation (auto install), all packages with an open Editor, all packages required by the project and all packages required by one of the other packages. Unneeded packages are automatically unloaded, when the IDE becomes idle.
  • The IDE never opens two packages with the same name at the same time. When the user opens another package file with the same name as an already opened package the IDE will ask to replace the old one.
  • The IDE maintains two extra sets of packages: The 'installed' packages and the 'auto install' packages. The auto install packages will be linked into the IDE on next compile. It creates two new files in the config directory: staticpackages.inc and idemake.cfg. Then it calls 'make ide OPT=@/path/to/your/config/idemake.cfg' to compile itself.

Contributors and Comments

This page has been converted from the epikwiki version.