Package: debhelper
Version: 11.2.1
Tags: patch

Dear maintainer,

Some time has passed since we have added cross-compilation support to
debhelper's qmake buildsystem. Since then, qmake has got a wrapper that
duplicates the debhelper functionality.

Now I think we should avoid copying the logic in two places, and just
make debhelper call that wrapper.

Please find the patch attached.

This will also fix some bugs, like missing QMAKE_QMAKE variable set,
and missing return to “-before” mode after the “-early” arguments have
ended.

--
Dmitry Shachnev
From ec365b8d611d01d601013a09385da1cb9a5a2185 Mon Sep 17 00:00:00 2001
From: Dmitry Shachnev <mity...@debian.org>
Date: Wed, 31 Jan 2018 23:38:17 +0300
Subject: [PATCH] qmake.pm: Let qmake cross wrapper set most of cross-build
 options

---
 debian/control                            |  3 ++
 lib/Debian/Debhelper/Buildsystem/qmake.pm | 56 +++----------------------------
 2 files changed, 7 insertions(+), 52 deletions(-)

diff --git a/debian/control b/debian/control
index 678c94d9..a5704dac 100644
--- a/debian/control
+++ b/debian/control
@@ -44,6 +44,9 @@ Breaks: dh-systemd (<< 1.38),
         cmake (<< 3.9~),
 # meson build system uses --wrap-mode, which requires meson (>= 0.40.0)
         meson (<< 0.40.0~),
+# The qmake cross wrapper was introduced in 5.9.2+dfsg-5, but got some important
+# fixes in the subsequent uploads. It is only needed for cross-building.
+        qt5-qmake (<< 5.9.2+dfsg-8),
 Replaces: dh-systemd (<< 1.38)
 Suggests: dh-make, dwz
 Provides: ${dh:CompatLevels}
diff --git a/lib/Debian/Debhelper/Buildsystem/qmake.pm b/lib/Debian/Debhelper/Buildsystem/qmake.pm
index 561080f8..18b896d8 100644
--- a/lib/Debian/Debhelper/Buildsystem/qmake.pm
+++ b/lib/Debian/Debhelper/Buildsystem/qmake.pm
@@ -8,7 +8,7 @@ package Debian::Debhelper::Buildsystem::qmake;
 
 use strict;
 use warnings;
-use Debian::Debhelper::Dh_Lib qw(dpkg_architecture_value error generated_file is_cross_compiling);
+use Debian::Debhelper::Dh_Lib qw(dpkg_architecture_value error is_cross_compiling);
 use parent qw(Debian::Debhelper::Buildsystem::makefile);
 
 my %OS_MKSPEC_MAPPING = (
@@ -63,38 +63,6 @@ sub configure {
 		} else {
 			error("Cannot cross-compile: Missing entry for HOST OS ${host_os} for qmake's -spec option");
 		}
-
-		my $filename = generated_file('_source', 'qmake-cross.conf');
-		my $host_multiarch = dpkg_architecture_value("DEB_HOST_MULTIARCH");
-		open(my $fh, '>', $filename) or error("open($filename) failed: $!");
-
-		$fh->print("[Paths]\n");
-		$fh->print("Prefix=/usr\n");
-		$fh->print("ArchData=lib/$host_multiarch/qt5\n");
-		$fh->print("Binaries=lib/qt5/bin\n");
-		$fh->print("Data=share/qt5\n");
-		$fh->print("Documentation=share/qt5/doc\n");
-		$fh->print("Examples=lib/$host_multiarch/qt5/examples\n");
-		$fh->print("Headers=include/$host_multiarch/qt5\n");
-		$fh->print("HostBinaries=lib/qt5/bin\n");
-		$fh->print("HostData=lib/$host_multiarch/qt5\n");
-		$fh->print("HostLibraries=lib/$host_multiarch\n");
-		$fh->print("Imports=lib/$host_multiarch/qt5/imports\n");
-		$fh->print("Libraries=lib/$host_multiarch\n");
-		$fh->print("LibraryExecutables=lib/$host_multiarch/qt5/libexec\n");
-		$fh->print("Plugins=lib/$host_multiarch/qt5/plugins\n");
-		$fh->print("Qml2Imports=lib/$host_multiarch/qt5/qml\n");
-		$fh->print("Settings=/etc/xdg\n");
-		$fh->print("Translations=share/qt5/translations\n");
-
-		close($fh) or error("close($filename) failed: $!");
-		if ($filename !~ m{^/}) {
-			# Make the file name absolute (just in case qmake cares).
-			require Cwd;
-			$filename =~ s{^\./}{};
-			$filename = Cwd::cwd() . "/${filename}";
-		}
-		push @options, ("-qtconf", $filename);
 	}
 
 	if ($ENV{CFLAGS}) {
@@ -112,25 +80,6 @@ sub configure {
 	push @flags, "QMAKE_STRIP=:";
 	push @flags, "PREFIX=/usr";
 
-	if (is_cross_compiling()) {
-		# qmake calls $$QMAKE_CXX in toolchain.prf to get a list of library/include paths,
-		# we need -early flag to make sure $$QMAKE_CXX is already properly set on that step.
-		push @flags, "-early";
-		if ($ENV{CC}) {
-			push @flags, "QMAKE_CC=" . $ENV{CC};
-		} else {
-			push @flags, "QMAKE_CC=" . dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-gcc";
-		}
-		if ($ENV{CXX}) {
-			push @flags, "QMAKE_CXX=" . $ENV{CXX};
-			push @flags, "QMAKE_LINK=" . $ENV{CXX};
-		} else {
-			push @flags, "QMAKE_CXX=" . dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-g++";
-			push @flags, "QMAKE_LINK=" . dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-g++";
-		}
-		push @flags, "PKG_CONFIG=" . dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-pkg-config";
-	}
-
 	$this->mkdir_builddir();
 	$this->doit_in_builddir($this->_qmake(), @options, @flags, @_);
 }
@@ -145,6 +94,9 @@ sub install {
 }
 
 sub _qmake {
+	if (is_cross_compiling()) {
+		return dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-qmake";
+	}
 	return 'qmake';
 }
 
-- 
2.16.3

Attachment: signature.asc
Description: PGP signature

Reply via email to