İçeriğe atla

Yap


Building Kate from Sources on Linux

Şu anda Kate'in kaynak kodu invent.kde.org GitLab örneğinde bulunuyor. Bu öğretici, Kate'in genel kurulumunuza dokunmadan nasıl yapılacağını açıklar.

Her şey dış bir geliştirme dizininde gerçekleşecek. Bu, yönetici haklarına olan gereksinimi ortadan kaldırır ve kullanılabilir derleme sürümü bozuksa her zaman global olarak kurulu Kate'i kullanmak için geri dönüş yapılmasına olanak tanır.

Bu öğreticide KDE yazılım yığınının diğer bölümlerinin de geliştirilmesine olanak tanıyan bir kurulum tanıtılacağından, aşağıda bir KDE geliştirme ortamı kurma hakkında konuşacağız. Kate uygulama bölümlerine ek olarak gerekli KDE Frameworks de derlenecektir. Bu, KDE yazılım yığınının tüm düzeylerine katkıyı kolaylaştırır.

Kate ve KDE geliştirme dizininizi seçin

Kendinize tüm Kate ve KDE geliştirme işlerinin koyulacağı bir yol seçin. Kullanıcı yerel yapılandırma dosyalarının yanı sıra, bu dizinin dışındaki hiçbir şey kirlenmeyecektir. Bunu KDE yazılım yığınının herhangi bir bölümünde geliştirme amacıyla yeniden kullanabilirsiniz.

Bu açıklamanın geri kalan kısımları için şunu kullanıyoruz

~/projects/kde

Bunu istediğiniz gibi özelleştirebilirsiniz.

Install kdesrc-build

Kurulum yalnızca güncel sürümü klonlamaktan ibarettir

mkdir -p ~/projects/kde/src
cd ~/projects/kde/src
git clone https://invent.kde.org/sdk/kdesrc-build.git

For later ease of use, best symlink the kdesrc-build script to some folder inside your path, e.g. if you have some user local bin:

ln -s ~/projects/kde/src/kdesrc-build/kdesrc-build ~/bin

Configuring kdesrc-build

kdesrc-build has some setup pass that can configure stuff for you, see this introduction.

Burada, Kate geliştirme gereksinimlerinize yeterli olması gereken bir ~/.config/kdesrc-buildrc gösteriyoruz.

Aşağıdaki varyantı ana klasörünüze ~/.config/kdesrc-buildrc olarak kopyalayıp yapıştırabilir ve yollarınızı gereksinimlerinize göre ayarlayabilirsiniz. Yukarıda yaptığımız gibi ~/projects/kde seçtiyseniz bu da bire bir çalışır.

global
    # use the latest KF6 and Qt6-based software.
    branch-group kf6-qt6

    # we want .kateproject files with ninja, turn off some Qt 5 things to have less dependencies
    cmake-options -G "Kate - Ninja" -DBUILD_WITH_QT6=ON -DQT_MAJOR_VERSION=6 -DPHONON_BUILD_QT5=OFF -DBUILD_QT5=OFF

    # clangd tooling
    compile-commands-export yes
    compile-commands-linking yes

    # flat structure
    directory-layout flat

    # Install directory for KDE software
    install-dir ~/projects/kde/usr

    # Directory for downloaded source code
    source-dir ~/projects/kde/src

    # Directory to build KDE into before installing relative to source-dir by default
    build-dir ~/projects/kde/build
end global

include ${module-definitions-dir}/kf6-qt6.ksb

Kate'i (veya diğer KDE şeylerini) Kate ile geliştirirken iyi bir deneyime sahip olmanın önemli noktaları aşağıda ayrıntılı olarak açıklanmaktadır.

.kateproject dosyaları oluşturun

# we want .kateproject files with ninja
cmake-options -G "Kate - Ninja"

This ensures you get not only Ninja build files (nifty as this will e.g. automatically use multiple cores for compiles) but in addition .kateproject files inside the build directories for later use, too. With these files, the project plugin of Kate will know what to do, e.g. where the source directory for the compile is and which build commands it should use for the build plugin.

