|
| 1 | +#!/bin/sh |
| 2 | +# The next line is executed by /bin/sh, but not Tcl \ |
| 3 | +exec tclsh $0 ${1+"$@"} |
| 4 | + |
| 5 | +# Parallax Static Timing Analyzer |
| 6 | +# Copyright (c) 2020, Parallax Software, Inc. |
| 7 | +# All rights reserved. |
| 8 | +# |
| 9 | +# No part of this document may be copied, transmitted or |
| 10 | +# disclosed in any form or fashion without the express |
| 11 | +# written consent of Parallax Software, Inc. |
| 12 | + |
| 13 | +# Find warning/error message IDs and detect collisions. |
| 14 | +# Usage: FindMessages.tcl > doc/messages.txt |
| 15 | + |
| 16 | +proc scan_file { file warn_regexp } { |
| 17 | + global msgs |
| 18 | + |
| 19 | + if { [file exists $file] } { |
| 20 | + set in_stream [open $file r] |
| 21 | + gets $in_stream line |
| 22 | + set file_line 1 |
| 23 | + |
| 24 | + while { ![eof $in_stream] } { |
| 25 | + if { [regexp -- $warn_regexp $line ignore1 ignore2 msg_id msg] } { |
| 26 | + lappend msgs "$msg_id $file $file_line $msg" |
| 27 | + } |
| 28 | + gets $in_stream line |
| 29 | + incr file_line |
| 30 | + } |
| 31 | + close $in_stream |
| 32 | + } else { |
| 33 | + puts "Warning: file $file not found." |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +set subdirs {app dcalc graph liberty network parasitics \ |
| 38 | + power sdc sdf search spice util verilog tcl} |
| 39 | +set files_c {} |
| 40 | +foreach subdir $subdirs { |
| 41 | + set files [glob -nocomplain [file join $subdir "*.{cc,hh,yy,ll,i}"]] |
| 42 | + set files_c [concat $files_c $files] |
| 43 | +} |
| 44 | +set warn_regexp_c {(criticalError|->warn|->fileWarn|->error|->fileError|libWarn|libError| warn)\(([0-9]+),.*(".+")} |
| 45 | + |
| 46 | +set files_tcl {} |
| 47 | +foreach subdir $subdirs { |
| 48 | + set files_tcl [concat $files_tcl [glob -nocomplain [file join $subdir "*.tcl"]]] |
| 49 | +} |
| 50 | +set warn_regexp_tcl {(sta_warn|sta_error|sta_warn_error) ([0-9]+) (".+")} |
| 51 | + |
| 52 | +proc scan_files {files warn_regexp } { |
| 53 | + foreach file $files { |
| 54 | + scan_file $file $warn_regexp |
| 55 | + } |
| 56 | +} |
| 57 | + |
| 58 | +proc check_msgs { } { |
| 59 | + global msgs |
| 60 | + |
| 61 | + set msgs [lsort -index 0 -integer $msgs] |
| 62 | + set prev_id -1 |
| 63 | + foreach msg $msgs { |
| 64 | + set msg_id [lindex $msg 0] |
| 65 | + if { $msg_id == $prev_id } { |
| 66 | + puts "Warning: $msg_id duplicated" |
| 67 | + } |
| 68 | + set prev_id $msg_id |
| 69 | + } |
| 70 | +} |
| 71 | + |
| 72 | +proc report_msgs { } { |
| 73 | + global msgs |
| 74 | + |
| 75 | + foreach msg_info $msgs { |
| 76 | + lassign $msg_info msg_id file line msg1 |
| 77 | + puts "[format %04d $msg_id] [format %-25s [file tail $file]:$line] $msg1" |
| 78 | + } |
| 79 | +} |
| 80 | + |
| 81 | +set msgs {} |
| 82 | +scan_files $files_c $warn_regexp_c |
| 83 | +scan_files $files_tcl $warn_regexp_tcl |
| 84 | +check_msgs |
| 85 | +report_msgs |
0 commit comments