mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-23 12:47:31 +02:00
105 lines
1.7 KiB
Perl
105 lines
1.7 KiB
Perl
|
#!/usr/bin/perl
|
||
|
#
|
||
|
# rptflt.pl - Filter known issues from KiCad DRC reports
|
||
|
#
|
||
|
# Written 2014 by Werner Almesberger
|
||
|
# Copyright 2014 Werner Almesberger
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or modify
|
||
|
# it under the terms of the GNU General Public License as published by
|
||
|
# the Free Software Foundation; either version 2 of the License, or
|
||
|
# (at your option) any later version.
|
||
|
#
|
||
|
|
||
|
#
|
||
|
# Usage:
|
||
|
#
|
||
|
# - generate a DRC report file with pcbnew, e.g., foo.rpt
|
||
|
# - review report file for any real issues
|
||
|
# - rename foo.rpt to foo.exceptions
|
||
|
# - to check for new errors, generate new report file, then run
|
||
|
# rptflt.pl foo.exceptions foo.rpt
|
||
|
#
|
||
|
|
||
|
|
||
|
sub compact
|
||
|
{
|
||
|
local ($m);
|
||
|
|
||
|
die if $#e != 2;
|
||
|
die unless $e[0] =~ /^ErrType\(\d+\):\s+(.*)\s*$/;
|
||
|
$m = $1;
|
||
|
die unless $e[1] =~ /^\s+@[^:]++:\s+(.*)\s*$/;
|
||
|
$m .= "; $1";
|
||
|
die unless $e[2] =~ /^\s+@[^:]+:\s+(.*)\s*$/;
|
||
|
$m .= "; $1";
|
||
|
return $m;
|
||
|
}
|
||
|
|
||
|
|
||
|
sub add
|
||
|
{
|
||
|
local ($m);
|
||
|
|
||
|
$m = &compact;
|
||
|
$exc{$m} = 1;
|
||
|
undef @e;
|
||
|
}
|
||
|
|
||
|
|
||
|
sub filter
|
||
|
{
|
||
|
local ($m);
|
||
|
|
||
|
$m = &compact;
|
||
|
if (defined $exc{$m}) {
|
||
|
$seen{$m} = 1;
|
||
|
} else {
|
||
|
print join("", @e);
|
||
|
}
|
||
|
undef @e;
|
||
|
}
|
||
|
|
||
|
|
||
|
sub process
|
||
|
{
|
||
|
open(FILE, $_[0]) || die "$_[0]: $!";
|
||
|
undef @e;
|
||
|
while (<FILE>) {
|
||
|
if (/^ErrType/) {
|
||
|
&flush if @e;
|
||
|
@e = ($_);
|
||
|
next;
|
||
|
}
|
||
|
if (/^\s+@/) {
|
||
|
die unless @e;
|
||
|
push(@e, $_);
|
||
|
next;
|
||
|
}
|
||
|
&flush if @e;
|
||
|
print unless $silent;
|
||
|
}
|
||
|
&flush if @e;
|
||
|
close FILE;
|
||
|
}
|
||
|
|
||
|
|
||
|
if ($#ARGV != 1) {
|
||
|
print stderr "usage: $0 name.exceptions name.rpt\n";
|
||
|
exit(1);
|
||
|
}
|
||
|
|
||
|
|
||
|
*flush = *add;
|
||
|
$silent = 1;
|
||
|
&process($ARGV[0]);
|
||
|
*flush = *filter;
|
||
|
$silent = 0;
|
||
|
&process($ARGV[1]);
|
||
|
|
||
|
for $m (keys %exc) {
|
||
|
#print STDERR "check $i\n";
|
||
|
next if $seen{$m};
|
||
|
print STDERR "Warning: exception \"$m\" not seen\n";
|
||
|
}
|