1. Fix a bug when parsing binary section of INF file
authorhche10x <hche10x@7335b38e-4728-0410-8992-fb3ffe349368>
Mon, 10 Sep 2007 03:33:55 +0000 (03:33 +0000)
committerhche10x <hche10x@7335b38e-4728-0410-8992-fb3ffe349368>
Mon, 10 Sep 2007 03:33:55 +0000 (03:33 +0000)
2. Fix a bug of printing wrong pcd type when raising a pcd format error of INF file
3. Adjust code of parsing "Pcd" section of INF file.

git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@700 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/Common/InfClassObject.py

index 37420e1..41869cc 100755 (executable)
@@ -340,6 +340,11 @@ class Inf(InfObject):
         Pcds = {}\r
         for Arch in DataType.ARCH_LIST:\r
             for Item in self.Contents[Arch].FixedPcd:\r
+                #\r
+                # Library should not have FixedPcd\r
+                #\r
+                if self.Module.Header.LibraryClass != {}:\r
+                    pass\r
                 MergeArches(Pcds, self.GetPcdOfInf(Item, TAB_PCDS_FIXED_AT_BUILD, File), Arch)\r
             \r
             for Item in self.Contents[Arch].PatchPcd:\r
@@ -353,6 +358,10 @@ class Inf(InfObject):
             \r
             for Item in self.Contents[Arch].Pcd:\r
                 MergeArches(Pcds, self.GetPcdOfInf(Item, TAB_PCDS_DYNAMIC, File), Arch)\r
+                MergeArches(Pcds, self.GetPcdOfInf(Item, TAB_PCDS_DYNAMIC_EX, File), Arch)\r
+                MergeArches(Pcds, self.GetPcdOfInf(Item, TAB_PCDS_FEATURE_FLAG, File), Arch)\r
+                MergeArches(Pcds, self.GetPcdOfInf(Item, TAB_PCDS_FIXED_AT_BUILD, File), Arch)\r
+                MergeArches(Pcds, self.GetPcdOfInf(Item, TAB_PCDS_PATCHABLE_IN_MODULE, File), Arch)\r
                 \r
         for Key in Pcds.keys():\r
             Pcd = PcdClass()\r
@@ -474,7 +483,7 @@ class Inf(InfObject):
                     CheckPcdTokenInfo(List[3], 'Binaries', File)\r
                     MergeArches(Binaries, (List[0], List[1], List[2], List[3]), Arch)\r
         for Key in Binaries.keys():\r
-            Binary = ModuleBinaryFileClass(Key[2], Key[0], Key[1], Key[3], Binaries[Key])\r
+            Binary = ModuleBinaryFileClass(Key[1], Key[0], Key[2], Key[3], Binaries[Key])\r
             self.Module.Binaries.append(Binary)\r
         \r
     #\r
@@ -483,12 +492,23 @@ class Inf(InfObject):
     #\r
     def GetPcdOfInf(self, Item, Type, File):\r
         Format = '<TokenSpaceGuidCName>.<PcdCName>[|<Value>]'\r
+        InfType = ''\r
+        if Type == TAB_PCDS_FIXED_AT_BUILD:\r
+            InfType = TAB_INF_FIXED_PCD\r
+        elif Type == TAB_PCDS_PATCHABLE_IN_MODULE:\r
+            InfType = TAB_INF_PATCH_PCD\r
+        elif Type == TAB_PCDS_FEATURE_FLAG:\r
+            InfType = TAB_INF_FEATURE_PCD        \r
+        elif Type == TAB_PCDS_DYNAMIC_EX:\r
+            InfType = TAB_INF_PCD_EX        \r
+        elif Type == TAB_PCDS_DYNAMIC:\r
+            InfType = TAB_INF_PCD\r
         List = GetSplitValueList(Item + DataType.TAB_VALUE_SPLIT)\r
         if len(List) < 2 or len(List) > 3:\r
-            RaiseParserError(Item, 'Pcds' + Type, File, Format)\r
+            RaiseParserError(Item, InfType, File, Format)\r
         TokenInfo = GetSplitValueList(List[0], DataType.TAB_SPLIT)\r
         if len(TokenInfo) != 2:\r
-            RaiseParserError(Item, 'Pcds' + Type, File, Format)\r
+            RaiseParserError(Item, InfType, File, Format)\r
         if len(List) == 3 and List[1] == '':\r
             #\r
             # Value is empty\r
@@ -622,7 +642,7 @@ class Inf(InfObject):
             print Item.Depex, Item.SupArchList, Item.Define\r
         print '\nBinaries =', m.Binaries\r
         for Binary in m.Binaries:\r
-            print Binary.FileType, Binary.Target, Binary.BinaryFile, Binary.FeatureFlag\r
+            print 'Type=', Binary.FileType, 'Target=', Binary.Target, 'Name=', Binary.BinaryFile, Binary.FeatureFlag\r
         \r
 if __name__ == '__main__':\r
     w = os.getenv('WORKSPACE')\r