]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/build/BuildReport.py
ShellPkg: Fix EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL_GUID to match UEFI Shell 2.1 spec
[mirror_edk2.git] / BaseTools / Source / Python / build / BuildReport.py
index f3555d705dcf92f5c45fbd0dd1f70fce24009c1f..945ee1b573e406ad9960946d7e331ed3ac836546 100644 (file)
@@ -4,7 +4,7 @@
 # This module contains the functionality to generate build report after\r
 # build all target completes successfully.\r
 #\r
-# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -33,7 +33,13 @@ from Common.Misc import GuidStructureStringToGuidString
 from Common.InfClassObject import gComponentType2ModuleType\r
 from Common.BuildToolError import FILE_WRITE_FAILURE\r
 from Common.BuildToolError import CODE_ERROR\r
-\r
+from Common.DataType import TAB_LINE_BREAK\r
+from Common.DataType import TAB_DEPEX\r
+from Common.DataType import TAB_SLASH\r
+from Common.DataType import TAB_SPACE_SPLIT\r
+from Common.DataType import TAB_BRG_PCD\r
+from Common.DataType import TAB_BRG_LIBRARY\r
+from Common.DataType import TAB_BACK_SLASH\r
 \r
 ## Pattern to extract contents in EDK DXS files\r
 gDxsDependencyPattern = re.compile(r"DEPENDENCY_START(.+)DEPENDENCY_END", re.DOTALL)\r
@@ -63,15 +69,22 @@ gIncludePattern2 = re.compile(r"#include\s+EFI_([A-Z_]+)\s*[(]\s*(\w+)\s*[)]")
 ## Pattern to find the entry point for EDK module using EDKII Glue library\r
 gGlueLibEntryPoint = re.compile(r"__EDKII_GLUE_MODULE_ENTRY_POINT__\s*=\s*(\w+)")\r
 \r
+## Tags for MaxLength of line in report\r
+gLineMaxLength = 120\r
+\r
+## Tags for end of line in report\r
+gEndOfLine = "\r\n"\r
+\r
 ## Tags for section start, end and separator\r
-gSectionStart = ">" + "=" * 118 + "<"\r
-gSectionEnd = "<" + "=" * 118 + ">" + "\n"\r
-gSectionSep = "=" * 120\r
+gSectionStart = ">" + "=" * (gLineMaxLength-2) + "<"\r
+gSectionEnd = "<" + "=" * (gLineMaxLength-2) + ">" + "\n"\r
+gSectionSep = "=" * gLineMaxLength\r
 \r
 ## Tags for subsection start, end and separator\r
