Root/
| 1 | #!/usr/bin/perl |
| 2 | # |
| 3 | # rptflt.pl - Filter known issues from KiCad DRC reports |
| 4 | # |
| 5 | # Written 2014 by Werner Almesberger |
| 6 | # Copyright 2014 Werner Almesberger |
| 7 | # |
| 8 | # This program is free software; you can redistribute it and/or modify |
| 9 | # it under the terms of the GNU General Public License as published by |
| 10 | # the Free Software Foundation; either version 2 of the License, or |
| 11 | # (at your option) any later version. |
| 12 | # |
| 13 | |
| 14 | # |
| 15 | # Usage: |
| 16 | # |
| 17 | # - generate a DRC report file with pcbnew, e.g., foo.rpt |
| 18 | # - review report file for any real issues |
| 19 | # - rename foo.rpt to foo.exceptions |
| 20 | # - to check for new errors, generate new report file, then run |
| 21 | # rptflt.pl foo.exceptions foo.rpt |
| 22 | # |
| 23 | |
| 24 | |
| 25 | sub compact |
| 26 | { |
| 27 | local ($m); |
| 28 | |
| 29 | die if $#e != 2; |
| 30 | die unless $e[0] =~ /^ErrType\(\d+\):\s+(.*)\s*$/; |
| 31 | $m = $1; |
| 32 | die unless $e[1] =~ /^\s+@[^:]++:\s+(.*)\s*$/; |
| 33 | $m .= "; $1"; |
| 34 | die unless $e[2] =~ /^\s+@[^:]+:\s+(.*)\s*$/; |
| 35 | $m .= "; $1"; |
| 36 | return $m; |
| 37 | } |
| 38 | |
| 39 | |
| 40 | sub add |
| 41 | { |
| 42 | local ($m); |
| 43 | |
| 44 | $m = &compact; |
| 45 | $exc{$m} = 1; |
| 46 | undef @e; |
| 47 | } |
| 48 | |
| 49 | |
| 50 | sub filter |
| 51 | { |
| 52 | local ($m); |
| 53 | |
| 54 | $m = &compact; |
| 55 | if (defined $exc{$m}) { |
| 56 | $seen{$m} = 1; |
| 57 | } else { |
| 58 | print join("", @e); |
| 59 | } |
| 60 | undef @e; |
| 61 | } |
| 62 | |
| 63 | |
| 64 | sub process |
| 65 | { |
| 66 | open(FILE, $_[0]) || die "$_[0]: $!"; |
| 67 | undef @e; |
| 68 | while (<FILE>) { |
| 69 | if (/^ErrType/) { |
| 70 | &flush if @e; |
| 71 | @e = ($_); |
| 72 | next; |
| 73 | } |
| 74 | if (/^\s+@/) { |
| 75 | die unless @e; |
| 76 | push(@e, $_); |
| 77 | next; |
| 78 | } |
| 79 | &flush if @e; |
| 80 | print unless $silent; |
| 81 | } |
| 82 | &flush if @e; |
| 83 | close FILE; |
| 84 | } |
| 85 | |
| 86 | |
| 87 | if ($#ARGV != 1) { |
| 88 | print stderr "usage: $0 name.exceptions name.rpt\n"; |
| 89 | exit(1); |
| 90 | } |
| 91 | |
| 92 | |
| 93 | *flush = *add; |
| 94 | $silent = 1; |
| 95 | &process($ARGV[0]); |
| 96 | *flush = *filter; |
| 97 | $silent = 0; |
| 98 | &process($ARGV[1]); |
| 99 | |
| 100 | for $m (keys %exc) { |
| 101 | #print STDERR "check $i\n"; |
| 102 | next if $seen{$m}; |
| 103 | print STDERR "Warning: exception \"$m\" not seen\n"; |
| 104 | } |
| 105 |
Branches:
master
