Unverified Commit 5de59129 authored by Weijia Wang's avatar Weijia Wang Committed by GitHub
Browse files

Merge pull request #226018 from NickCao/qt6-rework

qt6: rework packaging of qt modules (part 2)
parents ed0f4567 a1a3813f
Loading
Loading
Loading
Loading
+6 −10
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@
, fetchpatch
, makeSetupHook
, makeWrapper
, cmake
, gst_all_1
, libglvnd
, darwin
@@ -27,11 +26,6 @@ let
      callPackage = self.newScope ({
        inherit qtModule srcs;
        stdenv = if stdenv.isDarwin then darwin.apple_sdk_11_0.stdenv else stdenv;
        cmake = cmake.overrideAttrs (attrs: {
          patches = attrs.patches ++ [
            ./patches/cmake.patch
          ];
        });
      });
    in
    {
@@ -46,10 +40,12 @@ let
        inherit developerBuild;
        inherit (darwin.apple_sdk_11_0.frameworks) AGL AVFoundation AppKit GSS MetalKit;
        patches = [
          ./patches/qtbase-qmake-mkspecs-mac.patch
          ./patches/qtbase-qmake-pkg-config.patch
          ./patches/qtbase-tzdir.patch
          ./patches/qtbase-variable-fonts.patch
          ./patches/0001-qtbase-qmake-always-use-libname-instead-of-absolute-.patch
          ./patches/0002-qtbase-qmake-fix-mkspecs-for-darwin.patch
          ./patches/0003-qtbase-qmake-fix-includedir-in-generated-pkg-config.patch
          ./patches/0004-qtbase-fix-locating-tzdir-on-NixOS.patch
          ./patches/0005-qtbase-deal-with-a-font-face-at-index-0-as-Regular-f.patch
          ./patches/0006-qtbase-qt-cmake-always-use-cmake-from-path.patch
          # Remove symlink check causing build to bail out and fail.
          # https://gitlab.kitware.com/cmake/cmake/-/issues/23251
          (fetchpatch {
+24 −27
Original line number Diff line number Diff line
@@ -7,9 +7,6 @@
fixQtBuiltinPaths() {
    local dir="$1"
    local pattern="$2"
    local bin="${!outputBin}"
    local dev="${!outputDev}"
    local doc="${!outputDoc}"
    local lib="${!outputLib}"

    if [ -d "$dir" ]; then
@@ -17,48 +14,48 @@ fixQtBuiltinPaths() {
            if grep -q '\$\$\[QT_' "${pr_:?}"; then
                echo "fixQtBuiltinPaths: Fixing Qt builtin paths in \`${pr_:?}'..."
                sed -i "${pr_:?}" \
                    -e "s|\\\$\\\$\\[QT_HOST_BINS[^]]*\\]|$dev/bin|g" \
                    -e "s|\\\$\\\$\\[QT_HOST_LIBEXECS[^]]*\\]|$dev/libexec|g" \
                    -e "s|\\\$\\\$\\[QT_HOST_DATA[^]]*\\]/mkspecs|$dev/mkspecs|g" \
                    -e "s|\\\$\\\$\\[QT_HOST_PREFIX[^]]*\\]|$dev|g" \
                    -e "s|\\\$\\\$\\[QT_HOST_BINS[^]]*\\]|$lib/bin|g" \
                    -e "s|\\\$\\\$\\[QT_HOST_LIBEXECS[^]]*\\]|$lib/libexec|g" \
                    -e "s|\\\$\\\$\\[QT_HOST_DATA[^]]*\\]/mkspecs|$lib/mkspecs|g" \
                    -e "s|\\\$\\\$\\[QT_HOST_PREFIX[^]]*\\]|$lib|g" \
                    -e "s|\\\$\\\$\\[QT_INSTALL_ARCHDATA[^]]*\\]|$lib|g" \
                    -e "s|\\\$\\\$\\[QT_INSTALL_BINS[^]]*\\]|$bin/bin|g" \
                    -e "s|\\\$\\\$\\[QT_INSTALL_CONFIGURATION[^]]*\\]|$bin|g" \
                    -e "s|\\\$\\\$\\[QT_INSTALL_BINS[^]]*\\]|$lib/bin|g" \
                    -e "s|\\\$\\\$\\[QT_INSTALL_CONFIGURATION[^]]*\\]|$lib|g" \
                    -e "s|\\\$\\\$\\[QT_INSTALL_DATA[^]]*\\]|$lib|g" \
                    -e "s|\\\$\\\$\\[QT_INSTALL_DOCS[^]]*\\]|$doc/share/doc|g" \
                    -e "s|\\\$\\\$\\[QT_INSTALL_EXAMPLES[^]]*\\]|$doc/examples|g" \
                    -e "s|\\\$\\\$\\[QT_INSTALL_HEADERS[^]]*\\]|$dev/include|g" \
                    -e "s|\\\$\\\$\\[QT_INSTALL_DOCS[^]]*\\]|$lib/share/doc|g" \
                    -e "s|\\\$\\\$\\[QT_INSTALL_EXAMPLES[^]]*\\]|$lib/examples|g" \
                    -e "s|\\\$\\\$\\[QT_INSTALL_HEADERS[^]]*\\]|$lib/include|g" \
                    -e "s|\\\$\\\$\\[QT_INSTALL_LIBS[^]]*\\]|$lib/lib|g" \
                    -e "s|\\\$\\\$\\[QT_INSTALL_LIBEXECS[^]]*\\]|$lib/libexec|g" \
                    -e "s|\\\$\\\$\\[QT_INSTALL_PLUGINS[^]]*\\]|$bin/$qtPluginPrefix|g" \
                    -e "s|\\\$\\\$\\[QT_INSTALL_PLUGINS[^]]*\\]|$lib/$qtPluginPrefix|g" \
                    -e "s|\\\$\\\$\\[QT_INSTALL_PREFIX[^]]*\\]|$lib|g" \
                    -e "s|\\\$\\\$\\[QT_INSTALL_TESTS[^]]*\\]|$dev/tests|g" \
                    -e "s|\\\$\\\$\\[QT_INSTALL_TESTS[^]]*\\]|$lib/tests|g" \
                    -e "s|\\\$\\\$\\[QT_INSTALL_TRANSLATIONS[^]]*\\]|$lib/translations|g" \
                    -e "s|\\\$\\\$\\[QT_INSTALL_QML[^]]*\\]|$bin/$qtQmlPrefix|g"
                    -e "s|\\\$\\\$\\[QT_INSTALL_QML[^]]*\\]|$lib/$qtQmlPrefix|g"
            fi
        done
    elif [ -e "$dir" ]; then
        if grep -q '\$\$\[QT_' "${dir:?}"; then
            echo "fixQtBuiltinPaths: Fixing Qt builtin paths in \`${dir:?}'..."
            sed -i "${dir:?}" \
                -e "s|\\\$\\\$\\[QT_HOST_BINS[^]]*\\]|$dev/bin|g" \
                -e "s|\\\$\\\$\\[QT_HOST_LIBEXECS[^]]*\\]|$dev/libexec|g" \
                -e "s|\\\$\\\$\\[QT_HOST_DATA[^]]*\\]/mkspecs|$dev/mkspecs|g" \
                -e "s|\\\$\\\$\\[QT_HOST_PREFIX[^]]*\\]|$dev|g" \
                -e "s|\\\$\\\$\\[QT_HOST_BINS[^]]*\\]|$lib/bin|g" \
                -e "s|\\\$\\\$\\[QT_HOST_LIBEXECS[^]]*\\]|$lib/libexec|g" \
                -e "s|\\\$\\\$\\[QT_HOST_DATA[^]]*\\]/mkspecs|$lib/mkspecs|g" \
                -e "s|\\\$\\\$\\[QT_HOST_PREFIX[^]]*\\]|$lib|g" \
                -e "s|\\\$\\\$\\[QT_INSTALL_ARCHDATA[^]]*\\]|$lib|g" \
                -e "s|\\\$\\\$\\[QT_INSTALL_BINS[^]]*\\]|$bin/bin|g" \
                -e "s|\\\$\\\$\\[QT_INSTALL_CONFIGURATION[^]]*\\]|$bin|g" \
                -e "s|\\\$\\\$\\[QT_INSTALL_BINS[^]]*\\]|$lib/bin|g" \
                -e "s|\\\$\\\$\\[QT_INSTALL_CONFIGURATION[^]]*\\]|$lib|g" \
                -e "s|\\\$\\\$\\[QT_INSTALL_DATA[^]]*\\]|$lib|g" \
                -e "s|\\\$\\\$\\[QT_INSTALL_DOCS[^]]*\\]|$doc/share/doc|g" \
                -e "s|\\\$\\\$\\[QT_INSTALL_EXAMPLES[^]]*\\]|$doc/examples|g" \
                -e "s|\\\$\\\$\\[QT_INSTALL_HEADERS[^]]*\\]|$dev/include|g" \
                -e "s|\\\$\\\$\\[QT_INSTALL_DOCS[^]]*\\]|$lib/share/doc|g" \
                -e "s|\\\$\\\$\\[QT_INSTALL_EXAMPLES[^]]*\\]|$lib/examples|g" \
                -e "s|\\\$\\\$\\[QT_INSTALL_HEADERS[^]]*\\]|$lib/include|g" \
                -e "s|\\\$\\\$\\[QT_INSTALL_LIBS[^]]*\\]|$lib/lib|g" \
                -e "s|\\\$\\\$\\[QT_INSTALL_LIBEXECS[^]]*\\]|$lib/libexec|g" \
                -e "s|\\\$\\\$\\[QT_INSTALL_PLUGINS[^]]*\\]|$bin/$qtPluginPrefix|g" \
                -e "s|\\\$\\\$\\[QT_INSTALL_PLUGINS[^]]*\\]|$lib/$qtPluginPrefix|g" \
                -e "s|\\\$\\\$\\[QT_INSTALL_PREFIX[^]]*\\]|$lib|g" \
                -e "s|\\\$\\\$\\[QT_INSTALL_TESTS[^]]*\\]|$dev/tests|g" \
                -e "s|\\\$\\\$\\[QT_INSTALL_TESTS[^]]*\\]|$lib/tests|g" \
                -e "s|\\\$\\\$\\[QT_INSTALL_TRANSLATIONS[^]]*\\]|$lib/translations|g" \
                -e "s|\\\$\\\$\\[QT_INSTALL_QML[^]]*\\]|$bin/$qtQmlPrefix|g"
                -e "s|\\\$\\\$\\[QT_INSTALL_QML[^]]*\\]|$lib/$qtQmlPrefix|g"
        fi
    else
        echo "fixQtBuiltinPaths: Warning: \`$dir' does not exist"
+2 −11
Original line number Diff line number Diff line
@@ -6,8 +6,6 @@
#
fixQtModulePaths() {
    local dir="$1"
    local bin="${!outputBin}"
    local dev="${!outputDev}"
    local lib="${!outputLib}"

    if [ -d "$dir" ]; then
@@ -17,8 +15,8 @@ fixQtModulePaths() {
                sed -i "${pr:?}" \
                    -e "s|\\\$\\\$QT_MODULE_LIB_BASE|$lib/lib|g" \
                    -e "s|\\\$\\\$QT_MODULE_HOST_LIB_BASE|$lib/lib|g" \
                    -e "s|\\\$\\\$QT_MODULE_INCLUDE_BASE|$dev/include|g" \
                    -e "s|\\\$\\\$QT_MODULE_BIN_BASE|$dev/bin|g"
                    -e "s|\\\$\\\$QT_MODULE_INCLUDE_BASE|$lib/include|g" \
                    -e "s|\\\$\\\$QT_MODULE_BIN_BASE|$lib/bin|g"
            fi
        done
    elif [ -e "$dir" ]; then
@@ -26,11 +24,4 @@ fixQtModulePaths() {
    else
        echo "fixQtModulePaths: Warning: \`$dir' does not exist"
    fi

    if [ "z$bin" != "z$dev" ]; then
        if [ -d "$bin/bin" ]; then
            mkdir -p "$dev/bin"
            lndir -silent "$bin/bin" "$dev/bin"
        fi
    fi
}
+0 −34
Original line number Diff line number Diff line
updateToolPath() {
    local tool="$1"
    local target="$2"
    local original="${!outputBin}/$tool"
    local actual="${!outputDev}/$tool"
    if grep -q "$original" "$target"; then
        echo "updateToolPath: Updating \`$original' in \`$target\'..."
        sed -i "$target" -e "s|$original|$actual|"
    fi
}

moveQtDevTools() {
    if [ -n "$devTools" ]; then
        for tool in $devTools; do
            moveToOutput "$tool" "${!outputDev}"
        done

        if [ -d "${!outputDev}/mkspecs" ]; then
            find "${!outputDev}/mkspecs" -name '*.pr?' | while read pr_; do
                for tool in $devTools; do
                    updateToolPath "$tool" "$pr_"
                done
            done
        fi

        if [ -d "${!outputDev}/lib/cmake" ]; then
            find "${!outputDev}/lib/cmake" -name '*.cmake' | while read cmake; do
                for tool in $devTools; do
                    updateToolPath "$tool" "$cmake"
                done
            done
        fi
    fi
}
+10 −17
Original line number Diff line number Diff line
if [[ -n "${__nix_qtbase-}" ]]; then
    # Throw an error if a different version of Qt was already set up.
    if [[ "$__nix_qtbase" != "@dev@" ]]; then
    if [[ "$__nix_qtbase" != "@out@" ]]; then
        echo >&2 "Error: detected mismatched Qt dependencies:"
        echo >&2 "    @dev@"
        echo >&2 "    @out@"
        echo >&2 "    $__nix_qtbase"
        exit 1
    fi
else # Only set up Qt once.
    __nix_qtbase="@dev@"
    __nix_qtbase="@out@"

    qtPluginPrefix=@qtPluginPrefix@
    qtQmlPrefix=@qtQmlPrefix@
@@ -30,7 +30,7 @@ else # Only set up Qt once.
    fi

    # Build tools are often confused if QMAKE is unset.
    export QMAKE=@dev@/bin/qmake
    export QMAKE=@out@/bin/qmake

    export QMAKEPATH=

@@ -53,25 +53,18 @@ else # Only set up Qt once.
        # Prevent this hook from running multiple times
        dontPatchMkspecs=1

        local bin="${!outputBin}"
        local dev="${!outputDev}"
        local doc="${!outputDoc}"
        local lib="${!outputLib}"

        moveToOutput "mkspecs"   "$dev"
        moveToOutput "modules"   "$dev"
        moveToOutput "lib/*.prl" "$dev"

        if [ -d "$dev/mkspecs/modules" ]; then
            fixQtModulePaths "$dev/mkspecs/modules"
        if [ -d "$lib/mkspecs/modules" ]; then
            fixQtModulePaths "$lib/mkspecs/modules"
        fi

        if [ -d "$dev/mkspecs" ]; then
            fixQtBuiltinPaths "$dev/mkspecs" '*.pr?'
        if [ -d "$lib/mkspecs" ]; then
            fixQtBuiltinPaths "$lib/mkspecs" '*.pr?'
        fi

        if [ -d "$dev/lib" ]; then
            fixQtBuiltinPaths "$dev/lib" '*.pr?'
        if [ -d "$lib/lib" ]; then
            fixQtBuiltinPaths "$lib/lib" '*.pr?'
        fi
    }
    if [ -z "${dontPatchMkspecs-}" ]; then
Loading