qt5: separate plugins from libraries

This commit is contained in:
Thomas Tuegel 2017-05-18 18:19:42 -05:00
parent 5a8295e596
commit 6fa41788be
No known key found for this signature in database
GPG Key ID: 22CBF5249D4B4D59
17 changed files with 172 additions and 139 deletions

View File

@ -50,10 +50,6 @@ let
outputs = args.outputs or [ "out" "dev" ]; outputs = args.outputs or [ "out" "dev" ];
propagatedUserEnvPkgs =
(args.propagatedUserEnvPkgs or [])
++ map getBin (args.propagatedBuildInputs or []);
qmakeFlags = qmakeFlags =
(args.qmakeFlags or []) (args.qmakeFlags or [])
++ optional (debug != null) ++ optional (debug != null)
@ -90,7 +86,13 @@ let
setupHook = ../qtsubmodule-setup-hook.sh; setupHook = ../qtsubmodule-setup-hook.sh;
meta = self.qtbase.meta // (args.meta or {}); meta = {
homepage = http://www.qt.io;
description = "A cross-platform application framework for C++";
license = with licenses; [ fdl13 gpl2 lgpl21 lgpl3 ];
maintainers = with maintainers; [ qknight ttuegel periklis ];
platforms = platforms.unix;
} // (args.meta or {});
}); });
addPackages = self: with self; addPackages = self: with self;

View File

@ -41,10 +41,6 @@ let
outputs = args.outputs or [ "out" "dev" ]; outputs = args.outputs or [ "out" "dev" ];
propagatedUserEnvPkgs =
(args.propagatedUserEnvPkgs or [])
++ map getBin (args.propagatedBuildInputs or []);
qmakeFlags = qmakeFlags =
(args.qmakeFlags or []) (args.qmakeFlags or [])
++ optional (debug != null) ++ optional (debug != null)
@ -81,7 +77,13 @@ let
setupHook = ../qtsubmodule-setup-hook.sh; setupHook = ../qtsubmodule-setup-hook.sh;
meta = self.qtbase.meta // (args.meta or {}); meta = {
homepage = http://www.qt.io;
description = "A cross-platform application framework for C++";
license = with licenses; [ fdl13 gpl2 lgpl21 lgpl3 ];
maintainers = with maintainers; [ qknight ttuegel periklis ];
platforms = platforms.unix;
} // (args.meta or {});
}); });
addPackages = self: with self; addPackages = self: with self;

View File

