More consistently show modules without the file prefix and suffix.

This commit is contained in:
Sadie Powell 2020-10-15 17:13:57 +01:00
parent ff88faf931
commit 78c79a379a
3 changed files with 37 additions and 31 deletions

21
configure vendored
View File

@ -353,8 +353,8 @@ Would you like to enable extra modules manually?
EOQ
if (prompt_bool $interactive, $question, 0) {
foreach my $extra (<$RealDir/src/modules/extra/m_*.cpp>) {
my $module_name = basename $extra, '.cpp';
if (prompt_bool $interactive, "Would you like to enable $module_name?", 0) {
my $module_name = module_shrink $extra;
if (prompt_bool $interactive, "Would you like to enable the <|BOLD $module_name|> module?", 0) {
enable_extras $module_name;
}
}
@ -441,8 +441,7 @@ Configuration is complete! You have chosen to build with the following settings:
EOM
for my $file (<$RealDir/src/modules/m_*>) {
my $module = basename $file, '.cpp';
say " * $module" if -l $file;
say " * ${\module_shrink $file}" if -l $file;
}
my @makeargs;
@ -490,7 +489,7 @@ sub list_extras () {
my @sources = map { File::Spec->case_tolerant() ? lc($_) : $_ } (readdir($dd));
closedir $dd;
undef $dd;
my $maxlen = (sort { $b <=> $a } (map {length($_)} (@extras)))[0];
my $maxlen = (sort { $b <=> $a } (map { length module_shrink $_ } (@extras)))[0];
my %extras = ();
EXTRA: for my $extra (@extras) {
next if (File::Spec->curdir() eq $extra || File::Spec->updir() eq $extra);
@ -558,9 +557,9 @@ EXTRA: for my $extra (@extras) {
for my $extra (sort {$a cmp $b} keys(%extras)) {
my $text = $extras{$extra};
if ($text =~ m/needed by/ && $text !~ m/enabled/) {
printf "\e[31;1;5m%-*s = %s%s\e[0m\n", $maxlen, $extra, $text, ($text =~ m/needed by/ ? ")" : "");
printf "\e[31;1;5m%-*s = %s%s\e[0m\n", $maxlen, module_shrink($extra), $text, ($text =~ m/needed by/ ? ")" : "");
} else {
printf "%-*s = %s%s\n", $maxlen, $extra, $text, ($text =~ m/needed by/ ? "\e[0m)" : "");
printf "%-*s = %s%s\n", $maxlen, module_shrink($extra), $text, ($text =~ m/needed by/ ? "\e[0m)" : "");
}
}
return keys(%extras) if wantarray; # Can be used by manage_extras.
@ -571,8 +570,8 @@ sub enable_extras(@) {
my $extradir = catdir $moduledir, 'extra';
for my $extra (@_) {
my $shortname = $extra =~ s/(?:^m_|\.cpp$)//gr;
my $extrafile = "m_$shortname.cpp";
my $shortname = module_shrink $extra;
my $extrafile = module_expand $extra;
my $extrapath = catfile $extradir, $extrafile;
if (!-f $extrapath) {
@ -602,8 +601,8 @@ sub disable_extras(@) {
my $extradir = catdir $moduledir, 'extra';
for my $extra (@_) {
my $shortname = $extra =~ s/(?:^m_|\.cpp$)//gr;
my $extrafile = "m_$shortname.cpp";
my $shortname = module_shrink $extra;
my $extrafile = module_expand $extra;
my $modulepath = catfile $moduledir, $extrafile;
my $extrapath = catfile $extradir, $extrafile;

View File

@ -52,6 +52,8 @@ our @EXPORT = qw(CONFIGURE_CACHE_FILE
run_test
test_file
test_header
module_expand
module_shrink
write_configure_cache
get_compiler_info
find_compiler
@ -221,6 +223,18 @@ sub test_header($$;$) {
return !$?;
}
sub module_expand($) {
my $module = shift;
$module = "m_$module" unless $module =~ /^(?:m|core)_/;
$module = "$module.cpp" unless $module =~ /\.cpp$/;
return $module;
}
sub module_shrink($) {
my $module = basename shift;
return $module =~ s/(?:^m_|\.cpp$)//gr;
}
sub write_configure_cache(%) {
unless (-e CONFIGURE_DIRECTORY) {
print_format "Creating <|GREEN ${\abs2rel CONFIGURE_DIRECTORY, CONFIGURE_ROOT}|> ...\n";

View File

@ -27,7 +27,7 @@ use feature ':5.10';
use strict;
use warnings FATAL => qw(all);
use File::Basename qw(basename dirname);
use File::Basename qw(dirname);
use File::Spec::Functions qw(catdir);
use Exporter qw(import);
@ -89,13 +89,6 @@ sub __environment {
return $prefix . uc $suffix;
}
sub __module {
my $file = shift;
my $name = basename $file, '.cpp';
$name =~ s/^m_//;
return $name;
}
sub __error {
my ($file, @message) = @_;
push @message, '';
@ -133,7 +126,7 @@ sub __error {
push @message, 'at https://github.com/inspircd/inspircd/issues';
push @message, '';
push @message, 'You can also refer to the documentation page for this module at';
push @message, "https://docs.inspircd.org/3/modules/${\__module $file}";
push @message, "https://docs.inspircd.org/3/modules/${\module_shrink $file}";
}
push @message, '';
@ -184,25 +177,25 @@ sub __function_find_compiler_flags {
# Try to look up the compiler flags with pkg-config...
chomp(my $flags = `pkg-config --cflags $name ${\DIRECTIVE_ERROR_PIPE}`);
unless ($?) {
print_format "Found the <|GREEN $name|> compiler flags for <|GREEN ${\__module $file}|> using pkg-config: <|BOLD $flags|>\n";
print_format "Found the <|GREEN $name|> compiler flags for <|GREEN ${\module_shrink $file}|> using pkg-config: <|BOLD $flags|>\n";
return $flags;
}
# If looking up with pkg-config fails then check the environment...
my $key = __environment 'INSPIRCD_CXXFLAGS_', $name;
if (defined $ENV{$key}) {
print_format "Found the <|GREEN $name|> compiler flags for <|GREEN ${\__module $file}|> using the environment: <|BOLD $ENV{$key}|>\n";
print_format "Found the <|GREEN $name|> compiler flags for <|GREEN ${\module_shrink $file}|> using the environment: <|BOLD $ENV{$key}|>\n";
return $ENV{$key};
}
# If all else fails then look for the defaults..
if (defined $defaults) {
print_format "Using the default <|GREEN $name|> compiler flags for <|GREEN ${\__module $file}|>: <|BOLD $defaults|>\n";
print_format "Using the default <|GREEN $name|> compiler flags for <|GREEN ${\module_shrink $file}|>: <|BOLD $defaults|>\n";
return $defaults;
}
# We can't find it via pkg-config, via the environment, or via the defaults so give up.
__error $file, "unable to find the <|GREEN $name|> compiler flags for <|GREEN ${\__module $file}|>!";
__error $file, "unable to find the <|GREEN $name|> compiler flags for <|GREEN ${\module_shrink $file}|>!";
}
sub __function_find_linker_flags {
@ -211,25 +204,25 @@ sub __function_find_linker_flags {
# Try to look up the linker flags with pkg-config...
chomp(my $flags = `pkg-config --libs $name ${\DIRECTIVE_ERROR_PIPE}`);
unless ($?) {
print_format "Found the <|GREEN $name|> linker flags for <|GREEN ${\__module $file}|> using pkg-config: <|BOLD $flags|>\n";
print_format "Found the <|GREEN $name|> linker flags for <|GREEN ${\module_shrink $file}|> using pkg-config: <|BOLD $flags|>\n";
return $flags;
}
# If looking up with pkg-config fails then check the environment...
my $key = __environment 'INSPIRCD_CXXFLAGS_', $name;
if (defined $ENV{$key}) {
print_format "Found the <|GREEN $name|> linker flags for <|GREEN ${\__module $file}|> using the environment: <|BOLD $ENV{$key}|>\n";
print_format "Found the <|GREEN $name|> linker flags for <|GREEN ${\module_shrink $file}|> using the environment: <|BOLD $ENV{$key}|>\n";
return $ENV{$key};
}
# If all else fails then look for the defaults..
if (defined $defaults) {
print_format "Using the default <|GREEN $name|> linker flags for <|GREEN ${\__module $file}|>: <|BOLD $defaults|>\n";
print_format "Using the default <|GREEN $name|> linker flags for <|GREEN ${\module_shrink $file}|>: <|BOLD $defaults|>\n";
return $defaults;
}
# We can't find it via pkg-config, via the environment, or via the defaults so give up.
__error $file, "unable to find the <|GREEN $name|> linker flags for <|GREEN ${\__module $file}|>!";
__error $file, "unable to find the <|GREEN $name|> linker flags for <|GREEN ${\module_shrink $file}|>!";
}
sub __function_require_compiler {
@ -297,18 +290,18 @@ sub __function_vendor_directory {
# Try to look the directory up in the environment...
my $key = __environment 'INSPIRCD_VENDOR_', $name;
if (defined $ENV{$key}) {
print_format "Found the <|GREEN $name|> vendor directory for <|GREEN ${\__module $file}|> using the environment: <|BOLD $ENV{$key}|>\n";
print_format "Found the <|GREEN $name|> vendor directory for <|GREEN ${\module_shrink $file}|> using the environment: <|BOLD $ENV{$key}|>\n";
return $ENV{$key};
}
my $directory = catdir(VENDOR_DIRECTORY, $name);
if (-d $directory) {
print_format "Using the default <|GREEN $name|> vendor directory for <|GREEN ${\__module $file}|>: <|BOLD $directory|>\n";
print_format "Using the default <|GREEN $name|> vendor directory for <|GREEN ${\module_shrink $file}|>: <|BOLD $directory|>\n";
return $directory;
}
# We can't find it via the environment or via the filesystem so give up.
__error $file, "unable to find the <|GREEN $name|> vendor directory for <|GREEN ${\__module $file}|>!";
__error $file, "unable to find the <|GREEN $name|> vendor directory for <|GREEN ${\module_shrink $file}|>!";
}
sub __function_warning {