This patch is going to:

1.	Add a recovery mode for UPT failure
2.	Add UNI file support
3.	Add binary file header support
4.	Add support for PCD error message
5.	Add support for replace
6.	Format generated INF/DEC files
7.	Update dependency check
8.	Other minor fixes


Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hess Chen <hesheng.chen@intel.com>
Reviewed-by: Gao, Liming <liming.gao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15896 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Hess Chen
2014-08-26 05:58:02 +00:00
committed by hchen30
parent f0aa06e385
commit 421ccda307
56 changed files with 5945 additions and 1710 deletions

View File

@@ -1,7 +1,7 @@
## @file
# This file is used to parse a PCD file of .PKG file
#
# Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials are licensed and made available
# under the terms and conditions of the BSD License which accompanies this
@@ -31,6 +31,8 @@ from Library.Xml.XmlRoutines import XmlAttribute
from Library.Xml.XmlRoutines import XmlNode
from Library.Xml.XmlRoutines import XmlList
from Library.Xml.XmlRoutines import CreateXmlElement
from Library.UniClassObject import ConvertSpecialUnicodes
from Library.UniClassObject import GetLanguageCode1766
from Object.POM.CommonObject import FileObject
from Object.POM.CommonObject import MiscFileObject
from Object.POM.CommonObject import UserExtensionObject
@@ -40,7 +42,6 @@ from Object.POM.CommonObject import FileNameObject
from Object.POM.ModuleObject import ModuleObject
from Xml.XmlParserMisc import IsRequiredItemListNull
from Xml.XmlParserMisc import GetHelpTextList
import Library.DataType as DataType
##
@@ -54,14 +55,11 @@ class ClonedFromXml(object):
def FromXml(self, Item, Key):
self.GUID = XmlElement(Item, '%s/GUID' % Key)
self.Version = XmlAttribute(XmlNode(Item, '%s/GUID' % Key), 'Version')
if self.GUID == '' and self.Version == '':
return None
ClonedFrom = ClonedRecordObject()
ClonedFrom.SetPackageGuid(self.GUID)
ClonedFrom.SetPackageVersion(self.Version)
return ClonedFrom
def ToXml(self, ClonedFrom, Key):
@@ -72,7 +70,6 @@ class ClonedFromXml(object):
AttributeList = []
NodeList = [Element1]
Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)
return Root
def __str__(self):
@@ -99,7 +96,6 @@ class CommonDefinesXml(object):
[Mod for Mod in GetSplitValueList(XmlAttribute(Item, 'SupModList'), DataType.TAB_SPACE_SPLIT) if Mod]
self.FeatureFlag = ConvertNOTEQToNE(XmlAttribute(Item, 'FeatureFlag'))
def ToXml(self):
pass
@@ -107,7 +103,27 @@ class CommonDefinesXml(object):
return "Usage = %s SupArchList = %s SupModList = %s FeatureFlag = %s" \
% (self.Usage, self.SupArchList, self.SupModList, self.FeatureFlag)
##
# PromptXml
#
class PromptXml(object):
def __init__(self):
self.Prompt = ''
self.Lang = ''
def FromXml(self, Item, Key):
if Key:
pass
self.Prompt = XmlElement2(Item, 'Prompt')
self.Lang = XmlAttribute(Item, 'Lang')
def ToXml(self, Prompt, Key='Prompt'):
if self.Prompt:
pass
return CreateXmlElement('%s' % Key, Prompt.GetString(), [], [['Lang', Prompt.GetLang()]])
def __str__(self):
return "Prompt = %s Lang = %s" % (self.Prompt, self.Lang)
##
# HelpTextXml
#
@@ -138,10 +154,10 @@ class HeaderXml(object):
self.BaseName = ''
self.GUID = ''
self.Version = ''
self.Copyright = ''
self.License = ''
self.Abstract = ''
self.Description = ''
self.CopyrightList = []
self.LicenseList = []
self.AbstractList = []
self.DescriptionList = []
def FromXml(self, Item, Key, IsRequiredCheck=False, IsStandAlongModule=False):
if not Item and IsRequiredCheck:
@@ -156,21 +172,28 @@ class HeaderXml(object):
self.BaseName = XmlAttribute(XmlNode(Item, '%s/Name' % Key), 'BaseName')
self.GUID = XmlElement(Item, '%s/GUID' % Key)
self.Version = XmlAttribute(XmlNode(Item, '%s/GUID' % Key), 'Version')
self.Copyright = XmlElement(Item, '%s/Copyright' % Key)
self.License = XmlElement(Item, '%s/License' % Key)
self.Abstract = XmlElement(Item, '%s/Abstract' % Key)
self.Description = XmlElement(Item, '%s/Description' % Key)
for SubItem in XmlList(Item, '%s/Abstract' % Key):
HeaderAbstractLang = XmlAttribute(SubItem, 'Lang')
self.AbstractList.append((HeaderAbstractLang, XmlElement(SubItem, '%s/Abstract' % Key)))
for SubItem in XmlList(Item, '%s/Description' % Key):
HeaderDescriptionLang = XmlAttribute(SubItem, 'Lang')
self.DescriptionList.append((HeaderDescriptionLang, XmlElement(SubItem, '%s/Description' % Key)))
for SubItem in XmlList(Item, '%s/Copyright' % Key):
HeaderCopyrightLang = XmlAttribute(SubItem, 'Lang')
self.CopyrightList.append((HeaderCopyrightLang, XmlElement(SubItem, '%s/Copyright' % Key)))
for SubItem in XmlList(Item, '%s/License' % Key):
HeaderLicenseLang = XmlAttribute(SubItem, 'Lang')
self.LicenseList.append((HeaderLicenseLang, XmlElement(SubItem, '%s/License' % Key)))
ModuleHeader = ModuleObject()
ModuleHeader.SetName(self.Name)
ModuleHeader.SetBaseName(self.BaseName)
ModuleHeader.SetGuid(self.GUID)
ModuleHeader.SetVersion(self.Version)
ModuleHeader.SetCopyright(self.Copyright)
ModuleHeader.SetLicense(self.License)
ModuleHeader.SetAbstract(self.Abstract)
ModuleHeader.SetDescription(self.Description)
ModuleHeader.SetCopyright(self.CopyrightList)
ModuleHeader.SetLicense(self.LicenseList)
ModuleHeader.SetAbstract(self.AbstractList)
ModuleHeader.SetDescription(self.DescriptionList)
return ModuleHeader
def ToXml(self, Header, Key):
@@ -178,23 +201,51 @@ class HeaderXml(object):
pass
Element1 = CreateXmlElement('Name', Header.GetName(), [], [['BaseName', Header.GetBaseName()]])
Element2 = CreateXmlElement('GUID', Header.GetGuid(), [], [['Version', Header.GetVersion()]])
AttributeList = []
NodeList = [Element1,
Element2,
['Copyright', Header.GetCopyright()],
['License', Header.GetLicense()],
['Abstract', Header.GetAbstract()],
['Description', Header.GetDescription()],
]
Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)
UNIInfAbstractList = []
UNIInfDescriptionList = []
# Get Abstract and Description from Uni File
# if the Uni File exists
if Header.UniFileClassObject is not None:
UniStrDict = Header.UniFileClassObject.OrderedStringList
for Lang in UniStrDict:
for StringDefClassObject in UniStrDict[Lang]:
if not StringDefClassObject.StringValue:
continue
if StringDefClassObject.StringName == DataType.TAB_INF_ABSTRACT:
UNIInfAbstractList.append((GetLanguageCode1766(Lang),
ConvertSpecialUnicodes(StringDefClassObject.StringValue)))
if StringDefClassObject.StringName == DataType.TAB_INF_DESCRIPTION:
UNIInfDescriptionList.append((GetLanguageCode1766(Lang),
ConvertSpecialUnicodes(StringDefClassObject.StringValue)))
# Get Abstract and Description from INF File Header
for (Lang, Value) in Header.GetCopyright():
if Value:
NodeList.append(CreateXmlElement('Copyright', Value, [], []))
for (Lang, Value) in Header.GetLicense():
if Value:
NodeList.append(CreateXmlElement('License', Value, [], []))
for (Lang, Value) in Header.GetAbstract() + UNIInfAbstractList:
if Value:
NodeList.append(CreateXmlElement('Abstract', Value, [], [['Lang', Lang]]))
for (Lang, Value) in Header.GetDescription() + UNIInfDescriptionList:
if Value:
NodeList.append(CreateXmlElement('Description', Value, [], [['Lang', Lang]]))
AttributeList = []
Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)
return Root
def __str__(self):
return "Name = %s BaseName = %s GUID = %s Version = %s Copyright = %s \
License = %s Abstract = %s Description = %s" % \
(self.Name, self.BaseName, self.GUID, self.Version, self.Copyright, \
self.License, self.Abstract, self.Description)
(self.Name, self.BaseName, self.GUID, self.Version, self.CopyrightList, \
self.LicenseList, self.AbstractList, self.DescriptionList)
##
# DistributionPackageHeaderXml
#
@@ -218,13 +269,11 @@ class DistributionPackageHeaderXml(object):
self.Signature = XmlElement(Item, '%s/Signature' % Key)
self.XmlSpecification = XmlElement(Item, '%s/XmlSpecification' % Key)
self.Header.FromXml(Item, Key)
DistributionPackageHeader = DistributionPackageHeaderObject()
if self.ReadOnly.upper() == 'TRUE':
DistributionPackageHeader.ReadOnly = True
elif self.ReadOnly.upper() == 'FALSE':
DistributionPackageHeader.ReadOnly = False
if self.RePackage.upper() == 'TRUE':
DistributionPackageHeader.RePackage = True
elif self.RePackage.upper() == 'FALSE':
@@ -233,16 +282,14 @@ class DistributionPackageHeaderXml(object):
DistributionPackageHeader.Date = self.Date
DistributionPackageHeader.Signature = self.Signature
DistributionPackageHeader.XmlSpecification = self.XmlSpecification
DistributionPackageHeader.SetName(self.Header.Name)
DistributionPackageHeader.SetBaseName(self.Header.BaseName)
DistributionPackageHeader.SetGuid(self.Header.GUID)
DistributionPackageHeader.SetVersion(self.Header.Version)
DistributionPackageHeader.SetCopyright(self.Header.Copyright)
DistributionPackageHeader.SetLicense(self.Header.License)
DistributionPackageHeader.SetAbstract(self.Header.Abstract)
DistributionPackageHeader.SetDescription(self.Header.Description)
DistributionPackageHeader.SetCopyright(self.Header.CopyrightList)
DistributionPackageHeader.SetLicense(self.Header.LicenseList)
DistributionPackageHeader.SetAbstract(self.Header.AbstractList)
DistributionPackageHeader.SetDescription(self.Header.DescriptionList)
return DistributionPackageHeader
def ToXml(self, DistributionPackageHeader, Key):
@@ -261,22 +308,35 @@ class DistributionPackageHeaderXml(object):
AttributeList.append(['ReadOnly', str(DistributionPackageHeader.ReadOnly).lower()])
if DistributionPackageHeader.RePackage != '':
AttributeList.append(['RePackage', str(DistributionPackageHeader.RePackage).lower()])
if DistributionPackageHeader.GetAbstract():
DPAbstract = DistributionPackageHeader.GetAbstract()[0][1]
else:
DPAbstract = ''
if DistributionPackageHeader.GetDescription():
DPDescription = DistributionPackageHeader.GetDescription()[0][1]
else:
DPDescription = ''
if DistributionPackageHeader.GetCopyright():
DPCopyright = DistributionPackageHeader.GetCopyright()[0][1]
else:
DPCopyright = ''
if DistributionPackageHeader.GetLicense():
DPLicense = DistributionPackageHeader.GetLicense()[0][1]
else:
DPLicense = ''
NodeList = [Element1,
Element2,
['Vendor', DistributionPackageHeader.Vendor],
['Date', DistributionPackageHeader.Date],
['Copyright', DistributionPackageHeader.GetCopyright()],
['License', DistributionPackageHeader.GetLicense()],
['Abstract', DistributionPackageHeader.GetAbstract()],
['Description', \
DistributionPackageHeader.GetDescription()],
['Copyright', DPCopyright],
['License', DPLicense],
['Abstract', DPAbstract],
['Description', DPDescription],
['Signature', DistributionPackageHeader.Signature],
['XmlSpecification', \
DistributionPackageHeader.XmlSpecification],
]
Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)
return Root
def __str__(self):
@@ -299,36 +359,63 @@ class PackageHeaderXml(object):
IsRequiredItemListNull(CheckDict, XmlTreeLevel)
self.PackagePath = XmlElement(Item, '%s/PackagePath' % Key)
self.Header.FromXml(Item, Key)
PackageObject2.SetName(self.Header.Name)
PackageObject2.SetBaseName(self.Header.BaseName)
PackageObject2.SetGuid(self.Header.GUID)
PackageObject2.SetVersion(self.Header.Version)
PackageObject2.SetCopyright(self.Header.Copyright)
PackageObject2.SetLicense(self.Header.License)
PackageObject2.SetAbstract(self.Header.Abstract)
PackageObject2.SetDescription(self.Header.Description)
PackageObject2.SetCopyright(self.Header.CopyrightList)
PackageObject2.SetLicense(self.Header.LicenseList)
PackageObject2.SetAbstract(self.Header.AbstractList)
PackageObject2.SetDescription(self.Header.DescriptionList)
PackageObject2.SetPackagePath(self.PackagePath)
def ToXml(self, PackageObject2, Key):
if self.PackagePath:
pass
Element1 = \
CreateXmlElement('Name', PackageObject2.GetName(), [], \
Element1 = CreateXmlElement('Name', PackageObject2.GetName(), [], \
[['BaseName', PackageObject2.GetBaseName()]])
Element2 = CreateXmlElement('GUID', PackageObject2.GetGuid(), [], \
[['Version', PackageObject2.GetVersion()]])
AttributeList = []
NodeList = [Element1,
Element2,
['Copyright', PackageObject2.GetCopyright()],
['License', PackageObject2.GetLicense()],
['Abstract', PackageObject2.GetAbstract()],
['Description', PackageObject2.GetDescription()],
['PackagePath', PackageObject2.GetPackagePath()],
Element2
]
Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)
UNIPackageAbrstractList = []
UNIPackageDescriptionList = []
# Get Abstract and Description from Uni File
# if the Uni File exists
if PackageObject2.UniFileClassObject is not None:
UniStrDict = PackageObject2.UniFileClassObject.OrderedStringList
for Lang in UniStrDict:
for StringDefClassObject in UniStrDict[Lang]:
if not StringDefClassObject.StringValue:
continue
if StringDefClassObject.StringName == DataType.TAB_DEC_PACKAGE_ABSTRACT:
UNIPackageAbrstractList.append((GetLanguageCode1766(Lang),
ConvertSpecialUnicodes(StringDefClassObject.StringValue)))
if StringDefClassObject.StringName == DataType.TAB_DEC_PACKAGE_DESCRIPTION:
UNIPackageDescriptionList.append((GetLanguageCode1766(Lang),
ConvertSpecialUnicodes(StringDefClassObject.StringValue)))
# Get Abstract and Description from DEC File Header
for (Lang, Value) in PackageObject2.GetCopyright():
if Value:
NodeList.append(CreateXmlElement(DataType.TAB_HEADER_COPYRIGHT, Value, [], []))
for (Lang, Value) in PackageObject2.GetLicense():
if Value:
NodeList.append(CreateXmlElement(DataType.TAB_HEADER_LICENSE, Value, [], []))
for (Lang, Value) in PackageObject2.GetAbstract() + UNIPackageAbrstractList:
if Value:
NodeList.append(CreateXmlElement(DataType.TAB_HEADER_ABSTRACT, Value, [], [['Lang', Lang]]))
for (Lang, Value) in PackageObject2.GetDescription() + UNIPackageDescriptionList:
if Value:
NodeList.append(CreateXmlElement(DataType.TAB_HEADER_DESCRIPTION, Value, [], [['Lang', Lang]]))
NodeList.append(['PackagePath', PackageObject2.GetPackagePath()])
AttributeList = []
Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)
return Root
def __str__(self):
@@ -351,7 +438,6 @@ class MiscellaneousFileXml(object):
self.Header.FromXml(Item, Key)
NewItem = XmlNode(Item, '%s/Header' % Key)
self.Header.FromXml(NewItem, 'Header')
for SubItem in XmlList(Item, '%s/Filename' % Key):
Filename = XmlElement(SubItem, '%s/Filename' % Key)
Executable = XmlAttribute(XmlNode(SubItem, '%s/Filename' % Key), 'Executable')
@@ -362,12 +448,11 @@ class MiscellaneousFileXml(object):
else:
Executable = ''
self.Files.append([Filename, Executable])
MiscFile = MiscFileObject()
MiscFile.SetCopyright(self.Header.Copyright)
MiscFile.SetLicense(self.Header.License)
MiscFile.SetAbstract(self.Header.Abstract)
MiscFile.SetDescription(self.Header.Description)
MiscFile.SetCopyright(self.Header.CopyrightList)
MiscFile.SetLicense(self.Header.LicenseList)
MiscFile.SetAbstract(self.Header.AbstractList)
MiscFile.SetDescription(self.Header.DescriptionList)
MiscFileList = []
for File in self.Files:
FileObj = FileObject()
@@ -375,7 +460,6 @@ class MiscellaneousFileXml(object):
FileObj.SetExecutable(File[1])
MiscFileList.append(FileObj)
MiscFile.SetFileList(MiscFileList)
return MiscFile
##
# This API is used for DistP's tool section
@@ -383,10 +467,8 @@ class MiscellaneousFileXml(object):
def FromXml2(self, Item, Key):
if Item is None:
return None
NewItem = XmlNode(Item, '%s/Header' % Key)
self.Header.FromXml(NewItem, 'Header')
for SubItem in XmlList(Item, '%s/Filename' % Key):
Filename = XmlElement(SubItem, '%s/Filename' % Key)
Executable = \
@@ -399,13 +481,12 @@ class MiscellaneousFileXml(object):
else:
Executable = ''
self.Files.append([Filename, Executable, OsType])
MiscFile = MiscFileObject()
MiscFile.SetName(self.Header.Name)
MiscFile.SetCopyright(self.Header.Copyright)
MiscFile.SetLicense(self.Header.License)
MiscFile.SetAbstract(self.Header.Abstract)
MiscFile.SetDescription(self.Header.Description)
MiscFile.SetCopyright(self.Header.CopyrightList)
MiscFile.SetLicense(self.Header.LicenseList)
MiscFile.SetAbstract(self.Header.AbstractList)
MiscFile.SetDescription(self.Header.DescriptionList)
MiscFileList = []
for File in self.Files:
FileObj = FileObject()
@@ -414,7 +495,6 @@ class MiscellaneousFileXml(object):
FileObj.SetOS(File[2])
MiscFileList.append(FileObj)
MiscFile.SetFileList(MiscFileList)
return MiscFile
##
@@ -424,19 +504,33 @@ class MiscellaneousFileXml(object):
if self.Header:
pass
if MiscFile:
NodeList = [['Copyright', MiscFile.GetCopyright()],
['License', MiscFile.GetLicense()],
['Abstract', MiscFile.GetAbstract()],
['Description', MiscFile.GetDescription()],
if MiscFile.GetAbstract():
DPAbstract = MiscFile.GetAbstract()[0][1]
else:
DPAbstract = ''
if MiscFile.GetDescription():
DPDescription = MiscFile.GetDescription()[0][1]
else:
DPDescription = ''
if MiscFile.GetCopyright():
DPCopyright = MiscFile.GetCopyright()[0][1]
else:
DPCopyright = ''
if MiscFile.GetLicense():
DPLicense = MiscFile.GetLicense()[0][1]
else:
DPLicense = ''
NodeList = [['Copyright', DPCopyright],
['License', DPLicense],
['Abstract', DPAbstract],
['Description', DPDescription],
]
for File in MiscFile.GetFileList():
NodeList.append\
(CreateXmlElement\
('Filename', File.GetURI(), [], \
[['Executable', str(File.GetExecutable()).lower()]]))
Root = CreateXmlElement('%s' % Key, '', NodeList, [])
return Root
##
# This API is used for DistP's tool section
@@ -445,15 +539,30 @@ class MiscellaneousFileXml(object):
if self.Header:
pass
if MiscFile:
if MiscFile.GetAbstract():
DPAbstract = MiscFile.GetAbstract()[0][1]
else:
DPAbstract = ''
if MiscFile.GetDescription():
DPDescription = MiscFile.GetDescription()[0][1]
else:
DPDescription = ''
if MiscFile.GetCopyright():
DPCopyright = MiscFile.GetCopyright()[0][1]
else:
DPCopyright = ''
if MiscFile.GetLicense():
DPLicense = MiscFile.GetLicense()[0][1]
else:
DPLicense = ''
NodeList = [['Name', MiscFile.GetName()],
['Copyright', MiscFile.GetCopyright()],
['License', MiscFile.GetLicense()],
['Abstract', MiscFile.GetAbstract()],
['Description', MiscFile.GetDescription()],
['Copyright', DPCopyright],
['License', DPLicense],
['Abstract', DPAbstract],
['Description', DPDescription],
]
HeaderNode = CreateXmlElement('Header', '', NodeList, [])
NodeList = [HeaderNode]
for File in MiscFile.GetFileList():
NodeList.append\
(CreateXmlElement\
@@ -461,7 +570,6 @@ class MiscellaneousFileXml(object):
[['Executable', str(File.GetExecutable()).lower()], \
['OS', File.GetOS()]]))
Root = CreateXmlElement('%s' % Key, '', NodeList, [])
return Root
def __str__(self):
@@ -476,6 +584,11 @@ class UserExtensionsXml(object):
def __init__(self):
self.UserId = ''
self.Identifier = ''
self.BinaryAbstractList = []
self.BinaryDescriptionList = []
self.BinaryCopyrightList = []
self.BinaryLicenseList = []
self.LangDefsList = []
self.DefineDict = {}
self.BuildOptionDict = {}
self.IncludesDict = {}
@@ -489,51 +602,64 @@ class UserExtensionsXml(object):
def FromXml2(self, Item, Key):
self.UserId = XmlAttribute(XmlNode(Item, '%s' % Key), 'UserId')
self.Identifier = XmlAttribute(XmlNode(Item, '%s' % Key), 'Identifier')
UserExtension = UserExtensionObject()
UserExtension.SetUserID(self.UserId)
UserExtension.SetIdentifier(self.Identifier)
return UserExtension
def FromXml(self, Item, Key):
self.UserId = XmlAttribute(XmlNode(Item, '%s' % Key), 'UserId')
self.Identifier = XmlAttribute(XmlNode(Item, '%s' % Key), 'Identifier')
if self.UserId == DataType.TAB_BINARY_HEADER_USERID \
and self.Identifier == DataType.TAB_BINARY_HEADER_IDENTIFIER:
for SubItem in XmlList(Item, '%s/BinaryAbstract' % Key):
BinaryAbstractLang = XmlAttribute(SubItem, 'Lang')
self.BinaryAbstractList.append((BinaryAbstractLang, XmlElement(SubItem, '%s/BinaryAbstract' % Key)))
for SubItem in XmlList(Item, '%s/BinaryDescription' % Key):
BinaryDescriptionLang = XmlAttribute(SubItem, 'Lang')
self.BinaryDescriptionList.append((BinaryDescriptionLang,
XmlElement(SubItem, '%s/BinaryDescription' % Key)))
for SubItem in XmlList(Item, '%s/BinaryCopyright' % Key):
BinaryCopyrightLang = XmlAttribute(SubItem, 'Lang')
self.BinaryCopyrightList.append((BinaryCopyrightLang,
XmlElement(SubItem, '%s/BinaryCopyright' % Key)))
for SubItem in XmlList(Item, '%s/BinaryLicense' % Key):
BinaryLicenseLang = XmlAttribute(SubItem, 'Lang')
self.BinaryLicenseList.append((BinaryLicenseLang,
XmlElement(SubItem, '%s/BinaryLicense' % Key)))
DefineItem = XmlNode(Item, '%s/Define' % Key)
for SubItem in XmlList(DefineItem, 'Define/Statement'):
Statement = XmlElement(SubItem, '%s/Statement' % Key)
self.DefineDict[Statement] = ""
BuildOptionItem = XmlNode(Item, '%s/BuildOption' % Key)
for SubItem in XmlList(BuildOptionItem, 'BuildOption/Statement'):
Statement = XmlElement(SubItem, '%s/Statement' % Key)
Arch = XmlAttribute(XmlNode(SubItem, '%s/Statement' % Key), 'SupArchList')
self.BuildOptionDict[Arch] = Statement
IncludesItem = XmlNode(Item, '%s/Includes' % Key)
for SubItem in XmlList(IncludesItem, 'Includes/Statement'):
Statement = XmlElement(SubItem, '%s/Statement' % Key)
Arch = XmlAttribute(XmlNode(SubItem, '%s/Statement' % Key), 'SupArchList')
self.IncludesDict[Statement] = Arch
SourcesItem = XmlNode(Item, '%s/Sources' % Key)
Tmp = UserExtensionSourceXml()
SourceDict = Tmp.FromXml(SourcesItem, 'Sources')
self.SourcesDict = SourceDict
BinariesItem = XmlNode(Item, '%s/Binaries' % Key)
Tmp = UserExtensionBinaryXml()
BinariesDict = Tmp.FromXml(BinariesItem, 'Binaries')
self.BinariesDict = BinariesDict
self.Statement = XmlElement(Item, 'UserExtensions')
SupArch = XmlAttribute(XmlNode(Item, '%s' % Key), 'SupArchList')
self.SupArchList = [Arch for Arch in GetSplitValueList(SupArch, DataType.TAB_SPACE_SPLIT) if Arch]
UserExtension = UserExtensionObject()
UserExtension.SetUserID(self.UserId)
UserExtension.SetIdentifier(self.Identifier)
UserExtension.SetBinaryAbstract(self.BinaryAbstractList)
UserExtension.SetBinaryDescription(self.BinaryDescriptionList)
UserExtension.SetBinaryCopyright(self.BinaryCopyrightList)
UserExtension.SetBinaryLicense(self.BinaryLicenseList)
UserExtension.SetStatement(self.Statement)
UserExtension.SetSupArchList(self.SupArchList)
UserExtension.SetDefinesDict(self.DefineDict)
@@ -541,22 +667,37 @@ class UserExtensionsXml(object):
UserExtension.SetIncludesDict(self.IncludesDict)
UserExtension.SetSourcesDict(self.SourcesDict)
UserExtension.SetBinariesDict(self.BinariesDict)
return UserExtension
def ToXml(self, UserExtension, Key):
if self.UserId:
pass
AttributeList = [['UserId', str(UserExtension.GetUserID())],
['Identifier', str(UserExtension.GetIdentifier())],
['SupArchList', \
GetStringOfList(UserExtension.GetSupArchList())],
]
Root = CreateXmlElement('%s' % Key, UserExtension.GetStatement(), [], \
AttributeList)
AttributeList)
if UserExtension.GetIdentifier() == DataType.TAB_BINARY_HEADER_IDENTIFIER and \
UserExtension.GetUserID() == DataType.TAB_BINARY_HEADER_USERID:
for (Lang, Value) in UserExtension.GetBinaryAbstract():
if Value:
ChildElement = CreateXmlElement('BinaryAbstract', Value, [], [['Lang', Lang]])
Root.appendChild(ChildElement)
for (Lang, Value) in UserExtension.GetBinaryDescription():
if Value:
ChildElement = CreateXmlElement('BinaryDescription', Value, [], [['Lang', Lang]])
Root.appendChild(ChildElement)
for (Lang, Value) in UserExtension.GetBinaryCopyright():
if Value:
ChildElement = CreateXmlElement('BinaryCopyright', Value, [], [])
Root.appendChild(ChildElement)
for (Lang, Value) in UserExtension.GetBinaryLicense():
if Value:
ChildElement = CreateXmlElement('BinaryLicense', Value, [], [])
Root.appendChild(ChildElement)
NodeList = []
DefineDict = UserExtension.GetDefinesDict()
if DefineDict:
@@ -565,7 +706,6 @@ class UserExtensionsXml(object):
('Statement', Item, [], []))
DefineElement = CreateXmlElement('Define', '', NodeList, [])
Root.appendChild(DefineElement)
NodeList = []
BuildOptionDict = UserExtension.GetBuildOptionDict()
if BuildOptionDict:
@@ -576,7 +716,6 @@ class UserExtensionsXml(object):
BuildOptionElement = \
CreateXmlElement('BuildOption', '', NodeList, [])
Root.appendChild(BuildOptionElement)
NodeList = []
IncludesDict = UserExtension.GetIncludesDict()
if IncludesDict:
@@ -586,19 +725,16 @@ class UserExtensionsXml(object):
[['SupArchList', IncludesDict[Item]]]))
IncludesElement = CreateXmlElement('Includes', '', NodeList, [])
Root.appendChild(IncludesElement)
NodeList = []
SourcesDict = UserExtension.GetSourcesDict()
if SourcesDict:
Tmp = UserExtensionSourceXml()
Root.appendChild(Tmp.ToXml(SourcesDict, 'Sources'))
NodeList = []
BinariesDict = UserExtension.GetBinariesDict()
if BinariesDict:
Tmp = UserExtensionBinaryXml()
Root.appendChild(Tmp.ToXml(BinariesDict, 'Binaries'))
return Root
def __str__(self):
@@ -620,7 +756,6 @@ class UserExtensionSourceXml(object):
if self.UserExtensionSource:
pass
Dict = {}
#SourcesItem = XmlNode(Item, '%s/Sources' % Key)
for SubItem in XmlList(Item, 'Sources/SourceFile'):
FileName = XmlElement(SubItem, 'SourceFile/FileName')
@@ -628,7 +763,6 @@ class UserExtensionSourceXml(object):
FeatureFlag = XmlElement(SubItem, 'SourceFile/FeatureFlag')
SupArchStr = XmlElement(SubItem, 'SourceFile/SupArchList')
DictKey = (FileName, Family, FeatureFlag, SupArchStr)
ValueList = []
for ValueNodeItem in XmlList(SubItem, \
'SourceFile/SourceFileOtherAttr'):
@@ -643,9 +777,7 @@ class UserExtensionSourceXml(object):
ToolCode = ''
Comment = ''
ValueList.append((TagName, ToolCode, Comment))
Dict[DictKey] = ValueList
return Dict
def ToXml(self, Dict, Key):
@@ -690,16 +822,13 @@ class UserExtensionBinaryXml(object):
pass
if self.UserExtensionBinary:
pass
Dict = {}
for SubItem in XmlList(Item, 'Binaries/Binary'):
FileName = XmlElement(SubItem, 'Binary/FileName')
FileType = XmlElement(SubItem, 'Binary/FileType')
FFE = XmlElement(SubItem, 'Binary/FeatureFlag')
SupArch = XmlElement(SubItem, 'Binary/SupArchList')
DictKey = (FileName, FileType, ConvertNOTEQToNE(FFE), SupArch)
ValueList = []
for ValueNodeItem in XmlList(SubItem, \
'Binary/BinaryFileOtherAttr'):
@@ -719,9 +848,7 @@ class UserExtensionBinaryXml(object):
Comment = ''
ValueList.append((Target, Family, TagName, Comment))
Dict[DictKey] = ValueList
return Dict
def ToXml(self, Dict, Key):
@@ -777,7 +904,6 @@ class LibraryClassXml(object):
HelpTextObj = HelpTextXml()
HelpTextObj.FromXml(HelpTextItem, '%s/HelpText' % Key)
self.HelpText.append(HelpTextObj)
LibraryClass = LibraryClassObject()
LibraryClass.SetLibraryClass(self.Keyword)
LibraryClass.SetIncludeHeader(self.HeaderFile)
@@ -787,7 +913,6 @@ class LibraryClassXml(object):
LibraryClass.SetSupModuleList(self.CommonDefines.SupModList)
LibraryClass.SetFeatureFlag(ConvertNOTEQToNE(self.CommonDefines.FeatureFlag))
LibraryClass.SetHelpTextList(GetHelpTextList(self.HelpText))
return LibraryClass
def ToXml(self, LibraryClass, Key):
@@ -802,17 +927,13 @@ class LibraryClassXml(object):
for Item in LibraryClass.GetHelpTextList():
Tmp = HelpTextXml()
NodeList.append(Tmp.ToXml(Item))
Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)
return Root
def ToXml2(self, LibraryClass, Key):
if self.HeaderFile:
pass
FeatureFlag = ConvertNEToNOTEQ(LibraryClass.GetFeatureFlag())
AttributeList = \
[['Usage', LibraryClass.GetUsage()], \
['SupArchList', GetStringOfList(LibraryClass.GetSupArchList())], \
@@ -823,9 +944,7 @@ class LibraryClassXml(object):
for Item in LibraryClass.GetHelpTextList():
Tmp = HelpTextXml()
NodeList.append(Tmp.ToXml(Item))
Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)
return Root
def __str__(self):
@@ -847,18 +966,18 @@ class FilenameXml(object):
def FromXml(self, Item, Key):
self.FileType = XmlAttribute(Item, 'FileType')
Guid = XmlAttribute(Item, 'GUID')
self.Filename = XmlElement(Item, 'Filename')
self.CommonDefines.FromXml(Item, Key)
FeatureFlag = ConvertNOTEQToNE(self.CommonDefines.FeatureFlag)
Filename = FileNameObject()
#
# Convert File Type
#
if self.FileType == 'UEFI_IMAGE':
self.FileType = 'PE32'
Filename.SetGuidValue(Guid)
Filename.SetFileType(self.FileType)
Filename.SetFilename(self.Filename)
Filename.SetSupArchList(self.CommonDefines.SupArchList)
@@ -873,6 +992,7 @@ class FilenameXml(object):
GetStringOfList(Filename.GetSupArchList())],
['FileType', Filename.GetFileType()],
['FeatureFlag', ConvertNEToNOTEQ(Filename.GetFeatureFlag())],
['GUID', Filename.GetGuidValue()]
]
Root = CreateXmlElement('%s' % Key, Filename.GetFilename(), [], AttributeList)

