]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Workspace/MetaFileParser.py
BaseTools: Support DSC component !include PCD items
[mirror_edk2.git] / BaseTools / Source / Python / Workspace / MetaFileParser.py
index 2eb4c75e46587f8b7e238060abbfbd4b852ce971..322ed384496658635e8b87c1de4e75d6d564713c 100644 (file)
@@ -219,7 +219,7 @@ class MetaFileParser(object):
         NewRecordList = []\r
         for Record in RecordList:\r
             Arch = Record[3]\r
-            if Arch == 'COMMON' or Arch == FilterArch:\r
+            if Arch == TAB_ARCH_COMMON or Arch == FilterArch:\r
                 NewRecordList.append(Record)\r
         return NewRecordList\r
 \r
@@ -241,7 +241,7 @@ class MetaFileParser(object):
                 self.Start()\r
 \r
         # No specific ARCH or Platform given, use raw data\r
-        if self._RawTable and (len(DataInfo) == 1 or DataInfo[1] == None):\r
+        if self._RawTable and (len(DataInfo) == 1 or DataInfo[1] is None):\r
             return self._FilterRecordList(self._RawTable.Query(*DataInfo), self._Arch)\r
 \r
         # Do post-process if necessary\r
@@ -319,7 +319,7 @@ class MetaFileParser(object):
             if len(ItemList) > 1:\r
                 S1 = ItemList[1].upper()\r
             else:\r
-                S1 = 'COMMON'\r
+                S1 = TAB_ARCH_COMMON\r
             ArchList.add(S1)\r
 \r
             # S2 may be Platform or ModuleType\r
@@ -329,15 +329,15 @@ class MetaFileParser(object):
                 else:\r
                     S2 = ItemList[2].upper()\r
             else:\r
-                S2 = 'COMMON'\r
+                S2 = TAB_COMMON\r
             if len(ItemList) > 3:\r
                 S3 = ItemList[3]\r
             else:\r
-                S3 = "COMMON"\r
+                S3 = TAB_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
+        if TAB_ARCH_COMMON in ArchList and len(ArchList) > 1:\r
             EdkLogger.error('Parser', FORMAT_INVALID, "'common' ARCH must not be used with specific ARCHs",\r
                             File=self.MetaFile, Line=self._LineIndex + 1, ExtraData=self._CurrentLine)\r
         # If the section information is needed later, it should be stored in database\r
@@ -455,12 +455,12 @@ class MetaFileParser(object):
 \r
             for ActiveScope in self._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
+                if(Scope0, Scope1,Scope2) not in Scope and (Scope0, TAB_COMMON, TAB_COMMON) not in Scope and (TAB_COMMON, Scope1, TAB_COMMON) not in Scope:\r
                     break\r
             else:\r
                 ComSpeMacroDict.update(self._SectionsMacroDict[(SectionType, Scope)])\r
 \r
-            if ("COMMON", "COMMON","COMMON") in Scope:\r
+            if (TAB_COMMON, TAB_COMMON, TAB_COMMON) in Scope:\r
                 ComComMacroDict.update(self._SectionsMacroDict[(SectionType, Scope)])\r
 \r
         Macros.update(ComComMacroDict)\r
@@ -568,8 +568,8 @@ class InfParser(MetaFileParser):
             if Line[0] == TAB_SECTION_START and Line[-1] == TAB_SECTION_END:\r
                 if not GetHeaderComment:\r
                     for Cmt, LNo in Comments:\r
-                        self._Store(MODEL_META_DATA_HEADER_COMMENT, Cmt, '', '', 'COMMON',\r
-                                    'COMMON', self._Owner[-1], LNo, -1, LNo, -1, 0)\r
+                        self._Store(MODEL_META_DATA_HEADER_COMMENT, Cmt, '', '', TAB_COMMON,\r
+                                    TAB_COMMON, self._Owner[-1], LNo, -1, LNo, -1, 0)\r
                     GetHeaderComment = True\r
                 else:\r
                     TailComments.extend(SectionComments + Comments)\r
