# 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
\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
from Common.LongFilePathSupport import OpenLongFilePath as open\r
-\r
+from collections import defaultdict\r
from MetaFileTable import MetaFileStorage\r
from MetaFileCommentParser import CheckInfComment\r
\r
self._FileDir = self.MetaFile.Dir\r
self._Defines = {}\r
self._FileLocalMacros = {}\r
- self._SectionsMacroDict = {}\r
+ self._SectionsMacroDict = defaultdict(dict)\r
\r
# for recursive parsing\r
self._Owner = [Owner]\r
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
\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
def _ConstructSectionMacroDict(self, Name, Value):\r
ScopeKey = [(Scope[0], Scope[1],Scope[2]) for Scope in self._Scope]\r
ScopeKey = tuple(ScopeKey)\r
- SectionDictKey = self._SectionType, ScopeKey\r
#\r
# DecParser SectionType is a list, will contain more than one item only in Pcd Section\r
# As Pcd section macro usage is not alllowed, so here it is safe\r
#\r
if type(self) == DecParser:\r
SectionDictKey = self._SectionType[0], ScopeKey\r
- if SectionDictKey not in self._SectionsMacroDict:\r
- self._SectionsMacroDict[SectionDictKey] = {}\r
- SectionLocalMacros = self._SectionsMacroDict[SectionDictKey]\r
- SectionLocalMacros[Name] = Value\r
+ else:\r
+ SectionDictKey = self._SectionType, ScopeKey\r
+\r
+ self._SectionsMacroDict[SectionDictKey][Name] = Value\r
\r
## Get section Macros that are applicable to current line, which may come from other sections \r
## that share the same name while scope is wider\r
self._SubsectionType = MODEL_UNKNOWN\r
self._SubsectionName = ''\r
self._Owner[-1] = -1\r
- OwnerId = {}\r
+ OwnerId.clear()\r
continue\r
# subsection header\r
elif Line[0] == TAB_OPTION_START and Line[-1] == TAB_OPTION_END:\r
self._DirectiveEvalStack = []\r
self._FileWithError = self.MetaFile\r
self._FileLocalMacros = {}\r
- self._SectionsMacroDict = {}\r
+ self._SectionsMacroDict.clear()\r
GlobalData.gPlatformDefines = {}\r
\r
# Get all macro and PCD which has straitforward value\r
\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
\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