LSP tümleştirmesiin çalıştığından emin olun

# clangd tooling
compile-commands-export yes
compile-commands-linking yes

This ensures CMake will generate the compile_commands.json files that are required for clangd based LSP integration. Beside just generating them inside the build directory the linking option will symlink them back to your source directories. This allows zero-configuration usage of the LSP plugin inside Kate (and other editors).

Install needed dependencies (optional)

kdesrc-build provides some initial setup mode to install the needed packages for several common distributions to start developing. This is helpful if you are not sure if all needed development packages are installed on your system and you don't want to take care of this yourself manually. As this will try to install packages for your distribution, this step will require administrator rights for the package installation. To do that, just trigger:

kdesrc-build --initial-setup

We already created a .config/kdesrc-buildrc, that will be left untouched. For the further usage you don't need to modify your shell settings either.

Build Kate & dependencies

To trigger a compile of Kate and all needed KDE dependencies now just type:

kdesrc-build --include-dependencies kate

That takes a few minutes on a recent machine. Time to grab some coffee or think about what you actually want to implement.

As long as the KF 6 version of our dependencies is not bundled with your distribution, it might make sense to build some more parts to have better styling and a terminal integration:

kdesrc-build --include-dependencies breeze plasma-integration kwayland-integration konsole kate

If you only want to build Kate without the dependencies because you are sure you have recent enough stuff on your system, you can try:

kdesrc-build --no-include-dependencies kate

But given that on modern machines, the compile times are low, it is more convenient to just build all stuff, that ensures you have e.g. the latest and best KSyntaxHighlighting and KTextEditor frameworks around, too!

Given this setup, you are free to build all KDE software parts with a simple:

kdesrc-build

Keep in mind: that will take some time (and disk space).

If during the build you see any failures displayed with a red font, follow this guide - How to solve build problems

How to use the build stuff?

To launch you local Kate version, you need to setup the environment first properly to ensure the right plugins and stuff is loaded. Fortunately this is very simple:

source ~/projects/kde/build/kate/prefix.sh
kate

A nifty way to wrap this is to e.g. create yourself a small wrapper script to start your master branch version of Kate inside your local bin directory:

#!/bin/bash
source ~/projects/kde/build/kate/prefix.sh
exec kate "$@"

Keep your stuff up-to-date

To keep your local version up-to-date, you can just use the above commands again. They will take care of pulling new changes from the KDE repositories and building/installing them into your local prefix.

Develop!

Now, the remaining question is: How to develop best?

Naturally, if you want to hack on Kate, it might make sense to use Kate for that.

Given the above preparations, that is easy to do, just start your new master version of Kate and pass it the build directory:

kate ~/projects/kde/build/kate

Alternatively, you can navigate there in your terminal and startup Kate from there, it will auto-open it:

cd ~/projects/kde/build/kate
kate

To have the best experience with this, ensure you have at least project & LSP plugin enabled. If you like to have some GUI build integration, activate the build plugin, too.

You will end up with a new Kate windows like shown below.

In the lower "Current Project" tool view you have per default two terminals. The first terminal is inside your build directory, here you can e.g. run your ninja and ninja install commands and such. The second terminal is inside your source directory, perfect for e.g. git command line calls.

Given the above setup, the LSP plugin (if you have clangd installed) should work out of the box.

Other nifty stuff like project wide quick open, search & replace and correct build targets should be setup, too.

Contribute back!

Feel free to create a merge request at invent.kde.org. For more information see Join Us.

Get Support?

If you have questions you can ask them on our mailing list kwrite-devel@kde.org and/or join #kate on irc.libera.chat.

For more information see Get Help.

Building Kate from Sources on Windows

To build the KF5 based Kate/KWrite you can follow the guide on KDE on Windows.

Building Kate from Sources on macOS

To build the KF5 based Kate/KWrite you can follow the guide on KDE on macOS.