View File

@@ -1,7 +1,7 @@
## @file
# This file is for converting package information data file to xml file.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials are licensed and made available
# under the terms and conditions of the BSD License which accompanies this
@@ -32,6 +32,7 @@ from Library.DataType import TAB_SECTION_END
from Logger import StringTable as ST
from Library.String import ConvertSpecialChar
from Library.ParserValidate import IsValidPath
from Library import GlobalData
## log error:
#
@@ -58,9 +59,7 @@ def __ValidatePath(Path, Root):
# @param Filename: File to be checked
#
def ValidateMiscFile(Filename):
Root = ''
if 'WORKSPACE' in os.environ:
Root = os.environ['WORKSPACE']
Root = GlobalData.gWORKSPACE
return __ValidatePath(Filename, Root)
## ValidateToolsFile
@@ -71,8 +70,8 @@ def ValidateToolsFile(Filename):
Valid, Cause = False, ''
if not Valid and 'EDK_TOOLS_PATH' in os.environ:
Valid, Cause = __ValidatePath(Filename, os.environ['EDK_TOOLS_PATH'])
if not Valid and 'WORKSPACE' in os.environ:
Valid, Cause = __ValidatePath(Filename, os.environ['WORKSPACE'])
if not Valid:
Valid, Cause = __ValidatePath(Filename, GlobalData.gWORKSPACE)
return Valid, Cause
## ParseFileList
@@ -332,7 +331,7 @@ def IniToXml(IniFile):
for Index in range(0, len(FileContent)):
LastIndex = Index
Line = FileContent[Index].strip()
if Line == '':
if Line == '' or Line.startswith(';'):
continue
if Line[0] == TAB_SECTION_START and Line[-1] == TAB_SECTION_END:
CurrentKey = ''

