Added more error check
authorjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Mon, 7 Apr 2008 02:33:44 +0000 (02:33 +0000)
committerjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Mon, 7 Apr 2008 02:33:44 +0000 (02:33 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1121 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/Workspace/MetaFileParser.py
Source/Python/Workspace/WorkspaceDatabase.py

index c7b93c3..8bed29a 100644 (file)
@@ -100,11 +100,15 @@ class MetaFileParser(object):
     def _DefineParser(self):\r
         TokenList = GetSplitValueList(self._CurrentLine, TAB_EQUAL_SPLIT, 1)\r
         self._ValueList[0:len(TokenList)] = TokenList\r
+        if self._ValueList[1] == '':\r
+            EdkLogger.error('Parser', FORMAT_INVALID, "No value specified",\r
+                            ExtraData=self._CurrentLine, File=self._FilePath, Line=self._LineIndex+1)\r
 \r
     def _MacroParser(self):\r
         TokenList = GetSplitValueList(self._CurrentLine, ' ', 1)\r
-        if len(TokenList) <= 1:\r
-            return\r
+        if len(TokenList) < 2 or TokenList[1] == '':\r
+            EdkLogger.error('Parser', FORMAT_INVALID, "No macro name/value given",\r
+                            ExtraData=self._CurrentLine, File=self._FilePath, Line=self._LineIndex+1)\r
         TokenList = GetSplitValueList(TokenList[1], TAB_EQUAL_SPLIT, 1)\r
         if len(TokenList) < 1:\r
             return\r
@@ -145,7 +149,7 @@ class InfParser(MetaFileParser):
         try:\r
             self._Content = open(self._FilePath, 'r').readlines()\r
         except:\r
-            EdkLogger.error("InfParser", FILE_READ_FAILURE, ExtraData=self._FilePath)\r
+            EdkLogger.error("Parser", FILE_READ_FAILURE, ExtraData=self._FilePath)\r
 \r
         for Index in range(0, len(self._Content)):\r
             Line = CleanString(self._Content[Index])\r
@@ -165,7 +169,8 @@ class InfParser(MetaFileParser):
             # section content\r
             self._ValueList = ['','','']\r
             self._SectionParser[self._SectionType](self)\r
-\r
+            if self._ValueList == None:\r
+                continue\r
             # \r
             # Model, Value1, Value2, Value3, Value4, Value5, Arch, Platform, BelongsToFile=-1, \r
             # LineBegin=-1, ColumnBegin=-1, LineEnd=-1, ColumnEnd=-1, BelongsToItem=-1, FeatureFlag='', \r
@@ -205,9 +210,12 @@ class InfParser(MetaFileParser):
 \r
     def _PcdParser(self):\r
         TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT, 1)\r
-        self._ValueList[0:2] = GetSplitValueList(TokenList[0], TAB_SPLIT)\r
+        self._ValueList[0:1] = GetSplitValueList(TokenList[0], TAB_SPLIT)\r
         if len(TokenList) > 1:\r
             self._ValueList[2] = TokenList[1]\r
+        if self._ValueList[0] == '' or self._ValueList[1] == '':\r
+            EdkLogger.error('Parser', FORMAT_INVALID, "No token space GUID or PCD name specified",\r
+                            ExtraData=self._CurrentLine, File=self._FilePath, Line=self._LineIndex+1)\r
 \r
     def _DepexParser(self):\r
         self._ValueList[0:1] = [self._CurrentLine]\r
@@ -300,7 +308,7 @@ class DscParser(MetaFileParser):
             if self._Content == None:\r
                 self._Content = open(self._FilePath, 'r').readlines()\r
         except:\r
-            EdkLogger.error("DscParser", FILE_READ_FAILURE, ExtraData=self._FilePath)\r
+            EdkLogger.error("Parser", FILE_READ_FAILURE, ExtraData=self._FilePath)\r
 \r
         for Index in range(0, len(self._Content)):\r
             Line = CleanString(self._Content[Index])\r
@@ -339,9 +347,8 @@ class DscParser(MetaFileParser):
             else:\r
                 SectionType = self._SectionType\r
                 SectionName = self._SectionName\r
