## @file\r
# This file is used to parse meta files\r
#\r
-# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2015, Hewlett Packard Enterprise Development, L.P.<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
from Common.LongFilePathSupport import OpenLongFilePath as open\r
\r
from MetaFileTable import MetaFileStorage\r
+from MetaFileCommentParser import CheckInfComment\r
\r
## A decorator used to parse macro definition\r
def ParseMacro(Parser):\r
File=self.MetaFile,\r
Line=self._LineIndex + 1\r
)\r
-\r
+ def GetValidExpression(self, TokenSpaceGuid, PcdCName):\r
+ return self._Table.GetValidExpression(TokenSpaceGuid, PcdCName)\r
def _GetMacros(self):\r
Macros = {}\r
Macros.update(self._FileLocalMacros)\r
continue\r
if Comment:\r
Comments.append((Comment, Index + 1))\r
+ if GlobalData.gOptions and GlobalData.gOptions.CheckUsage:\r
+ CheckInfComment(self._SectionType, Comments, str(self.MetaFile), Index + 1, self._ValueList)\r
#\r
# Model, Value1, Value2, Value3, Arch, Platform, BelongsToItem=-1,\r
# LineBegin=-1, ColumnBegin=-1, LineEnd=-1, ColumnEnd=-1, Enabled=-1\r
"PLATFORM_VERSION",\r
"SKUID_IDENTIFIER",\r
"PCD_INFO_GENERATION",\r
+ "PCD_VAR_CHECK_GENERATION",\r
"SUPPORTED_ARCHITECTURES",\r
"BUILD_TARGETS",\r
"OUTPUT_DIRECTORY",\r
"FIX_LOAD_TOP_MEMORY_ADDRESS"\r
]\r
\r
+ SubSectionDefineKeywords = [\r
+ "FILE_GUID"\r
+ ]\r
+\r
SymbolPattern = ValueExpression.SymbolPattern\r
\r
## Constructor of DscParser\r
File=self.MetaFile, Line=self._LineIndex + 1,\r
ExtraData=self._CurrentLine)\r
self._DirectiveStack.append((ItemType, self._LineIndex + 1, self._CurrentLine))\r
- elif self._From > 0:\r
- EdkLogger.error('Parser', FORMAT_INVALID,\r
- "No '!include' allowed in included file",\r
- ExtraData=self._CurrentLine, File=self.MetaFile,\r
- Line=self._LineIndex + 1)\r
\r
#\r
# Model, Value1, Value2, Value3, Arch, ModuleType, BelongsToItem=-1, BelongsToFile=-1,\r
if not self._ValueList[2]:\r
EdkLogger.error('Parser', FORMAT_INVALID, "No value specified",\r
ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)\r
- if not self._ValueList[1] in self.DefineKeywords:\r
+ if (not self._ValueList[1] in self.DefineKeywords and\r
+ (self._InSubsection and self._ValueList[1] not in self.SubSectionDefineKeywords)):\r
EdkLogger.error('Parser', FORMAT_INVALID,\r
"Unknown keyword found: %s. "\r
"If this is a macro you must "\r
"add it as a DEFINE in the DSC" % self._ValueList[1],\r
ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)\r
- self._Defines[self._ValueList[1]] = self._ValueList[2]\r
+ if not self._InSubsection:\r
+ self._Defines[self._ValueList[1]] = self._ValueList[2]\r
self._ItemType = self.DataType[TAB_DSC_DEFINES.upper()]\r
\r
@ParseMacro\r
self.__RetrievePcdValue()\r
self._Content = self._RawTable.GetAll()\r
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
LineStart, ColStart, LineEnd, ColEnd, Enabled = self._Content[self._ContentIndex]\r
self._LineIndex = LineStart - 1\r
self._ValueList = [V1, V2, V3]\r
\r
+ if Owner > 0 and Owner in self._IdMapping:\r
+ self._InSubsection = True\r
+ else:\r
+ self._InSubsection = False\r
try:\r
Processer[self._ItemType]()\r
except EvaluationException, Excpt:\r
self._SubsectionType = MODEL_UNKNOWN\r
\r
def __RetrievePcdValue(self):\r
- Records = self._RawTable.Query(MODEL_PCD_FEATURE_FLAG, BelongsToItem= -1.0)\r
- for TokenSpaceGuid, PcdName, Value, Dummy2, Dummy3, ID, Line in Records:\r
- Name = TokenSpaceGuid + '.' + PcdName\r
- ValList, Valid, Index = AnalyzeDscPcd(Value, MODEL_PCD_FEATURE_FLAG)\r
- self._Symbols[Name] = ValList[Index]\r
-\r
- Records = self._RawTable.Query(MODEL_PCD_FIXED_AT_BUILD, BelongsToItem= -1.0)\r
- for TokenSpaceGuid, PcdName, Value, Dummy2, Dummy3, ID, Line in Records:\r
- Name = TokenSpaceGuid + '.' + PcdName\r
- ValList, Valid, Index = AnalyzeDscPcd(Value, MODEL_PCD_FIXED_AT_BUILD)\r
- self._Symbols[Name] = ValList[Index]\r
-\r
Content = open(str(self.MetaFile), 'r').readlines()\r
GlobalData.gPlatformOtherPcds['DSCFILE'] = str(self.MetaFile)\r
for PcdType in (MODEL_PCD_PATCHABLE_IN_MODULE, MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_HII,\r
\r
Type, Name, Value = self._ValueList\r
Value = ReplaceMacro(Value, self._Macros, False)\r
+ #\r
+ # If it is <Defines>, return\r
+ #\r
+ if self._InSubsection:\r
+ self._ValueList = [Type, Name, Value]\r
+ return\r
+\r
if self._ItemType == MODEL_META_DATA_DEFINE:\r
if self._SectionType == MODEL_META_DATA_HEADER:\r
self._FileLocalMacros[Name] = Value\r
Parser = DscParser(IncludedFile1, self._FileType, IncludedFileTable,\r
Owner=Owner, From=Owner)\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
+\r
+\r
# set the parser status with current status\r
Parser._SectionName = self._SectionName\r
Parser._SectionType = self._SectionType\r
if ValList[Index] == 'False':\r
ValList[Index] = '0'\r
\r
- GlobalData.gPlatformPcds[TAB_SPLIT.join(self._ValueList[0:2])] = PcdValue\r
+ if (not self._DirectiveEvalStack) or (False not in self._DirectiveEvalStack):\r
+ GlobalData.gPlatformPcds[TAB_SPLIT.join(self._ValueList[0:2])] = PcdValue\r
+ self._Symbols[TAB_SPLIT.join(self._ValueList[0:2])] = PcdValue\r
self._ValueList[2] = '|'.join(ValList)\r
\r
def __ProcessComponent(self):\r