View File

@@ -3,9 +3,9 @@
#
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials are licensed and made available
# under the terms and conditions of the BSD License which accompanies this
# distribution. The full text of the license may be found at
# This program and the accompanying materials are licensed and made available
# under the terms and conditions of the BSD License which accompanies this
# distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
@@ -67,7 +67,7 @@ from Library.Misc import GetSplitValueList
# </Filename> {1,}
# <AsBuilt> ... </AsBuilt> {0,}
# </BinaryFile> {1,}
#
#
class BinaryFileXml(object):
def __init__(self):
self.FileNames = []
@@ -82,11 +82,16 @@ class BinaryFileXml(object):
pass
BinaryFile = BinaryFileObject()
FilenameList = []
SupArchList = ['COMMON']
for SubItem in XmlList(Item, '%s/Filename' % Key):
Axml = FilenameXml()
Bxml = Axml.FromXml(SubItem, 'Filename')
FilenameList.append(Bxml)
BinaryFile.SetFileNameList(FilenameList)
for FileName in FilenameList:
if FileName.GetSupArchList():
SupArchList = FileName.GetSupArchList()
BinaryFile.SetSupArchList(SupArchList)
if GlobalData.gIS_BINARY_INF:
AsBuiltList = []
for AsBuiltItem in XmlList(Item, '%s/AsBuilt' % Key):
@@ -135,42 +140,44 @@ class BinaryFileXml(object):
NodeList.append(Tmp.ToXml(Filename, 'Filename'))
SupportArch = Filename.SupArchList
if GlobalData.gIS_BINARY_INF:
AsBuildList = BinaryFile.GetAsBuiltList()
PatchPcdValueList = AsBuildList.GetPatchPcdList()
PcdExList = AsBuildList.GetPcdExList()
LibGuidVerList = AsBuildList.GetLibraryInstancesList()
BuildFlagList = AsBuildList.GetBuildFlagsList()
AsBuildList = BinaryFile.GetAsBuiltList()
PatchPcdValueList = AsBuildList.GetPatchPcdList()
PcdExList = AsBuildList.GetPcdExList()
LibGuidVerList = AsBuildList.GetLibraryInstancesList()
BuildFlagList = AsBuildList.GetBuildFlagsList()
AsBuiltNodeList = []
AsBuiltNodeList = []
for Pcd in PatchPcdValueList:
if IsMatchArch(Pcd.SupArchList, SupportArch):
Tmp = PcdEntryXml()
AsBuiltNodeList.append(Tmp.ToXml4(Pcd, 'PatchPcdValue'))
for Pcd in PatchPcdValueList:
if IsMatchArch(Pcd.SupArchList, SupportArch):
Tmp = PcdEntryXml()
AsBuiltNodeList.append(Tmp.ToXml4(Pcd, 'PatchPcdValue'))
for Pcd in PcdExList:
if IsMatchArch(Pcd.SupArchList, SupportArch):
Tmp = PcdEntryXml()
AsBuiltNodeList.append(Tmp.ToXml4(Pcd, 'PcdExValue'))
for Pcd in PcdExList:
if IsMatchArch(Pcd.SupArchList, SupportArch):
Tmp = PcdEntryXml()
AsBuiltNodeList.append(Tmp.ToXml4(Pcd, 'PcdExValue'))
GuiVerElemList = []
for LibGuidVer in LibGuidVerList:
GuiVerElemList = []
for LibGuidVer in LibGuidVerList:
if IsMatchArch(LibGuidVer.GetSupArchList(), SupportArch):
GuiVerElem = \
CreateXmlElement('GUID', LibGuidVer.GetLibGuid(), [], [['Version', LibGuidVer.GetLibVersion()]])
GuiVerElemList.append(GuiVerElem)
if len(GuiVerElemList) > 0:
LibGuidVerElem = CreateXmlElement('LibraryInstances', '', GuiVerElemList, [])
AsBuiltNodeList.append(LibGuidVerElem)
if len(GuiVerElemList) > 0:
LibGuidVerElem = CreateXmlElement('LibraryInstances', '', GuiVerElemList, [])
AsBuiltNodeList.append(LibGuidVerElem)
for BuildFlag in BuildFlagList:
Tmp = BuildFlagXml()
Elem = CreateXmlElement('BuildFlags', ''.join(BuildFlag), [], [])
AsBuiltNodeList.append(Elem)
for BuildFlag in BuildFlagList:
if IsMatchArch(BuildFlag.GetSupArchList(), SupportArch):
for Item in BuildFlag.GetAsBuildList():
Tmp = BuildFlagXml()
Elem = CreateXmlElement('BuildFlags', ''.join(Item), [], [])
AsBuiltNodeList.append(Elem)
if len(AsBuiltNodeList) > 0:
Element = CreateXmlElement('AsBuilt', '', AsBuiltNodeList, [])
NodeList.append(Element)
if len(AsBuiltNodeList) > 0:
Element = CreateXmlElement('AsBuilt', '', AsBuiltNodeList, [])
NodeList.append(Element)
Root = CreateXmlElement('%s' % Key, '', NodeList, [])
@@ -286,7 +293,7 @@ class ExternXml(object):
for Item in self.HelpText:
Str = Str + '\n\t' + str(Item)
return Str
##
##
# DepexXml
#
class DepexXml(object):
@@ -654,7 +661,7 @@ class ModuleSurfaceAreaXml(object):
else:
Module.SetMiscFileList([])
#
#
# UserExtensions
#
for Item in XmlList(Item, '/ModuleSurfaceArea/UserExtensions'):
@@ -740,7 +747,7 @@ class ModuleSurfaceAreaXml(object):
not XmlList(Item, '/ModuleSurfaceArea/PackageDependencies/Package'):
Module.SetPackageDependencyList([None])
#
#
# Guid
#
for SubItem in XmlList(Item, '/ModuleSurfaceArea/Guids/GuidCName'):

