linux_xanmod: 5.11.14 -> 5.11.15
[NixPkgs.git] / pkgs / development / libraries / qt-5 / hooks / qtbase-setup-hook.sh
blob1b57d676e1fc5da609dc591b9f5a5a07e3334b52
1 if [[ -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
9 else # Only set up Qt once.
10 __nix_qtbase="@dev@"
12 qtPluginPrefix=@qtPluginPrefix@
13 qtQmlPrefix=@qtQmlPrefix@
14 qtDocPrefix=@qtDocPrefix@
16 . @fix_qt_builtin_paths@
17 . @fix_qt_module_paths@
19 # Disable debug symbols if qtbase was built without debugging.
20 # This stops -dev paths from leaking into other outputs.
21 if [ -z "@debug@" ]; then
22 NIX_CFLAGS_COMPILE="${NIX_CFLAGS_COMPILE-}${NIX_CFLAGS_COMPILE:+ }-DQT_NO_DEBUG"
25 # Integration with CMake:
26 # Set the CMake build type corresponding to how qtbase was built.
27 if [ -n "@debug@" ]; then
28 cmakeBuildType="Debug"
29 else
30 cmakeBuildType="Release"
33 providesQtRuntime() {
34 [ -d "$1/$qtPluginPrefix" ] || [ -d "$1/$qtQmlPrefix" ]
37 # Build tools are often confused if QMAKE is unset.
38 QMAKE=@dev@/bin/qmake
39 export QMAKE
41 QMAKEPATH=
42 export QMAKEPATH
44 QMAKEMODULES=
45 export QMAKEMODULES
47 declare -Ag qmakePathSeen=()
48 qmakePathHook() {
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"
59 envBuildHostHooks+=(qmakePathHook)
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.)
67 declare -Ag qtEnvHostTargetSeen=()
68 qtEnvHostTargetHook() {
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 propagatedBuildInputs+=" $1"
78 envHostTargetHooks+=(qtEnvHostTargetHook)
80 postPatchMkspecs() {
81 # Prevent this hook from running multiple times
82 dontPatchMkspecs=1
84 local bin="${!outputBin}"
85 local dev="${!outputDev}"
86 local doc="${!outputDoc}"
87 local lib="${!outputLib}"
89 moveToOutput "mkspecs" "$dev"
91 if [ -d "$dev/mkspecs/modules" ]; then
92 fixQtModulePaths "$dev/mkspecs/modules"
95 if [ -d "$dev/mkspecs" ]; then
96 fixQtBuiltinPaths "$dev/mkspecs" '*.pr?'
99 if [ -z "${dontPatchMkspecs-}" ]; then
100 postPhases="${postPhases-}${postPhases:+ }postPatchMkspecs"
103 qtPreHook() {
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
110 prePhases+=" qtPreHook"