1. Add <IsOverrided> to PcdClassObject
authorhche10x <hche10x@7335b38e-4728-0410-8992-fb3ffe349368>
Mon, 13 Aug 2007 09:19:53 +0000 (09:19 +0000)
committerhche10x <hche10x@7335b38e-4728-0410-8992-fb3ffe349368>
Mon, 13 Aug 2007 09:19:53 +0000 (09:19 +0000)
2. Support "," in section definition

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

Source/Python/Common/DataType.py
Source/Python/Common/DecClassObject.py
Source/Python/Common/DscClassObject.py
Source/Python/Common/EdkIIWorkspaceBuild.py
Source/Python/Common/InfClassObject.py
Source/Python/Common/String.py

index e853ca2..323cd6e 100644 (file)
@@ -18,6 +18,7 @@ TAB_SPLIT = '.'
 TAB_COMMENT_SPLIT = '#'\r
 TAB_EQUAL_SPLIT = '='\r
 TAB_VALUE_SPLIT = '|'\r
+TAB_COMMA_SPLIT = ','\r
 TAB_SPACE_SPLIT = ' '\r
 TAB_SECTION_START = '['\r
 TAB_SECTION_END = ']'\r
index a22ce66..1edb4df 100644 (file)
@@ -74,7 +74,7 @@ class Dec(DecObject):
     \r
     def ParseDec(self, Lines, Key, KeyField):\r
         newKey = SplitModuleType(Key)\r
-        if newKey[0].find(DataType.TAB_LIBRARY_CLASSES.upper()) != -1:\r
+        if newKey[0].upper().find(DataType.TAB_LIBRARY_CLASSES.upper()) != -1:\r
             GetLibraryClassesWithModuleType(Lines, Key, KeyField, TAB_COMMENT_SPLIT)\r
         else:\r
             GetMultipleValuesOfKeyFromLines(Lines, Key, KeyField, TAB_COMMENT_SPLIT)\r
@@ -91,29 +91,30 @@ class Dec(DecObject):
         self.Identification.FileFullPath = Filename\r
         self.Identification.FileRelativePath = Filepath\r
         \r
-        f = open(Filename, 'r').read()\r
-        PreCheck(Filename, f, self.KeyList)\r
-        sects = f.split('[')\r
-        for sect in sects:\r
-            tab = (sect.split(TAB_SECTION_END, 1)[0]).upper()\r
-            if tab == TAB_INF_DEFINES.upper():\r
-                GetSingleValueOfKeyFromLines(sect, self.Defines.DefinesDictionary, TAB_COMMENT_SPLIT, TAB_EQUAL_SPLIT, True, TAB_VALUE_SPLIT)\r
-                continue\r
-            for arch in DataType.ARCH_LIST_FULL + [DataType.TAB_ARCH_NULL]:\r
-                for key in self.KeyList:\r
-                    if arch != DataType.TAB_ARCH_NULL:\r
-                        target = (key + DataType.TAB_SPLIT + arch).upper()\r
-                    else:\r
-                        target = key.upper()\r
-                    if tab == target:\r
-                        if arch != DataType.TAB_ARCH_NULL:\r
-                            Command = 'self.ParseDec(sect, tab, self.Contents[arch].' + key + ')'\r
-                            eval(Command)\r
-                            continue\r
+        F = open(Filename, 'r').read()\r
+        PreCheck(Filename, F, self.KeyList)\r
+        Sects = F.split(DataType.TAB_SECTION_START)\r
+        for Sect in Sects:\r
+            TabList = GetSplitValueList(Sect.split(TAB_SECTION_END, 1)[0], DataType.TAB_COMMA_SPLIT)\r
+            for Tab in TabList:\r
+                if Tab.upper() == TAB_INF_DEFINES.upper():\r
+                    GetSingleValueOfKeyFromLines(Sect, self.Defines.DefinesDictionary, TAB_COMMENT_SPLIT, TAB_EQUAL_SPLIT, True, TAB_VALUE_SPLIT)\r
+                    continue\r
+                for Arch in DataType.ARCH_LIST_FULL + [DataType.TAB_ARCH_NULL]:\r
+                    for Key in self.KeyList:\r
+                        if Arch != DataType.TAB_ARCH_NULL:\r
+                            Target = (Key + DataType.TAB_SPLIT + Arch).upper()\r
                         else:\r
