kdePackages.mkKdeDerivation: qmllint hook v3
This commit is contained in:
@@ -8,6 +8,7 @@ self:
|
||||
qt6,
|
||||
python3,
|
||||
python3Packages,
|
||||
jq,
|
||||
}:
|
||||
let
|
||||
dependencies = (lib.importJSON ../generated/dependencies.json).dependencies;
|
||||
@@ -77,6 +78,14 @@ let
|
||||
};
|
||||
|
||||
moveOutputsHook = makeSetupHook { name = "kf6-move-outputs-hook"; } ./move-outputs-hook.sh;
|
||||
|
||||
qmllintHook = makeSetupHook {
|
||||
name = "qmllint-validate-hook";
|
||||
substitutions = {
|
||||
qmllint = "${qt6.qtdeclarative}/bin/qmllint";
|
||||
jq = lib.getExe jq;
|
||||
};
|
||||
} ./qmllint-hook.sh;
|
||||
in
|
||||
{
|
||||
pname,
|
||||
@@ -131,6 +140,7 @@ let
|
||||
ninja
|
||||
qt6.wrapQtAppsHook
|
||||
moveOutputsHook
|
||||
qmllintHook
|
||||
]
|
||||
++ lib.optionals hasPythonBindings [
|
||||
python3Packages.shiboken6
|
||||
@@ -155,6 +165,8 @@ let
|
||||
|
||||
cmakeFlags = [ "-DQT_MAJOR_VERSION=6" ] ++ extraCmakeFlags;
|
||||
|
||||
doInstallCheck = true;
|
||||
|
||||
separateDebugInfo = true;
|
||||
|
||||
env.LANG = "C.UTF-8";
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
# shellcheck shell=bash
|
||||
if [[ -z "${__nix_qmllintHook-}" ]]; then
|
||||
__nix_qmllintHook=1 # Don't run this hook more than once.
|
||||
|
||||
qmlHostPathSeen=()
|
||||
qmlIncludeDirs=()
|
||||
|
||||
qmlUnseenHostPath() {
|
||||
for pkg in "${qmlHostPathSeen[@]}"; do
|
||||
if [ "${pkg:?}" == "$1" ]; then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
|
||||
qtHostPathSeen+=("$1")
|
||||
return 0
|
||||
}
|
||||
|
||||
qmlHostPathHook() {
|
||||
qmlUnseenHostPath "$1" || return 0
|
||||
|
||||
if ! [ -v qtQmlPrefix ]; then
|
||||
echo "qmlLintHook: qtQmlPrefix is unset. hint: add qt6.qtbase to buildInputs"
|
||||
fi
|
||||
|
||||
local qmlDir="$1/${qtQmlPrefix:?}"
|
||||
if [ -d "$qmlDir" ]; then
|
||||
qmlIncludeDirs+=("-I" "$qmlDir")
|
||||
fi
|
||||
}
|
||||
addEnvHooks "$targetOffset" qmlHostPathHook
|
||||
|
||||
doQmlLint() {
|
||||
LANG=C.UTF-8 @qmllint@ --bare "${qmlIncludeDirs[@]}" -I "${out}/${qtQmlPrefix}" "$@"
|
||||
}
|
||||
|
||||
qmlLintCheck() {
|
||||
echo "Running qmlLintCheck"
|
||||
|
||||
# intentionally scoped to the default QML prefix, as things in $out/share etc
|
||||
# can be used in random weird contexts and will cause spurious errors
|
||||
if [ -d "$out/$qtQmlPrefix" ]; then
|
||||
find "$out/$qtQmlPrefix" -name '*.qml' | while IFS= read -r i; do
|
||||
if [ -n "$(doQmlLint "$i" --json - | @jq@ '.files[] | .warnings[] | select(.id == "import") | select(.message | startswith("Failed to import"))')" ]; then
|
||||
echo "qmllint failed for file $i:"
|
||||
|
||||
doQmlLint "$i"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -z "${dontQmlLint-}" ]; then
|
||||
postInstallCheckHooks+=('qmlLintCheck')
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user