forgejo-lts: 7.0.10 -> 7.0.11
[NixPkgs.git] / pkgs / development / libraries / qt-6 / hooks / qtbase-setup-hook.sh
blob48beac0b04fa67776081d565005836574b65d765
1 if [[ -n "${__nix_qtbase-}" ]]; then
2 # Throw an error if a different version of Qt was already set up.
3 if [[ "$__nix_qtbase" != "@out@" ]]; then
4 echo >&2 "Error: detected mismatched Qt dependencies:"
5 echo >&2 " @out@"
6 echo >&2 " $__nix_qtbase"
7 exit 1
8 fi
9 else # Only set up Qt once.
10 __nix_qtbase="@out@"
12 qtPluginPrefix=@qtPluginPrefix@
13 qtQmlPrefix=@qtQmlPrefix@
15 . @fix_qt_builtin_paths@
16 . @fix_qt_module_paths@
18 # Build tools are often confused if QMAKE is unset.
19 export QMAKE=@out@/bin/qmake
21 export QMAKEPATH=
23 export QMAKEMODULES=
25 declare -Ag qmakePathSeen=()
26 qmakePathHook() {
27 # Skip this path if we have seen it before.
28 # MUST use 'if' because 'qmakePathSeen[$]' may be unset.
29 if [ -n "${qmakePathSeen[$1]-}" ]; then return; fi
30 qmakePathSeen[$1]=1
31 if [ -d "$1/mkspecs" ]; then
32 QMAKEMODULES="${QMAKEMODULES}${QMAKEMODULES:+:}/mkspecs"
33 QMAKEPATH="${QMAKEPATH}${QMAKEPATH:+:}$1"
36 envBuildHostHooks+=(qmakePathHook)
38 export QTTOOLSPATH=
40 declare -Ag qttoolsPathSeen=()
41 qtToolsHook() {
42 # Skip this path if we have seen it before.
43 # MUST use 'if' because 'qttoolsPathSeen[$]' may be unset.
44 if [ -n "${qttoolsPathSeen[$1]-}" ]; then return; fi
45 qttoolsPathSeen[$1]=1
46 if [ -d "$1/libexec" ]; then
47 QTTOOLSPATH="${QTTOOLSPATH}${QTTOOLSPATH:+:}$1/libexec"
50 addEnvHooks "$hostOffset" qtToolsHook
52 postPatchMkspecs() {
53 # Prevent this hook from running multiple times
54 dontPatchMkspecs=1
56 local lib="${!outputLib}"
57 local dev="${!outputDev}"
59 moveToOutput "mkspecs/modules" "$dev"
61 if [ -d "$dev/mkspecs/modules" ]; then
62 fixQtModulePaths "$dev/mkspecs/modules"
65 if [ -d "$lib/mkspecs" ]; then
66 fixQtBuiltinPaths "$lib/mkspecs" '*.pr?'
69 if [ -d "$lib/lib" ]; then
70 fixQtBuiltinPaths "$lib/lib" '*.pr?'
73 if [ -z "${dontPatchMkspecs-}" ]; then
74 appendToVar postPhases postPatchMkspecs
77 qtPreHook() {
78 # Check that wrapQtAppsHook/wrapQtAppsNoGuiHook is used, or it is explicitly disabled.
79 if [[ -z "$__nix_wrapQtAppsHook" && -z "$dontWrapQtApps" ]]; then
80 echo >&2 "Error: this derivation depends on qtbase, but no wrapping behavior was specified."
81 echo >&2 " - If this is a graphical application, add wrapQtAppsHook to nativeBuildInputs"
82 echo >&2 " - If this is a CLI application, add wrapQtAppsNoGuiHook to nativeBuildInputs"
83 echo >&2 " - If this is a library or you need custom wrapping logic, set dontWrapQtApps = true"
84 exit 1
87 appendToVar prePhases qtPreHook
89 addQtModulePrefix() {
90 addToSearchPath QT_ADDITIONAL_PACKAGES_PREFIX_PATH $1
92 addEnvHooks "$hostOffset" addQtModulePrefix