2022-06-16 17:23:12 +00:00
|
|
|
if [[ -n "${__nix_qtbase-}" ]]; then
|
|
|
|
# Throw an error if a different version of Qt was already set up.
|
2023-04-29 16:46:19 +00:00
|
|
|
if [[ "$__nix_qtbase" != "@out@" ]]; then
|
2022-06-16 17:23:12 +00:00
|
|
|
echo >&2 "Error: detected mismatched Qt dependencies:"
|
2023-04-29 16:46:19 +00:00
|
|
|
echo >&2 " @out@"
|
2022-06-16 17:23:12 +00:00
|
|
|
echo >&2 " $__nix_qtbase"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else # Only set up Qt once.
|
2023-04-29 16:46:19 +00:00
|
|
|
__nix_qtbase="@out@"
|
2022-06-16 17:23:12 +00:00
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
qtPluginPrefix=@qtPluginPrefix@
|
|
|
|
qtQmlPrefix=@qtQmlPrefix@
|
2022-06-16 17:23:12 +00:00
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
. @fix_qt_builtin_paths@
|
|
|
|
. @fix_qt_module_paths@
|
2022-06-16 17:23:12 +00:00
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
# Disable debug symbols if qtbase was built without debugging.
|
|
|
|
# This stops -dev paths from leaking into other outputs.
|
|
|
|
if [ -z "@debug@" ]; then
|
|
|
|
NIX_CFLAGS_COMPILE="${NIX_CFLAGS_COMPILE-}${NIX_CFLAGS_COMPILE:+ }-DQT_NO_DEBUG"
|
|
|
|
fi
|
2022-06-16 17:23:12 +00:00
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
# Integration with CMake:
|
|
|
|
# Set the CMake build type corresponding to how qtbase was built.
|
|
|
|
if [ -n "@debug@" ]; then
|
|
|
|
cmakeBuildType="Debug"
|
|
|
|
else
|
|
|
|
cmakeBuildType="Release"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Build tools are often confused if QMAKE is unset.
|
2023-04-29 16:46:19 +00:00
|
|
|
export QMAKE=@out@/bin/qmake
|
2022-10-21 18:38:19 +00:00
|
|
|
|
|
|
|
export QMAKEPATH=
|
|
|
|
|
|
|
|
export QMAKEMODULES=
|
|
|
|
|
|
|
|
declare -Ag qmakePathSeen=()
|
|
|
|
qmakePathHook() {
|
|
|
|
# Skip this path if we have seen it before.
|
|
|
|
# MUST use 'if' because 'qmakePathSeen[$]' may be unset.
|
|
|
|
if [ -n "${qmakePathSeen[$1]-}" ]; then return; fi
|
|
|
|
qmakePathSeen[$1]=1
|
|
|
|
if [ -d "$1/mkspecs" ]; then
|
|
|
|
QMAKEMODULES="${QMAKEMODULES}${QMAKEMODULES:+:}/mkspecs"
|
|
|
|
QMAKEPATH="${QMAKEPATH}${QMAKEPATH:+:}$1"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
envBuildHostHooks+=(qmakePathHook)
|
|
|
|
|
|
|
|
postPatchMkspecs() {
|
|
|
|
# Prevent this hook from running multiple times
|
|
|
|
dontPatchMkspecs=1
|
|
|
|
|
|
|
|
local lib="${!outputLib}"
|
2023-04-29 16:46:19 +00:00
|
|
|
local dev="${!outputDev}"
|
2022-10-21 18:38:19 +00:00
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
moveToOutput "mkspecs/modules" "$dev"
|
2022-10-21 18:38:19 +00:00
|
|
|
|
|
|
|
if [ -d "$dev/mkspecs/modules" ]; then
|
|
|
|
fixQtModulePaths "$dev/mkspecs/modules"
|
|
|
|
fi
|
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
if [ -d "$lib/mkspecs" ]; then
|
|
|
|
fixQtBuiltinPaths "$lib/mkspecs" '*.pr?'
|
2022-10-21 18:38:19 +00:00
|
|
|
fi
|
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
if [ -d "$lib/lib" ]; then
|
|
|
|
fixQtBuiltinPaths "$lib/lib" '*.pr?'
|
2022-10-21 18:38:19 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
if [ -z "${dontPatchMkspecs-}" ]; then
|
|
|
|
postPhases="${postPhases-}${postPhases:+ }postPatchMkspecs"
|
2022-06-16 17:23:12 +00:00
|
|
|
fi
|
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
qtPreHook() {
|
|
|
|
# Check that wrapQtAppsHook is used, or it is explicitly disabled.
|
|
|
|
if [[ -z "$__nix_wrapQtAppsHook" && -z "$dontWrapQtApps" ]]; then
|
|
|
|
echo >&2 "Error: wrapQtAppsHook is not used, and dontWrapQtApps is not set."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
prePhases+=" qtPreHook"
|
|
|
|
|
|
|
|
addQtModulePrefix() {
|
|
|
|
addToSearchPath QT_ADDITIONAL_PACKAGES_PREFIX_PATH $1
|
|
|
|
}
|
|
|
|
addEnvHooks "$hostOffset" addQtModulePrefix
|
2022-06-16 17:23:12 +00:00
|
|
|
|
|
|
|
fi
|