Get Involved/development: Difference between revisions

From KDE Community Wiki
(The problem might be in ~/kde/usr)
(→‎Next steps: GitLab forks)
 
(117 intermediate revisions by 16 users not shown)
Line 1: Line 1:
[[File:Mascot konqi-app-dev.png|right|x250px|]]
[[File:Mascot konqi-app-dev.png|right|x250px|]]
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.
By joining the ranks of KDE developers, you will get to implement new features and defeat bugs both daunting and simple. Developers collaborate in teams based on what area they are working on. These can be small teams working on a single application, up to large teams working on a group of related pieces of software, or even meta-teams working on broader topics such as QA or automation. Many developers participate 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.
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.


{{Info|While any operating system can be used to patch or develop KDE software, it's easiest if you use a Linux distribution that provides relatively recent versions of Qt and KDE Frameworks, such as Arch/Manjaro, Fedora, KDE Neon, openSUSE Tumbleweed, or non-LTS versions of Kubuntu.<br /><br />Support for Windows, macOS, and Linux distros that ship older software (such as Debian, Ubuntu/Kubuntu 18.04, and openSUSE Leap 15) is still experimental, and you may have a better experience [[Get Involved/development/Developing in a virtual machine|doing your development in a virtual machine]] when using one of the distributions mentioned above.}}
== Where to find the development team ==


== New to C++/Qt software development? ==
The KDE developers are here to assist you if you need any help following this guide.
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.


If you'd like to dive deeper, the Qt wiki contains [https://wiki.qt.io/Books a list of online books] for learning Qt programming. Qt also provides [https://doc.qt.io/qt-5/qtexamplesandtutorials.html lots of examples] you can look at. For visual learners, [https://www.youtube.com/watch?v=JxyTkXLbcV4&list=PL6CJYn40gN6hdNC1IGQZfVI707dh9DPRc this YouTube playlist of QML tutorials] by KDE patron [https://www.kdab.com KDAB] may be useful. Finally, information about KDE Frameworks can be found on the [https://develop.kde.org/docs KDE Developer Platform] and [https://api.kde.org/ KDE API website].
There are several ways to get in touch with KDE developers, either generally or for a specific project. The most important communication channels are:
* '''Real-time chat:''' [irc://irc.libera.chat/kde-devel #kde-devel] room on the [http://libera.chat/ Libera Chat] IRC network (which is mirrored to the [https://webchat.kde.org/#/room/#kde-devel:kde.org #kde-devel] room on [[Matrix]])
* '''Forum:''' [https://discuss.kde.org/c/development/10 Development forum] on discuss.kde.org
* '''Mailing list:''' [https://mail.kde.org/mailman/listinfo/kde-devel kde-devel] ([http://kde.org/support/#mailinglists Learn more about mailing lists])


[[Get_Involved/development/Learn|More learning resources]].
These are general KDE development communication channels, and you may be directed to a more appropriate place for the project you're interested in.


== One-time setup: your development environment ==
* Many projects and teams have their own real-time chat channels, which can be found on the [[Matrix#Rooms|Matrix Rooms]] page.
Source code for KDE software lives at https://invent.kde.org. 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 Konsole (but any terminal program will suffice).
* There is a [http://www.kde.org/mailinglists/ list of mailing lists] if you want to find a mailing list for a specific team directly.


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!
The [[Main Page]] of this wiki includes links to specific development teams and the [[Get Involved]] page includes links to more general contribution teams.


{{Note|'''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!
== Prerequisites ==
If not done yet, better to create an account into gitlab instance and fork from your own repo there to make easier to send contributions: [[Infrastructure/GitLab]]
}}


{{Note|As an alternative to the set-up process described here, you can install Docker and the [[KDE PIM/Docker|KDE PIM Docker image]].  It provides a development environment that is isolated from your day-to-day system.  However, it is based on KDE Neon Unstable, which might not be to your taste.}}
=== Skills ===


=== Video version ===
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 improving text labels.


If you are a visual learner, you might consider watching the video version at https://www.youtube.com/embed/B4xoc0K5iA4
If you'd like to dive deeper, the Qt wiki contains [https://wiki.qt.io/Books a list of online books] for learning Qt programming. Qt also provides [https://doc.qt.io/qt-5/qtexamplesandtutorials.html lots of examples] you can look at. For visual learners, [https://www.youtube.com/watch?v=JxyTkXLbcV4&list=PL6CJYn40gN6hdNC1IGQZfVI707dh9DPRc this YouTube playlist of QML tutorials] by KDE patron [https://www.kdab.com KDAB] may be useful. Finally, information about KDE Frameworks can be found on the [https://develop.kde.org/docs KDE Developer Platform] and [https://api.kde.org/ KDE API website]. We also provide a [[Get_Involved/development/Learn|wiki page full of learning resources]].


[[Get_Involved/development/Video|More video versions]].
=== Operating system ===


=== Install basic tools ===
For KDE development, we recommend a Linux operating system installed on your computer or in a [[/Developing_in_a_virtual_machine|virtual machine]]. The ones best suited for development provide relatively recent versions of libraries needed by KDE software, and use the "[https://en.wikipedia.org/wiki/Rolling_release rolling release]" model. Some examples are Arch Linux, openSUSE Tumbleweed, Solus and KDE neon User Edition. The latest version of Fedora KDE usually works as well.
First you will need to use your operating system's package manager to install some basic tools:
* 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</code>
* KDE Neon/Kubuntu/Ubuntu/Debian: <code>sudo apt install git cmake dialog</code>
* openSUSE Leap & Tumbleweed: <code>sudo zypper install git breezy cmake dialog</code>
<br />


=== Configure Git ===
We recommend that you use the KDE Plasma desktop on your Linux operating system.
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 "you@email.com"
</nowiki>}}


{{Note|The name you provide should be your actual name, not your KDE Identity username.
Support for Windows and macOS are still experimental, and you may 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.
<nowiki>


</nowiki>
== The main way to develop KDE software: kde-builder ==
The email address you specify above 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).}}
<br />
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 kdesrc-build ===
KDE uses a custom tool called '''kde-builder''' for setting up a development environment and building KDE software. You only need to set up your environment once, and then you can compile (and recompile) KDE software as often as needed.
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.


Most Linux-based operating systems do not provide development packages that are up-to-date enough for working on KDE software, so we will compile all the KDE dependencies ourselves. To do this, we use a command-line tool called <code>kdesrc-build</code> to download, manage, and build KDE source code 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. We then clone the source code repository that holds <code>kdesrc-build</code> in that directory, so we have a local copy of it on our computer.
Setting up your environment on a Linux machine is fairly simple. You'll need to install a few programs to get started.


{{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:
{{CenteredButtonExt|text=Set up a development environment with kde-builder|link=https://develop.kde.org/docs/getting-started/building/kde-builder-setup/}}


{{Input|1=<nowiki>
./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".
Once you have a development environment set up, you'll be able to compile single applications or entire software stacks with kde-builder. One particular use that kde-builder makes convenient is compiling a full KDE Plasma session so you can dive into it.
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.
{{CenteredButtonExt|text=Start compiling KDE software using kde-builder|link=https://develop.kde.org/docs/getting-started/building/kde-builder-compile/}}
{{Input|1=<nowiki>
autoload -U +X compinit && compinit
autoload -U +X bashcompinit && bashcompinit
</nowiki>}}
}}


The initial setup tries to install the packages, from your Linux/BSD distribution, that are needed for compiling Qt and KDE software. It also creates a <code>~/.config/kdesrc-buildrc</code> configuration file.
If you want a more guided setup process for <code>kdesrc-build</code>, run the command <code>kdesrc-build-setup</code> instead. However, unlike <code>--initial-setup</code>, it won't install packages from your distro for compiling programs so you will have to do that yourself.


Consult the [https://docs.kde.org/trunk5/en/kdesrc-build/kdesrc-build/ kdesrc-build manual] and [https://invent.kde.org/sdk/kdesrc-build/-/blob/master/README.md 1], [https://invent.kde.org/sdk/kdesrc-build/-/blob/master/doc/README.md 2], [https://invent.kde.org/sdk/kdesrc-build/-/blob/master/doc/source-reference/index.adoc 3] for more information and options.
Once you've made some changes to a piece of KDE software, you'll need to submit those changes to KDE for inclusion in the next release. We use a GitLab instance hosted at invent.kde.org, which has a web interface to manage source code submissions (called "Merge Requests"), and this can be done from the terminal as well.


=== Set up Qt ===
{{CenteredButton|text=Submit your new software changes for review|link=Infrastructure/GitLab#Submitting_a_merge_request}}
By default, <code>kdesrc-build</code> will not build from source the Qt5 framework (i.e. "module-set qt5-set").


If your Linux distribution provides a recent version of Qt (5.15 or newer), you can save some time and disk space and use that version instead of building your own. To configure <code>kdesrc-build</code> to skip building Qt, open the configuration file <code>~/.config/kdesrc-buildrc</code> and confirm that <code>qtdir</code> and the lines <code>include...qt5-build-include</code> and <code>include...custom-qt5-libs-build-include</code> are commented out, and confirm the line that includes <code>kf5-qt5-build-include</code> has not been commented out.


For example, comment/disable (put a <code>#</code> at the start of the line) or delete these lines if you want to use your distro's Qt packages (actual paths may vary):
Once you've got kde-builder set up, you might also want to configure an IDE of your choice for a more convenient workflow. This is optional.


{{Input|1=<nowiki>
qtdir  ~/kde/qt5 # Where to find Qt5
include /path/to/kdesrc-build/qt5-build-include
include /path/to/kdesrc-build/custom-qt5-libs-build-include
</nowiki>}}


=== Disable indexing for your development environment ===
{{CenteredButtonExt|text=Configure the Integrated Development Environment|link=https://develop.kde.org/docs/getting-started/building/ide/}}
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 ===
Once you've finished learning how to use kde-builder, you might see yourself having certain needs, such as managing different branch groups or having separate builds of KDE software based on Qt6 and Qt5. Those topics are covered in the advanced section. This section is optional.
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 and can optionally be used to also build all of the required Qt modules. The rest of the dependencies are acquired using the distribution's package manager. To install the required non-KDE dependencies that <code>kdesrc-build --initial-setup</code> could not install, [[Guidelines and HOWTOs/Build from source/Install the dependencies|read this page]] and follow the instructions laid out there.


'''Reboot your computer''' and log back in so the package changes, and the changed ~/.bashrc take effect on your user account.
{{CenteredButton|text=Advanced kde-builder features and troubleshooting|link=Get_Involved/development/More}}


Once that's done, your development environment is set up and ready to build software! Let's take it for a spin.
== 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 [[#Where to find the development team|Where to find the development 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.
== 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>.
 
=== Applications ===
'''[https://apps.kde.org/ KDE Applications]''' like [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 Dolphin as an example:
 
{{Input|1=<nowiki>
kdesrc-build dolphin
</nowiki>}}
 
As a part of this process, Dolphin was installed to <code>~/kde/usr/bin/dolphin</code>. '''There is no need to manually install anything;''' <code>kdesrc-build</code> installed it for you! Source the project's auto-generated <code>prefix.sh</code> file every time you want to run your custom-compiled version of Dolphin:
 
{{Input|1=<nowiki>
source ~/kde/build/dolphin/prefix.sh
~/kde/usr/bin/dolphin
</nowiki>}}
 
Or using <code>kdesrc-run</code> wrapper:
{{Input|1=<nowiki>
kdesrc-run dolphin
</nowiki>}}
 
Did it run? If so, then '''congratulations, you just compiled your own version of Dolphin from source 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 frameworks can be found here: https://api.kde.org/frameworks.
 
For example, here is how to build the KIO framework:
 
{{Input|1=<nowiki>
kdesrc-build kio
</nowiki>}}
 
Now you can run an existing app using your custom-made version of the framework! For example, the following will run Dolphin, but it will be using the KIO library that you just built:
 
{{Input|1=<nowiki>
source ~/kde/build/kio/prefix.sh
~/kde/usr/bin/dolphin
</nowiki>}}
 
=== 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, 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 kaccounts-integration kaccounts-providers kdeconnect-kde plasma-browser-integration xdg-desktop-portal-kde kde-gtk-config khotkeys kgamma5 breeze-gtk drkonqi phonon --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 it off if you are using a distro that ships with it on by default (for example, Fedora). See https://www.tecmint.com/disable-selinux-in-centos-rhel-fedora/ for more information.}}
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 a phone-sized window within your existing session like so:
 
{{Input|1=<nowiki>
export XDG_RUNTIME_DIR=/tmp/
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>}}
 
Plasma Mobile can also be run on a mobile device itself. For information on how to do that, see https://community.kde.org/Plasma/Mobile/DevGuide#Mobile_device_running_plasma_mobile.
 
For more information, see https://community.kde.org/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>.
 
=== 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.
 
== Choose what to do ==
Now that you can compile and deploy custom versions of KDE software, you can open your editor and start hacking on the source code! The code for the version of Dolphin that you built earlier is located at <code>~/kde/src/dolphin/</code>; other projects you build with <code>kdesrc-build</code> will live in similar locations.
 
You may wish to look over the [[Get_Involved/development/IDE_configuration|instructions for setting up an Integrated Development Environment (IDE)]] for development with KDE projects.
 
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 241: Line 75:


* 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.
* 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 [https://bugs.kde.org/buglist.cgi?bug_status=UNCONFIRMED&bug_status=CONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&keywords=junior-jobs&list_id=1340815 Junior Jobs], which are small tasks that are suitable for beginners (both bugs and features).
* Work on Junior Jobs, which are small tasks that are suitable for beginners (both bugs and features). You can find them available both on [https://bugs.kde.org/buglist.cgi?bug_status=UNCONFIRMED&bug_status=CONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&keywords=junior-jobs&list_id=1340815 Bugzilla] and [https://invent.kde.org/dashboard/issues?sort=created_date&state=opened&label_name%5B%5D=Junior+Job Gitlab].
* Work on [https://bugs.kde.org/buglist.cgi?bug_status=UNCONFIRMED&bug_status=CONFIRMED&bug_status=ASSIGNED&bug_status=REOPENED&keywords=usability&keywords_type=allwords&list_id=1493316&order=product%2Cchangeddate%20DESC%2Cbug_status%20DESC%2Cresolution%2Cpriority%2Cassigned_to%2Cbug_id&query_format=advanced Bugs related to] KDE's [[Goals/Usability_%26_Productivity | Usability & Productivity initiative]], many of which are small and easy.
* Work on [https://bugs.kde.org/buglist.cgi?bug_status=UNCONFIRMED&bug_status=CONFIRMED&bug_status=ASSIGNED&bug_status=REOPENED&keywords=usability&keywords_type=allwords&list_id=1493316&order=product%2Cchangeddate%20DESC%2Cbug_status%20DESC%2Cresolution%2Cpriority%2Cassigned_to%2Cbug_id&query_format=advanced Bugs related to] KDE's [[Goals/Usability_%26_Productivity | Usability & Productivity initiative]], many of which are small and easy.
* [[Get_Involved/development/Easy|More easy tasks]].
* Write [[App ideas|small useful apps]].
 
== Test your changes ==
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 unit tests:
 
{{Input|1=<nowiki>
cd ~/kde/build/dolphin/
source ./prefix.sh
ctest --output-on-failure
</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.
== Source code cross-referencing ==


== Submit a Merge Request ==
To search for an identifier (e.g. class name, method name, signal name) or for free-text search in all KDE git repositories, KDE provides a code referencing tool 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.
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 [https://invent.kde.org GitLab] for merge request submission and review. [[Infrastructure/GitLab#Submitting_a_Merge_Request|Learn how to submit a Merge Request with GitLab]].
 
== Communicate with the 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:
* 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://mail.kde.org/mailman/listinfo/kde-devel kde-devel mailing list] is the primary development mailing list. [http://kde.org/support/#mailinglists Learn more about mailing lists].
 
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 [http://www.kde.org/mailinglists/ 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:
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
* From the '''Branch group''' menu, you can select either '''kf6-qt6''', to search the code in the Git ''master'' branches or '''stable-kf6-qt6''' to search only the stable (released) branches.
* There are two search ''modes'':
* There are two search ''modes'':
** On the '''Identifier search''' page, you can search for (note that this is case sensitive):
** 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''
*** 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()''
*** 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.
** 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.


== Microsoft Windows ==
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 , at the top of the page in the search bar ("Type / to search"), write your search term e.g. <code>KMessageBox</code>, select "In this organization". In order to search case sensitive and whole words, you can use case sensitive regex e.g. <code>org:KDE /(?-i)\bKMessageBox\b/</code>.
* <code>kde-builder --src-only</code> will download the source code of more than 300 KDE git repositories in <code>~/kde/src</code>. Search inside this directory. E.g. using Microsoft Visual Studio Code, from a terminal run the command line <code>code ~/kde/src</code>, from the vscode main menu > Edit > Find in Files Ctrl+Shift+F.


You can build and develop KDE projects using the [[Get_Involved/development/Windows|Microsoft Windows]] operating system.
== Next steps ==
Sharpen your skills by going through the [https://develop.kde.org/docs/ KDE development tutorials].


== Apple macOS ==
After you have had several drama-free patches accepted, a KDE developer is likely to suggest you get a [[Infrastructure/Get a Developer Account|Developer account]], which will allow you to do git commits directly to KDE projects without the need of GitLab forks. 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!


You can build and develop KDE projects using the [[Get_Involved/development/Mac|Apple macOS]] operating system.
== Best practices & other useful information ==


== Integrated Development Environment (IDE) configuration ==
* [[Get Involved/Design/Frequently Discussed Topics|Frequently discussed topics and lessons learned regarding the development of user-facing GUI software]]
 
Set 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.
 
== Next steps ==
Sharpen your skills by going through the [https://techbase.kde.org/Development/Tutorials KDE development tutorials].
 
After you have had several drama-free patches accepted, a KDE developer is likely to suggest you get a [[Infrastructure/Get a Developer Account|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==
* [[Get Involved/Design/Lessons Learned|Lessons learned over time regarding the development of user-facing software]]
* [[Guidelines_and_HOWTOs/Debugging|Debugging]]
* [[Guidelines_and_HOWTOs/Debugging|Debugging]]
* [[Guidelines and HOWTOs/UnitTests|Unit testing]]
* [[Guidelines and HOWTOs/UnitTests|Unit testing]]
Line 306: Line 109:
* [[Guidelines and HOWTOs/Licensing|Correctly state license information]]
* [[Guidelines and HOWTOs/Licensing|Correctly state license information]]
* [[Guidelines_and_HOWTOs/Wayland_Porting_Notes|Writing Wayland-friendly code]]
* [[Guidelines_and_HOWTOs/Wayland_Porting_Notes|Writing Wayland-friendly code]]
* [[Frameworks/Porting_Notes|Porting from KDE 4 to Frameworks 5]]
* [[Guidelines_and_HOWTOs/Making_apps_run_uninstalled|Running applications and their unit tests without first installing them]]
* [[Guidelines_and_HOWTOs/Making_apps_run_uninstalled|Running applications and their unit tests without first installing them]]
* [https://community.kde.org/Infrastructure/GitLab#Testing_someone_else.27s_Merge_Request How to review merge requests]
* [[Infrastructure/GitLab#Testing_someone_else's_merge_request|How to review merge requests]]
* [https://github.com/Wenzel/docker-kdesrc-build How to build with Docker]
 
== Advanced Topics ==
 
This page continues with [[Get_Involved/development/More|more advanced topics]].

Latest revision as of 18:21, 26 October 2024

By joining the ranks of KDE developers, you will get to implement new features and defeat bugs both daunting and simple. Developers collaborate in teams based on what area they are working on. These can be small teams working on a single application, up to large teams working on a group of related pieces of software, or even meta-teams working on broader topics such as QA or automation. Many developers participate 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.

Where to find the development team

The KDE developers are here to assist you if you need any help following this guide.

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

These are general KDE development communication channels, and you may be directed to a more appropriate place for the project you're interested in.

  • Many projects and teams have their own real-time chat channels, which can be found on the Matrix Rooms page.
  • There is a list of mailing lists if you want to find a mailing list for a specific team directly.

The Main Page of this wiki includes links to specific development teams and the Get Involved page includes links to more general contribution teams.

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 improving 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. We also provide a wiki page full of learning resources.

Operating system

For KDE development, we recommend a Linux operating system installed on your computer or in a virtual machine. The ones best suited for development provide relatively recent versions of libraries needed by KDE software, and use the "rolling release" model. Some examples are Arch Linux, openSUSE Tumbleweed, Solus and KDE neon User Edition. The latest version of Fedora KDE usually works as well.

We recommend that you use the KDE Plasma desktop on your Linux operating system.

Support for Windows and macOS are still experimental, and you may 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.

The main way to develop KDE software: kde-builder

KDE uses a custom tool called kde-builder for setting up a development environment and building KDE software. You only need to set up your environment once, and then you can compile (and recompile) KDE software as often as needed.

Setting up your environment on a Linux machine is fairly simple. You'll need to install a few programs to get started.



Once you have a development environment set up, you'll be able to compile single applications or entire software stacks with kde-builder. One particular use that kde-builder makes convenient is compiling a full KDE Plasma session so you can dive into it.



Once you've made some changes to a piece of KDE software, you'll need to submit those changes to KDE for inclusion in the next release. We use a GitLab instance hosted at invent.kde.org, which has a web interface to manage source code submissions (called "Merge Requests"), and this can be done from the terminal as well.


Once you've got kde-builder set up, you might also want to configure an IDE of your choice for a more convenient workflow. This is optional.



Once you've finished learning how to use kde-builder, you might see yourself having certain needs, such as managing different branch groups or having separate builds of KDE software based on Qt6 and Qt5. Those topics are covered in the advanced section. This section is optional.

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 Where to find the development 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). You can find them available both on Bugzilla and Gitlab.
  • Work on Bugs related to KDE's Usability & Productivity initiative, many of which are small and easy.
  • Write small useful apps.

Source code cross-referencing

To search for an identifier (e.g. class name, method name, signal name) or for free-text search in all KDE git repositories, KDE provides a code referencing tool 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.

Usage:

  • From the Branch group menu, you can select either kf6-qt6, to search the code in the Git master branches or stable-kf6-qt6 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 , at the top of the page in the search bar ("Type / to search"), write your search term e.g. KMessageBox, select "In this organization". In order to search case sensitive and whole words, you can use case sensitive regex e.g. org:KDE /(?-i)\bKMessageBox\b/.
  • kde-builder --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, from a terminal run the command line 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 do git commits directly to KDE projects without the need of GitLab forks. 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.