-            self._ValueList = ['','','']\r
+            self._ValueList = ['', '', '']\r
             self._SectionParser[SectionType](self)\r
-            EdkLogger.debug(EdkLogger.DEBUG_8, "Define: %s" % self._ValueList)\r
             if self._ValueList == None:\r
                 continue\r
 \r
@@ -370,11 +377,12 @@ class DscParser(MetaFileParser):
 \r
     def _DefineParser(self):\r
         TokenList = GetSplitValueList(self._CurrentLine, TAB_EQUAL_SPLIT, 1)\r
-        if len(TokenList) > 1:\r
-            if TokenList[0] in ['FLASH_DEFINITION', 'OUTPUT_DIRECTORY']:\r
-                TokenList[1] = NormPath(TokenList[1], self._Macros)\r
-        self._ValueList[0:len(TokenList)] = TokenList\r
-    \r
+        if len(TokenList) < 2:\r
+            EdkLogger.error('Parser', FORMAT_INVALID, "No value specified",\r
+                            ExtraData=self._CurrentLine, File=self._FilePath, Line=self._LineIndex+1)\r
+        if TokenList[0] in ['FLASH_DEFINITION', 'OUTPUT_DIRECTORY']:\r
+            TokenList[1] = NormPath(TokenList[1], self._Macros)\r
+        self._ValueList[0:len(TokenList)] = TokenList    \r
             \r
     def _SubsectionHeaderParser(self):\r
         self._SubsectionName = self._CurrentLine[1:-1].upper()\r
@@ -387,6 +395,10 @@ class DscParser(MetaFileParser):
         self._ValueList = ['','','']\r
         TokenList = GetSplitValueList(self._CurrentLine, ' ', 1)\r
         self._ValueList[0:len(TokenList)] = TokenList\r
+        if self._ValueList[1] == '':\r
+            EdkLogger.error("Parser", FORMAT_INVALID, "Missing expression", \r
+                            File=self._FilePath, Line=self._LineIndex+1,\r
+                            ExtraData=self._CurrentLine)\r
         DirectiveName = self._ValueList[0].upper()\r
         self._LastItem = self._Store(\r
             self._DataType[DirectiveName],\r
@@ -402,10 +414,11 @@ class DscParser(MetaFileParser):
             -1,\r
             0\r
             )\r
+        # process the directive\r
         if DirectiveName == "!INCLUDE":\r
             if not self._SectionName in self._IncludeAllowedSection:\r
-                EdkLogger.error("DscParser", FORMAT_INVALID, File=self._FilePath, Line=self._LineIndex+1,\r
-                                ExtraData="'!include' is not allowed in section %s" % self._SectionName)\r
+                EdkLogger.error("Parser", FORMAT_INVALID, File=self._FilePath, Line=self._LineIndex+1,\r
+                                ExtraData="'!include' is not allowed under section [%s]" % self._SectionName)\r
             # the included file must be relative to the parsing file\r
             IncludedFile = os.path.join(self._FileDir, self._ValueList[1])\r
             Parser = DscParser(IncludedFile, self._FileType, self._Table, self._Macros, From=self._LastItem)\r
@@ -416,7 +429,7 @@ class DscParser(MetaFileParser):
             try:\r
                 Parser.Start()\r
             except:\r
