Skip to content

Commit

Permalink
Issue RotherOSS#28: add features in the cpanfile
Browse files Browse the repository at this point in the history
  • Loading branch information
bschmalhofer committed May 15, 2020
1 parent fa80123 commit 1c87408
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions bin/otobo.CheckModules.pl
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@
);

if ($DoPrintCpanfile) {
PrintCpanfile( \@NeededModules );
PrintCpanfile( \@NeededModules, 1, 1 );
}
elsif ($DoPrintPackageList) {
my %PackageList = CollectPackageInfo( \@NeededModules );
Expand Down Expand Up @@ -955,12 +955,37 @@ sub GetInstallCommand {
}

sub PrintCpanfile {
my ($NeededModules) = @_;
my ($NeededModules, $FilterRequired, $HandleFeatures) = @_;

# print the required modules
# collect the modules per feature
my %ModulesForFeature;
MODULE:
for my $Module ( $NeededModules->@* ) {
if ( $Module->{Required} ) {
if ( ! $FilterRequired || $Module->{Required} ) {
say "requires '$Module->{Module}';";

next MODULE;
}

next MODULE unless $HandleFeatures;
next MODULE unless $Module->{Features};
next MODULE unless $Module->{Features};
next MODULE unless ref $Module->{Features} eq 'ARRAY';

for my $Feature ( $Module->{Features}->@* ) {
$ModulesForFeature{$Feature} //= [];
push $ModulesForFeature{$Feature}->@*, $Module;
}
}

# now print out the features
for my $Feature ( sort keys %ModulesForFeature ) {
my $Desc = $FeatureDescription{$Feature} // "Suppport for $Feature";
say '';
say "feature '$Feature', '$Desc' => sub {";
PrintCpanfile( $ModulesForFeature{$Feature}, 0, 0 );
say '};';
}

return;
Expand Down

0 comments on commit 1c87408

Please sign in to comment.