lol

qt5: factor out common setup hook for qtbase

+3 -335
+1 -1
pkgs/development/libraries/qt-5/5.5/qtbase/default.nix
··· 272 272 ''; 273 273 274 274 inherit lndir; 275 - setupHook = ./setup-hook.sh; 275 + setupHook = ../../qtbase-setup-hook.sh; 276 276 277 277 enableParallelBuilding = true; 278 278
pkgs/development/libraries/qt-5/5.5/qtbase/setup-hook.sh pkgs/development/libraries/qt-5/qtbase-setup-hook.sh
+1 -1
pkgs/development/libraries/qt-5/5.6/qtbase/default.nix
··· 228 228 ''; 229 229 230 230 inherit lndir; 231 - setupHook = ./setup-hook.sh; 231 + setupHook = ../../qtbase-setup-hook.sh; 232 232 233 233 enableParallelBuilding = true; 234 234
-166
pkgs/development/libraries/qt-5/5.6/qtbase/setup-hook.sh
··· 1 - addToSearchPathOnceWithCustomDelimiter() { 2 - local delim="$1" 3 - local search="$2" 4 - local target="$3" 5 - local dirs 6 - local exported 7 - IFS="$delim" read -a dirs <<< "${!search}" 8 - local canonical 9 - if canonical=$(readlink -e "$target"); then 10 - for dir in ${dirs[@]}; do 11 - if [ "z$dir" == "z$canonical" ]; then exported=1; fi 12 - done 13 - if [ -z $exported ]; then 14 - eval "export ${search}=\"${!search}${!search:+$delim}$canonical\"" 15 - fi 16 - fi 17 - } 18 - 19 - addToSearchPathOnce() { 20 - addToSearchPathOnceWithCustomDelimiter ':' "$@" 21 - } 22 - 23 - propagateOnce() { 24 - addToSearchPathOnceWithCustomDelimiter ' ' "$@" 25 - } 26 - 27 - _qtPropagate() { 28 - for dir in "lib/qt5/plugins" "lib/qt5/qml" "lib/qt5/imports"; do 29 - if [ -d "$1/$dir" ]; then 30 - propagateOnce propagatedBuildInputs "$1" 31 - break 32 - fi 33 - done 34 - addToSearchPathOnce QT_PLUGIN_PATH "$1/lib/qt5/plugins" 35 - addToSearchPathOnce QML_IMPORT_PATH "$1/lib/qt5/imports" 36 - addToSearchPathOnce QML2_IMPORT_PATH "$1/lib/qt5/qml" 37 - } 38 - 39 - crossEnvHooks+=(_qtPropagate) 40 - 41 - _qtPropagateNative() { 42 - for dir in "lib/qt5/plugins" "lib/qt5/qml" "lib/qt5/imports"; do 43 - if [ -d "$1/$dir" ]; then 44 - propagateOnce propagatedNativeBuildInputs "$1" 45 - break 46 - fi 47 - done 48 - if [ -z "$crossConfig" ]; then 49 - addToSearchPathOnce QT_PLUGIN_PATH "$1/lib/qt5/plugins" 50 - addToSearchPathOnce QML_IMPORT_PATH "$1/lib/qt5/imports" 51 - addToSearchPathOnce QML2_IMPORT_PATH "$1/lib/qt5/qml" 52 - fi 53 - } 54 - 55 - envHooks+=(_qtPropagateNative) 56 - 57 - _qtMultioutDevs() { 58 - # This is necessary whether the package is a Qt module or not 59 - moveToOutput "mkspecs" "${!outputDev}" 60 - } 61 - 62 - preFixupHooks+=(_qtMultioutDevs) 63 - 64 - _qtSetCMakePrefix() { 65 - export CMAKE_PREFIX_PATH="$NIX_QT5_TMP${CMAKE_PREFIX_PATH:+:}${CMAKE_PREFIX_PATH}" 66 - } 67 - 68 - _qtRmTmp() { 69 - if [ -z "$NIX_QT_SUBMODULE" ]; then 70 - rm -fr "$NIX_QT5_TMP" 71 - else 72 - cat "$NIX_QT5_TMP/nix-support/qt-inputs" | while read file; do 73 - if [ ! -d "$NIX_QT5_TMP/$file" ]; then 74 - rm -f "$NIX_QT5_TMP/$file" 75 - fi 76 - done 77 - 78 - cat "$NIX_QT5_TMP/nix-support/qt-inputs" | while read dir; do 79 - if [ -d "$NIX_QT5_TMP/$dir" ]; then 80 - rmdir --ignore-fail-on-non-empty -p "$NIX_QT5_TMP/$dir" 81 - fi 82 - done 83 - 84 - rm "$NIX_QT5_TMP/nix-support/qt-inputs" 85 - fi 86 - } 87 - 88 - _qtSetQmakePath() { 89 - export PATH="$NIX_QT5_TMP/bin${PATH:+:}$PATH" 90 - } 91 - 92 - if [ -z "$NIX_QT5_TMP" ]; then 93 - if [ -z "$NIX_QT_SUBMODULE" ]; then 94 - NIX_QT5_TMP=$(pwd)/__nix_qt5__ 95 - else 96 - NIX_QT5_TMP=$out 97 - fi 98 - postInstallHooks+=(_qtRmTmp) 99 - 100 - mkdir -p "$NIX_QT5_TMP/nix-support" 101 - for subdir in bin include lib mkspecs share; do 102 - mkdir "$NIX_QT5_TMP/$subdir" 103 - echo "$subdir/" >> "$NIX_QT5_TMP/nix-support/qt-inputs" 104 - done 105 - 106 - postHooks+=(_qtSetCMakePrefix) 107 - 108 - cp "@dev@/bin/qmake" "$NIX_QT5_TMP/bin" 109 - echo "bin/qmake" >> "$NIX_QT5_TMP/nix-support/qt-inputs" 110 - 111 - cat >"$NIX_QT5_TMP/bin/qt.conf" <<EOF 112 - [Paths] 113 - Prefix = $NIX_QT5_TMP 114 - Plugins = lib/qt5/plugins 115 - Imports = lib/qt5/imports 116 - Qml2Imports = lib/qt5/qml 117 - Documentation = share/doc/qt5 118 - EOF 119 - echo "bin/qt.conf" >> "$NIX_QT5_TMP/nix-support/qt-inputs" 120 - 121 - export QMAKE="$NIX_QT5_TMP/bin/qmake" 122 - 123 - # Set PATH to find qmake first in a preConfigure hook 124 - # It must run after all the envHooks! 125 - preConfigureHooks+=(_qtSetQmakePath) 126 - fi 127 - 128 - qt5LinkModuleDir() { 129 - if [ -d "$1/$2" ]; then 130 - @lndir@/bin/lndir -silent "$1/$2" "$NIX_QT5_TMP/$2" 131 - find "$1/$2" -printf "$2/%P\n" >> "$NIX_QT5_TMP/nix-support/qt-inputs" 132 - fi 133 - } 134 - 135 - NIX_QT5_MODULES="${NIX_QT5_MODULES}${NIX_QT5_MODULES:+:}@out@" 136 - NIX_QT5_MODULES_DEV="${NIX_QT5_MODULES_DEV}${NIX_QT5_MODULES_DEV:+:}@dev@" 137 - 138 - _qtLinkAllModules() { 139 - IFS=: read -a modules <<< $NIX_QT5_MODULES 140 - for module in ${modules[@]}; do 141 - qt5LinkModuleDir "$module" "lib" 142 - done 143 - 144 - IFS=: read -a modules <<< $NIX_QT5_MODULES_DEV 145 - for module in ${modules[@]}; do 146 - qt5LinkModuleDir "$module" "bin" 147 - qt5LinkModuleDir "$module" "include" 148 - qt5LinkModuleDir "$module" "lib" 149 - qt5LinkModuleDir "$module" "mkspecs" 150 - qt5LinkModuleDir "$module" "share" 151 - done 152 - } 153 - 154 - preConfigureHooks+=(_qtLinkAllModules) 155 - 156 - _qtFixCMakePaths() { 157 - find "${!outputLib}" -name "*.cmake" | while read file; do 158 - substituteInPlace "$file" \ 159 - --subst-var-by NIX_OUT "${!outputLib}" \ 160 - --subst-var-by NIX_DEV "${!outputDev}" 161 - done 162 - } 163 - 164 - if [ -n "$NIX_QT_SUBMODULE" ]; then 165 - postInstallHooks+=(_qtFixCMakePaths) 166 - fi
+1 -1
pkgs/development/libraries/qt-5/5.7/qtbase/default.nix
··· 232 232 ''; 233 233 234 234 inherit lndir; 235 - setupHook = ./setup-hook.sh; 235 + setupHook = ../../qtbase-setup-hook.sh; 236 236 237 237 enableParallelBuilding = true; 238 238
-166
pkgs/development/libraries/qt-5/5.7/qtbase/setup-hook.sh
··· 1 - addToSearchPathOnceWithCustomDelimiter() { 2 - local delim="$1" 3 - local search="$2" 4 - local target="$3" 5 - local dirs 6 - local exported 7 - IFS="$delim" read -a dirs <<< "${!search}" 8 - local canonical 9 - if canonical=$(readlink -e "$target"); then 10 - for dir in ${dirs[@]}; do 11 - if [ "z$dir" == "z$canonical" ]; then exported=1; fi 12 - done 13 - if [ -z $exported ]; then 14 - eval "export ${search}=\"${!search}${!search:+$delim}$canonical\"" 15 - fi 16 - fi 17 - } 18 - 19 - addToSearchPathOnce() { 20 - addToSearchPathOnceWithCustomDelimiter ':' "$@" 21 - } 22 - 23 - propagateOnce() { 24 - addToSearchPathOnceWithCustomDelimiter ' ' "$@" 25 - } 26 - 27 - _qtPropagate() { 28 - for dir in "lib/qt5/plugins" "lib/qt5/qml" "lib/qt5/imports"; do 29 - if [ -d "$1/$dir" ]; then 30 - propagateOnce propagatedBuildInputs "$1" 31 - break 32 - fi 33 - done 34 - addToSearchPathOnce QT_PLUGIN_PATH "$1/lib/qt5/plugins" 35 - addToSearchPathOnce QML_IMPORT_PATH "$1/lib/qt5/imports" 36 - addToSearchPathOnce QML2_IMPORT_PATH "$1/lib/qt5/qml" 37 - } 38 - 39 - crossEnvHooks+=(_qtPropagate) 40 - 41 - _qtPropagateNative() { 42 - for dir in "lib/qt5/plugins" "lib/qt5/qml" "lib/qt5/imports"; do 43 - if [ -d "$1/$dir" ]; then 44 - propagateOnce propagatedNativeBuildInputs "$1" 45 - break 46 - fi 47 - done 48 - if [ -z "$crossConfig" ]; then 49 - addToSearchPathOnce QT_PLUGIN_PATH "$1/lib/qt5/plugins" 50 - addToSearchPathOnce QML_IMPORT_PATH "$1/lib/qt5/imports" 51 - addToSearchPathOnce QML2_IMPORT_PATH "$1/lib/qt5/qml" 52 - fi 53 - } 54 - 55 - envHooks+=(_qtPropagateNative) 56 - 57 - _qtMultioutDevs() { 58 - # This is necessary whether the package is a Qt module or not 59 - moveToOutput "mkspecs" "${!outputDev}" 60 - } 61 - 62 - preFixupHooks+=(_qtMultioutDevs) 63 - 64 - _qtSetCMakePrefix() { 65 - export CMAKE_PREFIX_PATH="$NIX_QT5_TMP${CMAKE_PREFIX_PATH:+:}${CMAKE_PREFIX_PATH}" 66 - } 67 - 68 - _qtRmTmp() { 69 - if [ -z "$NIX_QT_SUBMODULE" ]; then 70 - rm -fr "$NIX_QT5_TMP" 71 - else 72 - cat "$NIX_QT5_TMP/nix-support/qt-inputs" | while read file; do 73 - if [ ! -d "$NIX_QT5_TMP/$file" ]; then 74 - rm -f "$NIX_QT5_TMP/$file" 75 - fi 76 - done 77 - 78 - cat "$NIX_QT5_TMP/nix-support/qt-inputs" | while read dir; do 79 - if [ -d "$NIX_QT5_TMP/$dir" ]; then 80 - rmdir --ignore-fail-on-non-empty -p "$NIX_QT5_TMP/$dir" 81 - fi 82 - done 83 - 84 - rm "$NIX_QT5_TMP/nix-support/qt-inputs" 85 - fi 86 - } 87 - 88 - _qtSetQmakePath() { 89 - export PATH="$NIX_QT5_TMP/bin${PATH:+:}$PATH" 90 - } 91 - 92 - if [ -z "$NIX_QT5_TMP" ]; then 93 - if [ -z "$NIX_QT_SUBMODULE" ]; then 94 - NIX_QT5_TMP=$(pwd)/__nix_qt5__ 95 - else 96 - NIX_QT5_TMP=$out 97 - fi 98 - postInstallHooks+=(_qtRmTmp) 99 - 100 - mkdir -p "$NIX_QT5_TMP/nix-support" 101 - for subdir in bin include lib mkspecs share; do 102 - mkdir "$NIX_QT5_TMP/$subdir" 103 - echo "$subdir/" >> "$NIX_QT5_TMP/nix-support/qt-inputs" 104 - done 105 - 106 - postHooks+=(_qtSetCMakePrefix) 107 - 108 - cp "@dev@/bin/qmake" "$NIX_QT5_TMP/bin" 109 - echo "bin/qmake" >> "$NIX_QT5_TMP/nix-support/qt-inputs" 110 - 111 - cat >"$NIX_QT5_TMP/bin/qt.conf" <<EOF 112 - [Paths] 113 - Prefix = $NIX_QT5_TMP 114 - Plugins = lib/qt5/plugins 115 - Imports = lib/qt5/imports 116 - Qml2Imports = lib/qt5/qml 117 - Documentation = share/doc/qt5 118 - EOF 119 - echo "bin/qt.conf" >> "$NIX_QT5_TMP/nix-support/qt-inputs" 120 - 121 - export QMAKE="$NIX_QT5_TMP/bin/qmake" 122 - 123 - # Set PATH to find qmake first in a preConfigure hook 124 - # It must run after all the envHooks! 125 - preConfigureHooks+=(_qtSetQmakePath) 126 - fi 127 - 128 - qt5LinkModuleDir() { 129 - if [ -d "$1/$2" ]; then 130 - @lndir@/bin/lndir -silent "$1/$2" "$NIX_QT5_TMP/$2" 131 - find "$1/$2" -printf "$2/%P\n" >> "$NIX_QT5_TMP/nix-support/qt-inputs" 132 - fi 133 - } 134 - 135 - NIX_QT5_MODULES="${NIX_QT5_MODULES}${NIX_QT5_MODULES:+:}@out@" 136 - NIX_QT5_MODULES_DEV="${NIX_QT5_MODULES_DEV}${NIX_QT5_MODULES_DEV:+:}@dev@" 137 - 138 - _qtLinkAllModules() { 139 - IFS=: read -a modules <<< $NIX_QT5_MODULES 140 - for module in ${modules[@]}; do 141 - qt5LinkModuleDir "$module" "lib" 142 - done 143 - 144 - IFS=: read -a modules <<< $NIX_QT5_MODULES_DEV 145 - for module in ${modules[@]}; do 146 - qt5LinkModuleDir "$module" "bin" 147 - qt5LinkModuleDir "$module" "include" 148 - qt5LinkModuleDir "$module" "lib" 149 - qt5LinkModuleDir "$module" "mkspecs" 150 - qt5LinkModuleDir "$module" "share" 151 - done 152 - } 153 - 154 - preConfigureHooks+=(_qtLinkAllModules) 155 - 156 - _qtFixCMakePaths() { 157 - find "${!outputLib}" -name "*.cmake" | while read file; do 158 - substituteInPlace "$file" \ 159 - --subst-var-by NIX_OUT "${!outputLib}" \ 160 - --subst-var-by NIX_DEV "${!outputDev}" 161 - done 162 - } 163 - 164 - if [ -n "$NIX_QT_SUBMODULE" ]; then 165 - postInstallHooks+=(_qtFixCMakePaths) 166 - fi