summaryrefslogtreecommitdiff
path: root/Debian/Debhelper/Dh_Buildsystems.pm
diff options
context:
space:
mode:
authorModestas Vainius <modestas@vainius.eu>2009-06-08 23:36:50 +0300
committerModestas Vainius <modestas@vainius.eu>2009-06-08 23:36:50 +0300
commit299cb17e2a2a2524c628c0581ba2a85b2d9b2bed (patch)
tree0dec89680ed120148db9a878e31ad85b312aeda8 /Debian/Debhelper/Dh_Buildsystems.pm
parentf897611a77726655aea258af0c4d52a8ce759ebc (diff)
--list all buildsystems (including all 3rd party ones) dynamically.
* Implement a new sub in Dh_Buildsystems (load_all_buildsystems()) which dynamically tries to find all buildsystem class files in perl module directories (@INC) and clearly marks third party buildsystems as such. * Use this sub for listing buildsystems so now --list easily helps a user discover *all* buildsystem classes installed on his/her system clearly separating built-in ones from third party ones.
Diffstat (limited to 'Debian/Debhelper/Dh_Buildsystems.pm')
-rw-r--r--Debian/Debhelper/Dh_Buildsystems.pm53
1 files changed, 42 insertions, 11 deletions
diff --git a/Debian/Debhelper/Dh_Buildsystems.pm b/Debian/Debhelper/Dh_Buildsystems.pm
index be29ac5c..3cfaffbc 100644
--- a/Debian/Debhelper/Dh_Buildsystems.pm
+++ b/Debian/Debhelper/Dh_Buildsystems.pm
@@ -9,9 +9,10 @@ package Debian::Debhelper::Dh_Buildsystems;
use strict;
use warnings;
use Debian::Debhelper::Dh_Lib;
+use File::Spec;
use base 'Exporter';
-our @EXPORT=qw(&buildsystems_init &buildsystems_do &load_buildsystem);
+our @EXPORT=qw(&buildsystems_init &buildsystems_do &load_buildsystem &load_all_buildsystems);
# Historical order must be kept for backwards compatibility. New
# buildsystems MUST be added to the END of the list.
@@ -62,6 +63,40 @@ sub load_buildsystem {
return;
}
+sub load_all_buildsystems {
+ my $incs=shift || \@INC;
+ my (%buildsystems, @buildsystems);
+
+ for my $inc (@$incs) {
+ my $path = File::Spec->catdir($inc, "Debian/Debhelper/Buildsystem");
+ if (-d $path) {
+ for my $module_path (glob "$path/*.pm") {
+ my $name = basename($module_path);
+ $name =~ s/\.pm$//;
+ next if exists $buildsystems{$name};
+ $buildsystems{$name} = create_buildsystem_instance($name, @_);
+ }
+ }
+ }
+
+ # Push debhelper built-in buildsystems first
+ for my $name (@BUILDSYSTEMS) {
+ error("Debhelper built-in buildsystem '$name' could not be found/loaded")
+ if not exists $buildsystems{$name};
+ push @buildsystems, $buildsystems{$name};
+ delete $buildsystems{$name};
+ }
+
+ # The rest are 3rd party buildsystems
+ for my $name (keys %buildsystems) {
+ my $inst = $buildsystems{$name};
+ $inst->{thirdparty} = 1;
+ push @buildsystems, $inst;
+ }
+
+ return @buildsystems;
+}
+
sub buildsystems_init {
my %args=@_;
@@ -90,22 +125,18 @@ sub buildsystems_list {
# List buildsystems (including auto and specified status)
my ($auto, $specified);
- for my $system (@BUILDSYSTEMS) {
- my $inst = create_buildsystem_instance($system, build_step => undef);
+ my @buildsystems = load_all_buildsystems(undef, build_step => undef);
+ for my $inst (@buildsystems) {
my $is_specified = defined $opt_buildsys && $opt_buildsys eq $inst->NAME();
if (! defined $specified && defined $opt_buildsys && $opt_buildsys eq $inst->NAME()) {
$specified = $inst->NAME();
}
- elsif (! defined $auto && $inst->check_auto_buildable($step)) {
+ elsif (! defined $auto && ! $inst->{thirdparty} && $inst->check_auto_buildable($step)) {
$auto = $inst->NAME();
}
- printf("%s - %s\n", $inst->NAME(), $inst->DESCRIPTION());
- }
- # List a specified 3rd party buildsystem too.
- if (! defined $specified && defined $opt_buildsys) {
- my $inst = create_buildsystem_instance($opt_buildsys, build_step => undef);
- printf("%s - %s.\n", $inst->NAME(), $inst->DESCRIPTION());
- $specified = $inst->NAME();
+ printf("%s - %s", $inst->NAME(), $inst->DESCRIPTION());
+ print " [3rd party]" if $inst->{thirdparty};
+ print "\n";
}
print "\n";
print "Auto-selected: $auto\n" if defined $auto;