diff options
author | Thomas Tuegel <ttuegel@mailbox.org> | 2021-01-26 16:24:41 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-26 16:24:41 -0600 |
commit | 0e418a1a18e14b0c6bc62554c0f4c4eff2e9d4e6 (patch) | |
tree | f99b33906ce1ef4ec91eeff358e65954bde1d21a /pkgs/development/libraries/qt-5 | |
parent | a3b529a4606779b8351cde31f9877496cc188f18 (diff) | |
parent | 13e3ec0d58a510742bb12f26d7c451ca4c94ce25 (diff) | |
download | nixpkgs-0e418a1a18e14b0c6bc62554c0f4c4eff2e9d4e6.tar nixpkgs-0e418a1a18e14b0c6bc62554c0f4c4eff2e9d4e6.tar.gz nixpkgs-0e418a1a18e14b0c6bc62554c0f4c4eff2e9d4e6.tar.bz2 nixpkgs-0e418a1a18e14b0c6bc62554c0f4c4eff2e9d4e6.tar.lz nixpkgs-0e418a1a18e14b0c6bc62554c0f4c4eff2e9d4e6.tar.xz nixpkgs-0e418a1a18e14b0c6bc62554c0f4c4eff2e9d4e6.tar.zst nixpkgs-0e418a1a18e14b0c6bc62554c0f4c4eff2e9d4e6.zip |
Merge pull request #108888 from ttuegel/feature--staging--qt-no-mkDerivation
Qt: Do not require mkDerivation
Diffstat (limited to 'pkgs/development/libraries/qt-5')
9 files changed, 75 insertions, 18 deletions
diff --git a/pkgs/development/libraries/qt-5/5.12/default.nix b/pkgs/development/libraries/qt-5/5.12/default.nix index cf5a0de11ad..e55b66d626a 100644 --- a/pkgs/development/libraries/qt-5/5.12/default.nix +++ b/pkgs/development/libraries/qt-5/5.12/default.nix @@ -145,7 +145,7 @@ let patches = patches.qtbase; inherit bison cups harfbuzz libGL; withGtk3 = true; inherit dconf gtk3; - inherit developerBuild decryptSslTraffic; + inherit debug developerBuild decryptSslTraffic; }; qtcharts = callPackage ../modules/qtcharts.nix {}; @@ -197,6 +197,7 @@ let qmake = makeSetupHook { deps = [ self.qtbase.dev ]; substitutions = { + inherit debug; fix_qmake_libtool = ../hooks/fix-qmake-libtool.sh; }; } ../hooks/qmake-hook.sh; diff --git a/pkgs/development/libraries/qt-5/5.14/default.nix b/pkgs/development/libraries/qt-5/5.14/default.nix index 7139a3b7354..7be50799275 100644 --- a/pkgs/development/libraries/qt-5/5.14/default.nix +++ b/pkgs/development/libraries/qt-5/5.14/default.nix @@ -149,7 +149,7 @@ let patches = patches.qtbase; inherit bison cups harfbuzz libGL; withGtk3 = true; inherit dconf gtk3; - inherit developerBuild decryptSslTraffic; + inherit debug developerBuild decryptSslTraffic; }; qtcharts = callPackage ../modules/qtcharts.nix {}; @@ -199,6 +199,7 @@ let qmake = makeSetupHook { deps = [ self.qtbase.dev ]; substitutions = { + inherit debug; fix_qmake_libtool = ../hooks/fix-qmake-libtool.sh; }; } ../hooks/qmake-hook.sh; diff --git a/pkgs/development/libraries/qt-5/5.15/default.nix b/pkgs/development/libraries/qt-5/5.15/default.nix index a3a0496f160..c3f6ab159c4 100644 --- a/pkgs/development/libraries/qt-5/5.15/default.nix +++ b/pkgs/development/libraries/qt-5/5.15/default.nix @@ -179,6 +179,7 @@ let qmake = makeSetupHook { deps = [ self.qtbase.dev ]; substitutions = { + inherit debug; fix_qmake_libtool = ../hooks/fix-qmake-libtool.sh; }; } ../hooks/qmake-hook.sh; diff --git a/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh b/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh index 7f6ddb76ad5..741225a5aa8 100644 --- a/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh +++ b/pkgs/development/libraries/qt-5/hooks/qmake-hook.sh @@ -3,6 +3,9 @@ qmakeFlags=( ${qmakeFlags-} ) qmakePrePhase() { + qmakeFlags_orig=( "${qmakeFlags[@]}" ) + + # These flags must be added _before_ the flags specified in the derivation. qmakeFlags=( \ "PREFIX=$out" \ "NIX_OUTPUT_OUT=$out" \ @@ -11,8 +14,15 @@ qmakePrePhase() { "NIX_OUTPUT_DOC=${!outputDev}/${qtDocPrefix:?}" \ "NIX_OUTPUT_QML=${!outputBin}/${qtQmlPrefix:?}" \ "NIX_OUTPUT_PLUGIN=${!outputBin}/${qtPluginPrefix:?}" \ - "${qmakeFlags[@]}" \ ) + + if [ -n "@debug@" ]; then + qmakeFlags+=( "CONFIG+=debug" ) + else + qmakeFlags+=( "CONFIG+=release" ) + fi + + qmakeFlags+=( "${qmakeFlags_orig[@]}" ) } prePhases+=" qmakePrePhase" diff --git a/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh index 9f2a9f06f1a..1b57d676e1f 100644 --- a/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh +++ b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh @@ -1,3 +1,14 @@ +if [[ -n "${__nix_qtbase-}" ]]; then + # Throw an error if a different version of Qt was already set up. + if [[ "$__nix_qtbase" != "@dev@" ]]; then + echo >&2 "Error: detected mismatched Qt dependencies:" + echo >&2 " @dev@" + echo >&2 " $__nix_qtbase" + exit 1 + fi +else # Only set up Qt once. +__nix_qtbase="@dev@" + qtPluginPrefix=@qtPluginPrefix@ qtQmlPrefix=@qtQmlPrefix@ qtDocPrefix=@qtDocPrefix@ @@ -5,6 +16,20 @@ qtDocPrefix=@qtDocPrefix@ . @fix_qt_builtin_paths@ . @fix_qt_module_paths@ +# Disable debug symbols if qtbase was built without debugging. +# This stops -dev paths from leaking into other outputs. +if [ -z "@debug@" ]; then + NIX_CFLAGS_COMPILE="${NIX_CFLAGS_COMPILE-}${NIX_CFLAGS_COMPILE:+ }-DQT_NO_DEBUG" +fi + +# Integration with CMake: +# Set the CMake build type corresponding to how qtbase was built. +if [ -n "@debug@" ]; then + cmakeBuildType="Debug" +else + cmakeBuildType="Release" +fi + providesQtRuntime() { [ -d "$1/$qtPluginPrefix" ] || [ -d "$1/$qtQmlPrefix" ] } @@ -19,7 +44,12 @@ export QMAKEPATH QMAKEMODULES= export QMAKEMODULES +declare -Ag qmakePathSeen=() qmakePathHook() { + # Skip this path if we have seen it before. + # MUST use 'if' because 'qmakePathSeen[$]' may be unset. + if [ -n "${qmakePathSeen[$1]-}" ]; then return; fi + qmakePathSeen[$1]=1 if [ -d "$1/mkspecs" ] then QMAKEMODULES="${QMAKEMODULES}${QMAKEMODULES:+:}/mkspecs" @@ -34,7 +64,12 @@ envBuildHostHooks+=(qmakePathHook) # package depending on the building package. (This is necessary in case # the building package does not provide runtime dependencies itself and so # would not be propagated to the user environment.) +declare -Ag qtEnvHostTargetSeen=() qtEnvHostTargetHook() { + # Skip this path if we have seen it before. + # MUST use 'if' because 'qmakePathSeen[$]' may be unset. + if [ -n "${qtEnvHostTargetSeen[$1]-}" ]; then return; fi + qtEnvHostTargetSeen[$1]=1 if providesQtRuntime "$1" && [ "z${!outputBin}" != "z${!outputDev}" ] then propagatedBuildInputs+=" $1" @@ -64,3 +99,14 @@ postPatchMkspecs() { if [ -z "${dontPatchMkspecs-}" ]; then postPhases="${postPhases-}${postPhases:+ }postPatchMkspecs" fi + +qtPreHook() { + # Check that wrapQtAppsHook is used, or it is explicitly disabled. + if [[ -z "$__nix_wrapQtAppsHook" && -z "$dontWrapQtApps" ]]; then + echo >&2 "Error: wrapQtAppsHook is not used, and dontWrapQtApps is not set." + exit 1 + fi +} +prePhases+=" qtPreHook" + +fi diff --git a/pkgs/development/libraries/qt-5/hooks/wrap-qt-apps-hook.sh b/pkgs/development/libraries/qt-5/hooks/wrap-qt-apps-hook.sh index 7356c8ee356..ce4d78fbb50 100644 --- a/pkgs/development/libraries/qt-5/hooks/wrap-qt-apps-hook.sh +++ b/pkgs/development/libraries/qt-5/hooks/wrap-qt-apps-hook.sh @@ -1,3 +1,6 @@ +if [[ -z "${__nix_wrapQtAppsHook-}" ]]; then +__nix_wrapQtAppsHook=1 # Don't run this hook more than once. + # Inherit arguments given in mkDerivation qtWrapperArgs=( ${qtWrapperArgs-} ) @@ -100,3 +103,5 @@ wrapQtAppsHook() { } fixupOutputHooks+=(wrapQtAppsHook) + +fi diff --git a/pkgs/development/libraries/qt-5/mkDerivation.nix b/pkgs/development/libraries/qt-5/mkDerivation.nix index 2c6333cb020..98f9a05fac7 100644 --- a/pkgs/development/libraries/qt-5/mkDerivation.nix +++ b/pkgs/development/libraries/qt-5/mkDerivation.nix @@ -9,21 +9,6 @@ args: let args_ = { - qmakeFlags = [ ("CONFIG+=" + (if debug then "debug" else "release")) ] - ++ (args.qmakeFlags or []); - - NIX_CFLAGS_COMPILE = toString ( - optional (!debug) "-DQT_NO_DEBUG" - ++ lib.toList (args.NIX_CFLAGS_COMPILE or [])); - - cmakeFlags = - (args.cmakeFlags or []) - ++ [ - ("-DCMAKE_BUILD_TYPE=" + (if debug then "Debug" else "Release")) - ]; - - enableParallelBuilding = args.enableParallelBuilding or true; - nativeBuildInputs = (args.nativeBuildInputs or []) ++ [ wrapQtAppsHook ]; }; diff --git a/pkgs/development/libraries/qt-5/modules/qtbase.nix b/pkgs/development/libraries/qt-5/modules/qtbase.nix index 24f1d6f81a2..0d0bef342b0 100644 --- a/pkgs/development/libraries/qt-5/modules/qtbase.nix +++ b/pkgs/development/libraries/qt-5/modules/qtbase.nix @@ -22,6 +22,7 @@ libGL, buildExamples ? false, buildTests ? false, + debug ? false, developerBuild ? false, decryptSslTraffic ? false }: @@ -33,12 +34,14 @@ let compareVersion = v: builtins.compareVersions version v; qmakeCacheName = if compareVersion "5.12.4" < 0 then ".qmake.cache" else ".qmake.stash"; + debugSymbols = debug || developerBuild; in stdenv.mkDerivation { name = "qtbase-${version}"; inherit qtCompatVersion src version; + debug = debugSymbols; propagatedBuildInputs = [ @@ -241,6 +244,7 @@ stdenv.mkDerivation { "-I" "${icu.dev}/include" "-pch" ] + ++ lib.optional debugSymbols "-debug" ++ lib.optionals (compareVersion "5.11.0" < 0) [ "-qml-debug" @@ -397,6 +401,8 @@ stdenv.mkDerivation { -e "/^host_bins=/ c host_bins=$dev/bin" ''; + dontStrip = debugSymbols; + setupHook = ../hooks/qtbase-setup-hook.sh; meta = with lib; { diff --git a/pkgs/development/libraries/qt-5/qtModule.nix b/pkgs/development/libraries/qt-5/qtModule.nix index 0481f000c6c..930ed9d67ba 100644 --- a/pkgs/development/libraries/qt-5/qtModule.nix +++ b/pkgs/development/libraries/qt-5/qtModule.nix @@ -34,6 +34,8 @@ mkDerivation (args // { fixQtBuiltinPaths . '*.pr?' ''; + dontWrapQtApps = args.dontWrapQtApps or true; + postFixup = '' if [ -d "''${!outputDev}/lib/pkgconfig" ]; then find "''${!outputDev}/lib/pkgconfig" -name '*.pc' | while read pc; do |