KDEConnect/Build Linux: Difference between revisions

From KDE Community Wiki
m (Add `dbus-devel` to Fedora build dependencies)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
== 1. SET UP ENVIRONMENT ==
= Setting up dependencies =


=== Install kdesrc-build ===
On some distros you will need to install some development packages.
kdesrc-build is a tool to allow you to easily build KDE from its source repositories.
Some package managers also feature a command which will automatically fetch the dependencies for you.
If yours does not, you will need to procure the dependencies by yourself,
in which case you can install/ build those yourself.


1. Call the following commands in a Terminal window: -
* '''Ubuntu'''
 
** Go to <code>/etc/apt/source.list</code> and enable the source repositories.
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 kdesrc-build 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. We then clone the source code repository that holds kdesrc-build in that directory, so we have a local copy of it on our computer.
** Run the following commands:
*:
*:<syntaxhighlight lang="bash">
# apt update
# apt-get build-dep kdeconnect
</syntaxhighlight>


<syntaxhighlight lang="bash">
* '''openSUSE'''
mkdir -p ~/kde/src
** Run the following commands:
cd ~/kde/src/
*:
*:<syntaxhighlight lang="bash">
# zypper si -d kdeconnect-kde
</syntaxhighlight>
</syntaxhighlight>


The development version of kdesrc-build is currently recommended, and can be downloaded from KDE's git server by running: -
* '''Arch Linux'''
 
** Run the following commands:
<syntaxhighlight lang="bash">
*:
git clone https://invent.kde.org/sdk/kdesrc-build.git && cd kdesrc-build
*:<syntaxhighlight lang="bash">
# pacman -S kdeconnect
</syntaxhighlight>
</syntaxhighlight>


Next, it's time to set up kdesrc-build and pick up the changes it made to your ~/.bashrc for the current terminal session:
* '''Gentoo'''
 
** Run the following commands:
<syntaxhighlight lang="bash">
*:
./kdesrc-build --initial-setup
*:<syntaxhighlight lang="bash">
source ~/.bashrc
# emerge --ask kdeconnect
</syntaxhighlight>
</syntaxhighlight>
** On Gentoo, you may need to enable pulseaudio and bluetooth USE flags for respective features.


To be sure you are up to speed up to this point, run the following bunch of commands: -
* '''Fedora'''
 
** Run the following commands:
<syntaxhighlight lang="bash">
*:
cd $HOME
*:<syntaxhighlight lang="bash">
kdesrc-build -v
# dnf builddep kde-connect
# dnf install dbus-devel qt5-qtquickcontrols2-devel
</syntaxhighlight>
</syntaxhighlight>


You should get something like the following as output: - <br/>
'''kdesrc-build xx.xx (...)'''


Now you have set up a kdesrc-build installation (the script and its associated modules). Afterwards, you can run...
= Build and install kdeconnect-kde =


<syntaxhighlight lang="bash">
* Next, uninstall the distribution-provided version of kdeconnect before continuing, otherwise, you might end up in a confusing situation
kdesrc-build --metadata-only
where some plugins are being provided by the system-installed version and others are coming from your new build.
* If you want to build KDE Connect yourself, you'll first need to grab the code from git. 
*:<syntaxhighlight lang="bash">
git clone https://invent.kde.org/network/kdeconnect-kde.git
</syntaxhighlight>
</syntaxhighlight>
* Note: if you plan to contribute code to '''KDE Connect''', you're advised to [https://community.kde.org/KDEConnect#Setting_up_KDE_Connect_Repository_for_Development set up your clone for contributing].


to have kdesrc-build download the current information about the KDE source configuration. From there you can try...
* If you intend to develop '''KDE Connect''' or experience a crash and are asked to give a backtrace, build '''KDE Connect''' with debugging symbols. Do this by adding the '''-DCMAKE_BUILD_TYPE=Debug''' flag before the two dots at the end of the '''cmake''' command. For example:
 