-                EdkLogger.error("DscParser", PARSER_ERROR, File=self._FilePath, Line=self._LineIndex+1,\r
+                EdkLogger.error("Parser", PARSER_ERROR, File=self._FilePath, Line=self._LineIndex+1,\r
                                 ExtraData="Failed to parse content in file %s" % IncludedFile)\r
             self._SectionName = Parser._SectionName\r
             self._SectionType = Parser._SectionType\r
@@ -438,7 +451,7 @@ class DscParser(MetaFileParser):
                 if len(self._Eval) > 0:\r
                     self._Eval.pop()\r
                 else:\r
-                    EdkLogger.error("DscParser", FORMAT_INVALID, "!IF..[!ELSE]..!ENDIF doesn't match",\r
+                    EdkLogger.error("Parser", FORMAT_INVALID, "!IF..[!ELSE]..!ENDIF doesn't match",\r
                                     File=self._FilePath, Line=self._LineIndex+1)\r
             if self._Eval.Result == False:\r
                 self._Enabled = 0 - len(self._Eval)\r
@@ -453,7 +466,7 @@ class DscParser(MetaFileParser):
         elif TokenNumber == 2:\r
             Op = TokenList[0]\r
             if Op not in self._OP_:\r
-                EdkLogger.error('DscParser', FORMAT_INVALID, File=self._FilePath, \r
+                EdkLogger.error('Parser', FORMAT_INVALID, "Unsupported operator", File=self._FilePath,\r
                                 Line=self._LineIndex+1, ExtraData=Expression)\r
             if TokenList[1].upper() == 'TRUE':\r
                 Value = True\r
@@ -470,7 +483,7 @@ class DscParser(MetaFileParser):
             Op = TokenList[1]\r
             return self._OP_[Op](self._Macros[Macro], Value)\r
         else:\r
-            EdkLogger.error('DscParser', FORMAT_INVALID, File=self._FilePath, Line=self._LineIndex+1,\r
+            EdkLogger.error('Parser', FORMAT_INVALID, File=self._FilePath, Line=self._LineIndex+1,\r
                             ExtraData=Expression)\r
 \r
     def _BuildOptionParser(self):\r
@@ -485,8 +498,14 @@ class DscParser(MetaFileParser):
 \r
     def _PcdParser(self):\r
         TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT, 1)\r
-        self._ValueList[0:2] = GetSplitValueList(TokenList[0], TAB_SPLIT)\r
+        self._ValueList[0:1] = GetSplitValueList(TokenList[0], TAB_SPLIT)\r
         self._ValueList[2] = TokenList[1]\r
+        if self._ValueList[0] == '' or self._ValueList[1] == '':\r
+            EdkLogger.error('Parser', FORMAT_INVALID, "No token space GUID or PCD name specified",\r
+                            ExtraData=self._CurrentLine, File=self._FilePath, Line=self._LineIndex+1)\r
+        if self._ValueList[2] == '':\r
+            EdkLogger.error('Parser', FORMAT_INVALID, "No PCD value given",\r
+                            ExtraData=self._CurrentLine, File=self._FilePath, Line=self._LineIndex+1)\r
 \r
     def _ComponentParser(self):        \r
         if self._CurrentLine[-1] == '{':\r
@@ -540,7 +559,7 @@ class DecParser(MetaFileParser):
             if self._Content == None:\r
                 self._Content = open(self._FilePath, 'r').readlines()\r
         except:\r
-            EdkLogger.error("DecParser", FILE_READ_FAILURE, ExtraData=self._FilePath)\r
+            EdkLogger.error("Parser", FILE_READ_FAILURE, ExtraData=self._FilePath)\r
 \r
         for Index in range(0, len(self._Content)):\r
             Line = CleanString(self._Content[Index])\r
@@ -561,7 +580,6 @@ class DecParser(MetaFileParser):
             # section content\r
             self._ValueList = ['','','']\r
             self._SectionParser[self._SectionType](self)\r
-            EdkLogger.debug(EdkLogger.DEBUG_8, "Define: %s" % self._ValueList)\r
             if self._ValueList == None:\r
                 continue\r
 \r
@@ -587,22 +605,24 @@ class DecParser(MetaFileParser):
                     )\r
         self._Done()\r
             \r
-    #def _DefineParser(self):\r
-    #    TokenList = GetSplitValueList(self._CurrentLine, TAB_EQUAL_SPLIT, 1)\r
-    #    self._ValueList[0] = TokenList[0]\r
-    #    if len(TokenList) == 2:\r
-    #        MoreValues = GetSplitValueList(TokenList[1], TAB_VALUE_SPLIT)\r
-    #        self._ValueList[1:1+len(MoreValues)] = MoreValues\r
-\r
     def _GuidParser(self):\r
         TokenList = GetSplitValueList(self._CurrentLine, TAB_EQUAL_SPLIT, 1)\r
+        if len(TokenList) < 2:\r
+            EdkLogger.error('Parser', FORMAT_INVALID, "No value specified",\r
+                            ExtraData=self._CurrentLine, File=self._FilePath, Line=self._LineIndex+1)\r
         self._ValueList[0] = TokenList[0]\r
         self._ValueList[1] = TokenList[1]\r
 \r
     def _PcdParser(self):\r
         TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT, 1)\r
-        self._ValueList[0:2] = GetSplitValueList(TokenList[0], TAB_SPLIT)\r
+        self._ValueList[0:1] = GetSplitValueList(TokenList[0], TAB_SPLIT)\r
         self._ValueList[2] = TokenList[1]\r
+        if self._ValueList[0] == '' or self._ValueList[1] == '':\r
+            EdkLogger.error('Parser', FORMAT_INVALID, "No token space GUID or PCD name specified",\r
+                            ExtraData=self._CurrentLine, File=self._FilePath, Line=self._LineIndex+1)\r
+        if self._ValueList[2] == '':\r
+            EdkLogger.error('Parser', FORMAT_INVALID, "No PCD Datum information given",\r
+                            ExtraData=self._CurrentLine, File=self._FilePath, Line=self._LineIndex+1)\r
 \r
     _SectionParser = {\r
         MODEL_META_DATA_HEADER          :   MetaFileParser._DefineParser,\r
@@ -620,92 +640,11 @@ class DecParser(MetaFileParser):
         MODEL_META_DATA_USER_EXTENSION  :   MetaFileParser._Skip,\r
     }\r
 \r
-class Timer(object):\r
-    def __init__(self):\r
-        self.StartTime = 0\r
-        self.EndTime = 0\r
-\r
-    def __str__(self):\r
-        if self.EndTime != 0:\r
-            return str(self.EndTime - self.StartTime)\r
-        return time.clock() - self.StartTime\r
-\r
-    def Start(self):\r
-        self.StartTime = time.clock()\r
-\r
-    def Stop(self):\r
-        self.EndTime = time.clock()\r
-\r
 ##\r
 #\r
 # This acts like the main() function for the script, unless it is 'import'ed into another\r
 # script.\r
 #\r
 if __name__ == '__main__':\r
-    from WorkspaceDatabase import WorkspaceDatabase as DB\r
-\r
-    try:\r
-        import psyco\r
-        #psyco.profile()\r
-        #psyco.log()\r
-    except:\r
-        pass\r
-    timer = Timer()\r
-    timer.Start()\r
-\r
-    EdkLogger.Initialize()\r
-    if os.path.exists("test.db"):\r
-        os.remove("test.db")\r
-    Wks = DB("test.db")\r
-    Wks.InitDatabase()\r
-\r
-    os.chdir(r"H:\dev\AllPackagesDev")\r
-\r
-    #Gf = r"H:\dev\AllPackagesDev\LakeportX64Pkg\LakeportX64Pkg.dec"\r
-    ##Gf = r"H:\dev\AllPackagesDev\Nt32Pkg\Nt32Pkg.dec"\r
-    #Gb32 = Wks.BuildObject[Gf, MODEL_FILE_DEC, 'IA32']\r
-    #print repr(Gb32)\r
-\r
-    Pf = r"H:\dev\AllPackagesDev\LakeportX64Pkg\LakeportX64Pkg.dsc"\r
-    #Pf = r"H:\dev\AllPackagesDev\Nt32Pkg\Nt32Pkg.dsc"\r
-    Pb32 = Wks.BuildObject[Pf, MODEL_FILE_DSC, 'IA32']\r
-\r
-    print repr(Pb32)\r
-    for Mb in Pb32.Modules:\r
-        print repr(Mb)\r
-\r
-    Pb64 = Wks.BuildObject[Pf, MODEL_FILE_DSC, 'X64']\r
-\r
-    print repr(Pb64)\r
-    for Mb in Pb64.Modules:\r
-        print repr(Mb)\r
-\r
-    #LibList = []\r
-    #for Key in Pb32.LibraryClasses:\r
-    #    Inf = Pb32.LibraryClasses[Key]\r
-    #    if Inf  in LibList:\r
-    #        continue \r
-    #    Wks[Inf] = MODEL_FILE_INF\r
-    #    Mb = Module(Inf, Wks[Inf], 'IA32')\r
-    #    print repr(Mb)\r
-    #    LibList.append(Inf)\r
-    #\r
-    #Pb64 = Platform(Pf, Dsc, 'X64')\r
-    #print repr(Pb64)\r
-    #for Inf in Pb64.Modules:\r
-    #    Wks[Inf] = MODEL_FILE_INF\r
-    #    Mb = Module(Inf, Wks[Inf], 'X64')\r
-    #    print repr(Mb)\r
-    #LibList = []\r
-    #for Key in Pb64.LibraryClasses:\r
-    #    Inf = Pb64.LibraryClasses[Key]\r
-    #    if Inf in LibList:\r
-    #        continue \r
-    #    Wks[Inf] = MODEL_FILE_INF\r
-    #    Mb = Module(Inf, Wks[Inf], 'X64')\r
-    #    print repr(Mb)\r
-    #    LibList.append(Inf)\r
-\r
-    Wks.Close()\r
-    timer.Stop()\r
-    print "DONE [%s]" % str(timer)\r
+    pass\r
+\r
index b257657..b457f77 100644 (file)
@@ -185,45 +185,64 @@ class DscBuildData(PlatformBuildClassObject):
     def _GetPlatformName(self):\r
         if self._PlatformName == None:\r
             RecordList = self._Table.Query(MODEL_META_DATA_HEADER, TAB_DSC_DEFINES_PLATFORM_NAME, self.Arch)\r
+            if len(RecordList) == 0 or RecordList[0][0] == None:\r
+                EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No PLATFORM_NAME", File=self.DescFilePath)\r
             self._PlatformName = RecordList[0][0]\r
         return self._PlatformName\r
 \r
     def _GetFileGuid(self):\r
         if self._Guid == None:\r
             RecordList = self._Table.Query(MODEL_META_DATA_HEADER, TAB_DSC_DEFINES_PLATFORM_GUID, self.Arch)\r
+            if len(RecordList) == 0 or RecordList[0][0] == None:\r
+                EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No FILE_GUID", File=self.DescFilePath)\r
             self._Guid = RecordList[0][0]\r
         return self._Guid\r
 \r
     def _GetVersion(self):\r
         if self._Version == None:\r
             RecordList = self._Table.Query(MODEL_META_DATA_HEADER, TAB_DSC_DEFINES_PLATFORM_VERSION, self.Arch)\r
-            self._Version = RecordList[0][0]\r
+            if len(RecordList) == 0 or RecordList[0][0] == None:\r
+                self._Version = 0.0\r
+            else:\r
+                self._Version = RecordList[0][0]\r
         return self._Version\r
 \r
     def _GetDscSpec(self):\r
         if self._DscSpecification == None:\r
             RecordList = self._Table.Query(MODEL_META_DATA_HEADER, TAB_DSC_DEFINES_DSC_SPECIFICATION, self.Arch)\r
-            self._DscSpecification = RecordList[0][0]\r
+            if len(RecordList) == 0 or RecordList[0][0] == None:\r
+                self._DscSpecification = ''\r
+            else:\r
+                self._DscSpecification = RecordList[0][0]\r
         return self._DscSpecification\r
 \r
     def _GetOutpuDir(self):\r
         if self._OutputDirectory == None:\r
             RecordList = self._Table.Query(MODEL_META_DATA_HEADER, TAB_DSC_DEFINES_OUTPUT_DIRECTORY, self.Arch)\r
-            File = NormPath(RecordList[0][0], self._Macros)\r
-            LineNo = RecordList[0][-1]\r
-            self._OutputDirectory = File\r
+            if len(RecordList) == 0 or RecordList[0][0] == None:\r
+                self._OutputDirectory = os.path.join("Build", self.PlatformName)\r
+            else:\r
+                File = NormPath(RecordList[0][0], self._Macros)\r
+                LineNo = RecordList[0][-1]\r
+                self._OutputDirectory = File\r
         return self._OutputDirectory\r
 \r
     def _GetSupArch(self):\r
         if self._SupArchList == None:\r
             RecordList = self._Table.Query(MODEL_META_DATA_HEADER, TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES, self.Arch)\r
-            self._SupArchList = GetSplitValueList(RecordList[0][0], TAB_VALUE_SPLIT)\r
+            if len(RecordList) == 0 or RecordList[0][0] == None:\r
+                self._SupArchList = ARCH_LIST\r
+            else:\r
+                self._SupArchList = GetSplitValueList(RecordList[0][0], TAB_VALUE_SPLIT)\r
         return self._SupArchList\r
 \r
     def _GetBuildTarget(self):\r
         if self._BuildTargets == None:\r
             RecordList = self._Table.Query(MODEL_META_DATA_HEADER, TAB_DSC_DEFINES_BUILD_TARGETS, self.Arch)\r
-            self._BuildTargets = GetSplitValueList(RecordList[0][0])\r
+            if len(RecordList) == 0 or RecordList[0][0] == None:\r
+                self._BuildTargets = ['DEBUG', 'RELEASE']\r
+            else:\r
+                self._BuildTargets = GetSplitValueList(RecordList[0][0])\r
         return self._BuildTargets\r
 \r
     def _GetSkuName(self):\r
@@ -249,29 +268,37 @@ class DscBuildData(PlatformBuildClassObject):
     def _GetBuildNumber(self):\r
         if self._BuildNumber == None:\r
             RecordList = self._Table.Query(MODEL_META_DATA_HEADER, TAB_DSC_DEFINES_BUILD_NUMBER, self.Arch)\r
-            if len(RecordList) > 0:\r
+            if len(RecordList) > 0 and RecordList[0][0] != None:\r
                 self._BuildNumber = RecordList[0][0]\r
+            else:\r
+                self._BuildNumber = ''\r
         return self._BuildNumber\r
 \r
     def _GetMakefileName(self):\r
         if self._MakefileName == None:\r
             RecordList = self._Table.Query(MODEL_META_DATA_HEADER, TAB_DSC_DEFINES_MAKEFILE_NAME, self.Arch)\r
-            if len(RecordList):\r
+            if len(RecordList) > 0 and RecordList[0][0] != None:\r
                 self._MakefileName = RecordList[0][0]\r
+            else:\r
+                self._MakefileName = ''\r
         return self._MakefileName\r
 \r
     def _GetBsBaseAddress(self):\r
         if self._BsBaseAddress == None:\r
             RecordList = self._Table.Query(MODEL_META_DATA_HEADER, TAB_DSC_DEFINES_BS_BASE_ADDRESS, self.Arch)\r
-            if len(RecordList) != 0:\r
+            if len(RecordList) > 0 and RecordList[0][0] != None:\r
                 self._BsBaseAddress = RecordList[0][0]\r
+            else:\r
+                self._BsBaseAddress = ''\r
         return self._BsBaseAddress\r
 \r
     def _GetRtBaseAddress(self):\r
         if self._RtBaseAddress == None:\r
             RecordList = self._Table.Query(MODEL_META_DATA_HEADER, TAB_DSC_DEFINES_RT_BASE_ADDRESS, self.Arch)\r
-            if len(RecordList):\r
+            if len(RecordList) > 0 and RecordList[0][0] != None:\r
                 self._RtBaseAddress = RecordList[0][0]\r
+            else:\r
+                self._RtBaseAddress = ''\r
         return self._RtBaseAddress\r
 \r
     def _GetSkuIds(self):\r
@@ -279,6 +306,12 @@ class DscBuildData(PlatformBuildClassObject):
             self._SkuIds = {}\r
             RecordList = self._Table.Query(MODEL_EFI_SKU_ID)\r
             for Record in RecordList:\r
+                if Record[0] in [None, '']:\r
+                    EdkLogger.error('build', FORMAT_INVALID, 'No Sku ID number',\r
+                                    File=self.DescFilePath, Line=Record[-1])\r
+                if Record[1] in [None, '']:\r
+                    EdkLogger.error('build', FORMAT_INVALID, 'No Sku ID name',\r
+                                    File=self.DescFilePath, Line=Record[-1])\r
                 self._SkuIds[Record[1]] = Record[0]\r
         return self._SkuIds\r
 \r
@@ -373,22 +406,22 @@ class DscBuildData(PlatformBuildClassObject):
         for LibraryClassName in LibraryInstance:\r
             M = LibraryInstance[LibraryClassName]\r
             if M == None:\r
-                EdkLogger.error("build", AUTOGEN_ERROR,\r
-                                "Library instance for library class [%s] is not found" % LibraryClassName,\r
-                                ExtraData="\t%s [%s]" % (str(Module), self.Arch))\r
+                EdkLogger.error("build", RESOURCE_NOT_AVAILABLE,\r
+                                "\tLibrary instance of library class [%s] is not found" % LibraryClassName,\r
+                                File=self.DescFilePath, ExtraData="consumed by [%s] [%s]" % (str(Module), self._Arch))\r
             LibraryList.append(M)\r
             #\r
             # check if there're duplicate library classes\r
             #\r
             for Lc in M.LibraryClass:\r
                 if Lc.SupModList != None and ModuleType not in Lc.SupModList:\r
-                    EdkLogger.error("build", AUTOGEN_ERROR,\r
+                    EdkLogger.error("build", OPTION_MISSING,\r
                                     "Module type [%s] is not supported by library instance [%s]" % (ModuleType, str(M)),\r
-                                    ExtraData="\t%s" % str(Module))\r
+                                    File=self.DescFilePath, ExtraData="\tconsumed by [%s]" % str(Module))\r
 \r
                 if Lc.LibraryClass in LibraryInstance and str(M) != str(LibraryInstance[Lc.LibraryClass]):\r
-                    EdkLogger.error("build", AUTOGEN_ERROR,\r
-                                    "More than one library instance found for library class [%s] in module [%s]" % (Lc.LibraryClass, Module),\r
+                    EdkLogger.error("build", OPTION_CONFLICT,\r
+                                    "More than one library instance found for library class [%s] in module [%s]" % (Lc.LibraryClass, str(Module)),\r
                                     ExtraData="\t%s\n\t%s" % (LibraryInstance[Lc.LibraryClass], str(M))\r
                                     )\r
             if ConsumedByList[M] == []:\r
@@ -445,8 +478,8 @@ class DscBuildData(PlatformBuildClassObject):
         for Item in LibraryList:\r
             if ConsumedByList[Item] != [] and Item in Constructor and len(Constructor) > 1:\r
                 ErrorMessage = "\tconsumed by " + "\n\tconsumed by ".join([str(L) for L in ConsumedByList[Item]])\r
-                EdkLogger.error("build", AUTOGEN_ERROR, 'Library [%s] with constructors has a cycle' % str(Item),\r
-                                ExtraData=ErrorMessage)\r
+                EdkLogger.error("build", BUILD_ERROR, 'Library [%s] with constructors has a cycle' % str(Item),\r
+                                ExtraData=ErrorMessage, File=self.DescFilePath)\r
             if Item not in SortedLibraryList:\r
                 SortedLibraryList.append(Item)\r
 \r
@@ -913,7 +946,7 @@ class DecBuildData(PackageBuildClassObject):
         if self._PackageName == None:\r
             RecordList = self._Table.Query(MODEL_META_DATA_HEADER, TAB_DEC_DEFINES_PACKAGE_NAME)\r
             if len(RecordList) == 0:\r
-                EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "No PACKAGE_NAME", ExtraData=self.DescFilePath)\r
+                EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "No PACKAGE_NAME", File=self.DescFilePath)\r
             self._PackageName = RecordList[0][0]\r
         return self._PackageName\r
 \r
