2019-10-12 18:47:55 +01:00
|
|
|
if [[ -n "${__nix_qtbase-}" ]]; then
|
|
|
|
# Throw an error if a different version of Qt was already set up.
|
|
|
|
if [[ "$__nix_qtbase" != "@dev@" ]]; then
|
|
|
|
echo >&2 "Error: detected mismatched Qt dependencies:"
|
|
|
|
echo >&2 " @dev@"
|
|
|
|
echo >&2 " $__nix_qtbase"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else # Only set up Qt once.
|
|
|
|
__nix_qtbase="@dev@"
|
|
|
|
|
2017-10-24 12:39:54 +01:00
|
|
|
qtPluginPrefix=@qtPluginPrefix@
|
|
|
|
qtQmlPrefix=@qtQmlPrefix@
|
|
|
|
qtDocPrefix=@qtDocPrefix@
|
|
|
|
|
|
|
|
. @fix_qt_builtin_paths@
|
|
|
|
. @fix_qt_module_paths@
|
|
|
|
|
2019-10-12 18:47:55 +01: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
|
|
|
|
|
|
|
|
# Integration with CMake:
|
|
|
|
# Set the CMake build type corresponding to how qtbase was built.
|
|
|
|
if [ -n "@debug@" ]; then
|
|
|
|
cmakeBuildType="Debug"
|
|
|
|
else
|
|
|
|
cmakeBuildType="Release"
|
|
|
|
fi
|
|
|
|
|
2017-10-24 12:39:54 +01:00
|
|
|
providesQtRuntime() {
|
|
|
|
[ -d "$1/$qtPluginPrefix" ] || [ -d "$1/$qtQmlPrefix" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
# Build tools are often confused if QMAKE is unset.
|
|
|
|
QMAKE=@dev@/bin/qmake
|
|
|
|
export QMAKE
|
|
|
|
|
|
|
|
QMAKEPATH=
|
|
|
|
export QMAKEPATH
|
|
|
|
|
|
|
|
QMAKEMODULES=
|
|
|
|
export QMAKEMODULES
|
|
|
|
|
2019-10-12 18:47:55 +01:00
|
|
|
declare -Ag qmakePathSeen=()
|
2019-07-05 16:41:41 +01:00
|
|
|
qmakePathHook() {
|
2019-10-12 18:47:55 +01:00
|
|
|
# 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
|
2019-07-05 16:41:41 +01:00
|
|
|
if [ -d "$1/mkspecs" ]
|
|
|
|
then
|
2017-10-24 12:39:54 +01:00
|
|
|
QMAKEMODULES="${QMAKEMODULES}${QMAKEMODULES:+:}/mkspecs"
|
|
|
|
QMAKEPATH="${QMAKEPATH}${QMAKEPATH:+:}$1"
|
|
|
|
fi
|
|
|
|
}
|
2019-07-05 16:41:41 +01:00
|
|
|
envBuildHostHooks+=(qmakePathHook)
|
2017-10-24 12:39:54 +01:00
|
|
|
|
|
|
|
# Propagate any runtime dependency of the building package.
|
|
|
|
# Each dependency is propagated to the user environment and as a build
|
|
|
|
# input so that it will be re-propagated to the user environment by any
|
|
|
|
# package depending on the building package. (This is necessary in case
|
|
|
|
# the building package does not provide runtime dependencies itself and so
|
|
|
|
# would not be propagated to the user environment.)
|
2019-10-12 18:47:55 +01:00
|
|
|
declare -Ag qtEnvHostTargetSeen=()
|
2019-07-05 16:41:41 +01:00
|
|
|
qtEnvHostTargetHook() {
|
2019-10-12 18:47:55 +01:00
|
|
|
# Skip this path if we have seen it before.
|
|
|
|
# MUST use 'if' because 'qmakePathSeen[$]' may be unset.
|
|
|
|
if [ -n "${qtEnvHostTargetSeen[$1]-}" ]; then return; fi
|
|
|
|
qtEnvHostTargetSeen[$1]=1
|
2019-07-05 16:41:41 +01:00
|
|
|
if providesQtRuntime "$1" && [ "z${!outputBin}" != "z${!outputDev}" ]
|
|
|
|
then
|
|
|
|
propagatedBuildInputs+=" $1"
|
2017-10-24 12:39:54 +01:00
|
|
|
fi
|
|
|
|
}
|
2019-07-05 16:41:41 +01:00
|
|
|
envHostTargetHooks+=(qtEnvHostTargetHook)
|
2017-10-24 12:39:54 +01:00
|
|
|
|
|
|
|
postPatchMkspecs() {
|
2019-07-05 16:41:41 +01:00
|
|
|
# Prevent this hook from running multiple times
|
|
|
|
dontPatchMkspecs=1
|
|
|
|
|
2017-10-24 12:39:54 +01:00
|
|
|
local bin="${!outputBin}"
|
|
|
|
local dev="${!outputDev}"
|
|
|
|
local doc="${!outputDoc}"
|
|
|
|
local lib="${!outputLib}"
|
|
|
|
|
|
|
|
moveToOutput "mkspecs" "$dev"
|
|
|
|
|
|
|
|
if [ -d "$dev/mkspecs/modules" ]; then
|
|
|
|
fixQtModulePaths "$dev/mkspecs/modules"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d "$dev/mkspecs" ]; then
|
|
|
|
fixQtBuiltinPaths "$dev/mkspecs" '*.pr?'
|
|
|
|
fi
|
|
|
|
}
|
2019-10-30 15:16:20 +00:00
|
|
|
if [ -z "${dontPatchMkspecs-}" ]; then
|
2019-11-02 23:22:36 +00:00
|
|
|
postPhases="${postPhases-}${postPhases:+ }postPatchMkspecs"
|
2017-10-24 12:39:54 +01:00
|
|
|
fi
|
2019-10-12 18:47:55 +01:00
|
|
|
|
|
|
|
fi
|