-                            Command = "self.ParseDec(sect, tab, self.Contents['" + DataType.TAB_ARCH_COMMON + "']." + key + ')'\r
-                            eval(Command)\r
-                            continue\r
+                            Target = Key.upper()\r
+                        if Tab.upper() == Target:\r
+                            if Arch != DataType.TAB_ARCH_NULL:\r
+                                Command = 'self.ParseDec(Sect, Tab, self.Contents[Arch].' + Key + ')'\r
+                                eval(Command)\r
+                                continue\r
+                            else:\r
+                                Command = "self.ParseDec(Sect, Tab, self.Contents['" + DataType.TAB_ARCH_COMMON + "']." + Key + ')'\r
+                                eval(Command)\r
+                                continue\r
         #EndFor\r
 \r
     def DecToPackage(self):\r
index 1b6b492..f561047 100644 (file)
@@ -91,12 +91,12 @@ class Dsc(DscObject):
             self.DscToPlatform()\r
         \r
     def ParseDsc(self, Lines, Key, KeyField):\r
-        newKey = SplitModuleType(Key)     \r
-        if newKey[0].find(TAB_LIBRARY_CLASSES.upper()) != -1:\r
+        newKey = SplitModuleType(Key)\r
+        if newKey[0].upper().find(TAB_LIBRARY_CLASSES.upper()) != -1:\r
             GetLibraryClassesWithModuleType(Lines, Key, KeyField, TAB_COMMENT_SPLIT)\r
-        elif newKey[0].find(TAB_COMPONENTS.upper()) != -1:\r
+        elif newKey[0].upper().find(TAB_COMPONENTS.upper()) != -1:\r
             GetComponents(Lines, Key, KeyField, TAB_COMMENT_SPLIT)\r
-        elif newKey[0].find(TAB_PCDS_DYNAMIC.upper()) != -1:\r
+        elif newKey[0].upper().find(TAB_PCDS_DYNAMIC.upper()) != -1:\r
             GetDynamics(Lines, Key, KeyField, TAB_COMMENT_SPLIT)\r
         else:\r
             GetMultipleValuesOfKeyFromLines(Lines, Key, KeyField, TAB_COMMENT_SPLIT)\r
@@ -115,27 +115,28 @@ class Dsc(DscObject):
         \r
         F = open(Filename, 'r').read()\r
         PreCheck(Filename, F, self.KeyList)\r
-        sects = F.split('[')\r
-        for sect in sects:\r
-            tab = (sect.split(TAB_SECTION_END, 1)[0]).upper()\r
-            if tab == TAB_INF_DEFINES.upper():\r
-                GetSingleValueOfKeyFromLines(sect, self.Defines.DefinesDictionary, TAB_COMMENT_SPLIT, TAB_EQUAL_SPLIT, True, TAB_VALUE_SPLIT)\r
-                continue\r
-            for arch in DataType.ARCH_LIST_FULL + [DataType.TAB_ARCH_NULL]:\r
-                for key in self.KeyList:\r
-                    if arch != DataType.TAB_ARCH_NULL:\r
-                        target = (key + DataType.TAB_SPLIT + arch).upper()\r
-                    else:\r
-                        target = key.upper()\r
-                    if SplitModuleType(tab)[0] == target:\r
-                        if arch != DataType.TAB_ARCH_NULL:\r
-                            Command = 'self.ParseDsc(sect, tab, self.Contents[arch].' + key + ')'\r
-                            eval(Command)\r
-                            continue\r
+        Sects = F.split(DataType.TAB_SECTION_START)\r
+        for Sect in Sects:\r
+            TabList = GetSplitValueList(Sect.split(TAB_SECTION_END, 1)[0], DataType.TAB_COMMA_SPLIT)\r
+            for Tab in TabList:\r
+                if Tab.upper() == TAB_INF_DEFINES.upper():\r
+                    GetSingleValueOfKeyFromLines(Sect, self.Defines.DefinesDictionary, TAB_COMMENT_SPLIT, TAB_EQUAL_SPLIT, True, TAB_VALUE_SPLIT)\r
+                    continue\r
+                for Arch in DataType.ARCH_LIST_FULL + [DataType.TAB_ARCH_NULL]:\r
+                    for Key in self.KeyList:\r
+                        if Arch != DataType.TAB_ARCH_NULL:\r
+                            Target = (Key + DataType.TAB_SPLIT + Arch).upper()\r
                         else:\r
