qt56: make symlink farm for CMake builds like QMake

This commit is contained in:
Thomas Tuegel 2016-05-30 16:29:41 -05:00
parent 0c9e904943
commit e0d03c43bf
5 changed files with 98 additions and 97 deletions

View File

@ -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;
};

View File

@ -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" <<EOF
[Paths]
Prefix = $qtOut
Plugins = lib/qt5/plugins
Imports = lib/qt5/imports
Qml2Imports = lib/qt5/qml
Documentation = share/doc/qt5
EOF
export QMAKE="$qtOut/bin/qmake"
envHooks+=(_qtLinkModule)
# Set PATH to find qmake first in a preConfigure hook
# It must run after all the envHooks!
postHooks+=(_qtSetQmakePath)
if [ -z "$dontUseQmakeConfigure" -a -z "$configurePhase" ]; then
configurePhase=qmakeConfigurePhase
fi
if [ -n "$NIX_QT_SUBMODULE" ]; then
postInstallHooks+=(_qtRmQmake _qtRmModules)
preFixupHooks+=(_qtModuleMultioutDevsPre)
postFixupHooks+=(_qtModuleMultioutDevsPost)
else
postInstallHooks+=(_qtRmQtOut)
fi
fi

View File

@ -253,12 +253,10 @@ stdenv.mkDerivation {
mv "''${!outputLib}/$file" "''${!outputDev}/$file"
done
popd
# Ensure that CMake can find the shared libraries
lndir -silent "''${!outputLib}/lib" "''${!outputDev}/lib"
fi
'';
inherit lndir;
setupHook = ./setup-hook.sh;
enableParallelBuilding = true;

View File

@ -50,3 +50,82 @@ if [[ -z "$NIX_QT_PIC" ]]; then
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE${NIX_CFLAGS_COMPILE:+ }-fPIC"
export NIX_QT_PIC=1
fi
_qtSetCMakePrefix() {
export CMAKE_PREFIX_PATH="$NIX_QT5_TMP${CMAKE_PREFIX_PATH:+:}${CMAKE_PREFIX_PATH}"
}
_qtRmTmp() {
if [ -z "$NIX_QT_SUBMODULE" ]; then
rm -fr "$NIX_QT5_TMP"
else
cat "$NIX_QT5_TMP/nix-support/qt-inputs" | while read file; do
if [ ! -d "$NIX_QT5_TMP/$file" ]; then
rm -f "$NIX_QT5_TMP/$file"
fi
done
cat "$NIX_QT5_TMP/nix-support/qt-inputs" | while read dir; do
if [ -d "$NIX_QT5_TMP/$dir" ]; then
rmdir --ignore-fail-on-non-empty -p "$NIX_QT5_TMP/$dir"
fi
done
rm "$NIX_QT5_TMP/nix-support/qt-inputs"
fi
}
_qtSetQmakePath() {
export PATH="$NIX_QT5_TMP/bin${PATH:+:}$PATH"
}
if [ -z "$NIX_QT5_TMP" ]; then
if [ -z "$NIX_QT_SUBMODULE" ]; then
NIX_QT5_TMP=$(mktemp -d)
else
NIX_QT5_TMP=$out
fi
postInstallHooks+=(_qtRmTmp)
mkdir -p "$NIX_QT5_TMP/nix-support"
for subdir in bin include lib mkspecs share; do
mkdir "$NIX_QT5_TMP/$subdir"
echo "$subdir/" >> "$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" <<EOF
[Paths]
Prefix = $NIX_QT5_TMP
Plugins = lib/qt5/plugins
Imports = lib/qt5/imports
Qml2Imports = lib/qt5/qml
Documentation = share/doc/qt5
EOF
echo "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"

View File

@ -0,0 +1,7 @@
qt5LinkModuleDir @out@ "lib"
qt5LinkModuleDir @dev@ "bin"
qt5LinkModuleDir @dev@ "include"
qt5LinkModuleDir @dev@ "lib"
qt5LinkModuleDir @dev@ "mkspecs"
qt5LinkModuleDir @dev@ "share"