@@ -921,7 +954,7 @@ class DecBuildData(PackageBuildClassObject):
         if self._Guid == None:\r
             RecordList = self._Table.Query(MODEL_META_DATA_HEADER, TAB_DEC_DEFINES_PACKAGE_GUID)\r
             if len(RecordList) == 0:\r
-                EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "No PACKAGE_GUID", ExtraData=self.DescFilePath)\r
+                EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "No PACKAGE_GUID", File=self.DescFilePath)\r
             self._Guid = RecordList[0][0]\r
         return self._Guid\r
 \r
@@ -936,39 +969,42 @@ class DecBuildData(PackageBuildClassObject):
     def _GetProtocol(self):\r
         if self._Protocols == None:\r
             ProtocolDict = tdict(True)\r
-            NameSet = set()\r
+            NameList = []\r
             RecordList = self._Table.Query(MODEL_EFI_PROTOCOL, Arch=self.Arch)\r
             for Name, Guid, Dummy, Arch, ID, LineNo in RecordList:\r
-                NameSet.add(Name)\r
+                if Name not in NameList:\r
+                    NameList.append(Name)\r
                 ProtocolDict[Arch, Name] = Guid\r
             self._Protocols = sdict()\r
-            for Name in NameSet:\r
+            for Name in NameList:\r
                 self._Protocols[Name] = ProtocolDict[self.Arch, Name]\r
         return self._Protocols\r
 \r
     def _GetPpi(self):\r
         if self._Ppis == None:\r
             PpiDict = tdict(True)\r