-                            Command = "self.ParseDsc(sect, tab, self.Contents['" + DataType.TAB_ARCH_COMMON + "']." + key + ')'\r
-                            eval(Command)\r
-                            continue\r
+                            Target = Key.upper()\r
+                        if SplitModuleType(Tab)[0].upper() == Target:\r
+                            if Arch != DataType.TAB_ARCH_NULL:\r
+                                Command = 'self.ParseDsc(Sect, Tab, self.Contents[Arch].' + Key + ')'\r
+                                eval(Command)\r
+                                continue\r
+                            else:\r
+                                Command = "self.ParseDsc(Sect, Tab, self.Contents['" + DataType.TAB_ARCH_COMMON + "']." + Key + ')'\r
+                                eval(Command)\r
+                                continue\r
 \r
     def DscToPlatform(self):\r
         #\r
index f9a684c..c4f5de6 100644 (file)
@@ -29,7 +29,7 @@ from CommonDataClass.CommonClass import *
 # This Class is used for PcdObject \r
 #\r
 class PcdClassObject(object):\r
-    def __init__(self, Name = None, Guid = None, Type = None, DatumType = None, Value = None, Token = None, MaxDatumSize = None, SkuInfoList = {}):\r
+    def __init__(self, Name = None, Guid = None, Type = None, DatumType = None, Value = None, Token = None, MaxDatumSize = None, SkuInfoList = {}, IsOverrided = False):\r
         self.TokenCName = Name\r
         self.TokenSpaceGuidCName = Guid\r
         self.Type = Type\r
@@ -38,6 +38,7 @@ class PcdClassObject(object):
         self.TokenValue = Token\r
         self.MaxDatumSize = MaxDatumSize\r
         self.SkuInfoList = SkuInfoList\r
+        self.IsOverrided = IsOverrided\r
         self.Phase = "DXE"\r
         \r
     def __str__(self):\r
@@ -49,7 +50,9 @@ class PcdClassObject(object):
               str(self.TokenValue) + DataType.TAB_VALUE_SPLIT + \\r
               str(self.MaxDatumSize) + DataType.TAB_VALUE_SPLIT\r
         for Item in self.SkuInfoList.values():\r
-            rtn = rtn + Item.SkuId + DataType.TAB_VALUE_SPLIT + Item.SkuIdName\r
+            rtn = rtn + Item.SkuId + DataType.TAB_VALUE_SPLIT + Item.SkuIdName + DataType.TAB_VALUE_SPLIT\r
+        rtn = rtn + str(self.IsOverrided)\r
+        \r
         return rtn\r
 \r
     def __eq__(self, other):\r
@@ -299,7 +302,7 @@ class WorkspaceBuild(object):
                         Token = Item.Token\r
                         MaxDatumSize = Item.MaxDatumSize\r
                         SkuInfoList = Item.SkuInfoList\r
-                        pb.Pcds[(Name, Guid)] = PcdClassObject(Name, Guid, Type, DatumType, Value, Token, MaxDatumSize, SkuInfoList)\r
+                        pb.Pcds[(Name, Guid)] = PcdClassObject(Name, Guid, Type, DatumType, Value, Token, MaxDatumSize, SkuInfoList, False)\r
                 \r
                 # Add to database\r
                 self.Build[Arch].PlatformDatabase[Dsc] = pb\r
