Multiple Lazarus/ru

From Lazarus wiki
Jump to navigationJump to search

Deutsch (de) English (en) español (es) français (fr) polski (pl) português (pt) русский (ru)

Несколько экземпляров Lazarus

В вашей системе может быть один каталог с Lazarus или более. Эти каталоги могут содержать одинаковые или разные версии Lazarus и могут работать независимо друг от друга (см. Раздел, посвященный --primary-config-dir ниже). Поскольку вам не нужно устанавливать Lazarus и версии могут быть одинаковыми, в этой статье концепция наличия нескольких каталогов Lazarus в вашей системе будет называться «несколько экземпляров».
Посмотреть для Linux в DualLaz.

Важная информация

  • Создайте резервные копии
    • вашей начальной конфигурации (например ~/.lazarus в системе Unix)
    • ваших файлов проектов *.lpi и *.lps

Кому нужно несколько версий Lazarus, а кому нет?

Вам нужно несколько версий Lazarus если...

  • использовать для разработки несколько разных версий Lazarus
  • иметь Lazarus собранный разными версиями FPC

Вам не нужно несколько версий Lazarus если...

  • собирать и тестировать свой проект с использованием разных виджетов
  • для кроссплатформенной компиляции

Каталог Lazarus

Каталог Lazarus (то есть каталог, в котором находится приложение Lazarus) можно переопределить с помощью --lazarusdir, это полезно при запуске Lazarus, например, с USB-флешки с различными точками монтирования или буквами диска.

Директория с конфигурацией

Все настройки IDE сохраняются в определённой директории. В Linux, Mac OS X и BSD директория для конфигурации по умолчанию ~/.lazarus. Обратите внимание на начальную точку, которая делает его скрытым каталогом.

В Windows настройки сохраняются в папке User AppData, которая отображается в другой каталог в зависимости от версии Windows (и языка в Windows XP и более ранних версиях). Смотрите также информацию здесь: Windows. Обратите внимание, что вы не увидите каталог конфигурации в Windows, если не выберите скрытые и системные файлы. Чтобы просмотреть каталог, наберите:

%localappdata%

в поле Start/Run или в адресной строке проводника Windows, в результате чего вы попадете в каталог Local Application Data. Для установок по умолчанию настройки хранятся в указанном там каталоге Lazarus.

ОС Расположение по умолчанию для каталога конфигурации Замечания
Linux, Mac OS X, BSD, другие UNIXes ~/.lazarus Скрытая папка
Windows XP C:\Documents and Settings\<User name>\Local Settings\Application Data\lazarus Английская Windows; другие [локализации ОС] могут иметь разные пути
Windows Vista и выше C:\Users\<User name>\AppData\Local\lazarus\ Независимо от выбранного языка

Каталог config не может быть разделен между разными версиями Lazarus. Более новый Lazarus может читать старые конфигурации и будет обновлять их автоматически. Нет гарантии, что более старая версия может читать файлы конфигурации более новой версии. Всегда хорошая идея время от времени делать резервную копию ваших конфигов на случай, если вы странно изменили что-то и не знаете, что это было.

Решение для разделения экземпляров с использованием нескольких директорий config

Каталог config может быть задан в командной строке с параметром --primary-config-path (более короткая версия: --pcp). Например

lazarus --primary-config-path=~/.lazarus2

запустит IDE, используя ~/.lazarus2 в качестве каталога конфигурации. Таким образом, вы можете иметь произвольное количество каталогов конфигурации и запускать несколько независимых экземпляров Lazarus. Поскольку Lazarus создает файлы настроек по умолчанию, если они не существуют, вы можете указать пустые каталоги, если хотите.

Если вы используете это часто, то можно создать небольшой скрипт bash:

#!/bin/sh
/path/to/lazarus --primary-config-path=~/.lazarus2

В Windows вы не можете использовать [символ] ~, поэтому используйте вместо этого, например, ярлык на рабочем столе со следующими параметрами для вызова Lazarus:

\path\to\lazarus.exe --primary-config-path=lazarusconf

Это поместит каталог конфигурации lazarus в каталог lazarus.

Использование файла lazarus.cfg

Другой способ настройки каталога конфигурации - использовать файл "lazarus.cfg", поместить его в папку с исполняемым файлом Lazarus и записать в него следующую строку:

--primary-config-path=\path\to\config\folder

Вы можете создать папку конфигурации в пути установки Lazarus и установить ее путь к файлу cfg. После этого Lazarus будет использовать этот файл lazarus.cfg для дальнейшего использования, и нет необходимости создавать файл bash или ярлык с параметром.

Например, для установки Windows это будет выглядеть так: Папка конфигурации и файл lazarus.cfg рядом с исполняемым файлом Lazarus и поместите такое значение, например, в файл cfg:

--primary-config-path=C:\Lazarus2\config\

и запустите Lazarus. Он будет запрашивать некоторые значения конфигурации, а после вы можете сделать простой ярлык для последующего использования без каких-либо параметров.

Config directory files

lazarus.dci - here Lazarus stores Code Templates

editoroptions.xml - information about colors, fonts and other editor options

miscellaneousoptions.xml - packages information

environmentoptions.xml - here stores history of opened projects and files(Recent Opened Files and Projects)

