Skip to content

Cross compiling GammaRay

Allen Winter edited this page Jul 22, 2023 · 4 revisions

Cross-compiling manually

When using GammaRay on an embedded target, you need two builds of it, a regular one on your desktop machine for the GammaRay client, and one for the target platform with the GammaRay probe.

GammaRay can be cross-compiled using the normal cross-compilation mechanism of CMake, ie. passing CMake a toolchain file. The GammaRay source code contains a number of example toolchain files for Linux (RPI, iMX6), QNX (6.5, 6.6) and Android you can use or adjust.

The toolchain file is passed to CMake using the -DCMAKE_TOOLCHAIN_FILE command line option. Note that this only works on the very first CMake run, CMake doesn't like changing the toolchain file on an existing build directory. In that case, make sure to wipe the entire build directory first (just deleting CMakeCache.txt is not enough!).

Additionally you might need to pass one or more -DCMAKE_PREFIX_PATH=... command line options to point CMake to the location your sysroot has Qt (or any other dependency) installed in, just as during desktop builds.

A default build of GammaRay includes both the client and the probe, for cross-compiling you normally only want the probe, which can be achieved by setting the CMake option GAMMARAY_BUILD_UI to off.

Here's an example CMake invocation for building for RaspberryPI:

export SYSROOT=/where/your/rpi/sysroot/is/located
export PATH=<toolchain>:$PATH

cd <builddir>
cmake -DCMAKE_TOOLCHAIN_FILE=<srcdir>/cmake/Toolchain-RPI.cmake  -DCMAKE_PREFIX_PATH=$SYSROOT/usr/local/Qt-5.5.1 -DCMAKE_INSTALL_PREFIX=$SYSROOT/usr/ -DGAMMARAY_BUILD_UI=OFF

Embedded Linux

There are build receipts for some popular embedded Linux build systems that simplify the process of adding the GammaRay probe to your device image. Note that these might need adjustments to your specific setup, like adding the correct dependencies for your specific Qt configuration.

Yocto

gammaray_git.bb (Qt5):

SUMMARY = "GammaRay Qt introspection probe"
HOMEPAGE = "https://www.kdab.com/gammaray"

LICENSE = "GPL-2.0-or-later"
LIC_FILES_CHKSUM = "file://LICENSES/GPL-2.0-or-later.txt;md5=3d26203303a722dedc6bf909d95ba815"

inherit cmake_qt5

SRC_URI = "git://github.com/KDAB/GammaRay;branch=master"

SRCREV = "1728dff87163c370fa6903a6d739d1a132b4c62f"
PV = "2.7.0+git${SRCPV}"

DEPENDS = "qtdeclarative"

S = "${WORKDIR}/git"

EXTRA_OECMAKE += " -DGAMMARAY_BUILD_UI=OFF"

FILES_${PN}-dev += " \
    /usr/lib/cmake/* \
    /usr/mkspecs/modules/* \
"
FILES_${PN}-dbg += " \
    /usr/lib/.debug/* \
    /usr/lib/gammaray/*/*/.debug \
    /usr/lib/gammaray/*/*/styles/.debug \
"

gammaray_git_cmake6.bb (Qt6):

SUMMARY = "GammaRay Qt introspection probe"
HOMEPAGE = "https://www.kdab.com/gammaray"

LICENSE = "GPL-2.0-or-later"
LIC_FILES_CHKSUM = "file://LICENSES/GPL-2.0-or-later.txt;md5=3d26203303a722dedc6bf909d95ba815"

inherit qt6-cmake

SRC_URI = "git://github.com/KDAB/GammaRay;branch=master"

SRCREV = "29dc942640d1666f6f11c13fa77d574ed004a450"

PV = "master_${SRCPV}"

DEPENDS = "qtdeclarative qtdeclarative-native"

S = "${WORKDIR}/git"

EXTRA_OECMAKE += " -DGAMMARAY_BUILD_UI=OFF -DQT_VERSION_MAJOR=6"

FILES_${PN} += "/usr/share/zsh/site-functions/_gammaray"

FILES_${PN}-dev += " \
    /usr/lib/cmake/* \
    /usr/mkspecs/modules/* \
"
FILES_${PN}-dbg += " \
    /usr/lib/.debug/* \
    /usr/lib/gammaray/*/*/.debug \
    /usr/lib/gammaray/*/*/styles/.debug \
"

The lines you probably want to adjust are:

  • SRCREV: to use newer versions
  • DEPENDS: to select the Qt modules you are using, in order to enable all relevant GammaRay features

Buildroot

Config.in:

config BR2_PACKAGE_GAMMARAY
        bool "gammaray"
        depends on BR2_PACKAGE_QT5
        help
          GammaRay Qt introspection probe

gammaray.mk:

GAMMARAY_VERSION = 139e003174f48b0c883fc6c200ef2efb7467bff1
GAMMARAY_SITE = git://github.com/KDAB/GammaRay.git
GAMMARAY_INSTALL_STAGING = NO
GAMMARAY_INSTALL_TARGET = YES
GAMMARAY_LICENSE = GPLv2
GAMMARAY_LICENSE_FILES = LICENSE
GAMMARAY_DEPENDENCIES = qt5base

GAMMARAY_CONF_OPTS += -DGAMMARAY_BUILD_UI=OFF

$(eval $(cmake-package))

The lines you probably want to adjust are:

  • GAMMARAY_VERSION: to use newer versions
  • GAMMARAY_DEPENDENCIES: to select the Qt modules you are using, in order to enable all relevant GammaRay features