summary refs log tree commit diff
path: root/pkgs/development/libraries/qt-5/5.5
diff options
context:
space:
mode:
authorThomas Tuegel <ttuegel@gmail.com>2016-01-27 20:05:40 -0600
committerThomas Tuegel <ttuegel@gmail.com>2016-01-31 21:15:03 -0600
commit9065ab0c8ac68887f4007ded5ac30de8555bfc44 (patch)
tree83837b8068fae518a2031913cec2faac7e854baf /pkgs/development/libraries/qt-5/5.5
parentf6e87370fbe56848d30a0631ee019a9b3a97b7ea (diff)
kde5.extra-cmake-modules: rewrite setupHook
The rewrite achieves three goals. First, all the installation paths are
set correctly for multiple outputs. Second, the correct search paths are
set for all types of shared data. Third, packages are installed through
propagatedUserEnvPkgs as required.
Diffstat (limited to 'pkgs/development/libraries/qt-5/5.5')
-rw-r--r--pkgs/development/libraries/qt-5/5.5/make-qt-wrapper.sh19
-rw-r--r--pkgs/development/libraries/qt-5/5.5/qtbase/setup-hook.sh89
2 files changed, 59 insertions, 49 deletions
diff --git a/pkgs/development/libraries/qt-5/5.5/make-qt-wrapper.sh b/pkgs/development/libraries/qt-5/5.5/make-qt-wrapper.sh
index 63525ba365bc3..f29bbb73639ba 100644
--- a/pkgs/development/libraries/qt-5/5.5/make-qt-wrapper.sh
+++ b/pkgs/development/libraries/qt-5/5.5/make-qt-wrapper.sh
@@ -1,10 +1,3 @@
-addQtDependency() {
-    addToSearchPath QT_PLUGIN_PATH "$1/lib/qt5/plugins"
-    addToSearchPath QML_IMPORT_PATH "$1/lib/qt5/imports"
-    addToSearchPath QML2_IMPORT_PATH "$1/lib/qt5/qml"
-    addToSearchPath XDG_CONFIG_DIRS "$1/etc/xdg"
-}
-
 wrapQtProgram() {
     local prog="$1"
     shift
@@ -12,8 +5,8 @@ wrapQtProgram() {
         --prefix QT_PLUGIN_PATH : "$QT_PLUGIN_PATH" \
         --prefix QML_IMPORT_PATH : "$QML_IMPORT_PATH" \
         --prefix QML2_IMPORT_PATH : "$QML2_IMPORT_PATH" \
-        --prefix XDG_CONFIG_DIRS : "$XDG_CONFIG_DIRS" \
-        --prefix XDG_DATA_DIRS : "$XDG_DATA_DIRS" \
+        --prefix XDG_CONFIG_DIRS : "$NIX_WRAP_XDG_CONFIG_DIRS" \
+        --prefix XDG_DATA_DIRS : "$NIX_WRAP_XDG_DATA_DIRS" \
         "$@"
 }
 
@@ -26,8 +19,8 @@ makeQtWrapper() {
         --prefix QT_PLUGIN_PATH : "$QT_PLUGIN_PATH" \
         --prefix QML_IMPORT_PATH : "$QML_IMPORT_PATH" \
         --prefix QML2_IMPORT_PATH : "$QML2_IMPORT_PATH" \
-        --prefix XDG_CONFIG_DIRS : "$XDG_CONFIG_DIRS" \
-        --prefix XDG_DATA_DIRS : "$XDG_DATA_DIRS" \
+        --prefix XDG_CONFIG_DIRS : "$NIX_WRAP_XDG_CONFIG_DIRS" \
+        --prefix XDG_DATA_DIRS : "$NIX_WRAP_XDG_DATA_DIRS" \
         "$@"
 }
 
@@ -37,5 +30,5 @@ export QML_IMPORT_PATH="$QML_IMPORT_PATH${QML_IMPORT_PATH:+:}${!outputLib}/lib/q
 export QML2_IMPORT_PATH="$QML2_IMPORT_PATH${QML2_IMPORT_PATH:+:}${!outputLib}/lib/qt5/qml"
 export XDG_CONFIG_DIRS="$XDG_CONFIG_DIRS${XDG_CONFIG_DIRS:+:}${!outputLib}/etc/xdg"
 export XDG_DATA_DIRS="$XDG_DATA_DIRS${XDG_DATA_DIRS:+:}${!outputLib}/share"
-
-envHooks+=(addQtDependency)
+export NIX_WRAP_XDG_CONFIG_DIRS="$NIX_WRAP_XDG_CONFIG_DIRS${NIX_WRAP_XDG_CONFIG_DIRS:+:}${!outputLib}/etc/xdg"
+export NIX_WRAP_XDG_DATA_DIRS="$NIX_WRAP_XDG_DATA_DIRS${NIX_WRAP_XDG_DATA_DIRS:+:}${!outputLib}/share"
diff --git a/pkgs/development/libraries/qt-5/5.5/qtbase/setup-hook.sh b/pkgs/development/libraries/qt-5/5.5/qtbase/setup-hook.sh
index 59e04a3561e00..9cf1ef9ccb614 100644
--- a/pkgs/development/libraries/qt-5/5.5/qtbase/setup-hook.sh
+++ b/pkgs/development/libraries/qt-5/5.5/qtbase/setup-hook.sh
@@ -1,45 +1,26 @@
 if [[ -z "$QMAKE" ]]; then
 
-linkDependencyDir() {
+_qtLinkDependencyDir() {
     @lndir@/bin/lndir -silent "$1/$2" "$qtOut/$2"
     if [[ -n "$NIX_QT_SUBMODULE" ]]; then
         find "$1/$2" -printf "$2/%P\n" >> "$out/nix-support/qt-inputs"
     fi
 }
 
-addQtModule() {
-    if [[ -d "$1/mkspecs" ]]; then
+_qtLinkModule() {
+    if [ -d "$1/mkspecs" ]; then
         # $1 is a Qt module
-        linkDependencyDir "$1" mkspecs
+        _qtLinkDependencyDir "$1" mkspecs
 
         for dir in bin include lib share; do
-            if [[ -d "$1/$dir" ]]; then
-                linkDependencyDir "$1" "$dir"
+            if [ -d "$1/$dir" ]; then
+                _qtLinkDependencyDir "$1" "$dir"
             fi
         done
     fi
 }
 
-propagateRuntimeDeps() {
-    local propagated
-    for dir in "etc/xdg" "lib/qt5/plugins" "lib/qt5/qml" "lib/qt5/imports" "share"; do
-        if [[ -d "$1/$dir" ]]; then
-            propagated=
-            for pkg in $propagatedBuildInputs; do
-                if [[ "z$pkg" == "z$1" ]]; then
-                    propagated=1
-                    break
-                fi
-            done
-            if [[ -z $propagated ]]; then
-                propagatedBuildInputs="$propagatedBuildInputs $1"
-            fi
-            break
-        fi
-    done
-}
-
-rmQtModules() {
+_qtRmModules() {
     cat "$out/nix-support/qt-inputs" | while read file; do
       if [[ -h "$out/$file" ]]; then
         rm "$out/$file"
@@ -55,15 +36,51 @@ rmQtModules() {
     rm "$out/nix-support/qt-inputs"
 }
 
-rmQMake() {
+addToSearchPathOnceWithCustomDelimiter() {
+    local delim="$1"
+    local search="$2"
+    local target="$3"
+    local dirs
+    local exported
+    IFS="$delim" read -a dirs <<< "${!search}"
+    for dir in ${dirs[@]}; do
+        if [ "z$dir" == "z$target" ]; then exported=1; fi
+    done
+    if [ -z $exported ]; then
+        eval "export ${search}=\"${!search}${!search:+$delim}$target\""
+    fi
+}
+
+addToSearchPathOnce() {
+    addToSearchPathOnceWithCustomDelimiter ':' "$@"
+}
+
+propagateOnce() {
+    addToSearchPathOnceWithCustomDelimiter ' ' "$@"
+}
+
+_qtPropagateRuntimeDependencies() {
+    for dir in "lib/qt5/plugins" "lib/qt5/qml" "lib/qt5/imports"; do
+        if [ -d "$1/$dir" ]; then
+            propagateOnce propagatedBuildInputs "$1"
+            propagateOnce propagatedUserEnvPkgs "$1"
+            break
+        fi
+    done
+    addToSearchPathOnce QT_PLUGIN_PATH "$1/lib/qt5/plugins"
+    addToSearchPathOnce QML_IMPORT_PATH "$1/lib/qt5/imports"
+    addToSearchPathOnce QML2_IMPORT_PATH "$1/lib/qt5/qml"
+}
+
+_qtRmQmake() {
     rm "$qtOut/bin/qmake" "$qtOut/bin/qt.conf"
 }
 
-setQMakePath() {
+_qtSetQmakePath() {
     export PATH="$qtOut/bin${PATH:+:}$PATH"
 }
 
-_multioutQtModuleDevs() {
+_qtMultioutModuleDevs() {
     # We cannot simply set these paths in configureFlags because libQtCore retains
     # references to the paths it was built with.
     moveToOutput "bin" "${!outputDev}"
@@ -74,7 +91,7 @@ _multioutQtModuleDevs() {
     moveToOutput "share/doc" "${!outputDev}"
 }
 
-_multioutQtDevs() {
+_qtMultioutDevs() {
     # This is necessary whether the package is a Qt module or not
     moveToOutput "mkspecs" "${!outputDev}"
 }
@@ -100,20 +117,20 @@ EOF
 
 export QMAKE="$qtOut/bin/qmake"
 
-envHooks+=(addQtModule propagateRuntimeDeps)
+envHooks+=(_qtLinkModule _qtPropagateRuntimeDependencies)
 # Set PATH to find qmake first in a preConfigure hook
 # It must run after all the envHooks!
-preConfigureHooks+=(setQMakePath)
+preConfigureHooks+=(_qtSetQmakePath)
 
-preFixupHooks+=(_multioutQtDevs)
+preFixupHooks+=(_qtMultioutDevs)
 if [[ -n "$NIX_QT_SUBMODULE" ]]; then
-    postInstallHooks+=(rmQMake rmQtModules)
-    preFixupHooks+=(_multioutQtModuleDevs)
+    postInstallHooks+=(_qtRmQmake _qtRmModules)
+    preFixupHooks+=(_qtMultioutModuleDevs)
 fi
 
 fi
 
 if [[ -z "$NIX_QT_PIC" ]]; then
-    export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -fPIC"
+    export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE${NIX_CFLAGS_COMPILE:+ }-fPIC"
     export NIX_QT_PIC=1
 fi