tests/qt5.nix
Build small Qt 5 programs with the Fil-C qmake and run them on the offscreen platform and on X11 (a native Xvfb).
λsource?, withQuick?
| source | default ../. |
Also build and run the SVG, QML and Qt Quick program. | |
| withQuick | default true |
let
Unspliced: in nativeBuildInputs a spliced qtbase.dev would become the build platform's qtbase.
in
pkgs.stdenv.mkDerivation
qtbase.dev carries qmake and moc (build-machine programs) and the Fil-C mkspecs.
runHook preConfigure
cp ${./qt5-smoke.cpp} qt5-smoke.cpp
cp ${./qt5-quick.cpp} qt5-quick.cpp
cp ${./qt5-contracts.cpp} qt5-contracts.cpp
cp ${./qt5-contract-plugin.cpp} qt5-contract-plugin.cpp
cat > smoke.pro <<'EOF'
QT += widgets network sql xml concurrent testlib
CONFIG += console
SOURCES = qt5-smoke.cpp
TARGET = qt5-smoke
EOF
cat > quick.pro <<'EOF'
QT += svg qml quick
CONFIG += console
SOURCES = qt5-quick.cpp
TARGET = qt5-quick
EOF
cat > contracts.pro <<'EOF'
CONFIG += console c++17
SOURCES = qt5-contracts.cpp
TARGET = qt5-contracts
EOF
cat > plugin.pro <<'EOF'
QT = core
TEMPLATE = lib
CONFIG += plugin
SOURCES = qt5-contract-plugin.cpp
TARGET = qt5-contract-plugin
EOF
export QMAKEPATH=${pkgs.lib.concatMapStringsSep":" m: "${m.dev}" pkgs.lib.optionalswithQuick qt5.qtsvg qt5.qtdeclarative}
mkdir smoke quick contracts plugin
(cd smoke && qmake ../smoke.pro)
(cd contracts && qmake ../contracts.pro)
(cd plugin && qmake ../plugin.pro)
runHook postConfigure
true
export QT_PLUGIN_PATH=${qt5.qtbase.bin}/${qtPluginPrefix}
+
export QML2_IMPORT_PATH=${qt5.qtdeclarative.bin}/${qtQmlPrefix}:${qt5.qtquickcontrols2.bin}/${qtQmlPrefix}
+
export QT_QUICK_BACKEND=software
export HOME=$TMPDIR
${pkgs.pkgsBuildBuild.binutils}/bin/readelf -SW plugin/libqt5-contract-plugin.so > plugin-sections.txt
if grep -q '\.qtmetadata' plugin-sections.txt; then
echo 'The metadata test requires a sectionless Fil-C plugin' >&2
exit 1
fi
./contracts/qt5-contracts "$PWD/plugin/libqt5-contract-plugin.so"
for platform in offscreen xcb; do
echo "== $program on $platform"
if [ $platform = xcb ]; then
QT_QPA_PLATFORM=xcb xvfb-run -a -s "-screen 0 640x480x24" ./$program
else
QT_QPA_PLATFORM=$platform ./$program
fi
done
done