Файлы Lazarus

The Lazarus source archive is contained in a single directory. You can simply compile Lazarus (see installation instructions) and a lot of files and subdirectories will be created, but and all will be below that single subdirectory.

A Lazarus instance (sources and resources) is a single subdirectory. Just copy this directory and you get a whole new Lazarus instance.

You don't need to install Lazarus to be able to run it. But if you do indeed install Lazarus, you get some nice shortcuts on your desktop and some file types (e.g. lpk, lpi, pas) are associated with that Lazarus installation. These things are platform dependent. There is no more than one single Lazarus indeed installed, secondary copies are just "there".

Newer installers support installing Lazarus multiple times. Alternatively, You can also add another Lazarus instance manually quite easily. Of course, file associations etc. can only be linked to one single Lazarus instance.

Linux

Find a 2015 run-through for Linux 64 bit at DualLaz.

Пример 1: Нормально установленный Lazarus плюс SVN версия

Download and install the Lazarus debian- & .rpm - packages as normal.

Then download the Lazarus svn archive to a directory of your choice, preferably somewhere in your home directory (e.g. ~/lazarus). See here Installing_Lazarus#Downloading_Lazarus_SVN.

Start your secondary Lazarus with:

/home/you/lazarus/startlazarus --pcp=~/.lazarus2nd

Example 2 : A normally installed Lazarus instance plus a manual copy

i.e. you obtain two subdirectories:

/usr/lib/lazarus     original  copy     via debian install
/home/you/lazarus    secondary copy 

or you may look at:

/home/you/development/lazarus    original copy      via fpcUP install
/home/you/lazarus                secondary copy 

Download and install the Lazarus debian-packages as usual.

Then copy the Lazarus directory to your home directory and change the ownership of the files:

cp -a /usr/lib/lazarus $(HOME)/
chown $USER:$USER -R $(HOME)/lazarus

(Note: The chown line assumes that your group has the same name as your username. If not, replace $USER:$USER with your username:groupname)

Now change your Lazarus desktop/menu shortcut to start the secondary copy

/home/you/lazarus/startlazarus --pcp=~/.lazarus2nd

Then start the IDE and change the environment options: Tools -> Options -> Environment / Lazarus directory to the secondary subdir, namely /home/you/lazarus


In recent Lazarus versions, you are also given a screen to name the other important paths, so you would name the secondary sudirs in the 2ndary config.

Also, inside the /home/you/development/fpc/bin/x86_64-linux/fpc.cfg text file, all paths should rather point to your secondary copy. To make sure everything is fine, run startlazarus from within xterm and watch the errormessages. make sure all paths are found (very difficult currently).


You now have a secondary copy that which you can edit and recompile. Don't forget to close source files of the primary /usr/lib/lazarus.

Windows

Example 1: SVN and Release

This is to have both SVN and last release version of Lazarus.

1) Install Lazarus last release and check setup option 'create desktop shortcut', you will get 'Lazarus.lnk' on the desktop.

2) Get Lazarus from SVN and compile, then create a shortcut on your desktop for 'lazarus.exe' and rename it to 'Lazarus SVN.lnk'.

Then you can set the config dir for each version editing the shortcut path to the executable:

This is for release, because you don't change the primary config path parameter, the config will be saved in the default path:

C:\lazarus\startlazarus.exe

For SVN, store the settings e.g. in the folder 'C:\lazsvncfg\':

C:\FPC\laz\startlazarus.exe --primary-config-path=C:\lazsvncfg

Installation of multiple Lazarus

Windows - Using the installer

On Windows the installer (Version 1.1) can create a secondary installation. And it will ask for a folder to store the config.

  • Install:
    • Make sure you back up ALL your existing configurations BEFORE you install.
    • AGAIN: Make sure you back up ALL your existing configurations BEFORE you install.
    • After install check that the correct config is used
      See the file "lazarus.cfg" in the installation directory. And Menu "View" > "IDE Internals" > "About IDE"
    • If you see a message about upgrading/downgrading the config, then the installation is incorrect. Press "Cancel"
  • Usage
    • Do not share packages between installations; rather you must have several independent copies of each package
    • Backup lpi and lps files (if you share projects). Ideally store sessions (lps) in the "IDE config directory"
      Menu: "Project" > "Project Options" > Session
  • Uninstall:
    • If you plan to uninstall: back up everything again
  • Update:
    • If you plan to update, back up everything again
    • After updating, check that the correct config is still being used
      See the file "lazarus.cfg" in the installation directory. And Menu "View" > "IDE Internals" > "About IDE"

The Windows Installer is able to create secondary installations, which allows you to have different versions installed that do not interfere with each other.

All you need to do is tick the checkbox "secondary installation" (when choosing the install directory), and follow the instructions. You will then be asked for a new empty folder where the config will be stored (this can be a subfolder in the install directory).

If you update an installation using the Windows Installer, it will detect when the selected directory contains a secondary install.

In order to always be able to quickly see which IDE you are using, and also to check that the correct config is loaded, it is advisable to make changes to some visual attributes. A possibility is to change the gutter color in the editor.

Windows - Adding a cross compiler install

The installation packages for cross compilers can be added to secondary installations, too. However, they will currently give a warning that the folder is not empty. This warning can be ignored.