View File

@@ -1,7 +1,7 @@
## @file
# This file is used to parse a Package file of .PKG file
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials are licensed and made available
# under the terms and conditions of the BSD License which accompanies this
@@ -254,6 +254,16 @@ class PackageSurfaceAreaXml(object):
Tmp = PcdEntryXml()
PcdEntry = Tmp.FromXml2(SubItem, 'PcdEntry')
Package.SetPcdList(Package.GetPcdList() + [PcdEntry])
#
# Get PcdErrorCommentDict from PcdError in PcdEntry Node
#
for PcdErrorObj in PcdEntry.GetPcdErrorsList():
PcdErrorMessageList = PcdErrorObj.GetErrorMessageList()
if PcdErrorMessageList:
Package.PcdErrorCommentDict[(PcdEntry.GetTokenSpaceGuidCName(), PcdErrorObj.GetErrorNumber())] = \
PcdErrorMessageList
if XmlList(Item, '/PackageSurfaceArea/PcdDeclarations') and not \
XmlList(Item, '/PackageSurfaceArea/PcdDeclarations/PcdEntry'):

View File

@@ -1,7 +1,7 @@
## @file
# This file is used to parse a PCD file of .PKG file
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials are licensed and made available
# under the terms and conditions of the BSD License which accompanies this
@@ -32,8 +32,11 @@ from Library import GlobalData
from Object.POM.CommonObject import PcdObject
from Object.POM.CommonObject import PcdErrorObject
from Xml.CommonXml import HelpTextXml
from Xml.CommonXml import PromptXml
from Xml.CommonXml import CommonDefinesXml
from Xml.XmlParserMisc import GetHelpTextList
from Xml.XmlParserMisc import GetPromptList
import re
##
# PcdErrorXml
@@ -51,7 +54,7 @@ class PcdErrorXml(object):
self.ValidValueList = XmlElement(Item, '%s/ValidValueList' % Key)
self.ValidValueListLang = \
XmlAttribute(XmlNode(Item, '%s/ValidValueList' % Key), 'Lang')
self.ValidValueRange = XmlElement(Item, '%s/ValidValueRange' % Key)
self.ValidValueRange = self.TransferValidEpxr2ValidRange(XmlElement(Item, '%s/ValidValueRange' % Key))
self.Expression = XmlElement(Item, '%s/Expression' % Key)
self.ErrorNumber = XmlElement(Item, '%s/ErrorNumber' % Key)
for ErrMsg in XmlList(Item, '%s/ErrorMessage' % Key):
@@ -81,9 +84,12 @@ class PcdErrorXml(object):
[['Lang', PcdError.GetValidValueLang()]])
NodeList.append(Element1)
if PcdError.GetValidValueRange():
TansferedRangeStr = self.TransferValidRange2Expr(PcdError.GetTokenSpaceGuidCName(),
PcdError.GetCName(),
PcdError.GetValidValueRange())
Element1 = \
CreateXmlElement('ValidValueRange', \
PcdError.GetValidValueRange(), [], [])
TansferedRangeStr, [], [])
NodeList.append(Element1)
if PcdError.GetExpression():
NodeList.append(['Expression', PcdError.GetExpression()])
@@ -96,6 +102,147 @@ class PcdErrorXml(object):
Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)
return Root
def TransferValidRange2Expr(self, TokenSpaceGuidCName, CName, ValidRange):
if self.Expression:
pass
INT_RANGE_PATTERN1 = '[\t\s]*[0-9]+[\t\s]*-[\t\s]*[0-9]+'
INT_RANGE_PATTERN2 = '[\t\s]*(LT|GT|LE|GE|XOR|EQ)[\t\s]+\d+[\t\s]*'
HEX_RANGE_PATTERN1 = \
'[\t\s]*0[xX][a-fA-F0-9]+[\t\s]*-[\t\s]*0[xX][a-fA-F0-9]+'
HEX_RANGE_PATTERN2 = '[\t\s]*(LT|GT|LE|GE|XOR|EQ)[\t\s]+0[xX][a-fA-F0-9]+[\t\s]*'
IntMatch1 = re.compile(INT_RANGE_PATTERN1)
IntMatch2 = re.compile(INT_RANGE_PATTERN2)
HexMatch1 = re.compile(HEX_RANGE_PATTERN1)
HexMatch2 = re.compile(HEX_RANGE_PATTERN2)
PcdName = '.'.join([TokenSpaceGuidCName, CName])
HexMatchedList = []
IntMatchedList = []
#
# Convert HEX2 format range
#
if HexMatch2:
for MatchObj in HexMatch2.finditer(ValidRange):
MatchStr = MatchObj.group()
TransferedRangeStr = ' '.join(['', PcdName, MatchStr.strip()])
ValidRange = ValidRange.replace(MatchStr, TransferedRangeStr)
#
# Convert INT2 format range
#
if IntMatch2:
for MatchObj in IntMatch2.finditer(ValidRange):
MatchStr = MatchObj.group()
TransferedRangeStr = ' '.join(['', PcdName, MatchStr.strip()])
ValidRange = ValidRange.replace(MatchStr, TransferedRangeStr)
#
# Convert HEX1 format range
#
if HexMatch1:
HexMatchedList += HexMatch1.findall(ValidRange)
for MatchStr in HexMatchedList:
RangeItemList = MatchStr.strip().split('-')
TransferedRangeStr = '(%s GE %s) AND (%s LE %s)' % \
(PcdName, RangeItemList[0].strip(), PcdName, RangeItemList[1].strip())
ValidRange = ValidRange.replace(MatchStr, TransferedRangeStr)
#
# Convert INT1 format range
#
if IntMatch1:
IntMatchedList += IntMatch1.findall(ValidRange)
for MatchStr in IntMatchedList:
RangeItemList = MatchStr.strip().split('-')
TransferedRangeStr = '(%s GE %s) AND (%s LE %s)' % \
(PcdName, RangeItemList[0].strip(), PcdName, RangeItemList[1].strip())
ValidRange = ValidRange.replace(MatchStr, TransferedRangeStr)
return ValidRange
def TransferValidEpxr2ValidRange(self, ValidRangeExpr):
if self.Expression:
pass
PCD_PATTERN = \
'[\t\s]*[_a-zA-Z][a-zA-Z0-9_]*[\t\s]*\.[\t\s]*[_a-zA-Z][a-zA-Z0-9_]*[\t\s]*'
IntPattern1 = \
'[\t\s]*\([\t\s]*'+PCD_PATTERN+'[\t\s]+GE[\t\s]+\d+[\t\s]*\)[\t\s]+AND[\t\s]+\([\t\s]*'+\
PCD_PATTERN+'[\t\s]+LE[\t\s]+\d+[\t\s]*\)'
IntPattern1 = IntPattern1.replace(' ', '')
IntPattern2 = '[\t\s]*'+PCD_PATTERN+'[\t\s]+(LT|GT|LE|GE|XOR|EQ)[\t\s]+\d+[\t\s]*'
HexPattern1 = \
'[\t\s]*\([\t\s]*'+PCD_PATTERN+'[\t\s]+GE[\t\s]+0[xX][0-9a-fA-F]+[\t\s]*\)[\t\s]+AND[\t\s]+\([\t\s]*'+\
PCD_PATTERN+'[\t\s]+LE[\t\s]+0[xX][0-9a-fA-F]+[\t\s]*\)'
HexPattern1 = HexPattern1.replace(' ', '')
HexPattern2 = '[\t\s]*'+PCD_PATTERN+'[\t\s]+(LT|GT|LE|GE|XOR|EQ)[\t\s]+0[xX][0-9a-zA-Z]+[\t\s]*'
#
# Do the Hex1 conversion
#
HexMatchedList = re.compile(HexPattern1).findall(ValidRangeExpr)
HexRangeDict = {}
for HexMatchedItem in HexMatchedList:
#
# To match items on both sides of '-'
#
RangeItemList = re.compile('[\t\s]*0[xX][0-9a-fA-F]+[\t\s]*').findall(HexMatchedItem)
if RangeItemList and len(RangeItemList) == 2:
HexRangeDict[HexMatchedItem] = RangeItemList
for Key in HexRangeDict.keys():
MaxItem = MixItem = ''
if int(HexRangeDict[Key][0], 16) > int(HexRangeDict[Key][1], 16):
MaxItem = HexRangeDict[Key][0]
MixItem = HexRangeDict[Key][1]
else:
MaxItem = HexRangeDict[Key][1]
MixItem = HexRangeDict[Key][0]
Range = ' %s - %s' % (MixItem.strip(), MaxItem.strip())
ValidRangeExpr = ValidRangeExpr.replace(Key, Range)
#
# Do the INT1 conversion
#
IntRangeDict = {}
IntMatchList = re.compile(IntPattern1).findall(ValidRangeExpr)
for MatchedItem in IntMatchList:
#
# To match items on both sides of '-'
#
RangeItemList = re.compile('[\t\s]*\d+[\t\s]*').findall(MatchedItem)
if RangeItemList and len(RangeItemList) == 2:
IntRangeDict[MatchedItem] = RangeItemList
for Key in IntRangeDict.keys():
MaxItem = MixItem = ''
if int(IntRangeDict[Key][0]) > int(IntRangeDict[Key][1]):
MaxItem = IntRangeDict[Key][0]
MixItem = IntRangeDict[Key][1]
else:
MaxItem = IntRangeDict[Key][1]
MixItem = IntRangeDict[Key][0]
Range = ' %s - %s' % (MixItem.strip(), MaxItem.strip())
ValidRangeExpr = ValidRangeExpr.replace(Key, Range)
#
# Do the HEX2 conversion
#
for MatchObj in re.compile(HexPattern2).finditer(ValidRangeExpr):
MatchStr = MatchObj.group()
Range = re.compile(PCD_PATTERN).sub(' ', MatchStr)
ValidRangeExpr = ValidRangeExpr.replace(MatchStr, Range)
#
# Do the INT2 conversion
#
for MatchObj in re.compile(IntPattern2).finditer(ValidRangeExpr):
MatchStr = MatchObj.group()
Range = re.compile(PCD_PATTERN).sub(' ', MatchStr)
ValidRangeExpr = ValidRangeExpr.replace(MatchStr, Range)
return ValidRangeExpr
def __str__(self):
return "ValidValueList = %s ValidValueListLang = %s ValidValueRange \
@@ -122,6 +269,7 @@ class PcdEntryXml(object):
self.Value = ''
self.Offset = ''
self.CommonDefines = CommonDefinesXml()
self.Prompt = []
self.HelpText = []
self.PcdError = []
@@ -149,6 +297,7 @@ class PcdEntryXml(object):
self.Value = XmlElement(Item, '%s/Value' % Key)
self.Offset = XmlElement(Item, '%s/Offset' % Key)
self.CommonDefines.FromXml(XmlNode(Item, '%s' % Key), Key)
for HelpTextItem in XmlList(Item, '%s/HelpText' % Key):
HelpTextObj = HelpTextXml()
HelpTextObj.FromXml(HelpTextItem, '%s/HelpText' % Key)
@@ -192,6 +341,10 @@ class PcdEntryXml(object):
self.DefaultValue = XmlElement(Item, '%s/DefaultValue' % Key)
self.MaxDatumSize = XmlElement(Item, '%s/MaxDatumSize' % Key)
self.CommonDefines.FromXml(XmlNode(Item, '%s' % Key), Key)
for PromptItem in XmlList(Item, '%s/Prompt' % Key):
PromptObj = PromptXml()
PromptObj.FromXml(PromptItem, '%s/Prompt' % Key)
self.Prompt.append(PromptObj)
for HelpTextItem in XmlList(Item, '%s/HelpText' % Key):
HelpTextObj = HelpTextXml()
HelpTextObj.FromXml(HelpTextItem, '%s/HelpText' % Key)
@@ -214,7 +367,8 @@ class PcdEntryXml(object):
PcdEntry.SetDefaultValue(self.DefaultValue)
PcdEntry.SetMaxDatumSize(self.MaxDatumSize)
PcdEntry.SetFeatureFlag(ConvertNOTEQToNE(self.CommonDefines.FeatureFlag))
PcdEntry.SetPromptList(GetPromptList(self.Prompt))
PcdEntry.SetHelpTextList(GetHelpTextList(self.HelpText))
PcdEntry.SetPcdErrorsList(self.PcdError)
@@ -311,6 +465,10 @@ class PcdEntryXml(object):
['DefaultValue', DefaultValue],
['MaxDatumSize', PcdEntry.GetMaxDatumSize()],
]
for Item in PcdEntry.GetPromptList():
Tmp = PromptXml()
NodeList.append(Tmp.ToXml(Item))
for Item in PcdEntry.GetHelpTextList():
Tmp = HelpTextXml()
NodeList.append(Tmp.ToXml(Item))
@@ -400,4 +558,4 @@ class PcdEntryXml(object):
Str = Str + "\n\t" + str(Item)
for Item in self.PcdError:
Str = Str + "\n\tPcdError:" + str(Item)
return Str
return Str

