## @file
# This file is used to create report for Eot tool
#
# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
# Import Modules
#
import os
import EotGlobalData
## Report() class
#
# This class defined Report
#
# @param object: Inherited from object class
#
## The constructor
#
# @param self: The object pointer
# @param ReportName: name of the report
# @param FvObj: FV object after parsing FV images
#
self.DispatchList = None
if DispatchName:
## WriteLn() method
#
# Write a line in the report
#
# @param self: The object pointer
# @param Line: The lint to be written into
#
## GenerateReport() method
#
# A caller to generate report
#
# @param self: The object pointer
#
## GenerateUnDispatchedList() method
#
# Create a list for not dispatched items
#
# @param self: The object pointer
#
## GenerateFv() method
#
# Generate FV information
#
# @param self: The object pointer
#
Content = """ <tr>
<td width="20%%"><strong>Name</strong></td>
<td width="60%%"><strong>Guid</strong></td>
<td width="20%%"><strong>Size</strong></td>
</tr>"""
Content = """ <tr>
<td>%s</td>
<td>%s</td>
<td>%s</td>
Content = """ <td colspan="3"><table width="100%%" border="1">
<tr>"""
Content = """ </table></td>
</tr>"""
# For UnDispatched
Content = """ <td colspan="3"><table width="100%%" border="1">
<tr>
<tr><strong>UnDispatched</strong></tr>"""
Content = """ </table></td>
</tr>"""
## GenerateDepex() method
#
# Generate Depex information
#
# @param self: The object pointer
# @param DepexString: A DEPEX string needed to be parsed
#
DepexString = ''
if Item not in NonGuidList:
SqlCommand = """select DISTINCT GuidName from Report where GuidValue like '%s' and ItemMode = 'Produced' group by GuidName""" % (Item)
if RecordSet != []:
Content = """ <tr>
<td width="5%%"></td>
<td width="95%%">%s</td>
</tr>""" % (DepexString)
## GeneratePpi() method
#
# Generate PPI information
#
# @param self: The object pointer
# @param Name: CName of a GUID
# @param Guid: Value of a GUID
# @param Type: Type of a GUID
#
## GenerateProtocol() method
#
# Generate PROTOCOL information
#
# @param self: The object pointer
# @param Name: CName of a GUID
# @param Guid: Value of a GUID
# @param Type: Type of a GUID
#
## GeneratePpiProtocol() method
#
#
# @param self: The object pointer
# @param Model: Model of a GUID, PPI or PROTOCOL
# @param Name: Name of a GUID
# @param Guid: Value of a GUID
# @param Type: Type of a GUID
# @param CName: CName(Index) of a GUID
#
Content = """ <tr>
<td width="5%%"></td>
<td width="10%%">%s</td>
<td width="85%%" colspan="3">%s</td>
<!-- %s -->
if Type == 'Produced':
SqlCommand = """select DISTINCT SourceFileFullPath, BelongsToFunction from Report where GuidName like '%s' and ItemMode = 'Callback'""" % Name
SqlCommand = """select FullPath from File
where ID = (
select DISTINCT BelongsToFile from Inf
Address = ''
break
break
Content = """ <tr>
<td width="5%%"></td>
<td width="10%%">%s</td>
<td width="40%%">%s</td>
<td width="35%%">%s</td>
<td width="10%%">%s</td>
## GenerateFfs() method
#
# Generate FFS information
#
# @param self: The object pointer
# @param FfsObj: FFS object after FV image is parsed
#
FfsName = 'Unknown-Module'
# Hard code for Binary INF
FfsName = 'Logo'
FfsName = 'AcpiTables'
FfsName = 'Fat'
# Find FFS Path and Name
SqlCommand = """select Value2 from Inf
where BelongsToFile = (select BelongsToFile from Inf where Value1 = 'FILE_GUID' and lower(Value2) = lower('%s') and Model = %s)
if RecordSet != []:
SqlCommand = """select FullPath from File
where ID = (select BelongsToFile from Inf where Value1 = 'FILE_GUID' and lower(Value2) = lower('%s') and Model = %s)
if RecordSet != []:
Content = """ <tr>
<tr class='styleFfs' id='FfsHeader%s'>
<td width="55%%"><span onclick="Display('FfsHeader%s', 'Ffs%s')" onMouseOver="funOnMouseOver()" onMouseOut="funOnMouseOut()">%s</span></td>
<td width="15%%">%s</td>
<!--<td width="20%%">%s</td>-->
<!--<td width="20%%">%s</td>-->
<td width="10%%">%s</td>
</tr>
<tr id='Ffs%s' style='display:none;'>
<td colspan="4"><table width="100%%" border="1">""" % (self.FfsIndex, self.FfsIndex, self.FfsIndex, FfsPath, FfsName, FfsGuid, FfsOffset, FfsType, self.FfsIndex)
if self.DispatchList:
Content = """ <tr>
<td><span id='DepexHeader%s' class="styleDepex" onclick="Display('DepexHeader%s', 'Depex%s')" onMouseOver="funOnMouseOver()" onMouseOut="funOnMouseOut()">  DEPEX expression</span></td>
</tr>
<tr id='Depex%s' style='display:none;'>
<td><table width="100%%" border="1">""" % (self.FfsIndex, self.FfsIndex, self.FfsIndex, self.FfsIndex)
Content = """ </table></td>
</tr>"""
# End of DEPEX
SqlCommand = """select ModuleName, ItemType, GuidName, GuidValue, GuidMacro from Report
where SourceFileFullPath in
(select Value1 from Inf where BelongsToFile =
(select BelongsToFile from Inf
where Value1 = 'FILE_GUID' and Value2 like '%s' and Model = %s)
and Model = %s)
and ItemMode = 'Consumed' group by GuidName order by ItemType""" \
if RecordSet != []:
Content = """ <tr>
<td><span id='ConsumedHeader%s' class="styleConsumed" onclick="Display('ConsumedHeader%s', 'Consumed%s')" onMouseOver="funOnMouseOver()" onMouseOut="funOnMouseOut()">  Consumed Ppis/Protocols List (%s)</span></td>
</tr>
<tr id='Consumed%s' style='display:none;'>
<td><table width="100%%" border="1">""" % (self.FfsIndex, self.FfsIndex, self.FfsIndex, Count, self.FfsIndex)
Content = """ </table></td>
</tr>"""
SqlCommand = """select ModuleName, ItemType, GuidName, GuidValue, GuidMacro from Report
where SourceFileFullPath in
(select Value1 from Inf where BelongsToFile =
(select BelongsToFile from Inf
where Value1 = 'FILE_GUID' and Value2 like '%s' and Model = %s)
and Model = %s)
and ItemMode = 'Produced' group by GuidName order by ItemType""" \
if RecordSet != []:
Content = """ <tr>
<td><span id='ProducedHeader%s' class="styleProduced" onclick="Display('ProducedHeader%s', 'Produced%s')" onMouseOver="funOnMouseOver()" onMouseOut="funOnMouseOut()">  Produced Ppis/Protocols List (%s)</span></td>
</tr>
<tr id='Produced%s' style='display:none;'>
<td><table width="100%%" border="1">""" % (self.FfsIndex, self.FfsIndex, self.FfsIndex, Count, self.FfsIndex)
Content = """ </table></td>
</tr>"""
RecordSet = None
Content = """ </table></td>
</tr>"""
## GenerateTail() method
#
# Generate end tags of HTML report
#
# @param self: The object pointer
#
Tail = """</table>
</body>
</html>"""
## GenerateHeader() method
#
# Generate start tags of HTML report
#
# @param self: The object pointer
#
Header = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<html>
<head>
<title>Execution Order Tool Report</title>
<!--
.styleFfs {
color: #006600;
font-weight: bold;
}
.styleDepex {
color: #FF0066;
font-weight: bold;
}
.styleProduced {
color: #0000FF;
font-weight: bold;
}
.styleConsumed {
color: #FF00FF;
font-weight: bold;
}
-->
</style>
<Script type="text/javascript">
function Display(ParentID, SubID)
{
SubItem = document.getElementById(SubID);
ParentItem = document.getElementById(ParentID);
if (SubItem.style.display == 'none')
{
SubItem.style.display = ''
ParentItem.style.fontWeight = 'normal'
}
else
{
SubItem.style.display = 'none'
ParentItem.style.fontWeight = 'bold'
}
}
function funOnMouseOver()
{
document.body.style.cursor = "hand";
}
function funOnMouseOut()
{
document.body.style.cursor = "";
}
</Script>
</head>
<body>
<table width="100%%" border="1">"""
##
#
# This acts like the main() function for the script, unless it is 'import'ed into another
# script.
#
if __name__ == '__main__':
# Initialize log system
try:
except EOFError:
pass