KDevelop4/Manual/Сеансы и проекты
Сессии и проекты: основы KDevelop
В этом разделе мы рассмотрим некоторые термины, как KDevelop смотрит на мир и какова структура работы с ним. В частности, вводится понятие сессий и проектов и описание как можно создать проект с которым Вы будете работать в KDevelop.
Терминология
KDevelop придерживается концепции сессий и проектов. Сессии содержат все проекты, которые как-то связаны с друг-дргом. Например предположим, что Вы являетесь разработчиком как некоторой библиотеки, так и приложения, использующего её. К примеру, библиотеки KDE — это первое, а KDevelop — последнее. Другой пример: допустим что Вы хакер ядра Linux, но Вы так же работаете над драйвером устройства для Linux, который не может быть добавлен непосредственно в исходный код ядра.
И так, возьмём последний пример. Вам требуется создать сессию в KDevelop, которая содержит два проекта: ядро Linux и драйвер устройства. Вы желаете объеденить их одну сессию (вместо того, чтобы иметь две сессии с одним проектом на каждую) потому что будет удобнее видеть функции ядра и структуры данных в KDevelop всякий раз, когда Вы пишете код для драйвера. Это даст возможность автодополнения имён функций и переменных ядра, а так же Вы сможете прочитать документацию на функции ядра в процессе написания драйвера устройства.
Now imagine you also happen to be a KDE developer. Then you would have a second session that contains KDE as a project. You could in principle have just one session for all of this, but there is no real reason for this: in your KDE work, you don't need to access kernel or device driver functions; and you don't want KDE class names autoexpanded while working working on the Linux kernel. Finally, building some of the KDE libraries is independent of re-compiling the Linux kernel (whereas whenever you compile the device driver it would also be good to re-compile the Linux kernel if some of the kernel header files have changed).
Finally, another use for sessions is if you work both on the current development version of a project, as well as on a branch: in that case, you don't want KDevelop to confuse classes that belong to mainline and the branch, so you'd have two sessions, with the same set of projects but from different directories (corresponding to different development branches).
Setting up a session and importing an existing project
Let's stick with the Linux kernel and device driver example — you may want to substitute your own set of libraries or projects for these two examples. To create a new session that contains these two projects go to the
menu at the top left (or, if this is the first time you use KDevelop: simply use the default session you get on first use, which is empty). We next want to populate this session with projects that for the moment we assume already exist somewhere (the case of starting projects from scratch is discussed elsewhere in this manual). For this, there are essentially two methods, depending on whether the project already is somewhere on your hard drive or whether it needs to be downloaded from a server.Option 1: Importing a project from a version control system server
Let's first assume that the project we want to set up -- the Linux kernel -- resides in some version control system on a server, but that you haven't checked it out to your local hard drive yet. In this case, go to the
menu to create the Linux kernel as a project inside the current session and then follow these steps:- Go to to import a project
- You then have multiple options to start a new project in the current session, depending on where the source files should come from: You can just point KDevelop at an existing directory (see option 2 below), or you can ask KDevelop to get the sources from a repository.
- Assuming you don't already have a version checked out:
- In the dialog box, under , choose to use , , or one of the other choices
- Choose a working directory as destination into which the sources should be checked out
- Choose an URL for the location of the repository where the source files can be obtained
- Hit
du -sk /path/to/KDevelop/project
to see how much data has already been downloaded. . This can take quite a long while; depending on the speed of your connection and the size of the project. Unfortunately, in KDevelop 4.2.x the progress bar does not actually show anything, but you can track progress by periodically looking at the output of the command line command
- It asks you to select a KDevelop project file in this directory. Since you probably don't have one yet, simply hit
- Hit again
- KDevelop will then ask you to choose a project manager. If this project uses standard Unix make files, choose the custom makefile project manager
- KDevelop will then start to parse the entire project. Again, it will take quite a while to go through all files and index classes etc. At the bottom right of the main window, there is a progress bar that shows how long this process has come along. (If you have several processor cores, you can accelerate this process by going to the menu item, then selecting on the left, and increasing the number of threads for background parsing on the right.)
Option 2: Importing a project that is already on your hard drive
Alternatively, if the project you want to work with already exists on your hard drive (for example, because you have downloaded it as a tar file from an FTP server, because you already checked out a version of the project from a version control system, or because it is your own project that exists only on your own hard drive), then use
and in the dialog box choose the directory in which your project resides.Setting up an application as a second project
The next thing you want to do is set up other projects in the same session. In the example above, you would want to add the device driver as the second project, which you can do using exactly the same steps.
If you have multiple applications or libraries, simply repeat the steps to add more and more projects to your session.
Creating projects from scratch
There is of course also the possibility that you want to start a new project from scratch. This can be done using the
menu item. The details of what options this offers to you are described elsewhere in this manual.