From e0d03c43bf2deb01b27a61154560df8576f305eb Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Mon, 30 May 2016 16:29:41 -0500 Subject: [PATCH] qt56: make symlink farm for CMake builds like QMake --- .../libraries/qt-5/5.6/default.nix | 4 +- .../libraries/qt-5/5.6/qmake-hook.sh | 101 ++---------------- .../libraries/qt-5/5.6/qtbase/default.nix | 4 +- .../libraries/qt-5/5.6/qtbase/setup-hook.sh | 79 ++++++++++++++ .../libraries/qt-5/5.6/setup-hook.sh | 7 ++ 5 files changed, 98 insertions(+), 97 deletions(-) create mode 100644 pkgs/development/libraries/qt-5/5.6/setup-hook.sh diff --git a/pkgs/development/libraries/qt-5/5.6/default.nix b/pkgs/development/libraries/qt-5/5.6/default.nix index 4aada4224dac..0d095517c568 100644 --- a/pkgs/development/libraries/qt-5/5.6/default.nix +++ b/pkgs/development/libraries/qt-5/5.6/default.nix @@ -52,6 +52,8 @@ let outputs = args.outputs or [ "dev" "out" ]; setOutputFlags = args.setOutputFlags or false; + setupHook = ./setup-hook.sh; + enableParallelBuilding = args.enableParallelBuilding or true; meta = self.qtbase.meta // (args.meta or {}); @@ -111,7 +113,7 @@ let ]; makeQtWrapper = makeSetupHook { deps = [ makeWrapper ]; } ./make-qt-wrapper.sh; - qmakeHook = makeSetupHook { substitutions = { qt_dev = qtbase.dev; lndir = pkgs.xorg.lndir; }; } ./qmake-hook.sh; + qmakeHook = makeSetupHook { deps = [ self.qtbase ]; } ./qmake-hook.sh; }; diff --git a/pkgs/development/libraries/qt-5/5.6/qmake-hook.sh b/pkgs/development/libraries/qt-5/5.6/qmake-hook.sh index 9fd4735209ce..696b4ea8dad3 100644 --- a/pkgs/development/libraries/qt-5/5.6/qmake-hook.sh +++ b/pkgs/development/libraries/qt-5/5.6/qmake-hook.sh @@ -1,48 +1,14 @@ -if [[ -z "$QMAKE" ]]; then +qmakeConfigurePhase() { + runHook preConfigure -_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 + qmake PREFIX=$out $qmakeFlags + + runHook postConfigure } -_qtLinkModule() { - if [ -d "$1/mkspecs" ]; then - # $1 is a Qt module - _qtLinkDependencyDir "$1" mkspecs - - for dir in bin include lib share; do - if [ -d "$1/$dir" ]; then - _qtLinkDependencyDir "$1" "$dir" - fi - done - fi -} - -_qtRmModules() { - cat "$out/nix-support/qt-inputs" | while read file; do - if [ -h "$out/$file" ]; then - rm "$out/$file" - fi - done - - cat "$out/nix-support/qt-inputs" | while read file; do - if [ -d "$out/$file" ]; then - rmdir --ignore-fail-on-non-empty -p "$out/$file" - fi - done - - rm "$out/nix-support/qt-inputs" -} - -_qtRmQmake() { - rm "$qtOut/bin/qmake" "$qtOut/bin/qt.conf" -} - -_qtSetQmakePath() { - export PATH="$qtOut/bin${PATH:+:}$PATH" -} +if [ -z "$dontUseQmakeConfigure" -a -z "$configurePhase" ]; then + configurePhase=qmakeConfigurePhase +fi _qtModuleMultioutDevsPre() { # We cannot simply set these paths in configureFlags because libQtCore retains @@ -65,63 +31,12 @@ _qtModuleMultioutDevsPost() { mkdir -p "${!outputDev}/$(dirname "$file")" mv "${!outputLib}/$file" "${!outputDev}/$file" done - - # Ensure that CMake can find the shared libraries - mkdir -p "${!outputDev}/lib" - @lndir@/bin/lndir -silent "${!outputLib}/lib" "${!outputDev}/lib" fi popd fi } -_qtRmQtOut() { - rm -fr "$qtOut" -} - -qmakeConfigurePhase() { - runHook preConfigure - - qmake PREFIX=$out $qmakeFlags - - runHook postConfigure -} - -qtOut="" -if [[ -z "$NIX_QT_SUBMODULE" ]]; then - qtOut=`mktemp -d` -else - qtOut=$out -fi - -mkdir -p "$qtOut/bin" "$qtOut/mkspecs" "$qtOut/include" "$qtOut/nix-support" "$qtOut/lib" "$qtOut/share" - -cp "@qt_dev@/bin/qmake" "$qtOut/bin" -cat >"$qtOut/bin/qt.conf" <> "$NIX_QT5_TMP/nix-support/qt-inputs" + done + + postHooks+=(_qtSetCMakePrefix) + + cp "@dev@/bin/qmake" "$NIX_QT5_TMP/bin" + echo "bin/qmake" >> "$NIX_QT5_TMP/nix-support/qt-inputs" + + cat >"$NIX_QT5_TMP/bin/qt.conf" <> "$NIX_QT5_TMP/nix-support/qt-inputs" + + export QMAKE="$NIX_QT5_TMP/bin/qmake" + + # Set PATH to find qmake first in a preConfigure hook + # It must run after all the envHooks! + postHooks+=(_qtSetQmakePath) +fi + +qt5LinkModuleDir() { + if [ -d "$1/$2" ]; then + @lndir@/bin/lndir -silent "$1/$2" "$NIX_QT5_TMP/$2" + find "$1/$2" -printf "$2/%P\n" >> "$NIX_QT5_TMP/nix-support/qt-inputs" + fi +} + +qt5LinkModuleDir @out@ "lib" + +qt5LinkModuleDir @dev@ "bin" +qt5LinkModuleDir @dev@ "include" +qt5LinkModuleDir @dev@ "lib" +qt5LinkModuleDir @dev@ "mkspecs" +qt5LinkModuleDir @dev@ "share" diff --git a/pkgs/development/libraries/qt-5/5.6/setup-hook.sh b/pkgs/development/libraries/qt-5/5.6/setup-hook.sh new file mode 100644 index 000000000000..212ac903eeeb --- /dev/null +++ b/pkgs/development/libraries/qt-5/5.6/setup-hook.sh @@ -0,0 +1,7 @@ +qt5LinkModuleDir @out@ "lib" + +qt5LinkModuleDir @dev@ "bin" +qt5LinkModuleDir @dev@ "include" +qt5LinkModuleDir @dev@ "lib" +qt5LinkModuleDir @dev@ "mkspecs" +qt5LinkModuleDir @dev@ "share"