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.
# - 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.
# - 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
# 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
if (exists $opts{builddir}) {
$this->_set_builddir($opts{builddir});
}
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;
$this->{parallel} = $opts{parallel};
}
return $this;
package Debian::Debhelper::Buildsystem::makefile;
use strict;
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 {
use base 'Debian::Debhelper::Buildsystem';
sub get_makecmd_C {
sub do_make {
my $this=shift;
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}, @_);
}
$this->doit_in_builddir($this->{makecmd}, @_);
}
sub buildsystems_init {
my %args=@_;
sub buildsystems_init {
my %args=@_;
+ my $max_parallel=-1; # unlimited
# Available command line options
my %options = (
# Available command line options
my %options = (
sub set_parallel {
my $max=shift;
sub set_parallel {
my $max=shift;
if (exists $ENV{DEB_BUILD_OPTIONS}) {
# Parse parallel=n tag
if (exists $ENV{DEB_BUILD_OPTIONS}) {
# Parse parallel=n tag
foreach my $opt (split(/\s+/, $ENV{DEB_BUILD_OPTIONS})) {
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;