-            NameSet = set()\r
+            NameList = []\r
             RecordList = self._Table.Query(MODEL_EFI_PPI, Arch=self.Arch)\r
             for Name, Guid, Dummy, Arch, ID, LineNo in RecordList:\r
-                NameSet.add(Name)\r
+                if Name not in NameList:\r
+                    NameList.append(Name)\r
                 PpiDict[Arch, Name] = Guid\r
             self._Ppis = sdict()\r
-            for Name in NameSet:\r
+            for Name in NameList:\r
                 self._Ppis[Name] = PpiDict[self.Arch, Name]\r
         return self._Ppis\r
 \r
     def _GetGuid(self):\r
         if self._Guids == None:\r
             GuidDict = tdict(True)\r
-            NameSet = set()\r
+            NameList = []\r
             RecordList = self._Table.Query(MODEL_EFI_GUID, Arch=self.Arch)\r
             for Name, Guid, Dummy, Arch, ID, LineNo in RecordList:\r
-                NameSet.add(Name)\r
+                if Name not in NameList:\r
+                    NameList.append(Name)\r
                 GuidDict[Arch, Name] = Guid\r
             self._Guids = sdict()\r
-            for Name in NameSet:\r
+            for Name in NameList:\r
                 self._Guids[Name] = GuidDict[self.Arch, Name]\r
         return self._Guids\r
 \r
