Merge branch 'qt5-unify-setup-hook'

This commit is contained in:
Thomas Tuegel 2016-12-03 11:23:38 -06:00
commit 6a8a0b14e4
No known key found for this signature in database
GPG Key ID: 22CBF5249D4B4D59
18 changed files with 26 additions and 504 deletions

View File

@ -49,7 +49,7 @@ let
outputs = args.outputs or [ "out" "dev" ];
setOutputFlags = args.setOutputFlags or false;
setupHook = ./setup-hook.sh;
setupHook = ../qtsubmodule-setup-hook.sh;
enableParallelBuilding = args.enableParallelBuilding or true;
@ -112,8 +112,15 @@ let
qtxmlpatterns
];
makeQtWrapper = makeSetupHook { deps = [ makeWrapper ]; } ./make-qt-wrapper.sh;
qmakeHook = makeSetupHook { substitutions = { qt_dev = qtbase.dev; lndir = pkgs.xorg.lndir; }; } ./qmake-hook.sh;
makeQtWrapper =
makeSetupHook
{ deps = [ makeWrapper ]; }
../make-qt-wrapper.sh;
qmakeHook =
makeSetupHook
{ deps = [ self.qtbase.dev ]; }
../qmake-hook.sh;
};

View File

@ -272,7 +272,7 @@ stdenv.mkDerivation {
'';
inherit lndir;
setupHook = ./setup-hook.sh;
setupHook = ../../qtbase-setup-hook.sh;
enableParallelBuilding = true;

View File

@ -50,7 +50,7 @@ let
outputs = args.outputs or [ "out" "dev" ];
setOutputFlags = args.setOutputFlags or false;
setupHook = ./setup-hook.sh;
setupHook = ../qtsubmodule-setup-hook.sh;
enableParallelBuilding = args.enableParallelBuilding or true;
@ -109,8 +109,15 @@ let
qtwebchannel qtwebengine qtwebsockets qtx11extras qtxmlpatterns
];
makeQtWrapper = makeSetupHook { deps = [ makeWrapper ]; } ./make-qt-wrapper.sh;
qmakeHook = makeSetupHook { deps = [ self.qtbase.dev ]; } ./qmake-hook.sh;
makeQtWrapper =
makeSetupHook
{ deps = [ makeWrapper ]; }
../make-qt-wrapper.sh;
qmakeHook =
makeSetupHook
{ deps = [ self.qtbase.dev ]; }
../qmake-hook.sh;
};

View File

@ -1,36 +0,0 @@
wrapQtProgram() {
local prog="$1"
shift
wrapProgram "$prog" \
--set QT_PLUGIN_PATH "$QT_PLUGIN_PATH" \
--set QML_IMPORT_PATH "$QML_IMPORT_PATH" \
--set QML2_IMPORT_PATH "$QML2_IMPORT_PATH" \
--prefix XDG_DATA_DIRS : "$RUNTIME_XDG_DATA_DIRS" \
--prefix XDG_CONFIG_DIRS : "$RUNTIME_XDG_CONFIG_DIRS" \
"$@"
}
makeQtWrapper() {
local old="$1"
local new="$2"
shift
shift
makeWrapper "$old" "$new" \
--set QT_PLUGIN_PATH "$QT_PLUGIN_PATH" \
--set QML_IMPORT_PATH "$QML_IMPORT_PATH" \
--set QML2_IMPORT_PATH "$QML2_IMPORT_PATH" \
--prefix XDG_DATA_DIRS : "$RUNTIME_XDG_DATA_DIRS" \
--prefix XDG_CONFIG_DIRS : "$RUNTIME_XDG_CONFIG_DIRS" \
"$@"
}
_makeQtWrapperSetup() {
# cannot use addToSearchPath because these directories may not exist yet
export QT_PLUGIN_PATH="$QT_PLUGIN_PATH${QT_PLUGIN_PATH:+:}${!outputLib}/lib/qt5/plugins"
export QML_IMPORT_PATH="$QML_IMPORT_PATH${QML_IMPORT_PATH:+:}${!outputLib}/lib/qt5/imports"
export QML2_IMPORT_PATH="$QML2_IMPORT_PATH${QML2_IMPORT_PATH:+:}${!outputLib}/lib/qt5/qml"
export RUNTIME_XDG_DATA_DIRS="$XDG_DATA_DIRS${XDG_DATA_DIRS:+:}${!outputBin}/share"
export RUNTIME_XDG_CONFIG_DIRS="$XDG_CONFIG_DIRS${XDG_CONFIG_DIRS:+:}${!outputBin}/etc/xdg"
}
prePhases+=(_makeQtWrapperSetup)

