File: Doxygen.tcl

package info (click to toggle)
dart 0.20061109-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 5,668 kB
  • ctags: 247
  • sloc: tcl: 5,652; perl: 256; python: 141; cpp: 79; makefile: 68; sh: 36
file content (207 lines) | stat: -rw-r--r-- 6,706 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# =========================================================================
# 
#   Program:   Insight Segmentation & Registration Toolkit
#   Module:    $RCSfile: Doxygen.tcl,v $
#   Language:  Tcl
#   Date:      $Date: 2002/03/01 14:34:49 $
#   Version:   $Revision: 1.11 $
# 

# Copyright (c) 2001 Insight Consortium
# All rights reserved.

# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:

#  * Redistributions of source code must retain the above copyright notice,
#    this list of conditions and the following disclaimer.

#  * Redistributions in binary form must reproduce the above copyright notice,
#    this list of conditions and the following disclaimer in the documentation
#    and/or other materials provided with the distribution.

#  * The name of the Insight Consortium, nor the names of any consortium members,
#    nor of any contributors, may be used to endorse or promote products derived
#    from this software without specific prior written permission.

#   * Modified source versions must be plainly marked as such, and must not be
#     misrepresented as being the original software.

# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


# Put in this directory
# Year Month Day - TimeZone - Hour:Minute
# e.g. 20000926-EDT-16:02
# or Year Month Day Hour Minute
# clock format [clock seconds] -format %Y%m%d%H%M

# Must be run from root directory of project build, only by make

proc Doxygen { Model OutFile } {
  global Dart DashboardDir
  
  set SourceDirectory [pwd]
  set UtilityDir [file join $Dart(DartRoot) Source Client]

  # If this project/build is not currently setup to use doxygen, then exit.
  # This configured by Utility.tcl
  if { $Dart(BuildDoxygen) != "ON" } {
    return
  }


  # Begin the XML output
  set Out [open $OutFile w]

  puts $Out $Dart(XMLHeader)
  puts $Out {<Doxygen>}
  puts $Out "\t<StartDateTime>[AbbreviateTimeZone [clock format [clock seconds]]]</StartDateTime>"


  set Log Doxygen.log

  # Do the build
  set DoxygenStatus [catch { eval exec $Dart(DoxygenCommand) $Dart(DoxygenConfig) 2> $Log } Result ]

  set Doxygen [open $Log r]

  set Cache ""
  catch { unset ErrorList }
  set ErrorList(Counter) 0
  set ErrorList(Append) ""
  set ErrorList(Buffer) ""
  set PostContextCount 5
  set BufferLength 5

  set Exceptions ""
  set Line 1
  while { ![eof $Doxygen] } \
  {
    # Get a line and write it out
    set LogLine [gets $Doxygen]

    set hasError [Match {.*[Ee][Rr][Rr][Oo][Rr]:.*} $LogLine $Exceptions]
    set hasWarning [Match {.*[Ww][Aa][Rr][Nn][Ii][Nn][Gg]:.*} $LogLine $Exceptions]

    if { $hasError } \
    {
      set Type Error
    }
    if { $hasWarning } \
    {
      set Type Warning
    }
    if { $hasError || $hasWarning } \
    {
      set i $ErrorList(Counter)
      incr ErrorList(Counter)
      set ErrorList($i,Type) $Type
      set ErrorList($i,Text) $LogLine
      set ErrorList($i,Line) $Line
      set ErrorList($i,PreContext) $ErrorList(Buffer)
      set ErrorList($i,PostContext) ""
      set ErrorList($i,ContextCounter) 0
      set ErrorList($i,SourceFile) ""
      set ErrorList($i,SourceLineNumber) ""

      # Take a stab at getting a file name out of the line
      # For GCC, we get /path/to/source.cxx:##
      if { [string match "*$SourceDirectory*:*" $LogLine] } \
      {
        # GCC
        if { [regexp "${SourceDirectory}/(\[^:\]*):(\[0-9\]*)" $LogLine dummy SourceFile LineNumber] } \
        {
          set ErrorList($i,SourceFile) $SourceFile
          set ErrorList($i,SourceLineNumber) $LineNumber
        }
      }
      
      lappend ErrorList(Append) $i
    }

    # Add to the PreContextBuffer
    set l [llength $ErrorList(Buffer)]
    if { $l > $BufferLength } \
    {
      set ErrorList(Buffer) [lrange $ErrorList(Buffer) 1 [expr $l - 2]]
    }
    lappend ErrorList(Buffer) $LogLine

    # Go through all in the ErrorList to append to, and do it
    set AppendList $ErrorList(Append)
    foreach i $AppendList \
    {
      if { $ErrorList($i,Line) != $Line } \
      {
        lappend ErrorList($i,PostContext) $LogLine
        incr ErrorList($i,ContextCounter) 

        # Remove this error for the append list
        if { $ErrorList($i,ContextCounter) > $PostContextCount } \
        {
          set ErrorList(Append) [lremove $ErrorList(Append) $i]
        }
      }
    }
    incr Line
  }

  # Write all the errors out to the Out file
  for { set i 0 } { $i < $ErrorList(Counter) } { incr i } \
  {
    puts $Out "\t<$ErrorList($i,Type)>"
    puts $Out "\t\t<LogLine>[XMLSafeString $ErrorList($i,Line)]</LogLine>"
    puts $Out "\t\t<Text>[XMLSafeString $ErrorList($i,Text)]</Text>"
    if { $ErrorList($i,SourceFile) != "" } \
    {
      puts $Out "\t\t<SourceFile>[XMLSafeString $ErrorList($i,SourceFile)]</SourceFile>"
      puts $Out "\t\t<SourceLineNumber>$ErrorList($i,SourceLineNumber)</SourceLineNumber>"
    }
    puts $Out "\t\t<PreContext>"
    foreach l $ErrorList($i,PreContext) \
    {
      puts $Out [XMLSafeString $l]
    }
    puts $Out "\t\t</PreContext>"
    puts $Out "\t\t<PostContext>"
    foreach l $ErrorList($i,PostContext) \
    {
      puts $Out [XMLSafeString $l]
    }
    puts $Out "\t\t</PostContext>"
    puts $Out "</$ErrorList($i,Type)>"
    puts $Out "\n"
  }

  # set LogCompressionStatus [ catch { CompressFile $DoxygenLogTempFilename $DoxygenLogCompressedFilename } CompressionResult ]
  # if { $LogCompressionStatus } \
  # {
  #   error $CompressionResult
  # }
  # set DoxygenLog [open $DoxygenLogCompressedFilename r]
  # fconfigure $DoxygenLog -translation binary

  # puts $Out "\t<Log Encoding=\"base64\" Compression=\"$CompressionType\">"
  # puts $Out [Base64Encode [read $DoxygenLog ]]
  # puts $Out "\t</Log>"

  puts $Out "\t<EndDateTime>[AbbreviateTimeZone [clock format [clock seconds]]]</EndDateTime>"

  puts $Out "</Doxygen>"

  close $Doxygen
  close $Out

  file delete $Log
  return
}