1if [[ -n "${__nix_qtbase-}" ]]; then
2 # Throw an error if a different version of Qt was already set up.
3 if [[ "$__nix_qtbase" != "@dev@" ]]; then
4 echo >&2 "Error: detected mismatched Qt dependencies:"
5 echo >&2 " @dev@"
6 echo >&2 " $__nix_qtbase"
7 exit 1
8 fi
9else # Only set up Qt once.
10__nix_qtbase="@dev@"
11
12qtPluginPrefix=@qtPluginPrefix@
13qtQmlPrefix=@qtQmlPrefix@
14qtDocPrefix=@qtDocPrefix@
15
16. @fix_qt_builtin_paths@
17. @fix_qt_module_paths@
18
19# Disable debug symbols if qtbase was built without debugging.
20# This stops -dev paths from leaking into other outputs.
21if [ -z "@debug@" ]; then
22 NIX_CFLAGS_COMPILE="${NIX_CFLAGS_COMPILE-}${NIX_CFLAGS_COMPILE:+ }-DQT_NO_DEBUG"
23fi
24
25# Integration with CMake:
26# Set the CMake build type corresponding to how qtbase was built.
27if [ -n "@debug@" ]; then
28 cmakeBuildType="Debug"
29else
30 cmakeBuildType="Release"
31fi
32
33providesQtRuntime() {
34 [ -d "$1/$qtPluginPrefix" ] || [ -d "$1/$qtQmlPrefix" ]
35}
36
37# Build tools are often confused if QMAKE is unset.
38QMAKE=@dev@/bin/qmake
39export QMAKE
40
41QMAKEPATH=
42export QMAKEPATH
43
44QMAKEMODULES=
45export QMAKEMODULES
46
47declare -Ag qmakePathSeen=()
48qmakePathHook() {
49 # Skip this path if we have seen it before.
50 # MUST use 'if' because 'qmakePathSeen[$]' may be unset.
51 if [ -n "${qmakePathSeen[$1]-}" ]; then return; fi
52 qmakePathSeen[$1]=1
53 if [ -d "$1/mkspecs" ]
54 then
55 QMAKEMODULES="${QMAKEMODULES}${QMAKEMODULES:+:}/mkspecs"
56 QMAKEPATH="${QMAKEPATH}${QMAKEPATH:+:}$1"
57 fi
58}
59envBuildHostHooks+=(qmakePathHook)
60
61# Propagate any runtime dependency of the building package.
62# Each dependency is propagated to the user environment and as a build
63# input so that it will be re-propagated to the user environment by any
64# package depending on the building package. (This is necessary in case
65# the building package does not provide runtime dependencies itself and so
66# would not be propagated to the user environment.)
67declare -Ag qtEnvHostTargetSeen=()
68qtEnvHostTargetHook() {
69 # Skip this path if we have seen it before.
70 # MUST use 'if' because 'qmakePathSeen[$]' may be unset.
71 if [ -n "${qtEnvHostTargetSeen[$1]-}" ]; then return; fi
72 qtEnvHostTargetSeen[$1]=1
73 if providesQtRuntime "$1" && [ "z${!outputBin}" != "z${!outputDev}" ]
74 then
75 appendToVar propagatedBuildInputs "$1"
76 fi
77}
78envHostTargetHooks+=(qtEnvHostTargetHook)
79
80postPatchMkspecs() {
81 # Prevent this hook from running multiple times
82 dontPatchMkspecs=1
83
84 local bin="${!outputBin}"
85 local dev="${!outputDev}"
86 local doc="${!outputDoc}"
87 local lib="${!outputLib}"
88
89 moveToOutput "mkspecs" "$dev"
90
91 if [ -d "$dev/mkspecs/modules" ]; then
92 fixQtModulePaths "$dev/mkspecs/modules"
93 fi
94
95 if [ -d "$dev/mkspecs" ]; then
96 fixQtBuiltinPaths "$dev/mkspecs" '*.pr?'
97 fi
98}
99if [ -z "${dontPatchMkspecs-}" ]; then
100 appendToVar postPhases postPatchMkspecs
101fi
102
103qtPreHook() {
104 # Check that wrapQtAppsHook is used, or it is explicitly disabled.
105 if [[ -z "$__nix_wrapQtAppsHook" && -z "$dontWrapQtApps" ]]; then
106 echo >&2 "Error: wrapQtAppsHook is not used, and dontWrapQtApps is not set."
107 exit 1
108 fi
109}
110appendToVar prePhases qtPreHook
111
112fi