[debhelper-devel] [debhelper] 01/01: meson.pm: Add prototype cross build support

Niels Thykier nthykier at moszumanska.debian.org
Tue Oct 10 18:55:10 UTC 2017


This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository debhelper.

commit 89cb23030fbd56ca89a9d6e8553fa58b6939fcc7
Author: Niels Thykier <niels at thykier.net>
Date:   Tue Oct 10 18:52:43 2017 +0000

    meson.pm: Add prototype cross build support
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 debian/changelog                          |  3 +++
 lib/Debian/Debhelper/Buildsystem/meson.pm | 29 +++++++++++++++++++++++++----
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 8224de4..ade8ba5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -38,6 +38,9 @@ debhelper (10.9.1) UNRELEASED; urgency=medium
     escaped names like "\x2d".  Thanks to Bernd Zeimetz for
     reporting the issue.  (Closes: #764730)
   * dh_systemd_start: Ditto.
+  * meson.pm: Add prototype support for cross building by relying
+    on /usr/share/meson/debcrossgen.  Note that this is currently
+    not functional due to #875703.
 
   [ Dmitry Shachnev ]
   * qmake.pm: Add basic cross-building support.  (Closes: #877357)
diff --git a/lib/Debian/Debhelper/Buildsystem/meson.pm b/lib/Debian/Debhelper/Buildsystem/meson.pm
index 1ff9054..e3b6dd4 100644
--- a/lib/Debian/Debhelper/Buildsystem/meson.pm
+++ b/lib/Debian/Debhelper/Buildsystem/meson.pm
@@ -7,7 +7,8 @@ package Debian::Debhelper::Buildsystem::meson;
 
 use strict;
 use warnings;
-use Debian::Debhelper::Dh_Lib qw(dpkg_architecture_value);
+use File::Temp qw(tempfile);
+use Debian::Debhelper::Dh_Lib qw(dpkg_architecture_value is_cross_compiling doit warning error);
 use parent qw(Debian::Debhelper::Buildsystem::ninja);
 
 sub DESCRIPTION {
@@ -35,9 +36,6 @@ sub new {
 sub configure {
 	my $this=shift;
 
-	# TODO: Support cross compilation
-	# https://github.com/mesonbuild/meson/wiki/Cross-compilation
-
 	# Standard set of options for meson.
 	my @opts = (
 		'--wrap-mode=nodownload',
@@ -50,6 +48,29 @@ sub configure {
 	push @opts, "--libdir=lib/$multiarch";
 	push @opts, "--libexecdir=lib/$multiarch";
 
+	if (is_cross_compiling()) {
+		# http://mesonbuild.com/Cross-compilation.html
+		my $cross_file = $ENV{'DH_MESON_CROSS_FILE'};
+		if (not $cross_file) {
+			my $debcrossgen = '/usr/share/meson/debcrossgen';
+			if (not -x $debcrossgen) {
+				warning("Missing debcrossgen (${debcrossgen}) cannot generate a meson cross file and non was provided");
+				error("Cannot cross-compile: Please use meson (>= 0.42.1) or provide a cross file via DH_MESON_CROSS_FILE");
+			}
+			my ($fh, $filename) = tempfile("meson-cross-file.XXXX", SUFFIX => ".conf", TMPDIR => 1, UNLINK => 1);
+			close($fh);
+			doit({ stdout => '/dev/null' }, $debcrossgen, "-o${filename}");
+			$cross_file = $filename;
+		}
+		if ($cross_file !~ m{^/}) {
+			# Make the file name absolute as meson will be called from the build dir.
+			require Cwd;
+			$cross_file =~ s{^\./}{};
+			$cross_file = Cwd::cwd() . "/${cross_file}";
+		}
+		push(@opts, '--cross-file', $cross_file);
+	}
+
 	$this->mkdir_builddir();
 	eval {
 		$this->doit_in_builddir("meson", $this->get_source_rel2builddir(), @opts, @_);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debhelper/debhelper.git




More information about the debhelper-devel mailing list