View File

@ -1,42 +0,0 @@
qmakeConfigurePhase() {
runHook preConfigure
qmake PREFIX=$out $qmakeFlags
runHook postConfigure
}
if [ -z "$dontUseQmakeConfigure" -a -z "$configurePhase" ]; then
configurePhase=qmakeConfigurePhase
fi
_qtModuleMultioutDevsPre() {
# We cannot simply set these paths in configureFlags because libQtCore retains
# references to the paths it was built with.
moveToOutput "bin" "${!outputDev}"
moveToOutput "include" "${!outputDev}"
# The destination directory must exist or moveToOutput will do nothing
mkdir -p "${!outputDev}/share"
moveToOutput "share/doc" "${!outputDev}"
}
_qtModuleMultioutDevsPost() {
# Move libtool archives and qmake project files to $dev/lib
if [ "z${!outputLib}" != "z${!outputDev}" ]; then
pushd "${!outputLib}"
if [ -d "lib" ]; then
find lib \( -name '*.a' -o -name '*.la' -o -name '*.prl' \) -print0 | \
while read -r -d $'\0' file; do
mkdir -p "${!outputDev}/$(dirname "$file")"
mv "${!outputLib}/$file" "${!outputDev}/$file"
done
fi
popd
fi
}
if [ -n "$NIX_QT_SUBMODULE" ]; then
preFixupHooks+=(_qtModuleMultioutDevsPre)
postFixupHooks+=(_qtModuleMultioutDevsPost)
fi

View File

@ -228,7 +228,7 @@ stdenv.mkDerivation {
'';
inherit lndir;
setupHook = ./setup-hook.sh;
setupHook = ../../qtbase-setup-hook.sh;
enableParallelBuilding = true;

View File

@ -1,166 +0,0 @@
addToSearchPathOnceWithCustomDelimiter() {
local delim="$1"
local search="$2"
local target="$3"
local dirs
local exported
IFS="$delim" read -a dirs <<< "${!search}"
local canonical
if canonical=$(readlink -e "$target"); then
for dir in ${dirs[@]}; do
if [ "z$dir" == "z$canonical" ]; then exported=1; fi
done
if [ -z $exported ]; then
eval "export ${search}=\"${!search}${!search:+$delim}$canonical\""
fi
fi
}
addToSearchPathOnce() {
addToSearchPathOnceWithCustomDelimiter ':' "$@"
}
propagateOnce() {
addToSearchPathOnceWithCustomDelimiter ' ' "$@"
}
_qtPropagate() {
for dir in "lib/qt5/plugins" "lib/qt5/qml" "lib/qt5/imports"; do
if [ -d "$1/$dir" ]; then
propagateOnce propagatedBuildInputs "$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"
}
crossEnvHooks+=(_qtPropagate)
_qtPropagateNative() {
for dir in "lib/qt5/plugins" "lib/qt5/qml" "lib/qt5/imports"; do
if [ -d "$1/$dir" ]; then
propagateOnce propagatedNativeBuildInputs "$1"
break
fi
done
if [ -z "$crossConfig" ]; then
addToSearchPathOnce QT_PLUGIN_PATH "$1/lib/qt5/plugins"
addToSearchPathOnce QML_IMPORT_PATH "$1/lib/qt5/imports"
addToSearchPathOnce QML2_IMPORT_PATH "$1/lib/qt5/qml"
fi
}
envHooks+=(_qtPropagateNative)
_qtMultioutDevs() {
# This is necessary whether the package is a Qt module or not
moveToOutput "mkspecs" "${!outputDev}"
}
preFixupHooks+=(_qtMultioutDevs)
_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=$(pwd)/__nix_qt5__
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!
preConfigureHooks+=(_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
}
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

View File

@ -1,2 +0,0 @@
NIX_QT5_MODULES="${NIX_QT5_MODULES}${NIX_QT5_MODULES:+:}@out@"
NIX_QT5_MODULES_DEV="${NIX_QT5_MODULES_DEV}${NIX_QT5_MODULES_DEV:+:}@dev@"

View File

@ -50,7 +50,7 @@ let
outputs = args.outputs or [ "out" "dev" ];
setOutputFlags = args.setOutputFlags or false;
setupHook = ./setup-hook.sh;
setupHook = ../qtsubmodule-setup-hook.sh;
enableParallelBuilding = args.enableParallelBuilding or true;
@ -107,12 +107,12 @@ let
makeQtWrapper =
makeSetupHook
{ deps = [ makeWrapper ]; }
./make-qt-wrapper.sh;
../make-qt-wrapper.sh;
qmakeHook =
makeSetupHook
{ deps = [ self.qtbase.dev ]; }
./qmake-hook.sh;
../qmake-hook.sh;
};