@ -76,7 +76,7 @@ stdenv.mkDerivation {
[ bison flex gperf lndir perl pkgconfig python2 ] [ bison flex gperf lndir perl pkgconfig python2 ]
++ lib.optional (!stdenv.isDarwin) patchelf; ++ lib.optional (!stdenv.isDarwin) patchelf;
outputs = [ "out" "dev" ]; outputs = [ "out" "dev" "bin" ];
patches = patches =
copyPathsToStore (lib.readPathsFromFile ./. ./series); copyPathsToStore (lib.readPathsFromFile ./. ./series);
@ -264,29 +264,32 @@ stdenv.mkDerivation {
enableParallelBuilding = true; enableParallelBuilding = true;
postInstall = '' postInstall =
find "$out" -name "*.cmake" | while read file; do # Hardcode some CMake module paths.
substituteInPlace "$file" \ ''
--subst-var-by NIX_OUT "$out" \ find "$out" -name "*.cmake" | while read file; do
--subst-var-by NIX_DEV "$dev" substituteInPlace "$file" \
done --subst-var-by NIX_OUT "$out" \
''; --subst-var-by NIX_DEV "$dev"
done
'';
preFixup = '' preFixup =
# We cannot simply set these paths in configureFlags because libQtCore retains # Move selected outputs.
# references to the paths it was built with. ''
moveToOutput "bin" "$dev" moveToOutput "bin" "$dev"
moveToOutput "include" "$dev" moveToOutput "include" "$dev"
moveToOutput "mkspecs" "$dev" moveToOutput "mkspecs" "$dev"
# The destination directory must exist or moveToOutput will do nothing mkdir -p "$dev/share"
mkdir -p "$dev/share" moveToOutput "share/doc" "$dev"
moveToOutput "share/doc" "$dev"
''; moveToOutput "$qtPluginPrefix" "$bin"
'';
postFixup = postFixup =
# Don't retain build-time dependencies like gdb.
'' ''
# Don't retain build-time dependencies like gdb.
sed '/QMAKE_DEFAULT_.*DIRS/ d' -i $dev/mkspecs/qconfig.pri sed '/QMAKE_DEFAULT_.*DIRS/ d' -i $dev/mkspecs/qconfig.pri
'' ''

View File

@ -3,4 +3,8 @@
qtSubmodule { qtSubmodule {
name = "qtconnectivity"; name = "qtconnectivity";
qtInputs = [ qtbase qtdeclarative ]; qtInputs = [ qtbase qtdeclarative ];
outputs = [ "out" "dev" "bin" ];
postInstall = ''
moveToOutput "$qtQmlPrefix" "$bin"
'';
} }

View File

@ -7,8 +7,14 @@ qtSubmodule {
patches = copyPathsToStore (readPathsFromFile ./. ./series); patches = copyPathsToStore (readPathsFromFile ./. ./series);
qtInputs = [ qtbase qtsvg qtxmlpatterns ]; qtInputs = [ qtbase qtsvg qtxmlpatterns ];
nativeBuildInputs = [ python2 ]; nativeBuildInputs = [ python2 ];
outputs = [ "out" "dev" "bin" ];
preConfigure = '' preConfigure = ''
NIX_CFLAGS_COMPILE+=" -DNIXPKGS_QML2_IMPORT_PREFIX=\"$qtQmlPrefix\"" NIX_CFLAGS_COMPILE+=" -DNIXPKGS_QML2_IMPORT_PREFIX=\"$qtQmlPrefix\""
''; '';
postInstall = ''
moveToOutput "$qtPluginPrefix" "$bin"
moveToOutput "$qtQmlPrefix" "$bin"
'';
} }

View File

@ -3,4 +3,5 @@
qtSubmodule { qtSubmodule {
name = "qtdoc"; name = "qtdoc";
qtInputs = [ qtdeclarative ]; qtInputs = [ qtdeclarative ];
outputs = [ "out" ];
} }

View File

@ -3,4 +3,9 @@
qtSubmodule { qtSubmodule {
name = "qtlocation"; name = "qtlocation";
qtInputs = [ qtbase qtmultimedia ]; qtInputs = [ qtbase qtmultimedia ];
outputs = [ "out" "dev" "bin" ];
postInstall = ''
moveToOutput "$qtPluginPrefix" "$bin"
moveToOutput "$qtQmlPrefix" "$bin"
'';
} }

View File

@ -10,6 +10,11 @@ qtSubmodule {
qtInputs = [ qtbase qtdeclarative ]; qtInputs = [ qtbase qtdeclarative ];
buildInputs = [ pkgconfig gstreamer gst-plugins-base libpulseaudio] buildInputs = [ pkgconfig gstreamer gst-plugins-base libpulseaudio]
++ optional (stdenv.isLinux) alsaLib; ++ optional (stdenv.isLinux) alsaLib;
outputs = [ "out" "dev" "bin" ];
qmakeFlags = [ "GST_VERSION=1.0" ]; qmakeFlags = [ "GST_VERSION=1.0" ];
NIX_LDFLAGS = optionalString (stdenv.isDarwin) "-lobjc"; NIX_LDFLAGS = optionalString (stdenv.isDarwin) "-lobjc";
postInstall = ''
moveToOutput "$qtPluginPrefix" "$bin"
moveToOutput "$qtQmlPrefix" "$bin"
'';
} }

View File

@ -3,4 +3,8 @@
qtSubmodule { qtSubmodule {
name = "qtquickcontrols2"; name = "qtquickcontrols2";
qtInputs = [ qtdeclarative ]; qtInputs = [ qtdeclarative ];
outputs = [ "out" "dev" "bin" ];
postInstall = ''
moveToOutput "$qtQmlPrefix" "$bin"
'';
} }

View File

@ -5,4 +5,9 @@ with stdenv.lib;
qtSubmodule { qtSubmodule {
name = "qtsensors"; name = "qtsensors";
qtInputs = [ qtbase qtdeclarative ]; qtInputs = [ qtbase qtdeclarative ];
outputs = [ "out" "dev" "bin" ];
postInstall = ''
moveToOutput "$qtPluginPrefix" "$bin"
moveToOutput "$qtQmlPrefix" "$bin"
'';
} }

