KDevelop5/Manuel/Sessions et projets

From KDE UserBase Wiki
Revision as of 19:17, 29 June 2018 by ChristianW (talk | contribs) (Created page with "Quelques modèles de projets sont fournis avec '''KDevelop''', vous pouvez en trouver d'autres sur internet en cliquant sur le bouton <menuchoice>Obtenir davantage de modèles...")

Sessions et projets: les bases de KDevelop

Dans cette section, nous aborderons certains points de terminologie concernant la manière dont KDevelop voit le monde et comment il structure le travail. En particulier, nous introduirons le concept des sessions et celui des projets et expliquerons comment vous pourrez déclarer les projets sur lesquels vous voulez travailler à l'intérieur de KDevelop.

Terminologie

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).

Démarrer une session et importer un projet existant

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 Session -> Start new session 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: Importer un projet d'un serveur de système de gestion des versions

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 Project menu to create the Linux kernel as a project inside the current session and then follow these steps:

  • Allez à Projets -> Rechercher un projet pour importer un projet
  • Ensuite vous avez plusieurs possibilités pour démarrer un nouveau projet dans la session courante, et cela en fonction de l'endroit où vos sources sont localisés : vous pouvez simplement faire pointer KDevelop vers un répertoire existant (voir option 2 ci-dessous), ou vous pouvez demander à KDevelop de récupérer les sources d'un dépôt.
  • Assuming you don't already have a version checked out:
    • In the dialog box, under Select the source, choose to use Subversion, Git, 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 Get. 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
      du -sk /path/to/KDevelop/project
      to see how much data has already been downloaded.

Remarque

Le problème lié à la barre de progression a été référencé sous le numéro de bogue KDevelop 256832.

Remarque

Dans ce processus, j'obtiens aussi le message d'erreur Vous devez spécifier un chemin valide pour le projet qui peut être tout à fait ignoré.


  • Il vous est demandé de sélectionner un fichier projet KDevelop dans ce répertoire. Comme probablement vous n'en n'avez pas encore, cliquez simplement sur Suivant
  • Cliquez de nouveau sur Suivant
  • KDevelop vous demandera ensuite de choisir un gestionnaire de projet. Si ce projet utilise les fichiers make standards de Unix, choisissez le gestionnaire de projet du makefile client
  • 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 Settings -> Configure KDevelop menu item, then selecting Background parser on the left, and increasing the number of threads for background parsing on the right.)

Option 2: Importer un projet qui est déja présent sur votre disque dur

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 Projects -> Open/Import project and in the dialog box choose the directory in which your project resides.

Configurer une application en tant que second projet

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.

Si vous avez de multiples applications ou bibliothèques, répétez simplement les étapes pour ajouter de plus en plus de projets à votre session.

Créer des projets à partir de rien

Il y a bien sûr aussi la possibilité pour vous de démarrer un nouveau projet de rien. Cela peut être fait en utilisant l'élément de menu Projets -> Nouveau à partir du modèle... , qui s'ouvre avec un dialogue de sélection de modèles.

Choisir une catégorie et un type de projet


Quelques modèles de projets sont fournis avec KDevelop, vous pouvez en trouver d'autres sur internet en cliquant sur le bouton Obtenir davantage de modèles, ou encore plus en installant l'application KAppTemplate . Choisissez le type de projet et le langage de programmation dans le dialogue, entrez un nom et la localisation de votre projet, et cliquez sur Suivant.

Choisir un système de contrôle des versions


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 None. When you are happy with your choice, press Finish.

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.