View File

@ -1,36 +0,0 @@
wrapQtProgram() {
local prog="$1"
shift
wrapProgram "$prog" \
--set QT_PLUGIN_PATH "$QT_PLUGIN_PATH" \
--set QML_IMPORT_PATH "$QML_IMPORT_PATH" \
--set QML2_IMPORT_PATH "$QML2_IMPORT_PATH" \
--prefix XDG_DATA_DIRS : "$RUNTIME_XDG_DATA_DIRS" \
--prefix XDG_CONFIG_DIRS : "$RUNTIME_XDG_CONFIG_DIRS" \
"$@"
}
makeQtWrapper() {
local old="$1"
local new="$2"
shift
shift
makeWrapper "$old" "$new" \
--set QT_PLUGIN_PATH "$QT_PLUGIN_PATH" \
--set QML_IMPORT_PATH "$QML_IMPORT_PATH" \
--set QML2_IMPORT_PATH "$QML2_IMPORT_PATH" \
--prefix XDG_DATA_DIRS : "$RUNTIME_XDG_DATA_DIRS" \
--prefix XDG_CONFIG_DIRS : "$RUNTIME_XDG_CONFIG_DIRS" \
"$@"
}
_makeQtWrapperSetup() {
# cannot use addToSearchPath because these directories may not exist yet
export QT_PLUGIN_PATH="$QT_PLUGIN_PATH${QT_PLUGIN_PATH:+:}${!outputLib}/lib/qt5/plugins"
export QML_IMPORT_PATH="$QML_IMPORT_PATH${QML_IMPORT_PATH:+:}${!outputLib}/lib/qt5/imports"
export QML2_IMPORT_PATH="$QML2_IMPORT_PATH${QML2_IMPORT_PATH:+:}${!outputLib}/lib/qt5/qml"
export RUNTIME_XDG_DATA_DIRS="$XDG_DATA_DIRS${XDG_DATA_DIRS:+:}${!outputBin}/share"
export RUNTIME_XDG_CONFIG_DIRS="$XDG_CONFIG_DIRS${XDG_CONFIG_DIRS:+:}${!outputBin}/etc/xdg"
}
prePhases+=(_makeQtWrapperSetup)

View File