@@ -357,7 +360,7 @@ class WorkspaceBuild(object):
                         Token = Item.Token\r
                         MaxDatumSize = Item.MaxDatumSize\r
                         SkuInfoList = Item.SkuInfoList\r
-                        pb.Pcds[(Name, Guid)] = PcdClassObject(Name, Guid, Type, DatumType, Value, Token, MaxDatumSize, SkuInfoList)\r
+                        pb.Pcds[(Name, Guid)] = PcdClassObject(Name, Guid, Type, DatumType, Value, Token, MaxDatumSize, SkuInfoList, False)\r
                 \r
                 # Add to database\r
                 self.Build[Arch].PackageDatabase[Dec] = pb\r
@@ -811,6 +814,7 @@ class WorkspaceBuild(object):
         Token = ''\r
         MaxDatumSize = ''\r
         SkuInfoList = {}\r
+        IsOverrided = False\r
         #\r
         # First get information from platform database\r
         #\r
@@ -823,6 +827,7 @@ class WorkspaceBuild(object):
                 Token = Pcds[(Name, Guid)].TokenValue\r
                 MaxDatumSize = Pcds[(Name, Guid)].MaxDatumSize\r
                 SkuInfoList =  Pcds[(Name, Guid)].SkuInfoList\r
+                IsOverrided = True\r
                 break\r
 \r
         #\r
@@ -848,14 +853,16 @@ class WorkspaceBuild(object):
                                     Value = Pcd.DefaultValue\r
                                 if Pcd.MaxDatumSize != '':\r
                                     MaxDatumSize = Pcd.MaxDatumSize\r
+                                IsOverrided = True\r
         \r
         #\r
         # Last get information from PcdsSet defined by FDF\r
         #\r
         if Guid in PcdsSet.keys():\r
             Value = PcdsSet[Guid]\r
-        \r
-        return PcdClassObject(Name, Guid, Type, DatumType, Value, Token, MaxDatumSize, SkuInfoList)\r
+            IsOverrided = True\r
+\r
+        return PcdClassObject(Name, Guid, Type, DatumType, Value, Token, MaxDatumSize, SkuInfoList, IsOverrided)\r
     \r
     #\r
     # Search in InfDatabase, find the supmodulelist of the libraryclass\r
index dcae952..6641a5d 100644 (file)
@@ -113,7 +113,7 @@ class Inf(InfObject):
             \r
     def ParseInf(self, Lines, Key, KeyField):\r
         newKey = SplitModuleType(Key)\r
-        if newKey[0].find(DataType.TAB_LIBRARY_CLASSES.upper()) != -1:\r
+        if newKey[0].upper().find(DataType.TAB_LIBRARY_CLASSES.upper()) != -1:\r
             GetLibraryClassesWithModuleType(Lines, Key, KeyField, TAB_COMMENT_SPLIT)\r
         else:\r
             GetMultipleValuesOfKeyFromLines(Lines, Key, KeyField, TAB_COMMENT_SPLIT)\r
@@ -462,33 +462,34 @@ class Inf(InfObject):
         self.Identification.FileFullPath = Filename\r
         self.Identification.FileRelativePath = Filepath\r
         \r
