]> git.donarmstrong.com Git - debhelper.git/commitdiff
support unlimited parallel jobs
authorJoey Hess <joey@gnu.kitenet.net>
Thu, 29 Oct 2009 23:45:06 +0000 (19:45 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Thu, 29 Oct 2009 23:48:51 +0000 (19:48 -0400)
dpkg-buildpackage -j sets DEB_BUILD_OPTIONS=parallel=-1. Policy does not
cover this but the intent is to allow unlimited parallel jobs.

Also, there is no longer any way for parallel to be set to undef, so remove
code to handle that.

Debian/Debhelper/Buildsystem.pm
Debian/Debhelper/Buildsystem/makefile.pm
Debian/Debhelper/Dh_Buildsystems.pm

index 677e3bf995982cd8b09c6ee52cc62fa7e59a7f5a..7354963d8c5a69114d2e081d12647ed34b9b9e0d 100644 (file)
@@ -48,11 +48,8 @@ sub DEFAULT_BUILD_DIRECTORY {
 # - builddir -     specifies build directory to use. Path is relative to the
 #                  current (top) directory. If undef or empty,
 #                  DEFAULT_BUILD_DIRECTORY directory will be used.
-# - parallel -     number of parallel process to be spawned for building
-#                  sources. Parallel building needs to be supported by the
-#                  underlying build system for this option to be effective.
-#                  Defaults to undef (i.e. parallel disabled, but do not try to
-#                  enforce this limit by messing with environment).
+# - parallel -     max number of parallel processes to be spawned for building
+#                  sources (-1 = unlimited; 1 = no parallel)
 # Derived class can override the constructor to initialize common object
 # parameters. Do NOT use constructor to execute commands or otherwise
 # configure/setup build environment. There is absolutely no guarantee the
@@ -77,7 +74,7 @@ sub new {
        if (exists $opts{builddir}) {
                $this->_set_builddir($opts{builddir});
        }
-       if (defined $opts{parallel} && $opts{parallel} >= 1) {
+       if (defined $opts{parallel}) {
                $this->{parallel} = $opts{parallel};
        }
        return $this;
index ff904afdfed4fd857fbf06cbd9f008ce9fba9b7d..704f9c952d112c25f39fc7f56f908b52b8945b8d 100644 (file)
@@ -7,8 +7,7 @@
 package Debian::Debhelper::Buildsystem::makefile;
 
 use strict;
-use Debian::Debhelper::Dh_Lib qw(escape_shell is_make_jobserver_unavailable
-       clean_jobserver_makeflags);
+use Debian::Debhelper::Dh_Lib qw(escape_shell clean_jobserver_makeflags);
 use base 'Debian::Debhelper::Buildsystem';
 
 sub get_makecmd_C {
@@ -34,17 +33,12 @@ sub exists_make_target {
 sub do_make {
        my $this=shift;
 
-       # Avoid warnings about unavailable jobserver.
-       if (is_make_jobserver_unavailable()) {
-               clean_jobserver_makeflags();
-       }
+       # Avoid possible warnings about unavailable jobserver,
+       # and force make to start a new jobserver.
+       clean_jobserver_makeflags();
 
-       if (defined $this->get_parallel()) {
-               # Note that this will override any -j settings in MAKEFLAGS.
-               unshift @_, "-j" . ($this->get_parallel() > 1 ? $this->get_parallel() : 1);
-               # Force make to start a new jobserver.
-               clean_jobserver_makeflags();
-       }
+       # Note that this will override any -j settings in MAKEFLAGS.
+       unshift @_, "-j" . ($this->get_parallel() > 0 ? $this->get_parallel() : "");
 
        $this->doit_in_builddir($this->{makecmd}, @_);
 }
index f43c87d4820b8d6807705368324ac4978eba83be..fc06a2ac16a27e3f32583b4d91473c6bf850dce1 100644 (file)
@@ -113,7 +113,7 @@ sub load_all_buildsystems {
 sub buildsystems_init {
        my %args=@_;
        
-       my $max_parallel=0;
+       my $max_parallel=-1; # unlimited
 
        # Available command line options
        my %options = (
@@ -139,27 +139,21 @@ sub buildsystems_init {
 sub set_parallel {
        my $max=shift;
 
+       $opt_parallel=1;
+
        if (exists $ENV{DEB_BUILD_OPTIONS}) {
                # Parse parallel=n tag
-               my $n;
                foreach my $opt (split(/\s+/, $ENV{DEB_BUILD_OPTIONS})) {
-                       $n = $1 if $opt =~ /^parallel=(\d+)$/;
-               }
-               if (defined $n && $n > 0) {
-                       if (!$max || $n < $max) {
-                               $opt_parallel = $n;
-                       }
-                       else {
-                               $opt_parallel = $max;
+                       if ($opt =~ /^parallel=([-\d]+)$/) {
+                               my $n=$1;
+                               if ($n > 0 && ($max == -1 || $n < $max)) {
+                                       $opt_parallel = $n;
+                               }
+                               else {
+                                       $opt_parallel = $max;
+                               }
                        }
                }
-               else {
-                       # Invalid value in the parallel tag. Disable.
-                       $opt_parallel = 1;
-               }
-       }
-       else {
-               $opt_parallel = 1;
        }
 }