[debhelper-devel] [debhelper] 01/01: Add support for Meson build system

Michael Biebl biebl at moszumanska.debian.org
Mon Apr 3 23:54:50 UTC 2017


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

biebl pushed a commit to branch master
in repository debhelper.

commit f771a9a62802733fea6801dacde3badee13ef8c0
Author: Michael Biebl <biebl at debian.org>
Date:   Fri Mar 24 00:37:16 2017 +0100

    Add support for Meson build system
    
    Meson is a new build system which is supposed to be extremly fast and,
    even more importantly, as user friendly as possible.
    
    It uses Ninja as backend to manage the actual build process.
    
    Closes: #795253
    Signed-off-by: Michael Biebl <biebl at debian.org>
---
 Debian/Debhelper/Buildsystem/meson.pm | 74 +++++++++++++++++++++++++++++
 Debian/Debhelper/Buildsystem/ninja.pm | 88 +++++++++++++++++++++++++++++++++++
 Debian/Debhelper/Dh_Buildsystems.pm   |  1 +
 3 files changed, 163 insertions(+)

diff --git a/Debian/Debhelper/Buildsystem/meson.pm b/Debian/Debhelper/Buildsystem/meson.pm
new file mode 100644
index 0000000..551b4f7
--- /dev/null
+++ b/Debian/Debhelper/Buildsystem/meson.pm
@@ -0,0 +1,74 @@
+# A debhelper build system class for handling Meson based projects.
+#
+# Copyright: © 2017 Michael Biebl
+# License: GPL-2+
+
+package Debian::Debhelper::Buildsystem::meson;
+
+use strict;
+use warnings;
+use Debian::Debhelper::Dh_Lib qw(dpkg_architecture_value);
+use parent qw(Debian::Debhelper::Buildsystem::ninja);
+
+sub DESCRIPTION {
+	"Meson (meson.build)"
+}
+
+sub check_auto_buildable {
+	my $this=shift;
+	my ($step)=@_;
+
+	return 0 unless -e $this->get_sourcepath("meson.build");
+
+	# Handle configure explicitly; inherit the rest
+	return 1 if $step eq "configure";
+	return $this->SUPER::check_auto_buildable(@_);
+}
+
+sub new {
+	my $class=shift;
+	my $this=$class->SUPER::new(@_);
+	$this->prefer_out_of_source_building(@_);
+	return $this;
+}
+
+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;
+	push @opts, "--buildtype=plain";
+	push @opts, "--prefix=/usr";
+	push @opts, "--sysconfdir=/etc";
+	push @opts, "--localstatedir=/var";
+	my $multiarch=dpkg_architecture_value("DEB_HOST_MULTIARCH");
+	push @opts, "--libdir=lib/$multiarch";
+	push @opts, "--libexecdir=lib/$multiarch";
+
+	$this->mkdir_builddir();
+	eval {
+		$this->doit_in_builddir("meson", $this->get_source_rel2builddir(), @opts, @_);
+	};
+	if ($@) {
+		if (-e $this->get_buildpath("meson-logs/meson-log.txt")) {
+			$this->doit_in_builddir("tail -v -n +0 meson-logs/meson-log.txt");
+		}
+		die $@;
+	}
+}
+
+sub test {
+	my $this=shift;
+	return $this->SUPER::test(@_);
+}
+
+1
+
+# Local Variables:
+# indent-tabs-mode: t
+# tab-width: 4
+# cperl-indent-level: 4
+# End:
diff --git a/Debian/Debhelper/Buildsystem/ninja.pm b/Debian/Debhelper/Buildsystem/ninja.pm
new file mode 100644
index 0000000..0df964e
--- /dev/null
+++ b/Debian/Debhelper/Buildsystem/ninja.pm
@@ -0,0 +1,88 @@
+# A debhelper build system class for handling ninja based projects.
+#
+# Copyright: © 2017 Michael Biebl
+# License: GPL-2+
+
+package Debian::Debhelper::Buildsystem::ninja;
+
+use strict;
+use warnings;
+use Debian::Debhelper::Dh_Lib qw(%dh dpkg_architecture_value);
+use parent qw(Debian::Debhelper::Buildsystem);
+
+sub DESCRIPTION {
+	"Ninja (build.ninja)"
+}
+
+sub new {
+	my $class=shift;
+	my $this=$class->SUPER::new(@_);
+	$this->{buildcmd} = "ninja";
+	return $this;
+}
+
+sub check_auto_buildable {
+	my $this=shift;
+	my ($step) = @_;
+
+	if (-e $this->get_buildpath("build.ninja"))
+	{
+		# This is always called in the source directory, but generally
+		# Ninja files are created (or live) in the build directory.
+		return 1;
+	} elsif ($step eq "clean" && defined $this->get_builddir() &&
+	         $this->check_auto_buildable("configure"))
+	{
+		# Assume that the package can be cleaned (i.e. the build directory can
+		# be removed) as long as it is built out-of-source tree and can be
+		# configured. This is useful for derivative buildsystems which
+		# generate Ninja files.
+		return 1;
+	}
+	return 0;
+}
+
+sub build {
+	my $this=shift;
+
+	if (!$dh{QUIET}) {
+		unshift @_, "-v";
+	}
+	if ($this->get_parallel() > 0) {
+		unshift @_, "-j" . $this->get_parallel();
+	}
+	$this->doit_in_builddir($this->{buildcmd}, @_);
+}
+
+sub test {
+	my $this=shift;
+
+	if ($this->get_parallel() > 0) {
+		$ENV{MESON_TESTTHREADS}=$this->get_parallel();
+	}
+	$this->doit_in_builddir($this->{buildcmd}, "test", @_);
+}
+
+sub install {
+	my $this=shift;
+	my $destdir=shift;
+
+	$ENV{DESTDIR}=$destdir;
+	$this->doit_in_builddir($this->{buildcmd}, "install", @_);
+}
+
+sub clean {
+	my $this=shift;
+
+	if (!$this->rmdir_builddir()) {
+		$this->doit_in_builddir($this->{buildcmd}, "clean", @_);
+	}
+}
+
+1
+
+# Local Variables:
+# indent-tabs-mode: t
+# tab-width: 4
+# cperl-indent-level: 4
+# End:
diff --git a/Debian/Debhelper/Dh_Buildsystems.pm b/Debian/Debhelper/Dh_Buildsystems.pm
index a2424c7..8004dbd 100644
--- a/Debian/Debhelper/Dh_Buildsystems.pm
+++ b/Debian/Debhelper/Dh_Buildsystems.pm
@@ -29,6 +29,7 @@ our @BUILDSYSTEMS = (
 	"ant",
 	"qmake",
 	"qmake_qt4",
+	"meson",
 );
 
 our @THIRD_PARTY_BUILDSYSTEMS = (

-- 
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