Hello,

On ketvirtadienis 19 Lapkritis 2009 18:55:31 Joey Hess wrote:
> Note that the --list code has not been updated to select more specific
> build systems.

Yay, code duplication, forgot about it. The patch for this is attached. 
(0002th).

0003th is another dh 7.0.x compatibility (I believe) bug fix for cmake.

-- 
Modestas Vainius <modes...@vainius.eu>
From 3fc93bb1ea215125e82b184237be75916b3a9393 Mon Sep 17 00:00:00 2001
From: Modestas Vainius <modes...@vainius.eu>
Date: Thu, 19 Nov 2009 20:45:14 +0200
Subject: [PATCH 2/3] Make buildsystems_list() use updated auto-selection code.

In order to avoid code duplication, auto-selection code has been refactored
into separate subroutine autoselect_buildsystem(). Both load_buildsystem() and
buildsystem_list() use it.
---
 Debian/Debhelper/Dh_Buildsystems.pm |   60 ++++++++++++++++++++---------------
 1 files changed, 34 insertions(+), 26 deletions(-)

diff --git a/Debian/Debhelper/Dh_Buildsystems.pm b/Debian/Debhelper/Dh_Buildsystems.pm
index 2893c1a..8470eac 100644
--- a/Debian/Debhelper/Dh_Buildsystems.pm
+++ b/Debian/Debhelper/Dh_Buildsystems.pm
@@ -56,6 +56,29 @@ sub create_buildsystem_instance {
 	return $module->new(%bsopts);
 }
 
+# Autoselect a build system from the list of instances
+sub autoselect_buildsystem {
+	my $step=shift;
+	my $selected;
+	my $selected_level = 0;
+
+	for my $inst (@_) {
+		# Only derived (i.e. more specific) build system can be
+		# considered beyond the currently selected one.
+		next if defined $selected && !$inst->isa(ref $selected);
+
+		# If the build system says it is auto-buildable at the current
+		# step and it can provide more specific information about its
+		# status than its parent (if any), auto-select it.
+		my $level = $inst->check_auto_buildable($step);
+		if ($level > $selected_level) {
+			$selected = $inst;
+			$selected_level = $level;
+		}
+	}
+	return $selected;
+}
+
 # Similar to create_build system_instance(), but it attempts to autoselect
 # a build system if none was specified. In case autoselection fails, undef
 # is returned.
@@ -68,25 +91,11 @@ sub load_buildsystem {
 	}
 	else {
 		# Try to determine build system automatically
-		my $selected;
-		my $selected_level = 0;
+		my @buildsystems;
 		for $system (@BUILDSYSTEMS) {
-			my $inst = create_buildsystem_instance($system, @_);
-
-			# Only derived (i.e. more specific) build system can be
-			# considered beyond the currently selected one.
-			next if defined $selected && !$inst->isa(ref $selected);
-
-			# If the build system says it is auto-buildable at the current
-			# step and it can provide more specific information about its
-			# status than its parent (if any), auto-select it.
-			my $level = $inst->check_auto_buildable($step);
-			if ($level > $selected_level) {
-				$selected = $inst;
-				$selected_level = $level;
-			}
+			push @buildsystems, create_buildsystem_instance($system, @_);
 		}
-		return $selected;
+		return autoselect_buildsystem($step, @buildsystems);
 	}
 }
 
@@ -174,23 +183,22 @@ sub set_parallel {
 sub buildsystems_list {
 	my $step=shift;
 
+	my @buildsystems = load_all_buildsystems();
+	my $auto = autoselect_buildsystem($step, grep { ! $_->{thirdparty} } @buildsystems);
+	my $specified;
+
 	# List build systems (including auto and specified status)
-	my ($auto, $specified);
-	for my $inst (load_all_buildsystems()) {
-		my $is_specified = defined $opt_buildsys && $opt_buildsys eq $inst->NAME();
+	for my $inst (@buildsystems) {
 		if (! defined $specified && defined $opt_buildsys && $opt_buildsys eq $inst->NAME()) {
-			$specified = $inst->NAME();
-		}
-		elsif (! defined $auto && ! $inst->{thirdparty} && $inst->check_auto_buildable($step)) {
-			$auto = $inst->NAME();
+			$specified = $inst;
 		}
 		printf("%-20s %s", $inst->NAME(), $inst->DESCRIPTION());
 		print " [3rd party]" if $inst->{thirdparty};
 		print "\n";
 	}
 	print "\n";
-	print "Auto-selected: $auto\n" if defined $auto;
-	print "Specified: $specified\n" if defined $specified;
+	print "Auto-selected: ", $auto->NAME(), "\n" if defined $auto;
+	print "Specified: ", $specified->NAME(), "\n" if defined $specified;
 	print "No system auto-selected or specified\n"
 		if ! defined $auto && ! defined $specified;
 }
-- 
1.6.5.2

From 768ce710b510205907145fd9f96096ca59e1d3af Mon Sep 17 00:00:00 2001
From: Modestas Vainius <modes...@vainius.eu>
Date: Thu, 19 Nov 2009 20:58:39 +0200
Subject: [PATCH 3/3] cmake build+ steps need Makefile.

The condition is not what dh_auto_* 7.0.x would have done. The
patch makes auto-selection to pass through cmake.pm if Makefile
was not created. This problem is not very dangerous though.
---
 Debian/Debhelper/Buildsystem/cmake.pm |    5 +++--
 t/buildsystems/buildsystem_tests      |    2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/Debian/Debhelper/Buildsystem/cmake.pm b/Debian/Debhelper/Buildsystem/cmake.pm
index ee90c1f..24f486f 100644
--- a/Debian/Debhelper/Buildsystem/cmake.pm
+++ b/Debian/Debhelper/Buildsystem/cmake.pm
@@ -17,12 +17,13 @@ sub check_auto_buildable {
 	my $this=shift;
 	my ($step)=...@_;
 	if (-e $this->get_sourcepath("CMakeLists.txt")) {
-		my $ret = $this->SUPER::check_auto_buildable(@_);
+		my $ret = ($step eq "configure" && 1) ||
+		          $this->SUPER::check_auto_buildable(@_);
 		# Existence of CMakeCache.txt indicates cmake has already
 		# been used by a prior build step, so should be used
 		# instead of the parent makefile class.
 		$ret++ if ($ret && -e $this->get_buildpath("CMakeCache.txt"));
-		return $ret > 0 ? $ret : 1;
+		return $ret;
 	}
 	return 0;
 }
diff --git a/t/buildsystems/buildsystem_tests b/t/buildsystems/buildsystem_tests
index e19ab5d..d8619fc 100755
--- a/t/buildsystems/buildsystem_tests
+++ b/t/buildsystems/buildsystem_tests
@@ -256,7 +256,7 @@ touch "$tmpdir/configure", 0755;
 test_check_auto_buildable($bs{autoconf}, "configure", { configure => 1 });
 
 touch "$tmpdir/CMakeLists.txt";
-test_check_auto_buildable($bs{cmake}, "CMakeLists.txt", 1);
+test_check_auto_buildable($bs{cmake}, "CMakeLists.txt", { configure => 1 });
 
 touch "$tmpdir/Makefile.PL";
 test_check_auto_buildable($bs{perl_makemaker}, "Makefile.PL", { configure => 1 });
-- 
1.6.5.2

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to