View File

@ -3,4 +3,8 @@
qtSubmodule { qtSubmodule {
name = "qtsvg"; name = "qtsvg";
qtInputs = [ qtbase ]; qtInputs = [ qtbase ];
outputs = [ "out" "dev" "bin" ];
postInstall = ''
moveToOutput "$qtPluginPrefix" "$bin"
'';
} }

View File

@ -5,10 +5,10 @@ with stdenv.lib;
qtSubmodule { qtSubmodule {
name = "qttools"; name = "qttools";
qtInputs = [ qtbase ]; qtInputs = [ qtbase ];
outputs = [ "out" "dev" "bin" ];
patches = copyPathsToStore (readPathsFromFile ./. ./series); patches = copyPathsToStore (readPathsFromFile ./. ./series);
postFixup = '' postInstall = ''
moveToOutput "bin/qdbus" "$out" moveToOutput "bin/qdbus" "$bin"
moveToOutput "bin/qtpaths" "$out" moveToOutput "bin/qtpaths" "$bin"
''; '';
} }

View File

@ -5,4 +5,9 @@ qtSubmodule {
qtInputs = [ qtbase qtquickcontrols ]; qtInputs = [ qtbase qtquickcontrols ];
buildInputs = [ wayland ]; buildInputs = [ wayland ];
nativeBuildInputs = [ pkgconfig ]; nativeBuildInputs = [ pkgconfig ];
outputs = [ "out" "dev" "bin" ];
postInstall = ''
moveToOutput "$qtPluginPrefix" "$bin"
moveToOutput "$qtQmlPrefix "$bin"
'';
} }

View File

@ -3,5 +3,9 @@
qtSubmodule { qtSubmodule {
name = "qtwebchannel"; name = "qtwebchannel";
qtInputs = [ qtbase qtdeclarative ]; qtInputs = [ qtbase qtdeclarative ];
outputs = [ "out" "dev" "bin" ];
postInstall = ''
moveToOutput "$qtQmlPrefix" "$bin"
'';
} }

View File

@ -25,6 +25,7 @@ qtSubmodule {
buildInputs = [ bison flex git which gperf ]; buildInputs = [ bison flex git which gperf ];
nativeBuildInputs = [ pkgconfig python2 coreutils ]; nativeBuildInputs = [ pkgconfig python2 coreutils ];
doCheck = true; doCheck = true;
outputs = [ "out" "dev" "bin" ];
enableParallelBuilding = true; enableParallelBuilding = true;
@ -90,5 +91,7 @@ qtSubmodule {
EOF EOF
paxmark m $out/libexec/QtWebEngineProcess paxmark m $out/libexec/QtWebEngineProcess
moveToOutput "$qtQmlPrefix" "$bin"
''; '';
} }

View File

@ -3,4 +3,8 @@
qtSubmodule { qtSubmodule {
name = "qtwebsockets"; name = "qtwebsockets";
qtInputs = [ qtbase qtdeclarative ]; qtInputs = [ qtbase qtdeclarative ];
outputs = [ "out" "dev" "bin" ];
postInstall = ''
moveToOutput "$qtQmlPrefix" "$bin"
'';
} }

View File