*:
<syntaxhighlight lang="bash">
*:<syntaxhighlight lang="bash">
kdesrc-build --pretend
cmake -DCMAKE_INSTALL_PREFIX=~/kde-prefix -DCMAKE_BUILD_TYPE=Debug ..
</syntaxhighlight>
</syntaxhighlight>


== Installing to ~/kde-prefix ==


=== Build kdeconnect-kde from latest source code ===
For development, it is recommended to install to your home directory and test changes using prefix.sh.
This gives a faster development cycle and avoids clobbering your system-installed version with a potentially unstable WIP version.


To build kdeconnect-kde out of the source code, use the following command.: -
# To configure:
 
#:<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
cd kdeconnect-kde
kdesrc-build --include-dependencies kdeconnect-kde
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=~/kde-prefix ..
</syntaxhighlight>
# To build and install:
#:<syntaxhighlight lang="bash">
make -j$(nproc) install
</syntaxhighlight>
# To run an executable, for example, kdeconnectd:
#:<syntaxhighlight lang="bash">
source build/prefix.sh
killall kdeconnectd; ~/kde-prefix/lib64/libexec/kdeconnectd
</syntaxhighlight>
</syntaxhighlight>
 
#: The daemon is in an obscure location. Other executables, such as the SMS app or the settings app, are on the path provided by prefix.sh, and can be found in <code>~/kde-prefix/bin</code>, i.e., for example, to test changes to the SMS app, do:
'''You can find the source code in $HOME/kde/src/kdeconnect-kde with the git history once this command returns.'''
#:<syntaxhighlight lang="bash">
 
source build/prefix.sh
== Test local changes ==
killall kdeconnect-sms; ~/kde-prefix/bin/kdeconnect-sms
 
=== Developer Recommendation ===
 
Add this to your $HOME/.bashrc file: -
 
<syntaxhighlight lang="bash">
## Update shell environment to prefer programs installed by kdesrc-build
 
function source-kdesrc
{
  PS1="\[\033[01;33m\]  ! !  K D E S R C - T E S T - M O D E  ! ! \n$PS1"
  source "$HOME/kde/build/network/kdeconnect-kde/prefix.sh"
  export PATH="$HOME/kde/usr/lib/libexec/:$PATH"
}
</syntaxhighlight>
</syntaxhighlight>


Once this is triggered, the environment will be updated to prefer kdesrc-build versions of any built programs (for eg: kdeconnect-kde). This can be useful for testing applications like kdeconnect-daemon. <br/>
== Installing to / ==
 
If you make changes to some project's source code, update the kdesrc-build version of the project by running the following command: -
 
<syntaxhighlight lang="bash">
kdesrc-build --no-include-dependencies kdeconnect-kde
</syntaxhighlight>


Once the compilation finishes, run the following command to switch the shell environment to testing mode: -
If you want to daily-drive the latest source code of '''KDE Connect''', you can install it to the system.
This is not recommended for day-to-day development since it requires <code>sudo</code> access.


<syntaxhighlight lang="bash">
# To configure:
source-kdesrc
#:<syntaxhighlight lang="bash">
cd kdeconnect-kde
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
</syntaxhighlight>
</syntaxhighlight>
 
# To build and install:
Now, feel free to run any binary from the terminal. Confirm so by using which
#:<syntaxhighlight lang="bash">
 
