]> git.donarmstrong.com Git - debhelper.git/blobdiff - Debian/Debhelper/Dh_Buildsystems.pm
support unlimited parallel jobs
[debhelper.git] / Debian / Debhelper / Dh_Buildsystems.pm
index a9a6b9141917e444514966397ef87ce2b2b7091e..fc06a2ac16a27e3f32583b4d91473c6bf850dce1 100644 (file)
@@ -17,18 +17,20 @@ our @EXPORT=qw(&buildsystems_init &buildsystems_do &load_buildsystem &load_all_b
 # Historical order must be kept for backwards compatibility. New
 # build systems MUST be added to the END of the list.
 our @BUILDSYSTEMS = (
-    "autoconf",
-    "perl_makemaker",
-    "makefile",
-    "python_distutils",
-    "perl_build",
-    "cmake",
+       "autoconf",
+       "perl_makemaker",
+       "makefile",
+       "python_distutils",
+       "perl_build",
+       "cmake",
+       "ant",
 );
 
 my $opt_buildsys;
 my $opt_sourcedir;
 my $opt_builddir;
 my $opt_list;
+my $opt_parallel;
 
 sub create_buildsystem_instance {
        my $system=shift;
@@ -46,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);
 }
 
@@ -107,6 +112,8 @@ sub load_all_buildsystems {
 
 sub buildsystems_init {
        my %args=@_;
+       
+       my $max_parallel=-1; # unlimited
 
        # Available command line options
        my %options = (
@@ -121,9 +128,33 @@ sub buildsystems_init {
 
            "l" => \$opt_list,
            "list" => \$opt_list,
+
+           "max-parallel:i" => \$max_parallel,
        );
        $args{options}{$_} = $options{$_} foreach keys(%options);
        Debian::Debhelper::Dh_Lib::init(%args);
+       set_parallel($max_parallel);
+}
+
+sub set_parallel {
+       my $max=shift;
+
+       $opt_parallel=1;
+
+       if (exists $ENV{DEB_BUILD_OPTIONS}) {
+               # Parse parallel=n tag
+               foreach my $opt (split(/\s+/, $ENV{DEB_BUILD_OPTIONS})) {
+                       if ($opt =~ /^parallel=([-\d]+)$/) {
+                               my $n=$1;
+                               if ($n > 0 && ($max == -1 || $n < $max)) {
+                                       $opt_parallel = $n;
+                               }
+                               else {
+                                       $opt_parallel = $max;
+                               }
+                       }
+               }
+       }
 }
 
 sub buildsystems_list {