@ -1,42 +0,0 @@
qmakeConfigurePhase() {
runHook preConfigure
qmake PREFIX=$out $qmakeFlags
runHook postConfigure
}
if [ -z "$dontUseQmakeConfigure" -a -z "$configurePhase" ]; then
configurePhase=qmakeConfigurePhase
fi
_qtModuleMultioutDevsPre() {
# We cannot simply set these paths in configureFlags because libQtCore retains
# references to the paths it was built with.
moveToOutput "bin" "${!outputDev}"
moveToOutput "include" "${!outputDev}"
# The destination directory must exist or moveToOutput will do nothing
mkdir -p "${!outputDev}/share"
moveToOutput "share/doc" "${!outputDev}"
}
_qtModuleMultioutDevsPost() {
# Move libtool archives and qmake project files to $dev/lib
if [ "z${!outputLib}" != "z${!outputDev}" ]; then
pushd "${!outputLib}"
if [ -d "lib" ]; then
find lib \( -name '*.a' -o -name '*.la' -o -name '*.prl' \) -print0 | \
while read -r -d $'\0' file; do
mkdir -p "${!outputDev}/$(dirname "$file")"
mv "${!outputLib}/$file" "${!outputDev}/$file"
done
fi
popd
fi
}
if [ -n "$NIX_QT_SUBMODULE" ]; then
preFixupHooks+=(_qtModuleMultioutDevsPre)
postFixupHooks+=(_qtModuleMultioutDevsPost)
fi

View File

@ -232,7 +232,7 @@ stdenv.mkDerivation {
'';
inherit lndir;
setupHook = ./setup-hook.sh;
setupHook = ../../qtbase-setup-hook.sh;
enableParallelBuilding = true;

View File

@ -1,166 +0,0 @@
addToSearchPathOnceWithCustomDelimiter() {
local delim="$1"
local search="$2"
local target="$3"
local dirs
local exported
IFS="$delim" read -a dirs <<< "${!search}"
local canonical
if canonical=$(readlink -e "$target"); then
for dir in ${dirs[@]}; do
if [ "z$dir" == "z$canonical" ]; then exported=1; fi
done
if [ -z $exported ]; then
eval "export ${search}=\"${!search}${!search:+$delim}$canonical\""
fi
fi
}
addToSearchPathOnce() {
addToSearchPathOnceWithCustomDelimiter ':' "$@"
}
propagateOnce() {
addToSearchPathOnceWithCustomDelimiter ' ' "$@"
}
_qtPropagate() {
for dir in "lib/qt5/plugins" "lib/qt5/qml" "lib/qt5/imports"; do
if [ -d "$1/$dir" ]; then
propagateOnce propagatedBuildInputs "$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"
}
crossEnvHooks+=(_qtPropagate)
_qtPropagateNative() {
for dir in "lib/qt5/plugins" "lib/qt5/qml" "lib/qt5/imports"; do
if [ -d "$1/$dir" ]; then
propagateOnce propagatedNativeBuildInputs "$1"
break
fi
done
if [ -z "$crossConfig" ]; then
addToSearchPathOnce QT_PLUGIN_PATH "$1/lib/qt5/plugins"
addToSearchPathOnce QML_IMPORT_PATH "$1/lib/qt5/imports"
addToSearchPathOnce QML2_IMPORT_PATH "$1/lib/qt5/qml"
fi
}
envHooks+=(_qtPropagateNative)
_qtMultioutDevs() {
# This is necessary whether the package is a Qt module or not
moveToOutput "mkspecs" "${!outputDev}"
}
preFixupHooks+=(_qtMultioutDevs)
_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=$(pwd)/__nix_qt5__
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!
preConfigureHooks+=(_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
}
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

View File

@ -1,2 +0,0 @@
NIX_QT5_MODULES="${NIX_QT5_MODULES}${NIX_QT5_MODULES:+:}@out@"
NIX_QT5_MODULES_DEV="${NIX_QT5_MODULES_DEV}${NIX_QT5_MODULES_DEV:+:}@dev@"