KDevelop4/Manual/Sessions and projects: Difference between revisions
m (To to->To do) |
No edit summary |
||
(14 intermediate revisions by 6 users not shown) | |||
Line 5: | Line 5: | ||
<!--T:2--> | <!--T:2--> | ||
In this section, we will go over some of the terminology of how '''KDevelop''' sees the world and how it structures work. In particular, we introduce the concept of | In this section, we will go over some of the terminology of how '''KDevelop''' sees the world and how it structures work. In particular, we introduce the concept of ''sessions'' and ''projects'' and explain how you can set up the projects you want to work on in '''KDevelop'''. | ||
</translate><span id="Terminology"></span><translate> | </translate><span id="Terminology"></span><translate> | ||
Line 12: | Line 12: | ||
<!--T:4--> | <!--T:4--> | ||
'''KDevelop''' has the concept of | '''KDevelop''' has the concept of ''sessions'' and ''projects''. A session contains all projects that have something to do with each other. For the examples that follow, assume you are the developer of both a library and an application that uses it. You can think of the core KDE libraries as the former and '''KDevelop''' as the latter. Another example: Let's say you are a Linux kernel hacker but you are also working on a device driver for Linux that hasn't been merged into the kernel tree yet. | ||
<!--T:5--> | <!--T:5--> | ||
Line 18: | Line 18: | ||
<!--T:6--> | <!--T:6--> | ||
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 | 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 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). | ||
<!--T:7--> | <!--T:7--> | ||
Line 28: | Line 28: | ||
<!--T:9--> | <!--T:9--> | ||
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 <menuchoice>Session -> Start new session</menuchoice> 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). | 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 <menuchoice>Session -> Start new session</menuchoice> 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 ==== <!--T:18--> | |||
<!--T:19--> | |||
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 <menuchoice>Project</menuchoice> menu to create the Linux kernel as a project inside the current session and then follow these steps: | |||
<!--T:10--> | <!--T:10--> | ||
* Go to <menuchoice>Projects -> Fetch project</menuchoice> to import a project | |||
< | <!--T:22--> | ||
< | * 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. | ||
<!--T:23--> | |||
* Assuming you don't already have a version checked out: | |||
** In the dialog box, under <menuchoice>Select the source</menuchoice>, choose to use <menuchoice>Subversion</menuchoice>, <menuchoice>Git</menuchoice>, 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 <menuchoice>Get</menuchoice>. 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 {{Input|1=du -sk /path/to/KDevelop/project}} to see how much data has already been downloaded. | |||
<!--T:24--> | |||
{{Note|1=The problem with the progress bar has been reported as [http://bugs.kde.org/show_bug.cgi?id=256832 KDevelop bug 256832].}} | {{Note|1=The problem with the progress bar has been reported as [http://bugs.kde.org/show_bug.cgi?id=256832 KDevelop bug 256832].}} | ||
{{Note|1=In this process, I also get the error message ''You need to specify a valid location for the project'' which can be safely ignored.}}< | {{Note|1=In this process, I also get the error message ''You need to specify a valid location for the project'' which can be safely ignored.}} | ||
< | <!--T:25--> | ||
< | * It asks you to select a '''KDevelop''' project file in this directory. Since you probably don't have one yet, simply hit <menuchoice>Next</menuchoice> | ||
< | |||
</ | <!--T:26--> | ||
* Hit <menuchoice>Next</menuchoice> again | |||
<!--T:27--> | |||
* '''KDevelop''' will then ask you to choose a project manager. If this project uses standard Unix make files, choose the custom makefile project manager | |||
<!--T:28--> | |||
* '''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 <menuchoice>Settings -> Configure KDevelop</menuchoice> menu item, then selecting <menuchoice>Background parser</menuchoice> 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 ==== <!--T:20--> | |||
<!--T:21--> | |||
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 <menuchoice>Projects -> Open/Import project</menuchoice> dialog. If the project already has a makefile (or CMakeList.txt) then browse into the directory in which your project resides, and select the makefile; you will then be shown a further dialog that enables you to change the name of the project (from the default, which is the name of the folder containing the makefile). For a makefile the Build System system selection should remain as Custom Makefile Project Manager. If you have a makefile with multiple targets then you will have to select <menuchoice>Run->Configure Launches...</menuchoice>, select Global and then click the +Add New button, select Compiled Binary, select the Executable radio button, and enter the full path of the executable in the Executable text box. | |||
</translate><span id="Setting up an application as a second project"></span><translate> | </translate><span id="Setting up an application as a second project"></span><translate> | ||
Line 65: | Line 87: | ||
<!--T:15--> | <!--T:15--> | ||
There is of course also the possibility that you want to start a new project from scratch. This can be done using the <menuchoice>Projects -> New from | There is of course also the possibility that you want to start a new project from scratch. This can be done using the <menuchoice>Projects -> New from Template</menuchoice> menu item, which presents you with a template selection dialog. Some project templates are provided with '''KDevelop''', but even more are available by installing the '''KAppTemplate''' application. Choose the project type and programming language from the dialog, enter a name and location for you project, and click <menuchoice>Next</menuchoice>. | ||
<!--T:29--> | |||
[[Image:kdevelop-project-dialog.png|thumb|500px|center]] | |||
<!--T:30--> | |||
The second page of the dialog allows you to set up a version control system. Choose the system you wish the use, and fill in the system-specific configuration if needed. If you do not wish to use a version control system, or want to set it up manually later, choose <menuchoice>None</menuchoice>. When you are happy with your choice, press <menuchoice>Finish</menuchoice>. | |||
<!--T:31--> | |||
Your project is now created, so you can try building or installing it. Some templates will include comments within the code, or even a separate README file, and it is recommended that you read those first. Then, you can start working on your project, by adding whatever features you want. | |||
<!--T:16--> | <!--T:16--> | ||
{{Prevnext2 | {{Prevnext2 | ||
| prevpage=Special:MyLanguage/Kdevelop4/Manual/ | | prevpage=Special:MyLanguage/Kdevelop4/Manual/Meet_KDevelop | nextpage=Special:MyLanguage/KDevelop4/Manual/Working_with_source_code | ||
| prevtext= | | prevtext=Meet KDevelop | nexttext=Working with source code | ||
| index=Special:MyLanguage/KDevelop4/Manual | indextext=Back to menu | | index=Special:MyLanguage/KDevelop4/Manual | indextext=Back to menu | ||
}} | }} |
Latest revision as of 10:20, 17 April 2018
Sessions and projects: The basics of KDevelop
In this section, we will go over some of the terminology of how KDevelop sees the world and how it structures work. In particular, we introduce the concept of sessions and projects and explain how you can set up the projects you want to work on in KDevelop.
Terminology
KDevelop has the concept of sessions and projects. A session contains all projects that have something to do with each other. For the examples that follow, assume you are the developer of both a library and an application that uses it. You can think of the core KDE libraries as the former and KDevelop as the latter. Another example: Let's say you are a Linux kernel hacker but you are also working on a device driver for Linux that hasn't been merged into the kernel tree yet.
So taking the latter as an example, you would have a session in KDevelop that has two projects: the Linux kernel and the device driver. You will want to group them into a single session (rather than having two sessions with a single project each) because it will be useful to be able to see the kernel functions and data structures in KDevelop whenever you write source code for the driver — for example so that you can get kernel function and variable names auto-expanded, or so that you can see kernel function documentation while hacking on the device driver.
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 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
dialog. If the project already has a makefile (or CMakeList.txt) then browse into the directory in which your project resides, and select the makefile; you will then be shown a further dialog that enables you to change the name of the project (from the default, which is the name of the folder containing the makefile). For a makefile the Build System system selection should remain as Custom Makefile Project Manager. If you have a makefile with multiple targets then you will have to select , select Global and then click the +Add New button, select Compiled Binary, select the Executable radio button, and enter the full path of the executable in the Executable text box.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, which presents you with a template selection dialog. Some project templates are provided with KDevelop, but even more are available by installing the KAppTemplate application. Choose the project type and programming language from the dialog, enter a name and location for you project, and click .The second page of the dialog allows you to set up a version control system. Choose the system you wish the use, and fill in the system-specific configuration if needed. If you do not wish to use a version control system, or want to set it up manually later, choose
. When you are happy with your choice, press .Your project is now created, so you can try building or installing it. Some templates will include comments within the code, or even a separate README file, and it is recommended that you read those first. Then, you can start working on your project, by adding whatever features you want.