## @file\r
# This file is used to parse a xml file of .PKG file\r
#\r
-# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
#\r
-# This program and the accompanying materials are licensed and made available \r
-# under the terms and conditions of the BSD License which accompanies this \r
-# 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
DPLicense = DpHeader.GetLicense()[0][1]\r
else:\r
DPLicense = ''\r
- \r
+\r
CheckDict['Name'] = DpHeader.GetName()\r
CheckDict['GUID'] = DpHeader.GetGuid()\r
CheckDict['Version'] = DpHeader.GetVersion()\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
else:\r
XmlTreeLevel = ['DistributionPackage', 'DistributionHeader']\r
- CheckDict = CheckDict = {'DistributionHeader':'', }\r
+ CheckDict = CheckDict = {'DistributionHeader': '', }\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
#\r
ValidateMS(self.DistP.ModuleSurfaceArea[Key], ['DistributionPackage', 'ModuleSurfaceArea'])\r
\r
#\r
- # Check Each Tool \r
+ # Check Each Tool\r
#\r
if self.DistP.Tools:\r
XmlTreeLevel = ['DistributionPackage', 'Tools', 'Header']\r
- CheckDict = {'Name':self.DistP.Tools.GetName(), }\r
+ CheckDict = {'Name': self.DistP.Tools.GetName(), }\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
if not self.DistP.Tools.GetFileList():\r
XmlTreeLevel = ['DistributionPackage', 'Tools']\r
- CheckDict = {'FileName':None, }\r
+ CheckDict = {'FileName': None, }\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
for Item in self.DistP.Tools.GetFileList():\r
XmlTreeLevel = ['DistributionPackage', 'Tools']\r
- CheckDict = {'FileName':Item.GetURI(), }\r
+ CheckDict = {'FileName': Item.GetURI(), }\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
#\r
#\r
if self.DistP.MiscellaneousFiles:\r
XmlTreeLevel = ['DistributionPackage', 'MiscellaneousFiles', 'Header']\r
- CheckDict = {'Name':self.DistP.MiscellaneousFiles.GetName(), }\r
+ CheckDict = {'Name': self.DistP.MiscellaneousFiles.GetName(), }\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
if not self.DistP.MiscellaneousFiles.GetFileList():\r
XmlTreeLevel = ['DistributionPackage', 'MiscellaneousFiles']\r
- CheckDict = {'FileName':None, }\r
+ CheckDict = {'FileName': None, }\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
for Item in self.DistP.MiscellaneousFiles.GetFileList():\r
XmlTreeLevel = ['DistributionPackage', 'MiscellaneousFiles']\r
- CheckDict = {'FileName':Item.GetURI(), }\r
+ CheckDict = {'FileName': Item.GetURI(), }\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
#\r
#\r
for Item in self.DistP.UserExtensions:\r
XmlTreeLevel = ['DistributionPackage', 'UserExtensions']\r
- CheckDict = {'UserId':Item.GetUserID(), }\r
+ CheckDict = {'UserId': Item.GetUserID(), }\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
\r
def FromXml(self, Filename=None):\r
- if Filename != None:\r
+ if Filename is not None:\r
self.DistP = DistributionPackageClass()\r
#\r
# Load to XML\r
ModuleKey = (Module.GetGuid(), Module.GetVersion(), Module.GetName(), Module.GetModulePath())\r
self.DistP.ModuleSurfaceArea[ModuleKey] = Module\r
\r
- # \r
+ #\r
# Parse Tools\r
#\r
Tmp = MiscellaneousFileXml()\r
def ToXml(self, DistP):\r
if self.DistP:\r
pass\r
- if DistP != None:\r
+ if DistP is not None:\r
#\r
# Parse DistributionPackageHeader\r
#\r
Msa = ModuleSurfaceAreaXml()\r
DomModule = Msa.ToXml(Module)\r
Root.appendChild(DomModule)\r
- # \r
+ #\r
# Parse Tools\r
#\r
Tmp = MiscellaneousFileXml()\r
\r
#\r
# Remove SupModList="COMMON" or "common"\r
- # \r
+ #\r
XmlContent = \\r
re.sub(r'[\s\r\n]*SupModList[\s\r\n]*=[\s\r\n]*"[\s\r\n]*COMMON'\r
'[\s\r\n]*"', '', XmlContent)\r
# Check if any required item is missing in ModuleSurfaceArea\r
#\r
# @param Module: The ModuleSurfaceArea to be checked\r
-# @param XmlTreeLevel: The top level of Module \r
+# @param XmlTreeLevel: The top level of Module\r
#\r
def ValidateMS(Module, TopXmlTreeLevel):\r
ValidateMS1(Module, TopXmlTreeLevel)\r
# Check if any required item is missing in ModuleSurfaceArea\r
#\r
# @param Module: The ModuleSurfaceArea to be checked\r
-# @param XmlTreeLevel: The top level of Module \r
+# @param XmlTreeLevel: The top level of Module\r
#\r
def ValidateMS1(Module, TopXmlTreeLevel):\r
#\r
#\r
XmlTreeLevel = TopXmlTreeLevel + ['Guids']\r
for Item in Module.GetGuidList():\r
- if Item == None:\r
+ if Item is None:\r
CheckDict = {'GuidCName':''}\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
#\r
XmlTreeLevel = TopXmlTreeLevel + ['Protocols']\r
for Item in Module.GetProtocolList():\r
- if Item == None:\r
+ if Item is None:\r
CheckDict = {'Protocol':''}\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
#\r
XmlTreeLevel = TopXmlTreeLevel + ['PPIs']\r
for Item in Module.GetPpiList():\r
- if Item == None:\r
+ if Item is None:\r
CheckDict = {'Ppi':''}\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
#\r
XmlTreeLevel = TopXmlTreeLevel + ['PcdCoded']\r
for Item in Module.GetPcdList():\r
- if Item == None:\r
+ if Item is None:\r
CheckDict = {'PcdEntry':''}\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
#\r
XmlTreeLevel = TopXmlTreeLevel + ['Externs']\r
for Item in Module.GetExternList():\r
- if Item == None:\r
+ if Item is None:\r
CheckDict = {'Extern':''}\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
#\r
- # If SupArchList is used to identify different EntryPoint, UnloadImage, Constructor/Destructor elements and \r
+ # If SupArchList is used to identify different EntryPoint, UnloadImage, Constructor/Destructor elements and\r
# that SupArchList does not match ModuleSurfaceArea.ModuleProperties:SupArchList, the tool must exit gracefully,\r
- # informing the user that the EDK II Build system does not support different EntryPoint, UnloadImage, \r
- # Constructor or Destructor elements based on Architecture type. Two SupArchList attributes are considered \r
+ # informing the user that the EDK II Build system does not support different EntryPoint, UnloadImage,\r
+ # Constructor or Destructor elements based on Architecture type. Two SupArchList attributes are considered\r
# identical if it lists the same CPU architectures in any order.\r
#\r
for Item in Module.GetExternList():\r
XmlTreeLevel = TopXmlTreeLevel + ['MiscellaneousFiles']\r
for Item in Module.GetMiscFileList():\r
if not Item.GetFileList():\r
- CheckDict = {'Filename':'', }\r
+ CheckDict = {'Filename': '', }\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
for File in Item.GetFileList():\r
- CheckDict = {'Filename':File.GetURI(), }\r
+ CheckDict = {'Filename': File.GetURI(), }\r
\r
## ValidateMS2\r
#\r
# Check if any required item is missing in ModuleSurfaceArea\r
#\r
# @param Module: The ModuleSurfaceArea to be checked\r
-# @param XmlTreeLevel: The top level of Module \r
+# @param XmlTreeLevel: The top level of Module\r
#\r
def ValidateMS2(Module, TopXmlTreeLevel):\r
#\r
Logger.Error("UPT", FORMAT_INVALID, ERR_FILE_NAME_INVALIDE % Module.GetModulePath())\r
\r
#\r
- # Check ModuleProperties->BootMode \r
+ # Check ModuleProperties->BootMode\r
#\r
XmlTreeLevel = TopXmlTreeLevel + ['ModuleProperties'] + ['BootMode']\r
for Item in Module.GetBootModeList():\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
#\r
- # Check ModuleProperties->Event \r
+ # Check ModuleProperties->Event\r
#\r
XmlTreeLevel = TopXmlTreeLevel + ['ModuleProperties'] + ['Event']\r
for Item in Module.GetEventList():\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
#\r
- # Check ModuleProperties->Hob \r
+ # Check ModuleProperties->Hob\r
#\r
XmlTreeLevel = TopXmlTreeLevel + ['ModuleProperties'] + ['HOB']\r
for Item in Module.GetHobList():\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
#\r
- # The UDP Specification supports the module type of UEFI_RUNTIME_DRIVER, which is not present in the EDK II INF \r
- # File Specification v. 1.23, so UPT must perform the following translation that include the generation of a \r
+ # The UDP Specification supports the module type of UEFI_RUNTIME_DRIVER, which is not present in the EDK II INF\r
+ # File Specification v. 1.23, so UPT must perform the following translation that include the generation of a\r
# [Depex] section.\r
#\r
if Module.ModuleType == "UEFI_RUNTIME_DRIVER":\r
#\r
XmlTreeLevel = TopXmlTreeLevel + ['LibraryClassDefinitions']\r
for Item in Module.GetLibraryClassList():\r
- if Item == None:\r
+ if Item is None:\r
CheckDict = {'LibraryClass':''}\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
'Usage':Item.GetUsage()}\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
#\r
- # If the LibraryClass:SupModList is not "UNDEFINED" the LIBRARY_CLASS entry must have the list \r
+ # If the LibraryClass:SupModList is not "UNDEFINED" the LIBRARY_CLASS entry must have the list\r
# appended using the format:\r
# LIBRARY_CLASS = <ClassName> ["|" <Edk2ModuleTypeList>]\r
#\r
\r
\r
#\r
- # For Library modules (indicated by a LIBRARY_CLASS statement in the [Defines] section) \r
- # If the SupModList attribute of the CONSTRUCTOR or DESTRUCTOR element does not match the Supported Module \r
- # Types listed after "LIBRARY_CLASS = <Keyword> |", the tool should gracefully exit with an error message \r
- # stating that there is a conflict in the module types the CONSTRUCTOR/DESTRUCTOR is to be used with and \r
+ # For Library modules (indicated by a LIBRARY_CLASS statement in the [Defines] section)\r
+ # If the SupModList attribute of the CONSTRUCTOR or DESTRUCTOR element does not match the Supported Module\r
+ # Types listed after "LIBRARY_CLASS = <Keyword> |", the tool should gracefully exit with an error message\r
+ # stating that there is a conflict in the module types the CONSTRUCTOR/DESTRUCTOR is to be used with and\r
# the Module types this Library supports.\r
#\r
if IsLibraryModule:\r
RaiseError=True)\r
\r
#\r
- # If the module is not a library module, the MODULE_TYPE listed in the ModuleSurfaceArea.Header must match the \r
- # SupModList attribute. If these conditions cannot be met, the tool must exit gracefully, informing the user \r
+ # If the module is not a library module, the MODULE_TYPE listed in the ModuleSurfaceArea.Header must match the\r
+ # SupModList attribute. If these conditions cannot be met, the tool must exit gracefully, informing the user\r
# that the EDK II Build system does not currently support the features required by this Module.\r
- # \r
+ #\r
if not IsLibraryModule:\r
for Item in Module.GetExternList():\r
if hasattr(Item, 'SupModList') and len(Item.SupModList) > 0 and \\r
#\r
XmlTreeLevel = TopXmlTreeLevel + ['SourceFiles']\r
for Item in Module.GetSourceFileList():\r
- if Item == None:\r
+ if Item is None:\r
CheckDict = {'Filename':''}\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
# Check if any required item is missing in ModuleSurfaceArea\r
#\r
# @param Module: The ModuleSurfaceArea to be checked\r
-# @param XmlTreeLevel: The top level of Module \r
+# @param XmlTreeLevel: The top level of Module\r
#\r
def ValidateMS3(Module, TopXmlTreeLevel):\r
#\r
#\r
XmlTreeLevel = TopXmlTreeLevel + ['PackageDependencies']\r
for Item in Module.GetPackageDependencyList():\r
- if Item == None:\r
+ if Item is None:\r
CheckDict = {'Package':''}\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
# Check BinaryFiles -> BinaryFile\r
#\r
for Item in Module.GetBinaryFileList():\r
- if Item == None:\r
+ if Item is None:\r
XmlTreeLevel = TopXmlTreeLevel + ['BinaryFiles']\r
CheckDict = {'BinaryFile':''}\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
for AsBuilt in Item.GetAsBuiltList():\r
#\r
# Check LibInstance\r
- # \r
+ #\r
if len(AsBuilt.LibraryInstancesList) == 1 and not AsBuilt.LibraryInstancesList[0]:\r
CheckDict = {'GUID':''}\r
XmlTreeLevel = TopXmlTreeLevel + ['BinaryFiles', 'BinaryFile', 'AsBuilt', 'LibraryInstances']\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
- \r
+\r
for LibItem in AsBuilt.LibraryInstancesList:\r
CheckDict = {'Guid':LibItem.Guid,\r
'Version':LibItem.Version}\r
#\r
XmlTreeLevel = ['DistributionPackage', 'PackageSurfaceArea', 'ClonedFrom']\r
for Item in Package.GetClonedFromList():\r
- if Item == None:\r
+ if Item is None:\r
CheckDict = Sdict()\r
CheckDict['GUID'] = ''\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
#\r
XmlTreeLevel = ['DistributionPackage', 'PackageSurfaceArea', 'LibraryClassDeclarations']\r
for Item in Package.GetLibraryClassList():\r
- if Item == None:\r
+ if Item is None:\r
CheckDict = {'LibraryClass':''}\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
#\r
XmlTreeLevel = ['DistributionPackage', 'PackageSurfaceArea', 'IndustryStandardIncludes']\r
for Item in Package.GetStandardIncludeFileList():\r
- if Item == None:\r
+ if Item is None:\r
CheckDict = {'IndustryStandardHeader':''}\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
#\r
XmlTreeLevel = ['DistributionPackage', 'PackageSurfaceArea', 'PackageIncludes']\r
for Item in Package.GetPackageIncludeFileList():\r
- if Item == None:\r
+ if Item is None:\r
CheckDict = {'PackageHeader':''}\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
#\r
XmlTreeLevel = ['DistributionPackage', 'PackageSurfaceArea', 'GuidDeclarations']\r
for Item in Package.GetGuidList():\r
- if Item == None:\r
+ if Item is None:\r
CheckDict = {'Entry':''}\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
#\r
XmlTreeLevel = ['DistributionPackage', 'PackageSurfaceArea', 'ProtocolDeclarations']\r
for Item in Package.GetProtocolList():\r
- if Item == None:\r
+ if Item is None:\r
CheckDict = {'Entry':''}\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
#\r
XmlTreeLevel = ['DistributionPackage', 'PackageSurfaceArea', 'PpiDeclarations']\r
for Item in Package.GetPpiList():\r
- if Item == None:\r
+ if Item is None:\r
CheckDict = {'Entry':''}\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
#\r
XmlTreeLevel = ['DistributionPackage', 'PackageSurfaceArea', 'PcdDeclarations']\r
for Item in Package.GetPcdList():\r
- if Item == None:\r
+ if Item is None:\r
CheckDict = {'PcdEntry':''}\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
XmlTreeLevel = ['DistributionPackage', 'PackageSurfaceArea', 'MiscellaneousFiles']\r
for Item in Package.GetMiscFileList():\r
if not Item.GetFileList():\r
- CheckDict = {'Filename':'', }\r
+ CheckDict = {'Filename': '', }\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
for File in Item.GetFileList():\r
- CheckDict = {'Filename':File.GetURI(), }\r
+ CheckDict = {'Filename': File.GetURI(), }\r
IsRequiredItemListNull(CheckDict, XmlTreeLevel)\r
\r
## ValidatePackageSurfaceArea\r
#\r
# Check if any required item is missing in PackageSurfaceArea\r
#\r
-# @param Package: The PackageSurfaceArea to be checked \r
+# @param Package: The PackageSurfaceArea to be checked\r
#\r
def ValidatePackageSurfaceArea(Package):\r
ValidatePS1(Package)\r