at master 3.1 kB view raw
1if [[ -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 9else # Only set up Qt once. 10 __nix_qtbase="@out@" 11 12 qtPluginPrefix=@qtPluginPrefix@ 13 qtQmlPrefix=@qtQmlPrefix@ 14 15 . @fix_qt_builtin_paths@ 16 . @fix_qt_module_paths@ 17 18 # Build tools are often confused if QMAKE is unset. 19 export QMAKE=@out@/bin/qmake 20 21 export QMAKEPATH= 22 23 export QMAKEMODULES= 24 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" 34 fi 35 } 36 envBuildHostHooks+=(qmakePathHook) 37 38 declare -g qttoolsPathSeen= 39 qtToolsHook() { 40 if [ -f "$1/libexec/qhelpgenerator" ]; then 41 if [[ -n "${qtToolsPathSeen:-}" && "${qttoolsPathSeen:-}" != "$1" ]]; then 42 echo >&2 "Error: detected mismatched Qt dependencies:" 43 echo >&2 " $1" 44 echo >&2 " $qttoolsPathSeen" 45 exit 1 46 fi 47 48 qttoolsPathSeen=$1 49 appendToVar cmakeFlags "-DQT_OPTIONAL_TOOLS_PATH=$1" 50 fi 51 } 52 addEnvHooks "$hostOffset" qtToolsHook 53 54 postPatchMkspecs() { 55 # Prevent this hook from running multiple times 56 dontPatchMkspecs=1 57 58 local lib="${!outputLib}" 59 local dev="${!outputDev}" 60 61 moveToOutput "mkspecs/modules" "$dev" 62 63 if [ -d "$dev/mkspecs/modules" ]; then 64 fixQtModulePaths "$dev/mkspecs/modules" 65 fi 66 67 if [ -d "$lib/mkspecs" ]; then 68 fixQtBuiltinPaths "$lib/mkspecs" '*.pr?' 69 fi 70 71 if [ -d "$lib/lib" ]; then 72 fixQtBuiltinPaths "$lib/lib" '*.pr?' 73 fi 74 } 75 if [ -z "${dontPatchMkspecs-}" ]; then 76 appendToVar postPhases postPatchMkspecs 77 fi 78 79 qtPreHook() { 80 # Check that wrapQtAppsHook/wrapQtAppsNoGuiHook is used, or it is explicitly disabled. 81 if [[ -z "$__nix_wrapQtAppsHook" && -z "$dontWrapQtApps" ]]; then 82 echo >&2 "Error: this derivation depends on qtbase, but no wrapping behavior was specified." 83 echo >&2 " - If this is a graphical application, add wrapQtAppsHook to nativeBuildInputs" 84 echo >&2 " - If this is a CLI application, add wrapQtAppsNoGuiHook to nativeBuildInputs" 85 echo >&2 " - If this is a library or you need custom wrapping logic, set dontWrapQtApps = true" 86 exit 1 87 fi 88 } 89 appendToVar prePhases qtPreHook 90 91 addQtModulePrefix() { 92 addToSearchPath QT_ADDITIONAL_PACKAGES_PREFIX_PATH $1 93 } 94 addEnvHooks "$hostOffset" addQtModulePrefix 95 96fi