]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Workspace/MetaFileParser.py
BaseTools: Support Structure PCD value inherit between the different SKUs
[mirror_edk2.git] / BaseTools / Source / Python / Workspace / MetaFileParser.py
index 6a30d45b3dbf7059cd21309776769ae1ef1e3d81..13a08c8846876e14175509fb12ea3a16fe89523e 100644 (file)
@@ -296,7 +296,7 @@ class MetaFileParser(object):
         for Item in GetSplitValueList(self._CurrentLine[1:-1], TAB_COMMA_SPLIT):\r
             if Item == '':\r
                 continue\r
-            ItemList = GetSplitValueList(Item, TAB_SPLIT,2)\r
+            ItemList = GetSplitValueList(Item, TAB_SPLIT,3)\r
             # different section should not mix in one section\r
             if self._SectionName != '' and self._SectionName != ItemList[0].upper():\r
                 EdkLogger.error('Parser', FORMAT_INVALID, "Different section names in the same section",\r
@@ -329,7 +329,11 @@ class MetaFileParser(object):
                     S2 = ItemList[2].upper()\r
             else:\r
                 S2 = 'COMMON'\r
-            self._Scope.append([S1, S2])\r
+            if len(ItemList) > 3:\r
+                S3 = ItemList[3]\r
+            else:\r
+                S3 = "COMMON"\r
+            self._Scope.append([S1, S2, S3])\r
 \r
         # 'COMMON' must not be used with specific ARCHs at the same section\r
         if 'COMMON' in ArchList and len(ArchList) > 1:\r
@@ -410,7 +414,7 @@ class MetaFileParser(object):
 \r
     ## Construct section Macro dict \r
     def _ConstructSectionMacroDict(self, Name, Value):\r
-        ScopeKey = [(Scope[0], Scope[1]) for Scope in self._Scope]\r
+        ScopeKey = [(Scope[0], Scope[1],Scope[2]) for Scope in self._Scope]\r
         ScopeKey = tuple(ScopeKey)\r
         SectionDictKey = self._SectionType, ScopeKey\r
         #\r
@@ -442,20 +446,20 @@ class MetaFileParser(object):
                 continue\r
 \r
             for ActiveScope in self._Scope:\r
-                Scope0, Scope1 = ActiveScope[0], ActiveScope[1]\r
-                if(Scope0, Scope1) not in Scope:\r
+                Scope0, Scope1 ,Scope2= ActiveScope[0], ActiveScope[1],ActiveScope[2]\r
+                if(Scope0, Scope1,Scope2) not in Scope:\r
                     break\r
             else:\r
                 SpeSpeMacroDict.update(self._SectionsMacroDict[(SectionType, Scope)])\r
 \r
             for ActiveScope in self._Scope:\r
-                Scope0, Scope1 = ActiveScope[0], ActiveScope[1]\r
-                if(Scope0, Scope1) not in Scope and (Scope0, "COMMON") not in Scope and ("COMMON", Scope1) not in Scope:\r
+                Scope0, Scope1,Scope2 = ActiveScope[0], ActiveScope[1],ActiveScope[2]\r
+                if(Scope0, Scope1,Scope2) not in Scope and (Scope0, "COMMON","COMMON") not in Scope and ("COMMON", Scope1,"COMMON") not in Scope:\r
                     break\r
             else:\r
                 ComSpeMacroDict.update(self._SectionsMacroDict[(SectionType, Scope)])\r
 \r
-            if ("COMMON", "COMMON") in Scope:\r
+            if ("COMMON", "COMMON","COMMON") in Scope:\r
                 ComComMacroDict.update(self._SectionsMacroDict[(SectionType, Scope)])\r
 \r
         Macros.update(ComComMacroDict)\r
@@ -627,7 +631,7 @@ class InfParser(MetaFileParser):
             # Model, Value1, Value2, Value3, Arch, Platform, BelongsToItem=-1,\r
             # LineBegin=-1, ColumnBegin=-1, LineEnd=-1, ColumnEnd=-1, Enabled=-1\r
             #\r
-            for Arch, Platform in self._Scope:\r
+            for Arch, Platform,_ in self._Scope:\r
                 LastItem = self._Store(self._SectionType,\r
                             self._ValueList[0],\r
                             self._ValueList[1],\r
@@ -804,6 +808,7 @@ class DscParser(MetaFileParser):
     # DSC file supported data types (one type per section)\r
     DataType = {\r
         TAB_SKUIDS.upper()                          :   MODEL_EFI_SKU_ID,\r
+        TAB_DEFAULT_STORES.upper()                  :   MODEL_EFI_DEFAULT_STORES,\r
         TAB_LIBRARIES.upper()                       :   MODEL_EFI_LIBRARY_INSTANCE,\r
         TAB_LIBRARY_CLASSES.upper()                 :   MODEL_EFI_LIBRARY_CLASS,\r
         TAB_BUILD_OPTIONS.upper()                   :   MODEL_META_DATA_BUILD_OPTION,\r
@@ -952,7 +957,7 @@ class DscParser(MetaFileParser):
             # Model, Value1, Value2, Value3, Arch, ModuleType, BelongsToItem=-1, BelongsToFile=-1,\r
             # LineBegin=-1, ColumnBegin=-1, LineEnd=-1, ColumnEnd=-1, Enabled=-1\r
             #\r
-            for Arch, ModuleType in self._Scope:\r
+            for Arch, ModuleType, DefaultStore in self._Scope:\r
                 Owner = self._Owner[-1]\r
                 if self._SubsectionType != MODEL_UNKNOWN:\r
                     Owner = OwnerId[Arch]\r
@@ -963,6 +968,7 @@ class DscParser(MetaFileParser):
                                         self._ValueList[2],\r
                                         Arch,\r
                                         ModuleType,\r
+                                        DefaultStore,\r
                                         Owner,\r
                                         self._From,\r
                                         self._LineIndex + 1,\r
@@ -1015,7 +1021,7 @@ class DscParser(MetaFileParser):
                             ExtraData=self._CurrentLine)\r
 \r
         ItemType = self.DataType[DirectiveName]\r
-        Scope = [['COMMON', 'COMMON']]\r
+        Scope = [['COMMON', 'COMMON','COMMON']]\r
         if ItemType == MODEL_META_DATA_INCLUDE:\r
             Scope = self._Scope\r
         if ItemType == MODEL_META_DATA_CONDITIONAL_STATEMENT_ENDIF:\r
@@ -1045,7 +1051,7 @@ class DscParser(MetaFileParser):
         # Model, Value1, Value2, Value3, Arch, ModuleType, BelongsToItem=-1, BelongsToFile=-1,\r
         # LineBegin=-1, ColumnBegin=-1, LineEnd=-1, ColumnEnd=-1, Enabled=-1\r
         #\r
-        for Arch, ModuleType in Scope:\r
+        for Arch, ModuleType, DefaultStore in Scope:\r
             self._LastItem = self._Store(\r
                                     ItemType,\r
                                     self._ValueList[0],\r
@@ -1053,6 +1059,7 @@ class DscParser(MetaFileParser):
                                     self._ValueList[2],\r
                                     Arch,\r
                                     ModuleType,\r
+                                    DefaultStore,\r
                                     self._Owner[-1],\r
                                     self._From,\r
                                     self._LineIndex + 1,\r
@@ -1088,6 +1095,13 @@ class DscParser(MetaFileParser):
 \r
     @ParseMacro\r
     def _SkuIdParser(self):\r
+        TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT)\r
+        if len(TokenList) not in (2,3):\r
+            EdkLogger.error('Parser', FORMAT_INVALID, "Correct format is '<Integer>|<UiName>[|<UiName>]'",\r
+                            ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)\r
+        self._ValueList[0:len(TokenList)] = TokenList\r
+    @ParseMacro\r
+    def _DefaultStoresParser(self):\r
         TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT)\r
         if len(TokenList) != 2:\r
             EdkLogger.error('Parser', FORMAT_INVALID, "Correct format is '<Integer>|<UiName>'",\r
@@ -1243,6 +1257,7 @@ class DscParser(MetaFileParser):
             MODEL_META_DATA_CONDITIONAL_STATEMENT_ENDIF     :   self.__ProcessDirective,\r
             MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSEIF    :   self.__ProcessDirective,\r
             MODEL_EFI_SKU_ID                                :   self.__ProcessSkuId,\r
+            MODEL_EFI_DEFAULT_STORES                        :   self.__ProcessDefaultStores,\r
             MODEL_EFI_LIBRARY_INSTANCE                      :   self.__ProcessLibraryInstance,\r
             MODEL_EFI_LIBRARY_CLASS                         :   self.__ProcessLibraryClass,\r
             MODEL_PCD_FIXED_AT_BUILD                        :   self.__ProcessPcd,\r
@@ -1276,7 +1291,7 @@ class DscParser(MetaFileParser):
         self._ContentIndex = 0\r
         self._InSubsection = False\r
         while self._ContentIndex < len(self._Content) :\r
-            Id, self._ItemType, V1, V2, V3, S1, S2, Owner, self._From, \\r
+            Id, self._ItemType, V1, V2, V3, S1, S2, S3,Owner, self._From, \\r
                 LineStart, ColStart, LineEnd, ColEnd, Enabled = self._Content[self._ContentIndex]\r
 \r
             if self._From < 0:\r
@@ -1284,7 +1299,7 @@ class DscParser(MetaFileParser):
 \r
             self._ContentIndex += 1\r
 \r
-            self._Scope = [[S1, S2]]\r
+            self._Scope = [[S1, S2, S3]]\r
             #\r
             # For !include directive, handle it specially,\r
             # merge arch and module type in case of duplicate items\r
@@ -1293,9 +1308,9 @@ class DscParser(MetaFileParser):
                 if self._ContentIndex >= len(self._Content):\r
                     break\r
                 Record = self._Content[self._ContentIndex]\r
-                if LineStart == Record[9] and LineEnd == Record[11]:\r
-                    if [Record[5], Record[6]] not in self._Scope:\r
-                        self._Scope.append([Record[5], Record[6]])\r
+                if LineStart == Record[10] and LineEnd == Record[12]:\r
+                    if [Record[5], Record[6],Record[7]] not in self._Scope:\r
+                        self._Scope.append([Record[5], Record[6],Record[7]])\r
                     self._ContentIndex += 1\r
                 else:\r
                     break\r
@@ -1348,6 +1363,7 @@ class DscParser(MetaFileParser):
                                 self._ValueList[2],\r
                                 S1,\r
                                 S2,\r
+                                S3,\r
                                 NewOwner,\r
                                 self._From,\r
                                 self._LineIndex + 1,\r
@@ -1383,7 +1399,7 @@ class DscParser(MetaFileParser):
                         MODEL_PCD_DYNAMIC_VPD, MODEL_PCD_DYNAMIC_EX_DEFAULT, MODEL_PCD_DYNAMIC_EX_HII,\r
                         MODEL_PCD_DYNAMIC_EX_VPD):\r
             Records = self._RawTable.Query(PcdType, BelongsToItem= -1.0)\r
-            for TokenSpaceGuid, PcdName, Value, Dummy2, Dummy3, ID, Line in Records:\r
+            for TokenSpaceGuid, PcdName, Value, Dummy2, Dummy3, Dummy4,ID, Line in Records:\r
                 Name = TokenSpaceGuid + '.' + PcdName\r
                 if Name not in GlobalData.gPlatformOtherPcds:\r
                     PcdLine = Line\r
@@ -1549,6 +1565,9 @@ class DscParser(MetaFileParser):
     def __ProcessSkuId(self):\r
         self._ValueList = [ReplaceMacro(Value, self._Macros, RaiseError=True)\r
                            for Value in self._ValueList]\r
+    def __ProcessDefaultStores(self):\r
+        self._ValueList = [ReplaceMacro(Value, self._Macros, RaiseError=True)\r
+                           for Value in self._ValueList]\r
 \r
     def __ProcessLibraryInstance(self):\r
         self._ValueList = [ReplaceMacro(Value, self._Macros) for Value in self._ValueList]\r
@@ -1598,6 +1617,7 @@ class DscParser(MetaFileParser):
     _SectionParser = {\r
         MODEL_META_DATA_HEADER                          :   _DefineParser,\r
         MODEL_EFI_SKU_ID                                :   _SkuIdParser,\r
+        MODEL_EFI_DEFAULT_STORES                        :   _DefaultStoresParser,\r
         MODEL_EFI_LIBRARY_INSTANCE                      :   _LibraryInstanceParser,\r
         MODEL_EFI_LIBRARY_CLASS                         :   _LibraryClassParser,\r
         MODEL_PCD_FIXED_AT_BUILD                        :   _PcdParser,\r