]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - make/directive.pm
Update copyright headers.
[user/henk/code/inspircd.git] / make / directive.pm
index cdf869e5ec62d9d832ab4d684e53d384c3158835..698934001e07c3f7c763934faee598523bd9e2c3 100644 (file)
@@ -1,7 +1,7 @@
 #
 # InspIRCd -- Internet Relay Chat Daemon
 #
-#   Copyright (C) 2016 Peter Powell <petpow@saberuk.com>
+#   Copyright (C) 2016-2021 Sadie Powell <sadie@witchery.services>
 #
 # This file is part of InspIRCd.  InspIRCd is free software: you can
 # redistribute it and/or modify it under the terms of the GNU General Public
 
 package make::directive;
 
-BEGIN {
-       require 5.10.0;
-}
-
-use feature ':5.10';
+use v5.10.0;
 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 +85,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, '';
@@ -131,11 +120,15 @@ sub __error {
        } else {
                push @message, 'If you believe this error to be a bug then you can file a bug report';
                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_shrink $file}";
        }
        push @message, '';
 
        push @message, 'If you would like help with fixing this problem then visit our IRC';
-       push @message, 'channel at irc.inspircd.org #InspIRCd for support.';
+       push @message, 'channel at irc.inspircd.org #InspIRCd or create a support discussion';
+       push @message, 'at https://github.com/inspircd/inspircd/discussions.';
        push @message, '';
 
        print_error @message;
@@ -152,7 +145,7 @@ sub __function_execute {
        # Try to execute the command...
        chomp(my $result = `$command ${\DIRECTIVE_ERROR_PIPE}`);
        unless ($?) {
-               print_format "Execution of `<|GREEN $command|>` succeeded: <|BOLD $result|>\n";
+               say console_format "Execution of `<|GREEN $command|>` succeeded: <|BOLD $result|>";
                return $result;
        }
 
@@ -160,14 +153,14 @@ sub __function_execute {
        if (defined $environment && $environment ne '') {
                $environment = __environment 'INSPIRCD_', $environment;
                if (defined $ENV{$environment}) {
-                       print_format "Execution of `<|GREEN $command|>` failed; using the environment: <|BOLD $ENV{$environment}|>\n";
+                       say console_format "Execution of `<|GREEN $command|>` failed; using the environment: <|BOLD $ENV{$environment}|>";
                        return $ENV{$environment};
                }
        }
 
        # If all else fails then look for the defaults..
        if (defined $defaults) {
-               print_format "Execution of `<|GREEN $command|>` failed; using the defaults: <|BOLD $defaults|>\n";
+               say console_format "Execution of `<|GREEN $command|>` failed; using the defaults: <|BOLD $defaults|>";
                return $defaults;
        }
 
@@ -181,25 +174,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";
+               say console_format "Found the <|GREEN $name|> compiler flags for <|GREEN ${\module_shrink $file}|> using pkg-config: <|BOLD $flags|>";
                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";
+               say console_format "Found the <|GREEN $name|> compiler flags for <|GREEN ${\module_shrink $file}|> using the environment: <|BOLD $ENV{$key}|>";
                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";
+               say console_format "Using the default <|GREEN $name|> compiler flags for <|GREEN ${\module_shrink $file}|>: <|BOLD $defaults|>";
                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 {
@@ -208,25 +201,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";
+               say console_format "Found the <|GREEN $name|> linker flags for <|GREEN ${\module_shrink $file}|> using pkg-config: <|BOLD $flags|>";
                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";
+               say console_format "Found the <|GREEN $name|> linker flags for <|GREEN ${\module_shrink $file}|> using the environment: <|BOLD $ENV{$key}|>";
                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";
+               say console_format "Using the default <|GREEN $name|> linker flags for <|GREEN ${\module_shrink $file}|>: <|BOLD $defaults|>";
                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 {
@@ -294,18 +287,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";
+               say console_format "Found the <|GREEN $name|> vendor directory for <|GREEN ${\module_shrink $file}|> using the environment: <|BOLD $ENV{$key}|>";
                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";
+               say console_format "Using the default <|GREEN $name|> vendor directory for <|GREEN ${\module_shrink $file}|>: <|BOLD $directory|>";
                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 {