Get Involved/development: Difference between revisions

From KDE Community Wiki
(Undo revision 96820 by Ngraham (talk) ehh, that was wrong)
Tag: Undo
(Massively reduce the page's size and intimidation factor by linking to sub-pages that contain the information about setting up a dev environment and using kdesrc-build)
Line 6: Line 6:
If you're a visual learner, video tutorials can be found [[Get_Involved/development/Video|here]].
If you're a visual learner, video tutorials can be found [[Get_Involved/development/Video|here]].


== Requirements ==
== Prerequisites ==
=== Prerequisite skills ===


=== Skills ===
Most KDE software is written in C++ using the [https://www.qt.io Qt toolkit] and [https://develop.kde.org/products/frameworks/ KDE Frameworks]. Though prior experience with these technologies or other programming languages is helpful, you don't need to be a C++ programmer to get started! For example, no programming knowledge whatsoever is required to do things like improve text labels.
Most KDE software is written in C++ using the [https://www.qt.io Qt toolkit] and [https://develop.kde.org/products/frameworks/ KDE Frameworks]. Though prior experience with these technologies or other programming languages is helpful, you don't need to be a C++ programmer to get started! For example, no programming knowledge whatsoever is required to do things like improve text labels.


Line 14: Line 14:


=== Operating system ===
=== Operating system ===
 
For KDE development, we recommend a Linux operating system installed on your computer or in a [[/Developing_in_a_virtual_machine|virtual machine]]. Those that are best suited for development provide relatively recent versions of libraries needed by KDE software, and use the rolling-release model. Some examples are Arch, openSUSE Tumbleweed, and KDE neon. The latest versions of Fedora KDE or Kubuntu can work as well.
We recommend that you set up your development environment using a Linux operating system installed on your computer or in a [[/Developing_in_a_virtual_machine|virtual machine]].


Support for Windows and macOS is still experimental, and you may likewise have a better experience [[/Developing in a virtual machine|doing your development in a virtual machine using a Linux distribution]]. Setting up a development environment on [[/More#Other_operating_systems|other operating systems--including FreeBSD]]--is an advanced topic.
Support for Windows and macOS is still experimental, and you may likewise have a better experience [[/Developing in a virtual machine|doing your development in a virtual machine using a Linux distribution]]. Setting up a development environment on [[/More#Other_operating_systems|other operating systems--including FreeBSD]]--is an advanced topic.


The Linux distribution chosen should provide relatively recent versions of Qt and KDE Frameworks. Those that are best suited for development use the rolling-release model (Arch, openSUSE Tumbleweed, KDE neon). The latest versions of Fedora KDE or Kubuntu can work as well.
== Set up a development environment ==
 
If you don't have a KDE development environment set up, [[Get_Involved/development/Set_up_a_development_environment|learn how here]].
== Setting up the development environment ==
{{Info|'''Everything in this section only needs to be done once.''' Once you've done it, your development environment is set up and you can use it to submit patches and develop KDE Software!}}
{{Note|This procedure will set up kdesrc-build for Qt5 and KDE Frameworks 5.<br/>
Setting up kdesrc-build for Qt6 and KDE Frameworks 6 and setting up kdesrc-build inside a Docker container are [[Get_Involved/development/More|advanced topics]].}}
Source code for KDE software lives on [https://invent.kde.org KDE Invent]. But before you can work on it, you'll need to set up a '''development environment''': a set of tools that allows you to access and edit the source code, compile it into a form that the computer can run, and deploy it to a safe location. We will now go through the process of setting one up. To accomplish these tasks, you will need to enter commands using a terminal program, such as KDE's [https://konsole.kde.org/ Konsole].
 
If you're not familiar with the command line interface, you can [https://lifehacker.com/5633909/who-needs-a-mouse-learn-to-use-the-command-line-for-almost-anything find a reasonable tutorial here]. However, advanced command-line skills are not required, and you will learn what you need along the way!
 
=== Install basic tools ===
First you will need to use your operating system's package manager to install some basic tools:
* KDE Neon/Kubuntu/Ubuntu/Debian: <code>sudo apt install git cmake dialog</code>
* Arch/Manjaro: <code>sudo pacman -S git cmake dialog extra-cmake-modules</code>
* Fedora: <code>sudo dnf install git cmake dialog perl perl-IPC-Cmd perl-MD5 perl-FindBin bzip2</code>
* openSUSE Leap & Tumbleweed: <code>sudo zypper install git breezy cmake dialog</code>
 
=== Configure Git ===
We need to set your authorship information properly so that any changes you make can be properly attributed to you:
{{Input|1=<nowiki>
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
</nowiki>}}
 
The name you provide should be your actual name, not your KDE Identity username or a pseudonym. And the email address must be the same as the email address used for your https://bugs.kde.org account. If they don't match, then the <code>BUG: </code> and <code>FEATURE: </code> keywords won't work (see [https://techbase.kde.org/Development/Git/Configuration#Basic_Settings this page] for more information).}}
 
Next, in order to authenticate yourself when pushing code changes, you need to add an ssh key to your GitLab profile as [https://invent.kde.org/help/user/ssh.md described here].
 
=== Set up a graphical IDE/tools ===
 
While not required, you may benefit from setting up [[Get_Involved/development/IDE_configuration|graphical development tools or an Integrated Development Environment (IDE)]]. You may want to try out [http://www.kdevelop.org KDevelop], the KDE IDE.
 
=== Set up kdesrc-build ===
Next, we need a method of '''managing dependencies'''. Every software has dependencies: other pieces of software that provide the functionality they rely on. In order to compile any piece of software, its dependencies must be available.
 
E.g. the KDE application KCalc depends on more than 20 other KDE git repositories: KDE Frameworks and other KDE libraries.
 
Most Linux operating systems do not provide development packages of the KDE Frameworks 5 and of other KDE libraries that are up-to-date enough for us to build from the "master" branch of the KDE git repositories. Therefore we will compile all of the KDE git repositories ourselves, including KDE Frameworks 5 and other KDE libraries. We should not use KDE files (binaries, libraries and other files) from the OS (i.e. the /usr directory). To do this, we use a command-line tool called <code>kdesrc-build</code> to download, manage, build, and install KDE git repositories. Let's set it up now!
 
First, we create a new directory for all the KDE source code we will be using. You will need many GB of free disk space. Budget 50 GB for KDE Frameworks + KDE Plasma, and 10-30 more for some apps as well. We then clone the <code>kdesrc-build</code> git repository in that directory.
 
{{Input|1=<nowiki>
# If you have an old installation of kdesrc-build and you want a clean kdesrc-build installation, run a command line like: # mv ~/.config/kdesrc-buildrc ~/.config/kdesrc-buildrc~bak ; mv ~/kde ~/kde~bak
mkdir -p ~/kde/src
cd ~/kde/src/
git clone https://invent.kde.org/sdk/kdesrc-build.git && cd kdesrc-build
</nowiki>}}
 
Next, it's time to set up <code>kdesrc-build</code> and pick up the changes it made to your <code>~/.bashrc</code> (or  <code>~/.zshrc</code> for zsh users) for the current terminal session:
 
{{Input|1=<nowiki>
# For supported operating systems (OSes), it installs all of the OS packages needed in order to build all of the KDE Frameworks 5.
./kdesrc-build --initial-setup
source ~/.bashrc
 
# Check that the command line above has worked by seeing if the PATH environment variable contains "~/kde/src/kdesrc-build".
echo $PATH
</nowiki>}}
 
{{Warning|Do not run the command <code>kdesrc-build</code> without any arguments because this will build everything, which is probably overkill right now.}}
{{Note|If you use zsh and selected yes for auto-completions during the initial setup for <code>kdesrc-build</code>, add the following to <code>~/.zshrc</code> if it is not already there.
{{Input|1=<nowiki>
autoload -U +X compinit && compinit
autoload -U +X bashcompinit && bashcompinit
</nowiki>}}
}}
 
Run <code>kdesrc-build --help</code> for the kdesrc-build command line help.
 
=== Set up Qt ===
Qt is the fundamental framework that is needed for pretty much all KDE development. We need a recent enough version of Qt to proceed. If you are just getting started, we recommend that you [[Get_Involved/development#Operating_system|use a Linux distribution that is well-suited for building software from source code]] either as the primary operating system or in a virtual machine.
 
You can look up the version of the Qt framework installed on your operating system by opening the application "Info Center" (KInfoCenter) > Basic Information > About this System > "Qt Version:"
 
If Qt 5.15 or later is installed, you're already done done with this step and can proceed to the next section! 🎉
 
...otherwise we now need to install a more recent version from somewhere. Your distribution might have one available. Alternatively, we need to configure <code>kdesrc-build</code> to build and install a recent Qt version for you. [[Get_Involved/development/More#Build_Qt_using_kdesrc-build|Building Qt using kdesrc-build]] is a more advanced topic.
 
=== Disable indexing for your development environment ===
You'll want to disable indexing for your development-related git repos and the files they will build and install. Add <tt>~/kde</tt> to the exclusions list in System Settings > File Search, like so:
 
[[File:Getting involved development file index options.png|center|600px|]]
 
=== Download non-KDE dependencies ===
If your distribution is supported, <code>kdesrc-build --initial-setup</code> will install the distribution packages which are needed in order to build KDE software. <code>kdesrc-build</code> is used in order to build any of the KDE git repositories. The packages for Qt and the rest of the dependencies are acquired using your Linux distribution's package manager.
 
Please [[/Install_the_dependencies|install at least all of the dependencies needed in order to build all of the KDE Frameworks. Steps 4 and 5 of setting up kdesrc-build are here]].
 
'''Reboot your computer''' and log back in so the package changes, and the changed ~/.bashrc take effect on your user account.
 
Once that's done, your development environment is set up and ready to build software! Let's take it for a spin.
 
{{Note|If you happen to find an external dependency needed to build KDE software that was not installed with <code>kdesrc-build --initial-setup</code>, once you finish this tutorial, you may send a merge request to https://invent.kde.org/sdk/kdesrc-build/-/blob/master/modules/ksb/FirstRun.pm in order to include the respective distro package to the list.}}
 
== Building software with kdesrc-build ==
It can take an hour or more to compile a KDE application, Framework, or Plasma itself for the first time. The reason for this is that <code>kdesrc-build</code> is compiling all of the KDE Frameworks 5 modules plus any other KDE module that is a dependency of the module that you tell <code>kdesrc-build</code> to build.
 
<code>kdesrc-build</code> by default has the option "--include-dependencies" enabled so it will ignore all KDE packages that were installed using the distribution's package manager and will instead build all needed KDE modules from source.
 
The next time you want to compile that or any other piece of KDE software, it will be much faster since most of the dependencies will have already been compiled. If you don't want to build all dependencies (e.g., because you are using a rolling release distro that provides recent versions of software), edit the same configuration file and simply set <code>include-dependencies</code> to '''false''' or add the <code>--no-include-dependencies</code> option when running <code>kdesrc-build</code>.
 
=== Frameworks ===
'''[[Frameworks|KDE Frameworks]]''' are libraries of tools and features that can be used by any application or Plasma itself. New versions of KDE Frameworks are [[Schedules/Frameworks|released once a month]]. A list of all of the frameworks can be found here: https://api.kde.org/frameworks.
 
After you [[Guidelines and HOWTOs/Build from source/Install_the_dependencies#For_all_of_the_KDE_Frameworks_5|install all of the dependencies needed in order to build all of the KDE Frameworks]], the first thing that you should do using <code>kdesrc-build</code> is to build all of the KDE Frameworks:
 
{{Input|1=<nowiki>
kdesrc-build frameworks --ignore-modules kdewebkit
</nowiki>}}
 
Note: if you cannot build the KDE Framework kdewebkit because your Linux OS does not have the qtwebkit package, that is not a problem.
 
If a KDE Framework fails to build, see [[#Most_important_current_build_issues|the list of the most important current kdesrc-build build issues]].
 
=== Applications ===
 
[https://apps.kde.org/ KDE Applications] like [https://apps.kde.org/kcalc Calculator (KCalc)], [https://apps.kde.org/dolphin/ Dolphin], [https://apps.kde.org/okular/ Okular], [https://apps.kde.org/konsole/ Konsole] and [https://apps.kde.org/gwenview/ Gwenview] are standalone apps that can be run on multiple platforms, such as Plasma, GNOME, even macOS and Windows! New versions of KDE Applications are [[Schedules#Current_Releases_by_KDE|released three times a year]]. Note that the Discover app store (git repo name: <code>plasma-discover</code>) and System Settings app (git repo name: <code>systemsettings</code>) are distributed alongside Plasma, but they build like apps using the below instructions. A list of all KDE applications can be found here: https://apps.kde.org/.
 
The general steps required to build and run an application are described in the following using KCalc as an example:
 
{{Input|1=<nowiki>
kdesrc-build kcalc
</nowiki>}}
 
This command clones the KDE git repository https://invent.kde.org/utilities/kcalc in the directory <code>~/kde/src/kcalc</code>, builds all of KCalc's KDE dependencies, and then builds KCalc itself, into the directory <code>~/kde/build/kcalc</code>. If the build is successful, the result is installed into <code>~/kde/usr</code>. As a result, '''there is no need to manually install anything;''' <code>kdesrc-build</code> installed it for you! 
 
To run it, use the <code>kdesrc-run</code> command, which launches the built-from-source version instead of the one installed by your system's package manager.
{{Input|1=<nowiki>
kdesrc-run kcalc
</nowiki>}}
 
Did it run? If so, then '''congratulations, you just compiled your own version of the KDE calculator (kcalc) from source code!'''
 
=== Plasma ===
'''[[Plasma|KDE Plasma]]''' is the environment in which you can run apps. Plasma is responsible for providing a desktop with wallpaper, app launchers, and widgets; displaying notifications; managing wired and wireless networks; and similar operating-system level tasks. New versions of Plasma are [[Schedules/Plasma 5|released three times a year]]. Plasma has multiple ''shells'': [https://kde.org/plasma-desktop Plasma Desktop] for desktop, laptop, and 2-in-1 computers, [https://www.plasma-mobile.org/ Plasma Mobile] for mobile phones, [https://plasma-bigscreen.org/ Plasma Bigscreen] for televisions, and so on. They all share certain common components, such as a window manager, networking stack, basic graphical components, and so on. Here is how to build them:
{{Input|1=<nowiki>
kdesrc-build plasma-workspace plasma-framework plasma-integration bluedevil powerdevil plasma-nm plasma-pa plasma-thunderbolt plasma-vault plasma-firewall plasma-workspace-wallpapers kdeplasma-addons krunner milou kwin kscreen sddm-kcm plymouth-kcm breeze discover print-manager plasma-sdk kdeconnect-kde plasma-browser-integration xdg-desktop-portal-kde kde-gtk-config kgamma5 breeze-gtk drkonqi phonon flatpak-kcm kactivitymanagerd --include-dependencies
</nowiki>}}
 
==== Plasma Desktop ====
To build the Plasma Desktop environment and its related apps, also build the following:
{{Input|1=<nowiki>
kdesrc-build plasma-desktop systemsettings plasma-disks plasma-systemmonitor ksystemstats kinfocenter kmenuedit --include-dependencies
</nowiki>}}
 
To get translations in your self-built Plasma, you must build <tt>plasma-workspace</tt> with <code>-DKDE_L10N_SYNC_TRANSLATIONS=true</code>. The easiest way to do this is go into the build directory (<code>~/kde/build/plasma-workspace</code> by default), run <code>ccmake .</code>, turn on that setting, and then rebuild the project.
 
Now it's time to make your built-from-source Plasma session accessible from the SDDM login screen, and also copy the built-from-source DBus files into a location where they are visible to them system bus. To do this, run the following command:
{{Input|1=<nowiki>
~/kde/build/plasma-workspace/login-sessions/install-sessions.sh
</nowiki>}}
 
{{Note|SELinux can interfere with the new DBus services working correctly, and the path of least resistance may be to simply turn off enforcement if you are using a distro that ships with it on by default (for example, Fedora). To do this, set the value of <code>SELINUX</code> to <code>permissive</code> in the file <code>/etc/selinux</code>.}}
 
After this, you can log out and select your new plasma session in SDDM's session chooser menu (which is located in the bottom-left corner of the screen if you're using the Breeze SDDM theme).
 
Alternatively, you can run the new version of plasma on top of your existing system for quick testing like so:
{{Input|1=<nowiki>
source ~/kde/build/plasma-desktop/prefix.sh
~/kde/usr/bin/plasmashell --replace
</nowiki>}}
 
==== Plasma Mobile ====
To build the Plasma Mobile environment, also build the following:
{{Input|1=<nowiki>
kdesrc-build plasma-nano plasma-mobile plasma-settings --include-dependencies
</nowiki>}}
 
You can run your custom-built Plasma Mobile in an emulated phone session using a phone-sized window within your existing desktop. Note that you probably want that this emulated phone session does not use the settings of your current user. E.g. you want in the emulated phone session to use Angelfish, not Mozilla Firefox as your web browser. Instructions:


{{Input|1=<nowiki>
== Build software with kdesrc-build ==
export XDG_RUNTIME_DIR=/tmp/
Once you have a working development environment, learn how to [[Get_Involved/development/Build_software_with_kdesrc-build|use it to build various types of KDE software here]].
export QT_QPA_PLATFORM=wayland
export QT_QPA_PLATFORMTHEME=KDE
export QT_WAYLAND_DISABLE_WINDOWDECORATION=1
export XDG_CURRENT_DESKTOP=KDE
export KSCREEN_BACKEND=QScreen
export KDE_FULL_SESSION=1
export KDE_SESSION_VERSION=5
export QT_QUICK_CONTROLS_MOBILE=1
export PLASMA_PLATFORM=phone:handheld
export $(dbus-launch)
dbus-run-session kwin_wayland --width 360 --height 720 --xwayland "plasmashell -p org.kde.plasma.phoneshell"
</nowiki>}}


Alternative instructions for starting an emulated phone session.
== Choose what to work on ==
 
A good place to start is with a small bug or feature in an existing piece of software that affects you personally ("scratch your own itch"). Get in touch with the existing developers (see [[#Communicate with the dev team|Communicate with the dev team]], below) and they can help you out, by pointing you to the right place in the code and giving advice about how to tackle the problem.
{{Input|1=<nowiki>
export QT_WAYLAND_DISABLE_WINDOWDECORATION=1
export QT_QUICK_CONTROLS_MOBILE=1
export PLASMA_PLATFORM=phone:handheld
 
QT_QPA_PLATFORM=wayland dbus-run-session kwin_wayland --xwayland "plasmashell -p org.kde.plasma.phoneshell" --width 360 --height 720
</nowiki>}}
 
Plasma Mobile can also be run on a mobile device itself. For more information, see the [[Plasma/Mobile/DevGuide#Mobile_device_running_plasma_mobile|DevGuide]].
 
=== Iterating on a single project ===
When you're working on a project and you want to rebuild it to test your changes, you can save a lot of time by only rebuilding that project, rather than the entire stack. For example if you are working on <code>plasma-desktop</code>, you can rebuild only that project rather than everything by running <code>kdesrc-build --no-src --no-include-dependencies plasma-desktop</code>.
 
=== Most important current build issues ===
 
See [[/More#kdesrc-build_issues|the list of the most important current kdesrc-build build issues]] that affect the Linux distributions that are better suited for kdesrc-build.
 
=== How to solve build problems ===
Did one or more modules fail to build (displayed in red font) using <code>kdesrc-build</code>? Here's what to do:
 
# Try building the failing module again from scratch using <code>kdesrc-build [failing module] --refresh-build</code>
# Make sure that you have all the dependencies for the failing module. Go back to the [[#Download non-KDE dependencies]] section and re-install the non-KDE dependencies. If that doesn't fix the problem, open the log file for the failing module which <code>kdesrc-build</code> will print the path at the end of its output. Scroll to the bottom of the log file and read the output to see what missing dependency it is complaining about. Then find and install the corresponding package using the package manager of your distribution. If several look relevant, install them all just to be safe. When you have the necessary dependencies, you can save time and resume from the failing module by adding <code>--resume-from [the name of the module that failed]</code> to your <code>kdesrc-build</code> command.
# Check the [https://build.kde.org/view/Failing/ list of currently broken modules] on the KDE build server. If it's broken there, then it's not your fault. :)
# Ask for help in the the [https://webchat.kde.org/#/room/#kde-devel:kde.org #kde-devel] channel on [[Matrix]] or Libera Chat [[Internet Relay Chat | IRC]]. See [[Get Involved/development#Communicate with the team]]
# Looking into the error log is also helpful. For example, the build stopped at kwallet. You will need to go into <code>kde/src/log/latest/kwallet/error.log</code> and find what packages are missing.
# If you know what files are missing, but you don't know what packages provide them, you can ask your package manager. See https://wiki.archlinux.org/index.php/Pacman/Rosetta (see "Query the package which provides FILE").
# The problem might be in <code>~/kde/usr</code>. E.g. a file in <code>~/kde/usr/include</code> which was renamed or moved. You can help yourself by seeing if you can reproduce this issue in a clean new Virtual Machine (VM). If you cannot reproduce the issue in your VM, then a possible solution is to start with a new and clean kdesrc-build installation. I.e. run something like <code>mv ~/.config/kdesrc-buildrc ~/.config/kdesrc-buildrc~bak ; mv ~/kde ~/kde~bak</code>. Then install kdesrc-build from scratch using this wiki page.
 
== Submitting changes ==
 
Now that you can compile and deploy custom versions of KDE software, you can open your editor and start hacking on the source code!
 
=== Choose what to do ===
 
A good place to start is with a small bug or feature in an existing piece of software that affects you personally ("scratch your own itch"). Get in touch with the existing developers (see [[#Communicate with the team|Communicate with the team]], below) and they can help you out, by pointing you to the right place in the code and giving advice about how to tackle the problem.


Try not to start by proposing or working on major features or significant design changes. These can be controversial, and the smoothest way to get going is by working on relatively non-controversial bugfixes. Start slowly and build trust!
Try not to start by proposing or working on major features or significant design changes. These can be controversial, and the smoothest way to get going is by working on relatively non-controversial bugfixes. Start slowly and build trust!
Line 251: Line 36:
* [[Get_Involved/development/Easy|More easy tasks]].
* [[Get_Involved/development/Easy|More easy tasks]].


=== Make your changes and test them ===
== Make your changes and test them ==
 
Once you've made some changes, make sure the project still compiles and installs, and make sure the changes have the desired effect when you run the software. Then it's time to run the project's test suite. For example, in KCalc:
The code for the KCalc that you built earlier is located at <code>~/kde/src/kcalc</code>; other projects you build with <code>kdesrc-build</code> will live in similar locations.
 
You may wish to look over the [[/IDE_configuration|instructions for setting up an Integrated Development Environment (IDE)]] for development with KDE projects. You can use the debugger inside an IDE to go over the lines of source code that you change.
 
Once you've made some changes, make sure the project still compiles and installs, and make sure the changes have the desired effect when you run the software. Then it's time to run the project's test suite:


{{Input|1=<nowiki>
{{Input|1=<nowiki>
cd ~/kde/build/kcalc
cd ~/kde/build/kcalc
source prefix.sh
source prefix.sh
ctest --output-on-failure # or make test
ctest --output-on-failure
</nowiki>}}
</nowiki>}}


If any test fails, that needs to be investigated and fixed before you can proceed. Once the tests pass, then run the software again to make sure it still behaves properly. If it doesn't, then go back and work on your patch some more, then re-compile and re-deploy, and test again, until the program does what you'd like it to do and all tests pass.
If any test fails, that needs to be investigated and fixed before you can proceed. Once the tests pass, then run the software again to make sure it still behaves properly. If it doesn't, then go back and work on your patch some more, then re-compile and re-deploy, and test again, until the program does what you'd like it to do and all tests pass.


=== How to run an application after making changes to one of its dependencies ===
== Submitting changes for review ==
 
Once you're happy with a patch and have verified that it does what you want, it's time to submit your changes for the review!
Build the application that you want to build. E.g. to return to KCalc:
{{Input|1=<nowiki>
kdesrc-build kcalc
</nowiki>}}
 
This command builds not only KCalc, but all of the KDE git repositories on which it depends, such as the KDE Frameworks 5 library KConfig.
 
Now let's say you want to make a change to KConfig that should change a behavior in KCalc. In this case, you don't want kdesrc-build to discard your changes to KConfig. So first build KConfig separately, on its own, without doing a source code update:
{{Input|1=<nowiki>
kdesrc-build kconfig --no-src --no-include-dependencies --refresh-build --debug
</nowiki>}}
 
This will build just KConfig and install the needed build products into <code>~/kde/usr</code>. Now we want to run KCalc in such a way that it makes use of those changed files. Do it like so:
 
{{Input|1=<nowiki>
kdesrc-build kcalc --no-src --no-include-dependencies --refresh-build --debug
kdesrc-run kcalc
</nowiki>}}
 
=== Submit a Merge Request ===
Once you're happy with your patch and have verified that it does what you want, it's time to submit your changes for the review!


KDE uses their own GitLab instance called [https://invent.kde.org Invent] for submitting merge requests and code review. See the [[Infrastructure/GitLab#Submitting_a_merge_request|GitLab page]] to learn how to submit a merge request.
KDE uses their own GitLab instance called [https://invent.kde.org Invent] for submitting merge requests and code review. See the [[Infrastructure/GitLab#Submitting_a_merge_request|GitLab page]] to learn how to submit a merge request.


=== Communicate with the team ===
== Communicate with the dev team ==
There are several ways to get in touch with KDE developers, either generally or for a specific project. The most important communications channels are:
There are several ways to get in touch with KDE developers, either generally or for a specific project. The most important communications channels are:
* The [https://webchat.kde.org/#/room/#kde-devel:kde.org #kde-devel] channel on [[Matrix]] or the Libera Chat [[Internet Relay Chat | IRC]], which is where KDE developers chat in real-time about their work.
* The [https://webchat.kde.org/#/room/#kde-devel:kde.org #kde-devel] channel on [[Matrix]] or the Libera Chat [[Internet Relay Chat | IRC]], which is where KDE developers chat in real-time about their work.
Line 335: Line 94:
* [https://github.com/Wenzel/docker-kdesrc-build How to build with Docker]
* [https://github.com/Wenzel/docker-kdesrc-build How to build with Docker]


== More ==
== Advanced Topics ==
 
This page continues with [[Get_Involved/development/More|more advanced topics]].
This page continues with [[Get_Involved/development/More|more advanced topics]].

Revision as of 04:16, 15 June 2023

By joining the ranks of KDE developers, you will get to implement new features and defeat bugs both daunting and simple, all while collaborating to make coherent and stable releases. Developers collaborate in teams based on what area they are working in. These can be small teams working on a single application, up to large teams working on a group of related pieces of software. Many developers are in more than one team.

KDE runs or participates in several mentoring programs to help new developers, including an informal list of people who are willing to help newcomers get started. See the Mentoring page for more details.

If you're a visual learner, video tutorials can be found here.

Prerequisites

Skills

Most KDE software is written in C++ using the Qt toolkit and KDE Frameworks. Though prior experience with these technologies or other programming languages is helpful, you don't need to be a C++ programmer to get started! For example, no programming knowledge whatsoever is required to do things like improve text labels.

If you'd like to dive deeper, the Qt wiki contains a list of online books for learning Qt programming. Qt also provides lots of examples you can look at. For visual learners, this YouTube playlist of QML tutorials by KDE patron KDAB may be useful. Finally, information about KDE Frameworks can be found on the KDE Developer Platform and KDE API website. Even more learning resources can be found here.

Operating system

For KDE development, we recommend a Linux operating system installed on your computer or in a virtual machine. Those that are best suited for development provide relatively recent versions of libraries needed by KDE software, and use the rolling-release model. Some examples are Arch, openSUSE Tumbleweed, and KDE neon. The latest versions of Fedora KDE or Kubuntu can work as well.

Support for Windows and macOS is still experimental, and you may likewise have a better experience doing your development in a virtual machine using a Linux distribution. Setting up a development environment on other operating systems--including FreeBSD--is an advanced topic.

Set up a development environment

If you don't have a KDE development environment set up, learn how here.

Build software with kdesrc-build

Once you have a working development environment, learn how to use it to build various types of KDE software here.

Choose what to work on

A good place to start is with a small bug or feature in an existing piece of software that affects you personally ("scratch your own itch"). Get in touch with the existing developers (see Communicate with the dev team, below) and they can help you out, by pointing you to the right place in the code and giving advice about how to tackle the problem.

Try not to start by proposing or working on major features or significant design changes. These can be controversial, and the smoothest way to get going is by working on relatively non-controversial bugfixes. Start slowly and build trust!

Here are some other ideas for starting points:

  • Improve awkwardly-worded messages and labels that are written in English. This is a great way for non-programmers to contribute! If you can compile software and have a good grasp of English, you can make a big difference here.
  • Work on Junior Jobs, which are small tasks that are suitable for beginners (both bugs and features).
  • Work on Bugs related to KDE's Usability & Productivity initiative, many of which are small and easy.
  • More easy tasks.

Make your changes and test them

Once you've made some changes, make sure the project still compiles and installs, and make sure the changes have the desired effect when you run the software. Then it's time to run the project's test suite. For example, in KCalc:

cd ~/kde/build/kcalc
source prefix.sh
ctest --output-on-failure

If any test fails, that needs to be investigated and fixed before you can proceed. Once the tests pass, then run the software again to make sure it still behaves properly. If it doesn't, then go back and work on your patch some more, then re-compile and re-deploy, and test again, until the program does what you'd like it to do and all tests pass.

Submitting changes for review

Once you're happy with a patch and have verified that it does what you want, it's time to submit your changes for the review!

KDE uses their own GitLab instance called Invent for submitting merge requests and code review. See the GitLab page to learn how to submit a merge request.

Communicate with the dev team

There are several ways to get in touch with KDE developers, either generally or for a specific project. The most important communications channels are:

These are general KDE development communication channels, and you may get directed to a more appropriate place for the project you are interested in. There is a list of mailing lists if you want to find a mailing list for a specific team directly. Many teams have their own real-time chat channels, too.

You can also try looking for the team's section on the Main Page of this wiki. Many teams have information there for new contributors.

Source code cross referencing

To search for a class, method, signal name... etc in all KDE repos, KDE uses a code referencing tool to index code in the various KDE repositories, you can search using the web interface available at https://lxr.kde.org/ . This is a very useful tool if you e.g. want to search for code usage examples in existing code... etc.

Usage:

  • From the Branch group menu, you can select either kf5-qt5, to search the code in the Git master branches or stable-kf5-qt5 to search only the stable (released) branches
  • There are two search modes:
    • On the Identifier search page, you can search for (note that this is case sensitive):
      • class names, e.g. RenameDialog, StatJob, and of course any Qt class (used in KDE code, which is pretty much all of them), QLatin1String, QListWidget
      • method names, e.g. addConfigSources() (from the KConfig framework) and signal names e.g. mimeTypeFound()
    • on the General search page, you can search for strings, e.g. in Dolphin's context menu (accessed by right- clicking any empty space) there is Paste Clipboard Contents, if you want to find in which source file this string is defined, search for Paste Clipboard Contents; this search includes classes/methods/signals names.

Other ways to search across all of the KDE git repositories:

  • If you have a github.com account. Log into github.com. Go to https://github.com/KDE , in the top left search bar, search for your search term e.g. KMessageBox, select "In this organization".
  • kdesrc-build --src-only will download the source code of more than 300 KDE git repositories in ~/kde/src. Search inside this directory. E.g. using Microsoft Visual Studio Code code ~/kde/src, from the vscode main menu > Edit > Find in Files Ctrl+Shift+F.

Next steps

Sharpen your skills by going through the KDE development tutorials.

After you have had several drama-free patches accepted, a KDE developer is likely to suggest you get a Developer account, which will allow you to commit directly to KDE projects. With very few limits on where you can commit, you will be expected to act responsibly. At this point, congratulations! You are officially a KDE developer!

Best practices & other useful information

Advanced Topics

This page continues with more advanced topics.