-        f = open(Filename, 'r').read()\r
-        PreCheck(Filename, f, self.KeyList)\r
-        sects = f.split('[')\r
-        for sect in sects:\r
-            tab = (sect.split(TAB_SECTION_END, 1)[0]).upper()\r
-            if tab == TAB_INF_DEFINES.upper():\r
-                GetSingleValueOfKeyFromLines(sect, self.Defines.DefinesDictionary, TAB_COMMENT_SPLIT, TAB_EQUAL_SPLIT, False, None)\r
-                continue\r
-            if tab.find(DataType.TAB_USER_EXTENSIONS.upper()) > -1:\r
-                self.UserExtensions = sect\r
-                continue\r
-            for arch in DataType.ARCH_LIST_FULL + [DataType.TAB_ARCH_NULL]:\r
-                for key in self.KeyList:\r
-                    if arch != DataType.TAB_ARCH_NULL:\r
-                        target = (key + DataType.TAB_SPLIT + arch).upper()\r
-                    else:\r
-                        target = key.upper()\r
-                    if SplitModuleType(tab)[0] == target:\r
-                        if arch != DataType.TAB_ARCH_NULL:\r
-                            Command = 'self.ParseInf(sect, tab, self.Contents[arch].' + key + ')'\r
-                            eval(Command)\r
-                            continue\r
+        F = open(Filename, 'r').read()\r
+        PreCheck(Filename, F, self.KeyList)\r
+        Sects = F.split(DataType.TAB_SECTION_START)\r
+        for Sect in Sects:\r
+            TabList = GetSplitValueList(Sect.split(TAB_SECTION_END, 1)[0], DataType.TAB_COMMA_SPLIT)\r
+            for Tab in TabList:            \r
+                if Tab.upper() == TAB_INF_DEFINES.upper():\r
+                    GetSingleValueOfKeyFromLines(Sect, self.Defines.DefinesDictionary, TAB_COMMENT_SPLIT, TAB_EQUAL_SPLIT, False, None)\r
+                    continue\r
+                if Tab.upper().find(DataType.TAB_USER_EXTENSIONS.upper()) > -1:\r
+                    self.UserExtensions = Sect\r
+                    continue\r
+                for Arch in DataType.ARCH_LIST_FULL + [DataType.TAB_ARCH_NULL]:\r
+                    for Key in self.KeyList:\r
+                        if Arch != DataType.TAB_ARCH_NULL:\r
+                            Target = (Key + DataType.TAB_SPLIT + Arch).upper()\r
                         else:\r
-                            Command = "self.ParseInf(sect, tab, self.Contents['" + DataType.TAB_ARCH_COMMON + "']." + key + ')'\r
-                            eval(Command)\r
-                            continue\r
-        #EndFor\r
+                            Target = Key.upper()\r
+                        if SplitModuleType(Tab)[0].upper() == Target:\r
+                            if Arch != DataType.TAB_ARCH_NULL:\r
+                                Command = 'self.ParseInf(Sect, Tab, self.Contents[Arch].' + Key + ')'\r
+                                eval(Command)\r
+                                continue\r
+                            else:\r
+                                Command = "self.ParseInf(Sect, Tab, self.Contents['" + DataType.TAB_ARCH_COMMON + "']." + Key + ')'\r
+                                eval(Command)\r
+                                continue\r
+            #EndFor\r
 \r
     def ShowInf(self):\r
         print TAB_SECTION_START + TAB_INF_DEFINES + TAB_SECTION_END\r
index aaa14f6..daf9256 100644 (file)
@@ -178,6 +178,9 @@ def GetComponents(Lines, Key, KeyValues, CommentCharacter):
         \r
     return True\r
 \r
+#\r
+# Get Library Class definition when no module type defined\r
+#\r
 def GetLibraryClassesWithModuleType(Lines, Key, KeyValues, CommentCharacter):\r
     newKey = SplitModuleType(Key)\r
     Lines = Lines.split(DataType.TAB_SECTION_END, 1)[1]\r
@@ -189,14 +192,21 @@ def GetLibraryClassesWithModuleType(Lines, Key, KeyValues, CommentCharacter):
 \r
     return True\r
 \r
+#\r
+# Get Dynamic Pcds\r
+#\r
 def GetDynamics(Lines, Key, KeyValues, CommentCharacter):\r
-    newKey = SplitModuleType(Key)\r
+    #\r
+    # Get SkuId Name List\r
+    #\r
+    SkuIdNameList = SplitModuleType(Key)\r
+    \r
     Lines = Lines.split(DataType.TAB_SECTION_END, 1)[1]\r
     LineList = Lines.splitlines()\r
     for Line in LineList:\r
         Line = CleanString(Line, CommentCharacter)\r
         if Line != '' and Line[0] != CommentCharacter:\r
-            KeyValues.append([CleanString(Line, CommentCharacter), newKey[1]])\r
+            KeyValues.append([CleanString(Line, CommentCharacter), SkuIdNameList[1]])\r
 \r
     return True\r
 \r