summaryrefslogtreecommitdiff
path: root/Debian/Debhelper/Dh_Buildsystems.pm
diff options
context:
space:
mode:
authorModestas Vainius <modestas@vainius.eu>2009-10-28 15:49:34 -0400
committerJoey Hess <joey@gnu.kitenet.net>2009-10-28 15:49:34 -0400
commitdace0773fe5f66fdf040f54383322e21a65fa1e8 (patch)
treed03e084c1980708e31773b1b422cfec4e5546c7d /Debian/Debhelper/Dh_Buildsystems.pm
parent834d95aaba24e5cee1c5a74078a09443f5e122a7 (diff)
Support parallel building in makefile buildsystem
1) Add routine to Dh_Lib (used by dh and makefile.pm) which is capable of detecting make jobserver and job control options from the MAKEFLAGS environment variable. It also generates and returns a clean up MAKEFLAGS from these options. 2) Add --parallel option to build system framework which allows source packages to specify that they support parallel building. Optional value for this option is the number of maximum parallel process to allow. However, the actual number of parallel process (if any) for the specific build is determined from DEB_BUILD_OPTIONS env variable as specified by Debian Policy. By default (no --parallel option) parallel is neither enabled nor disabled (depends on the external environment). However, dh may pass --parallel to dh_auto_* implicitly in case 4) described below. 3) Add parallel support for makefile buildsystem. This implementation forcefully starts a new make job server (or disables parallel) for the number of process requested. If --parallel was not passed to the build system at all, the build system will only clean up MAKEFLAGS from stale jobserver options to avoid pointless make warnings. 4) If dh detects that it is being run by dpkg-buildpackage -jX and it is NOT run with "+" prefix from debian/rules (i.e. jobserver is not reachable), it enables --parallel implicitly. This closes: #532805. Signed-off-by: Modestas Vainius <modestas@vainius.eu>
Diffstat (limited to 'Debian/Debhelper/Dh_Buildsystems.pm')
-rw-r--r--Debian/Debhelper/Dh_Buildsystems.pm42
1 files changed, 42 insertions, 0 deletions
diff --git a/Debian/Debhelper/Dh_Buildsystems.pm b/Debian/Debhelper/Dh_Buildsystems.pm
index 4986267..3908145 100644
--- a/Debian/Debhelper/Dh_Buildsystems.pm
+++ b/Debian/Debhelper/Dh_Buildsystems.pm
@@ -30,6 +30,7 @@ my $opt_buildsys;
my $opt_sourcedir;
my $opt_builddir;
my $opt_list;
+my $opt_parallel;
sub create_buildsystem_instance {
my $system=shift;
@@ -47,6 +48,9 @@ sub create_buildsystem_instance {
if (!exists $bsopts{sourcedir} && defined $opt_sourcedir) {
$bsopts{sourcedir} = ($opt_sourcedir eq "") ? undef : $opt_sourcedir;
}
+ if (!exists $bsopts{parallel}) {
+ $bsopts{parallel} = $opt_parallel;
+ }
return $module->new(%bsopts);
}
@@ -122,9 +126,47 @@ sub buildsystems_init {
"l" => \$opt_list,
"list" => \$opt_list,
+
+ "j:i" => \$opt_parallel,
+ "parallel:i" => \$opt_parallel,
);
$args{options}{$_} = $options{$_} foreach keys(%options);
Debian::Debhelper::Dh_Lib::init(%args);
+
+ # Post-process parallel building option. Initially $opt_parallel may have
+ # such values:
+ # * undef - no --parallel option was specified. This tells buildsystem class
+ # not to mess with MAKEFLAGS (with the exception of cleaning MAKEFLAGS
+ # from pointless unavailable jobserver options to avoid warnings) nor
+ # enable parallel.
+ # * 1 - --parallel=1 option was specified, hence the package should never be
+ # built in parallel mode. Cleans MAKEFLAGS if needed.
+ # * 0 - --parallel was specified without interger argument meaning package
+ # does not want to enforce limit on maximum number of parallel processes.
+ # * N > 1 - --parallel=N was specified where N is the maximum number parallel
+ # processes the package wants to enforce.
+ # Taken DEB_BUILD_OPTIONS and all this into account, set $opt_parallel to the
+ # number of parallel processes to be used for *this* build.
+ if (defined $opt_parallel) {
+ if ($opt_parallel >= 0 && 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) {
+ $opt_parallel = $n if $opt_parallel == 0 || $n < $opt_parallel;
+ }
+ else {
+ # Invalid value in the parallel tag. Disable.
+ $opt_parallel = 1;
+ }
+ }
+ else {
+ # In case invalid number was passed
+ $opt_parallel = 1;
+ }
+ }
}
sub buildsystems_list {