]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Workspace/MetaFileParser.py
BaseTools: Fix one bug of nest !include parser
[mirror_edk2.git] / BaseTools / Source / Python / Workspace / MetaFileParser.py
index 64394026cbb5201e89342e21a2fd291d9e2c0084..a2ded0c845ae49bfd6e880ffc42c549592df29f7 100644 (file)
@@ -2,7 +2,7 @@
 # This file is used to parse meta files\r
 #\r
 # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r
-# (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
+# (C) Copyright 2015-2018 Hewlett Packard Enterprise Development LP<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -26,7 +26,7 @@ import Common.GlobalData as GlobalData
 \r
 from CommonDataClass.DataClass import *\r
 from Common.DataType import *\r
-from Common.String import *\r
+from Common.StringUtils import *\r
 from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClass, AnalyzePcdData, AnalyzeDscPcd, AnalyzePcdExpression, ParseFieldValue\r
 from Common.Expression import *\r
 from CommonDataClass.Exceptions import *\r
@@ -310,7 +310,7 @@ class MetaFileParser(object):
             if self._SectionName in self.DataType:\r
                 self._SectionType = self.DataType[self._SectionName]\r
                 # Check if the section name is valid\r
-                if self._SectionName not in SECTIONS_HAVE_ITEM_AFTER_ARCH and len(ItemList) > 3:\r
+                if self._SectionName not in SECTIONS_HAVE_ITEM_AFTER_ARCH_SET and len(ItemList) > 3:\r
                     EdkLogger.error("Parser", FORMAT_UNKNOWN_ERROR, "%s is not a valid section name" % Item,\r
                                     self.MetaFile, self._LineIndex + 1, self._CurrentLine)\r
             elif self._Version >= 0x00010005:\r
@@ -328,7 +328,7 @@ class MetaFileParser(object):
 \r
             # S2 may be Platform or ModuleType\r
             if len(ItemList) > 2:\r
-                if self._SectionName.upper() in SECTIONS_HAVE_ITEM_PCD:\r
+                if self._SectionName.upper() in SECTIONS_HAVE_ITEM_PCD_SET:\r
                     S2 = ItemList[2]\r
                 else:\r
                     S2 = ItemList[2].upper()\r
@@ -1551,10 +1551,21 @@ class DscParser(MetaFileParser):
 \r
             self.IncludedFiles.add (IncludedFile1)\r
 \r
+            # todo: rework the nested include checking logic\r
+            # Current nested include checking rely on dsc file order inside build.db.\r
+            # It is not reliable and will lead to build fail in some case.\r
+            #\r
+            # When project A and B include a common dsc file C.\r
+            # Build project A. It give dsc file A = ID 1 in build.db, and C ID = 2.\r
+            # Build project B. It give dsc file B ID = 3, and C ID still = 2.\r
+            # Then, we build project B fail, unless we clean build.db.\r
+            # In oldder BaseTools, the project B ID will still be 1,\r
+            # that's why it work before.\r
+\r
             # Does not allow lower level included file to include upper level included file\r
-            if Parser._From != Owner and int(Owner) > int (Parser._From):\r
-                EdkLogger.error('parser', FILE_ALREADY_EXIST, File=self._FileWithError,\r
-                    Line=self._LineIndex + 1, ExtraData="{0} is already included at a higher level.".format(IncludedFile1))\r
+            #if Parser._From != Owner and int(Owner) > int (Parser._From):\r
+            #   EdkLogger.error('parser', FILE_ALREADY_EXIST, File=self._FileWithError,\r
+            #       Line=self._LineIndex + 1, ExtraData="{0} is already included at a higher level.".format(IncludedFile1))\r
 \r
 \r
             # set the parser status with current status\r
@@ -1570,7 +1581,11 @@ class DscParser(MetaFileParser):
 \r
             # update current status with sub-parser's status\r
             self._SectionName = Parser._SectionName\r
-            self._SectionType = Parser._SectionType\r
+            if not self._InSubsection:\r
+                self._SectionType = Parser._SectionType\r
+            self._SubsectionType = Parser._SubsectionType\r
+            self._InSubsection = Parser._InSubsection\r
+\r
             self._Scope = Parser._Scope\r
             self._Enabled = Parser._Enabled\r
 \r