summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
76719d8)
Now clean_jobserver_makeflags will only remove --jobserver settings
from MAKEFLAGS. This is simpler and easier to understand than
the old behavior, which, if there was no --jobserver, removed
all -j and --jobs, while leaving those when removing --jobserver.
This relies on -j options passed to make overriding
-j settings in MAKEFLAGS. So we don't need to clean those out,
we can just override them.
use strict;
use Debian::Debhelper::Dh_Lib qw(escape_shell is_make_jobserver_unavailable
use strict;
use Debian::Debhelper::Dh_Lib qw(escape_shell is_make_jobserver_unavailable
+ 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;
- # Remove unavailable jobserver options from MAKEFLAGS.
- # Always clean MAKEFLAGS from unavailable jobserver options. If parallel
- # is enabled, do more extensive clean up from all job control specific
- # options
- if (defined $this->get_parallel() || is_make_jobserver_unavailable()) {
- clean_makeflags();
+ # Avoid warnings about unavailable jobserver.
+ if (is_make_jobserver_unavailable()) {
+ clean_jobserver_makeflags();
- # Start a new jobserver if parallel building was requested
if (defined $this->get_parallel()) {
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);
unshift @_, "-j" . ($this->get_parallel() > 1 ? $this->get_parallel() : 1);
+ # Force make to start a new jobserver.
+ clean_jobserver_makeflags();
}
$this->doit_in_builddir($this->{makecmd}, @_);
}
$this->doit_in_builddir($this->{makecmd}, @_);
&compat &addsubstvar &delsubstvar &excludefile &package_arch
&is_udeb &udeb_filename &debhelper_script_subst &escape_shell
&inhibit_log &load_log &write_log &dpkg_architecture_value
&compat &addsubstvar &delsubstvar &excludefile &package_arch
&is_udeb &udeb_filename &debhelper_script_subst &escape_shell
&inhibit_log &load_log &write_log &dpkg_architecture_value
- &sourcepackage &is_make_jobserver_unavailable &clean_makeflags);
+ &sourcepackage
+ &is_make_jobserver_unavailable &clean_jobserver_makeflags);
return; # no jobserver specified
}
return; # no jobserver specified
}
-# Cleans out job control options from MAKEFLAGS.
-sub clean_makeflags {
+# Cleans out jobserver options from MAKEFLAGS.
+sub clean_jobserver_makeflags {
if (exists $ENV{MAKEFLAGS}) {
if ($ENV{MAKEFLAGS} =~ /(?:^|\s)--jobserver-fds=(\d+)/) {
$ENV{MAKEFLAGS} =~ s/(?:^|\s)--jobserver-fds=\S+//g;
$ENV{MAKEFLAGS} =~ s/(?:^|\s)-j\b//g;
}
if (exists $ENV{MAKEFLAGS}) {
if ($ENV{MAKEFLAGS} =~ /(?:^|\s)--jobserver-fds=(\d+)/) {
$ENV{MAKEFLAGS} =~ s/(?:^|\s)--jobserver-fds=\S+//g;
$ENV{MAKEFLAGS} =~ s/(?:^|\s)-j\b//g;
}
- else {
- $ENV{MAKEFLAGS} =~ s/(?:^|\s)(?:(?:-j\s*|--jobs(?:=|\s+))(\d+)?|--jobs)\b//g;
- }
delete $ENV{MAKEFLAGS} if $ENV{MAKEFLAGS} =~ /^\s*$/;
}
}
delete $ENV{MAKEFLAGS} if $ENV{MAKEFLAGS} =~ /^\s*$/;
}
}
-# Parallel defaults to "unset" unless unavailable --jobserver-fds is detected
-# in MAKEFLAGS. This typically means dpkg-buildpackage was called with a -jX
-# option. Then -jX in MAKEFLAGS gets "consumed" by make invocation of
-# debian/rules and "converted" to --jobserver-fds. If jobserver is
-# unavailable, dh was probably called via debian/rules without "+" prefix (so
-# make has closed jobserver FDs). In such a case, MAKEFLAGS is cleaned from the
-# offending --jobserver-fds option in order to prevent further make invocations
-# from spitting warnings and disabling job support.
+# If make was using a jobserver, but it is not available, clean out
+# MAKEFLAGS so that further make invocations can start a new job
+# server.
if (is_make_jobserver_unavailable()) {
if (is_make_jobserver_unavailable()) {
- clean_makeflags();
- # Enable parallel (no maximum) if the package doesn't since it appears this
- # dh is called via dpkg-buildpackage -jX.
+ clean_jobserver_makeflags();
+ # Enable parallel (no maximum) if a value was not previously
+ # specified.
$dh{PARALLEL} = 0 if !defined $dh{PARALLEL};
}
$dh{PARALLEL} = 0 if !defined $dh{PARALLEL};
}
#### Test parallel building and related options / routines
@tmp = ( $ENV{MAKEFLAGS}, $ENV{DEB_BUILD_OPTIONS} );
#### Test parallel building and related options / routines
@tmp = ( $ENV{MAKEFLAGS}, $ENV{DEB_BUILD_OPTIONS} );
-# Test is_make_jobserver_unavailable and clean_makeflags.
+# Test is_make_jobserver_unavailable and clean_jobserver_makeflags.
$ENV{MAKEFLAGS} = "--jobserver-fds=103,104 -j";
ok(is_make_jobserver_unavailable(), "unavailable jobserver" );
$ENV{MAKEFLAGS} = "--jobserver-fds=103,104 -j";
ok(is_make_jobserver_unavailable(), "unavailable jobserver" );
+clean_jobserver_makeflags();
ok(! exists $ENV{MAKEFLAGS}, "unset makeflags");
$ENV{MAKEFLAGS} = "-a --jobserver-fds=103,104 -j -b";
ok(is_make_jobserver_unavailable(), "unavailable jobserver" );
ok(! exists $ENV{MAKEFLAGS}, "unset makeflags");
$ENV{MAKEFLAGS} = "-a --jobserver-fds=103,104 -j -b";
ok(is_make_jobserver_unavailable(), "unavailable jobserver" );
+clean_jobserver_makeflags();
is($ENV{MAKEFLAGS}, "-a -b", "clean makeflags");
$ENV{MAKEFLAGS} = " --jobserver-fds=1,2 -j ";
ok(! is_make_jobserver_unavailable(), "available jobserver" );
is($ENV{MAKEFLAGS}, "-a -b", "clean makeflags");
$ENV{MAKEFLAGS} = " --jobserver-fds=1,2 -j ";
ok(! is_make_jobserver_unavailable(), "available jobserver" );
+clean_jobserver_makeflags();
ok(! exists $ENV{MAKEFLAGS}, "unset makeflags");
$ENV{MAKEFLAGS} = "-a -j -b";
ok(! is_make_jobserver_unavailable(), "no specified jobserver");
ok(! exists $ENV{MAKEFLAGS}, "unset makeflags");
$ENV{MAKEFLAGS} = "-a -j -b";
ok(! is_make_jobserver_unavailable(), "no specified jobserver");
-clean_makeflags();
-is($ENV{MAKEFLAGS}, "-a -b", "clean makeflags");
+clean_jobserver_makeflags();
+is($ENV{MAKEFLAGS}, "-a -j -b", "clean makeflags does not remove -j");
$ENV{MAKEFLAGS} = "-a --jobs -b";
ok(! is_make_jobserver_unavailable(), "no specified jobserver");
$ENV{MAKEFLAGS} = "-a --jobs -b";
ok(! is_make_jobserver_unavailable(), "no specified jobserver");
-clean_makeflags();
-is($ENV{MAKEFLAGS}, "-a -b", "clean makeflags");
+clean_jobserver_makeflags();
+is($ENV{MAKEFLAGS}, "-a --jobs -b", "clean makeflags does not remove --jobs");
$ENV{MAKEFLAGS} = "-j6";
ok(! is_make_jobserver_unavailable(), "no specified jobserver");
$ENV{MAKEFLAGS} = "-j6";
ok(! is_make_jobserver_unavailable(), "no specified jobserver");
-clean_makeflags();
-ok(! exists $ENV{MAKEFLAGS}, "unset makeflags");
+clean_jobserver_makeflags();
+is($ENV{MAKEFLAGS}, "-j6", "clean makeflags does not remove -j6");
$ENV{MAKEFLAGS} = "-a -j6 --jobs=7";
ok(! is_make_jobserver_unavailable(), "no specified jobserver");
$ENV{MAKEFLAGS} = "-a -j6 --jobs=7";
ok(! is_make_jobserver_unavailable(), "no specified jobserver");
-clean_makeflags();
-is($ENV{MAKEFLAGS}, "-a", "clean makeflags");
+clean_jobserver_makeflags();
+is($ENV{MAKEFLAGS}, "-a -j6 --jobs=7", "clean makeflags does not remove -j or --jobs");
$ENV{MAKEFLAGS} = "-j6 --jobserver-fds=5,6 --jobs=8";
ok(is_make_jobserver_unavailable(), "unavailable jobserver");
$ENV{MAKEFLAGS} = "-j6 --jobserver-fds=5,6 --jobs=8";
ok(is_make_jobserver_unavailable(), "unavailable jobserver");
+clean_jobserver_makeflags();
is($ENV{MAKEFLAGS}, "-j6 --jobs=8", "jobserver options removed");
# Test parallel building with makefile build system.
is($ENV{MAKEFLAGS}, "-j6 --jobs=8", "jobserver options removed");
# Test parallel building with makefile build system.