@@ -620,7 +620,7 @@ class InfParser(MetaFileParser):
             self._ValueList = ['', '', '']\r
             # parse current line, result will be put in self._ValueList\r
             self._SectionParser[self._SectionType](self)\r
-            if self._ValueList == None or self._ItemType == MODEL_META_DATA_DEFINE:\r
+            if self._ValueList is None or self._ItemType == MODEL_META_DATA_DEFINE:\r
                 self._ItemType = -1\r
                 Comments = []\r
                 continue\r
@@ -658,8 +658,8 @@ class InfParser(MetaFileParser):
 \r
         # If there are tail comments in INF file, save to database whatever the comments are\r
         for Comment in TailComments:\r
-            self._Store(MODEL_META_DATA_TAIL_COMMENT, Comment[0], '', '', 'COMMON',\r
-                                'COMMON', self._Owner[-1], -1, -1, -1, -1, 0)\r
+            self._Store(MODEL_META_DATA_TAIL_COMMENT, Comment[0], '', '', TAB_COMMON,\r
+                                TAB_COMMON, self._Owner[-1], -1, -1, -1, -1, 0)\r
         self._Done()\r
 \r
     ## Data parser for the format in which there's path\r
@@ -952,7 +952,7 @@ class DscParser(MetaFileParser):
 \r
             self._ValueList = ['', '', '']\r
             self._SectionParser[SectionType](self)\r
-            if self._ValueList == None:\r
+            if self._ValueList is None:\r
                 continue\r
             #\r
             # Model, Value1, Value2, Value3, Arch, ModuleType, BelongsToItem=-1, BelongsToFile=-1,\r
@@ -1022,7 +1022,7 @@ class DscParser(MetaFileParser):
                             ExtraData=self._CurrentLine)\r
 \r
         ItemType = self.DataType[DirectiveName]\r
-        Scope = [['COMMON', 'COMMON','COMMON']]\r
+        Scope = [[TAB_COMMON, TAB_COMMON, TAB_COMMON]]\r
         if ItemType == MODEL_META_DATA_INCLUDE:\r
             Scope = self._Scope\r
         if ItemType == MODEL_META_DATA_CONDITIONAL_STATEMENT_ENDIF:\r
@@ -1361,7 +1361,7 @@ class DscParser(MetaFileParser):
                                 File=self._FileWithError, ExtraData=' '.join(self._ValueList),\r
                                 Line=self._LineIndex + 1)\r
 \r
-            if self._ValueList == None:\r
+            if self._ValueList is None:\r
                 continue\r
 \r
             NewOwner = self._IdMapping.get(Owner, -1)\r
@@ -1504,12 +1504,12 @@ class DscParser(MetaFileParser):
             # Allow using system environment variables  in path after !include\r
             #\r
             __IncludeMacros['WORKSPACE'] = GlobalData.gGlobalDefines['WORKSPACE']\r
-            if "ECP_SOURCE" in GlobalData.gGlobalDefines.keys():\r
+            if "ECP_SOURCE" in GlobalData.gGlobalDefines:\r
                 __IncludeMacros['ECP_SOURCE'] = GlobalData.gGlobalDefines['ECP_SOURCE']\r
             #\r
             # During GenFds phase call DSC parser, will go into this branch.\r
             #\r
-            elif "ECP_SOURCE" in GlobalData.gCommandLineDefines.keys():\r
+            elif "ECP_SOURCE" in GlobalData.gCommandLineDefines:\r
                 __IncludeMacros['ECP_SOURCE'] = GlobalData.gCommandLineDefines['ECP_SOURCE']\r
 \r
             __IncludeMacros['EFI_SOURCE'] = GlobalData.gGlobalDefines['EFI_SOURCE']\r
