diff options
author | Adam Joseph <adam@westernsemico.com> | 2023-11-03 22:07:12 -0700 |
---|---|---|
committer | Adam Joseph <54836058+amjoseph-nixpkgs@users.noreply.github.com> | 2023-11-05 00:55:16 +0000 |
commit | d1df34dc100724eab55bd49e310572517e8a4dd1 (patch) | |
tree | f46d67f48090ba367dbc7669c70c9f82fce9bf99 /pkgs/development/libraries/qt-5 | |
parent | 49e8d9db2f83003c0c5ac6c2df25104390f60519 (diff) |
qt5.qtwebengine: fix cross
Diffstat (limited to 'pkgs/development/libraries/qt-5')
-rw-r--r-- | pkgs/development/libraries/qt-5/modules/qtwebengine.nix | 117 |
1 files changed, 90 insertions, 27 deletions
diff --git a/pkgs/development/libraries/qt-5/modules/qtwebengine.nix b/pkgs/development/libraries/qt-5/modules/qtwebengine.nix index 777430af0217f..58f90763a2452 100644 --- a/pkgs/development/libraries/qt-5/modules/qtwebengine.nix +++ b/pkgs/development/libraries/qt-5/modules/qtwebengine.nix @@ -1,8 +1,11 @@ { qtModule , qtdeclarative, qtquickcontrols, qtlocation, qtwebchannel -, bison, flex, git, gperf, ninja, pkg-config, python, which +, bison, flex, git, gperf, ninja, pkg-config, python, which, python3 , nodejs, qtbase, perl +, buildPackages +, pkgsBuildTarget +, pkgsBuildBuild , xorg, libXcursor, libXScrnSaver, libXrandr, libXtst , fontconfig, freetype, harfbuzz, icu, dbus, libdrm @@ -27,12 +30,45 @@ , pipewireSupport ? stdenv.isLinux , pipewire_0_2 , postPatch ? "" +, nspr +, lndir +, dbusSupport ? !stdenv.isDarwin, expat }: -qtModule { +let + # qtwebengine expects to find an executable in $PATH which runs on + # the build platform yet knows about the host `.pc` files. Most + # configury allows setting $PKG_CONFIG to point to an + # arbitrarily-named script which serves this purpose; however QT + # insists that it is named `pkg-config` with no target prefix. So + # we re-wrap the host platform's pkg-config. + pkg-config-wrapped-without-prefix = stdenv.mkDerivation { + name = "pkg-config-wrapper-without-target-prefix"; + dontUnpack = true; + dontBuild = true; + installPhase = '' + mkdir -p $out/bin + ln -s '${buildPackages.pkg-config}/bin/${buildPackages.pkg-config.targetPrefix}pkg-config' $out/bin/pkg-config + ''; + }; + + qtPlatformCross = plat: with plat; + if isLinux + then "linux-generic-g++" + else throw "Please add a qtPlatformCross entry for ${plat.config}"; + +in + +qtModule ({ pname = "qtwebengine"; nativeBuildInputs = [ bison flex git gperf ninja pkg-config python which gn nodejs + ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ + perl + lndir (lib.getDev pkgsBuildTarget.targetPackages.qt5.qtbase) + pkgsBuildBuild.pkg-config + (lib.getDev pkgsBuildTarget.targetPackages.qt5.qtquickcontrols) + pkg-config-wrapped-without-prefix ] ++ lib.optional stdenv.isDarwin xcbuild; doCheck = true; outputs = [ "bin" "dev" "out" ]; @@ -108,16 +144,25 @@ qtModule { --replace "-Wl,-fatal_warnings" "" '') + postPatch; - env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isGNU [ - # with gcc8, -Wclass-memaccess became part of -Wall and this exceeds the logging limit - "-Wno-class-memaccess" - ] ++ lib.optionals (stdenv.hostPlatform.gcc.arch or "" == "sandybridge") [ - # it fails when compiled with -march=sandybridge https://github.com/NixOS/nixpkgs/pull/59148#discussion_r276696940 - # TODO: investigate and fix properly - "-march=westmere" - ] ++ lib.optionals stdenv.cc.isClang [ - "-Wno-elaborated-enum-base" - ]); + env = { + NIX_CFLAGS_COMPILE = + toString ( + lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ + "-w " + ] ++ lib.optionals stdenv.cc.isGNU [ + # with gcc8, -Wclass-memaccess became part of -Wall and this exceeds the logging limit + "-Wno-class-memaccess" + ] ++ lib.optionals (stdenv.hostPlatform.gcc.arch or "" == "sandybridge") [ + # it fails when compiled with -march=sandybridge https://github.com/NixOS/nixpkgs/pull/59148#discussion_r276696940 + # TODO: investigate and fix properly + "-march=westmere" + ] ++ lib.optionals stdenv.cc.isClang [ + "-Wno-elaborated-enum-base" + ]); + } // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) { + NIX_CFLAGS_LINK = "-Wl,--no-warn-search-mismatch"; + "NIX_CFLAGS_LINK_${buildPackages.stdenv.cc.suffixSalt}" = "-Wl,--no-warn-search-mismatch"; + }; preConfigure = '' export NINJAFLAGS=-j$NIX_BUILD_CORES @@ -125,10 +170,15 @@ qtModule { if [ -d "$PWD/tools/qmake" ]; then QMAKEPATH="$PWD/tools/qmake''${QMAKEPATH:+:}$QMAKEPATH" fi + '' + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) '' + export QMAKE_CC=$CC + export QMAKE_CXX=$CXX + export QMAKE_LINK=$CXX + export QMAKE_AR=$AR ''; qmakeFlags = [ "--" "-system-ffmpeg" ] - ++ lib.optional pipewireSupport "-webengine-webrtc-pipewire" + ++ lib.optional (pipewireSupport && stdenv.buildPlatform == stdenv.hostPlatform) "-webengine-webrtc-pipewire" ++ lib.optional enableProprietaryCodecs "-proprietary-codecs"; propagatedBuildInputs = [ @@ -226,7 +276,9 @@ qtModule { dontUseNinjaBuild = true; dontUseNinjaInstall = true; - postInstall = lib.optionalString stdenv.isLinux '' + postInstall = lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) '' + mkdir -p $out/libexec + '' + lib.optionalString stdenv.isLinux '' cat > $out/libexec/qt.conf <<EOF [Paths] Prefix = .. @@ -245,21 +297,32 @@ qtModule { # qtwebengine-5.15.8: "QtWebEngine can only be built for x86, # x86-64, ARM, Aarch64, and MIPSel architectures." - platforms = - lib.trivial.pipe lib.systems.doubles.all [ - (map (double: lib.systems.elaborate { system = double; })) - (lib.lists.filter (parsedPlatform: with parsedPlatform; - isUnix && - (isx86_32 || - isx86_64 || - isAarch32 || - isAarch64 || - (isMips && isLittleEndian)))) - (map (plat: plat.system)) - ]; + platforms = with lib.systems.inspect.patterns; + let inherit (lib.systems.inspect) patternLogicalAnd; + in concatMap (patternLogicalAnd isUnix) (lib.concatMap lib.toList [ + isx86_32 + isx86_64 + isAarch32 + isAarch64 + (patternLogicalAnd isMips isLittleEndian) + ]); broken = stdenv.isDarwin && stdenv.isx86_64; # This build takes a long time; particularly on slow architectures timeout = 24 * 3600; }; -} + +} // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) { + configurePlatforms = [ ]; + # to get progress output in `nix-build` and `nix build -L` + preBuild = '' + export TERM=dumb + ''; + depsBuildBuild = [ + pkgsBuildBuild.stdenv + zlib + nss + nspr + ]; + +}) |