@@ -1349,7 +1385,7 @@ class InfBuildData(ModuleBuildClassObject):
             if self._Header_ == None:\r
                 self._GetHeaderInfo()\r
             if self._BaseName == None:\r
-                self._BaseName = ''\r
+                EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No BASE_NAME name", File=self.DescFilePath)\r
         return self._BaseName\r
 \r
     def _GetModuleType(self):\r
@@ -1506,7 +1542,7 @@ class InfBuildData(ModuleBuildClassObject):
     def _SetLibraryClassUses(self, Value):\r
         self._LibraryClasses = Value\r
 \r
-    def _GetLibraryInstances(self):\r
+    def _GetLibraryNames(self):\r
         if self._Libraries == None:\r
             self._Libraries = []\r
             RecordList = self._Table.Query(MODEL_EFI_LIBRARY_INSTANCE, Arch=self._Arch, Platform=self._Platform)\r
@@ -1703,7 +1739,7 @@ class InfBuildData(ModuleBuildClassObject):
     Binaries                = property(_GetBinaryFiles)\r
     Sources                 = property(_GetSourceFiles)\r
     LibraryClasses          = property(_GetLibraryClassUses, _SetLibraryClassUses)\r
-    Libraries               = property(_GetLibraryInstances)\r
+    Libraries               = property(_GetLibraryNames)\r
     Protocols               = property(_GetProtocols)\r
     Ppis                    = property(_GetPpis)\r
     Guids                   = property(_GetGuids)\r