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.
This commit is contained in:
Thomas Tuegel 2016-01-27 20:05:40 -06:00
parent f6e87370fb
commit 9065ab0c8a
7 changed files with 94 additions and 108 deletions

View File

@ -1,37 +1,37 @@
_propagateMimeTypes() {
if [ -d "$1/share/mime" ]; then
propagateOnce propagatedUserEnvPkgs "$1"
addToSearchPathOnce XDG_DATA_DIRS "$1/share"
fi
_ecmSetXdgDirs() {
addToSearchPathOnce XDG_DATA_DIRS "$1/share"
addToSearchPathOnce XDG_CONFIG_DIRS "$1/etc/xdg"
addToSearchPathOnce NIX_WRAP_XDG_CONFIG_DIRS "$1/etc/xdg"
}
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
_ecmPropagateSharedData() {
local sharedPaths=( \
"config.cfg" \
"doc" \
"kconf_update" \
"kservices5" \
"kservicetypes5" \
"kxmlgui5" \
"knotifications5" \
"icons" \
"sounds" \
"templates" \
"wallpapers" \
"applications" \
"desktop-directories" \
"mime" \
"info" \
"dbus-1" \
"interfaces" \
"services" \
"system-services" )
for dir in ${sharedPaths[@]}; do
if [ -d "$1/share/$dir" ]; then
addToSearchPathOnce NIX_WRAP_XDG_DATA_DIRS "$1/share"
propagateOnce propagatedUserEnvPkgs "$1"
break
fi
done
if [ -z $exported ]; then
eval "export ${search}=\"${!search}${!search:+$delim}$target\""
fi
}
addToSearchPathOnce() {
addToSearchPathOnceWithCustomDelimiter ':' "$@"
}
propagateOnce() {
addToSearchPathOnceWithCustomDelimiter ' ' "$@"
}
_exportLocales() {
if [[ -d "$1/share/locale" ]]; then
addToSearchPathOnce XDG_DATA_DIRS "$1/share"
fi
}
_ecmConfig() {
@ -69,13 +69,13 @@ _ecmConfig() {
cmakeFlags+=" -DKDE_INSTALL_MANDIR=${!outputLib}/share/man"
cmakeFlags+=" -DKDE_INSTALL_INFODIR=${!outputLib}/share/info"
cmakeFlags+=" -DKDE_INSTALL_DBUSDIR=${!outputLib}/share/dbus-1"
cmakeFlags+=" -DKDE_INSTALL_DBUSINTERFACEDIR=${!outputLib}/share/interfaces"
cmakeFlags+=" -DKDE_INSTALL_DBUSSERVICEDIR=${!outputLib}/share/services"
cmakeFlags+=" -DKDE_INSTALL_DBUSSYSTEMSERVICEDIR=${!outputLib}/share/system-services"
cmakeFlags+=" -DKDE_INSTALL_DBUSINTERFACEDIR=${!outputLib}/share/dbus-1/interfaces"
cmakeFlags+=" -DKDE_INSTALL_DBUSSERVICEDIR=${!outputLib}/share/dbus-1/services"
cmakeFlags+=" -DKDE_INSTALL_DBUSSYSTEMSERVICEDIR=${!outputLib}/share/dbus-1/system-services"
cmakeFlags+=" -DKDE_INSTALL_SYSCONFDIR=${!outputLib}/etc"
cmakeFlags+=" -DKDE_INSTALL_CONFDIR=${!outputLib}/etc/xdg"
cmakeFlags+=" -DKDE_INSTALL_AUTOSTARTDIR=${!outputLib}/etc/xdg/autostart"
}
envHooks+=(_propagateMimeTypes _exportLocales)
envHooks+=(_ecmSetXdgDirs _ecmPropagateSharedData)
preConfigureHooks+=(_ecmConfig)

View File

@ -4,7 +4,6 @@
kdeFramework {
name = "kdoctools";
setupHook = ./setup-hook.sh;
nativeBuildInputs = [ extra-cmake-modules ];
buildInputs = [ karchive ];
propagatedBuildInputs = [ ki18n ];

View File

@ -1,5 +0,0 @@
addXdgData() {
addToSearchPath XDG_DATA_DIRS "$1/share"
}
envHooks+=(addXdgData)

View File

@ -4,7 +4,6 @@
kdeFramework {
name = "kservice";
setupHook = ./setup-hook.sh;
propagatedNativeBuildInputs = [ extra-cmake-modules ];
nativeBuildInputs = [ kdoctools ];
buildInputs = [ kcrash kdbusaddons ];

View File

@ -1,17 +0,0 @@
_propagateServices() {
if [ -d "$1/share/kservices5" ]; then
propagateOnce propagatedUserEnvPkgs "$1"
addToSearchPathOnce XDG_DATA_DIRS "$1/share"
fi
}
_propagateServiceTypes() {
if [ -d "$1/share/kservicetypes5" ]; then
propagateOnce propagatedUserEnvPkgs "$1"
addToSearchPathOnce XDG_DATA_DIRS "$1/share"
fi
}
envHooks+=(_propagateServices _propagateServiceTypes)
propagateOnce propagatedBuildInputs "@out@"

View File

@ -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"

View File

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