forked from OSVVM/OSVVM-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReportSupport.tcl
174 lines (155 loc) · 6.85 KB
/
ReportSupport.tcl
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
# File Name: ReportSupport.tcl
# Purpose: Convert OSVVM YAML build reports to HTML
# Revision: OSVVM MODELS STANDARD VERSION
#
# Maintainer: Jim Lewis email: [email protected]
# Contributor(s):
# Jim Lewis email: [email protected]
#
# Description
# HTML Report Helpers
#
# Developed by:
# SynthWorks Design Inc.
# VHDL Training Classes
# OSVVM Methodology and Model Library
# 11898 SW 128th Ave. Tigard, Or 97223
# http://www.SynthWorks.com
#
# Revision History:
# Date Version Description
# 07/2024 2024.07 Updated variable naming. Changed GenericList to Report2GenericDict
# 05/2024 2024.05 Initial Revision
#
#
# This file is part of OSVVM.
#
# Copyright (c) 2024 by SynthWorks Design Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package require yaml
# -------------------------------------------------
# CreateOsvvmReportHeader
#
proc CreateOsvvmReportHeader {ResultsFile ReportName {RelativePath ""}} {
puts $ResultsFile "<!DOCTYPE html>"
puts $ResultsFile "<html lang=\"en\">"
puts $ResultsFile "<head>"
LinkCssFiles $ResultsFile $RelativePath
puts $ResultsFile " <title>$ReportName</title>"
puts $ResultsFile "</head>"
puts $ResultsFile "<body>"
puts $ResultsFile "<header>"
puts $ResultsFile " <h1>$ReportName</h1>"
puts $ResultsFile "</header>"
puts $ResultsFile "<main>"
}
# -------------------------------------------------
# CreateOsvvmReportFooter
#
proc CreateOsvvmReportFooter {ResultsFile} {
puts $ResultsFile "</main>"
puts $ResultsFile "<footer>"
puts $ResultsFile " <hr />"
# ::osvvm::OsvvmVersion is appropriate here. The two versions should match.
puts $ResultsFile " <p class=\"generated-by-osvvm\">Generated by OSVVM-Scripts ${::osvvm::OsvvmVersion} on [clock format [clock seconds] -format {%Y-%m-%d - %H:%M:%S (%Z)}].</p>"
puts $ResultsFile "</footer>"
puts $ResultsFile "</body>"
puts $ResultsFile "</html>"
}
# -------------------------------------------------
# FindHtmlThemeFiles
#
# proc FindHtmlThemeFiles {BaseDirectory CssTargetSubdirectory} {
# variable Report2CssFiles
# variable Report2PngFile
#
# # Note files are linked into the HTML in glob order (alphabetical but may be OS dependent WRT upper case)
# set CssFiles [glob -nocomplain [file join ${BaseDirectory} ${CssTargetSubdirectory} *.css]]
# set Report2CssFiles ""
# if {$CssFiles ne ""} {
# foreach CssFileWithPath ${CssFiles} {
# set CssFile [file join $CssTargetSubdirectory [file tail $CssFileWithPath]]
# lappend Report2CssFiles $CssFile
# }
# }
#
# # There should only be one *.png file.
# set PngFiles [glob -nocomplain [file join ${BaseDirectory} ${CssTargetSubdirectory} *.png]]
# set Report2PngFile ""
# if {$PngFiles ne ""} {
# foreach PngFileWithPath ${PngFiles} {
# set PngDestFile [file join $CssTargetSubdirectory [file tail $PngFileWithPath]]
# }
# }
# # There should be only one PNG file, so only copy the last one we find.
# # file copy -force ${PngFileWithPath} [file join $BaseDirectory $CssTargetSubdirectory $PngFile]
# set Report2PngFile $PngDestFile
# }
# -------------------------------------------------
# LinkCssFiles
#
proc LinkCssFiles {ResultsFile {RelativePath ""}} {
variable Report2CssFiles
# Note files are linked into the HTML in glob order (alphabetical but may be OS dependent WRT upper case)
if {$Report2CssFiles ne ""} {
foreach CssFile ${Report2CssFiles} {
puts $ResultsFile " <link rel=\"stylesheet\" href=\"[file join $RelativePath $CssFile]\">"
}
}
}
# -------------------------------------------------
# LinkLogoFile
#
proc LinkLogoFile {ResultsFile {RelativePath ""}} {
variable Report2PngFile
puts $ResultsFile " <div class=\"summary-logo\">"
puts $ResultsFile " <img id=\"logo\" src=\"[file join $RelativePath $Report2PngFile]\" alt=\"OSVVM logo\">"
puts $ResultsFile " </div>"
}
# -------------------------------------------------
# GetOsvvmPathSettings
#
proc GetOsvvmPathSettings {TestDict} {
set SettingsInfoDict [dict get $TestDict OsvvmSettingsInfo]
variable Report2BaseDirectory [dict get $SettingsInfoDict BaseDirectory]
variable Report2ReportsSubdirectory [dict get $SettingsInfoDict ReportsSubdirectory]
# variable Report2HtmlThemeSubdirectory [dict get $SettingsInfoDict HtmlThemeSubdirectory]
variable Report2SimulationLogFile [dict get $SettingsInfoDict SimulationLogFile]
variable Report2SimulationHtmlLogFile [dict get $SettingsInfoDict SimulationHtmlLogFile]
variable Report2RequirementsSubdirectory [dict get $SettingsInfoDict RequirementsSubdirectory]
variable Report2CoverageSubdirectory [dict get $SettingsInfoDict CoverageSubdirectory]
variable Report2CssFiles [dict get $SettingsInfoDict Report2CssFiles]
variable Report2PngFile [dict get $SettingsInfoDict Report2PngFile]
}
# -------------------------------------------------
# GetTestCaseSettings
#
proc GetTestCaseSettings {SettingsFileName} {
set TestDict [::yaml::yaml2dict -file ${SettingsFileName}]
variable Report2TestCaseName [dict get $TestDict TestCaseName ]
variable Report2TestSuiteName [dict get $TestDict TestSuiteName ]
variable Report2BuildName [dict get $TestDict BuildName ]
variable Report2GenericDict [dict get $TestDict Generics ]
variable Report2TestCaseFileName [dict get $TestDict TestCaseFileName ]
variable Report2GenericNames [dict get $TestDict GenericNames ]
variable Report2TestSuiteDirectory [dict get $TestDict TestSuiteDirectory ]
variable Report2RequirementsYamlFile [dict get $TestDict RequirementsYamlFile]
variable Report2AlertYamlFile [dict get $TestDict AlertYamlFile ]
variable Report2CovYamlFile [dict get $TestDict CovYamlFile ]
variable Report2ScoreboardDict [dict get $TestDict ScoreboardDict ]
variable Report2TranscriptFiles [dict get $TestDict TranscriptFiles ]
variable Report2TestCaseHtml [file join $Report2TestSuiteDirectory ${Report2TestCaseFileName}.html]
GetOsvvmPathSettings $TestDict
}