#\r
# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<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
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
#\r
\r
##\r
self.MetaFile = FilePath\r
self._FileDir = self.MetaFile.Dir\r
self._Defines = {}\r
+ self._Packages = []\r
self._FileLocalMacros = {}\r
self._SectionsMacroDict = defaultdict(dict)\r
\r
S1 = ItemList[1].upper()\r
else:\r
S1 = TAB_ARCH_COMMON\r
+ S1 = ReplaceMacro(S1, self._Macros)\r
ArchList.add(S1)\r
\r
# S2 may be Platform or ModuleType\r
# If the section information is needed later, it should be stored in database\r
self._ValueList[0] = self._SectionName\r
\r
+ ## [packages] section parser\r
+ @ParseMacro\r
+ def _PackageParser(self):\r
+ self._CurrentLine = CleanString(self._CurrentLine)\r
+ self._Packages.append(self._CurrentLine)\r
+ self._ValueList[0] = self._CurrentLine\r
+\r
## [defines] section parser\r
@ParseMacro\r
def _DefineParser(self):\r
NmakeLine = ''\r
Content = ''\r
try:\r
- Content = open(str(self.MetaFile), 'r').readlines()\r
+ with open(str(self.MetaFile), 'r') as File:\r
+ Content = File.readlines()\r
except:\r
EdkLogger.error("Parser", FILE_READ_FAILURE, ExtraData=self.MetaFile)\r
\r
@ParseMacro\r
def _SourceFileParser(self):\r
TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT)\r
+ # Let TokenList[2] be TagName|ToolCode|FeatureFlag\r
+ if len(TokenList) > 3:\r
+ for extraToken in range(3, len(TokenList)):\r
+ TokenList[2] = TokenList[2] + '|' + TokenList[extraToken]\r
self._ValueList[0:len(TokenList)] = TokenList\r
Macros = self._Macros\r
# For Acpi tables, remove macro like ' TABLE_NAME=Sata1'\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
+ TAB_PACKAGES.upper() : MODEL_META_DATA_PACKAGE,\r
TAB_PCDS_FIXED_AT_BUILD_NULL.upper() : MODEL_PCD_FIXED_AT_BUILD,\r
TAB_PCDS_PATCHABLE_IN_MODULE_NULL.upper() : MODEL_PCD_PATCHABLE_IN_MODULE,\r
TAB_PCDS_FEATURE_FLAG_NULL.upper() : MODEL_PCD_FEATURE_FLAG,\r
TAB_PCDS_DYNAMIC_EX_HII_NULL.upper() : MODEL_PCD_DYNAMIC_EX_HII,\r
TAB_PCDS_DYNAMIC_EX_VPD_NULL.upper() : MODEL_PCD_DYNAMIC_EX_VPD,\r
TAB_COMPONENTS.upper() : MODEL_META_DATA_COMPONENT,\r
- TAB_COMPONENTS_SOURCE_OVERRIDE_PATH.upper() : MODEL_META_DATA_COMPONENT_SOURCE_OVERRIDE_PATH,\r
TAB_DSC_DEFINES.upper() : MODEL_META_DATA_HEADER,\r
TAB_DSC_DEFINES_DEFINE : MODEL_META_DATA_DEFINE,\r
TAB_DSC_DEFINES_EDKGLOBAL : MODEL_META_DATA_GLOBAL_DEFINE,\r
def Start(self):\r
Content = ''\r
try:\r
- Content = open(str(self.MetaFile), 'r').readlines()\r
+ with open(str(self.MetaFile), 'r') as File:\r
+ Content = File.readlines()\r
except:\r
EdkLogger.error("Parser", FILE_READ_FAILURE, ExtraData=self.MetaFile)\r
\r
\r
self._ValueList[0:len(TokenList)] = TokenList\r
\r
- def _CompponentSourceOverridePathParser(self):\r
- self._ValueList[0] = self._CurrentLine\r
\r
## [BuildOptions] section parser\r
@ParseMacro\r
MODEL_META_DATA_DEFINE : self.__ProcessDefine,\r
MODEL_META_DATA_GLOBAL_DEFINE : self.__ProcessDefine,\r
MODEL_META_DATA_INCLUDE : self.__ProcessDirective,\r
+ MODEL_META_DATA_PACKAGE : self.__ProcessPackages,\r
MODEL_META_DATA_CONDITIONAL_STATEMENT_IF : self.__ProcessDirective,\r
MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE : self.__ProcessDirective,\r
MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF : self.__ProcessDirective,\r
MODEL_PCD_DYNAMIC_EX_HII : self.__ProcessPcd,\r
MODEL_PCD_DYNAMIC_EX_VPD : self.__ProcessPcd,\r
MODEL_META_DATA_COMPONENT : self.__ProcessComponent,\r
- MODEL_META_DATA_COMPONENT_SOURCE_OVERRIDE_PATH : self.__ProcessSourceOverridePath,\r
MODEL_META_DATA_BUILD_OPTION : self.__ProcessBuildOption,\r
MODEL_UNKNOWN : self._Skip,\r
MODEL_META_DATA_USER_EXTENSION : self._SkipUserExtension,\r
self._SubsectionType = MODEL_UNKNOWN\r
\r
def __RetrievePcdValue(self):\r
- Content = open(str(self.MetaFile), 'r').readlines()\r
+ try:\r
+ with open(str(self.MetaFile), 'r') as File:\r
+ Content = File.readlines()\r
+ except:\r
+ EdkLogger.error("Parser", FILE_READ_FAILURE, ExtraData=self.MetaFile)\r
+\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
MODEL_PCD_DYNAMIC_VPD, MODEL_PCD_DYNAMIC_EX_DEFAULT, MODEL_PCD_DYNAMIC_EX_HII,\r
# First search the include file under the same directory as DSC file\r
#\r
IncludedFile1 = PathClass(IncludedFile, self.MetaFile.Dir)\r
- ErrorCode, ErrorInfo1 = IncludedFile1.Validate()\r
- if ErrorCode != 0:\r
- #\r
- # Also search file under the WORKSPACE directory\r
- #\r
- IncludedFile1 = PathClass(IncludedFile, GlobalData.gWorkspace)\r
- ErrorCode, ErrorInfo2 = IncludedFile1.Validate()\r
+ if self._Enabled:\r
+ ErrorCode, ErrorInfo1 = IncludedFile1.Validate()\r
if ErrorCode != 0:\r
- EdkLogger.error('parser', ErrorCode, File=self._FileWithError,\r
- Line=self._LineIndex + 1, ExtraData=ErrorInfo1 + "\n" + ErrorInfo2)\r
-\r
- self._FileWithError = IncludedFile1\r
+ #\r
+ # Also search file under the WORKSPACE directory\r
+ #\r
+ IncludedFile1 = PathClass(IncludedFile, GlobalData.gWorkspace)\r
+ ErrorCode, ErrorInfo2 = IncludedFile1.Validate()\r
+ if ErrorCode != 0:\r
+ EdkLogger.error('parser', ErrorCode, File=self._FileWithError,\r
+ Line=self._LineIndex + 1, ExtraData=ErrorInfo1 + "\n" + ErrorInfo2)\r
+\r
+ self._FileWithError = IncludedFile1\r
+\r
+ FromItem = self._Content[self._ContentIndex - 1][0]\r
+ if self._InSubsection:\r
+ Owner = self._Content[self._ContentIndex - 1][8]\r
+ else:\r
+ Owner = self._Content[self._ContentIndex - 1][0]\r
+ IncludedFileTable = MetaFileStorage(self._RawTable.DB, IncludedFile1, MODEL_FILE_DSC, False, FromItem=FromItem)\r
+ Parser = DscParser(IncludedFile1, self._FileType, self._Arch, IncludedFileTable,\r
+ Owner=Owner, From=FromItem)\r
+\r
+ self.IncludedFiles.add (IncludedFile1)\r
+\r
+ # set the parser status with current status\r
+ Parser._SectionName = self._SectionName\r
+ Parser._SubsectionType = self._SubsectionType\r
+ Parser._InSubsection = self._InSubsection\r
+ Parser._SectionType = self._SectionType\r
+ Parser._Scope = self._Scope\r
+ Parser._Enabled = self._Enabled\r
+ # Parse the included file\r
+ Parser.StartParse()\r
+ # Insert all records in the table for the included file into dsc file table\r
+ Records = IncludedFileTable.GetAll()\r
+ if Records:\r
+ self._Content[self._ContentIndex:self._ContentIndex] = Records\r
+ self._Content.pop(self._ContentIndex - 1)\r
+ self._ValueList = None\r
+ self._ContentIndex -= 1\r
\r
- FromItem = self._Content[self._ContentIndex - 1][0]\r
- if self._InSubsection:\r
- Owner = self._Content[self._ContentIndex - 1][8]\r
- else:\r
- Owner = self._Content[self._ContentIndex - 1][0]\r
- IncludedFileTable = MetaFileStorage(self._RawTable.DB, IncludedFile1, MODEL_FILE_DSC, False, FromItem=FromItem)\r
- Parser = DscParser(IncludedFile1, self._FileType, self._Arch, IncludedFileTable,\r
- Owner=Owner, From=FromItem)\r
-\r
- self.IncludedFiles.add (IncludedFile1)\r
-\r
- # set the parser status with current status\r
- Parser._SectionName = self._SectionName\r
- Parser._SubsectionType = self._SubsectionType\r
- Parser._InSubsection = self._InSubsection\r
- Parser._SectionType = self._SectionType\r
- Parser._Scope = self._Scope\r
- Parser._Enabled = self._Enabled\r
- # Parse the included file\r
- Parser.StartParse()\r
- # Insert all records in the table for the included file into dsc file table\r
- Records = IncludedFileTable.GetAll()\r
- if Records:\r
- self._Content[self._ContentIndex:self._ContentIndex] = Records\r
- self._Content.pop(self._ContentIndex - 1)\r
- self._ValueList = None\r
- self._ContentIndex -= 1\r
+ def __ProcessPackages(self):\r
+ self._ValueList[0] = ReplaceMacro(self._ValueList[0], self._Macros)\r
\r
def __ProcessSkuId(self):\r
self._ValueList = [ReplaceMacro(Value, self._Macros, RaiseError=True)\r
def __ProcessComponent(self):\r
self._ValueList[0] = ReplaceMacro(self._ValueList[0], self._Macros)\r
\r
- def __ProcessSourceOverridePath(self):\r
- self._ValueList[0] = ReplaceMacro(self._ValueList[0], self._Macros)\r
-\r
def __ProcessBuildOption(self):\r
self._ValueList = [ReplaceMacro(Value, self._Macros, RaiseError=False)\r
for Value in self._ValueList]\r
MODEL_PCD_DYNAMIC_EX_HII : _PcdParser,\r
MODEL_PCD_DYNAMIC_EX_VPD : _PcdParser,\r
MODEL_META_DATA_COMPONENT : _ComponentParser,\r
- MODEL_META_DATA_COMPONENT_SOURCE_OVERRIDE_PATH : _CompponentSourceOverridePathParser,\r
MODEL_META_DATA_BUILD_OPTION : _BuildOptionParser,\r
MODEL_UNKNOWN : MetaFileParser._Skip,\r
+ MODEL_META_DATA_PACKAGE : MetaFileParser._PackageParser,\r
MODEL_META_DATA_USER_EXTENSION : MetaFileParser._SkipUserExtension,\r
MODEL_META_DATA_SECTION_HEADER : MetaFileParser._SectionHeaderParser,\r
MODEL_META_DATA_SUBSECTION_HEADER : _SubsectionHeaderParser,\r
def Start(self):\r
Content = ''\r
try:\r
- Content = open(str(self.MetaFile), 'r').readlines()\r
+ with open(str(self.MetaFile), 'r') as File:\r
+ Content = File.readlines()\r
except:\r
EdkLogger.error("Parser", FILE_READ_FAILURE, ExtraData=self.MetaFile)\r
\r