diff options
author | Joey Hess <joey@gnu.kitenet.net> | 2009-10-28 17:46:45 -0400 |
---|---|---|
committer | Joey Hess <joey@gnu.kitenet.net> | 2009-10-28 17:46:45 -0400 |
commit | 22272aacfd9a988e722ba3fcb9b93432f5a1e29a (patch) | |
tree | 969bae8fa4a7795d3f280b0b87738e052b885713 /Debian/Debhelper/Dh_Buildsystems.pm | |
parent | 2ec1c8af7f5216b574a93240e2a68a896b0896c1 (diff) |
refactor --parallel processing
Use a function to set the value rather than post-processing.
Diffstat (limited to 'Debian/Debhelper/Dh_Buildsystems.pm')
-rw-r--r-- | Debian/Debhelper/Dh_Buildsystems.pm | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/Debian/Debhelper/Dh_Buildsystems.pm b/Debian/Debhelper/Dh_Buildsystems.pm index 39081458..b0e0a568 100644 --- a/Debian/Debhelper/Dh_Buildsystems.pm +++ b/Debian/Debhelper/Dh_Buildsystems.pm @@ -127,46 +127,38 @@ sub buildsystems_init { "l" => \$opt_list, "list" => \$opt_list, - "j:i" => \$opt_parallel, - "parallel:i" => \$opt_parallel, + "j:i" => \&set_parallel, + "parallel:i" => \&set_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; +sub set_parallel { + my ($option, $value)=@_; + + if ($value >= 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) { + if ($value == 0 || $n < $value) { + $opt_parallel = $n; } else { - # Invalid value in the parallel tag. Disable. - $opt_parallel = 1; + $opt_parallel = $value; } } else { - # In case invalid number was passed + # Invalid value in the parallel tag. Disable. $opt_parallel = 1; } } + else { + $opt_parallel = 1; + } } sub buildsystems_list { |