qt54: use multiple outputs
This commit is contained in:
parent
d8a08fff90
commit
0055c6aa94
@ -43,6 +43,9 @@ let
|
|||||||
dontFixLibtool = args.dontFixLibtool or true;
|
dontFixLibtool = args.dontFixLibtool or true;
|
||||||
configureScript = args.configureScript or "qmake";
|
configureScript = args.configureScript or "qmake";
|
||||||
|
|
||||||
|
outputs = args.outputs or [ "dev" "out" ];
|
||||||
|
setOutputFlags = false;
|
||||||
|
|
||||||
enableParallelBuilding = args.enableParallelBuilding or true;
|
enableParallelBuilding = args.enableParallelBuilding or true;
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
|
@ -36,6 +36,8 @@ stdenv.mkDerivation {
|
|||||||
|
|
||||||
sourceRoot = "qt-everywhere-opensource-src-${version}";
|
sourceRoot = "qt-everywhere-opensource-src-${version}";
|
||||||
|
|
||||||
|
outputs = [ "dev" "out" ];
|
||||||
|
|
||||||
postUnpack = ''
|
postUnpack = ''
|
||||||
mv qtbase-opensource-src-${version} ./qt-everywhere-opensource-src-${version}/qtbase
|
mv qtbase-opensource-src-${version} ./qt-everywhere-opensource-src-${version}/qtbase
|
||||||
'';
|
'';
|
||||||
@ -93,15 +95,34 @@ stdenv.mkDerivation {
|
|||||||
--replace "@mesa_inc@" "${mesa.dev}"
|
--replace "@mesa_inc@" "${mesa.dev}"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
setOutputFlags = false;
|
||||||
preConfigure = ''
|
preConfigure = ''
|
||||||
export LD_LIBRARY_PATH="$PWD/qtbase/lib:$PWD/qtbase/plugins/platforms:$LD_LIBRARY_PATH"
|
export LD_LIBRARY_PATH="$PWD/qtbase/lib:$PWD/qtbase/plugins/platforms:$LD_LIBRARY_PATH"
|
||||||
export MAKEFLAGS=-j$NIX_BUILD_CORES
|
export MAKEFLAGS=-j$NIX_BUILD_CORES
|
||||||
|
|
||||||
configureFlags+=" -plugindir $out/lib/qt5/plugins"
|
_multioutQtDevs() {
|
||||||
configureFlags+=" -importdir $out/lib/qt5/imports"
|
# We cannot simply set these paths in configureFlags because libQtCore retains
|
||||||
configureFlags+=" -qmldir $out/lib/qt5/qml"
|
# references to the paths it was built with.
|
||||||
configureFlags+=" -docdir $out/share/doc/qt5"
|
moveToOutput "bin" "$dev"
|
||||||
export configureFlags
|
moveToOutput "include" "$dev"
|
||||||
|
moveToOutput "mkspecs" "$dev"
|
||||||
|
|
||||||
|
# The destination directory must exist or moveToOutput will do nothing
|
||||||
|
mkdir -p "$dev/share"
|
||||||
|
moveToOutput "share/doc" "$dev"
|
||||||
|
|
||||||
|
mkdir -p "$dev/lib"
|
||||||
|
lndir -silent "$out/lib" "$dev/lib"
|
||||||
|
if [[ -h "$dev/lib/cmake" ]]; then rm "$dev/lib/cmake"; fi
|
||||||
|
if [[ -h "$dev/lib/pkgconfig" ]]; then rm "$dev/lib/pkgconfig"; fi
|
||||||
|
}
|
||||||
|
preFixupHooks+=(_multioutQtDevs)
|
||||||
|
|
||||||
|
configureFlags+="\
|
||||||
|
-plugindir $out/lib/qt5/plugins \
|
||||||
|
-importdir $out/lib/qt5/imports \
|
||||||
|
-qmldir $out/lib/qt5/qml \
|
||||||
|
-docdir $out/share/doc/qt5"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
prefixKey = "-prefix ";
|
prefixKey = "-prefix ";
|
||||||
@ -194,15 +215,15 @@ stdenv.mkDerivation {
|
|||||||
++ lib.optional (postgresql != null) postgresql
|
++ lib.optional (postgresql != null) postgresql
|
||||||
++ lib.optionals gtkStyle [gnome_vfs libgnomeui gtk GConf];
|
++ lib.optionals gtkStyle [gnome_vfs libgnomeui gtk GConf];
|
||||||
|
|
||||||
nativeBuildInputs = [ python perl pkgconfig ];
|
nativeBuildInputs = [ lndir python perl pkgconfig ];
|
||||||
|
|
||||||
# freetype-2.5.4 changed signedness of some struct fields
|
# freetype-2.5.4 changed signedness of some struct fields
|
||||||
NIX_CFLAGS_COMPILE = "-Wno-error=sign-compare";
|
NIX_CFLAGS_COMPILE = "-Wno-error=sign-compare";
|
||||||
|
|
||||||
postInstall =
|
postFixup =
|
||||||
''
|
''
|
||||||
# Don't retain build-time dependencies like gdb and ruby.
|
# Don't retain build-time dependencies like gdb and ruby.
|
||||||
sed '/QMAKE_DEFAULT_.*DIRS/ d' -i $out/mkspecs/qconfig.pri
|
sed '/QMAKE_DEFAULT_.*DIRS/ d' -i "$dev/mkspecs/qconfig.pri"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
inherit lndir;
|
inherit lndir;
|
||||||
|
@ -1,45 +1,26 @@
|
|||||||
if [[ -z "$QMAKE" ]]; then
|
if [[ -z "$QMAKE" ]]; then
|
||||||
|
|
||||||
linkDependencyDir() {
|
_qtLinkDependencyDir() {
|
||||||
@lndir@/bin/lndir -silent "$1/$2" "$qtOut/$2"
|
@lndir@/bin/lndir -silent "$1/$2" "$qtOut/$2"
|
||||||
if [[ -n "$NIX_QT_SUBMODULE" ]]; then
|
if [[ -n "$NIX_QT_SUBMODULE" ]]; then
|
||||||
find "$1/$2" -printf "$2/%P\n" >> "$out/nix-support/qt-inputs"
|
find "$1/$2" -printf "$2/%P\n" >> "$out/nix-support/qt-inputs"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
addQtModule() {
|
_qtLinkModule() {
|
||||||
if [[ -d "$1/mkspecs" ]]; then
|
if [ -d "$1/mkspecs" ]; then
|
||||||
# $1 is a Qt module
|
# $1 is a Qt module
|
||||||
linkDependencyDir "$1" mkspecs
|
_qtLinkDependencyDir "$1" mkspecs
|
||||||
|
|
||||||
for dir in bin include lib share; do
|
for dir in bin include lib share; do
|
||||||
if [[ -d "$1/$dir" ]]; then
|
if [ -d "$1/$dir" ]; then
|
||||||
linkDependencyDir "$1" "$dir"
|
_qtLinkDependencyDir "$1" "$dir"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
propagateRuntimeDeps() {
|
_qtRmModules() {
|
||||||
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() {
|
|
||||||
cat "$out/nix-support/qt-inputs" | while read file; do
|
cat "$out/nix-support/qt-inputs" | while read file; do
|
||||||
if [[ -h "$out/$file" ]]; then
|
if [[ -h "$out/$file" ]]; then
|
||||||
rm "$out/$file"
|
rm "$out/$file"
|
||||||
@ -55,14 +36,65 @@ rmQtModules() {
|
|||||||
rm "$out/nix-support/qt-inputs"
|
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"
|
||||||
|
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"
|
rm "$qtOut/bin/qmake" "$qtOut/bin/qt.conf"
|
||||||
}
|
}
|
||||||
|
|
||||||
setQMakePath() {
|
_qtSetQmakePath() {
|
||||||
export PATH="$qtOut/bin${PATH:+:}$PATH"
|
export PATH="$qtOut/bin${PATH:+:}$PATH"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_qtMultioutModuleDevs() {
|
||||||
|
# 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}"
|
||||||
|
}
|
||||||
|
|
||||||
|
_qtMultioutDevs() {
|
||||||
|
# This is necessary whether the package is a Qt module or not
|
||||||
|
moveToOutput "mkspecs" "${!outputDev}"
|
||||||
|
}
|
||||||
|
|
||||||
qtOut=""
|
qtOut=""
|
||||||
if [[ -z "$NIX_QT_SUBMODULE" ]]; then
|
if [[ -z "$NIX_QT_SUBMODULE" ]]; then
|
||||||
qtOut=`mktemp -d`
|
qtOut=`mktemp -d`
|
||||||
@ -72,7 +104,7 @@ fi
|
|||||||
|
|
||||||
mkdir -p "$qtOut/bin" "$qtOut/mkspecs" "$qtOut/include" "$qtOut/nix-support" "$qtOut/lib" "$qtOut/share"
|
mkdir -p "$qtOut/bin" "$qtOut/mkspecs" "$qtOut/include" "$qtOut/nix-support" "$qtOut/lib" "$qtOut/share"
|
||||||
|
|
||||||
cp "@out@/bin/qmake" "$qtOut/bin"
|
cp "@dev@/bin/qmake" "$qtOut/bin"
|
||||||
cat >"$qtOut/bin/qt.conf" <<EOF
|
cat >"$qtOut/bin/qt.conf" <<EOF
|
||||||
[Paths]
|
[Paths]
|
||||||
Prefix = $qtOut
|
Prefix = $qtOut
|
||||||
@ -84,17 +116,20 @@ EOF
|
|||||||
|
|
||||||
export QMAKE="$qtOut/bin/qmake"
|
export QMAKE="$qtOut/bin/qmake"
|
||||||
|
|
||||||
envHooks+=(addQtModule propagateRuntimeDeps)
|
envHooks+=(_qtLinkModule _qtPropagateRuntimeDependencies)
|
||||||
preConfigurePhases+=(setQMakePath)
|
# Set PATH to find qmake first in a preConfigure hook
|
||||||
|
# It must run after all the envHooks!
|
||||||
|
preConfigureHooks+=(_qtSetQmakePath)
|
||||||
|
|
||||||
|
preFixupHooks+=(_qtMultioutDevs)
|
||||||
if [[ -n "$NIX_QT_SUBMODULE" ]]; then
|
if [[ -n "$NIX_QT_SUBMODULE" ]]; then
|
||||||
preFixupPhases+=(rmQtModules)
|
postInstallHooks+=(_qtRmQmake _qtRmModules)
|
||||||
postPhases+=(rmQMake)
|
preFixupHooks+=(_qtMultioutModuleDevs)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$NIX_QT_PIC" ]]; then
|
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
|
export NIX_QT_PIC=1
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user