mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
build-aux: rewrite duplicate header checker in Python
As part of an goal to eliminate Perl from libvirt build tools, rewrite the prohibit-duplicate-header.pl tool in Python. This was a straight conversion, manually going line-by-line to change the syntax from Perl to Python. Thus the overall structure of the file and approach is the same. Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
|
||||
my $file = " ";
|
||||
my $ret = 0;
|
||||
my %includes = ( );
|
||||
my $lineno = 0;
|
||||
|
||||
while (<>) {
|
||||
if (not $file eq $ARGV) {
|
||||
%includes = ( );
|
||||
$file = $ARGV;
|
||||
$lineno = 0;
|
||||
}
|
||||
$lineno++;
|
||||
if (/^# *include *[<"]([^>"]*\.h)[">]/) {
|
||||
$includes{$1}++;
|
||||
if ($includes{$1} == 2) {
|
||||
$ret = 1;
|
||||
print STDERR "$ARGV:$lineno: $_";
|
||||
print STDERR "Do not include a header more than once per file\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
exit $ret;
|
||||
@@ -2166,8 +2166,8 @@ endif
|
||||
|
||||
# Don't include duplicate header in the source (either *.c or *.h)
|
||||
prohibit-duplicate-header:
|
||||
$(AM_V_GEN)$(VC_LIST_EXCEPT) | $(GREP) '\.[chx]$$' | xargs \
|
||||
$(PERL) -W $(top_srcdir)/build-aux/prohibit-duplicate-header.pl
|
||||
$(AM_V_GEN)$(VC_LIST_EXCEPT) | $(GREP) '\.[chx]$$' | $(RUNUTF8) xargs \
|
||||
$(PYTHON) $(top_srcdir)/scripts/prohibit-duplicate-header.py
|
||||
|
||||
spacing-check:
|
||||
$(AM_V_GEN)$(VC_LIST) | $(GREP) '\.c$$' | xargs \
|
||||
|
||||
Reference in New Issue
Block a user