-gSubSectionStart = ">" + "-" * 118 + "<"\r
-gSubSectionEnd = "<" + "-" * 118 + ">"\r
-gSubSectionSep = "-" * 120\r
+gSubSectionStart = ">" + "-" * (gLineMaxLength-2) + "<"\r
+gSubSectionEnd = "<" + "-" * (gLineMaxLength-2) + ">"\r
+gSubSectionSep = "-" * gLineMaxLength\r
+\r
 \r
 ## The look up table to map PCD type to pair of report display type and DEC type\r
 gPcdTypeMap = {\r
@@ -81,9 +94,9 @@ gPcdTypeMap = {
   'Dynamic'          : ('DYN',    'Dynamic'),\r
   'DynamicHii'       : ('DYNHII', 'Dynamic'),\r
   'DynamicVpd'       : ('DYNVPD', 'Dynamic'),\r
-  'DynamicEx'        : ('DEX',    'Dynamic'),\r
-  'DynamicExHii'     : ('DEXHII', 'Dynamic'),\r
-  'DynamicExVpd'     : ('DEXVPD', 'Dynamic'),\r
+  'DynamicEx'        : ('DEX',    'DynamicEx'),\r
+  'DynamicExHii'     : ('DEXHII', 'DynamicEx'),\r
+  'DynamicExVpd'     : ('DEXVPD', 'DynamicEx'),\r
   }\r
 \r
 ## The look up table to map module type to driver type\r
@@ -118,7 +131,7 @@ gOpCodeList = ["BEFORE", "AFTER", "PUSH", "AND", "OR", "NOT", "TRUE", "FALSE", "
 def FileWrite(File, String, Wrapper=False):\r
     if Wrapper:\r
         String = textwrap.fill(String, 120)\r
-    File.write(String + "\r\n")\r
+    File.write(String + gEndOfLine)\r
 \r
 ##\r
 # Find all the header file that the module source directly includes.\r
@@ -166,6 +179,39 @@ def FindIncludeFiles(Source, IncludePathList, IncludeFiles):
                 IncludeFiles[FullFileName.lower().replace("\\", "/")] = FullFileName\r
                 break\r
 \r
+## Split each lines in file\r
+#\r
+#  This method is used to split the lines in file to make the length of each line \r
+#  less than MaxLength.\r
+#\r
+#  @param      Content           The content of file\r
+#  @param      MaxLength         The Max Length of the line\r
+#\r
+def FileLinesSplit(Content=None, MaxLength=None):\r
+    ContentList = Content.split(TAB_LINE_BREAK)\r
+    NewContent = ''\r
+    NewContentList = []\r
+    for Line in ContentList:\r
+        while len(Line.rstrip()) > MaxLength:\r
+            LineSpaceIndex = Line.rfind(TAB_SPACE_SPLIT, 0, MaxLength)\r
+            LineSlashIndex = Line.rfind(TAB_SLASH, 0, MaxLength)\r
+            LineBackSlashIndex = Line.rfind(TAB_BACK_SLASH, 0, MaxLength)\r
+            if max(LineSpaceIndex, LineSlashIndex, LineBackSlashIndex) > 0:\r
+                LineBreakIndex = max(LineSpaceIndex, LineSlashIndex, LineBackSlashIndex)\r
+            else:\r
+                LineBreakIndex = MaxLength\r
+            NewContentList.append(Line[:LineBreakIndex])\r
+            Line = Line[LineBreakIndex:]\r
+        if Line:\r
+            NewContentList.append(Line)\r
+    for NewLine in NewContentList:\r
+        NewContent += NewLine + TAB_LINE_BREAK\r
+    \r
+    NewContent = NewContent.replace(TAB_LINE_BREAK, gEndOfLine).replace('\r\r\n', gEndOfLine)\r
+    return NewContent\r
+    \r
+    \r
+    \r
 ##\r
 # Parse binary dependency expression section\r
 #\r
@@ -213,7 +259,7 @@ class DepexParser(object):
             Statement = gOpCodeList[struct.unpack("B", OpCode)[0]]\r
             if Statement in ["BEFORE", "AFTER", "PUSH"]:\r
                 GuidValue = "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X" % \\r
-                            struct.unpack("LHHBBBBBBBB", DepexFile.read(16))\r
+                            struct.unpack("=LHHBBBBBBBB", DepexFile.read(16))\r
                 GuidString = self._GuidDb.get(GuidValue, GuidValue)\r
                 Statement = "%s %s" % (Statement, GuidString)\r
             DepexStatement.append(Statement)\r
@@ -263,7 +309,7 @@ class LibraryReport(object):
     #\r
     def GenerateReport(self, File):\r
         FileWrite(File, gSubSectionStart)\r
-        FileWrite(File, "Library")\r
+        FileWrite(File, TAB_BRG_LIBRARY)\r
         if len(self.LibraryList) > 0:\r
             FileWrite(File, gSubSectionSep)\r
             for LibraryItem in self.LibraryList:\r
@@ -355,8 +401,10 @@ class DepexReport(object):
     #\r
     def GenerateReport(self, File, GlobalDepexParser):\r
         if not self.Depex:\r
+            FileWrite(File, gSubSectionStart)\r
+            FileWrite(File, TAB_DEPEX)\r
+            FileWrite(File, gSubSectionEnd)\r
             return\r
-\r
         FileWrite(File, gSubSectionStart)\r
         if os.path.isfile(self._DepexFileName):\r
             try:\r
@@ -651,7 +699,8 @@ class PcdReport(object):
         # Collect PCDs defined in DSC common section\r
         #\r
         self.DscPcdDefault = {}\r
-        for Platform in Wa.BuildDatabase.WorkspaceDb.PlatformList:\r
+        for Arch in Wa.ArchList:\r
+            Platform = Wa.BuildDatabase[Wa.MetaFile, Arch, Wa.BuildTarget, Wa.ToolChain]\r
             for (TokenCName, TokenSpaceGuidCName) in Platform.Pcds:\r
                 DscDefaultValue = Platform.Pcds[(TokenCName, TokenSpaceGuidCName)].DefaultValue\r
                 if DscDefaultValue:\r
@@ -685,7 +734,7 @@ class PcdReport(object):
             # For module PCD sub-section\r
             #\r
             FileWrite(File, gSubSectionStart)\r
-            FileWrite(File, "PCD")\r
+            FileWrite(File, TAB_BRG_PCD)\r
             FileWrite(File, gSubSectionSep)\r
 \r
         for Key in self.AllPcds:\r
@@ -1511,7 +1560,8 @@ class BuildReport(object):
                 File = StringIO('')\r
                 for (Wa, MaList) in self.ReportList:\r
                     PlatformReport(Wa, MaList, self.ReportType).GenerateReport(File, BuildDuration, self.ReportType)\r
-                SaveFileOnChange(self.ReportFile, File.getvalue(), False)\r
+                Content = FileLinesSplit(File.getvalue(), gLineMaxLength)\r
+                SaveFileOnChange(self.ReportFile, Content, True)\r
                 EdkLogger.quiet("Build report can be found at %s" % os.path.abspath(self.ReportFile))\r
             except IOError:\r
                 EdkLogger.error(None, FILE_WRITE_FAILURE, ExtraData=self.ReportFile)\r