Perl5::Build::Warnings - Parse make output for build-time warnings
use Perl5::Build::Warnings; my $self = Perl5::Build::Warnings->new( { file => '/path/to/make.log' } ); my $hashref = $self->get_warnings_groups; my $arrayref = $self->get_warnings; $self->report_warnings_groups; $arrayref = $self->get_warnings_for_group('Wunused-variable'); $arrayref = $self->get_warnings_for_source('op.c');
Perl5::Build::Warnings is a module for use in studying build-time warnings emitted by make when building the Perl 5 core distribution from source code.
CPAN module Capture::Tiny is used in this library's test suite, but not in the module itself. There are currently no other prerequisites not found in the Perl 5 core distribution.
The module assumes that the user has logged the output of make (or make test_prep -- but not make test -- or Windows equivalents) to a plain-text file. Something like:
make test_prep 2>&1 > /path/to/make.log
The build log may be gzipped-compressed, e.g.:
make test_prep 2>&1 | gzip -c > /path/to/make.log.gz
The module assumes that within such a logfile, warnings are recorded in this format:
op.c:5468:34: warning: argument ‘o’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Wclobbered]
That is,
<filename>:<line_numbert>:<character_number>: warning: <warning_description> [-<Wwarning_class>]
Note that the first field recorded, filename may be either the basename of a file in the top-level of the source code or a relative path to a file beneath the top-level.
filename
Note further that the last field recorded, the class of warning, starts with an open bracket ([), followed by a hyphen and an upper-case 'W' (-W), followed by the warning class, followed by a close bracket (]). In this module we will ignore the open and close brackets and the hyphen, but we will capture and report the upper-case 'W'. Hence, whereas the log will record
[
-W
]
[-Wclobbered]
... this module will store and report that information as:
Wclobbered
This is done in part because we may wish to use this data on the command-line and the hyphen is likely to be significant to the shell.
new()
Purpose
Perl5::Build::Warnings constructor.
Arguments
$file = "./t/data/make.g++-8-list-util-fallthrough.output.txt"; $self = Perl5::Build::Warnings->new( { file => $file } );
Single hash reference with one required element, file, whose value is a path to a file holding a log of make's output.
file
Return Value
Perl5::Build::Warnings object.
get_warnings_groups()
Identify the types of build-time warnings found in the make log and the number of each such type.
$hashref = $self->get_warnings_groups();
None.
Reference to a hash whose elements are keyed on warnings classes (e.g., Wclobbered). The value of each element is the number of times such class appeared in the file.
report_warnings_groups()
Pretty-print to STDOUT the information returned by get_warnings_groups.
get_warnings_groups
$self->report_warnings_groups;
Implicitly returns a Perl-true value.
Comment
The information reported will appear as below (2 leading whitespaces), but may change in the future.
Wcast-function-type 6 Wclobbered 2 Wformat-overflow= 2 Wignored-qualifiers 4 Wimplicit-fallthrough= 32 Wmultistatement-macros 1 Wpragmas 3
get_warnings()
Generate a list of all warnings.
$arrayref = $self->get_warnings();
Array reference, each element of which is a reference to a hash holding a parsing of the elements of an individual warning.
get_warnings_for_group()
Get a list of all the warnings for one specified warnings group.
$arrayref = $self->get_warnings_for_group("Wduplicate-decl-specifier");
String holding name of one group of warnings. Each such string must begin with an upper-case W. As mentioned above, we drop the leading hyphen to avoid confusing the shell.
W
Array reference, each element of which is a reference to a hash holding a parsing of the elements of an individual warning of the specified warnings group.
get_warnings_for_source()
Get a list of all the warnings generated from one specified source file.
$arrayref = $self->get_warnings_for_source('op.c');
String holding name of one source file. Note that there may be some ambiguity here. Use with caution.
Array reference, each element of which is a reference to a hash holding a parsing of the elements of an individual warning of the specified warnings source.
None reported so far. The author prefers patches filed at http://rt.cpan.org rather than pull requests at github.
James E Keenan CPAN ID: JKEENAN jkeenan@cpan.org http://thenceforward.net/perl/modules/Perl5-Parse-MakeLog-Warnings
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
perl(1).
To install Perl5::Build::Warnings, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Perl5::Build::Warnings
CPAN shell
perl -MCPAN -e shell install Perl5::Build::Warnings
For more information on module installation, please visit the detailed CPAN module installation guide.