@@ -1538,9 +1538,13 @@ class DscParser(MetaFileParser):
             self._FileWithError = IncludedFile1\r
 \r
             IncludedFileTable = MetaFileStorage(self._Table.Cur, IncludedFile1, MODEL_FILE_DSC, False)\r
-            Owner = self._Content[self._ContentIndex - 1][0]\r
+            FromItem = self._Content[self._ContentIndex - 1][0]\r
+            if self._Content[self._ContentIndex - 1][8] != -1.0:\r
+                Owner = self._Content[self._ContentIndex - 1][8]\r
+            else:\r
+                Owner = self._Content[self._ContentIndex - 1][0]\r
             Parser = DscParser(IncludedFile1, self._FileType, self._Arch, IncludedFileTable,\r
-                               Owner=Owner, From=Owner)\r
+                               Owner=Owner, From=FromItem)\r
 \r
             self.IncludedFiles.add (IncludedFile1)\r
 \r
@@ -1552,7 +1556,10 @@ class DscParser(MetaFileParser):
 \r
             # set the parser status with current status\r
             Parser._SectionName = self._SectionName\r
-            Parser._SectionType = self._SectionType\r
+            if self._InSubsection:\r
+                Parser._SectionType = self._SubsectionType\r
+            else:\r
+                Parser._SectionType = self._SectionType\r
             Parser._Scope = self._Scope\r
             Parser._Enabled = self._Enabled\r
             # Parse the included file\r
@@ -1740,7 +1747,7 @@ class DecParser(MetaFileParser):
             # section content\r
             self._ValueList = ['', '', '']\r
             self._SectionParser[self._SectionType[0]](self)\r
-            if self._ValueList == None or self._ItemType == MODEL_META_DATA_DEFINE:\r
+            if self._ValueList is None or self._ItemType == MODEL_META_DATA_DEFINE:\r
                 self._ItemType = -1\r
                 self._Comments = []\r
                 continue\r
@@ -1832,7 +1839,7 @@ class DecParser(MetaFileParser):
             if len(ItemList) > 1:\r
                 S1 = ItemList[1].upper()\r
             else:\r
-                S1 = 'COMMON'\r
+                S1 = TAB_ARCH_COMMON\r
             ArchList.add(S1)\r
             # S2 may be Platform or ModuleType\r
             if len(ItemList) > 2:\r
@@ -1843,18 +1850,18 @@ class DecParser(MetaFileParser):
                         EdkLogger.error("Parser", FORMAT_INVALID, 'Please use keyword "Private" as section tag modifier.',\r
                                         File=self.MetaFile, Line=self._LineIndex + 1, ExtraData=self._CurrentLine)\r
             else:\r
-                S2 = 'COMMON'\r
+                S2 = TAB_COMMON\r
             PrivateList.add(S2)\r
             if [S1, S2, self.DataType[self._SectionName]] not in self._Scope:\r
                 self._Scope.append([S1, S2, self.DataType[self._SectionName]])\r
 \r
         # 'COMMON' must not be used with specific ARCHs at the same section\r
-        if 'COMMON' in ArchList and len(ArchList) > 1:\r
+        if TAB_ARCH_COMMON in ArchList and len(ArchList) > 1:\r
             EdkLogger.error('Parser', FORMAT_INVALID, "'common' ARCH must not be used with specific ARCHs",\r
                             File=self.MetaFile, Line=self._LineIndex + 1, ExtraData=self._CurrentLine)\r
 \r
         # It is not permissible to mix section tags without the Private attribute with section tags with the Private attribute\r
-        if 'COMMON' in PrivateList and len(PrivateList) > 1:\r
+        if TAB_COMMON in PrivateList and len(PrivateList) > 1:\r
             EdkLogger.error('Parser', FORMAT_INVALID, "Can't mix section tags without the Private attribute with section tags with the Private attribute",\r
                             File=self.MetaFile, Line=self._LineIndex + 1, ExtraData=self._CurrentLine)\r
 \r