@ -2,72 +2,54 @@ qtPluginPrefix=@qtPluginPrefix@
qtQmlPrefix=@qtQmlPrefix@ qtQmlPrefix=@qtQmlPrefix@
qtDocPrefix=@qtDocPrefix@ qtDocPrefix=@qtDocPrefix@
addToSearchPathOnceWithCustomDelimiter() { NIX_QT5_MODULES="${NIX_QT5_MODULES}${NIX_QT5_MODULES:+:}@out@"
local delim="$1" NIX_QT5_MODULES_DEV="${NIX_QT5_MODULES_DEV}${NIX_QT5_MODULES_DEV:+:}@dev@"
local search="$2"
local target="$3" providesQtRuntime() {
local dirs [ -d "$1/$qtPluginPrefix" ] || [ -d "$1/$qtQmlPrefix" ]
local exported }
IFS="$delim" read -a dirs <<< "${!search}"
local canonical # Propagate any runtime dependency of the building package.
if canonical=$(readlink -e "$target"); then # Each dependency is propagated to the user environment and as a build
for dir in ${dirs[@]}; do # input so that it will be re-propagated to the user environment by any
if [ "z$dir" == "z$canonical" ]; then exported=1; fi # package depending on the building package. (This is necessary in case
done # the building package does not provide runtime dependencies itself and so
if [ -z $exported ]; then # would not be propagated to the user environment.)
eval "export ${search}=\"${!search}${!search:+$delim}$canonical\"" _qtCrossEnvHook() {
if providesQtRuntime "$1"; then
propagatedBuildInputs+=" $1"
propagatedUserEnvPkgs+=" $1"
fi
}
if [ -z "$NIX_QT5_TMP" ]; then
crossEnvHooks+=(_qtCrossEnvHook)
fi
_qtEnvHook() {
if providesQtRuntime "$1"; then
propagatedNativeBuildInputs+=" $1"
if [ -z "$crossConfig" ]; then
propagatedUserEnvPkgs+=" $1"
fi fi
fi fi
} }
if [ -z "$NIX_QT5_TMP" ]; then
envHooks+=(_qtEnvHook)
fi
addToSearchPathOnce() { _qtPreFixupHook() {
addToSearchPathOnceWithCustomDelimiter ':' "$@"
}
propagateOnce() {
addToSearchPathOnceWithCustomDelimiter ' ' "$@"
}
_qtPropagate() {
for dir in $qtPluginPrefix $qtQmlPrefix; do
if [ -d "$1/$dir" ]; then
propagateOnce propagatedBuildInputs "$1"
break
fi
done
addToSearchPathOnce QT_PLUGIN_PATH "$1/$qtPluginPrefix"
addToSearchPathOnce QML2_IMPORT_PATH "$1/$qtQmlPrefix"
}
crossEnvHooks+=(_qtPropagate)
_qtPropagateNative() {
for dir in $qtPluginPrefix $qtQmlPrefix; do
if [ -d "$1/$dir" ]; then
propagateOnce propagatedNativeBuildInputs "$1"
break
fi
done
if [ -z "$crossConfig" ]; then
addToSearchPathOnce QT_PLUGIN_PATH "$1/$qtPluginPrefix"
addToSearchPathOnce QML2_IMPORT_PATH "$1/$qtQmlPrefix"
fi
}
envHooks+=(_qtPropagateNative)
_qtMultioutDevs() {
# This is necessary whether the package is a Qt module or not
moveToOutput "mkspecs" "${!outputDev}" moveToOutput "mkspecs" "${!outputDev}"
} }
if [ -z "$NIX_QT5_TMP" ]; then
preFixupHooks+=(_qtPreFixupHook)
fi
preFixupHooks+=(_qtMultioutDevs) _qtPostInstallHook() {
# Clean up temporary installation files created by this setup hook.
_qtSetCMakePrefix() { # For building Qt modules, this is necessary to prevent including
export CMAKE_PREFIX_PATH="$NIX_QT5_TMP${CMAKE_PREFIX_PATH:+:}${CMAKE_PREFIX_PATH}" # dependencies in the output. For all other packages, this is necessary
} # to induce patchelf to remove the temporary paths from the RPATH of
# dynamically-linked objects.
_qtRmTmp() {
if [ -z "$NIX_QT_SUBMODULE" ]; then if [ -z "$NIX_QT_SUBMODULE" ]; then
rm -fr "$NIX_QT5_TMP" rm -fr "$NIX_QT5_TMP"
else else
@ -85,11 +67,51 @@ _qtRmTmp() {
rm "$NIX_QT5_TMP/nix-support/qt-inputs" rm "$NIX_QT5_TMP/nix-support/qt-inputs"
fi fi
# Patch CMake modules
if [ -n "$NIX_QT_SUBMODULE" ]; then
find "${!outputLib}" -name "*.cmake" | while read file; do
substituteInPlace "$file" \
--subst-var-by NIX_OUT "${!outputLib}" \
--subst-var-by NIX_DEV "${!outputDev}"
done
fi
}
if [ -z "$NIX_QT5_TMP" ]; then
preConfigureHooks+=(_qtPreConfigureHook)
fi
_qtLinkModuleDir() {
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
} }
_qtSetQmakePath() { _qtPreConfigureHook() {
# Find the temporary qmake executable first.
# This must run after all the environment hooks!
export PATH="$NIX_QT5_TMP/bin${PATH:+:}$PATH" export PATH="$NIX_QT5_TMP/bin${PATH:+:}$PATH"
# Link all runtime module dependencies into the temporary directory.
IFS=: read -a modules <<< $NIX_QT5_MODULES
for module in ${modules[@]}; do
_qtLinkModuleDir "$module" "lib"
done
# Link all the build-time module dependencies into the temporary directory.
IFS=: read -a modules <<< $NIX_QT5_MODULES_DEV
for module in ${modules[@]}; do
_qtLinkModuleDir "$module" "bin"
_qtLinkModuleDir "$module" "include"
_qtLinkModuleDir "$module" "lib"
_qtLinkModuleDir "$module" "mkspecs"
_qtLinkModuleDir "$module" "share"
done
} }
if [ -z "$NIX_QT5_TMP" ]; then
postInstallHooks+=(_qtPostInstallHook)
fi
if [ -z "$NIX_QT5_TMP" ]; then if [ -z "$NIX_QT5_TMP" ]; then
if [ -z "$NIX_QT_SUBMODULE" ]; then if [ -z "$NIX_QT_SUBMODULE" ]; then
@ -97,7 +119,6 @@ if [ -z "$NIX_QT5_TMP" ]; then
else else
NIX_QT5_TMP=$out NIX_QT5_TMP=$out
fi fi
postInstallHooks+=(_qtRmTmp)
mkdir -p "$NIX_QT5_TMP/nix-support" mkdir -p "$NIX_QT5_TMP/nix-support"
for subdir in bin include lib mkspecs share; do for subdir in bin include lib mkspecs share; do
@ -105,8 +126,6 @@ if [ -z "$NIX_QT5_TMP" ]; then
echo "$subdir/" >> "$NIX_QT5_TMP/nix-support/qt-inputs" echo "$subdir/" >> "$NIX_QT5_TMP/nix-support/qt-inputs"
done done
postHooks+=(_qtSetCMakePrefix)
cp "@dev@/bin/qmake" "$NIX_QT5_TMP/bin" cp "@dev@/bin/qmake" "$NIX_QT5_TMP/bin"
echo "bin/qmake" >> "$NIX_QT5_TMP/nix-support/qt-inputs" echo "bin/qmake" >> "$NIX_QT5_TMP/nix-support/qt-inputs"
@ -120,48 +139,5 @@ EOF
echo "bin/qt.conf" >> "$NIX_QT5_TMP/nix-support/qt-inputs" echo "bin/qt.conf" >> "$NIX_QT5_TMP/nix-support/qt-inputs"
export QMAKE="$NIX_QT5_TMP/bin/qmake" export QMAKE="$NIX_QT5_TMP/bin/qmake"
# Set PATH to find qmake first in a preConfigure hook
# It must run after all the envHooks!
preConfigureHooks+=(_qtSetQmakePath)
fi 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
}
NIX_QT5_MODULES="${NIX_QT5_MODULES}${NIX_QT5_MODULES:+:}@out@"
NIX_QT5_MODULES_DEV="${NIX_QT5_MODULES_DEV}${NIX_QT5_MODULES_DEV:+:}@dev@"
_qtLinkAllModules() {
IFS=: read -a modules <<< $NIX_QT5_MODULES
for module in ${modules[@]}; do
qt5LinkModuleDir "$module" "lib"
done
IFS=: read -a modules <<< $NIX_QT5_MODULES_DEV
for module in ${modules[@]}; do
qt5LinkModuleDir "$module" "bin"
qt5LinkModuleDir "$module" "include"
qt5LinkModuleDir "$module" "lib"
qt5LinkModuleDir "$module" "mkspecs"
qt5LinkModuleDir "$module" "share"
done
}
preConfigureHooks+=(_qtLinkAllModules)
_qtFixCMakePaths() {
find "${!outputLib}" -name "*.cmake" | while read file; do
substituteInPlace "$file" \
--subst-var-by NIX_OUT "${!outputLib}" \
--subst-var-by NIX_DEV "${!outputDev}"
done
}
if [ -n "$NIX_QT_SUBMODULE" ]; then
postInstallHooks+=(_qtFixCMakePaths)
fi