View File

@@ -1,7 +1,7 @@
## @file
# This file is used to parse a xml file of .PKG file
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials are licensed and made available
# under the terms and conditions of the BSD License which accompanies this
@@ -38,7 +38,6 @@ from Logger.StringTable import ERR_XML_INVALID_EXTERN_SUPARCHLIST
from Logger.StringTable import ERR_XML_INVALID_EXTERN_SUPMODLIST
from Logger.StringTable import ERR_XML_INVALID_EXTERN_SUPMODLIST_NOT_LIB
from Logger.StringTable import ERR_FILE_NAME_INVALIDE
from Logger.StringTable import ERR_XML_INVALID_BINARY_FILE_TYPE
from Logger.ToolError import PARSER_ERROR
from Logger.ToolError import FORMAT_INVALID
@@ -78,12 +77,25 @@ class DistributionPackageXml(object):
DpHeader = self.DistP.Header
XmlTreeLevel = ['DistributionPackage', 'DistributionHeader']
CheckDict = Sdict()
if DpHeader.GetAbstract():
DPAbstract = DpHeader.GetAbstract()[0][1]
else:
DPAbstract = ''
if DpHeader.GetCopyright():
DPCopyright = DpHeader.GetCopyright()[0][1]
else:
DPCopyright = ''
if DpHeader.GetLicense():
DPLicense = DpHeader.GetLicense()[0][1]
else:
DPLicense = ''
CheckDict['Name'] = DpHeader.GetName()
CheckDict['GUID'] = DpHeader.GetGuid()
CheckDict['Version'] = DpHeader.GetVersion()
CheckDict['Copyright'] = DpHeader.GetCopyright()
CheckDict['License'] = DpHeader.GetLicense()
CheckDict['Abstract'] = DpHeader.GetAbstract()
CheckDict['Copyright'] = DPCopyright
CheckDict['License'] = DPLicense
CheckDict['Abstract'] = DPAbstract
CheckDict['Vendor'] = DpHeader.GetVendor()
CheckDict['Date'] = DpHeader.GetDate()
CheckDict['XmlSpecification'] = DpHeader.GetXmlSpecification()
@@ -610,11 +622,6 @@ def ValidateMS2(Module, TopXmlTreeLevel):
if Item and len(Item.FileNamList) > 0 and Item.FileNamList[0].FileType == 'FREEFORM':
Item.FileNamList[0].FileType = 'SUBTYPE_GUID'
Module.GetBinaryFileList()[ItemCount] = Item
if Item and len(Item.FileNamList) > 0 and Item.FileNamList[0].FileType == 'DISPOSABLE':
Logger.Error('\nUPT',
PARSER_ERROR,
ERR_XML_INVALID_BINARY_FILE_TYPE % ('DISPOSABLE'),
RaiseError=True)
## ValidateMS3
#
@@ -697,8 +704,7 @@ def ValidateMS3(Module, TopXmlTreeLevel):
for PcdExItem in AsBuilt.PcdExValueList:
CheckDict = {'TokenSpaceGuidValue':PcdExItem.TokenSpaceGuidValue,
'Token':PcdExItem.Token,
'DatumType':PcdExItem.DatumType,
'Value':PcdExItem.DefaultValue}
'DatumType':PcdExItem.DatumType}
XmlTreeLevel = TopXmlTreeLevel + ['BinaryFiles', 'BinaryFile', 'AsBuilt', 'PcdExValue']
IsRequiredItemListNull(CheckDict, XmlTreeLevel)
#

View File

@@ -1,7 +1,7 @@
## @file
# This file is used to parse a xml file of .PKG file
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials are licensed and made available
# under the terms and conditions of the BSD License which accompanies this
@@ -74,7 +74,6 @@ def IsRequiredItemListNull(ItemDict, XmlTreeLevel):
ErrorMsg = ERR_XML_PARSER_REQUIRED_ITEM_MISSING % (Key, Msg)
Logger.Error('\nUPT', PARSER_ERROR, ErrorMsg, RaiseError=True)
## Get help text
#
# @param HelpText
@@ -87,3 +86,16 @@ def GetHelpTextList(HelpText):
HelpTextObj.SetString(HelT.HelpText)
HelpTextList.append(HelpTextObj)
return HelpTextList
## Get Prompt text
#
# @param Prompt
#
def GetPromptList(Prompt):
PromptList = []
for SubPrompt in Prompt:
PromptObj = TextObject()
PromptObj.SetLang(SubPrompt.Lang)
PromptObj.SetString(SubPrompt.Prompt)
PromptList.append(PromptObj)
return PromptList