make
<syntaxhighlight lang="bash">
sudo make install
which kdeconnectd
</syntaxhighlight>
</syntaxhighlight>
You should get something like the following as output: - <br/>
'''/home/XXXXXXXXXX/kde/usr/lib/libexec/kdeconnectd'''
== FREQUENTLY ASKED QUESTIONS ==
We are only human! There are many doubts that we face commonly, during DevSprints and during the onboarding of new contributors. We'd like to expedite this process for you by enlisting all the commonly asked questions in one place so you don't have to ask around like others had to!
'''5. How can I contact the KDE Connect team? I'd like to talk to the team about an issue/ suggestion.'''
* Telegram: You can find a link to our Telegram group [https://community.kde.org/Telegram here].
* IRC on Libera Chat: #kdeconnect
* Mailing List: [https://mail.kde.org/mailman/listinfo/kdeconnect https://mail.kde.org/mailman/listinfo/kdeconnect]
* email ID: [email protected]




''Be sure to tell us if you got stuck somewhere in the process of setting up the developer environment. You can [mailto:[email protected] mail us.] Yes we read and reply to the mails!''
* '''NOTE''': If you install KDE Connect in a custom location, you'll need to run <code>kdeconnectd</code> manually, since DBus doesn't know about it.

Latest revision as of 02:40, 23 August 2023

Setting up dependencies

On some distros you will need to install some development packages. Some package managers also feature a command which will automatically fetch the dependencies for you. If yours does not, you will need to procure the dependencies by yourself, in which case you can install/ build those yourself.

  • Ubuntu
    • Go to /etc/apt/source.list and enable the source repositories.
    • Run the following commands:
    # apt update
    # apt-get build-dep kdeconnect
    
  • openSUSE
    • Run the following commands:
    # zypper si -d kdeconnect-kde
    
  • Arch Linux
    • Run the following commands:
    # pacman -S kdeconnect
    
  • Gentoo
    • Run the following commands:
    # emerge --ask kdeconnect
    
    • On Gentoo, you may need to enable pulseaudio and bluetooth USE flags for respective features.
  • Fedora
    • Run the following commands:
    # dnf builddep kde-connect
    # dnf install dbus-devel qt5-qtquickcontrols2-devel
    


Build and install kdeconnect-kde

  • Next, uninstall the distribution-provided version of kdeconnect before continuing, otherwise, you might end up in a confusing situation

where some plugins are being provided by the system-installed version and others are coming from your new build.

  • If you want to build KDE Connect yourself, you'll first need to grab the code from git.
    git clone https://invent.kde.org/network/kdeconnect-kde.git
    
  • Note: if you plan to contribute code to KDE Connect, you're advised to set up your clone for contributing.
  • If you intend to develop KDE Connect or experience a crash and are asked to give a backtrace, build KDE Connect with debugging symbols. Do this by adding the -DCMAKE_BUILD_TYPE=Debug flag before the two dots at the end of the cmake command. For example:
    cmake -DCMAKE_INSTALL_PREFIX=~/kde-prefix -DCMAKE_BUILD_TYPE=Debug ..
    

Installing to ~/kde-prefix

For development, it is recommended to install to your home directory and test changes using prefix.sh. This gives a faster development cycle and avoids clobbering your system-installed version with a potentially unstable WIP version.

  1. To configure:
    cd kdeconnect-kde
    mkdir build
    cd build
    cmake -DCMAKE_INSTALL_PREFIX=~/kde-prefix ..
    
  2. To build and install:
    make -j$(nproc) install
    
  3. To run an executable, for example, kdeconnectd:
    source build/prefix.sh
    killall kdeconnectd; ~/kde-prefix/lib64/libexec/kdeconnectd
    
    The daemon is in an obscure location. Other executables, such as the SMS app or the settings app, are on the path provided by prefix.sh, and can be found in ~/kde-prefix/bin, i.e., for example, to test changes to the SMS app, do:
    source build/prefix.sh
    killall kdeconnect-sms; ~/kde-prefix/bin/kdeconnect-sms
    

Installing to /

If you want to daily-drive the latest source code of KDE Connect, you can install it to the system. This is not recommended for day-to-day development since it requires sudo access.

  1. To configure:
    cd kdeconnect-kde
    mkdir build
    cd build
    cmake -DCMAKE_INSTALL_PREFIX=/usr ..
    
  2. To build and install:
    make
    sudo make install
    


  • NOTE: If you install KDE Connect in a custom location, you'll need to run kdeconnectd manually, since DBus doesn't know about it.