BaseTools: Clean up source files

1. Do not use tab characters
2. No trailing white space in one line
3. All files must end with CRLF

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
Liming Gao
2018-07-05 17:40:04 +08:00
parent 39456d00f3
commit f7496d7173
289 changed files with 10647 additions and 10647 deletions

View File

@@ -2,11 +2,11 @@
#
# This file is for build version number auto generation
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -17,4 +17,4 @@
Build version information
'''
gBUILD_VERSION = ""
gBUILD_VERSION = "Developer Build based on Revision: Unknown"

View File

@@ -1,11 +1,11 @@
## @file
# This file is for installed package information database operations
#
# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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
#
#
@@ -40,7 +40,7 @@ DEPEX_CHECK_PACKAGE_NOT_FOUND, DEPEX_CHECK_DP_NOT_FOUND) = (0, 1, 2, 3)
## DependencyRules
#
# This class represents the dependency rule check mechanism
#
#
# @param object: Inherited from object class
#
class DependencyRules(object):
@@ -53,7 +53,7 @@ class DependencyRules(object):
# Add package info from the DIST to be installed.
self.PkgsToBeDepend.extend(self.GenToBeInstalledPkgList(ToBeInstalledPkgList))
def GenToBeInstalledPkgList(self, ToBeInstalledPkgList):
if not ToBeInstalledPkgList:
return []
@@ -81,7 +81,7 @@ class DependencyRules(object):
return True
else:
return False
## Check whether a module depex satisfied.
#
# @param ModuleObj: A module object
@@ -101,7 +101,7 @@ class DependencyRules(object):
#
Exist = self.CheckPackageExists(Dep.GetGuid(), Dep.GetVersion())
#
# check whether satisfied by current distribution
# check whether satisfied by current distribution
#
if not Exist:
if DpObj is None:
@@ -119,7 +119,7 @@ class DependencyRules(object):
else:
Result = False
break
if not Result:
Logger.Error("CheckModuleDepex", UNKNOWN_ERROR, \
ST.ERR_DEPENDENCY_NOT_MATCH % (ModuleObj.GetName(), \
@@ -127,7 +127,7 @@ class DependencyRules(object):
Dep.GetGuid(), \
Dep.GetVersion()))
return Result
## Check whether a package exists in a package list specified by PkgsToBeDepend.
#
# @param Guid: Guid of a package
@@ -154,7 +154,7 @@ class DependencyRules(object):
Logger.Verbose(ST.MSG_CHECK_PACKAGE_FINISH)
return Found
## Check whether a package depex satisfied.
#
# @param PkgObj: A package object
@@ -171,7 +171,7 @@ class DependencyRules(object):
else:
return False
return True
## Check whether a DP exists.
#
# @param Guid: Guid of a Distribution
@@ -216,7 +216,7 @@ class DependencyRules(object):
return True, DpObj
## Check whether a DP depex satisfied by current workspace
## Check whether a DP depex satisfied by current workspace
# (excluding the original distribution's packages to be replaced) for Replace
#
# @param DpObj: A distribution object
@@ -243,17 +243,17 @@ class DependencyRules(object):
continue
else:
return False
for ModKey in DpObj.ModuleSurfaceArea.keys():
ModObj = DpObj.ModuleSurfaceArea[ModKey]
if self.CheckModuleDepexSatisfied(ModObj, DpObj):
continue
else:
return False
return True
## Check whether a DP could be removed from current workspace.
## Check whether a DP could be removed from current workspace.
#
# @param DpGuid: File's guid
# @param DpVersion: File's version
@@ -267,7 +267,7 @@ class DependencyRules(object):
#
# remove modules that included in current DP
# List of item (FilePath)
DpModuleList = self.IpiDb.GetDpModuleList(DpGuid, DpVersion)
DpModuleList = self.IpiDb.GetDpModuleList(DpGuid, DpVersion)
for Module in DpModuleList:
if Module in WsModuleList:
WsModuleList.remove(Module)
@@ -277,7 +277,7 @@ class DependencyRules(object):
#
# get packages in current Dp and find the install path
# List of item (PkgGuid, PkgVersion, InstallPath)
DpPackageList = self.IpiDb.GetPackageListFromDp(DpGuid, DpVersion)
DpPackageList = self.IpiDb.GetPackageListFromDp(DpGuid, DpVersion)
DpPackagePathList = []
WorkSP = GlobalData.gWORKSPACE
for (PkgName, PkgGuid, PkgVersion, DecFile) in self.WsPkgList:
@@ -290,18 +290,18 @@ class DependencyRules(object):
else:
InstallPath = DecPath
DecFileRelaPath = DecFile
if (PkgGuid, PkgVersion, InstallPath) in DpPackageList:
DpPackagePathList.append(DecFileRelaPath)
DpPackageList.remove((PkgGuid, PkgVersion, InstallPath))
#
# the left items in DpPackageList are the packages that installed but not found anymore
#
for (PkgGuid, PkgVersion, InstallPath) in DpPackageList:
Logger.Warn("UPT",
ST.WARN_INSTALLED_PACKAGE_NOT_FOUND%(PkgGuid, PkgVersion, InstallPath))
#
# check modules to see if has dependency on package of current DP
#
@@ -320,7 +320,7 @@ class DependencyRules(object):
# @param NewDpPkgList: a list of package information (Guid, Version) in new Dp
# @retval Replaceable: True if distribution could be replaced, False Else
# @retval DependModuleList: the list of modules that make distribution can not be replaced
#
#
def CheckDpDepexForReplace(self, OrigDpGuid, OrigDpVersion, NewDpPkgList):
Replaceable = True
DependModuleList = []
@@ -328,19 +328,19 @@ class DependencyRules(object):
#
# remove modules that included in current DP
# List of item (FilePath)
DpModuleList = self.IpiDb.GetDpModuleList(OrigDpGuid, OrigDpVersion)
DpModuleList = self.IpiDb.GetDpModuleList(OrigDpGuid, OrigDpVersion)
for Module in DpModuleList:
if Module in WsModuleList:
WsModuleList.remove(Module)
else:
Logger.Warn("UPT\n",
ST.ERR_MODULE_NOT_INSTALLED % Module)
OtherPkgList = NewDpPkgList
#
# get packages in current Dp and find the install path
# List of item (PkgGuid, PkgVersion, InstallPath)
DpPackageList = self.IpiDb.GetPackageListFromDp(OrigDpGuid, OrigDpVersion)
DpPackageList = self.IpiDb.GetPackageListFromDp(OrigDpGuid, OrigDpVersion)
DpPackagePathList = []
WorkSP = GlobalData.gWORKSPACE
for (PkgName, PkgGuid, PkgVersion, DecFile) in self.WsPkgList:
@@ -353,7 +353,7 @@ class DependencyRules(object):
else:
InstallPath = DecPath
DecFileRelaPath = DecFile
if (PkgGuid, PkgVersion, InstallPath) in DpPackageList:
DpPackagePathList.append(DecFileRelaPath)
DpPackageList.remove((PkgGuid, PkgVersion, InstallPath))
@@ -366,7 +366,7 @@ class DependencyRules(object):
for (PkgGuid, PkgVersion, InstallPath) in DpPackageList:
Logger.Warn("UPT",
ST.WARN_INSTALLED_PACKAGE_NOT_FOUND%(PkgGuid, PkgVersion, InstallPath))
#
# check modules to see if it can be satisfied by package not belong to removed DP
#
@@ -376,8 +376,8 @@ class DependencyRules(object):
DependModuleList.append(Module)
return (Replaceable, DependModuleList)
## check whether module depends on packages in DpPackagePathList, return True
## check whether module depends on packages in DpPackagePathList, return True
# if found, False else
#
# @param Path: a module path
@@ -432,7 +432,7 @@ def GetPackagePath(InfPath):
# @param DpPackagePathList: a list of Package Paths
# @param OtherPkgList: a list of Package Information (Guid, Version)
# @retval: False: module depends on package in DpPackagePathList and can not be satisfied by OtherPkgList
# True: either module doesn't depend on DpPackagePathList or module depends on DpPackagePathList
# True: either module doesn't depend on DpPackagePathList or module depends on DpPackagePathList
# but can be satisfied by OtherPkgList
#
def VerifyReplaceModuleDep(Path, DpPackagePathList, OtherPkgList):

View File

@@ -1,11 +1,11 @@
## @file
# This file is used to define a class object to describe a distribution package
#
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -50,62 +50,62 @@ class DistributionPackageHeaderObject(IdentificationObject, \
self.Date = ''
self.Signature = 'Md5Sum'
self.XmlSpecification = ''
def GetReadOnly(self):
return self.ReadOnly
def SetReadOnly(self, ReadOnly):
self.ReadOnly = ReadOnly
def GetRePackage(self):
return self.RePackage
def SetRePackage(self, RePackage):
self.RePackage = RePackage
def GetVendor(self):
return self.Vendor
def SetDate(self, Date):
self.Date = Date
def GetDate(self):
return self.Date
def SetSignature(self, Signature):
self.Signature = Signature
def GetSignature(self):
return self.Signature
def SetXmlSpecification(self, XmlSpecification):
self.XmlSpecification = XmlSpecification
def GetXmlSpecification(self):
return self.XmlSpecification
## DistributionPackageClass
#
# @param object: DistributionPackageClass
#
#
class DistributionPackageClass(object):
def __init__(self):
self.Header = DistributionPackageHeaderObject()
#
# {(Guid, Version, Path) : PackageObj}
#
self.PackageSurfaceArea = Sdict()
self.PackageSurfaceArea = Sdict()
#
# {(Guid, Version, Name, Path) : ModuleObj}
#
self.ModuleSurfaceArea = Sdict()
self.ModuleSurfaceArea = Sdict()
self.Tools = MiscFileObject()
self.MiscellaneousFiles = MiscFileObject()
self.UserExtensions = []
self.FileList = []
## Get all included packages and modules for a distribution package
#
#
# @param WorkspaceDir: WorkspaceDir
# @param PackageList: A list of all packages
# @param ModuleList: A list of all modules
@@ -132,7 +132,7 @@ class DistributionPackageClass(object):
WsRelPath = os.path.normpath(WsRelPath)
if ModuleList and WsRelPath in ModuleList:
Logger.Error("UPT",
OPTION_VALUE_INVALID,
OPTION_VALUE_INVALID,
ST.ERR_NOT_STANDALONE_MODULE_ERROR%\
(WsRelPath, PackageFile))
Filename = os.path.normpath\
@@ -140,12 +140,12 @@ class DistributionPackageClass(object):
os.path.splitext(Filename)
#
# Call INF parser to generate Inf Object.
# Actually, this call is not directly call, but wrapped by
# Actually, this call is not directly call, but wrapped by
# Inf class in InfPomAlignment.
#
try:
ModuleObj = InfPomAlignment(Filename, WorkspaceDir, PackageObj.GetPackagePath())
#
# Add module to package
#
@@ -161,7 +161,7 @@ class DistributionPackageClass(object):
ST.WRN_EDK1_INF_FOUND%Filename)
else:
raise
self.PackageSurfaceArea\
[(PackageObj.GetGuid(), PackageObj.GetVersion(), \
PackageObj.GetCombinePath())] = PackageObj
@@ -176,16 +176,16 @@ class DistributionPackageClass(object):
try:
ModuleObj = InfPomAlignment(ModuleFileFullPath, WorkspaceDir)
ModuleKey = (ModuleObj.GetGuid(),
ModuleObj.GetVersion(),
ModuleObj.GetName(),
ModuleKey = (ModuleObj.GetGuid(),
ModuleObj.GetVersion(),
ModuleObj.GetName(),
ModuleObj.GetCombinePath())
self.ModuleSurfaceArea[ModuleKey] = ModuleObj
except FatalError as ErrCode:
if ErrCode.message == EDK1_INF_ERROR:
Logger.Error("UPT",
EDK1_INF_ERROR,
ST.WRN_EDK1_INF_FOUND%ModuleFileFullPath,
ST.WRN_EDK1_INF_FOUND%ModuleFileFullPath,
ExtraData=ST.ERR_NOT_SUPPORTED_SA_MODULE)
else:
raise
@@ -193,16 +193,16 @@ class DistributionPackageClass(object):
# Recover WorkspaceDir
WorkspaceDir = Root
## Get all files included for a distribution package, except tool/misc of
## Get all files included for a distribution package, except tool/misc of
# distribution level
#
#
# @retval DistFileList A list of filepath for NonMetaDataFile, relative to workspace
# @retval MetaDataFileList A list of filepath for MetaDataFile, relative to workspace
#
def GetDistributionFileList(self):
MetaDataFileList = []
SkipModulesUniList = []
for Guid, Version, Path in self.PackageSurfaceArea:
Package = self.PackageSurfaceArea[Guid, Version, Path]
PackagePath = Package.GetPackagePath()
@@ -221,7 +221,7 @@ class DistributionPackageClass(object):
MiscFileFullPath = os.path.normpath(os.path.join(PackagePath, FileObj.GetURI()))
if MiscFileFullPath not in self.FileList:
self.FileList.append(MiscFileFullPath)
Module = None
ModuleDict = Package.GetModuleDict()
for Guid, Version, Name, Path in ModuleDict:
@@ -262,12 +262,12 @@ class DistributionPackageClass(object):
for NonMetaDataFile in NonMetaDataFileList:
if NonMetaDataFile not in self.FileList:
self.FileList.append(NonMetaDataFile)
for SkipModuleUni in SkipModulesUniList:
if SkipModuleUni in self.FileList:
self.FileList.remove(SkipModuleUni)
return self.FileList, MetaDataFileList

View File

@@ -1,11 +1,11 @@
## @file
# This file hooks file and directory creation and removal
#
# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2014 - 2018, 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,

View File

@@ -1,11 +1,11 @@
## @file
# This file is for installed package information database operations
#
# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -33,8 +33,8 @@ import platform as pf
#
# This class represents the installed package information database
# Add/Remove/Get installed distribution package information here.
#
#
#
#
# @param object: Inherited from object class
# @param DbPath: A string for the path of the database
#
@@ -71,16 +71,16 @@ class IpiDatabase(object):
SqlCommand = """
create table %s (
Dummy TEXT NOT NULL,
PRIMARY KEY (Dummy)
PRIMARY KEY (Dummy)
)""" % self.DummyTable
self.Cur.execute(SqlCommand)
self.Conn.commit()
except sqlite3.OperationalError:
Logger.Error("UPT",
UPT_ALREADY_RUNNING_ERROR,
Logger.Error("UPT",
UPT_ALREADY_RUNNING_ERROR,
ST.ERR_UPT_ALREADY_RUNNING_ERROR
)
#
# Create new table
#
@@ -89,12 +89,12 @@ class IpiDatabase(object):
DpGuid TEXT NOT NULL,DpVersion TEXT NOT NULL,
InstallTime REAL NOT NULL,
NewPkgFileName TEXT NOT NULL,
PkgFileName TEXT NOT NULL,
PkgFileName TEXT NOT NULL,
RePackage TEXT NOT NULL,
PRIMARY KEY (DpGuid, DpVersion)
PRIMARY KEY (DpGuid, DpVersion)
)""" % self.DpTable
self.Cur.execute(SqlCommand)
SqlCommand = """
create table IF NOT EXISTS %s (
FilePath TEXT NOT NULL,
@@ -104,7 +104,7 @@ class IpiDatabase(object):
PRIMARY KEY (FilePath)
)""" % self.DpFileListTable
self.Cur.execute(SqlCommand)
SqlCommand = """
create table IF NOT EXISTS %s (
PackageGuid TEXT NOT NULL,
@@ -116,7 +116,7 @@ class IpiDatabase(object):
PRIMARY KEY (PackageGuid, PackageVersion, InstallPath)
)""" % self.PkgTable
self.Cur.execute(SqlCommand)
SqlCommand = """
create table IF NOT EXISTS %s (
ModuleGuid TEXT NOT NULL,
@@ -129,7 +129,7 @@ class IpiDatabase(object):
PRIMARY KEY (ModuleGuid, ModuleVersion, ModuleName, InstallPath)
)""" % self.ModInPkgTable
self.Cur.execute(SqlCommand)
SqlCommand = """
create table IF NOT EXISTS %s (
ModuleGuid TEXT NOT NULL,
@@ -142,7 +142,7 @@ class IpiDatabase(object):
PRIMARY KEY (ModuleGuid, ModuleVersion, ModuleName, InstallPath)
)""" % self.StandaloneModTable
self.Cur.execute(SqlCommand)
SqlCommand = """
create table IF NOT EXISTS %s (
ModuleGuid TEXT NOT NULL,
@@ -153,9 +153,9 @@ class IpiDatabase(object):
DepexVersion TEXT
)""" % self.ModDepexTable
self.Cur.execute(SqlCommand)
self.Conn.commit()
Logger.Verbose(ST.MSG_INIT_IPI_FINISH)
def RollBack(self):
@@ -199,7 +199,7 @@ class IpiDatabase(object):
self._AddDpFilePathList(DpObj.Header.GetGuid(), \
DpObj.Header.GetVersion(), FilePath, \
Md5Sum)
for ModKey in DpObj.ModuleSurfaceArea.keys():
ModGuid = ModKey[0]
ModVersion = ModKey[1]
@@ -219,17 +219,17 @@ class IpiDatabase(object):
self._AddDpFilePathList(DpObj.Header.GetGuid(), \
DpObj.Header.GetVersion(), \
Path, Md5Sum)
#
# add tool/misc files
#
for (Path, Md5Sum) in DpObj.FileList:
self._AddDpFilePathList(DpObj.Header.GetGuid(), \
DpObj.Header.GetVersion(), Path, Md5Sum)
self._AddDp(DpObj.Header.GetGuid(), DpObj.Header.GetVersion(), \
NewDpPkgFileName, DpPkgFileName, RePackage)
except sqlite3.IntegrityError as DetailMsg:
Logger.Error("UPT",
UPT_DB_UPDATE_ERROR,
@@ -239,17 +239,17 @@ class IpiDatabase(object):
## Add a distribution install information
#
# @param Guid Guid of the distribution package
# @param Version Version of the distribution package
# @param Guid Guid of the distribution package
# @param Version Version of the distribution package
# @param NewDpFileName the saved filename of distribution package file
# @param DistributionFileName the filename of distribution package file
#
def _AddDp(self, Guid, Version, NewDpFileName, DistributionFileName, \
RePackage):
if Version is None or len(Version.strip()) == 0:
Version = 'N/A'
#
# Add newly installed DP information to DB.
#
@@ -264,10 +264,10 @@ class IpiDatabase(object):
DistributionFileName, str(RePackage).upper())
self.Cur.execute(SqlCommand)
## Add a file list from DP
#
# @param DpGuid: A DpGuid
# @param DpGuid: A DpGuid
# @param DpVersion: A DpVersion
# @param Path: A Path
# @param Path: A Md5Sum
@@ -284,26 +284,26 @@ class IpiDatabase(object):
(self.DpFileListTable, Path, DpGuid, DpVersion, Md5Sum)
self.Cur.execute(SqlCommand)
## Add a package install information
#
# @param Guid: A package guid
# @param Guid: A package guid
# @param Version: A package version
# @param DpGuid: A DpGuid
# @param DpGuid: A DpGuid
# @param DpVersion: A DpVersion
# @param Path: A Path
#
def _AddPackage(self, Guid, Version, DpGuid=None, DpVersion=None, Path=''):
if Version is None or len(Version.strip()) == 0:
Version = 'N/A'
if DpGuid is None or len(DpGuid.strip()) == 0:
DpGuid = 'N/A'
if DpVersion is None or len(DpVersion.strip()) == 0:
DpVersion = 'N/A'
#
# Add newly installed package information to DB.
#
@@ -312,10 +312,10 @@ class IpiDatabase(object):
"""insert into %s values('%s', '%s', %s, '%s', '%s', '%s')""" % \
(self.PkgTable, Guid, Version, CurrentTime, DpGuid, DpVersion, Path)
self.Cur.execute(SqlCommand)
## Add a module that from a package install information
#
# @param Guid: Module Guid
# @param Guid: Module Guid
# @param Version: Module version
# @param Name: Module Name
# @param PkgGuid: Package Guid
@@ -324,21 +324,21 @@ class IpiDatabase(object):
#
def _AddModuleInPackage(self, Guid, Version, Name, PkgGuid=None, \
PkgVersion=None, Path=''):
if Version is None or len(Version.strip()) == 0:
Version = 'N/A'
if PkgGuid is None or len(PkgGuid.strip()) == 0:
PkgGuid = 'N/A'
if PkgVersion is None or len(PkgVersion.strip()) == 0:
PkgVersion = 'N/A'
if os.name == 'posix':
Path = Path.replace('\\', os.sep)
else:
Path = Path.replace('/', os.sep)
#
# Add module from package information to DB.
#
@@ -348,7 +348,7 @@ class IpiDatabase(object):
(self.ModInPkgTable, Guid, Version, Name, CurrentTime, PkgGuid, PkgVersion, \
Path)
self.Cur.execute(SqlCommand)
## Add a module that is standalone install information
#
# @param Guid: a module Guid
@@ -360,16 +360,16 @@ class IpiDatabase(object):
#
def _AddStandaloneModule(self, Guid, Version, Name, DpGuid=None, \
DpVersion=None, Path=''):
if Version is None or len(Version.strip()) == 0:
Version = 'N/A'
if DpGuid is None or len(DpGuid.strip()) == 0:
DpGuid = 'N/A'
if DpVersion is None or len(DpVersion.strip()) == 0:
DpVersion = 'N/A'
#
# Add module standalone information to DB.
#
@@ -379,7 +379,7 @@ class IpiDatabase(object):
(self.StandaloneModTable, Guid, Version, Name, CurrentTime, DpGuid, \
DpVersion, Path)
self.Cur.execute(SqlCommand)
## Add a module depex
#
# @param Guid: a module Guid
@@ -390,49 +390,49 @@ class IpiDatabase(object):
#
def _AddModuleDepex(self, Guid, Version, Name, Path, DepexGuid=None, \
DepexVersion=None):
if DepexGuid is None or len(DepexGuid.strip()) == 0:
DepexGuid = 'N/A'
if DepexVersion is None or len(DepexVersion.strip()) == 0:
DepexVersion = 'N/A'
if os.name == 'posix':
Path = Path.replace('\\', os.sep)
else:
Path = Path.replace('/', os.sep)
#
# Add module depex information to DB.
#
SqlCommand = """insert into %s values('%s', '%s', '%s', '%s', '%s', '%s')"""\
% (self.ModDepexTable, Guid, Version, Name, Path, DepexGuid, DepexVersion)
self.Cur.execute(SqlCommand)
## Remove a distribution install information, if no version specified,
## Remove a distribution install information, if no version specified,
# remove all DPs with this Guid.
#
# @param DpGuid: guid of dpex
# @param DpGuid: guid of dpex
# @param DpVersion: version of dpex
#
def RemoveDpObj(self, DpGuid, DpVersion):
PkgList = self.GetPackageListFromDp(DpGuid, DpVersion)
#
# delete from ModDepex the standalone module's dependency
#
SqlCommand = \
"""delete from ModDepexInfo where ModDepexInfo.ModuleGuid in
(select ModuleGuid from StandaloneModInfo as B where B.DpGuid = '%s'
"""delete from ModDepexInfo where ModDepexInfo.ModuleGuid in
(select ModuleGuid from StandaloneModInfo as B where B.DpGuid = '%s'
and B.DpVersion = '%s')
and ModDepexInfo.ModuleVersion in
(select ModuleVersion from StandaloneModInfo as B
(select ModuleVersion from StandaloneModInfo as B
where B.DpGuid = '%s' and B.DpVersion = '%s')
and ModDepexInfo.ModuleName in
(select ModuleName from StandaloneModInfo as B
(select ModuleName from StandaloneModInfo as B
where B.DpGuid = '%s' and B.DpVersion = '%s')
and ModDepexInfo.InstallPath in
(select InstallPath from StandaloneModInfo as B
(select InstallPath from StandaloneModInfo as B
where B.DpGuid = '%s' and B.DpVersion = '%s') """ % \
(DpGuid, DpVersion, DpGuid, DpVersion, DpGuid, DpVersion, DpGuid, DpVersion)
@@ -443,24 +443,24 @@ class IpiDatabase(object):
for Pkg in PkgList:
SqlCommand = \
"""delete from ModDepexInfo where ModDepexInfo.ModuleGuid in
(select ModuleGuid from ModInPkgInfo
where ModInPkgInfo.PackageGuid ='%s' and
"""delete from ModDepexInfo where ModDepexInfo.ModuleGuid in
(select ModuleGuid from ModInPkgInfo
where ModInPkgInfo.PackageGuid ='%s' and
ModInPkgInfo.PackageVersion = '%s')
and ModDepexInfo.ModuleVersion in
(select ModuleVersion from ModInPkgInfo
where ModInPkgInfo.PackageGuid ='%s' and
(select ModuleVersion from ModInPkgInfo
where ModInPkgInfo.PackageGuid ='%s' and
ModInPkgInfo.PackageVersion = '%s')
and ModDepexInfo.ModuleName in
(select ModuleName from ModInPkgInfo
where ModInPkgInfo.PackageGuid ='%s' and
(select ModuleName from ModInPkgInfo
where ModInPkgInfo.PackageGuid ='%s' and
ModInPkgInfo.PackageVersion = '%s')
and ModDepexInfo.InstallPath in
(select InstallPath from ModInPkgInfo where
ModInPkgInfo.PackageGuid ='%s'
(select InstallPath from ModInPkgInfo where
ModInPkgInfo.PackageGuid ='%s'
and ModInPkgInfo.PackageVersion = '%s')""" \
% (Pkg[0], Pkg[1], Pkg[0], Pkg[1], Pkg[0], Pkg[1], Pkg[0], Pkg[1])
self.Cur.execute(SqlCommand)
#
# delete the standalone module
@@ -474,7 +474,7 @@ class IpiDatabase(object):
#
for Pkg in PkgList:
SqlCommand = \
"""delete from %s where %s.PackageGuid ='%s'
"""delete from %s where %s.PackageGuid ='%s'
and %s.PackageVersion = '%s'""" % \
(self.ModInPkgTable, self.ModInPkgTable, Pkg[0], \
self.ModInPkgTable, Pkg[1])
@@ -493,23 +493,23 @@ class IpiDatabase(object):
"""delete from %s where DpGuid ='%s' and DpVersion = '%s'""" % \
(self.DpFileListTable, DpGuid, DpVersion)
self.Cur.execute(SqlCommand)
#
#
# delete DP
#
SqlCommand = \
"""delete from %s where DpGuid ='%s' and DpVersion = '%s'""" % \
(self.DpTable, DpGuid, DpVersion)
self.Cur.execute(SqlCommand)
#self.Conn.commit()
## Get a list of distribution install information.
#
# @param Guid: distribution package guid
# @param Version: distribution package version
# @param Guid: distribution package guid
# @param Version: distribution package version
#
def GetDp(self, Guid, Version):
if Version is None or len(Version.strip()) == 0:
Version = 'N/A'
Logger.Verbose(ST.MSG_GET_DP_INSTALL_LIST)
@@ -517,7 +517,7 @@ class IpiDatabase(object):
SqlCommand = """select * from %s where DpGuid ='%s'""" % \
(self.DpTable, DpGuid)
self.Cur.execute(SqlCommand)
else:
Logger.Verbose(ST.MSG_GET_DP_INSTALL_INFO_START)
(DpGuid, DpVersion) = (Guid, Version)
@@ -533,14 +533,14 @@ class IpiDatabase(object):
InstallTime = DpInfo[2]
PkgFileName = DpInfo[3]
DpList.append((DpGuid, DpVersion, InstallTime, PkgFileName))
Logger.Verbose(ST.MSG_GET_DP_INSTALL_INFO_FINISH)
Logger.Verbose(ST.MSG_GET_DP_INSTALL_INFO_FINISH)
return DpList
## Get a list of distribution install dirs
#
# @param Guid: distribution package guid
# @param Version: distribution package version
# @param Guid: distribution package guid
# @param Version: distribution package version
#
def GetDpInstallDirList(self, Guid, Version):
SqlCommand = """select InstallPath from PkgInfo where DpGuid = '%s' and DpVersion = '%s'""" % (Guid, Version)
@@ -562,11 +562,11 @@ class IpiDatabase(object):
## Get a list of distribution install file path information.
#
# @param Guid: distribution package guid
# @param Version: distribution package version
# @param Guid: distribution package guid
# @param Version: distribution package version
#
def GetDpFileList(self, Guid, Version):
(DpGuid, DpVersion) = (Guid, Version)
SqlCommand = \
"""select * from %s where DpGuid ='%s' and DpVersion = '%s'""" % \
@@ -578,7 +578,7 @@ class IpiDatabase(object):
Path = Result[0]
Md5Sum = Result[3]
PathList.append((os.path.join(self.Workspace, Path), Md5Sum))
return PathList
## Get files' repackage attribute if present that are installed into current workspace
@@ -588,12 +588,12 @@ class IpiDatabase(object):
def GetRePkgDict(self):
SqlCommand = """select * from %s """ % (self.DpTable)
self.Cur.execute(SqlCommand)
DpInfoList = []
for Result in self.Cur:
DpInfoList.append(Result)
FileDict = {}
FileDict = {}
for Result in DpInfoList:
DpGuid = Result[0]
DpVersion = Result[1]
@@ -606,12 +606,12 @@ class IpiDatabase(object):
for FileInfo in self.GetDpFileList(DpGuid, DpVersion):
PathInfo = FileInfo[0]
FileDict[PathInfo] = DpGuid, DpVersion, NewDpFileName, RePackage
return FileDict
## Get (Guid, Version) from distribution file name information.
#
# @param DistributionFile: Distribution File
# @param DistributionFile: Distribution File
#
def GetDpByName(self, DistributionFile):
SqlCommand = """select * from %s where NewPkgFileName = '%s'""" % \
@@ -622,34 +622,34 @@ class IpiDatabase(object):
DpGuid = Result[0]
DpVersion = Result[1]
NewDpFileName = Result[3]
return (DpGuid, DpVersion, NewDpFileName)
else:
return (None, None, None)
## Get a list of package information.
#
# @param Guid: package guid
# @param Guid: package guid
# @param Version: package version
#
def GetPackage(self, Guid, Version, DpGuid='', DpVersion=''):
if DpVersion == '' or DpGuid == '':
(PackageGuid, PackageVersion) = (Guid, Version)
SqlCommand = """select * from %s where PackageGuid ='%s'
SqlCommand = """select * from %s where PackageGuid ='%s'
and PackageVersion = '%s'""" % (self.PkgTable, PackageGuid, \
PackageVersion)
self.Cur.execute(SqlCommand)
elif Version is None or len(Version.strip()) == 0:
SqlCommand = """select * from %s where PackageGuid ='%s'""" % \
(self.PkgTable, Guid)
self.Cur.execute(SqlCommand)
else:
(PackageGuid, PackageVersion) = (Guid, Version)
SqlCommand = """select * from %s where PackageGuid ='%s' and
SqlCommand = """select * from %s where PackageGuid ='%s' and
PackageVersion = '%s'
and DpGuid = '%s' and DpVersion = '%s'""" % \
(self.PkgTable, PackageGuid, PackageVersion, \
@@ -664,10 +664,10 @@ class IpiDatabase(object):
InstallPath = PkgInfo[5]
PkgList.append((PkgGuid, PkgVersion, InstallTime, DpGuid, \
DpVersion, InstallPath))
return PkgList
## Get a list of module in package information.
#
# @param Guid: A module guid
@@ -676,15 +676,15 @@ class IpiDatabase(object):
def GetModInPackage(self, Guid, Version, Name, Path, PkgGuid='', PkgVersion=''):
(ModuleGuid, ModuleVersion, ModuleName, InstallPath) = (Guid, Version, Name, Path)
if PkgVersion == '' or PkgGuid == '':
SqlCommand = """select * from %s where ModuleGuid ='%s' and
ModuleVersion = '%s' and InstallPath = '%s'
SqlCommand = """select * from %s where ModuleGuid ='%s' and
ModuleVersion = '%s' and InstallPath = '%s'
and ModuleName = '%s'""" % (self.ModInPkgTable, ModuleGuid, \
ModuleVersion, InstallPath, ModuleName)
self.Cur.execute(SqlCommand)
else:
SqlCommand = """select * from %s where ModuleGuid ='%s' and
ModuleVersion = '%s' and InstallPath = '%s'
and ModuleName = '%s' and PackageGuid ='%s'
SqlCommand = """select * from %s where ModuleGuid ='%s' and
ModuleVersion = '%s' and InstallPath = '%s'
and ModuleName = '%s' and PackageGuid ='%s'
and PackageVersion = '%s'
""" % (self.ModInPkgTable, ModuleGuid, \
ModuleVersion, InstallPath, ModuleName, PkgGuid, PkgVersion)
@@ -698,26 +698,26 @@ class IpiDatabase(object):
InstallPath = ModInfo[5]
ModList.append((ModGuid, ModVersion, InstallTime, PkgGuid, \
PkgVersion, InstallPath))
return ModList
## Get a list of module standalone.
#
# @param Guid: A module guid
# @param Version: A module version
# @param Guid: A module guid
# @param Version: A module version
#
def GetStandaloneModule(self, Guid, Version, Name, Path, DpGuid='', DpVersion=''):
(ModuleGuid, ModuleVersion, ModuleName, InstallPath) = (Guid, Version, Name, Path)
if DpGuid == '':
SqlCommand = """select * from %s where ModuleGuid ='%s' and
ModuleVersion = '%s' and InstallPath = '%s'
SqlCommand = """select * from %s where ModuleGuid ='%s' and
ModuleVersion = '%s' and InstallPath = '%s'
and ModuleName = '%s'""" % (self.StandaloneModTable, ModuleGuid, \
ModuleVersion, InstallPath, ModuleName)
self.Cur.execute(SqlCommand)
else:
SqlCommand = """select * from %s where ModuleGuid ='%s' and
ModuleVersion = '%s' and InstallPath = '%s' and ModuleName = '%s' and DpGuid ='%s' and DpVersion = '%s'
SqlCommand = """select * from %s where ModuleGuid ='%s' and
ModuleVersion = '%s' and InstallPath = '%s' and ModuleName = '%s' and DpGuid ='%s' and DpVersion = '%s'
""" % (self.StandaloneModTable, ModuleGuid, \
ModuleVersion, ModuleName, InstallPath, DpGuid, DpVersion)
self.Cur.execute(SqlCommand)
@@ -730,18 +730,18 @@ class IpiDatabase(object):
InstallPath = ModInfo[5]
ModList.append((ModGuid, ModVersion, InstallTime, DpGuid, \
DpVersion, InstallPath))
return ModList
## Get a list of module information that comes from DP.
#
# @param DpGuid: A Distrabution Guid
# @param DpVersion: A Distrabution version
# @param DpGuid: A Distrabution Guid
# @param DpVersion: A Distrabution version
#
def GetSModInsPathListFromDp(self, DpGuid, DpVersion):
PathList = []
SqlCommand = """select InstallPath from %s where DpGuid ='%s'
SqlCommand = """select InstallPath from %s where DpGuid ='%s'
and DpVersion = '%s'
""" % (self.StandaloneModTable, DpGuid, DpVersion)
self.Cur.execute(SqlCommand)
@@ -749,17 +749,17 @@ class IpiDatabase(object):
for Result in self.Cur:
InstallPath = Result[0]
PathList.append(InstallPath)
return PathList
## Get a list of package information.
#
# @param DpGuid: A Distrabution Guid
# @param DpVersion: A Distrabution version
# @param DpGuid: A Distrabution Guid
# @param DpVersion: A Distrabution version
#
def GetPackageListFromDp(self, DpGuid, DpVersion):
SqlCommand = """select * from %s where DpGuid ='%s' and
SqlCommand = """select * from %s where DpGuid ='%s' and
DpVersion = '%s' """ % (self.PkgTable, DpGuid, DpVersion)
self.Cur.execute(SqlCommand)
@@ -769,31 +769,31 @@ class IpiDatabase(object):
PkgVersion = PkgInfo[1]
InstallPath = PkgInfo[5]
PkgList.append((PkgGuid, PkgVersion, InstallPath))
return PkgList
## Get a list of modules that depends on package information from a DP.
#
# @param DpGuid: A Distrabution Guid
# @param DpVersion: A Distrabution version
# @param DpGuid: A Distrabution Guid
# @param DpVersion: A Distrabution version
#
def GetDpDependentModuleList(self, DpGuid, DpVersion):
ModList = []
PkgList = self.GetPackageListFromDp(DpGuid, DpVersion)
if len(PkgList) > 0:
return ModList
for Pkg in PkgList:
#
# get all in-package modules that depends on current
# Pkg (Guid match, Version match or NA) but not belong to
# get all in-package modules that depends on current
# Pkg (Guid match, Version match or NA) but not belong to
# current Pkg
#
SqlCommand = """select t1.ModuleGuid, t1.ModuleVersion,
t1.InstallPath from %s as t1, %s as t2 where
t1.ModuleGuid = t2.ModuleGuid and
t1.ModuleVersion = t2.ModuleVersion and t2.DepexGuid ='%s'
SqlCommand = """select t1.ModuleGuid, t1.ModuleVersion,
t1.InstallPath from %s as t1, %s as t2 where
t1.ModuleGuid = t2.ModuleGuid and
t1.ModuleVersion = t2.ModuleVersion and t2.DepexGuid ='%s'
and (t2.DepexVersion = '%s' or t2.DepexVersion = 'N/A') and
t1.PackageGuid != '%s' and t1.PackageVersion != '%s'
""" % (self.ModInPkgTable, \
@@ -807,13 +807,13 @@ class IpiDatabase(object):
ModList.append((ModGuid, ModVersion, InstallPath))
#
# get all modules from standalone modules that depends on current
# get all modules from standalone modules that depends on current
#Pkg (Guid match, Version match or NA) but not in current dp
#
SqlCommand = \
"""select t1.ModuleGuid, t1.ModuleVersion, t1.InstallPath
from %s as t1, %s as t2 where t1.ModuleGuid = t2.ModuleGuid and
t1.ModuleVersion = t2.ModuleVersion and t2.DepexGuid ='%s'
"""select t1.ModuleGuid, t1.ModuleVersion, t1.InstallPath
from %s as t1, %s as t2 where t1.ModuleGuid = t2.ModuleGuid and
t1.ModuleVersion = t2.ModuleVersion and t2.DepexGuid ='%s'
and (t2.DepexVersion = '%s' or t2.DepexVersion = 'N/A') and
t1.DpGuid != '%s' and t1.DpVersion != '%s'
""" % \
@@ -825,75 +825,75 @@ class IpiDatabase(object):
ModVersion = ModInfo[1]
InstallPath = ModInfo[2]
ModList.append((ModGuid, ModVersion, InstallPath))
return ModList
## Get Dp's list of modules.
#
# @param DpGuid: A Distrabution Guid
# @param DpVersion: A Distrabution version
# @param DpGuid: A Distrabution Guid
# @param DpVersion: A Distrabution version
#
def GetDpModuleList(self, DpGuid, DpVersion):
def GetDpModuleList(self, DpGuid, DpVersion):
ModList = []
#
# get Dp module list from the DpFileList table
#
SqlCommand = """select FilePath
SqlCommand = """select FilePath
from %s
where DpGuid = '%s' and DpVersion = '%s' and
where DpGuid = '%s' and DpVersion = '%s' and
FilePath like '%%.inf'
""" % (self.DpFileListTable, DpGuid, DpVersion)
self.Cur.execute(SqlCommand)
for ModuleInfo in self.Cur:
FilePath = ModuleInfo[0]
ModList.append(os.path.join(self.Workspace, FilePath))
return ModList
return ModList
## Get a module depex
#
# @param DpGuid: A module Guid
# @param DpVersion: A module version
# @param DpGuid: A module Guid
# @param DpVersion: A module version
# @param Path:
#
def GetModuleDepex(self, Guid, Version, Path):
#
# Get module depex information to DB.
#
SqlCommand = """select * from %s where ModuleGuid ='%s' and
SqlCommand = """select * from %s where ModuleGuid ='%s' and
ModuleVersion = '%s' and InstallPath ='%s'
""" % (self.ModDepexTable, Guid, Version, Path)
self.Cur.execute(SqlCommand)
DepexList = []
for DepInfo in self.Cur:
DepexGuid = DepInfo[3]
DepexVersion = DepInfo[4]
DepexList.append((DepexGuid, DepexVersion))
return DepexList
## Inventory the distribution installed to current workspace
#
# Inventory the distribution installed to current workspace
#
#
def InventoryDistInstalled(self):
SqlCommand = """select * from %s """ % (self.DpTable)
self.Cur.execute(SqlCommand)
DpInfoList = []
for Result in self.Cur:
DpGuid = Result[0]
DpVersion = Result[1]
DpAliasName = Result[3]
DpFileName = Result[4]
DpFileName = Result[4]
DpInfoList.append((DpGuid, DpVersion, DpFileName, DpAliasName))
return DpInfoList
return DpInfoList
## Close entire database
#
@@ -904,18 +904,18 @@ class IpiDatabase(object):
# drop the dummy table
#
SqlCommand = """
drop table IF EXISTS %s
drop table IF EXISTS %s
""" % self.DummyTable
self.Cur.execute(SqlCommand)
self.Conn.commit()
self.Cur.close()
self.Conn.close()
## Convert To Sql String
#
# 1. Replace "'" with "''" in each item of StringList
#
#
# @param StringList: A list for strings to be converted
#
def __ConvertToSqlString(self, StringList):
@@ -925,4 +925,4 @@ class IpiDatabase(object):

View File

@@ -2,11 +2,11 @@
#
# PackageFile class represents the zip file of a distribution package.
#
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -52,25 +52,25 @@ class PackageFile:
for Filename in self._ZipFile.namelist():
self._Files[os.path.normpath(Filename)] = Filename
except BaseException as Xstr:
Logger.Error("PackagingTool", FILE_OPEN_FAILURE,
Logger.Error("PackagingTool", FILE_OPEN_FAILURE,
ExtraData="%s (%s)" % (FileName, str(Xstr)))
BadFile = self._ZipFile.testzip()
if BadFile is not None:
Logger.Error("PackagingTool", FILE_CHECKSUM_FAILURE,
Logger.Error("PackagingTool", FILE_CHECKSUM_FAILURE,
ExtraData="[%s] in %s" % (BadFile, FileName))
def GetZipFile(self):
return self._ZipFile
## Get file name
## Get file name
#
def __str__(self):
return self._FileName
## Extract the file
#
# @param To: the destination file
#
# @param To: the destination file
#
def Unpack(self, ToDest):
for FileN in self._ZipFile.namelist():
@@ -78,11 +78,11 @@ class PackageFile:
Msg = "%s -> %s" % (FileN, ToFile)
Logger.Info(Msg)
self.Extract(FileN, ToFile)
## Extract the file
#
# @param File: the extracted file
# @param ToFile: the destination file
#
# @param File: the extracted file
# @param ToFile: the destination file
#
def UnpackFile(self, File, ToFile):
File = File.replace('\\', '/')
@@ -91,13 +91,13 @@ class PackageFile:
Logger.Info(Msg)
self.Extract(File, ToFile)
return ToFile
return ''
## Extract the file
#
# @param Which: the source path
# @param ToDest: the destination path
#
# @param Which: the source path
# @param ToDest: the destination path
#
def Extract(self, Which, ToDest):
Which = os.path.normpath(Which)
@@ -107,7 +107,7 @@ class PackageFile:
try:
FileContent = self._ZipFile.read(self._Files[Which])
except BaseException as Xstr:
Logger.Error("PackagingTool", FILE_DECOMPRESS_FAILURE,
Logger.Error("PackagingTool", FILE_DECOMPRESS_FAILURE,
ExtraData="[%s] in %s (%s)" % (Which, \
self._FileName, \
str(Xstr)))
@@ -120,19 +120,19 @@ class PackageFile:
else:
ToFile = __FileHookOpen__(ToDest, 'wb')
except BaseException as Xstr:
Logger.Error("PackagingTool", FILE_OPEN_FAILURE,
Logger.Error("PackagingTool", FILE_OPEN_FAILURE,
ExtraData="%s (%s)" % (ToDest, str(Xstr)))
try:
ToFile.write(FileContent)
ToFile.close()
except BaseException as Xstr:
Logger.Error("PackagingTool", FILE_WRITE_FAILURE,
Logger.Error("PackagingTool", FILE_WRITE_FAILURE,
ExtraData="%s (%s)" % (ToDest, str(Xstr)))
## Remove the file
#
# @param Files: the removed files
#
# @param Files: the removed files
#
def Remove(self, Files):
TmpDir = os.path.join(tempfile.gettempdir(), ".packaging")
@@ -144,7 +144,7 @@ class PackageFile:
for SinF in Files:
SinF = os.path.normpath(SinF)
if SinF not in self._Files:
Logger.Error("PackagingTool", FILE_NOT_FOUND,
Logger.Error("PackagingTool", FILE_NOT_FOUND,
ExtraData="%s is not in %s!" % \
(SinF, self._FileName))
self._Files.pop(SinF)
@@ -159,12 +159,12 @@ class PackageFile:
RemoveDirectory(TmpDir, True)
## Pack the files under Top directory, the directory shown in the zipFile start from BaseDir,
# BaseDir should be the parent directory of the Top directory, for example,
# Pack(Workspace\Dir1, Workspace) will pack files under Dir1, and the path in the zipfile will
# BaseDir should be the parent directory of the Top directory, for example,
# Pack(Workspace\Dir1, Workspace) will pack files under Dir1, and the path in the zipfile will
# start from Workspace
#
# @param Top: the top directory
# @param BaseDir: the base directory
#
# @param Top: the top directory
# @param BaseDir: the base directory
#
def Pack(self, Top, BaseDir):
if not os.path.isdir(Top):
@@ -175,14 +175,14 @@ class PackageFile:
Cwd = os.getcwd()
os.chdir(BaseDir)
RelaDir = Top[Top.upper().find(BaseDir.upper()).\
join(len(BaseDir).join(1)):]
join(len(BaseDir).join(1)):]
for Root, Dirs, Files in os.walk(RelaDir):
if 'CVS' in Dirs:
Dirs.remove('CVS')
if '.svn' in Dirs:
Dirs.remove('.svn')
for Dir in Dirs:
if Dir.startswith('.'):
Dirs.remove(Dir)
@@ -200,8 +200,8 @@ class PackageFile:
os.chdir(Cwd)
## Pack the file
#
# @param Files: the files to pack
#
# @param Files: the files to pack
#
def PackFiles(self, Files):
for File in Files:
@@ -211,9 +211,9 @@ class PackageFile:
os.chdir(Cwd)
## Pack the file
#
# @param File: the files to pack
# @param ArcName: the Arc Name
#
# @param File: the files to pack
# @param ArcName: the Arc Name
#
def PackFile(self, File, ArcName=None):
try:
@@ -221,7 +221,7 @@ class PackageFile:
# avoid packing same file multiple times
#
if platform.system() != 'Windows':
File = File.replace('\\', '/')
File = File.replace('\\', '/')
ZipedFilesNameList = self._ZipFile.namelist()
for ZipedFile in ZipedFilesNameList:
if File == os.path.normpath(ZipedFile):
@@ -233,9 +233,9 @@ class PackageFile:
ExtraData="%s (%s)" % (File, str(Xstr)))
## Write data to the packed file
#
# @param Data: data to write
# @param ArcName: the Arc Name
#
# @param Data: data to write
# @param ArcName: the Arc Name
#
def PackData(self, Data, ArcName):
try:
@@ -247,7 +247,7 @@ class PackageFile:
ExtraData="%s (%s)" % (ArcName, str(Xstr)))
## Close file
#
#
#
def Close(self):
self._ZipFile.close()

View File

@@ -4,11 +4,11 @@
# This file is required to make Python interpreter treat the directory
# as containing package.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -17,4 +17,4 @@
'''
Core init file
'''
'''

View File

@@ -4,9 +4,9 @@
#
# Copyright (c) 2011 - 2018, 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,
@@ -70,7 +70,7 @@ from Library.StringUtils import GetUniFileName
def GenPcd(Package, Content):
#
# generate [Pcd] section
# <TokenSpcCName>.<TokenCName>|<Value>|<DatumType>|<Token>
# <TokenSpcCName>.<TokenCName>|<Value>|<DatumType>|<Token>
#
ValidUsageDict = {}
for Pcd in Package.GetPcdList():
@@ -80,16 +80,16 @@ def GenPcd(Package, Content):
HelpTextList = Pcd.GetHelpTextList()
HelpStr = _GetHelpStr(HelpTextList)
CommentStr = GenGenericCommentF(HelpStr, 2)
PromptList = Pcd.GetPromptList()
PromptStr = _GetHelpStr(PromptList)
CommentStr += GenGenericCommentF(PromptStr.strip(), 1, True)
PcdErrList = Pcd.GetPcdErrorsList()
for PcdErr in PcdErrList:
CommentStr += GenPcdErrComment(PcdErr)
Statement = CommentStr
CName = Pcd.GetCName()
TokenSpaceGuidCName = Pcd.GetTokenSpaceGuidCName()
DefaultValue = Pcd.GetDefaultValue()
@@ -107,7 +107,7 @@ def GenPcd(Package, Content):
ValidUsage = 'PcdsDynamic'
elif ValidUsage == 'PcdEx':
ValidUsage = 'PcdsDynamicEx'
if ValidUsage in ValidUsageDict:
NewSectionDict = ValidUsageDict[ValidUsage]
else:
@@ -129,17 +129,17 @@ def GenPcd(Package, Content):
NewSectionDict[SortedArch] = \
NewSectionDict[SortedArch] + [Statement]
else:
NewSectionDict[SortedArch] = [Statement]
NewSectionDict[SortedArch] = [Statement]
for ValidUsage in ValidUsageDict:
Content += GenSection(ValidUsage, ValidUsageDict[ValidUsage], True, True)
return Content
def GenPcdErrorMsgSection(Package, Content):
if not Package.PcdErrorCommentDict:
return Content
#
# Generate '# [Error.<TokenSpcCName>]' section
#
@@ -148,14 +148,14 @@ def GenPcdErrorMsgSection(Package, Content):
SectionComment += TAB_COMMENT_SPLIT + TAB_SPACE_SPLIT + TAB_PCD_ERROR_SECTION_COMMENT + END_OF_LINE
SectionComment += TAB_COMMENT_SPLIT + END_OF_LINE
TokenSpcCNameList = []
#
# Get TokenSpcCName list in PcdErrorCommentDict in Package object
#
for (TokenSpcCName, ErrorNumber) in Package.PcdErrorCommentDict:
if TokenSpcCName not in TokenSpcCNameList:
TokenSpcCNameList.append(TokenSpcCName)
for TokenSpcCNameItem in TokenSpcCNameList:
SectionName = TAB_COMMENT_SPLIT + TAB_SPACE_SPLIT + TAB_SECTION_START + TAB_PCD_ERROR + \
TAB_SPLIT + TokenSpcCNameItem + TAB_SECTION_END + END_OF_LINE
@@ -168,10 +168,10 @@ def GenPcdErrorMsgSection(Package, Content):
ErrorNumber + TAB_SPACE_SPLIT + TAB_VALUE_SPLIT + TAB_SPACE_SPLIT + \
PcdErrorMsg + END_OF_LINE
Content += SectionItem
Content += TAB_COMMENT_SPLIT
return Content
def GenGuidProtocolPpi(Package, Content):
#
# generate [Guids] section
@@ -203,17 +203,17 @@ def GenGuidProtocolPpi(Package, Content):
# generate tail comment
#
if Guid.GetSupModuleList():
Statement += GenDecTailComment(Guid.GetSupModuleList())
Statement += GenDecTailComment(Guid.GetSupModuleList())
ArchList = sorted(Guid.GetSupArchList())
SortedArch = ' '.join(ArchList)
if SortedArch in NewSectionDict:
NewSectionDict[SortedArch] = \
NewSectionDict[SortedArch] + [Statement]
else:
NewSectionDict[SortedArch] = [Statement]
NewSectionDict[SortedArch] = [Statement]
Content += GenSection('Guids', NewSectionDict, True, True)
#
# generate [Protocols] section
#
@@ -232,9 +232,9 @@ def GenGuidProtocolPpi(Package, Content):
#
HelpTextList = Protocol.GetHelpTextList()
HelpStr = _GetHelpStr(HelpTextList)
CommentStr = GenGenericCommentF(HelpStr, 2)
CommentStr = GenGenericCommentF(HelpStr, 2)
Statement = CommentStr
Statement = CommentStr
CName = Protocol.GetCName()
Value = GuidStringToGuidStructureString(Protocol.GetGuid())
Statement += CName.ljust(LeftOffset) + ' = ' + Value
@@ -250,9 +250,9 @@ def GenGuidProtocolPpi(Package, Content):
NewSectionDict[SortedArch] = \
NewSectionDict[SortedArch] + [Statement]
else:
NewSectionDict[SortedArch] = [Statement]
NewSectionDict[SortedArch] = [Statement]
Content += GenSection('Protocols', NewSectionDict, True, True)
Content += GenSection('Protocols', NewSectionDict, True, True)
#
# generate [Ppis] section
@@ -290,28 +290,28 @@ def GenGuidProtocolPpi(Package, Content):
NewSectionDict[SortedArch] = \
NewSectionDict[SortedArch] + [Statement]
else:
NewSectionDict[SortedArch] = [Statement]
NewSectionDict[SortedArch] = [Statement]
Content += GenSection('Ppis', NewSectionDict, True, True)
return Content
## Transfer Package Object to Dec files
#
# Transfer all contents of a standard Package Object to a Dec file
# Transfer all contents of a standard Package Object to a Dec file
#
# @param Package: A Package
# @param Package: A Package
#
def PackageToDec(Package, DistHeader = None):
#
# Init global information for the file
#
ContainerFile = Package.GetFullPath()
Content = ''
#
# Generate file header
# Generate file header
#
PackageAbstract = GetLocalValue(Package.GetAbstract())
PackageDescription = GetLocalValue(Package.GetDescription())
@@ -335,7 +335,7 @@ def PackageToDec(Package, DistHeader = None):
if not PackageLicense and DistHeader:
for (Lang, License) in DistHeader.GetLicense():
PackageLicense = License
#
# Generate header comment section of DEC file
#
@@ -345,7 +345,7 @@ def PackageToDec(Package, DistHeader = None):
PackageLicense).replace('\r\n', '\n')
#
# Generate Binary header
# Generate Binary header
#
for UserExtension in Package.GetUserExtensionList():
if UserExtension.GetUserID() == TAB_BINARY_HEADER_USERID \
@@ -357,12 +357,12 @@ def PackageToDec(Package, DistHeader = None):
for (Lang, Copyright) in UserExtension.GetBinaryCopyright():
PackageBinaryCopyright = Copyright
for (Lang, License) in UserExtension.GetBinaryLicense():
PackageBinaryLicense = License
PackageBinaryLicense = License
if PackageBinaryAbstract and PackageBinaryDescription and \
PackageBinaryCopyright and PackageBinaryLicense:
Content += GenHeaderCommentSection(PackageBinaryAbstract,
PackageBinaryDescription,
PackageBinaryCopyright,
Content += GenHeaderCommentSection(PackageBinaryAbstract,
PackageBinaryDescription,
PackageBinaryCopyright,
PackageBinaryLicense,
True)
@@ -374,23 +374,23 @@ def PackageToDec(Package, DistHeader = None):
GenPackageUNIEncodeFile(Package, FileHeader)
#
# for each section, maintain a dict, sorted arch will be its key,
# for each section, maintain a dict, sorted arch will be its key,
#statement list will be its data
# { 'Arch1 Arch2 Arch3': [statement1, statement2],
# 'Arch1' : [statement1, statement3]
# 'Arch1' : [statement1, statement3]
# }
#
#
# generate [Defines] section
# generate [Defines] section
#
LeftOffset = 31
NewSectionDict = {TAB_ARCH_COMMON : []}
SpecialItemList = []
Statement = (u'%s ' % TAB_DEC_DEFINES_DEC_SPECIFICATION).ljust(LeftOffset) + u'= %s' % '0x00010017'
SpecialItemList.append(Statement)
BaseName = Package.GetBaseName()
if BaseName.startswith('.') or BaseName.startswith('-'):
BaseName = '_' + BaseName
@@ -405,7 +405,7 @@ def PackageToDec(Package, DistHeader = None):
if Package.UNIFlag:
Statement = (u'%s ' % TAB_DEC_DEFINES_PKG_UNI_FILE).ljust(LeftOffset) + u'= %s' % Package.GetBaseName() + '.uni'
SpecialItemList.append(Statement)
SpecialItemList.append(Statement)
for SortedArch in NewSectionDict:
NewSectionDict[SortedArch] = \
@@ -417,7 +417,7 @@ def PackageToDec(Package, DistHeader = None):
#
NewSectionDict = {}
IncludeArchList = Package.GetIncludeArchList()
if IncludeArchList:
if IncludeArchList:
for Path, ArchList in IncludeArchList:
Statement = Path
ArchList.sort()
@@ -465,7 +465,7 @@ def PackageToDec(Package, DistHeader = None):
NewSectionDict[SortedArch] = \
NewSectionDict[SortedArch] + [Statement]
else:
NewSectionDict[SortedArch] = [Statement]
NewSectionDict[SortedArch] = [Statement]
Content += GenSection('LibraryClasses', NewSectionDict, True, True)
@@ -473,7 +473,7 @@ def PackageToDec(Package, DistHeader = None):
# Generate '# [Error.<TokenSpcCName>]' section
#
Content = GenPcdErrorMsgSection(Package, Content)
Content = GenPcd(Package, Content)
#
@@ -498,7 +498,7 @@ def PackageToDec(Package, DistHeader = None):
NewStatement = ""
for Line in LineList:
NewStatement += " %s\n" % Line
SectionList = []
SectionName = 'UserExtensions'
UserId = UserExtension.GetUserID()
@@ -533,7 +533,7 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHeader = '', Encoding=TAB_ENCO
BinaryAbstract = []
BinaryDescription = []
#
# If more than one language code is used for any element that would be present in the PACKAGE_UNI_FILE,
# If more than one language code is used for any element that would be present in the PACKAGE_UNI_FILE,
# then the PACKAGE_UNI_FILE must be created.
#
for (Key, Value) in PackageObject.GetAbstract() + PackageObject.GetDescription():
@@ -541,7 +541,7 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHeader = '', Encoding=TAB_ENCO
GenUNIFlag = True
else:
OnlyLANGUAGE_EN_X = False
for UserExtension in PackageObject.GetUserExtensionList():
if UserExtension.GetUserID() == TAB_BINARY_HEADER_USERID \
and UserExtension.GetIdentifier() == TAB_BINARY_HEADER_IDENTIFIER:
@@ -565,7 +565,7 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHeader = '', Encoding=TAB_ENCO
GenUNIFlag = True
else:
OnlyLANGUAGE_EN_X = False
for PcdError in Pcd.GetPcdErrorsList():
if PcdError.GetErrorNumber().startswith('0x') or PcdError.GetErrorNumber().startswith('0X'):
for (Key, Value) in PcdError.GetErrorMessageList():
@@ -579,26 +579,26 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHeader = '', Encoding=TAB_ENCO
return
else:
PackageObject.UNIFlag = True
if not os.path.exists(os.path.dirname(PackageObject.GetFullPath())):
os.makedirs(os.path.dirname(PackageObject.GetFullPath()))
ContainerFile = GetUniFileName(os.path.dirname(PackageObject.GetFullPath()), PackageObject.GetBaseName())
Content = UniFileHeader + '\r\n'
Content += '\r\n'
Content += FormatUniEntry('#string ' + TAB_DEC_PACKAGE_ABSTRACT, PackageObject.GetAbstract(), ContainerFile) + '\r\n'
Content += FormatUniEntry('#string ' + TAB_DEC_PACKAGE_DESCRIPTION, PackageObject.GetDescription(), ContainerFile) \
+ '\r\n'
Content += FormatUniEntry('#string ' + TAB_DEC_BINARY_ABSTRACT, BinaryAbstract, ContainerFile) + '\r\n'
Content += FormatUniEntry('#string ' + TAB_DEC_BINARY_DESCRIPTION, BinaryDescription, ContainerFile) + '\r\n'
PromptGenList = []
HelpTextGenList = []
HelpTextGenList = []
for Pcd in PackageObject.GetPcdList():
# Generate Prompt for each Pcd
PcdPromptStrName = '#string ' + 'STR_' + Pcd.GetTokenSpaceGuidCName() + '_' + Pcd.GetCName() + '_PROMPT '
@@ -607,7 +607,7 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHeader = '', Encoding=TAB_ENCO
Lang = TxtObj.GetLang()
PromptStr = TxtObj.GetString()
#
# Avoid generating the same PROMPT entry more than one time.
# Avoid generating the same PROMPT entry more than one time.
#
if (PcdPromptStrName, Lang) not in PromptGenList:
TokenValueList.append((Lang, PromptStr))
@@ -615,7 +615,7 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHeader = '', Encoding=TAB_ENCO
PromptString = FormatUniEntry(PcdPromptStrName, TokenValueList, ContainerFile) + '\r\n'
if PromptString not in Content:
Content += PromptString
# Generate Help String for each Pcd
PcdHelpStrName = '#string ' + 'STR_' + Pcd.GetTokenSpaceGuidCName() + '_' + Pcd.GetCName() + '_HELP '
TokenValueList = []
@@ -623,7 +623,7 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHeader = '', Encoding=TAB_ENCO
Lang = TxtObj.GetLang()
HelpStr = TxtObj.GetString()
#
# Avoid generating the same HELP entry more than one time.
# Avoid generating the same HELP entry more than one time.
#
if (PcdHelpStrName, Lang) not in HelpTextGenList:
TokenValueList.append((Lang, HelpStr))
@@ -631,7 +631,7 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHeader = '', Encoding=TAB_ENCO
HelpTextString = FormatUniEntry(PcdHelpStrName, TokenValueList, ContainerFile) + '\r\n'
if HelpTextString not in Content:
Content += HelpTextString
# Generate PcdError for each Pcd if ErrorNo exist.
for PcdError in Pcd.GetPcdErrorsList():
ErrorNo = PcdError.GetErrorNumber()
@@ -642,7 +642,7 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHeader = '', Encoding=TAB_ENCO
PcdErrString = FormatUniEntry(PcdErrStrName, PcdError.GetErrorMessageList(), ContainerFile) + '\r\n'
if PcdErrString not in Content:
Content += PcdErrString
File = codecs.open(ContainerFile, 'w', Encoding)
File.write(u'\uFEFF' + Content)
File.stream.close()
@@ -652,23 +652,23 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHeader = '', Encoding=TAB_ENCO
PackageObject.FileList.append((ContainerFile, Md5Sum))
return ContainerFile
## GenPcdErrComment
#
# @param PcdErrObject: PcdErrorObject
#
#
# @retval CommentStr: Generated comment lines, with prefix "#"
#
#
def GenPcdErrComment (PcdErrObject):
CommentStr = ''
CommentStr = ''
ErrorCode = PcdErrObject.GetErrorNumber()
ValidValueRange = PcdErrObject.GetValidValueRange()
if ValidValueRange:
CommentStr = TAB_COMMENT_SPLIT + TAB_SPACE_SPLIT + TAB_PCD_VALIDRANGE + TAB_SPACE_SPLIT
CommentStr = TAB_COMMENT_SPLIT + TAB_SPACE_SPLIT + TAB_PCD_VALIDRANGE + TAB_SPACE_SPLIT
if ErrorCode:
CommentStr += ErrorCode + TAB_SPACE_SPLIT + TAB_VALUE_SPLIT + TAB_SPACE_SPLIT
CommentStr += ValidValueRange + END_OF_LINE
ValidValue = PcdErrObject.GetValidValue()
if ValidValue:
ValidValueList = \
@@ -677,13 +677,13 @@ def GenPcdErrComment (PcdErrObject):
if ErrorCode:
CommentStr += ErrorCode + TAB_SPACE_SPLIT + TAB_VALUE_SPLIT + TAB_SPACE_SPLIT
CommentStr += TAB_COMMA_SPLIT.join(ValidValueList) + END_OF_LINE
Expression = PcdErrObject.GetExpression()
if Expression:
CommentStr = TAB_COMMENT_SPLIT + TAB_SPACE_SPLIT + TAB_PCD_EXPRESSION + TAB_SPACE_SPLIT
if ErrorCode:
CommentStr += ErrorCode + TAB_SPACE_SPLIT + TAB_VALUE_SPLIT + TAB_SPACE_SPLIT
CommentStr += Expression + END_OF_LINE
return CommentStr

View File

@@ -4,9 +4,9 @@
#
# Copyright (c) 2011 - 2018, 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,
@@ -46,8 +46,8 @@ from Library.StringUtils import GetUniFileName
## Transfer Module Object to Inf files
#
# Transfer all contents of a standard Module Object to an Inf file
# @param ModuleObject: A Module Object
# Transfer all contents of a standard Module Object to an Inf file
# @param ModuleObject: A Module Object
#
def ModuleToInf(ModuleObject, PackageObject=None, DistHeader=None):
if not GlobalData.gWSPKG_LIST:
@@ -59,9 +59,9 @@ def ModuleToInf(ModuleObject, PackageObject=None, DistHeader=None):
Content = ''
#
# Generate file header, If any Abstract, Description, Copyright or License XML elements are missing,
# should 1) use the Abstract, Description, Copyright or License from the PackageSurfaceArea.Header elements
# that the module belongs to, or 2) if this is a stand-alone module that is not included in a PackageSurfaceArea,
# Generate file header, If any Abstract, Description, Copyright or License XML elements are missing,
# should 1) use the Abstract, Description, Copyright or License from the PackageSurfaceArea.Header elements
# that the module belongs to, or 2) if this is a stand-alone module that is not included in a PackageSurfaceArea,
# use the abstract, description, copyright or license from the DistributionPackage.Header elements.
#
ModuleAbstract = GetLocalValue(ModuleObject.GetAbstract())
@@ -107,15 +107,15 @@ def ModuleToInf(ModuleObject, PackageObject=None, DistHeader=None):
#
# Generate header comment section of INF file
#
#
Content += GenHeaderCommentSection(ModuleAbstract,
ModuleDescription,
ModuleCopyright,
ModuleLicense).replace('\r\n', '\n')
#
# Generate Binary Header
#
# Generate Binary Header
#
for UserExtension in ModuleObject.GetUserExtensionList():
if UserExtension.GetUserID() == DT.TAB_BINARY_HEADER_USERID \
and UserExtension.GetIdentifier() == DT.TAB_BINARY_HEADER_IDENTIFIER:
@@ -152,10 +152,10 @@ def ModuleToInf(ModuleObject, PackageObject=None, DistHeader=None):
else:
GlobalData.gIS_BINARY_INF = False
#
# for each section, maintain a dict, sorted arch will be its key,
# for each section, maintain a dict, sorted arch will be its key,
# statement list will be its data
# { 'Arch1 Arch2 Arch3': [statement1, statement2],
# 'Arch1' : [statement1, statement3]
# 'Arch1' : [statement1, statement3]
# }
#
# Gen section contents
@@ -197,7 +197,7 @@ def GenModuleUNIEncodeFile(ModuleObject, UniFileHeader='', Encoding=DT.TAB_ENCOD
BinaryAbstract = []
BinaryDescription = []
#
# If more than one language code is used for any element that would be present in the MODULE_UNI_FILE,
# If more than one language code is used for any element that would be present in the MODULE_UNI_FILE,
# then the MODULE_UNI_FILE must be created.
#
for (Key, Value) in ModuleObject.GetAbstract() + ModuleObject.GetDescription():
@@ -300,11 +300,11 @@ def GenDefines(ModuleObject):
BaseName = '_' + BaseName
Statement = (u'%s ' % DT.TAB_INF_DEFINES_BASE_NAME).ljust(LeftOffset) + u'= %s' % BaseName
SpecialStatementList.append(Statement)
# TAB_INF_DEFINES_FILE_GUID
Statement = (u'%s ' % DT.TAB_INF_DEFINES_FILE_GUID).ljust(LeftOffset) + u'= %s' % ModuleObject.GetGuid()
SpecialStatementList.append(Statement)
# TAB_INF_DEFINES_VERSION_STRING
Statement = (u'%s ' % DT.TAB_INF_DEFINES_VERSION_STRING).ljust(LeftOffset) + u'= %s' % ModuleObject.GetVersion()
SpecialStatementList.append(Statement)
@@ -480,7 +480,7 @@ def GenPackages(ModuleObject):
Path = ''
#
# find package path/name
#
#
for PkgInfo in GlobalData.gWSPKG_LIST:
if Guid == PkgInfo[1]:
if (not Version) or (Version == PkgInfo[2]):
@@ -553,7 +553,7 @@ def GenDepex(ModuleObject):
else:
NewSectionDict[Key] = [Statement]
Content += GenSection('Depex', NewSectionDict, False)
return Content
## GenUserExtensions
#
@@ -673,7 +673,7 @@ def GenBinaryStatement(Key, Value, SubTypeGuidValue=None):
Statement += '|' + Target
return Statement
## GenGuidSections
#
#
# @param GuidObjList: List of GuidObject
# @retVal Content: The generated section contents
#
@@ -736,7 +736,7 @@ def GenGuidSections(GuidObjList):
return Content
## GenProtocolPPiSections
#
#
# @param ObjList: List of ProtocolObject or Ppi Object
# @retVal Content: The generated section contents
#
@@ -804,7 +804,7 @@ def GenPcdSections(ModuleObject):
Content = ''
if not GlobalData.gIS_BINARY_INF:
#
# for each Pcd Itemtype, maintain a dict so the same type will be grouped
# for each Pcd Itemtype, maintain a dict so the same type will be grouped
# together
#
ItemTypeDict = {}
@@ -866,7 +866,7 @@ def GenPcdSections(ModuleObject):
if NewSectionDict:
Content += GenSection(ItemType, NewSectionDict)
#
# For AsBuild INF files
# For AsBuild INF files
#
else:
Content += GenAsBuiltPacthPcdSections(ModuleObject)
@@ -905,7 +905,7 @@ def GenAsBuiltPacthPcdSections(ModuleObject):
Statement = HelpString + TokenSpaceName + '.' + PcdCName + ' | ' + PcdValue + ' | ' + \
PcdOffset + DT.TAB_SPACE_SPLIT
#
# Use binary file's Arch to be Pcd's Arch
# Use binary file's Arch to be Pcd's Arch
#
ArchList = []
FileNameObjList = BinaryFile.GetFileNameList()
@@ -954,7 +954,7 @@ def GenAsBuiltPcdExSections(ModuleObject):
Statement = HelpString + TokenSpaceName + DT.TAB_SPLIT + PcdCName + DT.TAB_SPACE_SPLIT
#
# Use binary file's Arch to be Pcd's Arch
# Use binary file's Arch to be Pcd's Arch
#
ArchList = []
FileNameObjList = BinaryFile.GetFileNameList()
@@ -1033,7 +1033,7 @@ def GenSpecialSections(ObjectList, SectionName, UserExtensionsContent=''):
Content = Content.lstrip()
#
# add a return to differentiate it between other possible sections
#
#
if Content:
Content += '\n'
return Content
@@ -1110,7 +1110,7 @@ def GenBinaries(ModuleObject):
else:
NewSectionDict[SortedArch] = [Statement]
#
# as we already generated statement for this DictKey here set the Valuelist to be empty
# as we already generated statement for this DictKey here set the Valuelist to be empty
# to avoid generate duplicate entries as the DictKey may have multiple entries
#
BinariesDict[Key] = []

View File

@@ -2,11 +2,11 @@
#
# This file contained the miscellaneous routines for GenMetaFile usage.
#
# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -26,7 +26,7 @@ from Parser.DecParser import Dec
# @param SectionDict: string of source file path/name
# @param Arch: string of source file family field
# @param ExternList: string of source file FeatureFlag field
#
#
def AddExternToDefineSec(SectionDict, Arch, ExternList):
LeftOffset = 31
for ArchList, EntryPoint, UnloadImage, Constructor, Destructor, FFE, HelpStringList in ExternList:
@@ -93,7 +93,7 @@ def ObtainPcdName(Packages, TokenSpaceGuidValue, Token):
Path = None
#
# find package path/name
#
#
for PkgInfo in GlobalData.gWSPKG_LIST:
if Guid == PkgInfo[1]:
if (not Version) or (Version == PkgInfo[2]):
@@ -156,9 +156,9 @@ def ObtainPcdName(Packages, TokenSpaceGuidValue, Token):
return TokenSpaceGuidName, PcdCName
## _TransferDict
# transfer dict that using (Statement, SortedArch) as key,
# transfer dict that using (Statement, SortedArch) as key,
# (GenericComment, UsageComment) as value into a dict that using SortedArch as
# key and NewStatement as value
# key and NewStatement as value
#
def TransferDict(OrigDict, Type=None):
NewDict = {}
@@ -171,7 +171,7 @@ def TransferDict(OrigDict, Type=None):
for Statement, SortedArch in OrigDict:
if len(Statement) > LeftOffset:
LeftOffset = len(Statement)
for Statement, SortedArch in OrigDict:
Comment = OrigDict[Statement, SortedArch]
#

View File

@@ -2,11 +2,11 @@
#
# This file contained the logical of generate XML files.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -15,4 +15,4 @@
'''
GenXmlFile
'''
'''

View File

@@ -4,11 +4,11 @@
# This file is required to make Python interpreter treat the directory
# as containing package.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -17,4 +17,4 @@
'''
GenMetaFile
'''
'''

View File

@@ -1,11 +1,11 @@
## @file
# Install distribution package.
#
# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -102,7 +102,7 @@ def InstallNewModule(WorkspaceDir, Path, PathList = None):
Logger.Info(ST.MSG_RELATIVE_PATH_ONLY%FullPath)
else:
return Path
Input = stdin.readline()
Input = Input.replace('\r', '').replace('\n', '')
if Input == '':
@@ -110,7 +110,7 @@ def InstallNewModule(WorkspaceDir, Path, PathList = None):
Input = Input.replace('\r', '').replace('\n', '')
return InstallNewModule(WorkspaceDir, Input, PathList)
## InstallNewFile
#
# @param WorkspaceDir: Workspace Direction
@@ -137,15 +137,15 @@ def UnZipDp(WorkspaceDir, DpPkgFileName, Index=1):
ContentZipFile = None
Logger.Quiet(ST.MSG_UZIP_PARSE_XML)
DistFile = PackageFile(DpPkgFileName)
DpDescFileName, ContentFileName = GetDPFile(DistFile.GetZipFile())
TempDir = os.path.normpath(os.path.join(WorkspaceDir, "Conf/.tmp%s" % str(Index)))
GlobalData.gUNPACK_DIR.append(TempDir)
DistPkgFile = DistFile.UnpackFile(DpDescFileName, os.path.normpath(os.path.join(TempDir, DpDescFileName)))
if not DistPkgFile:
Logger.Error("InstallPkg", FILE_NOT_FOUND, ST.ERR_FILE_BROKEN %DpDescFileName)
#
# Generate distpkg
#
@@ -166,10 +166,10 @@ def UnZipDp(WorkspaceDir, DpPkgFileName, Index=1):
#
# Get file size
#
#
FileSize = os.path.getsize(ContentFile)
if FileSize != 0:
if FileSize != 0:
ContentZipFile = PackageFile(ContentFile)
#
@@ -201,12 +201,12 @@ def GetPackageList(DistPkg, Dep, WorkspaceDir, Options, ContentZipFile, ModuleLi
NewPackagePath = InstallNewPackage(WorkspaceDir, GuidedPkgPath, Options.CustomPath)
else:
NewPackagePath = InstallNewPackage(WorkspaceDir, PackagePath, Options.CustomPath)
InstallPackageContent(PackagePath, NewPackagePath, Package, ContentZipFile, Dep, WorkspaceDir, ModuleList,
InstallPackageContent(PackagePath, NewPackagePath, Package, ContentZipFile, Dep, WorkspaceDir, ModuleList,
DistPkg.Header.ReadOnly)
PackageList.append(Package)
NewDict[Guid, Version, Package.GetPackagePath()] = Package
#
# Now generate meta-data files, first generate all dec for package
# dec should be generated before inf, and inf should be generated after
@@ -219,7 +219,7 @@ def GetPackageList(DistPkg, Dep, WorkspaceDir, Options, ContentZipFile, ModuleLi
Md5Sum = Md5Sigature.hexdigest()
if (FilePath, Md5Sum) not in Package.FileList:
Package.FileList.append((FilePath, Md5Sum))
return NewDict
## GetModuleList
@@ -229,18 +229,18 @@ def GetPackageList(DistPkg, Dep, WorkspaceDir, Options, ContentZipFile, ModuleLi
def GetModuleList(DistPkg, Dep, WorkspaceDir, ContentZipFile, ModuleList):
#
# ModulePathList will keep track of the standalone module path that
# we just installed. If a new module's path in that list
# (only multiple INF in one directory will be so), we will
# install them directly. If not, we will try to create a new directory
# we just installed. If a new module's path in that list
# (only multiple INF in one directory will be so), we will
# install them directly. If not, we will try to create a new directory
# for it.
#
ModulePathList = []
#
# Check module exist and install
#
Module = None
NewDict = Sdict()
NewDict = Sdict()
for Guid, Version, Name, Path in DistPkg.ModuleSurfaceArea:
ModulePath = Path
Module = DistPkg.ModuleSurfaceArea[Guid, Version, Name, Path]
@@ -259,14 +259,14 @@ def GetModuleList(DistPkg, Dep, WorkspaceDir, ContentZipFile, ModuleList):
ModulePathList.append(NewModuleFullPath)
else:
NewModulePath = ModulePath
InstallModuleContent(ModulePath, NewModulePath, '', Module, ContentZipFile, WorkspaceDir, ModuleList, None,
InstallModuleContent(ModulePath, NewModulePath, '', Module, ContentZipFile, WorkspaceDir, ModuleList, None,
DistPkg.Header.ReadOnly)
#
# Update module
#
Module.SetModulePath(Module.GetModulePath().replace(Path, NewModulePath, 1))
NewDict[Guid, Version, Name, Module.GetModulePath()] = Module
#
@@ -289,7 +289,7 @@ def GetModuleList(DistPkg, Dep, WorkspaceDir, ContentZipFile, ModuleList):
for (FilePath, Md5Sum) in Module.FileList:
if str(FilePath).endswith('.uni') and Package and (FilePath, Md5Sum) not in Package.FileList:
Package.FileList.append((FilePath, Md5Sum))
return NewDict
##
@@ -303,7 +303,7 @@ def GetDepProtocolPpiGuidPcdNames(DePackageObjList):
DependentPpiCNames = []
DependentGuidCNames = []
DependentPcdNames = []
for PackageObj in DePackageObjList:
#
# Get protocol CName list from all dependent DEC file
@@ -312,29 +312,29 @@ def GetDepProtocolPpiGuidPcdNames(DePackageObjList):
for Protocol in PackageObj.GetProtocolList():
if Protocol.GetCName() not in ProtocolCNames:
ProtocolCNames.append(Protocol.GetCName())
DependentProtocolCNames.append(ProtocolCNames)
#
# Get Ppi CName list from all dependent DEC file
#
#
PpiCNames = []
for Ppi in PackageObj.GetPpiList():
if Ppi.GetCName() not in PpiCNames:
PpiCNames.append(Ppi.GetCName())
DependentPpiCNames.append(PpiCNames)
#
# Get Guid CName list from all dependent DEC file
#
#
GuidCNames = []
for Guid in PackageObj.GetGuidList():
if Guid.GetCName() not in GuidCNames:
GuidCNames.append(Guid.GetCName())
DependentGuidCNames.append(GuidCNames)
#
# Get PcdName list from all dependent DEC file
#
@@ -343,10 +343,10 @@ def GetDepProtocolPpiGuidPcdNames(DePackageObjList):
PcdName = '.'.join([Pcd.GetTokenSpaceGuidCName(), Pcd.GetCName()])
if PcdName not in PcdNames:
PcdNames.append(PcdName)
DependentPcdNames.append(PcdNames)
return DependentProtocolCNames, DependentPpiCNames, DependentGuidCNames, DependentPcdNames
##
@@ -358,8 +358,8 @@ def CheckProtoclCNameRedefined(Module, DependentProtocolCNames):
for PackageProtocolCNames in DependentProtocolCNames:
if ProtocolInModule.GetCName() in PackageProtocolCNames:
if IsCNameDefined:
Logger.Error("\nUPT", FORMAT_INVALID,
File = Module.GetFullPath(),
Logger.Error("\nUPT", FORMAT_INVALID,
File = Module.GetFullPath(),
ExtraData = \
ST.ERR_INF_PARSER_ITEM_DUPLICATE_IN_DEC % ProtocolInModule.GetCName())
else:
@@ -374,11 +374,11 @@ def CheckPpiCNameRedefined(Module, DependentPpiCNames):
for PackagePpiCNames in DependentPpiCNames:
if PpiInModule.GetCName() in PackagePpiCNames:
if IsCNameDefined:
Logger.Error("\nUPT", FORMAT_INVALID,
File = Module.GetFullPath(),
Logger.Error("\nUPT", FORMAT_INVALID,
File = Module.GetFullPath(),
ExtraData = ST.ERR_INF_PARSER_ITEM_DUPLICATE_IN_DEC % PpiInModule.GetCName())
else:
IsCNameDefined = True
IsCNameDefined = True
##
# Check if Guid CName is redefined
@@ -389,8 +389,8 @@ def CheckGuidCNameRedefined(Module, DependentGuidCNames):
for PackageGuidCNames in DependentGuidCNames:
if GuidInModule.GetCName() in PackageGuidCNames:
if IsCNameDefined:
Logger.Error("\nUPT", FORMAT_INVALID,
File = Module.GetFullPath(),
Logger.Error("\nUPT", FORMAT_INVALID,
File = Module.GetFullPath(),
ExtraData = \
ST.ERR_INF_PARSER_ITEM_DUPLICATE_IN_DEC % GuidInModule.GetCName())
else:
@@ -414,8 +414,8 @@ def CheckPcdNameRedefined(Module, DependentPcdNames):
for PcdNames in DependentPcdNames:
if PcdName in PcdNames:
if IsPcdNameDefined:
Logger.Error("\nUPT", FORMAT_INVALID,
File = Module.GetFullPath(),
Logger.Error("\nUPT", FORMAT_INVALID,
File = Module.GetFullPath(),
ExtraData = ST.ERR_INF_PARSER_ITEM_DUPLICATE_IN_DEC % PcdName)
else:
IsPcdNameDefined = True
@@ -427,7 +427,7 @@ def CheckCNameInModuleRedefined(Module, DistPkg):
DePackageObjList = []
#
# Get all dependent package objects
#
#
for Obj in Module.GetPackageDependencyList():
Guid = Obj.GetGuid()
Version = Obj.GetVersion()
@@ -435,7 +435,7 @@ def CheckCNameInModuleRedefined(Module, DistPkg):
if Key[0] == Guid and Key[1] == Version:
if DistPkg.PackageSurfaceArea[Key] not in DePackageObjList:
DePackageObjList.append(DistPkg.PackageSurfaceArea[Key])
DependentProtocolCNames, DependentPpiCNames, DependentGuidCNames, DependentPcdNames = \
GetDepProtocolPpiGuidPcdNames(DePackageObjList)
@@ -457,7 +457,7 @@ def GenToolMisc(DistPkg, WorkspaceDir, ContentZipFile):
ToolFileNum = 0
FileNum = 0
RootDir = WorkspaceDir
#
# FileList stores both tools files and misc files
# Misc file list must be appended to FileList *AFTER* Tools file list
@@ -506,7 +506,7 @@ def Main(Options = None):
WorkspaceDir = GlobalData.gWORKSPACE
if not Options.PackageFile:
Logger.Error("InstallPkg", OPTION_MISSING, ExtraData=ST.ERR_SPECIFY_PACKAGE)
# Get all Dist Info
DistInfoList = []
DistPkgList = []
@@ -536,17 +536,17 @@ def Main(Options = None):
InstallDp(ToBeInstalledDist[0], ToBeInstalledDist[2], ToBeInstalledDist[1],
Options, Dep, WorkspaceDir, DataBase)
ReturnCode = 0
except FatalError as XExcept:
ReturnCode = XExcept.args[0]
if Logger.GetLevel() <= Logger.DEBUG_9:
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())
except KeyboardInterrupt:
ReturnCode = ABORT_ERROR
if Logger.GetLevel() <= Logger.DEBUG_9:
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())
except:
ReturnCode = CODE_ERROR
Logger.Error(
@@ -574,8 +574,8 @@ def Main(Options = None):
return ReturnCode
# BackupDist method
#
# This method will backup the Distribution file into the $(WORKSPACE)/conf/upt, and rename it
#
# This method will backup the Distribution file into the $(WORKSPACE)/conf/upt, and rename it
# if there is already a same-named distribution existed.
#
# @param DpPkgFileName: The distribution path
@@ -645,19 +645,19 @@ def CheckInstallDpx(Dep, DistPkg, DistPkgFileName):
#
def InstallModuleContent(FromPath, NewPath, ModulePath, Module, ContentZipFile,
WorkspaceDir, ModuleList, Package = None, ReadOnly = False):
if NewPath.startswith("\\") or NewPath.startswith("/"):
NewPath = NewPath[1:]
if not IsValidInstallPath(NewPath):
Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%NewPath)
Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%NewPath)
NewModuleFullPath = os.path.normpath(os.path.join(WorkspaceDir, NewPath,
ConvertPath(ModulePath)))
Module.SetFullPath(os.path.normpath(os.path.join(NewModuleFullPath,
ConvertPath(Module.GetName()) + '.inf')))
Module.FileList = []
for MiscFile in Module.GetMiscFileList():
if not MiscFile:
continue
@@ -665,12 +665,12 @@ def InstallModuleContent(FromPath, NewPath, ModulePath, Module, ContentZipFile,
File = Item.GetURI()
if File.startswith("\\") or File.startswith("/"):
File = File[1:]
if not IsValidInstallPath(File):
Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%File)
FromFile = os.path.join(FromPath, ModulePath, File)
Executable = Item.GetExecutable()
Executable = Item.GetExecutable()
ToFile = os.path.normpath(os.path.join(NewModuleFullPath, ConvertPath(File)))
Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly, Executable)
if Package and ((ToFile, Md5Sum) not in Package.FileList):
@@ -683,10 +683,10 @@ def InstallModuleContent(FromPath, NewPath, ModulePath, Module, ContentZipFile,
File = Item.GetSourceFile()
if File.startswith("\\") or File.startswith("/"):
File = File[1:]
if not IsValidInstallPath(File):
Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%File)
Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%File)
FromFile = os.path.join(FromPath, ModulePath, File)
ToFile = os.path.normpath(os.path.join(NewModuleFullPath, ConvertPath(File)))
Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly)
@@ -698,24 +698,24 @@ def InstallModuleContent(FromPath, NewPath, ModulePath, Module, ContentZipFile,
Module.FileList.append((ToFile, Md5Sum))
for Item in Module.GetBinaryFileList():
FileNameList = Item.GetFileNameList()
for FileName in FileNameList:
File = FileName.GetFilename()
for FileName in FileNameList:
File = FileName.GetFilename()
if File.startswith("\\") or File.startswith("/"):
File = File[1:]
if not IsValidInstallPath(File):
Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%File)
FromFile = os.path.join(FromPath, ModulePath, File)
ToFile = os.path.normpath(os.path.join(NewModuleFullPath, ConvertPath(File)))
Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly)
Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly)
if Package and ((ToFile, Md5Sum) not in Package.FileList):
Package.FileList.append((ToFile, Md5Sum))
elif Package:
continue
elif (ToFile, Md5Sum) not in Module.FileList:
Module.FileList.append((ToFile, Md5Sum))
InstallModuleContentZipFile(ContentZipFile, FromPath, ModulePath, WorkspaceDir, NewPath, Module, Package, ReadOnly,
ModuleList)
@@ -726,7 +726,7 @@ def InstallModuleContent(FromPath, NewPath, ModulePath, Module, ContentZipFile,
def InstallModuleContentZipFile(ContentZipFile, FromPath, ModulePath, WorkspaceDir, NewPath, Module, Package, ReadOnly,
ModuleList):
#
# Extract other files under current module path in content Zip file but not listed in the description
# Extract other files under current module path in content Zip file but not listed in the description
#
if ContentZipFile:
for FileName in ContentZipFile.GetZipFile().namelist():
@@ -735,12 +735,12 @@ def InstallModuleContentZipFile(ContentZipFile, FromPath, ModulePath, WorkspaceD
if FileUnderPath(FileName, CheckPath):
if FileName.startswith("\\") or FileName.startswith("/"):
FileName = FileName[1:]
if not IsValidInstallPath(FileName):
Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FileName)
FromFile = FileName
ToFile = os.path.normpath(os.path.join(WorkspaceDir,
ToFile = os.path.normpath(os.path.join(WorkspaceDir,
ConvertPath(FileName.replace(FromPath, NewPath, 1))))
CheckList = copy.copy(Module.FileList)
if Package:
@@ -755,16 +755,16 @@ def InstallModuleContentZipFile(ContentZipFile, FromPath, ModulePath, WorkspaceD
elif Package:
continue
elif (ToFile, Md5Sum) not in Module.FileList:
Module.FileList.append((ToFile, Md5Sum))
Module.FileList.append((ToFile, Md5Sum))
ModuleList.append((Module, Package))
## FileUnderPath
# Check whether FileName started with directory specified by CheckPath
# Check whether FileName started with directory specified by CheckPath
#
# @param FileName: the FileName need to be checked
# @param CheckPath: the path need to be checked against
# @return: True or False
# @return: True or False
#
def FileUnderPath(FileName, CheckPath):
FileName = FileName.replace('\\', '/')
@@ -777,13 +777,13 @@ def FileUnderPath(FileName, CheckPath):
RemainingPath = RemainingPath[1:]
if FileName == os.path.normpath(os.path.join(CheckPath, RemainingPath)):
return True
return False
## InstallFile
# Extract File from Zipfile, set file attribute, and return the Md5Sum
#
# @return: True or False
# @return: True or False
#
def InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly, Executable=False):
if os.path.exists(os.path.normpath(ToFile)):
@@ -802,7 +802,7 @@ def InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly, Executable=False):
stat.S_IWOTH | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH)
else:
chmod(ToFile, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH | stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH)
Md5Sigature = md5.new(__FileHookOpen__(str(ToFile), 'rb').read())
Md5Sum = Md5Sigature.hexdigest()
@@ -823,44 +823,44 @@ def InstallPackageContent(FromPath, ToPath, Package, ContentZipFile, Dep,
if Dep:
pass
Package.FileList = []
if ToPath.startswith("\\") or ToPath.startswith("/"):
ToPath = ToPath[1:]
if not IsValidInstallPath(ToPath):
Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%ToPath)
Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%ToPath)
if FromPath.startswith("\\") or FromPath.startswith("/"):
FromPath = FromPath[1:]
if not IsValidInstallPath(FromPath):
Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FromPath)
Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FromPath)
PackageFullPath = os.path.normpath(os.path.join(WorkspaceDir, ToPath))
for MiscFile in Package.GetMiscFileList():
for Item in MiscFile.GetFileList():
FileName = Item.GetURI()
if FileName.startswith("\\") or FileName.startswith("/"):
FileName = FileName[1:]
if not IsValidInstallPath(FileName):
Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FileName)
FromFile = os.path.join(FromPath, FileName)
Executable = Item.GetExecutable()
ToFile = (os.path.join(PackageFullPath, ConvertPath(FileName)))
Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly, Executable)
if (ToFile, Md5Sum) not in Package.FileList:
Package.FileList.append((ToFile, Md5Sum))
PackageIncludeArchList = []
PackageIncludeArchList = []
for Item in Package.GetPackageIncludeFileList():
FileName = Item.GetFilePath()
if FileName.startswith("\\") or FileName.startswith("/"):
FileName = FileName[1:]
if not IsValidInstallPath(FileName):
Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FileName)
Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FileName)
FromFile = os.path.join(FromPath, FileName)
ToFile = os.path.normpath(os.path.join(PackageFullPath, ConvertPath(FileName)))
RetFile = ContentZipFile.UnpackFile(FromFile, ToFile)
@@ -875,21 +875,21 @@ def InstallPackageContent(FromPath, ToPath, Package, ContentZipFile, Dep,
if ReadOnly:
chmod(ToFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH)
else:
chmod(ToFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH|stat.S_IWUSR|stat.S_IWGRP|stat.S_IWOTH)
chmod(ToFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH|stat.S_IWUSR|stat.S_IWGRP|stat.S_IWOTH)
Md5Sigature = md5.new(__FileHookOpen__(str(ToFile), 'rb').read())
Md5Sum = Md5Sigature.hexdigest()
if (ToFile, Md5Sum) not in Package.FileList:
Package.FileList.append((ToFile, Md5Sum))
Package.SetIncludeArchList(PackageIncludeArchList)
for Item in Package.GetStandardIncludeFileList():
FileName = Item.GetFilePath()
if FileName.startswith("\\") or FileName.startswith("/"):
FileName = FileName[1:]
if not IsValidInstallPath(FileName):
Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FileName)
Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FileName)
FromFile = os.path.join(FromPath, FileName)
ToFile = os.path.normpath(os.path.join(PackageFullPath, ConvertPath(FileName)))
Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly)
@@ -932,7 +932,7 @@ def GetDPFile(ZipFile):
continue
else:
continue
Logger.Error("PackagingTool", FILE_TYPE_MISMATCH,
ExtraData=ST.ERR_DIST_FILE_TOOMANY)
if not DescFile or not ContentFile:
@@ -951,13 +951,13 @@ def InstallDp(DistPkg, DpPkgFileName, ContentZipFile, Options, Dep, WorkspaceDir
#
PackageList = []
ModuleList = []
DistPkg.PackageSurfaceArea = GetPackageList(DistPkg, Dep, WorkspaceDir, Options,
DistPkg.PackageSurfaceArea = GetPackageList(DistPkg, Dep, WorkspaceDir, Options,
ContentZipFile, ModuleList, PackageList)
DistPkg.ModuleSurfaceArea = GetModuleList(DistPkg, Dep, WorkspaceDir, ContentZipFile, ModuleList)
GenToolMisc(DistPkg, WorkspaceDir, ContentZipFile)
#
# copy "Distribution File" to directory $(WORKSPACE)/conf/upt
#
@@ -968,6 +968,6 @@ def InstallDp(DistPkg, DpPkgFileName, ContentZipFile, Options, Dep, WorkspaceDir
# update database
#
Logger.Quiet(ST.MSG_UPDATE_PACKAGE_DATABASE)
DataBase.AddDPObject(DistPkg, NewDpPkgFileName, DistFileName,
DataBase.AddDPObject(DistPkg, NewDpPkgFileName, DistFileName,
DistPkg.Header.RePackage)

View File

@@ -1,11 +1,11 @@
## @file
# Inventory workspace's distribution package information.
#
# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2014 - 2018, 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,
@@ -37,7 +37,7 @@ from Library import GlobalData
#
def InventoryDistInstalled(DataBase):
DistInstalled = DataBase.InventoryDistInstalled()
#
# find the max length for each item
#
@@ -47,9 +47,9 @@ def InventoryDistInstalled(DataBase):
DpOriginalNameStr = "DpOriginalName"
MaxGuidlen = len(DpGuidStr)
MaxVerlen = len(DpVerStr)
MaxDpAliasFileNameLen = len(DpNameStr)
MaxDpAliasFileNameLen = len(DpNameStr)
MaxDpOrigFileNamelen = len(DpOriginalNameStr)
for (DpGuid, DpVersion, DpOriginalName, DpAliasFileName) in DistInstalled:
MaxGuidlen = max(MaxGuidlen, len(DpGuid))
MaxVerlen = max(MaxVerlen, len(DpVersion))
@@ -57,22 +57,22 @@ def InventoryDistInstalled(DataBase):
MaxDpOrigFileNamelen = max(MaxDpOrigFileNamelen, len(DpOriginalName))
OutMsgFmt = "%-*s\t%-*s\t%-*s\t%-s"
OutMsg = OutMsgFmt % (MaxDpAliasFileNameLen,
DpNameStr,
MaxGuidlen,
DpGuidStr,
MaxVerlen,
DpVerStr,
OutMsg = OutMsgFmt % (MaxDpAliasFileNameLen,
DpNameStr,
MaxGuidlen,
DpGuidStr,
MaxVerlen,
DpVerStr,
DpOriginalNameStr)
Logger.Info(OutMsg)
for (DpGuid, DpVersion, DpFileName, DpAliasFileName) in DistInstalled:
OutMsg = OutMsgFmt % (MaxDpAliasFileNameLen,
DpAliasFileName,
MaxGuidlen,
DpGuid,
MaxVerlen,
DpVersion,
OutMsg = OutMsgFmt % (MaxDpAliasFileNameLen,
DpAliasFileName,
MaxGuidlen,
DpGuid,
MaxVerlen,
DpVersion,
DpFileName)
Logger.Info(OutMsg)
@@ -90,13 +90,13 @@ def Main(Options = None):
try:
DataBase = GlobalData.gDB
InventoryDistInstalled(DataBase)
ReturnCode = 0
InventoryDistInstalled(DataBase)
ReturnCode = 0
except FatalError as XExcept:
ReturnCode = XExcept.args[0]
if Logger.GetLevel() <= Logger.DEBUG_9:
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())
except KeyboardInterrupt:
except KeyboardInterrupt:
ReturnCode = ABORT_ERROR
if Logger.GetLevel() <= Logger.DEBUG_9:
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())
@@ -113,5 +113,5 @@ def Main(Options = None):
if ReturnCode == 0:
Logger.Quiet(ST.MSG_FINISH)
return ReturnCode
return ReturnCode

View File

@@ -3,9 +3,9 @@
#
# Copyright (c) 2011 - 2018, 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,
@@ -39,21 +39,21 @@ from Library.Misc import GetLocalValue
## GenTailCommentLines
#
# @param TailCommentLines: the tail comment lines that need to be generated
# @param LeadingSpaceNum: the number of leading space needed for non-first
# @param LeadingSpaceNum: the number of leading space needed for non-first
# line tail comment
#
#
def GenTailCommentLines (TailCommentLines, LeadingSpaceNum = 0):
TailCommentLines = TailCommentLines.rstrip(END_OF_LINE)
CommentStr = TAB_SPACE_SPLIT*2 + TAB_SPECIAL_COMMENT + TAB_SPACE_SPLIT + \
(END_OF_LINE + LeadingSpaceNum * TAB_SPACE_SPLIT + TAB_SPACE_SPLIT*2 + TAB_SPECIAL_COMMENT + \
TAB_SPACE_SPLIT).join(GetSplitValueList(TailCommentLines, END_OF_LINE))
return CommentStr
## GenGenericComment
#
# @param CommentLines: Generic comment Text, maybe Multiple Lines
#
#
def GenGenericComment (CommentLines):
if not CommentLines:
return ''
@@ -68,8 +68,8 @@ def GenGenericComment (CommentLines):
# and for line with only <EOL>, '#\n' will be generated instead of '# \n'
#
# @param CommentLines: Generic comment Text, maybe Multiple Lines
# @return CommentStr: Generated comment line
#
# @return CommentStr: Generated comment line
#
def GenGenericCommentF (CommentLines, NumOfPound=1, IsPrompt=False, IsInfLibraryClass=False):
if not CommentLines:
return ''
@@ -104,7 +104,7 @@ def GenGenericCommentF (CommentLines, NumOfPound=1, IsPrompt=False, IsInfLibrary
CommentStr += TAB_COMMENT_SPLIT * NumOfPound + TAB_SPACE_SPLIT * 16 + Line + END_OF_LINE
else:
CommentStr += TAB_COMMENT_SPLIT * NumOfPound + TAB_SPACE_SPLIT + Line + END_OF_LINE
return CommentStr
@@ -112,7 +112,7 @@ def GenGenericCommentF (CommentLines, NumOfPound=1, IsPrompt=False, IsInfLibrary
#
# Generate Header comment sections
#
# @param Abstract One line of abstract
# @param Abstract One line of abstract
# @param Description multiple lines of Description
# @param Copyright possible multiple copyright lines
# @param License possible multiple license lines
@@ -148,9 +148,9 @@ def GenHeaderCommentSection(Abstract, Description, Copyright, License, IsBinaryH
Content += CommChar + TAB_SPACE_SPLIT + ('\r\n' + CommChar + TAB_SPACE_SPLIT).join(GetSplitValueList\
(Description, '\n'))
Content += '\r\n' + CommChar + '\r\n'
#
# There is no '#\n' line to separate multiple copyright lines in code base
# There is no '#\n' line to separate multiple copyright lines in code base
#
if Copyright:
Copyright = Copyright.rstrip('\r\n')
@@ -163,12 +163,12 @@ def GenHeaderCommentSection(Abstract, Description, Copyright, License, IsBinaryH
Content += CommChar + TAB_SPACE_SPLIT + ('\r\n' + CommChar + TAB_SPACE_SPLIT).join(GetSplitValueList\
(License, '\n'))
Content += '\r\n' + CommChar + '\r\n'
if CommChar == TAB_COMMENT_EDK1_SPLIT:
Content += CommChar + TAB_SPACE_SPLIT + TAB_STAR + TAB_COMMENT_EDK1_END + '\r\n'
else:
Content += CommChar * 2 + '\r\n'
return Content
@@ -177,11 +177,11 @@ def GenHeaderCommentSection(Abstract, Description, Copyright, License, IsBinaryH
#
# @param Usage: Usage type
# @param TailCommentText: Comment text for tail comment
#
#
def GenInfPcdTailComment (Usage, TailCommentText):
if (Usage == ITEM_UNDEFINED) and (not TailCommentText):
return ''
CommentLine = TAB_SPACE_SPLIT.join([Usage, TailCommentText])
return GenTailCommentLines(CommentLine)
@@ -190,16 +190,16 @@ def GenInfPcdTailComment (Usage, TailCommentText):
#
# @param Usage: Usage type
# @param TailCommentText: Comment text for tail comment
#
#
def GenInfProtocolPPITailComment (Usage, Notify, TailCommentText):
if (not Notify) and (Usage == ITEM_UNDEFINED) and (not TailCommentText):
return ''
if Notify:
CommentLine = USAGE_ITEM_NOTIFY + " ## "
else:
CommentLine = ''
CommentLine += TAB_SPACE_SPLIT.join([Usage, TailCommentText])
return GenTailCommentLines(CommentLine)
@@ -208,39 +208,39 @@ def GenInfProtocolPPITailComment (Usage, Notify, TailCommentText):
#
# @param Usage: Usage type
# @param TailCommentText: Comment text for tail comment
#
#
def GenInfGuidTailComment (Usage, GuidTypeList, VariableName, TailCommentText):
GuidType = GuidTypeList[0]
if (Usage == ITEM_UNDEFINED) and (GuidType == ITEM_UNDEFINED) and \
(not TailCommentText):
return ''
FirstLine = Usage + " ## " + GuidType
FirstLine = Usage + " ## " + GuidType
if GuidType == TAB_INF_GUIDTYPE_VAR:
FirstLine += ":" + VariableName
CommentLine = TAB_SPACE_SPLIT.join([FirstLine, TailCommentText])
return GenTailCommentLines(CommentLine)
## GenDecGuidTailComment
#
# @param SupModuleList: Supported module type list
#
def GenDecTailComment (SupModuleList):
#
def GenDecTailComment (SupModuleList):
CommentLine = TAB_SPACE_SPLIT.join(SupModuleList)
return GenTailCommentLines(CommentLine)
## _GetHelpStr
# get HelpString from a list of HelpTextObject, the priority refer to
# get HelpString from a list of HelpTextObject, the priority refer to
# related HLD
#
# @param HelpTextObjList: List of HelpTextObject
#
#
# @return HelpStr: the help text string found, '' means no help text found
#
def _GetHelpStr(HelpTextObjList):
ValueList = []
ValueList = []
for HelpObj in HelpTextObjList:
ValueList.append((HelpObj.GetLang(), HelpObj.GetString()))
return GetLocalValue(ValueList, True)

View File

@@ -3,9 +3,9 @@
#
# Copyright (c) 2011 - 2018, 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,
@@ -69,7 +69,7 @@ def ParseHeaderCommentSection(CommentList, FileName = None, IsBinaryHeader = Fal
else:
STR_HEADER_COMMENT_START = "@file"
HeaderCommentStage = HEADER_COMMENT_NOT_STARTED
#
# first find the last copyright line
#
@@ -79,24 +79,24 @@ def ParseHeaderCommentSection(CommentList, FileName = None, IsBinaryHeader = Fal
if _IsCopyrightLine(Line):
Last = Index
break
for Item in CommentList:
Line = Item[0]
LineNo = Item[1]
if not Line.startswith(TAB_COMMENT_SPLIT) and Line:
Logger.Error("\nUPT", FORMAT_INVALID, ST.ERR_INVALID_COMMENT_FORMAT, FileName, Item[1])
Comment = CleanString2(Line)[1]
Comment = Comment.strip()
#
# if there are blank lines between License or Description, keep them as they would be
# if there are blank lines between License or Description, keep them as they would be
# indication of different block; or in the position that Abstract should be, also keep it
# as it indicates that no abstract
#
if not Comment and HeaderCommentStage not in [HEADER_COMMENT_LICENSE, \
HEADER_COMMENT_DESCRIPTION, HEADER_COMMENT_ABSTRACT]:
continue
if HeaderCommentStage == HEADER_COMMENT_NOT_STARTED:
if Comment.startswith(STR_HEADER_COMMENT_START):
HeaderCommentStage = HEADER_COMMENT_ABSTRACT
@@ -114,20 +114,20 @@ def ParseHeaderCommentSection(CommentList, FileName = None, IsBinaryHeader = Fal
ValidateCopyright(Result, ST.WRN_INVALID_COPYRIGHT, FileName, LineNo, ErrMsg)
Copyright += Comment + EndOfLine
HeaderCommentStage = HEADER_COMMENT_COPYRIGHT
else:
else:
Abstract += Comment + EndOfLine
HeaderCommentStage = HEADER_COMMENT_DESCRIPTION
elif HeaderCommentStage == HEADER_COMMENT_DESCRIPTION:
#
# in case there is no description
#
#
if _IsCopyrightLine(Comment):
Result, ErrMsg = _ValidateCopyright(Comment)
ValidateCopyright(Result, ST.WRN_INVALID_COPYRIGHT, FileName, LineNo, ErrMsg)
Copyright += Comment + EndOfLine
HeaderCommentStage = HEADER_COMMENT_COPYRIGHT
else:
Description += Comment + EndOfLine
Description += Comment + EndOfLine
elif HeaderCommentStage == HEADER_COMMENT_COPYRIGHT:
if _IsCopyrightLine(Comment):
Result, ErrMsg = _ValidateCopyright(Comment)
@@ -136,23 +136,23 @@ def ParseHeaderCommentSection(CommentList, FileName = None, IsBinaryHeader = Fal
else:
#
# Contents after copyright line are license, those non-copyright lines in between
# copyright line will be discarded
# copyright line will be discarded
#
if LineNo > Last:
if License:
License += EndOfLine
License += Comment + EndOfLine
HeaderCommentStage = HEADER_COMMENT_LICENSE
HeaderCommentStage = HEADER_COMMENT_LICENSE
else:
if not Comment and not License:
continue
License += Comment + EndOfLine
return Abstract.strip(), Description.strip(), Copyright.strip(), License.strip()
## _IsCopyrightLine
# check whether current line is copyright line, the criteria is whether there is case insensitive keyword "Copyright"
# followed by zero or more white space characters followed by a "(" character
# check whether current line is copyright line, the criteria is whether there is case insensitive keyword "Copyright"
# followed by zero or more white space characters followed by a "(" character
#
# @param LineContent: the line need to be checked
# @return: True if current line is copyright line, False else
@@ -160,7 +160,7 @@ def ParseHeaderCommentSection(CommentList, FileName = None, IsBinaryHeader = Fal
def _IsCopyrightLine (LineContent):
LineContent = LineContent.upper()
Result = False
ReIsCopyrightRe = re.compile(r"""(^|\s)COPYRIGHT *\(""", re.DOTALL)
if ReIsCopyrightRe.search(LineContent):
Result = True
@@ -169,23 +169,23 @@ def _IsCopyrightLine (LineContent):
## ParseGenericComment
#
# @param GenericComment: Generic comment list, element of
# @param GenericComment: Generic comment list, element of
# (CommentLine, LineNum)
# @param ContainerFile: Input value for filename of Dec file
#
#
def ParseGenericComment (GenericComment, ContainerFile=None, SkipTag=None):
if ContainerFile:
pass
HelpTxt = None
HelpStr = ''
HelpTxt = None
HelpStr = ''
for Item in GenericComment:
CommentLine = Item[0]
Comment = CleanString2(CommentLine)[1]
if SkipTag is not None and Comment.startswith(SkipTag):
Comment = Comment.replace(SkipTag, '', 1)
HelpStr += Comment + '\n'
if HelpStr:
HelpTxt = TextObject()
if HelpStr.endswith('\n') and not HelpStr.endswith('\n\n') and HelpStr != '\n':
@@ -196,22 +196,22 @@ def ParseGenericComment (GenericComment, ContainerFile=None, SkipTag=None):
## ParsePcdErrorCode
#
# @param Value: original ErrorCode value
# @param Value: original ErrorCode value
# @param ContainerFile: Input value for filename of Dec file
# @param LineNum: Line Num
#
def ParsePcdErrorCode (Value = None, ContainerFile = None, LineNum = None):
try:
# @param LineNum: Line Num
#
def ParsePcdErrorCode (Value = None, ContainerFile = None, LineNum = None):
try:
if Value.strip().startswith((TAB_HEX_START, TAB_CAPHEX_START)):
Base = 16
else:
Base = 10
ErrorCode = long(Value, Base)
if ErrorCode > PCD_ERR_CODE_MAX_SIZE or ErrorCode < 0:
Logger.Error('Parser',
Logger.Error('Parser',
FORMAT_NOT_SUPPORTED,
"The format %s of ErrorCode is not valid, should be UNIT32 type or long type" % Value,
File = ContainerFile,
File = ContainerFile,
Line = LineNum)
#
# To delete the tailing 'L'
@@ -220,27 +220,27 @@ def ParsePcdErrorCode (Value = None, ContainerFile = None, LineNum = None):
except ValueError as XStr:
if XStr:
pass
Logger.Error('Parser',
Logger.Error('Parser',
FORMAT_NOT_SUPPORTED,
"The format %s of ErrorCode is not valid, should be UNIT32 type or long type" % Value,
File = ContainerFile,
File = ContainerFile,
Line = LineNum)
## ParseDecPcdGenericComment
#
# @param GenericComment: Generic comment list, element of (CommentLine,
# @param GenericComment: Generic comment list, element of (CommentLine,
# LineNum)
# @param ContainerFile: Input value for filename of Dec file
#
def ParseDecPcdGenericComment (GenericComment, ContainerFile, TokenSpaceGuidCName, CName, MacroReplaceDict):
HelpStr = ''
#
def ParseDecPcdGenericComment (GenericComment, ContainerFile, TokenSpaceGuidCName, CName, MacroReplaceDict):
HelpStr = ''
PromptStr = ''
PcdErr = None
PcdErrList = []
ValidValueNum = 0
ValidRangeNum = 0
ExpressionNum = 0
for (CommentLine, LineNum) in GenericComment:
Comment = CleanString2(CommentLine)[1]
#
@@ -252,13 +252,13 @@ def ParseDecPcdGenericComment (GenericComment, ContainerFile, TokenSpaceGuidCNam
if MatchedStr:
Macro = MatchedStr.strip().lstrip('$(').rstrip(')').strip()
if Macro in MacroReplaceDict:
Comment = Comment.replace(MatchedStr, MacroReplaceDict[Macro])
Comment = Comment.replace(MatchedStr, MacroReplaceDict[Macro])
if Comment.startswith(TAB_PCD_VALIDRANGE):
if ValidValueNum > 0 or ExpressionNum > 0:
Logger.Error('Parser',
Logger.Error('Parser',
FORMAT_NOT_SUPPORTED,
ST.WRN_MULTI_PCD_RANGES,
File = ContainerFile,
File = ContainerFile,
Line = LineNum)
else:
PcdErr = PcdErrorObject()
@@ -280,21 +280,21 @@ def ParseDecPcdGenericComment (GenericComment, ContainerFile, TokenSpaceGuidCNam
else:
Logger.Error("Parser",
FORMAT_NOT_SUPPORTED,
Cause,
ContainerFile,
Cause,
ContainerFile,
LineNum)
elif Comment.startswith(TAB_PCD_VALIDLIST):
if ValidRangeNum > 0 or ExpressionNum > 0:
Logger.Error('Parser',
Logger.Error('Parser',
FORMAT_NOT_SUPPORTED,
ST.WRN_MULTI_PCD_RANGES,
File = ContainerFile,
File = ContainerFile,
Line = LineNum)
elif ValidValueNum > 0:
Logger.Error('Parser',
Logger.Error('Parser',
FORMAT_NOT_SUPPORTED,
ST.WRN_MULTI_PCD_VALIDVALUE,
File = ContainerFile,
File = ContainerFile,
Line = LineNum)
else:
PcdErr = PcdErrorObject()
@@ -317,15 +317,15 @@ def ParseDecPcdGenericComment (GenericComment, ContainerFile, TokenSpaceGuidCNam
else:
Logger.Error("Parser",
FORMAT_NOT_SUPPORTED,
Cause,
ContainerFile,
Cause,
ContainerFile,
LineNum)
elif Comment.startswith(TAB_PCD_EXPRESSION):
if ValidRangeNum > 0 or ValidValueNum > 0:
Logger.Error('Parser',
Logger.Error('Parser',
FORMAT_NOT_SUPPORTED,
ST.WRN_MULTI_PCD_RANGES,
File = ContainerFile,
File = ContainerFile,
Line = LineNum)
else:
PcdErr = PcdErrorObject()
@@ -344,24 +344,24 @@ def ParseDecPcdGenericComment (GenericComment, ContainerFile, TokenSpaceGuidCNam
else:
PcdErr.SetExpression(Expression)
PcdErrList.append(PcdErr)
else:
else:
Logger.Error("Parser",
FORMAT_NOT_SUPPORTED,
Cause,
ContainerFile,
LineNum)
Cause,
ContainerFile,
LineNum)
elif Comment.startswith(TAB_PCD_PROMPT):
if PromptStr:
Logger.Error('Parser',
Logger.Error('Parser',
FORMAT_NOT_SUPPORTED,
ST.WRN_MULTI_PCD_PROMPT,
File = ContainerFile,
File = ContainerFile,
Line = LineNum)
PromptStr = Comment.replace(TAB_PCD_PROMPT, "", 1).strip()
else:
if Comment:
HelpStr += Comment + '\n'
#
# remove the last EOL if the comment is of format 'FOO\n'
#
@@ -384,9 +384,9 @@ def ParseDecPcdTailComment (TailCommentList, ContainerFile):
LineNum = TailCommentList[0][1]
Comment = TailComment.lstrip(" #")
ReFindFirstWordRe = re.compile(r"""^([^ #]*)""", re.DOTALL)
#
# get first word and compare with SUP_MODULE_LIST
#
@@ -398,7 +398,7 @@ def ParseDecPcdTailComment (TailCommentList, ContainerFile):
# parse line, it must have supported module type specified
#
if Comment.find(TAB_COMMENT_SPLIT) == -1:
Comment += TAB_COMMENT_SPLIT
Comment += TAB_COMMENT_SPLIT
SupMode, HelpStr = GetSplitValueList(Comment, TAB_COMMENT_SPLIT, 1)
SupModuleList = []
for Mod in GetSplitValueList(SupMode, TAB_SPACE_SPLIT):
@@ -407,8 +407,8 @@ def ParseDecPcdTailComment (TailCommentList, ContainerFile):
elif Mod not in SUP_MODULE_LIST:
Logger.Error("UPT",
FORMAT_INVALID,
ST.WRN_INVALID_MODULE_TYPE%Mod,
ContainerFile,
ST.WRN_INVALID_MODULE_TYPE%Mod,
ContainerFile,
LineNum)
else:
SupModuleList.append(Mod)
@@ -417,15 +417,15 @@ def ParseDecPcdTailComment (TailCommentList, ContainerFile):
## _CheckListExpression
#
# @param Expression: Pcd value list expression
# @param Expression: Pcd value list expression
#
def _CheckListExpression(Expression):
ListExpr = ''
if TAB_VALUE_SPLIT in Expression:
ListExpr = Expression[Expression.find(TAB_VALUE_SPLIT)+1:]
ListExpr = Expression[Expression.find(TAB_VALUE_SPLIT)+1:]
else:
ListExpr = Expression
return IsValidListExpr(ListExpr)
## _CheckExpreesion
@@ -443,14 +443,14 @@ def _CheckExpression(Expression):
## _CheckRangeExpression
#
# @param Expression: Pcd range expression
#
#
def _CheckRangeExpression(Expression):
RangeExpr = ''
if TAB_VALUE_SPLIT in Expression:
RangeExpr = Expression[Expression.find(TAB_VALUE_SPLIT)+1:]
else:
RangeExpr = Expression
return IsValidRangeExpr(RangeExpr)
## ValidateCopyright
@@ -459,28 +459,28 @@ def _CheckRangeExpression(Expression):
#
def ValidateCopyright(Result, ErrType, FileName, LineNo, ErrMsg):
if not Result:
Logger.Warn("\nUPT", ErrType, FileName, LineNo, ErrMsg)
Logger.Warn("\nUPT", ErrType, FileName, LineNo, ErrMsg)
## _ValidateCopyright
#
# @param Line: Line that contains copyright information, # stripped
#
#
# @retval Result: True if line is conformed to Spec format, False else
# @retval ErrMsg: the detailed error description
#
#
def _ValidateCopyright(Line):
if Line:
pass
Result = True
ErrMsg = ''
return Result, ErrMsg
def GenerateTokenList (Comment):
#
# Tokenize Comment using '#' and ' ' as token seperators
#
RelplacedComment = None
RelplacedComment = None
while Comment != RelplacedComment:
RelplacedComment = Comment
Comment = Comment.replace('##', '#').replace(' ', ' ').replace(' ', '#').strip('# ')
@@ -500,25 +500,25 @@ def ParseComment (Comment, UsageTokens, TypeTokens, RemoveTokens, ParseVariable)
Usage = None
Type = None
String = None
Comment = Comment[0]
NumTokens = 2
NumTokens = 2
if ParseVariable:
#
# Remove white space around first instance of ':' from Comment if 'Variable'
#
# Remove white space around first instance of ':' from Comment if 'Variable'
# is in front of ':' and Variable is the 1st or 2nd token in Comment.
#
List = Comment.split(':', 1)
List = Comment.split(':', 1)
if len(List) > 1:
SubList = GenerateTokenList (List[0].strip())
if len(SubList) in [1, 2] and SubList[-1] == 'Variable':
if List[1].strip().find('L"') == 0:
if List[1].strip().find('L"') == 0:
Comment = List[0].strip() + ':' + List[1].strip()
#
#
# Remove first instance of L"<VariableName> from Comment and put into String
# if and only if L"<VariableName>" is the 1st token, the 2nd token. Or
# if and only if L"<VariableName>" is the 1st token, the 2nd token. Or
# L"<VariableName>" is the third token immediately following 'Variable:'.
#
End = -1
@@ -533,25 +533,25 @@ def ParseComment (Comment, UsageTokens, TypeTokens, RemoveTokens, ParseVariable)
End = String[2:].find('"')
if End >= 0:
SubList = GenerateTokenList (Comment[:Start])
if len(SubList) < 2:
if len(SubList) < 2:
Comment = Comment[:Start] + String[End + 3:]
String = String[:End + 3]
Type = 'Variable'
NumTokens = 1
NumTokens = 1
#
# Initialze HelpText to Comment.
# Initialze HelpText to Comment.
# Content will be remove from HelpText as matching tokens are found
#
#
HelpText = Comment
#
# Tokenize Comment using '#' and ' ' as token seperators
#
List = GenerateTokenList (Comment)
#
# Search first two tokens for Usage and Type and remove any matching tokens
# Search first two tokens for Usage and Type and remove any matching tokens
# from HelpText
#
for Token in List[0:NumTokens]:
@@ -563,39 +563,39 @@ def ParseComment (Comment, UsageTokens, TypeTokens, RemoveTokens, ParseVariable)
if Type is None and Token in TypeTokens:
Type = TypeTokens[Token]
HelpText = HelpText.replace(Token, '')
if Usage is not None:
if Usage is not None:
for Token in List[0:NumTokens]:
if Token in RemoveTokens:
HelpText = HelpText.replace(Token, '')
#
# If no Usage token is present and set Usage to UNDEFINED
#
#
if Usage is None:
Usage = 'UNDEFINED'
#
# If no Type token is present and set Type to UNDEFINED
#
#
if Type is None:
Type = 'UNDEFINED'
#
# If Type is not 'Variable:', then set String to None
#
#
if Type != 'Variable':
String = None
String = None
#
# Strip ' ' and '#' from the beginning of HelpText
# If HelpText is an empty string after all parsing is
# If HelpText is an empty string after all parsing is
# complete then set HelpText to None
#
#
HelpText = HelpText.lstrip('# ')
if HelpText == '':
HelpText = None
#
# Return parsing results
#
return Usage, Type, String, HelpText
#
return Usage, Type, String, HelpText

View File

@@ -1,11 +1,11 @@
## @file
# This file is used to define class for data type structure
#
# Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -64,13 +64,13 @@ USAGE_ITEM_UNDEFINED = 'UNDEFINED'
USAGE_CONSUMES_LIST = [USAGE_ITEM_CONSUMES,
'CONSUMED',
'ALWAYS_CONSUMED',
'ALWAYS_CONSUMES'
'ALWAYS_CONSUMES'
]
USAGE_PRODUCES_LIST = [USAGE_ITEM_PRODUCES,
'PRODUCED',
'ALWAYS_PRODUCED',
'ALWAYS_PRODUCES'
'ALWAYS_PRODUCES'
]
USAGE_SOMETIMES_PRODUCES_LIST = [USAGE_ITEM_SOMETIMES_PRODUCES,
@@ -94,7 +94,7 @@ TAB_STR_TOKENERR = 'ERR'
#
# Dictionary of usage tokens and their synonmys
#
#
ALL_USAGE_TOKENS = {
"PRODUCES" : "PRODUCES",
"PRODUCED" : "PRODUCES",
@@ -109,20 +109,20 @@ ALL_USAGE_TOKENS = {
"SOMETIMES_CONSUMES" : "SOMETIMES_CONSUMES",
"SOMETIMES_CONSUMED" : "SOMETIMES_CONSUMES",
"SOMETIME_CONSUMES" : "SOMETIMES_CONSUMES",
"UNDEFINED" : "UNDEFINED"
"UNDEFINED" : "UNDEFINED"
}
PROTOCOL_USAGE_TOKENS = {
"TO_START" : "TO_START",
"BY_START" : "BY_START"
}
PROTOCOL_USAGE_TOKENS.update (ALL_USAGE_TOKENS)
#
# Dictionary of GUID type tokens
#
GUID_TYPE_TOKENS = {
#
GUID_TYPE_TOKENS = {
"Event" : "Event",
"File" : "File",
"FV" : "FV",
@@ -134,31 +134,31 @@ GUID_TYPE_TOKENS = {
"Hob:" : "HOB",
"SystemTable" : "SystemTable",
"TokenSpaceGuid" : "TokenSpaceGuid",
"UNDEFINED" : "UNDEFINED"
"UNDEFINED" : "UNDEFINED"
}
#
# Dictionary of Protocol Notify tokens and their synonyms
#
PROTOCOL_NOTIFY_TOKENS = {
#
PROTOCOL_NOTIFY_TOKENS = {
"NOTIFY" : "NOTIFY",
"PROTOCOL_NOTIFY" : "NOTIFY",
"UNDEFINED" : "UNDEFINED"
"UNDEFINED" : "UNDEFINED"
}
#
# Dictionary of PPI Notify tokens and their synonyms
#
PPI_NOTIFY_TOKENS = {
#
PPI_NOTIFY_TOKENS = {
"NOTIFY" : "NOTIFY",
"PPI_NOTIFY" : "NOTIFY",
"UNDEFINED" : "UNDEFINED"
"UNDEFINED" : "UNDEFINED"
}
EVENT_TOKENS = {
"EVENT_TYPE_PERIODIC_TIMER" : "EVENT_TYPE_PERIODIC_TIMER",
"EVENT_TYPE_RELATIVE_TIMER" : "EVENT_TYPE_RELATIVE_TIMER",
"UNDEFINED" : "UNDEFINED"
"UNDEFINED" : "UNDEFINED"
}
BOOTMODE_TOKENS = {
@@ -182,16 +182,16 @@ BOOTMODE_TOKENS = {
"RECOVERY_S4_RESUME" : "RECOVERY_S4_RESUME",
"RECOVERY_S5_RESUME" : "RECOVERY_S5_RESUME",
"RECOVERY_FLASH_UPDATE" : "RECOVERY_FLASH_UPDATE",
"UNDEFINED" : "UNDEFINED"
"UNDEFINED" : "UNDEFINED"
}
HOB_TOKENS = {
HOB_TOKENS = {
"PHIT" : "PHIT",
"MEMORY_ALLOCATION" : "MEMORY_ALLOCATION",
"LOAD_PEIM" : "LOAD_PEIM",
"RESOURCE_DESCRIPTOR" : "RESOURCE_DESCRIPTOR",
"FIRMWARE_VOLUME" : "FIRMWARE_VOLUME",
"UNDEFINED" : "UNDEFINED"
"UNDEFINED" : "UNDEFINED"
}
##
@@ -223,22 +223,22 @@ PCD_DIRVER_TYPE_LIST = ["PEI_PCD_DRIVER", "DXE_PCD_DRIVER"]
#
BOOT_MODE_LIST = ["FULL",
"MINIMAL",
"NO_CHANGE",
"DIAGNOSTICS",
"DEFAULT",
"NO_CHANGE",
"DIAGNOSTICS",
"DEFAULT",
"S2_RESUME",
"S3_RESUME",
"S4_RESUME",
"S5_RESUME",
"S3_RESUME",
"S4_RESUME",
"S5_RESUME",
"FLASH_UPDATE",
"RECOVERY_FULL",
"RECOVERY_MINIMAL",
"RECOVERY_FULL",
"RECOVERY_MINIMAL",
"RECOVERY_NO_CHANGE",
"RECOVERY_DIAGNOSTICS",
"RECOVERY_DIAGNOSTICS",
"RECOVERY_DEFAULT",
"RECOVERY_S2_RESUME",
"RECOVERY_S2_RESUME",
"RECOVERY_S3_RESUME",
"RECOVERY_S4_RESUME",
"RECOVERY_S4_RESUME",
"RECOVERY_S5_RESUME",
"RECOVERY_FLASH_UPDATE"]
@@ -251,9 +251,9 @@ EVENT_TYPE_LIST = ["EVENT_TYPE_PERIODIC_TIMER",
##
# Hob Type List Items
#
HOB_TYPE_LIST = ["PHIT",
HOB_TYPE_LIST = ["PHIT",
"MEMORY_ALLOCATION",
"RESOURCE_DESCRIPTOR",
"RESOURCE_DESCRIPTOR",
"FIRMWARE_VOLUME",
"LOAD_PEIM"]
@@ -290,19 +290,19 @@ BINARY_FILE_TYPE_LIST = ["PE32", "PIC", "TE", "DXE_DEPEX", "VER", "UI", "COMPAT1
BINARY_FILE_TYPE_LIST_IN_UDP = \
["GUID", "FREEFORM",
"UEFI_IMAGE", "PE32", "PIC",
"PEI_DEPEX",
"PEI_DEPEX",
"DXE_DEPEX",
"SMM_DEPEX",
"FV", "TE",
"BIN", "VER", "UI"
"BIN", "VER", "UI"
]
SUBTYPE_GUID_BINARY_FILE_TYPE = "FREEFORM"
##
# Possible values for COMPONENT_TYPE, and their descriptions, are listed in
# the table,
# "Component (module) Types." For each component, the BASE_NAME and
# COMPONENT_TYPE
# Possible values for COMPONENT_TYPE, and their descriptions, are listed in
# the table,
# "Component (module) Types." For each component, the BASE_NAME and
# COMPONENT_TYPE
# are required. The COMPONENT_TYPE definition is case sensitive.
#
COMPONENT_TYPE_LIST = [
@@ -436,7 +436,7 @@ BINARY_FILE_TYPE_FV = 'FV'
BINARY_FILE_TYPE_UI_LIST = [BINARY_FILE_TYPE_UNI_UI,
BINARY_FILE_TYPE_SEC_UI,
BINARY_FILE_TYPE_UI
]
]
BINARY_FILE_TYPE_VER_LIST = [BINARY_FILE_TYPE_UNI_VER,
BINARY_FILE_TYPE_SEC_VER,
BINARY_FILE_TYPE_VER
@@ -712,7 +712,7 @@ TAB_INF_DEFINES_FV_EXT = 'FV_EXT'
TAB_INF_DEFINES_SOURCE_FV = 'SOURCE_FV'
TAB_INF_DEFINES_PACKAGE = 'PACKAGE'
TAB_INF_DEFINES_VERSION_NUMBER = 'VERSION_NUMBER'
TAB_INF_DEFINES_VERSION = 'VERSION'
TAB_INF_DEFINES_VERSION = 'VERSION'
TAB_INF_DEFINES_VERSION_STRING = 'VERSION_STRING'
TAB_INF_DEFINES_PCD_IS_DRIVER = 'PCD_IS_DRIVER'
TAB_INF_DEFINES_TIANO_EDK1_FLASHMAP_H = 'TIANO_EDK1_FLASHMAP_H'
@@ -720,9 +720,9 @@ TAB_INF_DEFINES_ENTRY_POINT = 'ENTRY_POINT'
TAB_INF_DEFINES_UNLOAD_IMAGE = 'UNLOAD_IMAGE'
TAB_INF_DEFINES_CONSTRUCTOR = 'CONSTRUCTOR'
TAB_INF_DEFINES_DESTRUCTOR = 'DESTRUCTOR'
TAB_INF_DEFINES_PCI_VENDOR_ID = 'PCI_VENDOR_ID'
TAB_INF_DEFINES_PCI_DEVICE_ID = 'PCI_DEVICE_ID'
TAB_INF_DEFINES_PCI_CLASS_CODE = 'PCI_CLASS_CODE'
TAB_INF_DEFINES_PCI_VENDOR_ID = 'PCI_VENDOR_ID'
TAB_INF_DEFINES_PCI_DEVICE_ID = 'PCI_DEVICE_ID'
TAB_INF_DEFINES_PCI_CLASS_CODE = 'PCI_CLASS_CODE'
TAB_INF_DEFINES_PCI_REVISION = 'PCI_REVISION'
TAB_INF_DEFINES_PCI_COMPRESS = 'PCI_COMPRESS'
TAB_INF_DEFINES_DEFINE = 'DEFINE'
@@ -819,12 +819,12 @@ TAB_IF_EXIST = '!if exist'
TAB_UNKNOWN = 'UNKNOWN'
#
# Header section (virtual section for abstract, description, copyright,
# Header section (virtual section for abstract, description, copyright,
# license)
#
TAB_HEADER = 'Header'
TAB_HEADER_ABSTRACT = 'Abstract'
TAB_HEADER_DESCRIPTION = 'Description'
TAB_HEADER_DESCRIPTION = 'Description'
TAB_HEADER_COPYRIGHT = 'Copyright'
TAB_HEADER_LICENSE = 'License'
TAB_BINARY_HEADER_IDENTIFIER = 'BinaryHeader'
@@ -833,7 +833,7 @@ TAB_BINARY_HEADER_USERID = 'TianoCore'
#
# Build database path
#
DATABASE_PATH = ":memory:"
DATABASE_PATH = ":memory:"
#
# used by ECC
#
@@ -855,7 +855,7 @@ TAB_DEPENDENCY_EXPRESSION_FILE = "DEPENDENCY-EXPRESSION-FILE"
TAB_UNKNOWN_FILE = "UNKNOWN-TYPE-FILE"
TAB_DEFAULT_BINARY_FILE = "_BINARY_FILE_"
#
# used to indicate the state of processing header comment section of dec,
# used to indicate the state of processing header comment section of dec,
# inf files
#
HEADER_COMMENT_NOT_STARTED = -1
@@ -953,6 +953,6 @@ TOOL_FAMILY_LIST = ["MSFT",
TYPE_HOB_SECTION = 'HOB'
TYPE_EVENT_SECTION = 'EVENT'
TYPE_BOOTMODE_SECTION = 'BOOTMODE'
TYPE_BOOTMODE_SECTION = 'BOOTMODE'
PCD_ERR_CODE_MAX_SIZE = 4294967295

View File

@@ -1,11 +1,11 @@
## @file
# This file is used to check PCD logical expression
#
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -47,7 +47,7 @@ def IsValidBareCString(String):
and (IntChar < 0x23 or IntChar > 0x7e):
return False
PreChar = Char
# Last char cannot be \ if PreChar is not \
if LastChar == '\\' and PreChar == LastChar:
return False
@@ -83,7 +83,7 @@ class _ExprBase:
self.Token = Token
self.Index = 0
self.Len = len(Token)
## SkipWhitespace
#
def SkipWhitespace(self):
@@ -91,14 +91,14 @@ class _ExprBase:
if Char not in ' \t':
break
self.Index += 1
## IsCurrentOp
#
# @param OpList: option list
#
# @param OpList: option list
#
def IsCurrentOp(self, OpList):
self.SkipWhitespace()
LetterOp = ["EQ", "NE", "GE", "LE", "GT", "LT", "NOT", "and", "AND",
LetterOp = ["EQ", "NE", "GE", "LE", "GT", "LT", "NOT", "and", "AND",
"or", "OR", "XOR"]
OpMap = {
'|' : '|',
@@ -107,11 +107,11 @@ class _ExprBase:
'>' : '=',
'<' : '='
}
for Operator in OpList:
if not self.Token[self.Index:].startswith(Operator):
continue
self.Index += len(Operator)
Char = self.Token[self.Index : self.Index + 1]
@@ -119,36 +119,36 @@ class _ExprBase:
or (Operator in OpMap and OpMap[Operator] == Char):
self.Index -= len(Operator)
break
return True
return False
## _LogicalExpressionParser
#
# @param _ExprBase: _ExprBase object
#
#
class _LogicalExpressionParser(_ExprBase):
#
# STRINGITEM can only be logical field according to spec
#
STRINGITEM = -1
#
# Evaluate to True or False
#
LOGICAL = 0
REALLOGICAL = 2
#
# Just arithmetic expression
#
ARITH = 1
def __init__(self, Token):
_ExprBase.__init__(self, Token)
self.Parens = 0
def _CheckToken(self, MatchList):
for Match in MatchList:
if Match and Match.start() == 0:
@@ -156,7 +156,7 @@ class _LogicalExpressionParser(_ExprBase):
self.Token[self.Index:self.Index+Match.end()]
):
return False
self.Index += Match.end()
if self.Token[self.Index - 1] == '"':
return True
@@ -164,61 +164,61 @@ class _LogicalExpressionParser(_ExprBase):
self.Token[self.Index:self.Index+1].isalnum():
self.Index -= Match.end()
return False
Token = self.Token[self.Index - Match.end():self.Index]
if Token.strip() in ["EQ", "NE", "GE", "LE", "GT", "LT",
"NOT", "and", "AND", "or", "OR", "XOR"]:
self.Index -= Match.end()
return False
return True
return False
def IsAtomicNumVal(self):
#
# Hex number
#
Match1 = re.compile(self.HEX_PATTERN).match(self.Token[self.Index:])
#
# Number
#
Match2 = re.compile(self.INT_PATTERN).match(self.Token[self.Index:])
#
# Macro
#
Match3 = re.compile(self.MACRO_PATTERN).match(self.Token[self.Index:])
#
# PcdName
#
Match4 = re.compile(self.PCD_PATTERN).match(self.Token[self.Index:])
return self._CheckToken([Match1, Match2, Match3, Match4])
def IsAtomicItem(self):
#
# Macro
#
Match1 = re.compile(self.MACRO_PATTERN).match(self.Token[self.Index:])
#
# PcdName
#
Match2 = re.compile(self.PCD_PATTERN).match(self.Token[self.Index:])
#
# Quoted string
#
Match3 = re.compile(self.QUOTED_PATTERN).\
match(self.Token[self.Index:].replace('\\\\', '//').\
replace('\\\"', '\\\''))
return self._CheckToken([Match1, Match2, Match3])
## A || B
#
def LogicalExpression(self):
@@ -233,12 +233,12 @@ class _LogicalExpressionParser(_ExprBase):
raise _ExprError(ST.ERR_EXPR_LOGICAL % self.Token)
Ret = self.REALLOGICAL
return Ret
def SpecNot(self):
if self.IsCurrentOp(["NOT", "!", "not"]):
return self.SpecNot()
return self.Rel()
## A < B, A > B, A <= B, A >= B
#
def Rel(self):
@@ -252,7 +252,7 @@ class _LogicalExpressionParser(_ExprBase):
raise _ExprError(ST.ERR_EXPR_LOGICAL % self.Token)
Ret = self.REALLOGICAL
return Ret
## A + B, A - B
#
def Expr(self):
@@ -269,7 +269,7 @@ class _LogicalExpressionParser(_ExprBase):
return Ret
## Factor
#
#
def Factor(self):
if self.IsCurrentOp(["("]):
self.Parens += 1
@@ -279,7 +279,7 @@ class _LogicalExpressionParser(_ExprBase):
(self.Token, self.Token[self.Index:]))
self.Parens -= 1
return Ret
if self.IsAtomicItem():
if self.Token[self.Index - 1] == '"':
return self.STRINGITEM
@@ -289,7 +289,7 @@ class _LogicalExpressionParser(_ExprBase):
else:
raise _ExprError(ST.ERR_EXPR_FACTOR % \
(self.Token[self.Index:], self.Token))
## IsValidLogicalExpression
#
def IsValidLogicalExpression(self):
@@ -319,7 +319,7 @@ class _ValidRangeExpressionParser(_ExprBase):
self.INT = 2
self.IsParenHappen = False
self.IsLogicalOpHappen = False
## IsValidRangeExpression
#
def IsValidRangeExpression(self):
@@ -330,12 +330,12 @@ class _ValidRangeExpressionParser(_ExprBase):
return False, ST.ERR_EXPR_RANGE % self.Token
except _ExprError as XExcept:
return False, XExcept.Error
self.SkipWhitespace()
if self.Index != self.Len:
return False, (ST.ERR_EXPR_RANGE % self.Token)
return True, ''
## RangeExpression
#
def RangeExpression(self):
@@ -346,22 +346,22 @@ class _ValidRangeExpressionParser(_ExprBase):
raise _ExprError(ST.ERR_PAREN_NOT_USED % self.Token)
self.IsParenHappen = False
Ret = self.Unary()
if self.IsCurrentOp(['XOR']):
Ret = self.Unary()
return Ret
## Unary
#
def Unary(self):
if self.IsCurrentOp(["NOT"]):
return self.Unary()
return self.ValidRange()
## ValidRange
#
#
def ValidRange(self):
Ret = -1
if self.IsCurrentOp(["("]):
@@ -375,10 +375,10 @@ class _ValidRangeExpressionParser(_ExprBase):
raise _ExprError(ST.ERR_EXPR_RIGHT_PAREN % self.Token)
self.Parens -= 1
return Ret
if self.IsLogicalOpHappen:
raise _ExprError(ST.ERR_PAREN_NOT_USED % self.Token)
if self.IsCurrentOp(["LT", "GT", "LE", "GE", "EQ", "XOR"]):
IntMatch = \
re.compile(self.INT_PATTERN).match(self.Token[self.Index:])
@@ -417,7 +417,7 @@ class _ValidListExpressionParser(_ExprBase):
def __init__(self, Token):
_ExprBase.__init__(self, Token)
self.NUM = 1
def IsValidListExpression(self):
if self.Len == 0:
return False, ST.ERR_EXPR_LIST_EMPTY
@@ -432,7 +432,7 @@ class _ValidListExpressionParser(_ExprBase):
return False, (ST.ERR_EXPR_LIST % self.Token)
return True, ''
def ListExpression(self):
Ret = -1
self.SkipWhitespace()
@@ -444,7 +444,7 @@ class _ValidListExpressionParser(_ExprBase):
raise _ExprError(ST.ERR_EXPR_LIST % self.Token)
return Ret
## _StringTestParser
#
class _StringTestParser(_ExprBase):
@@ -452,7 +452,7 @@ class _StringTestParser(_ExprBase):
_ExprBase.__init__(self, Token)
## IsValidStringTest
#
#
def IsValidStringTest(self):
if self.Len == 0:
return False, ST.ERR_EXPR_EMPTY
@@ -463,7 +463,7 @@ class _StringTestParser(_ExprBase):
return True, ''
## StringItem
#
#
def StringItem(self):
Match1 = re.compile(self.QUOTED_PATTERN)\
.match(self.Token[self.Index:].replace('\\\\', '//')\
@@ -489,7 +489,7 @@ class _StringTestParser(_ExprBase):
(self.Token, self.Token[self.Index:]))
## StringTest
#
#
def StringTest(self):
self.StringItem()
if not self.IsCurrentOp(["==", "EQ", "!=", "NE"]):
@@ -538,7 +538,7 @@ def IsValidRangeExpr(Token):
##
# Check syntax of value list expression token
#
# @param Token: value list expression token
# @param Token: value list expression token
#
def IsValidListExpr(Token):
return _ValidListExpressionParser(Token).IsValidListExpression()
@@ -562,7 +562,7 @@ def IsValidFeatureFlagExp(Token, Flag=False):
if not Valid:
Valid, Cause = IsValidLogicalExpr(Token, Flag)
if not Valid:
return False, Cause
return False, Cause
return True, ""
if __name__ == '__main__':
@@ -570,4 +570,4 @@ if __name__ == '__main__':
print(_LogicalExpressionParser('gCrownBayTokenSpaceGuid.PcdPciDevice1BridgeAddressLE0').IsValidLogicalExpression())

View File

@@ -1,11 +1,11 @@
## @file
# This file is used to define common static strings and global data used by UPT
#
# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -16,7 +16,7 @@ GlobalData
'''
#
# The workspace directory
# The workspace directory
#
gWORKSPACE = '.'
gPACKAGE_PATH = None

View File

@@ -3,9 +3,9 @@
#
# Copyright (c) 2011 - 2018, 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,
@@ -52,7 +52,7 @@ from Object.POM.CommonObject import TextObject
from Core.FileHook import __FileHookOpen__
from Common.MultipleWorkspace import MultipleWorkspace as mws
## Convert GUID string in xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx style to C
## Convert GUID string in xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx style to C
# structure style
#
# @param Guid: The GUID string
@@ -87,7 +87,7 @@ def CheckGuidRegFormat(GuidValue):
return False
## Convert GUID string in C structure style to
## Convert GUID string in C structure style to
# xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
#
# @param GuidValue: The GUID value in C structure format
@@ -151,12 +151,12 @@ def RemoveDirectory(Directory, Recursively=False):
## Store content in file
#
# This method is used to save file only when its content is changed. This is
# quite useful for "make" system to decide what will be re-built and what
# quite useful for "make" system to decide what will be re-built and what
# won't.
#
# @param File: The path of file
# @param Content: The new content of the file
# @param IsBinaryFile: The flag indicating if the file is binary file
# @param IsBinaryFile: The flag indicating if the file is binary file
# or not
#
def SaveFileOnChange(File, Content, IsBinaryFile=True):
@@ -216,7 +216,7 @@ def GetFiles(Root, SkipList=None, FullPath=True):
# @param FullPath: True if the returned file should be full path
# @param PrefixPath: the path that need to be added to the files found
# @return: the list of files found
#
#
def GetNonMetaDataFiles(Root, SkipList, FullPath, PrefixPath):
FileList = GetFiles(Root, SkipList, FullPath)
NewFileList = []
@@ -602,25 +602,25 @@ def GetWorkspace():
## Get relative path
#
# use full path and workspace to get relative path
# the destination of this function is mainly to resolve the root path issue(like c: or c:\)
# the destination of this function is mainly to resolve the root path issue(like c: or c:\)
#
# @param Fullpath: a string of fullpath
# @param Workspace: a string of workspace
#
def GetRelativePath(Fullpath, Workspace):
RelativePath = ''
if Workspace.endswith(os.sep):
RelativePath = Fullpath[Fullpath.upper().find(Workspace.upper())+len(Workspace):]
else:
RelativePath = Fullpath[Fullpath.upper().find(Workspace.upper())+len(Workspace)+1:]
return RelativePath
## Check whether all module types are in list
#
# check whether all module types (SUP_MODULE_LIST) are in list
#
#
# @param ModuleList: a list of ModuleType
#
def IsAllModuleList(ModuleList):
@@ -632,9 +632,9 @@ def IsAllModuleList(ModuleList):
return True
## Dictionary that use comment(GenericComment, TailComment) as value,
# if a new comment which key already in the dic is inserted, then the
# if a new comment which key already in the dic is inserted, then the
# comment will be merged.
# Key is (Statement, SupArch), when TailComment is added, it will ident
# Key is (Statement, SupArch), when TailComment is added, it will ident
# according to Statement
#
class MergeCommentDict(dict):
@@ -671,7 +671,7 @@ def GenDummyHelpTextObj():
# <Major> ::= (a-fA-F0-9){4}
# <Minor> ::= (a-fA-F0-9){4}
# <DecVersion> ::= (0-65535) ["." (0-99)]
#
#
# @param StringIn: The string contains version defined in INF file.
# It can be Decimal or Hex
#
@@ -764,7 +764,7 @@ def ConvertPath(Path):
## ConvertSpec
#
# during install, convert the Spec string extract from UPD into INF allowable definition,
# during install, convert the Spec string extract from UPD into INF allowable definition,
# the difference is period is allowed in the former (not the first letter) but not in the latter.
# return converted Spec string
#
@@ -787,7 +787,7 @@ def ConvertSpec(SpecStr):
# The rule is elements in List A are in List B and elements in List B are in List A.
#
# @param ListA, ListB Lists need to be judged.
#
#
# @return True ListA and ListB are identical
# @return False ListA and ListB are different with each other
#
@@ -808,10 +808,10 @@ def IsEqualList(ListA, ListB):
## ConvertArchList
#
# Convert item in ArchList if the start character is lower case.
# In UDP spec, Arch is only allowed as: [A-Z]([a-zA-Z0-9])*
# In UDP spec, Arch is only allowed as: [A-Z]([a-zA-Z0-9])*
#
# @param ArchList The ArchList need to be converted.
#
#
# @return NewList The ArchList been converted.
#
def ConvertArchList(ArchList):
@@ -835,7 +835,7 @@ def ConvertArchList(ArchList):
# If one line ends with a line extender, then it will be combined together with next line.
#
# @param LineList The LineList need to be processed.
#
#
# @return NewList The ArchList been processed.
#
def ProcessLineExtender(LineList):
@@ -854,11 +854,11 @@ def ProcessLineExtender(LineList):
## ProcessEdkComment
#
# Process EDK style comment in LineList: c style /* */ comment or cpp style // comment
# Process EDK style comment in LineList: c style /* */ comment or cpp style // comment
#
#
# @param LineList The LineList need to be processed.
#
#
# @return LineList The LineList been processed.
# @return FirstPos Where Edk comment is first found, -1 if not found
#
@@ -868,7 +868,7 @@ def ProcessEdkComment(LineList):
StartPos = -1
EndPos = -1
FirstPos = -1
while(Count < len(LineList)):
Line = LineList[Count].strip()
if Line.startswith("/*"):
@@ -886,7 +886,7 @@ def ProcessEdkComment(LineList):
FindEdkBlockComment = True
break
Count = Count + 1
if FindEdkBlockComment:
if FirstPos == -1:
FirstPos = StartPos
@@ -900,9 +900,9 @@ def ProcessEdkComment(LineList):
LineList[Count] = Line.replace("//", '#')
if FirstPos == -1:
FirstPos = Count
Count = Count + 1
return LineList, FirstPos
## GetLibInstanceInfo
@@ -994,13 +994,13 @@ def GetLibInstanceInfo(String, WorkSpace, LineNo):
## GetLocalValue
#
# Generate the local value for INF and DEC file. If Lang attribute not present, then use this value.
# If present, and there is no element without the Lang attribute, and one of the elements has the rfc1766 code is
# "en-x-tianocore", or "en-US" if "en-x-tianocore" was not found, or "en" if "en-US" was not found, or startswith 'en'
# If present, and there is no element without the Lang attribute, and one of the elements has the rfc1766 code is
# "en-x-tianocore", or "en-US" if "en-x-tianocore" was not found, or "en" if "en-US" was not found, or startswith 'en'
# if 'en' was not found, then use this value.
# If multiple entries of a tag exist which have the same language code, use the last entry.
#
# @param ValueList A list need to be processed.
# @param UseFirstValue: True to use the first value, False to use the last value
# @param UseFirstValue: True to use the first value, False to use the last value
#
# @return LocalValue
def GetLocalValue(ValueList, UseFirstValue=False):
@@ -1040,7 +1040,7 @@ def GetLocalValue(ValueList, UseFirstValue=False):
Value5 = Value
else:
Value5 = Value
if Value1:
return Value1
if Value2:
@@ -1051,7 +1051,7 @@ def GetLocalValue(ValueList, UseFirstValue=False):
return Value4
if Value5:
return Value5
return ''
@@ -1088,29 +1088,29 @@ def GetCharIndexOutStr(CommentCharacter, Line):
#
# Check the UNI file path
#
# @param FilePath: The UNI file path
# @param FilePath: The UNI file path
#
def ValidateUNIFilePath(Path):
Suffix = Path[Path.rfind(TAB_SPLIT):]
#
# Check if the suffix is one of the '.uni', '.UNI', '.Uni'
# Check if the suffix is one of the '.uni', '.UNI', '.Uni'
#
if Suffix not in TAB_UNI_FILE_SUFFIXS:
Logger.Error("Unicode File Parser",
ToolError.FORMAT_INVALID,
Message=ST.ERR_UNI_FILE_SUFFIX_WRONG,
ExtraData=Path)
Logger.Error("Unicode File Parser",
ToolError.FORMAT_INVALID,
Message=ST.ERR_UNI_FILE_SUFFIX_WRONG,
ExtraData=Path)
#
# Check if '..' in the file name(without suffixe)
#
if (TAB_SPLIT + TAB_SPLIT) in Path:
Logger.Error("Unicode File Parser",
ToolError.FORMAT_INVALID,
Message=ST.ERR_UNI_FILE_NAME_INVALID,
ExtraData=Path)
Logger.Error("Unicode File Parser",
ToolError.FORMAT_INVALID,
Message=ST.ERR_UNI_FILE_NAME_INVALID,
ExtraData=Path)
#
# Check if the file name is valid according to the DEC and INF specification
#
@@ -1118,8 +1118,8 @@ def ValidateUNIFilePath(Path):
FileName = Path.replace(Suffix, '')
InvalidCh = re.sub(Pattern, '', FileName)
if InvalidCh:
Logger.Error("Unicode File Parser",
ToolError.FORMAT_INVALID,
Message=ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID,
ExtraData=Path)
Logger.Error("Unicode File Parser",
ToolError.FORMAT_INVALID,
Message=ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID,
ExtraData=Path)

View File

@@ -3,9 +3,9 @@
#
# Copyright (c) 2011 - 2018, 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,
@@ -42,7 +42,7 @@ def __HexDigit(TempChar):
return True
else:
return False
## IsValidHex() method
#
# Whether char input is a Hex data.
@@ -59,7 +59,7 @@ def IsValidHex(HexStr):
return False
## Judge the input string is valid bool type or not.
#
#
# <TRUE> ::= {"TRUE"} {"true"} {"True"} {"0x1"} {"0x01"}
# <FALSE> ::= {"FALSE"} {"false"} {"False"} {"0x0"} {"0x00"}
# <BoolType> ::= {<TRUE>} {<FALSE>}
@@ -90,18 +90,18 @@ def IsValidBoolType(BoolString):
#
else:
return False
## Is Valid Module Type List or not
#
# @param ModuleTypeList: A list contain ModuleType strings need to be
## Is Valid Module Type List or not
#
# @param ModuleTypeList: A list contain ModuleType strings need to be
# judged.
#
def IsValidInfMoudleTypeList(ModuleTypeList):
for ModuleType in ModuleTypeList:
return IsValidInfMoudleType(ModuleType)
## Is Valid Module Type or not
#
## Is Valid Module Type or not
#
# @param ModuleType: A string contain ModuleType need to be judged.
#
def IsValidInfMoudleType(ModuleType):
@@ -110,8 +110,8 @@ def IsValidInfMoudleType(ModuleType):
else:
return False
## Is Valid Component Type or not
#
## Is Valid Component Type or not
#
# @param ComponentType: A string contain ComponentType need to be judged.
#
def IsValidInfComponentType(ComponentType):
@@ -124,7 +124,7 @@ def IsValidInfComponentType(ComponentType):
## Is valid Tool Family or not
#
# @param ToolFamily: A string contain Tool Family need to be judged.
# Famlily := [A-Z]([a-zA-Z0-9])*
# Famlily := [A-Z]([a-zA-Z0-9])*
#
def IsValidToolFamily(ToolFamily):
ReIsValieFamily = re.compile(r"^[A-Z]+[A-Za-z0-9]{0,}$", re.DOTALL)
@@ -148,13 +148,13 @@ def IsValidToolTagName(TagName):
return True
## Is valid arch or not
#
#
# @param Arch The arch string need to be validated
# <OA> ::= (a-zA-Z)(A-Za-z0-9){0,}
# <arch> ::= {"IA32"} {"X64"} {"IPF"} {"EBC"} {<OA>}
# {"common"}
# @param Arch: Input arch
#
#
def IsValidArch(Arch):
if Arch == 'common':
return True
@@ -164,55 +164,55 @@ def IsValidArch(Arch):
return True
## Is valid family or not
#
#
# <Family> ::= {"MSFT"} {"GCC"} {"INTEL"} {<Usr>} {"*"}
# <Usr> ::= [A-Z][A-Za-z0-9]{0,}
#
# @param family: The family string need to be validated
#
#
def IsValidFamily(Family):
Family = Family.strip()
if Family == '*':
return True
if Family == '':
return True
ReIsValidFamily = re.compile(r"^[A-Z]+[A-Za-z0-9]{0,}$", re.DOTALL)
if ReIsValidFamily.match(Family) is None:
return False
return True
## Is valid build option name or not
#
#
# @param BuildOptionName: The BuildOptionName string need to be validated
#
def IsValidBuildOptionName(BuildOptionName):
if not BuildOptionName:
return False
ToolOptionList = GetSplitValueList(BuildOptionName, '_', 4)
if len(ToolOptionList) != 5:
return False
ReIsValidBuildOption1 = re.compile(r"^\s*(\*)|([A-Z][a-zA-Z0-9]*)$")
ReIsValidBuildOption2 = re.compile(r"^\s*(\*)|([a-zA-Z][a-zA-Z0-9]*)$")
if ReIsValidBuildOption1.match(ToolOptionList[0]) is None:
return False
if ReIsValidBuildOption1.match(ToolOptionList[1]) is None:
return False
if ReIsValidBuildOption2.match(ToolOptionList[2]) is None:
return False
if ToolOptionList[3] == "*" and ToolOptionList[4] not in ['FAMILY', 'DLL', 'DPATH']:
return False
return True
## IsValidToken
#
# Check if pattern string matches total token
@@ -234,14 +234,14 @@ def IsValidToken(ReString, Token):
def IsValidPath(Path, Root):
Path = Path.strip()
OrigPath = Path.replace('\\', '/')
Path = os.path.normpath(Path).replace('\\', '/')
Root = os.path.normpath(Root).replace('\\', '/')
FullPath = mws.join(Root, Path)
if not os.path.exists(FullPath):
return False
#
# If Path is absolute path.
# It should be in Root.
@@ -263,16 +263,16 @@ def IsValidPath(Path, Root):
for Rel in ['/.', '/..', '/']:
if OrigPath.endswith(Rel):
return False
Path = Path.rstrip('/')
#
# Check relative path
#
for Word in Path.split('/'):
if not IsValidWord(Word):
return False
return True
## IsValidInstallPath
@@ -294,12 +294,12 @@ def IsValidInstallPath(Path):
return False
if Path.startswith('.'):
return False
if Path.find('..') != -1:
return False
return True
## IsValidCFormatGuid
#
@@ -309,14 +309,14 @@ def IsValidInstallPath(Path):
#
def IsValidCFormatGuid(Guid):
#
# Valid: { 0xf0b11735, 0x87a0, 0x4193, {0xb2, 0x66, 0x53, 0x8c, 0x38,
# Valid: { 0xf0b11735, 0x87a0, 0x4193, {0xb2, 0x66, 0x53, 0x8c, 0x38,
# 0xaf, 0x48, 0xce }}
# Invalid: { 0xf0b11735, 0x87a0, 0x4193, {0xb2, 0x66, 0x53, 0x8c, 0x38,
# Invalid: { 0xf0b11735, 0x87a0, 0x4193, {0xb2, 0x66, 0x53, 0x8c, 0x38,
# 0xaf, 0x48, 0xce }} 0x123
# Invalid: { 0xf0b1 1735, 0x87a0, 0x4193, {0xb2, 0x66, 0x53, 0x8c, 0x38,
# Invalid: { 0xf0b1 1735, 0x87a0, 0x4193, {0xb2, 0x66, 0x53, 0x8c, 0x38,
# 0xaf, 0x48, 0xce }}
#
List = ['{', 10, ',', 6, ',', 6, ',{', 4, ',', 4, ',', 4,
List = ['{', 10, ',', 6, ',', 6, ',{', 4, ',', 4, ',', 4,
',', 4, ',', 4, ',', 4, ',', 4, ',', 4, '}}']
Index = 0
Value = ''
@@ -337,14 +337,14 @@ def IsValidCFormatGuid(Guid):
if not Value.startswith('0x') and not Value.startswith('0X'):
return False
#
# Index may out of bound
#
if not isinstance(List[Index], type(1)) or \
len(Value) > List[Index] or len(Value) < 3:
return False
#
# Check if string can be converted to integer
# Throw exception if not
@@ -367,23 +367,23 @@ def IsValidCFormatGuid(Guid):
# Check whether the PCD type is valid
#
# @param PcdTypeString: The PcdType string need to be checked.
#
#
def IsValidPcdType(PcdTypeString):
if PcdTypeString.upper() in PCD_USAGE_TYPE_LIST_OF_MODULE:
return True
else:
return False
## IsValidWord
#
# Check whether the word is valid.
# <Word> ::= (a-zA-Z0-9_)(a-zA-Z0-9_-){0,} Alphanumeric characters with
# optional
# dash "-" and/or underscore "_" characters. No whitespace
# <Word> ::= (a-zA-Z0-9_)(a-zA-Z0-9_-){0,} Alphanumeric characters with
# optional
# dash "-" and/or underscore "_" characters. No whitespace
# characters are permitted.
#
#
# @param Word: The word string need to be checked.
#
#
def IsValidWord(Word):
if not Word:
return False
@@ -394,9 +394,9 @@ def IsValidWord(Word):
not Word[0] == '_' and \
not Word[0].isdigit():
return False
LastChar = ''
for Char in Word[1:]:
for Char in Word[1:]:
if (not Char.isalpha()) and \
(not Char.isdigit()) and \
Char != '-' and \
@@ -406,82 +406,82 @@ def IsValidWord(Word):
if Char == '.' and LastChar == '.':
return False
LastChar = Char
return True
## IsValidSimpleWord
#
# Check whether the SimpleWord is valid.
# <SimpleWord> ::= (a-zA-Z0-9)(a-zA-Z0-9_-){0,}
# <SimpleWord> ::= (a-zA-Z0-9)(a-zA-Z0-9_-){0,}
# A word that cannot contain a period character.
#
#
# @param Word: The word string need to be checked.
#
#
def IsValidSimpleWord(Word):
ReIsValidSimpleWord = \
re.compile(r"^[0-9A-Za-z][0-9A-Za-z\-_]*$", re.DOTALL)
Word = Word.strip()
if not Word:
return False
if not ReIsValidSimpleWord.match(Word):
return False
return True
## IsValidDecVersion
#
# Check whether the decimal version is valid.
# <DecVersion> ::= (0-9){1,} ["." (0-9){1,}]
#
#
# @param Word: The word string need to be checked.
#
#
def IsValidDecVersion(Word):
if Word.find('.') > -1:
ReIsValidDecVersion = re.compile(r"[0-9]+\.?[0-9]+$")
else:
ReIsValidDecVersion = re.compile(r"[0-9]+$")
if ReIsValidDecVersion.match(Word) is None:
return False
return False
return True
## IsValidHexVersion
#
# Check whether the hex version is valid.
# <HexVersion> ::= "0x" <Major> <Minor>
# <Major> ::= <HexDigit>{4}
# <Minor> ::= <HexDigit>{4}
#
#
# @param Word: The word string need to be checked.
#
#
def IsValidHexVersion(Word):
ReIsValidHexVersion = re.compile(r"[0][xX][0-9A-Fa-f]{8}$", re.DOTALL)
if ReIsValidHexVersion.match(Word) is None:
return False
return True
## IsValidBuildNumber
#
# Check whether the BUILD_NUMBER is valid.
# ["BUILD_NUMBER" "=" <Integer>{1,4} <EOL>]
#
#
# @param Word: The BUILD_NUMBER string need to be checked.
#
#
def IsValidBuildNumber(Word):
ReIsValieBuildNumber = re.compile(r"[0-9]{1,4}$", re.DOTALL)
if ReIsValieBuildNumber.match(Word) is None:
return False
return True
## IsValidDepex
#
# Check whether the Depex is valid.
#
#
# @param Word: The Depex string need to be checked.
#
#
def IsValidDepex(Word):
Index = Word.upper().find("PUSH")
if Index > -1:
@@ -490,12 +490,12 @@ def IsValidDepex(Word):
ReIsValidCName = re.compile(r"^[A-Za-z_][0-9A-Za-z_\s\.]*$", re.DOTALL)
if ReIsValidCName.match(Word) is None:
return False
return True
## IsValidNormalizedString
#
# Check
# Check
# <NormalizedString> ::= <DblQuote> [{<Word>} {<Space>}]{1,} <DblQuote>
# <Space> ::= 0x20
#
@@ -504,31 +504,31 @@ def IsValidDepex(Word):
def IsValidNormalizedString(String):
if String == '':
return True
for Char in String:
if Char == '\t':
return False
StringList = GetSplitValueList(String, TAB_SPACE_SPLIT)
for Item in StringList:
if not Item:
continue
if not IsValidWord(Item):
return False
return True
## IsValidIdString
#
# Check whether the IdString is valid.
#
#
# @param IdString: The IdString need to be checked.
#
#
def IsValidIdString(String):
if IsValidSimpleWord(String.strip()):
return True
if String.strip().startswith('"') and \
String.strip().endswith('"'):
String = String[1:-1]
@@ -536,7 +536,7 @@ def IsValidIdString(String):
return True
if IsValidNormalizedString(String):
return True
return False
## IsValidVersionString
@@ -546,52 +546,52 @@ def IsValidIdString(String):
# <WhiteSpace> ::= {<Tab>} {<Space>}
# <Tab> ::= 0x09
# <Space> ::= 0x20
# <AsciiChars> ::= (0x21 - 0x7E)
#
# <AsciiChars> ::= (0x21 - 0x7E)
#
# @param VersionString: The VersionString need to be checked.
#
#
def IsValidVersionString(VersionString):
VersionString = VersionString.strip()
for Char in VersionString:
if not (Char >= 0x21 and Char <= 0x7E):
return False
return True
## IsValidPcdValue
#
# Check whether the PcdValue is valid.
#
#
# @param VersionString: The PcdValue need to be checked.
#
#
def IsValidPcdValue(PcdValue):
for Char in PcdValue:
if Char == '\n' or Char == '\t' or Char == '\f':
return False
#
# <Boolean>
#
if IsValidFeatureFlagExp(PcdValue, True)[0]:
return True
#
# <Number> ::= {<Integer>} {<HexNumber>}
# <Integer> ::= {(0-9)} {(1-9)(0-9){1,}}
# <HexNumber> ::= "0x" <HexDigit>{1,}
# <HexDigit> ::= (a-fA-F0-9)
#
#
if IsValidHex(PcdValue):
return True
ReIsValidIntegerSingle = re.compile(r"^\s*[0-9]\s*$", re.DOTALL)
if ReIsValidIntegerSingle.match(PcdValue) is not None:
return True
ReIsValidIntegerMulti = re.compile(r"^\s*[1-9][0-9]+\s*$", re.DOTALL)
ReIsValidIntegerMulti = re.compile(r"^\s*[1-9][0-9]+\s*$", re.DOTALL)
if ReIsValidIntegerMulti.match(PcdValue) is not None:
return True
#
# <StringVal> ::= {<StringType>} {<Array>} {"$(" <MACRO> ")"}
# <StringType> ::= {<UnicodeString>} {<CString>}
@@ -609,7 +609,7 @@ def IsValidPcdValue(PcdValue):
IsTrue = True
if IsTrue:
return IsTrue
#
# <Array> ::= {<CArray>} {<NList>} {<CFormatGUID>}
# <CArray> ::= "{" [<NList>] <CArray>{0,} "}"
@@ -619,44 +619,44 @@ def IsValidPcdValue(PcdValue):
#
if IsValidCFormatGuid(PcdValue):
return True
ReIsValidByteHex = re.compile(r"^\s*0x[0-9a-fA-F]{1,2}\s*$", re.DOTALL)
if PcdValue.strip().startswith('{') and PcdValue.strip().endswith('}') :
StringValue = PcdValue.strip().lstrip('{').rstrip('}')
ValueList = StringValue.split(',')
AllValidFlag = True
for ValueItem in ValueList:
for ValueItem in ValueList:
if not ReIsValidByteHex.match(ValueItem.strip()):
AllValidFlag = False
if AllValidFlag:
return True
#
#
# NList
#
AllValidFlag = True
ValueList = PcdValue.split(',')
for ValueItem in ValueList:
for ValueItem in ValueList:
if not ReIsValidByteHex.match(ValueItem.strip()):
AllValidFlag = False
if AllValidFlag:
return True
return False
## IsValidCVariableName
#
# Check whether the PcdValue is valid.
#
#
# @param VersionString: The PcdValue need to be checked.
#
#
def IsValidCVariableName(CName):
ReIsValidCName = re.compile(r"^[A-Za-z_][0-9A-Za-z_]*$", re.DOTALL)
if ReIsValidCName.match(CName) is None:
return False
return True
## IsValidIdentifier
@@ -671,7 +671,7 @@ def IsValidIdentifier(Ident):
ReIdent = re.compile(r"^[A-Za-z_][0-9A-Za-z_]*$", re.DOTALL)
if ReIdent.match(Ident) is None:
return False
return True
## IsValidDecVersionVal
@@ -682,10 +682,10 @@ def IsValidIdentifier(Ident):
#
def IsValidDecVersionVal(Ver):
ReVersion = re.compile(r"[0-9]+(\.[0-9]{1,2})$")
if ReVersion.match(Ver) is None:
return False
return True
@@ -699,7 +699,7 @@ def IsValidLibName(LibName):
ReLibName = re.compile("^[A-Z]+[a-zA-Z0-9]*$")
if not ReLibName.match(LibName):
return False
return True
# IsValidUserId

View File

@@ -1,12 +1,12 @@
## @file
# This file is used to define common parsing related functions used in parsing
# This file is used to define common parsing related functions used in parsing
# INF/DEC/DSC process
#
# Copyright (c) 2011 - 2018, 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,
@@ -74,7 +74,7 @@ def GetBuildOption(String, File, LineNo= -1):
# Get Library of Dsc as <LibraryClassKeyWord>|<LibraryInstance>
#
# @param Item: String as <LibraryClassKeyWord>|<LibraryInstance>
# @param ContainerFile: The file which describes the library class, used for
# @param ContainerFile: The file which describes the library class, used for
# error report
#
def GetLibraryClass(Item, ContainerFile, WorkspaceDir, LineNo= -1):
@@ -99,7 +99,7 @@ def GetLibraryClass(Item, ContainerFile, WorkspaceDir, LineNo= -1):
# [|<TokenSpaceGuidCName>.<PcdCName>]
#
# @param Item: String as <LibraryClassKeyWord>|<LibraryInstance>
# @param ContainerFile: The file which describes the library class, used for
# @param ContainerFile: The file which describes the library class, used for
# error report
#
def GetLibraryClassOfInf(Item, ContainerFile, WorkspaceDir, LineNo= -1):
@@ -148,7 +148,7 @@ def CheckPcdTokenInfo(TokenInfoString, Section, File, LineNo= -1):
#
# @param Item: String as <PcdTokenSpaceGuidCName>.<TokenCName>|
# <Value>[|<Type>|<MaximumDatumSize>]
# @param ContainerFile: The file which describes the pcd, used for error
# @param ContainerFile: The file which describes the pcd, used for error
# report
#
@@ -176,7 +176,7 @@ def GetPcd(Item, Type, ContainerFile, LineNo= -1):
#
# @param Item: String as <PcdTokenSpaceGuidCName>
# .<TokenCName>|TRUE/FALSE
# @param ContainerFile: The file which describes the pcd, used for error
# @param ContainerFile: The file which describes the pcd, used for error
# report
#
def GetFeatureFlagPcd(Item, Type, ContainerFile, LineNo= -1):
@@ -200,7 +200,7 @@ def GetFeatureFlagPcd(Item, Type, ContainerFile, LineNo= -1):
#
# @param Item: String as <PcdTokenSpaceGuidCName>.<TokenCName>|
# TRUE/FALSE
# @param ContainerFile: The file which describes the pcd, used for error
# @param ContainerFile: The file which describes the pcd, used for error
# report
#
def GetDynamicDefaultPcd(Item, Type, ContainerFile, LineNo= -1):
@@ -226,7 +226,7 @@ def GetDynamicDefaultPcd(Item, Type, ContainerFile, LineNo= -1):
#
# @param Item: String as <PcdTokenSpaceGuidCName>.<TokenCName>|
# TRUE/FALSE
# @param ContainerFile: The file which describes the pcd, used for error
# @param ContainerFile: The file which describes the pcd, used for error
# report
#
def GetDynamicHiiPcd(Item, Type, ContainerFile, LineNo= -1):
@@ -253,7 +253,7 @@ def GetDynamicHiiPcd(Item, Type, ContainerFile, LineNo= -1):
#
# @param Item: String as <PcdTokenSpaceGuidCName>.<TokenCName>
# |TRUE/FALSE
# @param ContainerFile: The file which describes the pcd, used for error
# @param ContainerFile: The file which describes the pcd, used for error
# report
#
def GetDynamicVpdPcd(Item, Type, ContainerFile, LineNo= -1):
@@ -273,7 +273,7 @@ def GetDynamicVpdPcd(Item, Type, ContainerFile, LineNo= -1):
## GetComponent
#
# Parse block of the components defined in dsc file
# Set KeyValues as [ ['component name', [lib1, lib2, lib3],
# Set KeyValues as [ ['component name', [lib1, lib2, lib3],
# [bo1, bo2, bo3], [pcd1, pcd2, pcd3]], ...]
#
# @param Lines: The content to be parsed
@@ -408,7 +408,7 @@ def GetExec(String):
## GetComponents
#
# Parse block of the components defined in dsc file
# Set KeyValues as [ ['component name', [lib1, lib2, lib3], [bo1, bo2, bo3],
# Set KeyValues as [ ['component name', [lib1, lib2, lib3], [bo1, bo2, bo3],
# [pcd1, pcd2, pcd3]], ...]
#
# @param Lines: The content to be parsed
@@ -531,7 +531,7 @@ def GetComponents(Lines, KeyValues, CommentCharacter):
#
# @param Item: String as <Filename>[|<Family>[|<TagName>[|<ToolCode>
# [|<PcdFeatureFlag>]]]]
# @param ContainerFile: The file which describes the library class, used
# @param ContainerFile: The file which describes the library class, used
# for error report
#
def GetSource(Item, ContainerFile, FileRelativePath, LineNo= -1):
@@ -556,7 +556,7 @@ def GetSource(Item, ContainerFile, FileRelativePath, LineNo= -1):
#
# @param Item: String as <Filename>[|<Family>[|<TagName>
# [|<ToolCode>[|<PcdFeatureFlag>]]]]
# @param ContainerFile: The file which describes the library class,
# @param ContainerFile: The file which describes the library class,
# used for error report
#
def GetBinary(Item, ContainerFile, LineNo= -1):
@@ -580,7 +580,7 @@ def GetBinary(Item, ContainerFile, LineNo= -1):
#
# @param Item: String as <GuidCName>[|<PcdFeatureFlag>]
# @param Type: Type of parsing string
# @param ContainerFile: The file which describes the library class,
# @param ContainerFile: The file which describes the library class,
# used for error report
#
def GetGuidsProtocolsPpisOfInf(Item):
@@ -594,7 +594,7 @@ def GetGuidsProtocolsPpisOfInf(Item):
#
# @param Item: String as <GuidCName>=<GuidValue>
# @param Type: Type of parsing string
# @param ContainerFile: The file which describes the library class,
# @param ContainerFile: The file which describes the library class,
# used for error report
#
def GetGuidsProtocolsPpisOfDec(Item, Type, ContainerFile, LineNo= -1):
@@ -625,7 +625,7 @@ def GetGuidsProtocolsPpisOfDec(Item, Type, ContainerFile, LineNo= -1):
#
# @param Item: String as <PackagePath>[|<PcdFeatureFlag>]
# @param Type: Type of parsing string
# @param ContainerFile: The file which describes the library class,
# @param ContainerFile: The file which describes the library class,
# used for error report
#
def GetPackage(Item, ContainerFile, FileRelativePath, LineNo= -1):
@@ -936,7 +936,7 @@ def MacroParser(Line, FileName, SectionType, FileLocalMacros):
# <Value> ::= {<NumVal>} {<Boolean>} {<AsciiString>} {<GUID>}
# {<CString>} {<UnicodeString>} {<CArray>}
#
# The definition of <NumVal>, <PATH>, <Boolean>, <GUID>, <CString>,
# The definition of <NumVal>, <PATH>, <Boolean>, <GUID>, <CString>,
# <UnicodeString>, <CArray> are subset of <AsciiString>.
#
ReIsValidMacroValue = re.compile(r"^[\x20-\x7e]*$", re.DOTALL)
@@ -950,15 +950,15 @@ def MacroParser(Line, FileName, SectionType, FileLocalMacros):
return Name, Value
## GenSection
## GenSection
#
# generate section contents
#
# @param SectionName: indicate the name of the section, details refer to
# @param SectionName: indicate the name of the section, details refer to
# INF, DEC specs
# @param SectionDict: section statement dict, key is SectionAttrs(arch,
# moduletype or platform may exist as needed) list
# seperated by space,
# @param SectionDict: section statement dict, key is SectionAttrs(arch,
# moduletype or platform may exist as needed) list
# seperated by space,
# value is statement
#
def GenSection(SectionName, SectionDict, SplitArch=True, NeedBlankLine=False):
@@ -1004,10 +1004,10 @@ def GenSection(SectionName, SectionDict, SplitArch=True, NeedBlankLine=False):
return Content
## ConvertArchForInstall
# if Arch.upper() is in "IA32", "X64", "IPF", and "EBC", it must be upper case. "common" must be lower case.
# if Arch.upper() is in "IA32", "X64", "IPF", and "EBC", it must be upper case. "common" must be lower case.
# Anything else, the case must be preserved
#
# @param Arch: the arch string that need to be converted, it should be stripped before pass in
# @param Arch: the arch string that need to be converted, it should be stripped before pass in
# @return: the arch string that get converted
#
def ConvertArchForInstall(Arch):

View File

@@ -3,9 +3,9 @@
#
# Copyright (c) 2014 - 2018, 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,
@@ -148,9 +148,9 @@ def GetLanguageCode1766(LangName, File=None):
if LangName.isalpha() and gLANG_CONV_TABLE.get(LangName.lower()):
return LangName
else:
EdkLogger.Error("Unicode File Parser",
EdkLogger.Error("Unicode File Parser",
ToolError.FORMAT_INVALID,
"Invalid RFC 1766 language code : %s" % LangName,
"Invalid RFC 1766 language code : %s" % LangName,
File)
elif length == 5:
if LangName[0:2].isalpha() and LangName[2] == '-':
@@ -167,11 +167,11 @@ def GetLanguageCode1766(LangName, File=None):
if Key == LangName[0:3].lower():
return Key
EdkLogger.Error("Unicode File Parser",
EdkLogger.Error("Unicode File Parser",
ToolError.FORMAT_INVALID,
"Invalid RFC 4646 language code : %s" % LangName,
"Invalid RFC 4646 language code : %s" % LangName,
File)
## GetLanguageCode
#
# Check the language code read from .UNI file and convert RFC 1766 codes to RFC 4646 codes if appropriate
@@ -191,9 +191,9 @@ def GetLanguageCode(LangName, IsCompatibleMode, File):
return TempLangName
return LangName
else:
EdkLogger.Error("Unicode File Parser",
EdkLogger.Error("Unicode File Parser",
ToolError.FORMAT_INVALID,
"Invalid RFC 1766 language code : %s" % LangName,
"Invalid RFC 1766 language code : %s" % LangName,
File)
if (LangName[0] == 'X' or LangName[0] == 'x') and LangName[1] == '-':
return LangName
@@ -212,9 +212,9 @@ def GetLanguageCode(LangName, IsCompatibleMode, File):
if LangName[0:3].isalpha() and gLANG_CONV_TABLE.get(LangName.lower()) is None and LangName[3] == '-':
return LangName
EdkLogger.Error("Unicode File Parser",
EdkLogger.Error("Unicode File Parser",
ToolError.FORMAT_INVALID,
"Invalid RFC 4646 language code : %s" % LangName,
"Invalid RFC 4646 language code : %s" % LangName,
File)
## FormatUniEntry
@@ -231,7 +231,7 @@ def FormatUniEntry(StrTokenName, TokenValueList, ContainerFile):
PreFormatLength = 40
if len(StrTokenName) > PreFormatLength:
PreFormatLength = len(StrTokenName) + 1
for (Lang, Value) in TokenValueList:
for (Lang, Value) in TokenValueList:
if not Value or Lang == DT.TAB_LANGUAGE_EN_X:
continue
if Lang == '':
@@ -333,15 +333,15 @@ class UniFileClassObject(object):
except UnicodeError as Xstr:
FileIn = codecs.open(File.Path, mode='rb', encoding='utf_16_le').readlines()
except:
EdkLogger.Error("Unicode File Parser",
ToolError.FILE_OPEN_FAILURE,
EdkLogger.Error("Unicode File Parser",
ToolError.FILE_OPEN_FAILURE,
"File read failure: %s" % str(Xstr),
ExtraData=File)
LineNo = GetLineNo(FileIn, Line, False)
EdkLogger.Error("Unicode File Parser",
EdkLogger.Error("Unicode File Parser",
ToolError.PARSER_ERROR,
"Wrong language definition",
ExtraData="""%s\n\t*Correct format is like '#langdef en-US "English"'""" % Line,
"Wrong language definition",
ExtraData="""%s\n\t*Correct format is like '#langdef en-US "English"'""" % Line,
File = File, Line = LineNo)
else:
LangName = GetLanguageCode(Lang[1], self.IsCompatibleMode, self.File)
@@ -365,7 +365,7 @@ class UniFileClassObject(object):
if not IsLangInDef:
#
# The found STRING tokens will be added into new language string list
# so that the unique STRING identifier is reserved for all languages in the package list.
# so that the unique STRING identifier is reserved for all languages in the package list.
#
FirstLangName = self.LanguageDef[0][0]
if LangName != FirstLangName:
@@ -375,10 +375,10 @@ class UniFileClassObject(object):
OtherLang = Item.UseOtherLangDef
else:
OtherLang = FirstLangName
self.OrderedStringList[LangName].append (StringDefClassObject(Item.StringName,
'',
Item.Referenced,
Item.Token,
self.OrderedStringList[LangName].append (StringDefClassObject(Item.StringName,
'',
Item.Referenced,
Item.Token,
OtherLang))
self.OrderedStringDict[LangName][Item.StringName] = len(self.OrderedStringList[LangName]) - 1
return True
@@ -395,7 +395,7 @@ class UniFileClassObject(object):
if Name != '':
MatchString = re.match('[A-Z0-9_]+', Name, re.UNICODE)
if MatchString is None or MatchString.end(0) != len(Name):
EdkLogger.Error("Unicode File Parser",
EdkLogger.Error("Unicode File Parser",
ToolError.FORMAT_INVALID,
'The string token name %s in UNI file %s must be upper case character.' %(Name, self.File))
LanguageList = Item.split(u'#language ')
@@ -406,7 +406,7 @@ class UniFileClassObject(object):
Language = LanguageList[IndexI].split()[0]
#.replace(u'\r\n', u'')
Value = \
LanguageList[IndexI][LanguageList[IndexI].find(u'\"') + len(u'\"') : LanguageList[IndexI].rfind(u'\"')]
LanguageList[IndexI][LanguageList[IndexI].find(u'\"') + len(u'\"') : LanguageList[IndexI].rfind(u'\"')]
Language = GetLanguageCode(Language, self.IsCompatibleMode, self.File)
self.AddStringToList(Name, Language, Value)
@@ -424,7 +424,7 @@ class UniFileClassObject(object):
#
def PreProcess(self, File, IsIncludeFile=False):
if not os.path.exists(File.Path) or not os.path.isfile(File.Path):
EdkLogger.Error("Unicode File Parser",
EdkLogger.Error("Unicode File Parser",
ToolError.FILE_NOT_FOUND,
ExtraData=File.Path)
@@ -443,8 +443,8 @@ class UniFileClassObject(object):
FileIn = codecs.open(File.Path, mode='rb', encoding='utf_16_le').readlines()
except:
EdkLogger.Error("Unicode File Parser", ToolError.FILE_OPEN_FAILURE, ExtraData=File.Path)
#
# get the file header
#
@@ -467,7 +467,7 @@ class UniFileClassObject(object):
if Line.startswith(DT.TAB_COMMENT_EDK1_SPLIT) and HeaderStart and not HeaderEnd and FirstGenHeader:
self.UniFileHeader += Line + '\r\n'
continue
#
# Use unique identifier
#
@@ -486,7 +486,7 @@ class UniFileClassObject(object):
Line = Line.strip()
#
# Ignore comment line and empty line
#
#
if Line == u'' or Line.startswith(u'//'):
#
# Change the single line String entry flag status
@@ -528,7 +528,7 @@ class UniFileClassObject(object):
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path)
else:
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path)
Line = Line.replace(UNICODE_WIDE_CHAR, WIDE_CHAR)
Line = Line.replace(UNICODE_NARROW_CHAR, NARROW_CHAR)
Line = Line.replace(UNICODE_NON_BREAKING_CHAR, NON_BREAKING_CHAR)
@@ -556,16 +556,16 @@ class UniFileClassObject(object):
#
if Line.startswith(u'#string') and Line.find(u'#language') == -1:
MultiLineFeedExits = True
if Line.startswith(u'#string') and Line.find(u'#language') > 0 and Line.find(u'"') < 0:
MultiLineFeedExits = True
#
# Between Language entry and String entry can not contain line feed
#
if Line.startswith(u'#language') and len(Line.split()) == 2:
MultiLineFeedExits = True
#
# Between two String entry, can not contain line feed
#
@@ -588,7 +588,7 @@ class UniFileClassObject(object):
StringEntryExistsFlag = 0
Lines.append(Line)
#
# Convert string def format as below
#
@@ -601,11 +601,11 @@ class UniFileClassObject(object):
# "Mi segunda secuencia 1"
# "Mi segunda secuencia 2"
#
if not IsIncludeFile and not Lines:
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, \
Message=ST.ERR_UNIPARSE_NO_SECTION_EXIST, \
ExtraData=File.Path)
ExtraData=File.Path)
NewLines = []
StrName = u''
@@ -615,7 +615,7 @@ class UniFileClassObject(object):
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, \
Message=ST.ERR_UNIPARSE_STRNAME_FORMAT_ERROR % StrName.split()[1], \
ExtraData=File.Path)
if StrName and len(StrName.split()[1].split(DT.TAB_UNDERLINE_SPLIT)) == 4:
StringTokenList = StrName.split()[1].split(DT.TAB_UNDERLINE_SPLIT)
if (StringTokenList[3].upper() in [DT.TAB_STR_TOKENPROMPT, DT.TAB_STR_TOKENHELP] and \
@@ -624,19 +624,19 @@ class UniFileClassObject(object):
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, \
Message=ST.ERR_UNIPARSE_STRTOKEN_FORMAT_ERROR % StrName.split()[1], \
ExtraData=File.Path)
if Line.count(u'#language') > 1:
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, \
Message=ST.ERR_UNIPARSE_SEP_LANGENTRY_LINE % Line, \
ExtraData=File.Path)
ExtraData=File.Path)
if Line.startswith(u'//'):
continue
elif Line.startswith(u'#langdef'):
if len(Line.split()) == 2:
NewLines.append(Line)
continue
elif len(Line.split()) > 2 and Line.find(u'"') > 0:
elif len(Line.split()) > 2 and Line.find(u'"') > 0:
NewLines.append(Line[:Line.find(u'"')].strip())
NewLines.append(Line[Line.find(u'"'):])
else:
@@ -659,10 +659,10 @@ class UniFileClassObject(object):
if Line[Line.find(u'#language')-1] != ' ' or \
Line[Line.find(u'#language')+len(u'#language')] != u' ':
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path)
if Line.find(u'"') > 0:
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path)
StrName = Line.split()[0] + u' ' + Line.split()[1]
if StrName:
if StrName.split()[1] not in ExistStrNameList:
@@ -684,11 +684,11 @@ class UniFileClassObject(object):
if Line[Line.find(u'#language')-1] != u' ' or \
Line[Line.find(u'#language')+len(u'#language')] != u' ':
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path)
if Line[Line.find(u'"')-1] != u' ':
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path)
StrName = Line.split()[0] + u' ' + Line.split()[1]
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path)
StrName = Line.split()[0] + u' ' + Line.split()[1]
if StrName:
if StrName.split()[1] not in ExistStrNameList:
ExistStrNameList.append(StrName.split()[1].strip())
@@ -698,11 +698,11 @@ class UniFileClassObject(object):
DT.TAB_DEC_BINARY_ABSTRACT, DT.TAB_DEC_BINARY_DESCRIPTION]:
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, \
Message=ST.ERR_UNIPARSE_MULTI_ENTRY_EXIST % StrName.split()[1], \
ExtraData=File.Path)
ExtraData=File.Path)
if IsIncludeFile:
if StrName not in NewLines:
NewLines.append((Line[:Line.find(u'#language')]).strip())
else:
else:
NewLines.append((Line[:Line.find(u'#language')]).strip())
NewLines.append((Line[Line.find(u'#language'):Line.find(u'"')]).strip())
NewLines.append((Line[Line.find(u'"'):]).strip())
@@ -733,17 +733,17 @@ class UniFileClassObject(object):
else:
print(Line)
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path)
if StrName and not StrName.split()[1].startswith(u'STR_'):
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, \
Message=ST.ERR_UNIPARSE_STRNAME_FORMAT_ERROR % StrName.split()[1], \
ExtraData=File.Path)
ExtraData=File.Path)
if StrName and not NewLines:
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, \
Message=ST.ERR_UNI_MISS_LANGENTRY % StrName, \
ExtraData=File.Path)
#
# Check Abstract, Description, BinaryAbstract and BinaryDescription order,
# should be Abstract, Description, BinaryAbstract, BinaryDesctiption
@@ -762,7 +762,7 @@ class UniFileClassObject(object):
BinaryDescriptionPosition = ExistStrNameList.index(StrName)
else:
DescriptionPosition = ExistStrNameList.index(StrName)
OrderList = sorted([AbstractPosition, DescriptionPosition])
BinaryOrderList = sorted([BinaryAbstractPosition, BinaryDescriptionPosition])
Min = OrderList[0]
@@ -774,25 +774,25 @@ class UniFileClassObject(object):
BinaryMax > Max):
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, \
Message=ST.ERR_UNIPARSE_ENTRY_ORDER_WRONG, \
ExtraData=File.Path)
ExtraData=File.Path)
elif BinaryAbstractPosition > -1:
if not(BinaryAbstractPosition > Max):
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, \
Message=ST.ERR_UNIPARSE_ENTRY_ORDER_WRONG, \
ExtraData=File.Path)
ExtraData=File.Path)
if DescriptionPosition > -1:
if not(DescriptionPosition == Max and AbstractPosition == Min and \
DescriptionPosition > AbstractPosition):
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, \
Message=ST.ERR_UNIPARSE_ENTRY_ORDER_WRONG, \
ExtraData=File.Path)
ExtraData=File.Path)
if not self.UniFileHeader:
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID,
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID,
Message = ST.ERR_NO_SOURCE_HEADER,
ExtraData=File.Path)
return NewLines
#
@@ -800,13 +800,13 @@ class UniFileClassObject(object):
#
def LoadUniFile(self, File = None):
if File is None:
EdkLogger.Error("Unicode File Parser",
ToolError.PARSER_ERROR,
Message='No unicode file is given',
EdkLogger.Error("Unicode File Parser",
ToolError.PARSER_ERROR,
Message='No unicode file is given',
ExtraData=File.Path)
self.File = File
#
# Process special char in file
#
@@ -849,10 +849,10 @@ class UniFileClassObject(object):
SecondLine.find(u'#string ') < 0 and SecondLine.find(u'#language ') >= 0 and \
ThirdLine.find(u'#string ') < 0 and ThirdLine.find(u'#language ') < 0:
if Line.find('"') > 0 or SecondLine.find('"') > 0:
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID,
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID,
Message=ST.ERR_UNIPARSE_DBLQUOTE_UNMATCHED,
ExtraData=File.Path)
Name = Line[Line.find(u'#string ') + len(u'#string ') : ].strip(' ')
Language = SecondLine[SecondLine.find(u'#language ') + len(u'#language ') : ].strip(' ')
for IndexJ in range(IndexI + 2, len(Lines)):
@@ -894,11 +894,11 @@ class UniFileClassObject(object):
for LangNameItem in self.LanguageDef:
if Language == LangNameItem[0]:
break
if Language not in self.OrderedStringList:
self.OrderedStringList[Language] = []
self.OrderedStringDict[Language] = {}
IsAdded = True
if Name in self.OrderedStringDict[Language]:
IsAdded = False
@@ -906,38 +906,38 @@ class UniFileClassObject(object):
ItemIndexInList = self.OrderedStringDict[Language][Name]
Item = self.OrderedStringList[Language][ItemIndexInList]
Item.UpdateValue(Value)
Item.UseOtherLangDef = ''
Item.UseOtherLangDef = ''
if IsAdded:
Token = len(self.OrderedStringList[Language])
if Index == -1:
self.OrderedStringList[Language].append(StringDefClassObject(Name,
Value,
Referenced,
Token,
self.OrderedStringList[Language].append(StringDefClassObject(Name,
Value,
Referenced,
Token,
UseOtherLangDef))
self.OrderedStringDict[Language][Name] = Token
for LangName in self.LanguageDef:
#
# New STRING token will be added into all language string lists.
# so that the unique STRING identifier is reserved for all languages in the package list.
# so that the unique STRING identifier is reserved for all languages in the package list.
#
if LangName[0] != Language:
if UseOtherLangDef != '':
OtherLangDef = UseOtherLangDef
else:
OtherLangDef = Language
self.OrderedStringList[LangName[0]].append(StringDefClassObject(Name,
'',
Referenced,
Token,
self.OrderedStringList[LangName[0]].append(StringDefClassObject(Name,
'',
Referenced,
Token,
OtherLangDef))
self.OrderedStringDict[LangName[0]][Name] = len(self.OrderedStringList[LangName[0]]) - 1
else:
self.OrderedStringList[Language].insert(Index, StringDefClassObject(Name,
Value,
Referenced,
Token,
self.OrderedStringList[Language].insert(Index, StringDefClassObject(Name,
Value,
Referenced,
Token,
UseOtherLangDef))
self.OrderedStringDict[Language][Name] = Index
@@ -1029,16 +1029,16 @@ class UniFileClassObject(object):
print(Item)
for Member in self.OrderedStringList[Item]:
print(str(Member))
#
# Read content from '!include' UNI file
# Read content from '!include' UNI file
#
def ReadIncludeUNIfile(self, FilaPath):
if self.File:
pass
if not os.path.exists(FilaPath) or not os.path.isfile(FilaPath):
EdkLogger.Error("Unicode File Parser",
EdkLogger.Error("Unicode File Parser",
ToolError.FILE_NOT_FOUND,
ExtraData=FilaPath)
try:

View File

@@ -2,11 +2,11 @@
# This is an XML API that uses a syntax similar to XPath, but it is written in
# standard python so that no extra python packages are required to use it.
#
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -141,8 +141,8 @@ def XmlElement(Dom, String):
## Get a single XML element using XPath style syntax.
#
# Similar with XmlElement, but do not strip all the leading and tailing space
# and newline, instead just remove the newline and spaces introduced by
# toprettyxml()
# and newline, instead just remove the newline and spaces introduced by
# toprettyxml()
#
# @param Dom The root XML DOM object.
# @param Strin A XPath style path.

View File

@@ -4,11 +4,11 @@
# This file is required to make Python interpreter treat the directory
# as containing package.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -17,4 +17,4 @@
'''
Xml
'''
'''

View File

@@ -4,11 +4,11 @@
# This file is required to make Python interpreter treat the directory
# as containing package.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -17,4 +17,4 @@
'''
Library
'''
'''

View File

@@ -1,11 +1,11 @@
## @file
# This file implements the log mechanism for Python tools.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -197,8 +197,8 @@ def Warn(ToolName, Message, File=None, Line=None, ExtraData=None):
## Log ERROR message
#
# Once an error messages is logged, the tool's execution will be broken by
# raising an execption. If you don't want to break the execution later, you
# Once an error messages is logged, the tool's execution will be broken by
# raising an execption. If you don't want to break the execution later, you
# can give "RaiseError" with "False" value.
#
# @param ToolName The name of the tool. If not given, the name of caller
@@ -248,13 +248,13 @@ def Error(ToolName, ErrorCode, Message=None, File=None, Line=None, \
if RaiseError:
raise FatalError(ErrorCode)
## Initialize log system
#
def Initialize():
#
# Since we use different format to log different levels of message into
# different place (stdout or stderr), we have to use different "Logger"
# Since we use different format to log different levels of message into
# different place (stdout or stderr), we have to use different "Logger"
# objects to do this.
#
# For DEBUG level (All DEBUG_0~9 are applicable)

View File

@@ -1,11 +1,11 @@
## @file
# This file is used to define strings used in the UPT tool
#
# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -118,7 +118,7 @@ ERR_INF_PARSER_DEPEX_SECTION_MODULE_TYPE_ERROR = \
ERR_INF_PARSER_DEPEX_SECTION_CONTENT_MISSING = \
_("Missing content in: %s")
ERR_INF_PARSER_DEPEX_SECTION_CONTENT_ERROR = \
_("The [Depex] section contains invalid content: %s")
_("The [Depex] section contains invalid content: %s")
ERR_INF_PARSER_DEPEX_SECTION_SEC_TYPE_ERROR = \
_("The format is incorrect. The section type keyword of the content in the"
" [Depex] section is only for 'PEI_DEPEX', 'DXE_DEPEX', 'SMM_DEPEX', "
@@ -140,11 +140,11 @@ ERR_INF_PARSER_SOURCES_SECTION_CONTENT_ERROR = \
ERR_INF_PARSER_PCD_SECTION_TYPE_ERROR = \
_("The PCD section type is incorrect. The value should be this list: %s")
ERR_INF_PARSER_PCD_SECTION_CONTENT_ERROR = \
_("PcdName format invalid."
_("PcdName format invalid."
"Should like following: PcdName | Value | FeatureFlag.")
ERR_INF_PARSER_PCD_NAME_FORMAT_ERROR = \
_("Format invalid."
"Should like following: <TokenSpaceGuidCName>.<PcdCName> ")
_("Format invalid."
"Should like following: <TokenSpaceGuidCName>.<PcdCName> ")
ERR_INF_PARSER_GUID_PPI_PROTOCOL_SECTION_CONTENT_ERROR = \
_("The format is incorrect. "
"It should be formated as follows: CName | FeatureFlag.")
@@ -181,7 +181,7 @@ ERR_INF_PARSER_PCD_CVAR_GUID = \
ERR_INF_PARSER_PCD_CVAR_PCDCNAME = \
_("PcdCName must be valid C variable format.")
ERR_INF_PARSER_PCD_VALUE_INVALID = \
_("The PCD value is incorrect. It must be corrected before continuing.")
_("The PCD value is incorrect. It must be corrected before continuing.")
ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID = \
_("Incorrect feature flag expression: %s")
ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING = \
@@ -191,7 +191,7 @@ ERR_INF_PARSER_INVALID_CNAME = \
ERR_INF_PARSER_CNAME_MISSING = \
_("Missing CName. Specify a valid C variable name.")
ERR_INF_PARSER_DEFINE_SECTION_KEYWORD_INVALID = \
_("The Define section contains an invalid keyword: \"%s\"."
_("The Define section contains an invalid keyword: \"%s\"."
"It must be corrected before continuing.")
ERR_INF_PARSER_FILE_MISS_DEFINE = \
_("The following file listed in the module "
@@ -206,7 +206,7 @@ ERR_INF_PARSER_NOT_SUPPORT_EDKI_INF = _("EDKI INF is not supported")
ERR_INF_PARSER_EDKI_COMMENT_IN_EDKII = _("The EDKI style comment is not supported in EDKII modules")
ERR_INF_PARSER_FEATUREPCD_USAGE_INVALID = _("The usage for FeaturePcd can only"
" be type of \"CONSUMES\".")
" be type of \"CONSUMES\".")
ERR_INF_PARSER_DEFINE_ITEM_NO_NAME = _("No name specified")
ERR_INF_PARSER_DEFINE_ITEM_NO_VALUE = _("No value specified")
@@ -221,9 +221,9 @@ ERR_INF_NO_PKG_DEPENDENCY_INFO = _("There are no packages defined that use the A
#
ERR_INF_PARSER_ITEM_DUPLICATE_IN_DEC = \
_('"%s" is redefined in its dependent DEC files')
ERR_INF_PARSER_ITEM_DUPLICATE = _("%s define duplicated! "
ERR_INF_PARSER_ITEM_DUPLICATE = _("%s define duplicated! "
"It must be corrected before continuing.")
ERR_INF_PARSER_ITEM_DUPLICATE_COMMON = _("%s define duplicated! Item listed"
ERR_INF_PARSER_ITEM_DUPLICATE_COMMON = _("%s define duplicated! Item listed"
"in an architectural section must not be listed in the common architectural"
"section.It must be corrected before continuing.")
ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR = \
@@ -237,11 +237,11 @@ _("The name 'NULL' for LibraryClass is a reserved word."
ERR_GLOBAL_MARCO_INVALID = \
_("Using global MACRO in INF/DEC is not permitted: %s . "
"It must be corrected before continuing.")
"It must be corrected before continuing.")
ERR_MARCO_DEFINITION_MISS_ERROR = \
_("MACRO expand incorrectly, can not find the MACRO definition. "
"It must be corrected before continuing.")
"It must be corrected before continuing.")
#
# AsBuilt related
@@ -370,7 +370,7 @@ MSG_RECOVER_FAIL = _('Recovery failed.')
#
ERR_DEPENDENCY_NOT_MATCH = _(
"Module %s's dependency on package %s (GUID %s Version %s) "
"Module %s's dependency on package %s (GUID %s Version %s) "
"cannot be satisfied")
ERR_MODULE_NOT_INSTALLED = _(
"This module is not installed in the workspace: %s\n")
@@ -475,7 +475,7 @@ ERR_FILELIST_EXIST = _(
ERR_COPYRIGHT_CONTENT = _(
"The copyright content must contain the word \"Copyright\" (case insensitive).")
ERR_WRONG_FILELIST_FORMAT = \
_('File list format is incorrect.'
_('File list format is incorrect.'
'The correct format is: filename|key=value[|key=value]')
ERR_FILELIST_ATTR = _(
"The value of attribute \"%s\" includes illegal character.")
@@ -593,7 +593,7 @@ _("There are same entries : %s in the UNI file, every kind of entry should be on
ERR_UNIPARSE_ENTRY_ORDER_WRONG = \
_("The string entry order in UNI file should be <AbstractStrings>, <DescriptionStrings>, \
<BinaryAbstractStrings>, <BinaryDescriptionStrings>.")
ERR_UNIPARSE_STRTOKEN_FORMAT_ERROR = _("The String Token Type %s must be one of the '_PROMPT', '_HELP' and '_ERR_'.")
ERR_UNIPARSE_STRTOKEN_FORMAT_ERROR = _("The String Token Type %s must be one of the '_PROMPT', '_HELP' and '_ERR_'.")
ERR_UNIPARSE_LINEFEED_UNDER_EXIST = _("Line feed should not exist under this line: %s.")
ERR_UNIPARSE_LINEFEED_UP_EXIST = _("Line feed should not exist up this line: %s.")
ERR_UNI_MISS_STRING_ENTRY = _("String entry missed in this Entry, %s.")
@@ -672,7 +672,7 @@ _("Library class format error, must be Libraryclass|Headerpath.")
ERR_DECPARSE_LIBCLASS_EMPTY = \
_("Class name or file name must not be empty.")
ERR_DECPARSE_LIBCLASS_LIB = \
_("Class name format error, must start with upper case letter followed with "
_("Class name format error, must start with upper case letter followed with "
"zero or more alphanumeric characters.")
ERR_DECPARSE_LIBCLASS_PATH_EXT = _("File name must be end with .h.")
ERR_DECPARSE_LIBCLASS_PATH_DOT = _("Path must not include '..'.")
@@ -695,7 +695,7 @@ _("Incorrect value [%s] of type [%s]. Value must be printable and in the "
"form of{...} for array, or ""..."" for string, or L""..."""
"for unicode string.")
ERR_DECPARSE_PCD_VALUE_EMPTY = \
_("Pcd value can not be empty.")
_("Pcd value can not be empty.")
ERR_DECPARSE_PCD_BOOL = \
_("Invalid value [%s] of type [%s]; must be expression, TRUE, FALSE, 0 or 1.")
ERR_DECPARSE_PCD_INT = _("Incorrect value [%s] of type [%s]."\
@@ -719,14 +719,14 @@ _("No GUID name specified, must be <CName> = <GuidValueInCFormat>.")
ERR_DECPARSE_CGUID_GUID = \
_("No GUID value specified, must be <CName> = <GuidValueInCFormat>.")
ERR_DECPARSE_CGUID_GUIDFORMAT = \
_("Incorrect GUID value format, must be <GuidValueInCFormat:"
_("Incorrect GUID value format, must be <GuidValueInCFormat:"
"{8,4,4,{2,2,2,2,2,2,2,2}}>.")
ERR_DECPARSE_CGUID_NOT_FOUND = _("Unable to find the GUID value of this GUID CName : '%s'.")
ERR_DECPARSE_FILEOPEN = _("Unable to open: [%s].")
ERR_DECPARSE_SECTION_EMPTY = _("Empty sections are not allowed.")
ERR_DECPARSE_SECTION_UE = _("Incorrect UserExtentions format. "
"Must be UserExtenxions.UserId.IdString[.Arch]+.")
ERR_DECPARSE_SECTION_UE_USERID = _("Invalid UserId, must be underscore"
ERR_DECPARSE_SECTION_UE_USERID = _("Invalid UserId, must be underscore"
"or alphanumeric characters.")
ERR_DECPARSE_SECTION_UE_IDSTRING = \
_("Incorrect IdString, must be \" ... \".")
@@ -805,7 +805,7 @@ WRN_INF_PARSER_MODULE_INVALID_EVENT_TYPE = \
WRN_INF_PARSER_MODULE_INVALID_BOOTMODE_TYPE = \
_("This is an incorrect BOOTMODE type: %s")
WRN_INVALID_MODULE_TYPE = \
_("This is an incorrect Module type: %s")
_("This is an incorrect Module type: %s")
WRN_MODULE_PARSE_FAILED = \
_("Parsing of this module did not complete correctly: %s.")
WRN_EDK1_INF_FOUND = \
@@ -826,7 +826,7 @@ HLP_PRINT_DEBUG_INFO = _(
"Print DEBUG statements, where DEBUG_LEVEL is 0-9")
HLP_PRINT_INFORMATIONAL_STATEMENT = _("Print informational statements")
HLP_RETURN_NO_DISPLAY = _(
"Returns only the exit code, informational and error messages are"
"Returns only the exit code, informational and error messages are"
" not displayed")
HLP_RETURN_AND_DISPLAY = _(
"Returns the exit code and displays error messages only")

View File

@@ -1,11 +1,11 @@
## @file
# Standardized Error Hanlding infrastructures.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,

View File

@@ -4,11 +4,11 @@
# This file is required to make Python interpreter treat the directory
# as containing package.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -17,4 +17,4 @@
'''
Logger
'''
'''

View File

@@ -1,11 +1,11 @@
## @file
# Install distribution package.
#
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -55,7 +55,7 @@ from Common.MultipleWorkspace import MultipleWorkspace as mws
## CheckForExistingDp
#
# Check if there is a same name DP file existing
# @param Path: The path to be checked
# @param Path: The path to be checked
#
def CheckForExistingDp(Path):
if os.path.exists(Path):
@@ -76,7 +76,7 @@ def Main(Options = None):
if Options is None:
Logger.Error("\nMkPkg", OPTION_UNKNOWN_ERROR, ST.ERR_OPTION_NOT_FOUND)
try:
DataBase = GlobalData.gDB
DataBase = GlobalData.gDB
ContentFileClosed = True
WorkspaceDir = GlobalData.gWORKSPACE
@@ -85,7 +85,7 @@ def Main(Options = None):
#
if not Options.PackFileToCreate:
Logger.Error("\nMkPkg", OPTION_UNKNOWN_ERROR, ST.ERR_OPTION_NOT_FOUND)
#
# Handle if the distribution package file already exists
#
@@ -95,7 +95,7 @@ def Main(Options = None):
# Check package file existing and valid
#
CheckFileList('.DEC', Options.PackageFileList, ST.ERR_INVALID_PACKAGE_NAME, ST.ERR_INVALID_PACKAGE_PATH)
#
#
# Check module file existing and valid
#
CheckFileList('.INF', Options.ModuleFileList, ST.ERR_INVALID_MODULE_NAME, ST.ERR_INVALID_MODULE_PATH)
@@ -104,10 +104,10 @@ def Main(Options = None):
# Get list of files that installed with RePackage attribute available
#
RePkgDict = DataBase.GetRePkgDict()
ContentFile = PackageFile(GlobalData.gCONTENT_FILE, "w")
ContentFile = PackageFile(GlobalData.gCONTENT_FILE, "w")
ContentFileClosed = False
#
# Add temp distribution header
#
@@ -118,7 +118,7 @@ def Main(Options = None):
#
# add distribution level tool/misc files
# before pack, current dir should be workspace dir, else the full
# before pack, current dir should be workspace dir, else the full
# path will be in the pack file
#
Cwd = getcwd()
@@ -132,8 +132,8 @@ def Main(Options = None):
FileList += MiscObject.GetFileList()
for FileObject in FileList:
#
# If you have unicode file names, please convert them to byte
# strings in your desired encoding before passing them to
# If you have unicode file names, please convert them to byte
# strings in your desired encoding before passing them to
# write().
#
FromFile = os.path.normpath(FileObject.GetURI()).encode('utf_8')
@@ -151,8 +151,8 @@ def Main(Options = None):
DistPkg.Header.RePackage = True
ContentFile.PackFile(FromFile)
chdir(Cwd)
#
#
# Add init dp information
#
else:
@@ -160,14 +160,14 @@ def Main(Options = None):
DistPkg.Header.Name = 'Distribution Package'
DistPkg.Header.Guid = str(uuid4())
DistPkg.Header.Version = '1.0'
DistPkg.GetDistributionPackage(WorkspaceDir, Options.PackageFileList, \
Options.ModuleFileList)
FileList, MetaDataFileList = DistPkg.GetDistributionFileList()
for File in FileList + MetaDataFileList:
FileFullPath = os.path.normpath(os.path.join(WorkspaceDir, File))
#
# check whether file was included in a distribution that can not
# check whether file was included in a distribution that can not
# be repackaged
#
if FileFullPath in RePkgDict:
@@ -182,17 +182,17 @@ def Main(Options = None):
)
else:
DistPkg.Header.RePackage = True
Cwd = getcwd()
chdir(WorkspaceDir)
ContentFile.PackFiles(FileList)
chdir(Cwd)
Logger.Verbose(ST.MSG_COMPRESS_DISTRIBUTION_PKG)
Logger.Verbose(ST.MSG_COMPRESS_DISTRIBUTION_PKG)
ContentFile.Close()
ContentFileClosed = True
#
# Add Md5Sigature
#
@@ -201,7 +201,7 @@ def Main(Options = None):
# Add current Date
#
DistPkg.Header.Date = str(strftime("%Y-%m-%dT%H:%M:%S", localtime()))
#
# Finish final dp file
#
@@ -214,7 +214,7 @@ def Main(Options = None):
ReturnCode = 0
except FatalError as XExcept:
ReturnCode = XExcept.args[0]
ReturnCode = XExcept.args[0]
if Logger.GetLevel() <= Logger.DEBUG_9:
Logger.Quiet(ST.MSG_PYTHON_ON % \
(python_version(), platform) + format_exc())
@@ -247,7 +247,7 @@ def Main(Options = None):
## CheckFileList
#
#
# @param QualifiedExt: QualifiedExt
# @param FileList: FileList
# @param ErrorStringExt: ErrorStringExt
@@ -263,7 +263,7 @@ def CheckFileList(QualifiedExt, FileList, ErrorStringExt, ErrorStringFullPath):
if Ext.upper() != QualifiedExt.upper():
Logger.Error("\nMkPkg", OPTION_VALUE_INVALID, \
ErrorStringExt % Item)
Item = os.path.normpath(Item)
Path = mws.join(WorkspaceDir, Item)
if not os.path.exists(Path):
@@ -274,7 +274,7 @@ def CheckFileList(QualifiedExt, FileList, ErrorStringExt, ErrorStringFullPath):
elif not IsValidPath(Item, WorkspaceDir):
Logger.Error("\nMkPkg", OPTION_VALUE_INVALID, \
ErrorStringExt % Item)
if not os.path.split(Item)[0]:
Logger.Error("\nMkPkg", OPTION_VALUE_INVALID, \
ST.ERR_INVALID_METAFILE_PATH % Item)

View File

@@ -1,11 +1,11 @@
## @file
# This file is used to define common items of class object
#
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -23,10 +23,10 @@ from Library.DataType import TAB_LANGUAGE_EN_US
class HelpTextObject(object):
def __init__(self):
self.HelpText = TextObject()
def SetHelpText(self, HelpText):
self.HelpText = HelpText
def GetHelpText(self):
return self.HelpText
@@ -37,10 +37,10 @@ class HelpTextObject(object):
class HelpTextListObject(object):
def __init__(self):
self.HelpTextList = []
def SetHelpTextList(self, HelpTextList):
self.HelpTextList = HelpTextList
def GetHelpTextList(self):
return self.HelpTextList
@@ -51,13 +51,13 @@ class HelpTextListObject(object):
class PromptListObject(object):
def __init__(self):
self.PromptList = []
def SetPromptList(self, PromptList):
self.PromptList = PromptList
def GetPromptList(self):
return self.PromptList
## CommonPropertiesObject
#
# This class defined common attribution used in Module/Platform/Package files
@@ -77,7 +77,7 @@ class CommonPropertiesObject(HelpTextObject, HelpTextListObject):
self.GuidValue = ''
HelpTextObject.__init__(self)
HelpTextListObject.__init__(self)
def SetUsage(self, Usage):
self.Usage = Usage
@@ -95,10 +95,10 @@ class CommonPropertiesObject(HelpTextObject, HelpTextListObject):
def GetSupArchList(self):
return self.SupArchList
def SetGuidValue(self, GuidValue):
self.GuidValue = GuidValue
def GetGuidValue(self):
return self.GuidValue
@@ -199,11 +199,11 @@ class BinaryHeaderObject(object):
def GetBinaryHeaderLicense(self):
return self.BinaryHeaderLicenseList
## ClonedRecordObject
#
# This class defined ClonedRecord items used in Module/Platform/Package files
#
#
# @param object: Inherited from object class
#
class ClonedRecordObject(object):
@@ -285,7 +285,7 @@ class FileNameObject(CommonPropertiesObject):
self.FileType = ''
self.Filename = ''
CommonPropertiesObject.__init__(self)
def SetFileType(self, FileType):
self.FileType = FileType
@@ -306,10 +306,10 @@ class FileNameObject(CommonPropertiesObject):
#
class FileObject(object):
def __init__(self):
self.Executable = ''
self.Executable = ''
self.Uri = ''
self.OsType = ''
def SetExecutable(self, Executable):
self.Executable = Executable
@@ -327,8 +327,8 @@ class FileObject(object):
def GetOS(self):
return self.OsType
##
##
# MiscFileObject is used for xml
#
# @param CommonHeaderObject: Inherited from CommonHeaderObject class
@@ -336,18 +336,18 @@ class FileObject(object):
class MiscFileObject(CommonHeaderObject):
def __init__(self):
self.Name = ''
self.FileList = []
self.FileList = []
CommonHeaderObject.__init__(self)
def SetName(self, Name):
self.Name = Name
def GetName(self):
return self.Name
def SetFileList(self, FileList):
self.FileList = FileList
def GetFileList(self):
return self.FileList
@@ -397,7 +397,7 @@ class IdentificationObject(GuidVersionObject):
self.ModulePath = ''
self.CombinePath = ''
GuidVersionObject.__init__(self)
def SetName(self, Name):
self.Name = Name
@@ -448,7 +448,7 @@ class IdentificationObject(GuidVersionObject):
## GuidProtocolPpiCommonObject
#
# This class defined Guid, Protocol and Ppi like items used in
# This class defined Guid, Protocol and Ppi like items used in
# Module/Platform/Package files
#
# @param CommonPropertiesObject: Inherited from CommonPropertiesObject class
@@ -460,7 +460,7 @@ class GuidProtocolPpiCommonObject(CommonPropertiesObject):
self.Guid = ''
self.SupModuleList = []
CommonPropertiesObject.__init__(self)
def SetName(self, Name):
self.Name = Name
@@ -512,7 +512,7 @@ class GuidObject(GuidProtocolPpiCommonObject):
#
# This class defined Protocol item used in Module/Platform/Package files
#
# @param GuidProtocolPpiCommonObject: Inherited from
# @param GuidProtocolPpiCommonObject: Inherited from
# GuidProtocolPpiCommonObject
#
class ProtocolObject(GuidProtocolPpiCommonObject):
@@ -529,7 +529,7 @@ class ProtocolObject(GuidProtocolPpiCommonObject):
#
# This class defined Ppi item used in Module/Platform/Package files
#
# @param GuidProtocolPpiCommonObject: Inherited from
# @param GuidProtocolPpiCommonObject: Inherited from
# GuidProtocolPpiCommonObject
#
class PpiObject(GuidProtocolPpiCommonObject):
@@ -566,13 +566,13 @@ class UserExtensionObject(object):
self.BinaryLicenseList = []
self.UniLangDefsList = []
#
# { Statement : Arch , ... }
# { Statement : Arch , ... }
#
self.DefinesDict = {}
self.DefinesDict = {}
#
# { Arch : Statement , ... }
#
self.BuildOptionDict = {}
self.BuildOptionDict = {}
self.IncludesDict = {}
self.SourcesDict = {}
self.BinariesDict = {}
@@ -581,40 +581,40 @@ class UserExtensionObject(object):
#
self.Statement = ''
self.SupArchList = []
def SetStatement(self, Statement):
self.Statement = Statement
def GetStatement(self):
return self.Statement
def SetSupArchList(self, ArchList):
self.SupArchList = ArchList
def GetSupArchList(self):
return self.SupArchList
def SetUserID(self, UserID):
self.UserID = UserID
def GetUserID(self):
return self.UserID
def SetIdentifier(self, Identifier):
self.Identifier = Identifier
def GetIdentifier(self):
return self.Identifier
def SetUniLangDefsList(self, UniLangDefsList):
self.UniLangDefsList = UniLangDefsList
def GetUniLangDefsList(self):
return self.UniLangDefsList
def SetBinaryAbstract(self, BinaryAbstractList):
self.BinaryAbstractList = BinaryAbstractList
def GetBinaryAbstract(self, Lang=None):
if Lang:
for (Key, Value) in self.BinaryAbstractList:
@@ -623,10 +623,10 @@ class UserExtensionObject(object):
return None
else:
return self.BinaryAbstractList
def SetBinaryDescription(self, BinaryDescriptionList):
self.BinaryDescriptionList = BinaryDescriptionList
def GetBinaryDescription(self, Lang=None):
if Lang:
for (Key, Value) in self.BinaryDescriptionList:
@@ -635,10 +635,10 @@ class UserExtensionObject(object):
return None
else:
return self.BinaryDescriptionList
def SetBinaryCopyright(self, BinaryCopyrightList):
self.BinaryCopyrightList = BinaryCopyrightList
def GetBinaryCopyright(self, Lang=None):
if Lang:
for (Key, Value) in self.BinaryCopyrightList:
@@ -647,10 +647,10 @@ class UserExtensionObject(object):
return None
else:
return self.BinaryCopyrightList
def SetBinaryLicense(self, BinaryLicenseList):
self.BinaryLicenseList = BinaryLicenseList
def GetBinaryLicense(self, Lang=None):
if Lang:
for (Key, Value) in self.BinaryLicenseList:
@@ -659,34 +659,34 @@ class UserExtensionObject(object):
return None
else:
return self.BinaryLicenseList
def SetDefinesDict(self, DefinesDict):
self.DefinesDict = DefinesDict
def GetDefinesDict(self):
return self.DefinesDict
def SetBuildOptionDict(self, BuildOptionDict):
self.BuildOptionDict = BuildOptionDict
def GetBuildOptionDict(self):
return self.BuildOptionDict
def SetIncludesDict(self, IncludesDict):
self.IncludesDict = IncludesDict
def GetIncludesDict(self):
return self.IncludesDict
def SetSourcesDict(self, SourcesDict):
self.SourcesDict = SourcesDict
def GetSourcesDict(self):
return self.SourcesDict
def SetBinariesDict(self, BinariesDict):
self.BinariesDict = BinariesDict
def GetBinariesDict(self):
return self.BinariesDict
@@ -703,28 +703,28 @@ class LibraryClassObject(CommonPropertiesObject):
self.SupModuleList = []
self.RecommendedInstance = GuidVersionObject()
CommonPropertiesObject.__init__(self)
def SetLibraryClass(self, LibraryClass):
self.LibraryClass = LibraryClass
def GetLibraryClass(self):
return self.LibraryClass
def SetSupModuleList(self, SupModuleList):
self.SupModuleList = SupModuleList
def GetSupModuleList(self):
return self.SupModuleList
def SetIncludeHeader(self, IncludeHeader):
self.IncludeHeader = IncludeHeader
def GetIncludeHeader(self):
return self.IncludeHeader
def SetRecommendedInstance(self, RecommendedInstance):
self.RecommendedInstance = RecommendedInstance
def GetRecommendedInstance(self):
return self.RecommendedInstance
@@ -748,69 +748,69 @@ class PcdErrorObject(object):
def SetValidValue(self, ValidValue):
self.ValidValue = ValidValue
def GetValidValue(self):
return self.ValidValue
def SetValidValueLang(self, ValidValueLang):
self.ValidValueLang = ValidValueLang
def GetValidValueLang(self):
return self.ValidValueLang
def SetValidValueRange(self, ValidValueRange):
self.ValidValueRange = ValidValueRange
def GetValidValueRange(self):
return self.ValidValueRange
def SetExpression(self, Expression):
self.Expression = Expression
def GetExpression(self):
return self.Expression
def SetErrorNumber(self, ErrorNumber):
self.ErrorNumber = ErrorNumber
def GetErrorNumber(self):
return self.ErrorNumber
def SetErrorMessageList(self, ErrorMessageList):
self.ErrorMessageList = ErrorMessageList
def GetErrorMessageList(self):
return self.ErrorMessageList
def SetTokenSpaceGuidCName(self, TokenSpaceGuidCName):
self.TokenSpaceGuidCName = TokenSpaceGuidCName
def GetTokenSpaceGuidCName(self):
return self.TokenSpaceGuidCName
def SetCName(self, CName):
self.CName = CName
def GetCName(self):
return self.CName
def SetFileLine(self, FileLine):
self.FileLine = FileLine
def GetFileLine(self):
return self.FileLine
def SetLineNum(self, LineNum):
self.LineNum = LineNum
def GetLineNum(self):
return self.LineNum
## IncludeObject
#
# This class defined Include item used in Module/Platform/Package files
#
#
# @param CommonPropertiesObject: Inherited from CommonPropertiesObject class
#
class IncludeObject(CommonPropertiesObject):
@@ -820,31 +820,31 @@ class IncludeObject(CommonPropertiesObject):
self.SupModuleList = []
self.Comment = ''
CommonPropertiesObject.__init__(self)
def SetFilePath(self, FilePath):
self.FilePath = FilePath
def GetFilePath(self):
return self.FilePath
def SetModuleType(self, ModuleType):
self.ModuleType = ModuleType
def GetModuleType(self):
return self.ModuleType
def SetSupModuleList(self, SupModuleList):
self.SupModuleList = SupModuleList
def GetSupModuleList(self):
return self.SupModuleList
return self.SupModuleList
def SetComment(self, Comment):
self.Comment = Comment
def GetComment(self):
return self.Comment
return self.Comment
## PcdObject
#
# This class defined Pcd item used in Module/Platform/Package files
@@ -874,86 +874,86 @@ class PcdObject(CommonPropertiesObject, HelpTextListObject, PromptListObject):
self.Offset = ''
self.ValidUsage = ''
self.ItemType = ''
self.PcdErrorsList = []
self.SupModuleList = []
self.PcdErrorsList = []
self.SupModuleList = []
CommonPropertiesObject.__init__(self)
HelpTextListObject.__init__(self)
PromptListObject.__init__(self)
def SetPcdCName(self, PcdCName):
self.PcdCName = PcdCName
def GetPcdCName(self):
return self.PcdCName
def SetCName(self, CName):
self.CName = CName
def GetCName(self):
return self.CName
def SetToken(self, Token):
self.Token = Token
def GetOffset(self):
return self.Offset
def SetOffset(self, Offset):
self.Offset = Offset
def GetToken(self):
return self.Token
def SetTokenSpaceGuidCName(self, TokenSpaceGuidCName):
self.TokenSpaceGuidCName = TokenSpaceGuidCName
def GetTokenSpaceGuidCName(self):
return self.TokenSpaceGuidCName
def SetTokenSpaceGuidValue(self, TokenSpaceGuidValue):
self.TokenSpaceGuidValue = TokenSpaceGuidValue
def GetTokenSpaceGuidValue(self):
return self.TokenSpaceGuidValue
def SetDatumType(self, DatumType):
self.DatumType = DatumType
def GetDatumType(self):
return self.DatumType
def SetMaxDatumSize(self, MaxDatumSize):
self.MaxDatumSize = MaxDatumSize
def GetMaxDatumSize(self):
return self.MaxDatumSize
def SetDefaultValue(self, DefaultValue):
self.DefaultValue = DefaultValue
def GetDefaultValue(self):
return self.DefaultValue
def SetValidUsage(self, ValidUsage):
self.ValidUsage = ValidUsage
def GetValidUsage(self):
return self.ValidUsage
def SetPcdErrorsList(self, PcdErrorsList):
self.PcdErrorsList = PcdErrorsList
def GetPcdErrorsList(self):
return self.PcdErrorsList
def SetItemType(self, ItemType):
self.ItemType = ItemType
def GetItemType(self):
return self.ItemType
def SetSupModuleList(self, SupModuleList):
self.SupModuleList = SupModuleList
def GetSupModuleList(self):
return self.SupModuleList

View File

@@ -1,11 +1,11 @@
## @file
# This file is used to define a class object to describe a module
#
# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -17,16 +17,16 @@ ModuleObject
##
# Import Modules
#
#
from Object.POM.CommonObject import CommonPropertiesObject
from Object.POM.CommonObject import IdentificationObject
from Object.POM.CommonObject import CommonHeaderObject
from Object.POM.CommonObject import BinaryHeaderObject
from Object.POM.CommonObject import HelpTextListObject
from Object.POM.CommonObject import GuidVersionObject
##
##
# BootModeObject
#
class BootModeObject(CommonPropertiesObject, HelpTextListObject):
@@ -34,10 +34,10 @@ class BootModeObject(CommonPropertiesObject, HelpTextListObject):
self.SupportedBootModes = ''
CommonPropertiesObject.__init__(self)
HelpTextListObject.__init__(self)
def SetSupportedBootModes(self, SupportedBootModes):
self.SupportedBootModes = SupportedBootModes
def GetSupportedBootModes(self):
return self.SupportedBootModes
@@ -49,10 +49,10 @@ class EventObject(CommonPropertiesObject, HelpTextListObject):
self.EventType = ''
CommonPropertiesObject.__init__(self)
HelpTextListObject.__init__(self)
def SetEventType(self, EventType):
self.EventType = EventType
def GetEventType(self):
return self.EventType
@@ -64,10 +64,10 @@ class HobObject(CommonPropertiesObject, HelpTextListObject):
self.HobType = ''
CommonPropertiesObject.__init__(self)
HelpTextListObject.__init__(self)
def SetHobType(self, HobType):
self.HobType = HobType
def GetHobType(self):
return self.HobType
@@ -78,23 +78,23 @@ class SpecObject(object):
def __init__(self):
self.Spec = ''
self.Version = ''
def SetSpec(self, Spec):
self.Spec = Spec
def GetSpec(self):
return self.Spec
def SetVersion(self, Version):
self.Version = Version
def GetVersion(self):
return self.Version
## ModuleHeaderObject
#
# This class defined header items used in Module file
#
#
class ModuleHeaderObject(IdentificationObject, CommonHeaderObject, BinaryHeaderObject):
def __init__(self):
self.IsLibrary = False
@@ -109,97 +109,97 @@ class ModuleHeaderObject(IdentificationObject, CommonHeaderObject, BinaryHeaderO
#
# SpecObject
#
self.SpecList = []
self.SpecList = []
#
# BootModeObject
#
self.BootModeList = []
self.BootModeList = []
#
# EventObject
#
self.EventList = []
self.EventList = []
#
# HobObject
#
self.HobList = []
#
#
# LibraryClassObject
#
self.LibraryClassList = []
self.LibraryClassList = []
self.SupArchList = []
IdentificationObject.__init__(self)
CommonHeaderObject.__init__(self)
BinaryHeaderObject.__init__(self)
def SetIsLibrary(self, IsLibrary):
self.IsLibrary = IsLibrary
def GetIsLibrary(self):
return self.IsLibrary
def SetIsLibraryModList(self, IsLibraryModList):
self.IsLibraryModList = IsLibraryModList
def GetIsLibraryModList(self):
return self.IsLibraryModList
def SetModuleType(self, ModuleType):
self.ModuleType = ModuleType
def GetModuleType(self):
return self.ModuleType
def SetBinaryModule(self, BinaryModule):
self.BinaryModule = BinaryModule
def GetBinaryModule(self):
return self.BinaryModule
def SetPcdIsDriver(self, PcdIsDriver):
self.PcdIsDriver = PcdIsDriver
def GetPcdIsDriver(self):
return self.PcdIsDriver
def SetPiSpecificationVersion(self, PiSpecificationVersion):
self.PiSpecificationVersion = PiSpecificationVersion
def GetPiSpecificationVersion(self):
return self.PiSpecificationVersion
def SetUefiSpecificationVersion(self, UefiSpecificationVersion):
self.UefiSpecificationVersion = UefiSpecificationVersion
def GetUefiSpecificationVersion(self):
return self.UefiSpecificationVersion
def SetSpecList(self, SpecList):
self.SpecList = SpecList
def GetSpecList(self):
return self.SpecList
def SetBootModeList(self, BootModeList):
self.BootModeList = BootModeList
def GetBootModeList(self):
return self.BootModeList
def SetEventList(self, EventList):
self.EventList = EventList
def GetEventList(self):
return self.EventList
def SetHobList(self, HobList):
self.HobList = HobList
def GetHobList(self):
return self.HobList
def SetLibraryClassList(self, LibraryClassList):
self.LibraryClassList = LibraryClassList
def GetLibraryClassList(self):
return self.LibraryClassList
@@ -225,38 +225,38 @@ class SourceFileObject(CommonPropertiesObject):
self.ToolCode = ''
self.Family = ''
self.FileType = ''
def SetSourceFile(self, SourceFile):
self.SourceFile = SourceFile
def GetSourceFile(self):
return self.SourceFile
def SetTagName(self, TagName):
self.TagName = TagName
def GetTagName(self):
return self.TagName
def SetToolCode(self, ToolCode):
self.ToolCode = ToolCode
def GetToolCode(self):
return self.ToolCode
def SetFamily(self, Family):
self.Family = Family
def GetFamily(self):
return self.Family
def SetFileType(self, FileType):
self.FileType = FileType
def GetFileType(self):
return self.FileType
##
# BinaryFileObject
#
@@ -265,7 +265,7 @@ class BinaryFileObject(CommonPropertiesObject):
self.FileNamList = []
self.AsBuiltList = []
CommonPropertiesObject.__init__(self)
def SetFileNameList(self, FileNamList):
self.FileNamList = FileNamList
@@ -277,7 +277,7 @@ class BinaryFileObject(CommonPropertiesObject):
def GetAsBuiltList(self):
return self.AsBuiltList
##
# AsBuildLibraryClassObject
@@ -287,12 +287,12 @@ class AsBuildLibraryClassObject(object):
self.LibGuid = ''
self.LibVersion = ''
self.SupArchList = []
def SetLibGuid(self, LibGuid):
self.LibGuid = LibGuid
def GetLibGuid(self):
return self.LibGuid
def SetLibVersion(self, LibVersion):
self.LibVersion = LibVersion
def GetLibVersion(self):
@@ -342,7 +342,7 @@ class AsBuiltObject(object):
def GetLibraryInstancesList(self):
return self.LibraryInstancesList
def SetBuildFlagsList(self, BinaryBuildFlagList):
self.BinaryBuildFlagList = BinaryBuildFlagList
@@ -351,7 +351,7 @@ class AsBuiltObject(object):
##
# BinaryBuildFlag, this object will include those fields that are not
# covered by the UPT Spec BinaryFile field
# covered by the UPT Spec BinaryFile field
#
class BinaryBuildFlagObject(object):
def __init__(self):
@@ -359,31 +359,31 @@ class BinaryBuildFlagObject(object):
self.TagName = ''
self.Family = ''
self.AsBuiltOptionFlags = ''
def SetTarget(self, Target):
self.Target = Target
def GetTarget(self):
return self.Target
return self.Target
def SetTagName(self, TagName):
self.TagName = TagName
def GetTagName(self):
return self.TagName
def SetFamily(self, Family):
self.Family = Family
def GetFamily(self):
return self.Family
def SetAsBuiltOptionFlags(self, AsBuiltOptionFlags):
self.AsBuiltOptionFlags = AsBuiltOptionFlags
def GetAsBuiltOptionFlags(self):
return self.AsBuiltOptionFlags
##
##
# ExternObject
#
class ExternObject(CommonPropertiesObject):
@@ -394,31 +394,31 @@ class ExternObject(CommonPropertiesObject):
self.Destructor = ''
self.SupModList = []
CommonPropertiesObject.__init__(self)
def SetEntryPoint(self, EntryPoint):
self.EntryPoint = EntryPoint
def GetEntryPoint(self):
return self.EntryPoint
def SetUnloadImage(self, UnloadImage):
self.UnloadImage = UnloadImage
def GetUnloadImage(self):
return self.UnloadImage
def SetConstructor(self, Constructor):
self.Constructor = Constructor
def GetConstructor(self):
return self.Constructor
def SetDestructor(self, Destructor):
self.Destructor = Destructor
def GetDestructor(self):
return self.Destructor
def SetSupModList(self, SupModList):
self.SupModList = SupModList
def GetSupModList(self):
@@ -432,16 +432,16 @@ class DepexObject(CommonPropertiesObject):
self.Depex = ''
self.ModuelType = ''
CommonPropertiesObject.__init__(self)
def SetDepex(self, Depex):
self.Depex = Depex
def GetDepex(self):
return self.Depex
def SetModuleType(self, ModuleType):
self.ModuelType = ModuleType
def GetModuleType(self):
return self.ModuelType
@@ -454,16 +454,16 @@ class PackageDependencyObject(GuidVersionObject, CommonPropertiesObject):
self.PackageFilePath = ''
GuidVersionObject.__init__(self)
CommonPropertiesObject.__init__(self)
def SetPackageFilePath(self, PackageFilePath):
self.PackageFilePath = PackageFilePath
def GetPackageFilePath(self):
return self.PackageFilePath
def SetPackage(self, Package):
self.Package = Package
def GetPackage(self):
return self.Package
@@ -474,13 +474,13 @@ class BuildOptionObject(CommonPropertiesObject):
def __init__(self):
CommonPropertiesObject.__init__(self)
self.BuildOption = ''
def SetBuildOption(self, BuildOption):
self.BuildOption = BuildOption
def GetBuildOption(self):
return self.BuildOption
##
# ModuleObject
#
@@ -489,172 +489,172 @@ class ModuleObject(ModuleHeaderObject):
#
# {Arch : ModuleHeaderObject}
#
self.HeaderDict = {}
self.HeaderDict = {}
#
# LibraryClassObject
#
self.LibraryClassList = []
self.LibraryClassList = []
#
# SourceFileObject
#
self.SourceFileList = []
self.SourceFileList = []
#
# BinaryFileObject
#
self.BinaryFileList = []
self.BinaryFileList = []
#
# PackageDependencyObject
#
self.PackageDependencyList = []
self.PackageDependencyList = []
#
# DepexObject
#
self.PeiDepex = []
self.PeiDepex = []
#
# DepexObject
#
self.DxeDepex = []
self.DxeDepex = []
#
# DepexObject
#
self.SmmDepex = []
self.SmmDepex = []
#
# ProtocolObject
#
self.ProtocolList = []
self.ProtocolList = []
#
# PpiObject
#
self.PpiList = []
self.PpiList = []
#
# GuidObject
#
self.GuidList = []
self.GuidList = []
#
# PcdObject
#
self.PcdList = []
self.PcdList = []
#
# ExternObject
#
self.ExternList = []
self.ExternList = []
#
# BuildOptionObject
#
self.BuildOptionList = []
self.BuildOptionList = []
#
# UserExtensionObject
#
self.UserExtensionList = []
self.UserExtensionList = []
#
# MiscFileObject
#
self.MiscFileList = []
self.MiscFileList = []
#
# ClonedFromObject
#
self.ClonedFrom = None
self.ClonedFrom = None
ModuleHeaderObject.__init__(self)
def SetHeaderDict(self, HeaderDict):
self.HeaderDict = HeaderDict
def GetHeaderDict(self):
return self.HeaderDict
def SetLibraryClassList(self, LibraryClassList):
self.LibraryClassList = LibraryClassList
def GetLibraryClassList(self):
return self.LibraryClassList
def SetSourceFileList(self, SourceFileList):
self.SourceFileList = SourceFileList
def GetSourceFileList(self):
return self.SourceFileList
def SetBinaryFileList(self, BinaryFileList):
self.BinaryFileList = BinaryFileList
def GetBinaryFileList(self):
return self.BinaryFileList
def SetPackageDependencyList(self, PackageDependencyList):
self.PackageDependencyList = PackageDependencyList
def GetPackageDependencyList(self):
return self.PackageDependencyList
def SetPeiDepex(self, PeiDepex):
self.PeiDepex = PeiDepex
def GetPeiDepex(self):
return self.PeiDepex
def SetDxeDepex(self, DxeDepex):
self.DxeDepex = DxeDepex
def GetDxeDepex(self):
return self.DxeDepex
def SetSmmDepex(self, SmmDepex):
self.SmmDepex = SmmDepex
def GetSmmDepex(self):
return self.SmmDepex
def SetPpiList(self, PpiList):
self.PpiList = PpiList
def GetPpiList(self):
return self.PpiList
def SetProtocolList(self, ProtocolList):
self.ProtocolList = ProtocolList
def GetProtocolList(self):
return self.ProtocolList
def SetPcdList(self, PcdList):
self.PcdList = PcdList
def GetPcdList(self):
return self.PcdList
def SetGuidList(self, GuidList):
self.GuidList = GuidList
def GetGuidList(self):
return self.GuidList
def SetExternList(self, ExternList):
self.ExternList = ExternList
def GetExternList(self):
return self.ExternList
def SetBuildOptionList(self, BuildOptionList):
self.BuildOptionList = BuildOptionList
def GetBuildOptionList(self):
return self.BuildOptionList
def SetUserExtensionList(self, UserExtensionList):
self.UserExtensionList = UserExtensionList
def GetUserExtensionList(self):
return self.UserExtensionList
def SetMiscFileList(self, MiscFileList):
self.MiscFileList = MiscFileList
def GetMiscFileList(self):
return self.MiscFileList
def SetClonedFrom(self, ClonedFrom):
self.ClonedFrom = ClonedFrom
def GetClonedFrom(self):
return self.ClonedFrom

View File

@@ -1,11 +1,11 @@
## @file
# This file is used to define a class object to describe a package
#
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -30,10 +30,10 @@ class StandardIncludeFileObject(CommonPropertiesObject):
def __init__(self):
CommonPropertiesObject.__init__(self)
self.IncludeFile = ''
def SetIncludeFile(self, IncludeFile):
self.IncludeFile = IncludeFile
def GetIncludeFile(self):
return self.IncludeFile
@@ -53,19 +53,19 @@ class PackageObject(IdentificationObject, CommonHeaderObject, BinaryHeaderObject
#
# LibraryClassObject
#
self.LibraryClassList = []
self.LibraryClassList = []
#
# FileObject
#
self.IncludePathList = []
self.IncludePathList = []
#
# StandardIncludeFileObject
#
self.StandardIncludeFileList = []
self.StandardIncludeFileList = []
#
# PackageIncludeFileObject
#
self.PackageIncludeFileList = []
self.PackageIncludeFileList = []
#
# Include and Arch List, item is (IncludePath, SupArchList-List of Arch), used during install package
#
@@ -73,126 +73,126 @@ class PackageObject(IdentificationObject, CommonHeaderObject, BinaryHeaderObject
#
# ProtocolObject
#
self.ProtocolList = []
self.ProtocolList = []
#
# PpiObject
#
self.PpiList = []
self.PpiList = []
#
# GuidObject
#
self.GuidList = []
self.GuidList = []
#
# (PcdObject, PcdErrorObject)
#
self.PcdList = []
self.PcdList = []
#
# {(PcdTokenSpaceGuidCName, PcdErrroNumber): PcdErrorMessageList}
#
self.PcdErrorCommentDict = {}
#
# UserExtensionObject
#
self.UserExtensionList = []
#
self.UserExtensionList = []
#
# MiscFileObject
#
self.MiscFileList = []
self.MiscFileList = []
self.ModuleDict = Sdict()
#
# ClonedRecordObject
#
self.ClonedFromList = []
self.ClonedFromList = []
#
# string object
#
self.ModuleFileList = []
self.ModuleFileList = []
self.PcdChecks = []
self.UNIFlag = False
def SetLibraryClassList(self, LibraryClassList):
self.LibraryClassList = LibraryClassList
def GetLibraryClassList(self):
return self.LibraryClassList
def SetIncludePathList(self, IncludePathList):
self.IncludePathList = IncludePathList
def GetIncludePathList(self):
return self.IncludePathList
def SetIncludeArchList(self, IncludeArchList):
self.IncludeArchList = IncludeArchList
def GetIncludeArchList(self):
return self.IncludeArchList
return self.IncludeArchList
def SetStandardIncludeFileList(self, StandardIncludeFileList):
self.StandardIncludeFileList = StandardIncludeFileList
def GetStandardIncludeFileList(self):
return self.StandardIncludeFileList
def SetPackageIncludeFileList(self, PackageIncludeFileList):
self.PackageIncludeFileList = PackageIncludeFileList
def GetPackageIncludeFileList(self):
return self.PackageIncludeFileList
def SetProtocolList(self, ProtocolList):
self.ProtocolList = ProtocolList
def GetProtocolList(self):
return self.ProtocolList
def SetPpiList(self, PpiList):
self.PpiList = PpiList
def GetPpiList(self):
return self.PpiList
def SetGuidList(self, GuidList):
self.GuidList = GuidList
def GetGuidList(self):
return self.GuidList
def SetPcdList(self, PcdList):
self.PcdList = PcdList
def GetPcdList(self):
return self.PcdList
def SetUserExtensionList(self, UserExtensionList):
self.UserExtensionList = UserExtensionList
def GetUserExtensionList(self):
return self.UserExtensionList
def SetMiscFileList(self, MiscFileList):
self.MiscFileList = MiscFileList
def GetMiscFileList(self):
return self.MiscFileList
def SetModuleDict(self, ModuleDict):
self.ModuleDict = ModuleDict
def GetModuleDict(self):
return self.ModuleDict
def SetClonedFromList(self, ClonedFromList):
self.ClonedFromList = ClonedFromList
def GetClonedFromList(self):
return self.ClonedFromList
def SetModuleFileList(self, ModuleFileList):
self.ModuleFileList = ModuleFileList
def GetModuleFileList(self):
return self.ModuleFileList

View File

@@ -4,11 +4,11 @@
# This file is required to make Python interpreter treat the directory
# as containing package.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -17,4 +17,4 @@
'''
POM
'''
'''

View File

@@ -1,12 +1,12 @@
## @file
# This file is used to define class objects for DEC file. It will consumed by
# This file is used to define class objects for DEC file. It will consumed by
#DecParser
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -49,7 +49,7 @@ class _DecComments:
return self._HeadComment, self._TailComment
## GetHeadComment
#
#
def GetHeadComment(self):
return self._HeadComment
@@ -61,7 +61,7 @@ class _DecComments:
self._HeadComment = Comment
## GetTailComment
#
#
def GetTailComment(self):
return self._TailComment
@@ -89,22 +89,22 @@ class _DecBaseObject(_DecComments):
self._SecName = ''
## GetSectionName
#
#
def GetSectionName(self):
return self._SecName
## GetPackagePath
#
#
def GetPackagePath(self):
return self._PackagePath
## GetPackageFile
#
#
def GetPackageFile(self):
return self._FileName
## GetPackageFullName
#
#
def GetPackageFullName(self):
return self._PkgFullName
@@ -151,7 +151,7 @@ class _DecBaseObject(_DecComments):
## _DecItemBaseObject
#
# Module type and arch the item belongs to
# Module type and arch the item belongs to
#
class _DecItemBaseObject(_DecComments):
def __init__(self):
@@ -162,7 +162,7 @@ class _DecItemBaseObject(_DecComments):
self.ArchAndModuleType = []
## GetArchList
#
#
def GetArchList(self):
ArchSet = set()
for Arch in self.ArchAndModuleType:
@@ -184,7 +184,7 @@ class DecDefineObject(_DecBaseObject):
self._PkgUniFile = ''
## GetPackageSpecification
#
#
def GetPackageSpecification(self):
return self._DecSpec
@@ -192,7 +192,7 @@ class DecDefineObject(_DecBaseObject):
self._DecSpec = DecSpec
## GetPackageName
#
#
def GetPackageName(self):
return self._PkgName
@@ -200,7 +200,7 @@ class DecDefineObject(_DecBaseObject):
self._PkgName = PkgName
## GetPackageGuid
#
#
def GetPackageGuid(self):
return self._PkgGuid
@@ -208,7 +208,7 @@ class DecDefineObject(_DecBaseObject):
self._PkgGuid = PkgGuid
## GetPackageVersion
#
#
def GetPackageVersion(self):
return self._PkgVersion
@@ -216,7 +216,7 @@ class DecDefineObject(_DecBaseObject):
self._PkgVersion = PkgVersion
## GetPackageUniFile
#
#
def GetPackageUniFile(self):
return self._PkgUniFile
@@ -224,12 +224,12 @@ class DecDefineObject(_DecBaseObject):
self._PkgUniFile = PkgUniFile
## GetDefines
#
#
def GetDefines(self):
return self._GetItemByArch(TAB_ARCH_COMMON)
## GetAllDefines
#
#
def GetAllDefines(self):
return self._GetAllItems()
@@ -244,7 +244,7 @@ class DecDefineItemObject(_DecItemBaseObject):
self.Value = ''
## __hash__
#
#
def __hash__(self):
return hash(self.Key + self.Value)
@@ -254,7 +254,7 @@ class DecDefineItemObject(_DecItemBaseObject):
return id(self) == id(Other)
## __str__
#
#
def __str__(self):
return str(self.ArchAndModuleType) + '\n' + self.Key + \
' = ' + self.Value
@@ -269,12 +269,12 @@ class DecIncludeObject(_DecBaseObject):
self._SecName = TAB_INCLUDES.upper()
## GetIncludes
#
#
def GetIncludes(self, Arch=TAB_ARCH_COMMON):
return self._GetItemByArch(Arch)
## GetAllIncludes
#
#
def GetAllIncludes(self):
return self._GetAllItems()
@@ -289,7 +289,7 @@ class DecIncludeItemObject(_DecItemBaseObject):
_DecItemBaseObject.__init__(self)
## __hash__
#
#
def __hash__(self):
return hash(self.File)
@@ -299,7 +299,7 @@ class DecIncludeItemObject(_DecItemBaseObject):
return id(self) == id(Other)
## __str__
#
#
def __str__(self):
return self.File
@@ -314,12 +314,12 @@ class DecLibraryclassObject(_DecBaseObject):
self._SecName = TAB_LIBRARY_CLASSES.upper()
## GetLibraryclasses
#
#
def GetLibraryclasses(self, Arch=TAB_ARCH_COMMON):
return self._GetItemByArch(Arch)
## GetAllLibraryclasses
#
#
def GetAllLibraryclasses(self):
return self._GetAllItems()
@@ -334,7 +334,7 @@ class DecLibraryclassItemObject(_DecItemBaseObject):
self.Libraryclass = Libraryclass
## __hash__
#
#
def __hash__(self):
return hash(self.Libraryclass + self.File)
@@ -344,7 +344,7 @@ class DecLibraryclassItemObject(_DecItemBaseObject):
return id(self) == id(Other)
## __str__
#
#
def __str__(self):
return self.Libraryclass + '|' + self.File
@@ -381,7 +381,7 @@ class DecPcdObject(_DecBaseObject):
#
# @param PcdType: PcdType
# @param Arch: Arch
#
#
def GetPcds(self, PcdType, Arch=TAB_ARCH_COMMON):
PcdType = PcdType.upper()
Arch = Arch.upper()
@@ -392,7 +392,7 @@ class DecPcdObject(_DecBaseObject):
## GetPcdsByType
#
# @param PcdType: PcdType
#
#
def GetPcdsByType(self, PcdType):
PcdType = PcdType.upper()
Retlst = []
@@ -422,7 +422,7 @@ class DecPcdItemObject(_DecItemBaseObject):
self.MaxDatumSize = MaxDatumSize
## __hash__
#
#
def __hash__(self):
return hash(self.TokenSpaceGuidCName + self.TokenCName)
@@ -434,7 +434,7 @@ class DecPcdItemObject(_DecItemBaseObject):
## GetArchListOfType
#
# @param PcdType: PcdType
#
#
def GetArchListOfType(self, PcdType):
ItemSet = set()
PcdType = PcdType.upper()
@@ -458,12 +458,12 @@ class DecGuidObjectBase(_DecBaseObject):
## GetGuidStyleItems
#
# @param Arch: Arch
#
#
def GetGuidStyleItems(self, Arch=TAB_ARCH_COMMON):
return self._GetItemByArch(Arch)
## GetGuidStyleAllItems
#
#
def GetGuidStyleAllItems(self):
return self._GetAllItems()
@@ -481,7 +481,7 @@ class DecGuidItemObject(_DecItemBaseObject):
self.GuidString = GuidString
## __hash__
#
#
def __hash__(self):
return hash(self.GuidCName)
@@ -491,7 +491,7 @@ class DecGuidItemObject(_DecItemBaseObject):
return id(self) == id(Other)
## __str__
#
#
def __str__(self):
return self.GuidCName + ' = ' + self.GuidCValue
@@ -507,14 +507,14 @@ class DecGuidObject(DecGuidObjectBase):
self._SecName = TAB_GUIDS.upper()
## GetGuids
#
#
# @param Arch: Arch
#
def GetGuids(self, Arch=TAB_ARCH_COMMON):
return self._GetItemByArch(Arch)
## GetAllGuids
#
#
def GetAllGuids(self):
return self._GetAllItems()
@@ -530,14 +530,14 @@ class DecPpiObject(DecGuidObjectBase):
self._SecName = TAB_PPIS.upper()
## GetPpis
#
#
# @param Arch: Arch
#
#
def GetPpis(self, Arch=TAB_ARCH_COMMON):
return self._GetItemByArch(Arch)
## GetAllPpis
#
#
def GetAllPpis(self):
return self._GetAllItems()
@@ -553,14 +553,14 @@ class DecProtocolObject(DecGuidObjectBase):
self._SecName = TAB_PROTOCOLS.upper()
## GetProtocols
#
#
# @param Arch: Arch
#
#
def GetProtocols(self, Arch=TAB_ARCH_COMMON):
return self._GetItemByArch(Arch)
## GetAllProtocols
#
#
def GetAllProtocols(self):
return self._GetAllItems()
@@ -577,10 +577,10 @@ class DecUserExtensionObject(_DecBaseObject):
self.ItemList = []
## GetProtocols
#
#
# @param Item: Item
# @param Scope: Scope
#
#
def AddItem(self, Item, Scope):
if not Scope:
pass
@@ -589,7 +589,7 @@ class DecUserExtensionObject(_DecBaseObject):
self.ItemList.append(Item)
## GetAllUserExtensions
#
#
def GetAllUserExtensions(self):
return self.ItemList

View File

@@ -1,12 +1,12 @@
## @file
# This file is used to define class objects of INF file [Binaries] section.
# It will consumed by InfParser.
# This file is used to define class objects of INF file [Binaries] section.
# It will consumed by InfParser.
#
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -117,7 +117,7 @@ class InfBianryCommonItem(InfBianryItem, CurrentLine):
self.Family = Family
def GetFamily(self):
return self.Family
def SetGuidValue(self, GuidValue):
self.GuidValue = GuidValue
def GetGuidValue(self):
@@ -228,7 +228,7 @@ class InfBinariesObject(InfSectionCommonDef):
Line=VerCurrentLine.GetLineNo(),
ExtraData=VerCurrentLine.GetLineString())
#
# Validate Feature Flag Express
# Validate Feature Flag Express
#
FeatureFlagRtv = IsValidFeatureFlagExp(VerContent[3].\
strip())
@@ -246,15 +246,15 @@ class InfBinariesObject(InfSectionCommonDef):
#
# Determine binary file name duplicate. Follow below rule:
#
# A binary filename must not be duplicated within
# a [Binaries] section. A binary filename may appear in
# multiple architectural [Binaries] sections. A binary
# filename listed in an architectural [Binaries] section
# must not be listed in the common architectural
# A binary filename must not be duplicated within
# a [Binaries] section. A binary filename may appear in
# multiple architectural [Binaries] sections. A binary
# filename listed in an architectural [Binaries] section
# must not be listed in the common architectural
# [Binaries] section.
#
#
# NOTE: This check will not report error now.
#
#
for Item in self.Binaries:
if Item.GetFileName() == InfBianryVerItemObj.GetFileName():
ItemSupArchList = Item.GetSupArchList()
@@ -315,7 +315,7 @@ class InfBinariesObject(InfSectionCommonDef):
Line=CurrentLineOfItem.GetLineNo(),
ExtraData=CurrentLineOfItem.GetLineString())
return False
if len(ItemContent) > 7:
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
@@ -335,7 +335,7 @@ class InfBinariesObject(InfSectionCommonDef):
BinaryFileType = ItemContent[0].strip()
if BinaryFileType == 'RAW' or BinaryFileType == 'ACPI' or BinaryFileType == 'ASL':
BinaryFileType = 'BIN'
if BinaryFileType not in DT.BINARY_FILE_TYPE_LIST:
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
@@ -344,10 +344,10 @@ class InfBinariesObject(InfSectionCommonDef):
File=CurrentLineOfItem.GetFileName(),
Line=CurrentLineOfItem.GetLineNo(),
ExtraData=CurrentLineOfItem.GetLineString())
if BinaryFileType == 'SUBTYPE_GUID':
BinaryFileType = 'FREEFORM'
if BinaryFileType == 'LIB' or BinaryFileType == 'UEFI_APP':
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
@@ -407,7 +407,7 @@ class InfBinariesObject(InfSectionCommonDef):
#
if BinaryFileType != 'FREEFORM':
InfBianryCommonItemObj.SetTarget(ItemContent[2])
if len(ItemContent) >= 4:
#
# Add Family information
@@ -416,13 +416,13 @@ class InfBinariesObject(InfSectionCommonDef):
InfBianryCommonItemObj.SetFamily(ItemContent[3])
else:
InfBianryCommonItemObj.SetTarget(ItemContent[3])
if len(ItemContent) >= 5:
#
# TagName entries are build system specific. If there
# is content in the entry, the tool must exit
# TagName entries are build system specific. If there
# is content in the entry, the tool must exit
# gracefully with an error message that indicates build
# system specific content cannot be distributed using
# system specific content cannot be distributed using
# the UDP
#
if BinaryFileType != 'FREEFORM':
@@ -435,7 +435,7 @@ class InfBinariesObject(InfSectionCommonDef):
ExtraData=CurrentLineOfItem.GetLineString())
else:
InfBianryCommonItemObj.SetFamily(ItemContent[4])
if len(ItemContent) >= 6:
#
# Add FeatureFlagExp
@@ -449,7 +449,7 @@ class InfBinariesObject(InfSectionCommonDef):
Line=CurrentLineOfItem.GetLineNo(),
ExtraData=CurrentLineOfItem.GetLineString())
#
# Validate Feature Flag Express
# Validate Feature Flag Express
#
FeatureFlagRtv = IsValidFeatureFlagExp(ItemContent[5].strip())
if not FeatureFlagRtv[0]:
@@ -468,7 +468,7 @@ class InfBinariesObject(InfSectionCommonDef):
File=CurrentLineOfItem.GetFileName(),
Line=CurrentLineOfItem.GetLineNo(),
ExtraData=CurrentLineOfItem.GetLineString())
if len(ItemContent) == 7:
if ItemContent[6].strip() == '':
Logger.Error("InfParser",
@@ -478,7 +478,7 @@ class InfBinariesObject(InfSectionCommonDef):
Line=CurrentLineOfItem.GetLineNo(),
ExtraData=CurrentLineOfItem.GetLineString())
#
# Validate Feature Flag Express
# Validate Feature Flag Express
#
FeatureFlagRtv = IsValidFeatureFlagExp(ItemContent[6].strip())
if not FeatureFlagRtv[0]:
@@ -495,15 +495,15 @@ class InfBinariesObject(InfSectionCommonDef):
#
# Determine binary file name duplicate. Follow below rule:
#
# A binary filename must not be duplicated within
# a [Binaries] section. A binary filename may appear in
# multiple architectural [Binaries] sections. A binary
# filename listed in an architectural [Binaries] section
# must not be listed in the common architectural
# A binary filename must not be duplicated within
# a [Binaries] section. A binary filename may appear in
# multiple architectural [Binaries] sections. A binary
# filename listed in an architectural [Binaries] section
# must not be listed in the common architectural
# [Binaries] section.
#
#
# NOTE: This check will not report error now.
#
#
# for Item in self.Binaries:
# if Item.GetFileName() == InfBianryCommonItemObj.GetFileName():
# ItemSupArchList = Item.GetSupArchList()
@@ -537,7 +537,7 @@ class InfBinariesObject(InfSectionCommonDef):
for ArchItem in ArchList:
#
# Validate Arch
#
#
if (ArchItem == '' or ArchItem is None):
ArchItem = 'COMMON'
__SupArchList.append(ArchItem)
@@ -546,7 +546,7 @@ class InfBinariesObject(InfSectionCommonDef):
if len(UiInf) > 0:
#
# Check UI
#
#
for UiItem in UiInf:
IsValidFileFlag = False
InfBianryUiItemObj = None
@@ -630,7 +630,7 @@ class InfBinariesObject(InfSectionCommonDef):
Line=UiCurrentLine.GetLineNo(),
ExtraData=UiCurrentLine.GetLineString())
#
# Validate Feature Flag Express
# Validate Feature Flag Express
#
FeatureFlagRtv = IsValidFeatureFlagExp(UiContent[3].strip())
if not FeatureFlagRtv[0]:
@@ -647,15 +647,15 @@ class InfBinariesObject(InfSectionCommonDef):
#
# Determine binary file name duplicate. Follow below rule:
#
# A binary filename must not be duplicated within
# a [Binaries] section. A binary filename may appear in
# multiple architectural [Binaries] sections. A binary
# filename listed in an architectural [Binaries] section
# must not be listed in the common architectural
# A binary filename must not be duplicated within
# a [Binaries] section. A binary filename may appear in
# multiple architectural [Binaries] sections. A binary
# filename listed in an architectural [Binaries] section
# must not be listed in the common architectural
# [Binaries] section.
#
#
# NOTE: This check will not report error now.
#
#
# for Item in self.Binaries:
# if Item.GetFileName() == InfBianryUiItemObj.GetFileName():
# ItemSupArchList = Item.GetSupArchList()

View File

@@ -1,12 +1,12 @@
## @file
# This file is used to define class objects of INF file [BuildOptions] section.
# It will consumed by InfParser.
# This file is used to define class objects of INF file [BuildOptions] section.
# It will consumed by InfParser.
#
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -16,7 +16,7 @@
InfBuildOptionObject
'''
from Library import GlobalData
from Library import GlobalData
from Object.Parser.InfCommonObject import InfSectionCommonDef
@@ -25,17 +25,17 @@ class InfBuildOptionItem():
self.Content = ''
self.SupArchList = []
self.AsBuildList = []
def SetContent(self, Content):
self.Content = Content
def GetContent(self):
return self.Content
def SetSupArchList(self, SupArchList):
self.SupArchList = SupArchList
def GetSupArchList(self):
return self.SupArchList
#
# AsBuild Information
#
@@ -43,12 +43,12 @@ class InfBuildOptionItem():
self.AsBuildList = AsBuildList
def GetAsBuildList(self):
return self.AsBuildList
## INF BuildOption section
# Macro define is not permitted for this section.
#
#
#
class InfBuildOptionsObject(InfSectionCommonDef):
def __init__(self):
self.BuildOptions = []
@@ -56,38 +56,38 @@ class InfBuildOptionsObject(InfSectionCommonDef):
## SetBuildOptions function
#
# For BuildOptionName, need to validate it's format
# For BuildOptionValue, just ignore it.
# For BuildOptionValue, just ignore it.
#
# @param Arch Indicated which arch of build options belong to.
# @param BuildOptCont A list contain BuildOption related information.
# The element in the list contain 3 members.
# BuildOptionName, BuildOptionValue and IsReplace
# flag.
#
#
# @return True Build options set/validate successfully
# @return False Build options set/validate failed
#
def SetBuildOptions(self, BuildOptCont, ArchList = None, SectionContent = ''):
if not GlobalData.gIS_BINARY_INF:
if not GlobalData.gIS_BINARY_INF:
if SectionContent.strip() != '':
InfBuildOptionItemObj = InfBuildOptionItem()
InfBuildOptionItemObj.SetContent(SectionContent)
InfBuildOptionItemObj.SetSupArchList(ArchList)
self.BuildOptions.append(InfBuildOptionItemObj)
else:
#
# For AsBuild INF file
# For AsBuild INF file
#
if len(BuildOptCont) >= 1:
InfBuildOptionItemObj = InfBuildOptionItem()
InfBuildOptionItemObj.SetAsBuildList(BuildOptCont)
InfBuildOptionItemObj.SetSupArchList(ArchList)
self.BuildOptions.append(InfBuildOptionItemObj)
return True
def GetBuildOptions(self):
return self.BuildOptions
return self.BuildOptions

View File

@@ -1,12 +1,12 @@
## @file
# This file is used to define common class objects for INF file.
# This file is used to define common class objects for INF file.
# It will consumed by InfParser
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -17,9 +17,9 @@ InfCommonObject
'''
## InfLineCommentObject
#
# Comment Object for any line in the INF file
#
#
# Comment Object for any line in the INF file
#
# #
# # HeaderComment
# #
@@ -29,21 +29,21 @@ class InfLineCommentObject():
def __init__(self):
self.HeaderComments = ''
self.TailComments = ''
def SetHeaderComments(self, HeaderComments):
self.HeaderComments = HeaderComments
def GetHeaderComments(self):
return self.HeaderComments
def SetTailComments(self, TailComments):
self.TailComments = TailComments
def GetTailComments(self):
return self.TailComments
return self.TailComments
## CurrentLine
#
#
class CurrentLine():
def __init__(self):
self.LineNo = ''
@@ -51,48 +51,48 @@ class CurrentLine():
self.FileName = ''
## SetLineNo
#
# @param LineNo: LineNo
#
#
# @param LineNo: LineNo
#
def SetLineNo(self, LineNo):
self.LineNo = LineNo
## GetLineNo
#
#
def GetLineNo(self):
return self.LineNo
## SetLineString
#
# @param LineString: Line String content
#
#
# @param LineString: Line String content
#
def SetLineString(self, LineString):
self.LineString = LineString
## GetLineString
#
#
def GetLineString(self):
return self.LineString
## SetFileName
#
#
# @param FileName: File Name
#
#
def SetFileName(self, FileName):
self.FileName = FileName
## GetFileName
#
#
def GetFileName(self):
return self.FileName
##
##
# Inf Section common data
#
class InfSectionCommonDef():
def __init__(self):
#
# #
# #
# # HeaderComments at here
# #
# [xxSection] TailComments at here
@@ -104,7 +104,7 @@ class InfSectionCommonDef():
# The support arch list of this section
#
self.SupArchList = []
#
# Store all section content
# Key is supported Arch
@@ -112,51 +112,51 @@ class InfSectionCommonDef():
self.AllContent = {}
## SetHeaderComments
#
#
# @param HeaderComments: HeaderComments
#
#
def SetHeaderComments(self, HeaderComments):
self.HeaderComments = HeaderComments
## GetHeaderComments
#
#
def GetHeaderComments(self):
return self.HeaderComments
## SetTailComments
#
#
# @param TailComments: TailComments
#
#
def SetTailComments(self, TailComments):
self.TailComments = TailComments
## GetTailComments
#
#
def GetTailComments(self):
return self.TailComments
## SetSupArchList
#
#
# @param Arch: Arch
#
#
def SetSupArchList(self, Arch):
if Arch not in self.SupArchList:
self.SupArchList.append(Arch)
## GetSupArchList
#
#
def GetSupArchList(self):
return self.SupArchList
## SetAllContent
#
#
# @param ArchList: ArchList
# @param Content: Content
#
#
def SetAllContent(self, Content):
self.AllContent = Content
## GetAllContent
#
#
def GetAllContent(self):
return self.AllContent

View File

@@ -1,12 +1,12 @@
## @file
# This file is used to define common class objects of [Defines] section for INF file.
# This file is used to define common class objects of [Defines] section for INF file.
# It will consumed by InfParser
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -19,13 +19,13 @@ InfDefineCommonObject
from Object.Parser.InfCommonObject import InfLineCommentObject
## InfDefineImageExeParamItem
#
#
class InfDefineImageExeParamItem():
def __init__(self):
self.CName = ''
self.FeatureFlagExp = ''
self.Comments = InfLineCommentObject()
def SetCName(self, CName):
self.CName = CName
def GetCName(self):
@@ -36,49 +36,49 @@ class InfDefineImageExeParamItem():
return self.FeatureFlagExp
## InfDefineEntryPointItem
#
#
class InfDefineEntryPointItem(InfDefineImageExeParamItem):
def __init__(self):
InfDefineImageExeParamItem.__init__(self)
## InfDefineUnloadImageItem
#
#
class InfDefineUnloadImageItem(InfDefineImageExeParamItem):
def __init__(self):
InfDefineImageExeParamItem.__init__(self)
## InfDefineConstructorItem
#
#
class InfDefineConstructorItem(InfDefineImageExeParamItem):
def __init__(self):
InfDefineImageExeParamItem.__init__(self)
self.SupModList = []
def SetSupModList(self, SupModList):
self.SupModList = SupModList
def GetSupModList(self):
return self.SupModList
## InfDefineDestructorItem
#
#
class InfDefineDestructorItem(InfDefineImageExeParamItem):
def __init__(self):
InfDefineImageExeParamItem.__init__(self)
self.SupModList = []
def SetSupModList(self, SupModList):
self.SupModList = SupModList
def GetSupModList(self):
return self.SupModList
## InfDefineLibraryItem
#
#
class InfDefineLibraryItem():
def __init__(self):
self.LibraryName = ''
self.Types = []
self.Comments = InfLineCommentObject()
def SetLibraryName(self, Name):
self.LibraryName = Name
def GetLibraryName(self):
@@ -86,4 +86,4 @@ class InfDefineLibraryItem():
def SetTypes(self, Type):
self.Types = Type
def GetTypes(self):
return self.Types
return self.Types

View File

@@ -1,12 +1,12 @@
## @file
# This file is used to define class objects of [Defines] section for INF file.
# This file is used to define class objects of [Defines] section for INF file.
# It will consumed by InfParser
#
# Copyright (c) 2011 - 2018, 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,
@@ -21,21 +21,21 @@ import re
from Logger import StringTable as ST
from Logger import ToolError
from Library import GlobalData
from Library import GlobalData
from Library import DataType as DT
from Library.StringUtils import GetSplitValueList
from Library.Misc import CheckGuidRegFormat
from Library.Misc import Sdict
from Library.Misc import ConvPathFromAbsToRel
from Library.Misc import ValidateUNIFilePath
from Library.ExpressionValidate import IsValidFeatureFlagExp
from Library.ExpressionValidate import IsValidFeatureFlagExp
from Library.ParserValidate import IsValidWord
from Library.ParserValidate import IsValidInfMoudleType
from Library.ParserValidate import IsValidHex
from Library.ParserValidate import IsValidHexVersion
from Library.ParserValidate import IsValidDecVersion
from Library.ParserValidate import IsValidCVariableName
from Library.ParserValidate import IsValidBoolType
from Library.ParserValidate import IsValidInfMoudleType
from Library.ParserValidate import IsValidHex
from Library.ParserValidate import IsValidHexVersion
from Library.ParserValidate import IsValidDecVersion
from Library.ParserValidate import IsValidCVariableName
from Library.ParserValidate import IsValidBoolType
from Library.ParserValidate import IsValidPath
from Library.ParserValidate import IsValidFamily
from Library.ParserValidate import IsValidIdentifier
@@ -47,7 +47,7 @@ from Object.Parser.InfMisc import ErrorInInf
from Object.Parser.InfDefineCommonObject import InfDefineLibraryItem
from Object.Parser.InfDefineCommonObject import InfDefineEntryPointItem
from Object.Parser.InfDefineCommonObject import InfDefineUnloadImageItem
from Object.Parser.InfDefineCommonObject import InfDefineConstructorItem
from Object.Parser.InfDefineCommonObject import InfDefineConstructorItem
from Object.Parser.InfDefineCommonObject import InfDefineDestructorItem
class InfDefSectionOptionRomInfo():
@@ -65,9 +65,9 @@ class InfDefSectionOptionRomInfo():
if self.PciVendorId is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_PCI_VENDOR_ID),
LineInfo=self.CurrentLine)
return False
return False
#
# The PciVendorId should be hex string.
# The PciVendorId should be hex string.
#
if (IsValidHex(PciVendorId)):
self.PciVendorId = InfDefMember()
@@ -78,10 +78,10 @@ class InfDefSectionOptionRomInfo():
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(PciVendorId),
LineInfo=self.CurrentLine)
return False
def GetPciVendorId(self):
return self.PciVendorId
def SetPciDeviceId(self, PciDeviceId, Comments):
#
# Value has been set before.
@@ -89,23 +89,23 @@ class InfDefSectionOptionRomInfo():
if self.PciDeviceId is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_PCI_DEVICE_ID),
LineInfo=self.CurrentLine)
return False
return False
#
# The PciDeviceId should be hex string.
# The PciDeviceId should be hex string.
#
if (IsValidHex(PciDeviceId)):
self.PciDeviceId = InfDefMember()
self.PciDeviceId.SetValue(PciDeviceId)
self.PciDeviceId.Comments = Comments
self.PciDeviceId.Comments = Comments
return True
else:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(PciDeviceId),
LineInfo=self.CurrentLine)
return False
def GetPciDeviceId(self):
return self.PciDeviceId
def SetPciClassCode(self, PciClassCode, Comments):
#
# Value has been set before.
@@ -113,9 +113,9 @@ class InfDefSectionOptionRomInfo():
if self.PciClassCode is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_PCI_CLASS_CODE),
LineInfo=self.CurrentLine)
return False
return False
#
# The PciClassCode should be 4 bytes hex string.
# The PciClassCode should be 4 bytes hex string.
#
if (IsValidHex(PciClassCode)):
self.PciClassCode = InfDefMember()
@@ -127,10 +127,10 @@ class InfDefSectionOptionRomInfo():
(PciClassCode),
LineInfo=self.CurrentLine)
return False
def GetPciClassCode(self):
return self.PciClassCode
def SetPciRevision(self, PciRevision, Comments):
#
# Value has been set before.
@@ -138,9 +138,9 @@ class InfDefSectionOptionRomInfo():
if self.PciRevision is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_PCI_REVISION),
LineInfo=self.CurrentLine)
return False
return False
#
# The PciRevision should be 4 bytes hex string.
# The PciRevision should be 4 bytes hex string.
#
if (IsValidHex(PciRevision)):
self.PciRevision = InfDefMember()
@@ -151,10 +151,10 @@ class InfDefSectionOptionRomInfo():
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(PciRevision),
LineInfo=self.CurrentLine)
return False
def GetPciRevision(self):
return self.PciRevision
def SetPciCompress(self, PciCompress, Comments):
#
# Value has been set before.
@@ -163,9 +163,9 @@ class InfDefSectionOptionRomInfo():
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_PCI_COMPRESS),
LineInfo=self.CurrentLine)
return False
#
# The PciCompress should be 'TRUE' or 'FALSE'.
# The PciCompress should be 'TRUE' or 'FALSE'.
#
if (PciCompress == 'TRUE' or PciCompress == 'FALSE'):
self.PciCompress = InfDefMember()
@@ -175,9 +175,9 @@ class InfDefSectionOptionRomInfo():
else:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(PciCompress),
LineInfo=self.CurrentLine)
return False
return False
def GetPciCompress(self):
return self.PciCompress
return self.PciCompress
##
# INF [Define] section Object
#
@@ -210,15 +210,15 @@ class InfDefSection(InfDefSectionOptionRomInfo):
## SetHeadComment
#
# @param BaseName: BaseName
#
#
def SetBaseName(self, BaseName, Comments):
#
# Value has been set before.
#
if self.BaseName is not None:
if self.BaseName is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_BASE_NAME),
LineInfo=self.CurrentLine)
return False
return False
if not (BaseName == '' or BaseName is None):
if IsValidWord(BaseName) and not BaseName.startswith("_"):
self.BaseName = InfDefMember()
@@ -231,26 +231,26 @@ class InfDefSection(InfDefSectionOptionRomInfo):
return False
## GetBaseName
#
#
def GetBaseName(self):
return self.BaseName
## SetFileGuid
#
# @param FileGuid: FileGuid
#
#
def SetFileGuid(self, FileGuid, Comments):
#
# Value has been set before.
#
if self.FileGuid is not None:
if self.FileGuid is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
%(DT.TAB_INF_DEFINES_FILE_GUID),
LineInfo=self.CurrentLine)
return False
return False
#
# Do verification of GUID content/format
#
#
if (CheckGuidRegFormat(FileGuid)):
self.FileGuid = InfDefMember()
self.FileGuid.SetValue(FileGuid)
@@ -262,23 +262,23 @@ class InfDefSection(InfDefSectionOptionRomInfo):
return False
## GetFileGuid
#
#
def GetFileGuid(self):
return self.FileGuid
## SetModuleType
#
# @param ModuleType: ModuleType
#
#
def SetModuleType(self, ModuleType, Comments):
#
# Value has been set before.
#
if self.ModuleType is not None:
if self.ModuleType is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
%(DT.TAB_INF_DEFINES_MODULE_TYPE),
LineInfo=self.CurrentLine)
return False
return False
#
# Valid Module Type or not
#
@@ -289,7 +289,7 @@ class InfDefSection(InfDefSectionOptionRomInfo):
self.ModuleType.CurrentLine.SetLineNo(self.CurrentLine[1])
self.ModuleType.CurrentLine.SetLineString(self.CurrentLine[2])
self.ModuleType.CurrentLine.SetFileName(self.CurrentLine[0])
self.ModuleType.Comments = Comments
self.ModuleType.Comments = Comments
return True
else:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_MODULETYPE_INVALID%\
@@ -298,14 +298,14 @@ class InfDefSection(InfDefSectionOptionRomInfo):
return False
## GetModuleType
#
#
def GetModuleType(self):
return self.ModuleType
## SetModuleUniFileName
#
# @param ModuleUniFileName: ModuleUniFileName
#
#
def SetModuleUniFileName(self, ModuleUniFileName, Comments):
if Comments:
pass
@@ -315,25 +315,25 @@ class InfDefSection(InfDefSectionOptionRomInfo):
self.ModuleUniFileName = ModuleUniFileName
## GetModuleType
#
#
def GetModuleUniFileName(self):
return self.ModuleUniFileName
## SetInfVersion
#
# @param InfVersion: InfVersion
#
#
def SetInfVersion(self, InfVersion, Comments):
#
# Value has been set before.
#
if self.InfVersion is not None:
if self.InfVersion is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
%(DT.TAB_INF_DEFINES_INF_VERSION),
LineInfo=self.CurrentLine)
return False
return False
#
# The InfVersion should be 4 bytes hex string.
# The InfVersion should be 4 bytes hex string.
#
if (IsValidHex(InfVersion)):
if (InfVersion < '0x00010005'):
@@ -356,25 +356,25 @@ class InfDefSection(InfDefSectionOptionRomInfo):
return True
## GetInfVersion
#
#
def GetInfVersion(self):
return self.InfVersion
## SetEdkReleaseVersion
#
# @param EdkReleaseVersion: EdkReleaseVersion
#
#
def SetEdkReleaseVersion(self, EdkReleaseVersion, Comments):
#
# Value has been set before.
#
if self.EdkReleaseVersion is not None:
if self.EdkReleaseVersion is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
%(DT.TAB_INF_DEFINES_EDK_RELEASE_VERSION),
LineInfo=self.CurrentLine)
return False
return False
#
# The EdkReleaseVersion should be 4 bytes hex string.
# The EdkReleaseVersion should be 4 bytes hex string.
#
if IsValidHexVersion(EdkReleaseVersion) or \
IsValidDecVersionVal(EdkReleaseVersion):
@@ -389,25 +389,25 @@ class InfDefSection(InfDefSectionOptionRomInfo):
return False
## GetEdkReleaseVersion
#
#
def GetEdkReleaseVersion(self):
return self.EdkReleaseVersion
return self.EdkReleaseVersion
## SetUefiSpecificationVersion
#
# @param UefiSpecificationVersion: UefiSpecificationVersion
#
#
def SetUefiSpecificationVersion(self, UefiSpecificationVersion, Comments):
#
# Value has been set before.
#
if self.UefiSpecificationVersion is not None:
if self.UefiSpecificationVersion is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
%(DT.TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION),
LineInfo=self.CurrentLine)
return False
return False
#
# The EdkReleaseVersion should be 4 bytes hex string.
# The EdkReleaseVersion should be 4 bytes hex string.
#
if IsValidHexVersion(UefiSpecificationVersion) or \
IsValidDecVersionVal(UefiSpecificationVersion):
@@ -422,25 +422,25 @@ class InfDefSection(InfDefSectionOptionRomInfo):
return False
## GetUefiSpecificationVersion
#
#
def GetUefiSpecificationVersion(self):
return self.UefiSpecificationVersion
return self.UefiSpecificationVersion
## SetPiSpecificationVersion
#
# @param PiSpecificationVersion: PiSpecificationVersion
#
#
def SetPiSpecificationVersion(self, PiSpecificationVersion, Comments):
#
# Value has been set before.
#
if self.PiSpecificationVersion is not None:
if self.PiSpecificationVersion is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
%(DT.TAB_INF_DEFINES_PI_SPECIFICATION_VERSION),
LineInfo=self.CurrentLine)
return False
return False
#
# The EdkReleaseVersion should be 4 bytes hex string.
# The EdkReleaseVersion should be 4 bytes hex string.
#
if IsValidHexVersion(PiSpecificationVersion) or \
IsValidDecVersionVal(PiSpecificationVersion):
@@ -451,24 +451,24 @@ class InfDefSection(InfDefSectionOptionRomInfo):
else:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID\
%(PiSpecificationVersion),
LineInfo=self.CurrentLine)
LineInfo=self.CurrentLine)
return False
## GetPiSpecificationVersion
#
#
def GetPiSpecificationVersion(self):
return self.PiSpecificationVersion
## SetLibraryClass
#
# @param LibraryClass: LibraryClass
#
#
def SetLibraryClass(self, LibraryClass, Comments):
ValueList = GetSplitValueList(LibraryClass)
Name = ValueList[0]
Name = ValueList[0]
if IsValidWord(Name):
InfDefineLibraryItemObj = InfDefineLibraryItem()
InfDefineLibraryItemObj.SetLibraryName(Name)
InfDefineLibraryItemObj.SetLibraryName(Name)
InfDefineLibraryItemObj.Comments = Comments
if len(ValueList) == 2:
Type = ValueList[1]
@@ -479,23 +479,23 @@ class InfDefSection(InfDefSectionOptionRomInfo):
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Item),
LineInfo=self.CurrentLine)
return False
InfDefineLibraryItemObj.SetTypes(TypeList)
self.LibraryClass.append(InfDefineLibraryItemObj)
InfDefineLibraryItemObj.SetTypes(TypeList)
self.LibraryClass.append(InfDefineLibraryItemObj)
else:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Name),
LineInfo=self.CurrentLine)
return False
return True
def GetLibraryClass(self):
return self.LibraryClass
def SetVersionString(self, VersionString, Comments):
#
# Value has been set before.
#
if self.VersionString is not None:
if self.VersionString is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
%(DT.TAB_INF_DEFINES_VERSION_STRING),
LineInfo=self.CurrentLine)
@@ -503,25 +503,25 @@ class InfDefSection(InfDefSectionOptionRomInfo):
if not IsValidDecVersion(VersionString):
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID\
%(VersionString),
LineInfo=self.CurrentLine)
LineInfo=self.CurrentLine)
self.VersionString = InfDefMember()
self.VersionString.SetValue(VersionString)
self.VersionString.Comments = Comments
return True
def GetVersionString(self):
return self.VersionString
def SetPcdIsDriver(self, PcdIsDriver, Comments):
#
# Value has been set before.
#
if self.PcdIsDriver is not None:
if self.PcdIsDriver is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND\
%(DT.TAB_INF_DEFINES_PCD_IS_DRIVER),
LineInfo=self.CurrentLine)
return False
return False
if PcdIsDriver == 'PEI_PCD_DRIVER' or PcdIsDriver == 'DXE_PCD_DRIVER':
self.PcdIsDriver = InfDefMember()
self.PcdIsDriver.SetValue(PcdIsDriver)
@@ -531,20 +531,20 @@ class InfDefSection(InfDefSectionOptionRomInfo):
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(PcdIsDriver),
LineInfo=self.CurrentLine)
return False
def GetPcdIsDriver(self):
return self.PcdIsDriver
#
# SetEntryPoint
#
#
def SetEntryPoint(self, EntryPoint, Comments):
#
# It can be a list
#
ValueList = []
TokenList = GetSplitValueList(EntryPoint, DT.TAB_VALUE_SPLIT)
ValueList[0:len(TokenList)] = TokenList
ValueList[0:len(TokenList)] = TokenList
InfDefineEntryPointItemObj = InfDefineEntryPointItem()
if not IsValidCVariableName(ValueList[0]):
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%\
@@ -557,33 +557,33 @@ class InfDefSection(InfDefSectionOptionRomInfo):
(ValueList[1]),
LineInfo=self.CurrentLine)
#
# Validate FFE
# Validate FFE
#
FeatureFlagRtv = IsValidFeatureFlagExp(ValueList[1].strip())
if not FeatureFlagRtv[0]:
ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%\
(FeatureFlagRtv[1]),
LineInfo=self.CurrentLine)
InfDefineEntryPointItemObj.SetFeatureFlagExp(ValueList[1])
LineInfo=self.CurrentLine)
InfDefineEntryPointItemObj.SetFeatureFlagExp(ValueList[1])
if len(ValueList) > 2:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(EntryPoint),
LineInfo=self.CurrentLine)
InfDefineEntryPointItemObj.Comments = Comments
self.EntryPoint.append(InfDefineEntryPointItemObj)
InfDefineEntryPointItemObj.Comments = Comments
self.EntryPoint.append(InfDefineEntryPointItemObj)
def GetEntryPoint(self):
return self.EntryPoint
#
# SetUnloadImages
#
#
def SetUnloadImages(self, UnloadImages, Comments):
#
# It can be a list
#
ValueList = []
TokenList = GetSplitValueList(UnloadImages, DT.TAB_VALUE_SPLIT)
ValueList[0:len(TokenList)] = TokenList
ValueList[0:len(TokenList)] = TokenList
InfDefineUnloadImageItemObj = InfDefineUnloadImageItem()
if not IsValidCVariableName(ValueList[0]):
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[0]),
@@ -594,33 +594,33 @@ class InfDefSection(InfDefSectionOptionRomInfo):
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[1]),
LineInfo=self.CurrentLine)
#
# Validate FFE
# Validate FFE
#
FeatureFlagRtv = IsValidFeatureFlagExp(ValueList[1].strip())
if not FeatureFlagRtv[0]:
ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[1]),
LineInfo=self.CurrentLine)
InfDefineUnloadImageItemObj.SetFeatureFlagExp(ValueList[1])
if len(ValueList) > 2:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(UnloadImages),
LineInfo=self.CurrentLine)
InfDefineUnloadImageItemObj.Comments = Comments
self.UnloadImages.append(InfDefineUnloadImageItemObj)
def GetUnloadImages(self):
return self.UnloadImages
#
# SetConstructor
#
#
def SetConstructor(self, Constructor, Comments):
#
# It can be a list
#
ValueList = []
TokenList = GetSplitValueList(Constructor, DT.TAB_VALUE_SPLIT)
ValueList[0:len(TokenList)] = TokenList
ValueList[0:len(TokenList)] = TokenList
InfDefineConstructorItemObj = InfDefineConstructorItem()
if not IsValidCVariableName(ValueList[0]):
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[0]),
@@ -635,39 +635,39 @@ class InfDefSection(InfDefSectionOptionRomInfo):
if ModItem not in DT.MODULE_LIST:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_MODULETYPE_INVALID%(ModItem),
LineInfo=self.CurrentLine)
InfDefineConstructorItemObj.SetSupModList(ModList)
InfDefineConstructorItemObj.SetSupModList(ModList)
if len(ValueList) == 3:
if ValueList[2].strip() == '':
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[2]),
LineInfo=self.CurrentLine)
#
# Validate FFE
# Validate FFE
#
FeatureFlagRtv = IsValidFeatureFlagExp(ValueList[2].strip())
if not FeatureFlagRtv[0]:
ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[2]),
LineInfo=self.CurrentLine)
InfDefineConstructorItemObj.SetFeatureFlagExp(ValueList[2])
if len(ValueList) > 3:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Constructor),
LineInfo=self.CurrentLine)
InfDefineConstructorItemObj.Comments = Comments
self.Constructor.append(InfDefineConstructorItemObj)
InfDefineConstructorItemObj.Comments = Comments
self.Constructor.append(InfDefineConstructorItemObj)
def GetConstructor(self):
return self.Constructor
#
# SetDestructor
#
#
def SetDestructor(self, Destructor, Comments):
#
# It can be a list and only 1 set to TRUE
#
#
ValueList = []
TokenList = GetSplitValueList(Destructor, DT.TAB_VALUE_SPLIT)
ValueList[0:len(TokenList)] = TokenList
ValueList[0:len(TokenList)] = TokenList
InfDefineDestructorItemObj = InfDefineDestructorItem()
if not IsValidCVariableName(ValueList[0]):
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[0]),
@@ -682,30 +682,30 @@ class InfDefSection(InfDefSectionOptionRomInfo):
if ModItem not in DT.MODULE_LIST:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_MODULETYPE_INVALID%(ModItem),
LineInfo=self.CurrentLine)
InfDefineDestructorItemObj.SetSupModList(ModList)
InfDefineDestructorItemObj.SetSupModList(ModList)
if len(ValueList) == 3:
if ValueList[2].strip() == '':
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(ValueList[2]),
LineInfo=self.CurrentLine)
#
# Validate FFE
# Validate FFE
#
FeatureFlagRtv = IsValidFeatureFlagExp(ValueList[2].strip())
if not FeatureFlagRtv[0]:
ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[1]),
LineInfo=self.CurrentLine)
InfDefineDestructorItemObj.SetFeatureFlagExp(ValueList[2])
if len(ValueList) > 3:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Destructor),
LineInfo=self.CurrentLine)
InfDefineDestructorItemObj.Comments = Comments
self.Destructor.append(InfDefineDestructorItemObj)
InfDefineDestructorItemObj.Comments = Comments
self.Destructor.append(InfDefineDestructorItemObj)
def GetDestructor(self):
return self.Destructor
def SetShadow(self, Shadow, Comments):
#
# Value has been set before.
@@ -713,7 +713,7 @@ class InfDefSection(InfDefSectionOptionRomInfo):
if self.Shadow is not None:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND%(DT.TAB_INF_DEFINES_SHADOW),
LineInfo=self.CurrentLine)
return False
return False
if (IsValidBoolType(Shadow)):
self.Shadow = InfDefMember()
self.Shadow.SetValue(Shadow)
@@ -751,22 +751,22 @@ class InfDefSection(InfDefSectionOptionRomInfo):
IsValidFileFlag = False
ModulePath = os.path.split(self.CurrentLine[0])[0]
if IsValidPath(FileName, ModulePath):
IsValidFileFlag = True
IsValidFileFlag = True
else:
ErrorInInf(ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(FileName),
LineInfo=self.CurrentLine)
return False
if IsValidFileFlag:
FileName = ConvPathFromAbsToRel(FileName, GlobalData.gINF_MODULE_DIR)
FileName = ConvPathFromAbsToRel(FileName, GlobalData.gINF_MODULE_DIR)
self.CustomMakefile.append((Family, FileName, Comments))
IsValidFileFlag = False
return True
else:
return False
def GetCustomMakefile(self):
return self.CustomMakefile
#
# ["SPEC" <Spec> <EOL>]*{0,}
# <Spec> ::= <Word> "=" <VersionVal>
@@ -785,7 +785,7 @@ class InfDefSection(InfDefSectionOptionRomInfo):
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_NO_NAME + ' Or ' + ST.ERR_INF_PARSER_DEFINE_ITEM_NO_VALUE,
LineInfo=self.CurrentLine)
Name = __ValueList[0].strip()
Version = __ValueList[1].strip()
Version = __ValueList[1].strip()
if IsValidIdentifier(Name):
if IsValidDecVersion(Version):
self.Specification.append((Name, Version, Comments))
@@ -794,15 +794,15 @@ class InfDefSection(InfDefSectionOptionRomInfo):
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Version),
LineInfo=self.CurrentLine)
return False
else:
else:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(Name),
LineInfo=self.CurrentLine)
return False
return False
return True
def GetSpecification(self):
return self.Specification
#
# [<UefiHiiResource> <EOL>]{0,1}
# <UefiHiiResource> ::= "UEFI_HII_RESOURCE_SECTION" "=" <BoolType>
@@ -815,12 +815,12 @@ class InfDefSection(InfDefSectionOptionRomInfo):
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_MORE_THAN_ONE_FOUND
%(DT.TAB_INF_DEFINES_UEFI_HII_RESOURCE_SECTION),
LineInfo=self.CurrentLine)
return False
return False
if not (UefiHiiResourceSection == '' or UefiHiiResourceSection is None):
if (IsValidBoolType(UefiHiiResourceSection)):
self.UefiHiiResourceSection = InfDefMember()
self.UefiHiiResourceSection.SetValue(UefiHiiResourceSection)
self.UefiHiiResourceSection.Comments = Comments
self.UefiHiiResourceSection.Comments = Comments
return True
else:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(UefiHiiResourceSection),
@@ -828,28 +828,28 @@ class InfDefSection(InfDefSectionOptionRomInfo):
return False
else:
return False
def GetUefiHiiResourceSection(self):
return self.UefiHiiResourceSection
def SetDpxSource(self, DpxSource, Comments):
def SetDpxSource(self, DpxSource, Comments):
#
# The MakefileName specified file should exist
#
IsValidFileFlag = False
ModulePath = os.path.split(self.CurrentLine[0])[0]
if IsValidPath(DpxSource, ModulePath):
IsValidFileFlag = True
IsValidFileFlag = True
else:
ErrorInInf(ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(DpxSource),
LineInfo=self.CurrentLine)
return False
if IsValidFileFlag:
DpxSource = ConvPathFromAbsToRel(DpxSource,
GlobalData.gINF_MODULE_DIR)
DpxSource = ConvPathFromAbsToRel(DpxSource,
GlobalData.gINF_MODULE_DIR)
self.DpxSource.append((DpxSource, Comments))
IsValidFileFlag = False
return True
return True
def GetDpxSource(self):
return self.DpxSource
@@ -867,7 +867,7 @@ gFUNCTION_MAPPING_FOR_DEFINE_SECTION = {
DT.TAB_INF_DEFINES_INF_VERSION : InfDefSection.SetInfVersion,
#
# Optional Fields
#
#
DT.TAB_INF_DEFINES_MODULE_UNI_FILE : InfDefSection.SetModuleUniFileName,
DT.TAB_INF_DEFINES_EDK_RELEASE_VERSION : InfDefSection.SetEdkReleaseVersion,
DT.TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION : InfDefSection.SetUefiSpecificationVersion,
@@ -882,10 +882,10 @@ gFUNCTION_MAPPING_FOR_DEFINE_SECTION = {
DT.TAB_INF_DEFINES_SHADOW : InfDefSection.SetShadow,
DT.TAB_INF_DEFINES_PCI_VENDOR_ID : InfDefSection.SetPciVendorId,
DT.TAB_INF_DEFINES_PCI_DEVICE_ID : InfDefSection.SetPciDeviceId,
DT.TAB_INF_DEFINES_PCI_CLASS_CODE : InfDefSection.SetPciClassCode,
DT.TAB_INF_DEFINES_PCI_CLASS_CODE : InfDefSection.SetPciClassCode,
DT.TAB_INF_DEFINES_PCI_REVISION : InfDefSection.SetPciRevision,
DT.TAB_INF_DEFINES_PCI_COMPRESS : InfDefSection.SetPciCompress,
DT.TAB_INF_DEFINES_CUSTOM_MAKEFILE : InfDefSection.SetCustomMakefile,
DT.TAB_INF_DEFINES_CUSTOM_MAKEFILE : InfDefSection.SetCustomMakefile,
DT.TAB_INF_DEFINES_SPEC : InfDefSection.SetSpecification,
DT.TAB_INF_DEFINES_UEFI_HII_RESOURCE_SECTION : InfDefSection.SetUefiHiiResourceSection,
DT.TAB_INF_DEFINES_DPX_SOURCE : InfDefSection.SetDpxSource
@@ -908,7 +908,7 @@ class InfDefMember():
return self.Value
def SetValue(self, Value):
self.Value = Value
## InfDefObject
#
#
@@ -922,7 +922,7 @@ class InfDefObject(InfSectionCommonDef):
#
HasFoundInfVersionFalg = False
LineInfo = ['', -1, '']
ArchListString = ' '.join(Arch)
ArchListString = ' '.join(Arch)
#
# Parse Define items.
#
@@ -947,7 +947,7 @@ class InfDefObject(InfSectionCommonDef):
ErrorCode=ToolError.EDK1_INF_ERROR,
RaiseError=True)
if Name == DT.TAB_INF_DEFINES_INF_VERSION:
HasFoundInfVersionFalg = True
HasFoundInfVersionFalg = True
if not (Name == '' or Name is None):
#
# Process "SPEC" Keyword definition.
@@ -958,7 +958,7 @@ class InfDefObject(InfSectionCommonDef):
Name = "SPEC"
Value = SpecValue + " = " + Value
if ArchListString in self.Defines:
DefineList = self.Defines[ArchListString]
DefineList = self.Defines[ArchListString]
LineInfo[0] = InfDefMemberObj.CurrentLine.GetFileName()
LineInfo[1] = InfDefMemberObj.CurrentLine.GetLineNo()
LineInfo[2] = InfDefMemberObj.CurrentLine.GetLineString()
@@ -968,7 +968,7 @@ class InfDefObject(InfSectionCommonDef):
#
if Name not in gFUNCTION_MAPPING_FOR_DEFINE_SECTION.keys():
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_SECTION_KEYWORD_INVALID%(Name),
LineInfo=LineInfo)
LineInfo=LineInfo)
else:
ProcessFunc = gFUNCTION_MAPPING_FOR_DEFINE_SECTION[Name]
if (ProcessFunc is not None):
@@ -988,7 +988,7 @@ class InfDefObject(InfSectionCommonDef):
LineInfo=LineInfo)
#
# Found the process function from mapping table.
#
#
else:
ProcessFunc = gFUNCTION_MAPPING_FOR_DEFINE_SECTION[Name]
if (ProcessFunc is not None):
@@ -1000,9 +1000,9 @@ class InfDefObject(InfSectionCommonDef):
if not HasFoundInfVersionFalg:
ErrorInInf(ST.ERR_INF_PARSER_NOT_SUPPORT_EDKI_INF,
ErrorCode=ToolError.EDK1_INF_ERROR,
RaiseError=True)
RaiseError=True)
return True
def GetDefines(self):
return self.Defines
return self.Defines

View File

@@ -1,12 +1,12 @@
## @file
# This file is used to define class objects of INF file [Depex] section.
# It will consumed by InfParser.
# This file is used to define class objects of INF file [Depex] section.
# It will consumed by InfParser.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -99,7 +99,7 @@ class InfDepexObject(InfSectionCommonDef):
#
# Validate Arch
#
#
if IsValidArch(Arch.strip().upper()):
InfDepexItemIns.SetSupArch(Arch)
else:

View File

@@ -1,12 +1,12 @@
## @file
# This file is used to define class objects of INF file [Guids] section.
# It will consumed by InfParser.
# This file is used to define class objects of INF file [Guids] section.
# It will consumed by InfParser.
#
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -18,10 +18,10 @@ InfGuidObject
from Library.ParserValidate import IsValidCVariableName
from Library.CommentParsing import ParseComment
from Library.ExpressionValidate import IsValidFeatureFlagExp
from Library.ExpressionValidate import IsValidFeatureFlagExp
from Library.Misc import Sdict
from Library import DataType as DT
from Library import DataType as DT
import Logger.Log as Logger
from Logger import ToolError
from Logger import StringTable as ST
@@ -29,7 +29,7 @@ from Logger import StringTable as ST
class InfGuidItemCommentContent():
def __init__(self):
#
# ## SOMETIMES_CONSUMES ## Variable:L"MemoryTypeInformation"
# ## SOMETIMES_CONSUMES ## Variable:L"MemoryTypeInformation"
# TailString.
#
#
@@ -48,27 +48,27 @@ class InfGuidItemCommentContent():
# TailString
#
self.HelpStringItem = ''
def SetUsageItem(self, UsageItem):
self.UsageItem = UsageItem
def GetUsageItem(self):
return self.UsageItem
def SetGuidTypeItem(self, GuidTypeItem):
self.GuidTypeItem = GuidTypeItem
def GetGuidTypeItem(self):
return self.GuidTypeItem
def SetVariableNameItem(self, VariableNameItem):
self.VariableNameItem = VariableNameItem
def GetVariableNameItem(self):
return self.VariableNameItem
def SetHelpStringItem(self, HelpStringItem):
self.HelpStringItem = HelpStringItem
def GetHelpStringItem(self):
return self.HelpStringItem
class InfGuidItem():
def __init__(self):
self.Name = ''
@@ -78,22 +78,22 @@ class InfGuidItem():
#
self.CommentList = []
self.SupArchList = []
def SetName(self, Name):
self.Name = Name
def GetName(self):
return self.Name
def SetFeatureFlagExp(self, FeatureFlagExp):
self.FeatureFlagExp = FeatureFlagExp
def GetFeatureFlagExp(self):
return self.FeatureFlagExp
def SetCommentList(self, CommentList):
self.CommentList = CommentList
def GetCommentList(self):
return self.CommentList
def SetSupArchList(self, SupArchList):
self.SupArchList = SupArchList
def GetSupArchList(self):
@@ -120,17 +120,17 @@ def ParseGuidComment(CommentsList, InfGuidItemObj):
CommentItemGuidType, \
CommentItemVarString, \
CommentItemHelpText = \
ParseComment(CommentItem,
DT.ALL_USAGE_TOKENS,
DT.GUID_TYPE_TOKENS,
[],
ParseComment(CommentItem,
DT.ALL_USAGE_TOKENS,
DT.GUID_TYPE_TOKENS,
[],
True)
if CommentItemHelpText is None:
CommentItemHelpText = ''
if Count == len(CommentsList) and CommentItemUsage == CommentItemGuidType == DT.ITEM_UNDEFINED:
CommentItemHelpText = DT.END_OF_LINE
if Count == len(CommentsList):
if BlockFlag == 1 or BlockFlag == 2:
if CommentItemUsage == CommentItemGuidType == DT.ITEM_UNDEFINED:
@@ -138,7 +138,7 @@ def ParseGuidComment(CommentsList, InfGuidItemObj):
else:
BlockFlag = 3
if BlockFlag == -1:
BlockFlag = 4
BlockFlag = 4
if BlockFlag == -1 or BlockFlag == 1 or BlockFlag == 2:
if CommentItemUsage == CommentItemGuidType == DT.ITEM_UNDEFINED:
if BlockFlag == -1:
@@ -150,15 +150,15 @@ def ParseGuidComment(CommentsList, InfGuidItemObj):
BlockFlag = 3
elif BlockFlag == -1:
BlockFlag = 4
#
# Combine two comment line if they are generic comment
#
#
if CommentItemUsage == CommentItemGuidType == PreUsage == PreGuidType == DT.ITEM_UNDEFINED:
CommentItemHelpText = PreHelpText + DT.END_OF_LINE + CommentItemHelpText
PreHelpText = CommentItemHelpText
if BlockFlag == 4:
if BlockFlag == 4:
CommentItemIns = InfGuidItemCommentContent()
CommentItemIns.SetUsageItem(CommentItemUsage)
CommentItemIns.SetGuidTypeItem(CommentItemGuidType)
@@ -167,16 +167,16 @@ def ParseGuidComment(CommentsList, InfGuidItemObj):
CommentItemHelpText = CommentItemHelpText.strip(DT.END_OF_LINE)
CommentItemIns.SetHelpStringItem(CommentItemHelpText)
CommentInsList.append(CommentItemIns)
BlockFlag = -1
PreUsage = None
PreGuidType = None
PreHelpText = ''
elif BlockFlag == 3:
#
# Add previous help string
#
#
CommentItemIns = InfGuidItemCommentContent()
CommentItemIns.SetUsageItem(DT.ITEM_UNDEFINED)
CommentItemIns.SetGuidTypeItem(DT.ITEM_UNDEFINED)
@@ -195,17 +195,17 @@ def ParseGuidComment(CommentsList, InfGuidItemObj):
CommentItemHelpText = CommentItemHelpText.strip(DT.END_OF_LINE)
CommentItemIns.SetHelpStringItem(CommentItemHelpText)
CommentInsList.append(CommentItemIns)
BlockFlag = -1
PreUsage = None
PreGuidType = None
PreHelpText = ''
PreHelpText = ''
else:
PreUsage = CommentItemUsage
PreGuidType = CommentItemGuidType
PreHelpText = CommentItemHelpText
InfGuidItemObj.SetCommentList(CommentInsList)
else:
#
@@ -215,7 +215,7 @@ def ParseGuidComment(CommentsList, InfGuidItemObj):
CommentItemIns.SetUsageItem(DT.ITEM_UNDEFINED)
CommentItemIns.SetGuidTypeItem(DT.ITEM_UNDEFINED)
InfGuidItemObj.SetCommentList([CommentItemIns])
return InfGuidItemObj
## InfGuidObject
@@ -229,18 +229,18 @@ class InfGuidObject():
# Macro defined in this section should be only used in this section.
#
self.Macros = {}
def SetGuid(self, GuidList, Arch = None):
__SupportArchList = []
for ArchItem in Arch:
#
# Validate Arch
#
#
if (ArchItem == '' or ArchItem is None):
ArchItem = 'COMMON'
ArchItem = 'COMMON'
__SupportArchList.append(ArchItem)
for Item in GuidList:
#
# Get Comment content of this protocol
@@ -250,77 +250,77 @@ class InfGuidObject():
CommentsList = Item[1]
CurrentLineOfItem = Item[2]
Item = Item[0]
InfGuidItemObj = InfGuidItem()
InfGuidItemObj = InfGuidItem()
if len(Item) >= 1 and len(Item) <= 2:
#
# Only GuildName contained
#
if not IsValidCVariableName(Item[0]):
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_INVALID_CNAME%(Item[0]),
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
ExtraData=CurrentLineOfItem[0])
if (Item[0] != ''):
InfGuidItemObj.SetName(Item[0])
else:
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_CNAME_MISSING,
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
ExtraData=CurrentLineOfItem[0])
if len(Item) == 2:
#
# Contained CName and Feature Flag Express
# <statements> ::= <CName> ["|" <FeatureFlagExpress>]
# For GUID entry.
# For GUID entry.
#
if Item[1].strip() == '':
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
ExtraData=CurrentLineOfItem[0])
#
# Validate Feature Flag Express
# Validate Feature Flag Express
#
FeatureFlagRtv = IsValidFeatureFlagExp(Item[1].strip())
if not FeatureFlagRtv[0]:
Logger.Error("InfParser",
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[1]),
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
ExtraData=CurrentLineOfItem[0])
InfGuidItemObj.SetFeatureFlagExp(Item[1])
if len(Item) != 1 and len(Item) != 2:
#
# Invalid format of GUID statement
# Invalid format of GUID statement
#
Logger.Error("InfParser",
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_GUID_PPI_PROTOCOL_SECTION_CONTENT_ERROR,
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
ExtraData=CurrentLineOfItem[0])
InfGuidItemObj = ParseGuidComment(CommentsList, InfGuidItemObj)
InfGuidItemObj.SetSupArchList(__SupportArchList)
#
# Determine GUID name duplicate. Follow below rule:
#
# A GUID must not be duplicated within a [Guids] section.
# A GUID may appear in multiple architectural [Guids]
# sections. A GUID listed in an architectural [Guids]
# section must not be listed in the common architectural
# A GUID must not be duplicated within a [Guids] section.
# A GUID may appear in multiple architectural [Guids]
# sections. A GUID listed in an architectural [Guids]
# section must not be listed in the common architectural
# [Guids] section.
#
#
# NOTE: This check will not report error now.
#
#
for Item in self.Guids:
if Item.GetName() == InfGuidItemObj.GetName():
ItemSupArchList = Item.GetSupArchList()
@@ -337,17 +337,17 @@ class InfGuidObject():
# ST.ERR_INF_PARSER_ITEM_DUPLICATE_COMMON
#
pass
if (InfGuidItemObj) in self.Guids:
GuidList = self.Guids[InfGuidItemObj]
GuidList = self.Guids[InfGuidItemObj]
GuidList.append(InfGuidItemObj)
self.Guids[InfGuidItemObj] = GuidList
else:
GuidList = []
GuidList.append(InfGuidItemObj)
self.Guids[InfGuidItemObj] = GuidList
return True
def GetGuid(self):
return self.Guids

View File

@@ -1,12 +1,12 @@
## @file
# This file is used to define class objects of INF file header.
# It will consumed by InfParser.
# This file is used to define class objects of INF file header.
# It will consumed by InfParser.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -17,16 +17,16 @@ InfHeaderObject
'''
## INF file header object
#
#
# A sample file header
#
# ## @file xxx.inf FileName
# # Abstract
# #
# #
# # Description
# #
# # Copyright
# #
# #
# # License
# #
#
@@ -41,7 +41,7 @@ class InfHeaderObject():
## SetFileName
#
# @param FileName: File Name
#
#
def SetFileName(self, FileName):
if not (FileName == '' or FileName is None):
self.FileName = FileName
@@ -50,14 +50,14 @@ class InfHeaderObject():
return False
## GetFileName
#
#
def GetFileName(self):
return self.FileName
## SetAbstract
#
#
# @param Abstract: Abstract
#
#
def SetAbstract(self, Abstract):
if not (Abstract == '' or Abstract is None):
self.Abstract = Abstract
@@ -66,14 +66,14 @@ class InfHeaderObject():
return False
## GetAbstract
#
#
def GetAbstract(self):
return self.Abstract
return self.Abstract
## SetDescription
#
# @param Description: Description content
#
#
# @param Description: Description content
#
def SetDescription(self, Description):
if not (Description == '' or Description is None):
self.Description = Description
@@ -82,14 +82,14 @@ class InfHeaderObject():
return False
## GetAbstract
#
#
def GetDescription(self):
return self.Description
return self.Description
## SetCopyright
#
# @param Copyright: Copyright content
#
#
# @param Copyright: Copyright content
#
def SetCopyright(self, Copyright):
if not (Copyright == '' or Copyright is None):
self.Copyright = Copyright
@@ -98,14 +98,14 @@ class InfHeaderObject():
return False
## GetCopyright
#
#
def GetCopyright(self):
return self.Copyright
return self.Copyright
## SetCopyright
#
# @param License: License content
#
#
# @param License: License content
#
def SetLicense(self, License):
if not (License == '' or License is None):
self.License = License
@@ -114,6 +114,6 @@ class InfHeaderObject():
return False
## GetLicense
#
#
def GetLicense(self):
return self.License
return self.License

View File

@@ -1,12 +1,12 @@
## @file
# This file is used to define class objects of INF file [LibraryClasses] section.
# It will consumed by InfParser.
# This file is used to define class objects of INF file [LibraryClasses] section.
# It will consumed by InfParser.
#
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -37,7 +37,7 @@ def GetArchModuleType(KeyList):
for (ArchItem, ModuleItem) in KeyList:
#
# Validate Arch
#
#
if (ArchItem == '' or ArchItem is None):
ArchItem = 'COMMON'
@@ -118,7 +118,7 @@ class InfLibraryClassObject():
##SetLibraryClasses
#
#
#
# @param HelpString: It can be a common comment or contain a recommend
# instance.
#
@@ -173,7 +173,7 @@ class InfLibraryClassObject():
Line=LibItemObj.CurrentLine.GetLineNo(),
ExtraData=LibItemObj.CurrentLine.GetLineString())
#
# Validate FFE
# Validate FFE
#
FeatureFlagRtv = IsValidFeatureFlagExp(LibItem[1].strip())
if not FeatureFlagRtv[0]:
@@ -202,15 +202,15 @@ class InfLibraryClassObject():
#
# Determine Library class duplicate. Follow below rule:
#
# A library class keyword must not be duplicated within a
# [LibraryClasses] section. Library class keywords may appear in
# multiple architectural and module type [LibraryClasses] sections.
# A library class keyword listed in an architectural or module type
# [LibraryClasses] section must not be listed in the common
# A library class keyword must not be duplicated within a
# [LibraryClasses] section. Library class keywords may appear in
# multiple architectural and module type [LibraryClasses] sections.
# A library class keyword listed in an architectural or module type
# [LibraryClasses] section must not be listed in the common
# architectural or module type [LibraryClasses] section.
#
#
# NOTE: This check will not report error now. But keep code for future enhancement.
#
#
# for Item in self.LibraryClasses:
# if Item.GetLibName() == LibItemObj.GetLibName():
# ItemSupArchList = Item.GetSupArchList()

View File

@@ -1,12 +1,12 @@
## @file
# This file is used to define class objects of INF file miscellaneous.
# Include BootMode/HOB/Event and others. It will consumed by InfParser.
# This file is used to define class objects of INF file miscellaneous.
# Include BootMode/HOB/Event and others. It will consumed by InfParser.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -23,7 +23,7 @@ from Library import DataType as DT
from Object.Parser.InfCommonObject import InfSectionCommonDef
from Library.Misc import Sdict
##
##
# BootModeObject
#
class InfBootModeObject():
@@ -31,16 +31,16 @@ class InfBootModeObject():
self.SupportedBootModes = ''
self.HelpString = ''
self.Usage = ''
def SetSupportedBootModes(self, SupportedBootModes):
self.SupportedBootModes = SupportedBootModes
self.SupportedBootModes = SupportedBootModes
def GetSupportedBootModes(self):
return self.SupportedBootModes
def SetHelpString(self, HelpString):
self.HelpString = HelpString
def GetHelpString(self):
return self.HelpString
return self.HelpString
def SetUsage(self, Usage):
self.Usage = Usage
@@ -54,18 +54,18 @@ class InfEventObject():
self.EventType = ''
self.HelpString = ''
self.Usage = ''
def SetEventType(self, EventType):
self.EventType = EventType
def GetEventType(self):
return self.EventType
def SetHelpString(self, HelpString):
self.HelpString = HelpString
def GetHelpString(self):
return self.HelpString
return self.HelpString
def SetUsage(self, Usage):
self.Usage = Usage
def GetUsage(self):
@@ -79,36 +79,36 @@ class InfHobObject():
self.Usage = ''
self.SupArchList = []
self.HelpString = ''
def SetHobType(self, HobType):
self.HobType = HobType
def GetHobType(self):
return self.HobType
def SetUsage(self, Usage):
self.Usage = Usage
def GetUsage(self):
return self.Usage
def SetSupArchList(self, ArchList):
self.SupArchList = ArchList
def GetSupArchList(self):
return self.SupArchList
def SetHelpString(self, HelpString):
self.HelpString = HelpString
def GetHelpString(self):
return self.HelpString
##
# InfSpecialCommentObject
#
#
class InfSpecialCommentObject(InfSectionCommonDef):
def __init__(self):
self.SpecialComments = Sdict()
InfSectionCommonDef.__init__(self)
def SetSpecialComments(self, SepcialSectionList = None, Type = ''):
if Type == DT.TYPE_HOB_SECTION or \
Type == DT.TYPE_EVENT_SECTION or \
@@ -122,27 +122,27 @@ class InfSpecialCommentObject(InfSectionCommonDef):
ObjList = []
ObjList.append(Item)
self.SpecialComments[Type] = ObjList
return True
def GetSpecialComments(self):
return self.SpecialComments
## ErrorInInf
#
#
# An encapsulate of Error for INF parser.
#
#
def ErrorInInf(Message=None, ErrorCode=None, LineInfo=None, RaiseError=True):
if ErrorCode is None:
ErrorCode = ToolError.FORMAT_INVALID
if LineInfo is None:
LineInfo = ['', -1, '']
Logger.Error("InfParser",
ErrorCode,
Message=Message,
File=LineInfo[0],
Logger.Error("InfParser",
ErrorCode,
Message=Message,
File=LineInfo[0],
Line=LineInfo[1],
ExtraData=LineInfo[2],
ExtraData=LineInfo[2],
RaiseError=RaiseError)

View File

@@ -1,12 +1,12 @@
## @file
# This file is used to define class objects of INF file [Packages] section.
# It will consumed by InfParser.
# This file is used to define class objects of INF file [Packages] section.
# It will consumed by InfParser.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -19,14 +19,14 @@ InfPackageObject
from Logger import StringTable as ST
from Logger import ToolError
import Logger.Log as Logger
from Library import GlobalData
from Library import GlobalData
from Library.Misc import Sdict
from Library.ParserValidate import IsValidPath
from Library.ExpressionValidate import IsValidFeatureFlagExp
from Library.ExpressionValidate import IsValidFeatureFlagExp
class InfPackageItem():
def __init__(self,
def __init__(self,
PackageName = '',
FeatureFlagExp = '',
HelpString = ''):
@@ -34,28 +34,28 @@ class InfPackageItem():
self.FeatureFlagExp = FeatureFlagExp
self.HelpString = HelpString
self.SupArchList = []
def SetPackageName(self, PackageName):
self.PackageName = PackageName
def GetPackageName(self):
return self.PackageName
def SetFeatureFlagExp(self, FeatureFlagExp):
self.FeatureFlagExp = FeatureFlagExp
def GetFeatureFlagExp(self):
return self.FeatureFlagExp
def SetHelpString(self, HelpString):
self.HelpString = HelpString
def GetHelpString(self):
return self.HelpString
def SetSupArchList(self, SupArchList):
self.SupArchList = SupArchList
def GetSupArchList(self):
return self.SupArchList
## INF package section
#
#
@@ -67,18 +67,18 @@ class InfPackageObject():
# Macro defined in this section should be only used in this section.
#
self.Macros = {}
def SetPackages(self, PackageData, Arch = None):
IsValidFileFlag = False
SupArchList = []
for ArchItem in Arch:
#
# Validate Arch
#
#
if (ArchItem == '' or ArchItem is None):
ArchItem = 'COMMON'
SupArchList.append(ArchItem)
SupArchList.append(ArchItem)
for PackageItem in PackageData:
PackageItemObj = InfPackageItem()
HelpStringObj = PackageItem[1]
@@ -86,7 +86,7 @@ class InfPackageObject():
PackageItem = PackageItem[0]
if HelpStringObj is not None:
HelpString = HelpStringObj.HeaderComments + HelpStringObj.TailComments
PackageItemObj.SetHelpString(HelpString)
PackageItemObj.SetHelpString(HelpString)
if len(PackageItem) >= 1:
#
# Validate file exist/format.
@@ -94,67 +94,67 @@ class InfPackageObject():
if IsValidPath(PackageItem[0], ''):
IsValidFileFlag = True
elif IsValidPath(PackageItem[0], GlobalData.gINF_MODULE_DIR):
IsValidFileFlag = True
IsValidFileFlag = True
elif IsValidPath(PackageItem[0], GlobalData.gWORKSPACE):
IsValidFileFlag = True
else:
Logger.Error("InfParser",
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(PackageItem[0]),
File=CurrentLineOfPackItem[2],
Line=CurrentLineOfPackItem[1],
File=CurrentLineOfPackItem[2],
Line=CurrentLineOfPackItem[1],
ExtraData=CurrentLineOfPackItem[0])
return False
if IsValidFileFlag:
if IsValidFileFlag:
PackageItemObj.SetPackageName(PackageItem[0])
if len(PackageItem) == 2:
#
# Validate Feature Flag Express
#
if PackageItem[1].strip() == '':
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
File=CurrentLineOfPackItem[2],
Line=CurrentLineOfPackItem[1],
File=CurrentLineOfPackItem[2],
Line=CurrentLineOfPackItem[1],
ExtraData=CurrentLineOfPackItem[0])
#
# Validate FFE
# Validate FFE
#
FeatureFlagRtv = IsValidFeatureFlagExp(PackageItem[1].strip())
if not FeatureFlagRtv[0]:
Logger.Error("InfParser",
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[1]),
File=CurrentLineOfPackItem[2],
Line=CurrentLineOfPackItem[1],
File=CurrentLineOfPackItem[2],
Line=CurrentLineOfPackItem[1],
ExtraData=CurrentLineOfPackItem[0])
PackageItemObj.SetFeatureFlagExp(PackageItem[1].strip())
if len(PackageItem) > 2:
#
# Invalid format of Package statement
# Invalid format of Package statement
#
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_PACKAGE_SECTION_CONTENT_ERROR,
File=CurrentLineOfPackItem[2],
Line=CurrentLineOfPackItem[1],
File=CurrentLineOfPackItem[2],
Line=CurrentLineOfPackItem[1],
ExtraData=CurrentLineOfPackItem[0])
PackageItemObj.SetSupArchList(SupArchList)
#
# Determine package file name duplicate. Follow below rule:
#
# A package filename must not be duplicated within a [Packages]
# section. Package filenames may appear in multiple architectural
# [Packages] sections. A package filename listed in an
# A package filename must not be duplicated within a [Packages]
# section. Package filenames may appear in multiple architectural
# [Packages] sections. A package filename listed in an
# architectural [Packages] section must not be listed in the common
# architectural [Packages] section.
#
#
# NOTE: This check will not report error now.
#
#
for Item in self.Packages:
if Item.GetPackageName() == PackageItemObj.GetPackageName():
ItemSupArchList = Item.GetSupArchList()
@@ -170,7 +170,7 @@ class InfPackageObject():
# ST.ERR_INF_PARSER_ITEM_DUPLICATE_COMMON
#
pass
if (PackageItemObj) in self.Packages:
PackageList = self.Packages[PackageItemObj]
PackageList.append(PackageItemObj)
@@ -179,9 +179,9 @@ class InfPackageObject():
PackageList = []
PackageList.append(PackageItemObj)
self.Packages[PackageItemObj] = PackageList
return True
def GetPackages(self, Arch = None):
if Arch is None:
return self.Packages

View File

@@ -1,12 +1,12 @@
## @file
# This file is used to define class objects of INF file [Pcds] section.
# It will consumed by InfParser.
# This file is used to define class objects of INF file [Pcds] section.
# It will consumed by InfParser.
#
# Copyright (c) 2011 - 2018, 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,
@@ -42,7 +42,7 @@ from Object.Parser.InfPackagesObject import InfPackageItem
def ValidateArch(ArchItem, PcdTypeItem1, LineNo, SupArchDict, SupArchList):
#
# Validate Arch
#
#
if (ArchItem == '' or ArchItem is None):
ArchItem = 'COMMON'
@@ -122,7 +122,7 @@ def ParsePcdComment(CommentList, PcdTypeItem, PcdItemObj):
BlockFlag = 4
#
# Combine two comment line if they are generic comment
#
#
if CommentItemUsage == PreUsage == DT.ITEM_UNDEFINED:
CommentItemHelpText = PreHelpText + DT.END_OF_LINE + CommentItemHelpText
@@ -141,7 +141,7 @@ def ParsePcdComment(CommentList, PcdTypeItem, PcdItemObj):
elif BlockFlag == 3:
#
# Add previous help string
#
#
CommentItemIns = InfPcdItemCommentContent()
CommentItemIns.SetUsageItem(DT.ITEM_UNDEFINED)
if PreHelpText == '' or PreHelpText.endswith(DT.END_OF_LINE):
@@ -171,7 +171,7 @@ def ParsePcdComment(CommentList, PcdTypeItem, PcdItemObj):
class InfPcdItemCommentContent():
def __init__(self):
#
# ## SOMETIMES_CONSUMES ## HelpString
# ## SOMETIMES_CONSUMES ## HelpString
#
self.UsageItem = ''
#
@@ -195,7 +195,7 @@ class InfPcdItemCommentContent():
#
# @param CName: Input value for CName, default is ''
# @param Token: Input value for Token, default is ''
# @param TokenSpaceGuidCName: Input value for TokenSpaceGuidCName, default
# @param TokenSpaceGuidCName: Input value for TokenSpaceGuidCName, default
# is ''
# @param DatumType: Input value for DatumType, default is ''
# @param MaxDatumSize: Input value for MaxDatumSize, default is ''
@@ -385,7 +385,7 @@ class InfPcdObject():
Line=CurrentLineOfPcdItem[1],
ExtraData=CurrentLineOfPcdItem[0])
#
# Validate FFE
# Validate FFE
#
FeatureFlagRtv = IsValidFeatureFlagExp(PcdItem[2].strip())
if not FeatureFlagRtv[0]:
@@ -478,7 +478,7 @@ def ParserPcdInfoInDec(String):
def SetValueDatumTypeMaxSizeToken(PcdItem, CurrentLineOfPcdItem, PcdItemObj, Arch, PackageInfo=None):
#
# Package information not been generated currently, we need to parser INF file to get information.
# Package information not been generated currently, we need to parser INF file to get information.
#
if not PackageInfo:
PackageInfo = []
@@ -507,7 +507,7 @@ def SetValueDatumTypeMaxSizeToken(PcdItem, CurrentLineOfPcdItem, PcdItemObj, Arc
DecParser = GlobalData.gPackageDict[FullFileName]
#
# Find PCD information.
# Find PCD information.
#
DecPcdsDict = DecParser.GetPcdSectionObject().ValueDict
for Key in DecPcdsDict.keys():
@@ -640,7 +640,7 @@ def ValidatePcdValueOnDatumType(Value, Type):
def SetPcdName(PcdItem, CurrentLineOfPcdItem, PcdItemObj):
#
# Only PCD Name specified
# Only PCD Name specified
# <PcdName> ::= <TokenSpaceGuidCName> "." <TokenCName>
#
PcdId = GetSplitValueList(PcdItem[0], DT.TAB_SPLIT)

View File

@@ -1,12 +1,12 @@
## @file
# This file is used to define class objects of INF file [Ppis] section.
# It will consumed by InfParser.
# This file is used to define class objects of INF file [Ppis] section.
# It will consumed by InfParser.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -18,17 +18,17 @@ InfPpiObject
from Library.ParserValidate import IsValidCVariableName
from Library.CommentParsing import ParseComment
from Library.ExpressionValidate import IsValidFeatureFlagExp
from Library.ExpressionValidate import IsValidFeatureFlagExp
from Library.Misc import Sdict
from Library import DataType as DT
from Library import DataType as DT
import Logger.Log as Logger
from Logger import ToolError
from Logger import StringTable as ST
def ParsePpiComment(CommentsList, InfPpiItemObj):
PreNotify = None
PreUsage = None
PreUsage = None
PreHelpText = ''
BlockFlag = -1
CommentInsList = []
@@ -39,22 +39,22 @@ def ParsePpiComment(CommentsList, InfPpiItemObj):
CommentItemNotify, \
CommentItemString, \
CommentItemHelpText = \
ParseComment(CommentItem,
DT.ALL_USAGE_TOKENS,
DT.PPI_NOTIFY_TOKENS,
['PPI'],
ParseComment(CommentItem,
DT.ALL_USAGE_TOKENS,
DT.PPI_NOTIFY_TOKENS,
['PPI'],
False)
#
# To avoid PyLint error
# To avoid PyLint error
#
if CommentItemString:
pass
if CommentItemHelpText is None:
CommentItemHelpText = ''
if Count == len(CommentsList) and CommentItemUsage == CommentItemNotify == DT.ITEM_UNDEFINED:
CommentItemHelpText = DT.END_OF_LINE
CommentItemHelpText = DT.END_OF_LINE
#
# For the Last comment Item, set BlockFlag.
#
@@ -65,12 +65,12 @@ def ParsePpiComment(CommentsList, InfPpiItemObj):
else:
BlockFlag = 3
elif BlockFlag == -1:
BlockFlag = 4
BlockFlag = 4
#
# Comment USAGE and NOTIFY information are "UNDEFINED"
#
if BlockFlag == -1 or BlockFlag == 1 or BlockFlag == 2:
if BlockFlag == -1 or BlockFlag == 1 or BlockFlag == 2:
if CommentItemUsage == CommentItemNotify == DT.ITEM_UNDEFINED:
if BlockFlag == -1:
BlockFlag = 1
@@ -81,41 +81,41 @@ def ParsePpiComment(CommentsList, InfPpiItemObj):
BlockFlag = 3
#
# An item have Usage or Notify information and the first time get this information
#
#
elif BlockFlag == -1:
BlockFlag = 4
#
# Combine two comment line if they are generic comment
#
#
if CommentItemUsage == CommentItemNotify == PreUsage == PreNotify == DT.ITEM_UNDEFINED:
CommentItemHelpText = PreHelpText + DT.END_OF_LINE + CommentItemHelpText
#
# Store this information for next line may still need combine operation.
#
PreHelpText = CommentItemHelpText
if BlockFlag == 4:
if BlockFlag == 4:
CommentItemIns = InfPpiItemCommentContent()
CommentItemIns.SetUsage(CommentItemUsage)
CommentItemIns.SetNotify(CommentItemNotify)
CommentItemIns.SetHelpStringItem(CommentItemHelpText)
CommentInsList.append(CommentItemIns)
BlockFlag = -1
PreUsage = None
PreNotify = None
PreHelpText = ''
elif BlockFlag == 3:
#
# Add previous help string
#
#
CommentItemIns = InfPpiItemCommentContent()
CommentItemIns.SetUsage(DT.ITEM_UNDEFINED)
CommentItemIns.SetNotify(DT.ITEM_UNDEFINED)
if PreHelpText == '' or PreHelpText.endswith(DT.END_OF_LINE):
PreHelpText += DT.END_OF_LINE
PreHelpText += DT.END_OF_LINE
CommentItemIns.SetHelpStringItem(PreHelpText)
CommentInsList.append(CommentItemIns)
#
@@ -126,7 +126,7 @@ def ParsePpiComment(CommentsList, InfPpiItemObj):
CommentItemIns.SetNotify(CommentItemNotify)
CommentItemIns.SetHelpStringItem(CommentItemHelpText)
CommentInsList.append(CommentItemIns)
BlockFlag = -1
PreUsage = None
PreNotify = None
@@ -135,15 +135,15 @@ def ParsePpiComment(CommentsList, InfPpiItemObj):
PreUsage = CommentItemUsage
PreNotify = CommentItemNotify
PreHelpText = CommentItemHelpText
InfPpiItemObj.SetCommentList(CommentInsList)
return InfPpiItemObj
class InfPpiItemCommentContent():
def __init__(self):
#
# ## SOMETIMES_CONSUMES ## HelpString
# ## SOMETIMES_CONSUMES ## HelpString
#
self.UsageItem = ''
#
@@ -152,30 +152,30 @@ class InfPpiItemCommentContent():
self.HelpStringItem = ''
self.Notify = ''
self.CommentList = []
def SetUsage(self, UsageItem):
self.UsageItem = UsageItem
def GetUsage(self):
return self.UsageItem
def SetNotify(self, Notify):
if Notify != DT.ITEM_UNDEFINED:
self.Notify = 'true'
def GetNotify(self):
return self.Notify
def SetHelpStringItem(self, HelpStringItem):
self.HelpStringItem = HelpStringItem
def GetHelpStringItem(self):
return self.HelpStringItem
class InfPpiItem():
def __init__(self):
self.Name = ''
self.FeatureFlagExp = ''
self.FeatureFlagExp = ''
self.SupArchList = []
self.CommentList = []
def SetName(self, Name):
self.Name = Name
def GetName(self):
@@ -184,7 +184,7 @@ class InfPpiItem():
def SetSupArchList(self, SupArchList):
self.SupArchList = SupArchList
def GetSupArchList(self):
return self.SupArchList
return self.SupArchList
def SetCommentList(self, CommentList):
self.CommentList = CommentList
@@ -206,17 +206,17 @@ class InfPpiObject():
# Macro defined in this section should be only used in this section.
#
self.Macros = {}
def SetPpi(self, PpiList, Arch = None):
__SupArchList = []
for ArchItem in Arch:
#
# Validate Arch
#
#
if (ArchItem == '' or ArchItem is None):
ArchItem = 'COMMON'
ArchItem = 'COMMON'
__SupArchList.append(ArchItem)
for Item in PpiList:
#
# Get Comment content of this protocol
@@ -226,26 +226,26 @@ class InfPpiObject():
CommentsList = Item[1]
CurrentLineOfItem = Item[2]
Item = Item[0]
InfPpiItemObj = InfPpiItem()
InfPpiItemObj = InfPpiItem()
if len(Item) >= 1 and len(Item) <= 2:
#
# Only CName contained
#
if not IsValidCVariableName(Item[0]):
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_INVALID_CNAME%(Item[0]),
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
ExtraData=CurrentLineOfItem[0])
if (Item[0] != ''):
InfPpiItemObj.SetName(Item[0])
else:
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_CNAME_MISSING,
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
ExtraData=CurrentLineOfItem[0])
#
# Have FeatureFlag information
@@ -254,14 +254,14 @@ class InfPpiObject():
#
# Contained CName and Feature Flag Express
# <statements> ::= <CName> ["|" <FeatureFlagExpress>]
# Item[1] should not be empty
# Item[1] should not be empty
#
if Item[1].strip() == '':
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
ExtraData=CurrentLineOfItem[0])
#
# Validate Feature Flag Express for PPI entry
@@ -269,24 +269,24 @@ class InfPpiObject():
#
FeatureFlagRtv = IsValidFeatureFlagExp(Item[1].strip())
if not FeatureFlagRtv[0]:
Logger.Error("InfParser",
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[1]),
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
ExtraData=CurrentLineOfItem[0])
InfPpiItemObj.SetFeatureFlagExp(Item[1])
if len(Item) != 1 and len(Item) != 2:
#
# Invalid format of Ppi statement
# Invalid format of Ppi statement
#
Logger.Error("InfParser",
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_GUID_PPI_PROTOCOL_SECTION_CONTENT_ERROR,
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
ExtraData=CurrentLineOfItem[0])
#
# Get/Set Usage and HelpString for PPI entry
#
@@ -297,20 +297,20 @@ class InfPpiObject():
CommentItemIns.SetUsage(DT.ITEM_UNDEFINED)
CommentItemIns.SetNotify(DT.ITEM_UNDEFINED)
InfPpiItemObj.SetCommentList([CommentItemIns])
InfPpiItemObj.SetSupArchList(__SupArchList)
#
# Determine PPI name duplicate. Follow below rule:
#
# A PPI must not be duplicated within a [Ppis] section.
# A PPI may appear in multiple architectural [Ppis]
# sections. A PPI listed in an architectural [Ppis]
# section must not be listed in the common architectural
# A PPI must not be duplicated within a [Ppis] section.
# A PPI may appear in multiple architectural [Ppis]
# sections. A PPI listed in an architectural [Ppis]
# section must not be listed in the common architectural
# [Ppis] section.
#
#
# NOTE: This check will not report error now.
#
#
for Item in self.Ppis:
if Item.GetName() == InfPpiItemObj.GetName():
ItemSupArchList = Item.GetSupArchList()
@@ -324,9 +324,9 @@ class InfPpiObject():
if ItemArch.upper() == 'COMMON' or PpiItemObjArch.upper() == 'COMMON':
#
# ST.ERR_INF_PARSER_ITEM_DUPLICATE_COMMON
#
#
pass
if (InfPpiItemObj) in self.Ppis:
PpiList = self.Ppis[InfPpiItemObj]
PpiList.append(InfPpiItemObj)
@@ -335,9 +335,9 @@ class InfPpiObject():
PpiList = []
PpiList.append(InfPpiItemObj)
self.Ppis[InfPpiItemObj] = PpiList
return True
return True
def GetPpi(self):
return self.Ppis

View File

@@ -1,12 +1,12 @@
## @file
# This file is used to define class objects of INF file [Protocols] section.
# It will consumed by InfParser.
# This file is used to define class objects of INF file [Protocols] section.
# It will consumed by InfParser.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -18,8 +18,8 @@ InfProtocolObject
from Library.ParserValidate import IsValidCVariableName
from Library.CommentParsing import ParseComment
from Library.ExpressionValidate import IsValidFeatureFlagExp
from Library.ExpressionValidate import IsValidFeatureFlagExp
from Library.Misc import Sdict
from Object.Parser.InfMisc import ErrorInInf
@@ -40,20 +40,20 @@ def ParseProtocolComment(CommentsList, InfProtocolItemObj):
CommentItemNotify, \
CommentItemString, \
CommentItemHelpText = \
ParseComment(CommentItem,
DT.PROTOCOL_USAGE_TOKENS,
DT.PROTOCOL_NOTIFY_TOKENS,
['PROTOCOL'],
ParseComment(CommentItem,
DT.PROTOCOL_USAGE_TOKENS,
DT.PROTOCOL_NOTIFY_TOKENS,
['PROTOCOL'],
False)
if CommentItemString:
pass
if CommentItemHelpText is None:
CommentItemHelpText = ''
if Count == len(CommentsList) and CommentItemUsage == CommentItemNotify == DT.ITEM_UNDEFINED:
CommentItemHelpText = DT.END_OF_LINE
if Count == len(CommentsList):
if BlockFlag == 1 or BlockFlag == 2:
if CommentItemUsage == CommentItemNotify == DT.ITEM_UNDEFINED:
@@ -61,9 +61,9 @@ def ParseProtocolComment(CommentsList, InfProtocolItemObj):
else:
BlockFlag = 3
elif BlockFlag == -1:
BlockFlag = 4
if BlockFlag == -1 or BlockFlag == 1 or BlockFlag == 2:
BlockFlag = 4
if BlockFlag == -1 or BlockFlag == 1 or BlockFlag == 2:
if CommentItemUsage == CommentItemNotify == DT.ITEM_UNDEFINED:
if BlockFlag == -1:
BlockFlag = 1
@@ -74,36 +74,36 @@ def ParseProtocolComment(CommentsList, InfProtocolItemObj):
BlockFlag = 3
elif BlockFlag == -1:
BlockFlag = 4
#
# Combine two comment line if they are generic comment
#
#
if CommentItemUsage == CommentItemNotify == PreUsage == PreNotify == DT.ITEM_UNDEFINED:
CommentItemHelpText = PreHelpText + DT.END_OF_LINE + CommentItemHelpText
PreHelpText = CommentItemHelpText
if BlockFlag == 4:
if BlockFlag == 4:
CommentItemIns = InfProtocolItemCommentContent()
CommentItemIns.SetUsageItem(CommentItemUsage)
CommentItemIns.SetNotify(CommentItemNotify)
CommentItemIns.SetHelpStringItem(CommentItemHelpText)
CommentInsList.append(CommentItemIns)
BlockFlag = -1
PreUsage = None
PreNotify = None
PreHelpText = ''
elif BlockFlag == 3:
#
# Add previous help string
#
#
CommentItemIns = InfProtocolItemCommentContent()
CommentItemIns.SetUsageItem(DT.ITEM_UNDEFINED)
CommentItemIns.SetNotify(DT.ITEM_UNDEFINED)
if PreHelpText == '' or PreHelpText.endswith(DT.END_OF_LINE):
PreHelpText += DT.END_OF_LINE
PreHelpText += DT.END_OF_LINE
CommentItemIns.SetHelpStringItem(PreHelpText)
CommentInsList.append(CommentItemIns)
#
@@ -114,25 +114,25 @@ def ParseProtocolComment(CommentsList, InfProtocolItemObj):
CommentItemIns.SetNotify(CommentItemNotify)
CommentItemIns.SetHelpStringItem(CommentItemHelpText)
CommentInsList.append(CommentItemIns)
BlockFlag = -1
PreUsage = None
PreNotify = None
PreHelpText = ''
PreHelpText = ''
else:
PreUsage = CommentItemUsage
PreNotify = CommentItemNotify
PreHelpText = CommentItemHelpText
InfProtocolItemObj.SetCommentList(CommentInsList)
return InfProtocolItemObj
class InfProtocolItemCommentContent():
def __init__(self):
#
# ## SOMETIMES_CONSUMES ## HelpString
# ## SOMETIMES_CONSUMES ## HelpString
#
self.UsageItem = ''
#
@@ -141,44 +141,44 @@ class InfProtocolItemCommentContent():
self.HelpStringItem = ''
self.Notify = ''
self.CommentList = []
def SetUsageItem(self, UsageItem):
self.UsageItem = UsageItem
def GetUsageItem(self):
return self.UsageItem
def SetNotify(self, Notify):
if Notify != DT.ITEM_UNDEFINED:
self.Notify = 'true'
def GetNotify(self):
return self.Notify
def SetHelpStringItem(self, HelpStringItem):
self.HelpStringItem = HelpStringItem
def GetHelpStringItem(self):
return self.HelpStringItem
class InfProtocolItem():
def __init__(self):
self.Name = ''
self.FeatureFlagExp = ''
self.SupArchList = []
self.CommentList = []
def SetName(self, Name):
self.Name = Name
def GetName(self):
return self.Name
def SetFeatureFlagExp(self, FeatureFlagExp):
self.FeatureFlagExp = FeatureFlagExp
def GetFeatureFlagExp(self):
return self.FeatureFlagExp
def SetSupArchList(self, SupArchList):
self.SupArchList = SupArchList
def GetSupArchList(self):
return self.SupArchList
return self.SupArchList
def SetCommentList(self, CommentList):
self.CommentList = CommentList
@@ -196,13 +196,13 @@ class InfProtocolObject():
# Macro defined in this section should be only used in this section.
#
self.Macros = {}
def SetProtocol(self, ProtocolContent, Arch = None,):
__SupArchList = []
for ArchItem in Arch:
#
# Validate Arch
#
#
if (ArchItem == '' or ArchItem is None):
ArchItem = 'COMMON'
__SupArchList.append(ArchItem)
@@ -233,7 +233,7 @@ class InfProtocolObject():
if len(Item) == 2:
#
# Contained CName and Feature Flag Express
# <statements> ::= <CName> ["|"
# <statements> ::= <CName> ["|"
# <FeatureFlagExpress>]
# For Protocol Object
#
@@ -248,14 +248,14 @@ class InfProtocolObject():
ErrorInInf(ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[1]),
LineInfo=LineInfo)
InfProtocolItemObj.SetFeatureFlagExp(Item[1])
if len(Item) < 1 or len(Item) > 2:
#
# Invalid format of Protocols statement
# Invalid format of Protocols statement
#
ErrorInInf(ST.ERR_INF_PARSER_GUID_PPI_PROTOCOL_SECTION_CONTENT_ERROR,
LineInfo=LineInfo)
#
# Get/Set Usage and HelpString for Protocol entry
#
@@ -266,20 +266,20 @@ class InfProtocolObject():
CommentItemIns.SetUsageItem(DT.ITEM_UNDEFINED)
CommentItemIns.SetNotify(DT.ITEM_UNDEFINED)
InfProtocolItemObj.SetCommentList([CommentItemIns])
InfProtocolItemObj.SetSupArchList(__SupArchList)
#
# Determine protocol name duplicate. Follow below rule:
#
# A protocol must not be duplicated within a [Protocols] section.
# A protocol may appear in multiple architectural [Protocols]
# sections. A protocol listed in an architectural [Protocols]
# section must not be listed in the common architectural
# A protocol must not be duplicated within a [Protocols] section.
# A protocol may appear in multiple architectural [Protocols]
# sections. A protocol listed in an architectural [Protocols]
# section must not be listed in the common architectural
# [Protocols] section.
#
#
# NOTE: This check will not report error now.
#
#
for Item in self.Protocols:
if Item.GetName() == InfProtocolItemObj.GetName():
ItemSupArchList = Item.GetSupArchList()
@@ -294,8 +294,8 @@ class InfProtocolObject():
#
# ST.ERR_INF_PARSER_ITEM_DUPLICATE_COMMON
#
pass
pass
if (InfProtocolItemObj) in self.Protocols:
ProcotolList = self.Protocols[InfProtocolItemObj]
ProcotolList.append(InfProtocolItemObj)
@@ -304,8 +304,8 @@ class InfProtocolObject():
ProcotolList = []
ProcotolList.append(InfProtocolItemObj)
self.Protocols[InfProtocolItemObj] = ProcotolList
return True
def GetProtocol(self):
return self.Protocols

View File

@@ -1,12 +1,12 @@
## @file
# This file is used to define class objects of INF file [Sources] section.
# It will consumed by InfParser.
# This file is used to define class objects of INF file [Sources] section.
# It will consumed by InfParser.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -21,22 +21,22 @@ import os
from Logger import StringTable as ST
from Logger import ToolError
import Logger.Log as Logger
from Library import GlobalData
from Library import GlobalData
from Library.Misc import Sdict
from Library.ExpressionValidate import IsValidFeatureFlagExp
from Library.ExpressionValidate import IsValidFeatureFlagExp
from Object.Parser.InfCommonObject import InfSectionCommonDef
from Library.Misc import ValidFile
from Library.Misc import ValidFile
from Library.ParserValidate import IsValidFamily
from Library.ParserValidate import IsValidPath
## __GenSourceInstance
## __GenSourceInstance
#
#
#
def GenSourceInstance(Item, CurrentLineOfItem, ItemObj):
IsValidFileFlag = False
if len(Item) < 6 and len(Item) >= 1:
#
# File | Family | TagName | ToolCode | FeatureFlagExpr
@@ -46,43 +46,43 @@ def GenSourceInstance(Item, CurrentLineOfItem, ItemObj):
# Validate Feature Flag Express
#
if Item[4].strip() == '':
Logger.Error("InfParser",
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
ExtraData=CurrentLineOfItem[0])
#
# Validate FFE
# Validate FFE
#
FeatureFlagRtv = IsValidFeatureFlagExp(Item[4].strip())
if not FeatureFlagRtv[0]:
Logger.Error("InfParser",
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID%(FeatureFlagRtv[1]),
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
ExtraData=CurrentLineOfItem[0])
ItemObj.SetFeatureFlagExp(Item[4])
if len(Item) >= 4:
if Item[3].strip() == '':
ItemObj.SetToolCode(Item[3])
else:
Logger.Error("InfParser",
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_TOOLCODE_NOT_PERMITTED%(Item[2]),
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
ExtraData=CurrentLineOfItem[0])
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
ExtraData=CurrentLineOfItem[0])
if len(Item) >= 3:
if Item[2].strip() == '':
ItemObj.SetTagName(Item[2])
else:
Logger.Error("InfParser",
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_TAGNAME_NOT_PERMITTED%(Item[2]),
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
ExtraData=CurrentLineOfItem[0])
if len(Item) >= 2:
if IsValidFamily(Item[1].strip()):
@@ -93,11 +93,11 @@ def GenSourceInstance(Item, CurrentLineOfItem, ItemObj):
Item[1] = ""
ItemObj.SetFamily(Item[1])
else:
Logger.Error("InfParser",
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_SOURCE_SECTION_FAMILY_INVALID%(Item[1]),
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
ExtraData=CurrentLineOfItem[0])
if len(Item) >= 1:
#
@@ -105,41 +105,41 @@ def GenSourceInstance(Item, CurrentLineOfItem, ItemObj):
#
FullFileName = os.path.normpath(os.path.realpath(os.path.join(GlobalData.gINF_MODULE_DIR, Item[0])))
if not (ValidFile(FullFileName) or ValidFile(Item[0])):
Logger.Error("InfParser",
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_FILELIST_EXIST%(Item[0]),
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
ExtraData=CurrentLineOfItem[0])
#
# Validate file exist/format.
#
if IsValidPath(Item[0], GlobalData.gINF_MODULE_DIR):
IsValidFileFlag = True
else:
Logger.Error("InfParser",
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(Item[0]),
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
ExtraData=CurrentLineOfItem[0])
return False
if IsValidFileFlag:
ItemObj.SetSourceFileName(Item[0])
ItemObj.SetSourceFileName(Item[0])
else:
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
Logger.Error("InfParser",
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_SOURCES_SECTION_CONTENT_ERROR,
File=CurrentLineOfItem[2],
File=CurrentLineOfItem[2],
Line=CurrentLineOfItem[1],
ExtraData=CurrentLineOfItem[0])
return ItemObj
return ItemObj
## InfSourcesItemObject()
#
#
#
class InfSourcesItemObject():
def __init__(self, \
@@ -156,32 +156,32 @@ class InfSourcesItemObject():
self.HeaderString = ''
self.TailString = ''
self.SupArchList = []
def SetSourceFileName(self, SourceFilename):
self.SourceFileName = SourceFilename
def GetSourceFileName(self):
return self.SourceFileName
def SetFamily(self, Family):
self.Family = Family
def GetFamily(self):
return self.Family
def SetTagName(self, TagName):
self.TagName = TagName
def GetTagName(self):
return self.TagName
def SetToolCode(self, ToolCode):
self.ToolCode = ToolCode
def GetToolCode(self):
return self.ToolCode
def SetFeatureFlagExp(self, FeatureFlagExp):
self.FeatureFlagExp = FeatureFlagExp
def GetFeatureFlagExp(self):
return self.FeatureFlagExp
def SetHeaderString(self, HeaderString):
self.HeaderString = HeaderString
def GetHeaderString(self):
@@ -191,11 +191,11 @@ class InfSourcesItemObject():
self.TailString = TailString
def GetTailString(self):
return self.TailString
def SetSupArchList(self, SupArchList):
self.SupArchList = SupArchList
def GetSupArchList(self):
return self.SupArchList
return self.SupArchList
##
#
#
@@ -204,26 +204,26 @@ class InfSourcesObject(InfSectionCommonDef):
def __init__(self):
self.Sources = Sdict()
InfSectionCommonDef.__init__(self)
def SetSources(self, SourceList, Arch = None):
__SupArchList = []
for ArchItem in Arch:
#
# Validate Arch
#
#
if (ArchItem == '' or ArchItem is None):
ArchItem = 'COMMON'
__SupArchList.append(ArchItem)
ArchItem = 'COMMON'
__SupArchList.append(ArchItem)
for Item in SourceList:
ItemObj = InfSourcesItemObject()
CurrentLineOfItem = Item[2]
Item = Item[0]
Item = Item[0]
ItemObj = GenSourceInstance(Item, CurrentLineOfItem, ItemObj)
ItemObj.SetSupArchList(__SupArchList)
ItemObj.SetSupArchList(__SupArchList)
if (ItemObj) in self.Sources:
SourceContent = self.Sources[ItemObj]
SourceContent.append(ItemObj)
@@ -232,8 +232,8 @@ class InfSourcesObject(InfSectionCommonDef):
SourceContent = []
SourceContent.append(ItemObj)
self.Sources[ItemObj] = SourceContent
return True
def GetSources(self):
return self.Sources

View File

@@ -1,12 +1,12 @@
## @file
# This file is used to define class objects of INF file [UserExtension] section.
# It will consumed by InfParser.
# This file is used to define class objects of INF file [UserExtension] section.
# It will consumed by InfParser.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -19,7 +19,7 @@ InfUserExtensionsObject
from Logger import StringTable as ST
from Logger import ToolError
import Logger.Log as Logger
from Library import GlobalData
from Library import GlobalData
from Library.Misc import Sdict
@@ -32,27 +32,27 @@ class InfUserExtensionItem():
self.UserId = UserId
self.IdString = IdString
self.SupArchList = []
def SetContent(self, Content):
self.Content = Content
def GetContent(self):
return self.Content
def SetUserId(self, UserId):
self.UserId = UserId
def GetUserId(self):
return self.UserId
def SetIdString(self, IdString):
self.IdString = IdString
def GetIdString(self):
return self.IdString
def SetSupArchList(self, SupArchList):
self.SupArchList = SupArchList
def GetSupArchList(self):
return self.SupArchList
##
#
#
@@ -60,74 +60,74 @@ class InfUserExtensionItem():
class InfUserExtensionObject():
def __init__(self):
self.UserExtension = Sdict()
def SetUserExtension(self, UserExtensionCont, IdContent=None, LineNo=None):
if not UserExtensionCont or UserExtensionCont == '':
return True
#
# IdContent is a list contain UserId and IdString
# IdContent is a list contain UserId and IdString
# For this call the general section header parser, if no definition of
# IdString/UserId, it will return 'COMMON'
#
for IdContentItem in IdContent:
for IdContentItem in IdContent:
InfUserExtensionItemObj = InfUserExtensionItem()
if IdContentItem[0] == 'COMMON':
UserId = ''
else:
UserId = IdContentItem[0]
if IdContentItem[1] == 'COMMON':
IdString = ''
else:
IdString = IdContentItem[1]
IdString = IdContentItem[1]
#
# Fill UserExtensionObj members.
#
#
InfUserExtensionItemObj.SetUserId(UserId)
InfUserExtensionItemObj.SetIdString(IdString)
InfUserExtensionItemObj.SetContent(UserExtensionCont)
InfUserExtensionItemObj.SetSupArchList(IdContentItem[2])
InfUserExtensionItemObj.SetSupArchList(IdContentItem[2])
# for CheckItem in self.UserExtension:
# if IdContentItem[0] == CheckItem[0] and IdContentItem[1] == CheckItem[1]:
# if IdContentItem[2].upper() == 'COMMON' or CheckItem[2].upper() == 'COMMON':
# #
# # For COMMON ARCH type, do special check.
# #
# Logger.Error('InfParser',
# Logger.Error('InfParser',
# ToolError.FORMAT_INVALID,
# ST.ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR%\
# (IdContentItem[0] + '.' + IdContentItem[1] + '.' + IdContentItem[2]),
# File=GlobalData.gINF_MODULE_NAME,
# File=GlobalData.gINF_MODULE_NAME,
# Line=LineNo,
# ExtraData=None)
if IdContentItem in self.UserExtension:
#
# Each UserExtensions section header must have a unique set
# Each UserExtensions section header must have a unique set
# of UserId, IdString and Arch values.
# This means that the same UserId can be used in more than one
# section header, provided the IdString or Arch values are
# different. The same IdString values can be used in more than
# one section header if the UserId or Arch values are
# different. The same UserId and the same IdString can be used
# in a section header if the Arch values are different in each
# This means that the same UserId can be used in more than one
# section header, provided the IdString or Arch values are
# different. The same IdString values can be used in more than
# one section header if the UserId or Arch values are
# different. The same UserId and the same IdString can be used
# in a section header if the Arch values are different in each
# of the section headers.
#
Logger.Error('InfParser',
Logger.Error('InfParser',
ToolError.FORMAT_INVALID,
ST.ERR_INF_PARSER_UE_SECTION_DUPLICATE_ERROR%\
(IdContentItem[0] + '.' + IdContentItem[1] + '.' + IdContentItem[2]),
File=GlobalData.gINF_MODULE_NAME,
File=GlobalData.gINF_MODULE_NAME,
Line=LineNo,
ExtraData=None)
else:
UserExtensionList = []
UserExtensionList.append(InfUserExtensionItemObj)
self.UserExtension[IdContentItem] = UserExtensionList
return True
def GetUserExtension(self):
return self.UserExtension

View File

@@ -4,11 +4,11 @@
# This file is required to make Python interpreter treat the directory
# as containing package.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -17,4 +17,4 @@
'''
PARSER
'''
'''

View File

@@ -4,11 +4,11 @@
# This file is required to make Python interpreter treat the directory
# as containing package.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -17,4 +17,4 @@
'''
Object
'''
'''

View File

@@ -3,9 +3,9 @@
#
# Copyright (c) 2011 - 2018, 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,
@@ -75,31 +75,31 @@ class _DecBase:
# Data parsed by 'self' are saved to this object
#
self.ItemObject = None
def GetDataObject(self):
return self.ItemObject
def GetLocalMacro(self):
return self._LocalMacro
## BlockStart
#
# Called if a new section starts
#
def BlockStart(self):
self._LocalMacro = {}
## _CheckReDefine
#
# @param Key: to be checked if multi-defined
# @param Scope: Format: [[SectionName, Arch], ...].
# @param Scope: Format: [[SectionName, Arch], ...].
# If scope is none, use global scope
#
def _CheckReDefine(self, Key, Scope = None):
if not Scope:
Scope = self._RawData.CurrentScope
return
SecArch = []
#
# Copy scope to SecArch, avoid Scope be changed outside
@@ -108,7 +108,7 @@ class _DecBase:
if Key not in self._ItemDict:
self._ItemDict[Key] = [[SecArch, self._RawData.LineIndex]]
return
for Value in self._ItemDict[Key]:
for SubValue in Scope:
#
@@ -132,18 +132,18 @@ class _DecBase:
self._LoggerError(ST.ERR_DECPARSE_REDEFINE % (Key, Value[1]))
return
self._ItemDict[Key].append([SecArch, self._RawData.LineIndex])
## CheckRequiredFields
# Some sections need to check if some fields exist, define section for example
# Derived class can re-implement, top parser will call this function after all parsing done
#
#
def CheckRequiredFields(self):
if self._RawData:
pass
return True
## IsItemRequired
# In DEC spec, sections must have at least one statement except user
# In DEC spec, sections must have at least one statement except user
# extension.
# For example: "[guids" [<attribs>] "]" <EOL> <statements>+
# sub class can override this method to indicate if statement is a must.
@@ -152,12 +152,12 @@ class _DecBase:
if self._RawData:
pass
return False
def _LoggerError(self, ErrorString):
Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE, File=self._RawData.Filename,
Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE, File=self._RawData.Filename,
Line = self._RawData.LineIndex,
ExtraData=ErrorString + ST.ERR_DECPARSE_LINE % self._RawData.CurrentLine)
def _ReplaceMacro(self, String):
if gMACRO_PATTERN.findall(String):
String = ReplaceMacro(String, self._LocalMacro, False,
@@ -169,11 +169,11 @@ class _DecBase:
MacroUsed = gMACRO_PATTERN.findall(String)
if MacroUsed:
Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE,
File=self._RawData.Filename,
File=self._RawData.Filename,
Line = self._RawData.LineIndex,
ExtraData = ST.ERR_DECPARSE_MACRO_RESOLVE % (str(MacroUsed), String))
return String
def _MacroParser(self, String):
TokenList = GetSplitValueList(String, ' ', 1)
if len(TokenList) < 2 or TokenList[1] == '':
@@ -184,7 +184,7 @@ class _DecBase:
self._LoggerError(ST.ERR_DECPARSE_MACRO_NAME)
elif not IsValidToken(MACRO_PATTERN, TokenList[0]):
self._LoggerError(ST.ERR_DECPARSE_MACRO_NAME_UPPER % TokenList[0])
if len(TokenList) == 1:
self._LocalMacro[TokenList[0]] = ''
else:
@@ -202,7 +202,7 @@ class _DecBase:
#
return None
## _TailCommentStrategy
#
# This function can be derived to parse tail comment
@@ -216,7 +216,7 @@ class _DecBase:
if self._RawData:
pass
return False
## _StopCurrentParsing
#
# Called in Parse if current parsing should be stopped when encounter some
@@ -229,7 +229,7 @@ class _DecBase:
if self._RawData:
pass
return Line[0] == DT.TAB_SECTION_START and Line[-1] == DT.TAB_SECTION_END
## _TryBackSlash
#
# Split comment and DEC content, concatenate lines if end of char is '\'
@@ -246,7 +246,7 @@ class _DecBase:
if Line == '':
self._LoggerError(ST.ERR_DECPARSE_BACKSLASH_EMPTY)
break
if Comment:
CommentList.append((Comment, self._RawData.LineIndex))
if Line[-1] != DT.TAB_SLASH:
@@ -269,7 +269,7 @@ class _DecBase:
if not Line or Line[-1] == DT.TAB_SLASH:
self._LoggerError(ST.ERR_DECPARSE_BACKSLASH_EMPTY)
CatLine += Line
#
# All MACRO values defined by the DEFINE statements in any section
# (except [Userextensions] sections for Intel) of the INF or DEC file
@@ -286,17 +286,17 @@ class _DecBase:
self._RawData.CurrentLine = CatLine
return CatLine, CommentList
## Parse
# This is a template method in which other member functions which might
# override by sub class are called. It is responsible for reading file
# This is a template method in which other member functions which might
# override by sub class are called. It is responsible for reading file
# line by line, and call other member functions to parse. This function
# should not be re-implement by sub class.
#
def Parse(self):
HeadComments = []
TailComments = []
#======================================================================
# CurComments may pointer to HeadComments or TailComments
#======================================================================
@@ -304,7 +304,7 @@ class _DecBase:
CurObj = None
ItemNum = 0
FromBuf = False
#======================================================================
# Used to report error information if empty section found
#======================================================================
@@ -333,20 +333,20 @@ class _DecBase:
# Set tail comments to previous statement if not empty.
#==========================================================
CurObj.SetTailComment(CurObj.GetTailComment()+TailComments)
if not FromBuf:
del TailComments[:]
CurComments = TailComments
Comments = []
if Comment:
Comments = [(Comment, self._RawData.LineIndex)]
#==============================================================
# Try if last char of line has backslash
#==============================================================
Line, Comments = self._TryBackSlash(Line, Comments)
CurComments.extend(Comments)
#==============================================================
# Macro found
#==============================================================
@@ -356,7 +356,7 @@ class _DecBase:
del TailComments[:]
CurComments = HeadComments
continue
if self._StopCurrentParsing(Line):
#==========================================================
# This line does not belong to this parse,
@@ -364,7 +364,7 @@ class _DecBase:
#==========================================================
self._RawData.SetNext(Line, HeadComments, TailComments)
break
Obj = self._ParseItem()
ItemNum += 1
if Obj:
@@ -387,7 +387,7 @@ class _DecBase:
CurComments.append(((Comment, self._RawData.LineIndex)))
else:
del CurComments[:]
if self._IsStatementRequired() and ItemNum == 0:
Logger.Error(
TOOL_NAME, FILE_PARSE_FAILURE,
@@ -405,7 +405,7 @@ class _DecDefine(_DecBase):
self.ItemObject = DecDefineObject(RawData.Filename)
self._LocalMacro = self._RawData.Macros
self._DefSecNum = 0
#
# Each field has a function to validate
#
@@ -416,12 +416,12 @@ class _DecDefine(_DecBase):
DT.TAB_DEC_DEFINES_PACKAGE_VERSION : self._SetPackageVersion,
DT.TAB_DEC_DEFINES_PKG_UNI_FILE : self._SetPackageUni,
}
def BlockStart(self):
self._DefSecNum += 1
if self._DefSecNum > 1:
self._LoggerError(ST.ERR_DECPARSE_DEFINE_MULTISEC)
## CheckRequiredFields
#
# Check required fields: DEC_SPECIFICATION, PACKAGE_NAME
@@ -430,21 +430,21 @@ class _DecDefine(_DecBase):
def CheckRequiredFields(self):
Ret = False
if self.ItemObject.GetPackageSpecification() == '':
Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE, File=self._RawData.Filename,
Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE, File=self._RawData.Filename,
ExtraData=ST.ERR_DECPARSE_DEFINE_REQUIRED % DT.TAB_DEC_DEFINES_DEC_SPECIFICATION)
elif self.ItemObject.GetPackageName() == '':
Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE, File=self._RawData.Filename,
Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE, File=self._RawData.Filename,
ExtraData=ST.ERR_DECPARSE_DEFINE_REQUIRED % DT.TAB_DEC_DEFINES_PACKAGE_NAME)
elif self.ItemObject.GetPackageGuid() == '':
Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE, File=self._RawData.Filename,
Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE, File=self._RawData.Filename,
ExtraData=ST.ERR_DECPARSE_DEFINE_REQUIRED % DT.TAB_DEC_DEFINES_PACKAGE_GUID)
elif self.ItemObject.GetPackageVersion() == '':
Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE, File=self._RawData.Filename,
Logger.Error(TOOL_NAME, FILE_PARSE_FAILURE, File=self._RawData.Filename,
ExtraData=ST.ERR_DECPARSE_DEFINE_REQUIRED % DT.TAB_DEC_DEFINES_PACKAGE_VERSION)
else:
Ret = True
return Ret
def _ParseItem(self):
Line = self._RawData.CurrentLine
TokenList = GetSplitValueList(Line, DT.TAB_EQUAL_SPLIT, 1)
@@ -456,13 +456,13 @@ class _DecDefine(_DecBase):
self._LoggerError(ST.ERR_DECPARSE_DEFINE_UNKNOWKEY % TokenList[0])
else:
self.DefineValidation[TokenList[0]](TokenList[1])
DefineItem = DecDefineItemObject()
DefineItem.Key = TokenList[0]
DefineItem.Value = TokenList[1]
self.ItemObject.AddItem(DefineItem, self._RawData.CurrentScope)
return DefineItem
def _SetDecSpecification(self, Token):
if self.ItemObject.GetPackageSpecification():
self._LoggerError(ST.ERR_DECPARSE_DEFINE_DEFINED % DT.TAB_DEC_DEFINES_DEC_SPECIFICATION)
@@ -470,21 +470,21 @@ class _DecDefine(_DecBase):
if not IsValidDecVersionVal(Token):
self._LoggerError(ST.ERR_DECPARSE_DEFINE_SPEC)
self.ItemObject.SetPackageSpecification(Token)
def _SetPackageName(self, Token):
if self.ItemObject.GetPackageName():
self._LoggerError(ST.ERR_DECPARSE_DEFINE_DEFINED % DT.TAB_DEC_DEFINES_PACKAGE_NAME)
if not IsValidWord(Token):
self._LoggerError(ST.ERR_DECPARSE_DEFINE_PKGNAME)
self.ItemObject.SetPackageName(Token)
def _SetPackageGuid(self, Token):
if self.ItemObject.GetPackageGuid():
self._LoggerError(ST.ERR_DECPARSE_DEFINE_DEFINED % DT.TAB_DEC_DEFINES_PACKAGE_GUID)
if not CheckGuidRegFormat(Token):
self._LoggerError(ST.ERR_DECPARSE_DEFINE_PKGGUID)
self.ItemObject.SetPackageGuid(Token)
def _SetPackageVersion(self, Token):
if self.ItemObject.GetPackageVersion():
self._LoggerError(ST.ERR_DECPARSE_DEFINE_DEFINED % DT.TAB_DEC_DEFINES_PACKAGE_VERSION)
@@ -494,7 +494,7 @@ class _DecDefine(_DecBase):
if not DT.TAB_SPLIT in Token:
Token = Token + '.0'
self.ItemObject.SetPackageVersion(Token)
def _SetPackageUni(self, Token):
if self.ItemObject.GetPackageUniFile():
self._LoggerError(ST.ERR_DECPARSE_DEFINE_DEFINED % DT.TAB_DEC_DEFINES_PKG_UNI_FILE)
@@ -508,13 +508,13 @@ class _DecInclude(_DecBase):
def __init__(self, RawData):
_DecBase.__init__(self, RawData)
self.ItemObject = DecIncludeObject(RawData.Filename)
def _ParseItem(self):
Line = self._RawData.CurrentLine
if not IsValidPath(Line, self._RawData.PackagePath):
self._LoggerError(ST.ERR_DECPARSE_INCLUDE % Line)
self._LoggerError(ST.ERR_DECPARSE_INCLUDE % Line)
Item = DecIncludeItemObject(StripRoot(self._RawData.PackagePath, Line), self._RawData.PackagePath)
self.ItemObject.AddItem(Item, self._RawData.CurrentScope)
return Item
@@ -527,32 +527,32 @@ class _DecLibraryclass(_DecBase):
def __init__(self, RawData):
_DecBase.__init__(self, RawData)
self.ItemObject = DecLibraryclassObject(RawData.Filename)
def _ParseItem(self):
Line = self._RawData.CurrentLine
TokenList = GetSplitValueList(Line, DT.TAB_VALUE_SPLIT)
if len(TokenList) != 2:
self._LoggerError(ST.ERR_DECPARSE_LIBCLASS_SPLIT)
self._LoggerError(ST.ERR_DECPARSE_LIBCLASS_SPLIT)
if TokenList[0] == '' or TokenList[1] == '':
self._LoggerError(ST.ERR_DECPARSE_LIBCLASS_EMPTY)
if not IsValidToken('[A-Z][0-9A-Za-z]*', TokenList[0]):
self._LoggerError(ST.ERR_DECPARSE_LIBCLASS_LIB)
self._CheckReDefine(TokenList[0])
Value = TokenList[1]
#
# Must end with .h
#
if not Value.endswith('.h'):
self._LoggerError(ST.ERR_DECPARSE_LIBCLASS_PATH_EXT)
#
# Path must be existed
#
if not IsValidPath(Value, self._RawData.PackagePath):
self._LoggerError(ST.ERR_DECPARSE_INCLUDE % Value)
Item = DecLibraryclassItemObject(TokenList[0], StripRoot(self._RawData.PackagePath, Value),
self._RawData.PackagePath)
self.ItemObject.AddItem(Item, self._RawData.CurrentScope)
@@ -571,38 +571,38 @@ class _DecPcd(_DecBase):
# Key is token space and token number (integer), value is C name
#
self.TokenMap = {}
def _ParseItem(self):
Line = self._RawData.CurrentLine
TokenList = Line.split(DT.TAB_VALUE_SPLIT)
if len(TokenList) < 4:
self._LoggerError(ST.ERR_DECPARSE_PCD_SPLIT)
#
# Token space guid C name
#
PcdName = GetSplitValueList(TokenList[0], DT.TAB_SPLIT)
if len(PcdName) != 2 or PcdName[0] == '' or PcdName[1] == '':
self._LoggerError(ST.ERR_DECPARSE_PCD_NAME)
Guid = PcdName[0]
if not IsValidToken(CVAR_PATTERN, Guid):
self._LoggerError(ST.ERR_DECPARSE_PCD_CVAR_GUID)
#
# PCD C name
#
CName = PcdName[1]
if not IsValidToken(CVAR_PATTERN, CName):
self._LoggerError(ST.ERR_DECPARSE_PCD_CVAR_PCDCNAME)
self._CheckReDefine(Guid + DT.TAB_SPLIT + CName)
#
# Default value, may be C array, string or number
#
Data = DT.TAB_VALUE_SPLIT.join(TokenList[1:-2]).strip()
#
# PCD data type
#
@@ -623,18 +623,18 @@ class _DecPcd(_DecBase):
if long(Token) > 4294967295:
self._LoggerError(ST.ERR_DECPARSE_PCD_TOKEN_INT % Token)
Token = hex(long(Token))[:-1]
IntToken = long(Token, 0)
if (Guid, IntToken) in self.TokenMap:
if self.TokenMap[Guid, IntToken] != CName:
self._LoggerError(ST.ERR_DECPARSE_PCD_TOKEN_UNIQUE%(Token))
else:
self.TokenMap[Guid, IntToken] = CName
Item = DecPcdItemObject(Guid, CName, Data, DataType, Token)
self.ItemObject.AddItem(Item, self._RawData.CurrentScope)
return Item
## _DecGuid
#
# Parse GUID, PPI, Protocol section
@@ -651,21 +651,21 @@ class _DecGuid(_DecBase):
DT.TAB_PPIS.upper() : self.PpiObj,
DT.TAB_PROTOCOLS.upper() : self.ProtocolObj
}
def GetDataObject(self):
if self._RawData.CurrentScope:
return self.ObjectDict[self._RawData.CurrentScope[0][0]]
return None
def GetGuidObject(self):
return self.GuidObj
def GetPpiObject(self):
return self.PpiObj
def GetProtocolObject(self):
return self.ProtocolObj
def _ParseItem(self):
Line = self._RawData.CurrentLine
TokenList = GetSplitValueList(Line, DT.TAB_EQUAL_SPLIT, 1)
@@ -677,9 +677,9 @@ class _DecGuid(_DecBase):
self._LoggerError(ST.ERR_DECPARSE_CGUID_GUID)
if not IsValidToken(CVAR_PATTERN, TokenList[0]):
self._LoggerError(ST.ERR_DECPARSE_PCD_CVAR_GUID)
self._CheckReDefine(TokenList[0])
if TokenList[1][0] != '{':
if not CheckGuidRegFormat(TokenList[1]):
self._LoggerError(ST.ERR_DECPARSE_DEFINE_PKGGUID)
@@ -691,7 +691,7 @@ class _DecGuid(_DecBase):
GuidString = GuidStructureStringToGuidString(TokenList[1])
if TokenList[1][0] != '{' or TokenList[1][-1] != '}' or GuidString == '':
self._LoggerError(ST.ERR_DECPARSE_CGUID_GUIDFORMAT)
#
# Check C format GUID
#
@@ -713,7 +713,7 @@ class _DecUserExtension(_DecBase):
self.ItemObject = DecUserExtensionObject(RawData.Filename)
self._Headers = []
self._CurItems = []
def BlockStart(self):
self._CurItems = []
for Header in self._RawData.CurrentScope:
@@ -721,7 +721,7 @@ class _DecUserExtension(_DecBase):
self._LoggerError(ST.ERR_DECPARSE_UE_DUPLICATE)
else:
self._Headers.append(Header)
for Item in self._CurItems:
if Item.UserId == Header[1] and Item.IdString == Header[2]:
Item.ArchAndModuleType.append(Header[3])
@@ -734,7 +734,7 @@ class _DecUserExtension(_DecBase):
self._CurItems.append(Item)
self.ItemObject.AddItem(Item, None)
self._LocalMacro = {}
def _ParseItem(self):
Line = self._RawData.CurrentLine
Item = None
@@ -749,8 +749,8 @@ class _DecUserExtension(_DecBase):
#
# Top dec parser
#
class Dec(_DecBase, _DecComments):
def __init__(self, DecFile, Parse = True):
class Dec(_DecBase, _DecComments):
def __init__(self, DecFile, Parse = True):
try:
Content = ConvertSpecialChar(open(DecFile, 'rb').readlines())
except BaseException:
@@ -776,20 +776,20 @@ class Dec(_DecBase, _DecComments):
NewContent.append(Line + '\r')
RawData = FileContent(DecFile, NewContent)
_DecComments.__init__(self)
_DecBase.__init__(self, RawData)
self.BinaryHeadComment = []
self.PcdErrorCommentDict = {}
self._Define = _DecDefine(RawData)
self._Include = _DecInclude(RawData)
self._Guid = _DecGuid(RawData)
self._LibClass = _DecLibraryclass(RawData)
self._Pcd = _DecPcd(RawData)
self._UserEx = _DecUserExtension(RawData)
#
# DEC file supported data types (one type per section)
#
@@ -815,7 +815,7 @@ class Dec(_DecBase, _DecComments):
# Parsing done, check required fields
#
self.CheckRequiredFields()
def CheckRequiredFields(self):
for SectionParser in self._SectionParser.values():
if not SectionParser.CheckRequiredFields():
@@ -831,7 +831,7 @@ class Dec(_DecBase, _DecComments):
FileHeaderLineIndex = -1
BinaryHeaderLineIndex = -1
TokenSpaceGuidCName = ''
#
# Parse PCD error comment section
#
@@ -853,13 +853,13 @@ class Dec(_DecBase, _DecComments):
self._RawData.CurrentLine = self._RawData.CurrentLine.replace(DT.TAB_COMMENT_SPLIT, '').strip()
if self._RawData.CurrentLine != '':
if DT.TAB_VALUE_SPLIT not in self._RawData.CurrentLine:
self._LoggerError(ST.ERR_DECPARSE_PCDERRORMSG_MISS_VALUE_SPLIT)
self._LoggerError(ST.ERR_DECPARSE_PCDERRORMSG_MISS_VALUE_SPLIT)
PcdErrorNumber, PcdErrorMsg = GetSplitValueList(self._RawData.CurrentLine, DT.TAB_VALUE_SPLIT, 1)
PcdErrorNumber = ParsePcdErrorCode(PcdErrorNumber, self._RawData.Filename, self._RawData.LineIndex)
if not PcdErrorMsg.strip():
self._LoggerError(ST.ERR_DECPARSE_PCD_MISS_ERRORMSG)
self.PcdErrorCommentDict[(TokenSpaceGuidCName, PcdErrorNumber)] = PcdErrorMsg.strip()
else:
TokenSpaceGuidCName = ''
@@ -870,27 +870,27 @@ class Dec(_DecBase, _DecComments):
while not self._RawData.IsEndOfFile():
Line, Comment = CleanString(self._RawData.GetNextLine())
#
# Header must be pure comment
#
if Line != '':
self._RawData.UndoNextLine()
break
if Comment and Comment.startswith(DT.TAB_SPECIAL_COMMENT) and Comment.find(DT.TAB_HEADER_COMMENT) > 0 \
and not Comment[2:Comment.find(DT.TAB_HEADER_COMMENT)].strip():
IsFileHeader = True
IsBinaryHeader = False
FileHeaderLineIndex = self._RawData.LineIndex
#
# Get license information before '@file'
#
# Get license information before '@file'
#
if not IsFileHeader and not IsBinaryHeader and Comment and Comment.startswith(DT.TAB_COMMENT_SPLIT) and \
DT.TAB_BINARY_HEADER_COMMENT not in Comment:
self._HeadComment.append((Comment, self._RawData.LineIndex))
if Comment and IsFileHeader and \
not(Comment.startswith(DT.TAB_SPECIAL_COMMENT) \
and Comment.find(DT.TAB_BINARY_HEADER_COMMENT) > 0):
@@ -899,15 +899,15 @@ class Dec(_DecBase, _DecComments):
# Double '#' indicates end of header comments
#
if (not Comment or Comment == DT.TAB_SPECIAL_COMMENT) and IsFileHeader:
IsFileHeader = False
IsFileHeader = False
continue
if Comment and Comment.startswith(DT.TAB_SPECIAL_COMMENT) \
and Comment.find(DT.TAB_BINARY_HEADER_COMMENT) > 0:
IsBinaryHeader = True
IsFileHeader = False
BinaryHeaderLineIndex = self._RawData.LineIndex
if Comment and IsBinaryHeader:
self.BinaryHeadComment.append((Comment, self._RawData.LineIndex))
#
@@ -916,23 +916,23 @@ class Dec(_DecBase, _DecComments):
if (not Comment or Comment == DT.TAB_SPECIAL_COMMENT) and IsBinaryHeader:
IsBinaryHeader = False
break
if FileHeaderLineIndex > -1 and not IsFileHeader and not IsBinaryHeader:
break
if FileHeaderLineIndex > BinaryHeaderLineIndex and FileHeaderLineIndex > -1 and BinaryHeaderLineIndex > -1:
self._LoggerError(ST.ERR_BINARY_HEADER_ORDER)
if FileHeaderLineIndex == -1:
# self._LoggerError(ST.ERR_NO_SOURCE_HEADER)
Logger.Error(TOOL_NAME, FORMAT_INVALID,
Logger.Error(TOOL_NAME, FORMAT_INVALID,
ST.ERR_NO_SOURCE_HEADER,
File=self._RawData.Filename)
return
def _StopCurrentParsing(self, Line):
return False
def _ParseItem(self):
self._SectionHeaderParser()
if len(self._RawData.CurrentScope) == 0:
@@ -955,8 +955,8 @@ class Dec(_DecBase, _DecComments):
if Token.upper() != DT.TAB_USER_EXTENSIONS.upper():
self._LoggerError(ST.ERR_DECPARSE_SECTION_UE)
UserExtension = Token.upper()
Par.AssertChar(DT.TAB_SPLIT, ST.ERR_DECPARSE_SECTION_UE, self._RawData.LineIndex)
Par.AssertChar(DT.TAB_SPLIT, ST.ERR_DECPARSE_SECTION_UE, self._RawData.LineIndex)
#
# UserID
#
@@ -991,7 +991,7 @@ class Dec(_DecBase, _DecComments):
Par.AssertEnd(ST.ERR_DECPARSE_SECTION_UE, self._RawData.LineIndex)
if 'COMMON' in ArchList and len(ArchList) > 1:
self._LoggerError(ST.ERR_DECPARSE_SECTION_COMMON)
## Section header parser
#
# The section header is always in following format:
@@ -1001,7 +1001,7 @@ class Dec(_DecBase, _DecComments):
def _SectionHeaderParser(self):
if self._RawData.CurrentLine[0] != DT.TAB_SECTION_START or self._RawData.CurrentLine[-1] != DT.TAB_SECTION_END:
self._LoggerError(ST.ERR_DECPARSE_SECTION_IDENTIFY)
RawSection = self._RawData.CurrentLine[1:-1].strip().upper()
#
# Check defines section which is only allowed to occur once and
@@ -1039,7 +1039,7 @@ class Dec(_DecBase, _DecComments):
self._LoggerError(ST.ERR_DECPARSE_SECTION_SUBTOOMANY % Item)
if DT.TAB_PCDS_FEATURE_FLAG_NULL.upper() in SectionNames and len(SectionNames) > 1:
self._LoggerError(ST.ERR_DECPARSE_SECTION_FEATUREFLAG % DT.TAB_PCDS_FEATURE_FLAG_NULL)
self._LoggerError(ST.ERR_DECPARSE_SECTION_FEATUREFLAG % DT.TAB_PCDS_FEATURE_FLAG_NULL)
#
# S1 is always Arch
#
@@ -1064,7 +1064,7 @@ class Dec(_DecBase, _DecComments):
for Sec in SectionNames:
if not Sec.startswith(DT.TAB_PCDS.upper()):
self._LoggerError(ST.ERR_DECPARSE_SECTION_NAME % str(SectionNames))
def GetDefineSectionMacro(self):
return self._Define.GetLocalMacro()
def GetDefineSectionObject(self):
@@ -1084,11 +1084,11 @@ class Dec(_DecBase, _DecComments):
def GetUserExtensionSectionObject(self):
return self._UserEx.GetDataObject()
def GetPackageSpecification(self):
return self._Define.GetDataObject().GetPackageSpecification()
return self._Define.GetDataObject().GetPackageSpecification()
def GetPackageName(self):
return self._Define.GetDataObject().GetPackageName()
return self._Define.GetDataObject().GetPackageName()
def GetPackageGuid(self):
return self._Define.GetDataObject().GetPackageGuid()
return self._Define.GetDataObject().GetPackageGuid()
def GetPackageVersion(self):
return self._Define.GetDataObject().GetPackageVersion()
def GetPackageUniFile(self):

View File

@@ -1,11 +1,11 @@
## @file
# This file is used to define helper class and function for DEC parser
#
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -104,7 +104,7 @@ def StripRoot(Root, Path):
# Remove spaces
#
# @param Line: The string to be cleaned
# @param CommentCharacter: Comment char, used to ignore comment content,
# @param CommentCharacter: Comment char, used to ignore comment content,
# default is DataType.TAB_COMMENT_SPLIT
#
def CleanString(Line, CommentCharacter=TAB_COMMENT_SPLIT, \
@@ -291,7 +291,7 @@ def IsValidPcdDatum(Type, Value):
Valid, Cause = IsValidLogicalExpr(Value, True)
if not Valid:
return False, Cause
return True, ""
## ParserHelper
@@ -366,7 +366,7 @@ class ParserHelper:
## AssertChar
#
# Assert char at current index of string is AssertChar, or will report
# Assert char at current index of string is AssertChar, or will report
# error message
#
# @param AssertChar: AssertChar

View File

@@ -3,9 +3,9 @@
#
# Copyright (c) 2011 - 2018, 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,
@@ -133,7 +133,7 @@ def GetPackageListInfo(FileNameString, WorkSpace, LineNo):
continue
#
# Found [Packages] section
# Found [Packages] section
#
if RePackageHeader.match(Line):
PackageHederFlag = True
@@ -174,7 +174,7 @@ def GetPackageListInfo(FileNameString, WorkSpace, LineNo):
#
# Replace with Local section Macro and [Defines] section Macro.
#
#
Line = InfExpandMacro(Line, (FileNameString, Line, LineNo), DefineSectionMacros, PackageSectionMacros, True)
Line = GetSplitValueList(Line, "#", 1)[0]

View File

@@ -1,11 +1,11 @@
## @file
# This file contained the parser for [Binaries] sections in INF file
# This file contained the parser for [Binaries] sections in INF file
#
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -35,7 +35,7 @@ class InfBinarySectionParser(InfParserSectionRoot):
#
def InfBinaryParser(self, SectionString, InfSectionObject, FileName):
#
# Macro defined in this section
# Macro defined in this section
#
SectionMacros = {}
ValueList = []
@@ -56,8 +56,8 @@ class InfBinarySectionParser(InfParserSectionRoot):
StillCommentFalg = False
HeaderComments = []
LineComment = None
LineComment = None
AllSectionContent = ''
#
# Parse section content
@@ -65,16 +65,16 @@ class InfBinarySectionParser(InfParserSectionRoot):
for Line in SectionString:
BinLineContent = Line[0]
BinLineNo = Line[1]
if BinLineContent.strip() == '':
continue
CurrentLineObj = CurrentLine()
CurrentLineObj.FileName = FileName
CurrentLineObj.LineString = BinLineContent
CurrentLineObj.LineNo = BinLineNo
#
# Found Header Comments
# Found Header Comments
#
if BinLineContent.strip().startswith(DT.TAB_COMMENT_SPLIT):
#
@@ -85,7 +85,7 @@ class InfBinarySectionParser(InfParserSectionRoot):
AllSectionContent += BinLineContent + DT.END_OF_LINE
continue
#
# First time encounter comment
# First time encounter comment
#
else:
#
@@ -98,14 +98,14 @@ class InfBinarySectionParser(InfParserSectionRoot):
continue
else:
StillCommentFalg = False
if len(HeaderComments) >= 1:
LineComment = InfLineCommentObject()
LineCommentContent = ''
for Item in HeaderComments:
LineCommentContent += Item[0] + DT.END_OF_LINE
LineComment.SetHeaderComments(LineCommentContent)
#
# Find Tail comment.
#
@@ -114,8 +114,8 @@ class InfBinarySectionParser(InfParserSectionRoot):
BinLineContent = BinLineContent[:BinLineContent.find(DT.TAB_COMMENT_SPLIT)]
if LineComment is None:
LineComment = InfLineCommentObject()
LineComment.SetTailComments(TailComments)
LineComment.SetTailComments(TailComments)
#
# Find Macro
#
@@ -126,22 +126,22 @@ class InfBinarySectionParser(InfParserSectionRoot):
if MacroDef[0] is not None:
SectionMacros[MacroDef[0]] = MacroDef[1]
LineComment = None
HeaderComments = []
HeaderComments = []
continue
#
# Replace with Local section Macro and [Defines] section Macro.
#
LineContent = InfExpandMacro(BinLineContent,
(FileName, BinLineContent, BinLineNo),
self.FileLocalMacros,
#
LineContent = InfExpandMacro(BinLineContent,
(FileName, BinLineContent, BinLineNo),
self.FileLocalMacros,
SectionMacros, True)
AllSectionContent += LineContent + DT.END_OF_LINE
AllSectionContent += LineContent + DT.END_OF_LINE
TokenList = GetSplitValueList(LineContent, DT.TAB_VALUE_SPLIT, 1)
ValueList[0:len(TokenList)] = TokenList
#
#
# Should equal to UI/SEC_UI/UNI_UI
#
ValueList[0] = ValueList[0].strip()
@@ -149,84 +149,84 @@ class InfBinarySectionParser(InfParserSectionRoot):
ValueList[0] == DT.BINARY_FILE_TYPE_SEC_UI or \
ValueList[0] == DT.BINARY_FILE_TYPE_UI:
if len(ValueList) == 2:
TokenList = GetSplitValueList(ValueList[1],
DT.TAB_VALUE_SPLIT,
TokenList = GetSplitValueList(ValueList[1],
DT.TAB_VALUE_SPLIT,
2)
NewValueList = []
NewValueList.append(ValueList[0])
for Item in TokenList:
NewValueList.append(Item)
UiBinaryList.append((NewValueList,
LineComment,
CurrentLineObj))
#
UiBinaryList.append((NewValueList,
LineComment,
CurrentLineObj))
#
# Should equal to VER/SEC_VER/UNI_VER
#
elif ValueList[0] == DT.BINARY_FILE_TYPE_UNI_VER or \
ValueList[0] == DT.BINARY_FILE_TYPE_SEC_VER or \
ValueList[0] == DT.BINARY_FILE_TYPE_VER:
if len(ValueList) == 2:
TokenList = GetSplitValueList(ValueList[1],
DT.TAB_VALUE_SPLIT,
TokenList = GetSplitValueList(ValueList[1],
DT.TAB_VALUE_SPLIT,
2)
NewValueList = []
NewValueList.append(ValueList[0])
for Item in TokenList:
NewValueList.append(Item)
VerBinaryList.append((NewValueList,
LineComment,
NewValueList.append(Item)
VerBinaryList.append((NewValueList,
LineComment,
CurrentLineObj))
else:
if len(ValueList) == 2:
if ValueList[0].strip() == 'SUBTYPE_GUID':
TokenList = GetSplitValueList(ValueList[1],
DT.TAB_VALUE_SPLIT,
TokenList = GetSplitValueList(ValueList[1],
DT.TAB_VALUE_SPLIT,
5)
else:
TokenList = GetSplitValueList(ValueList[1],
DT.TAB_VALUE_SPLIT,
TokenList = GetSplitValueList(ValueList[1],
DT.TAB_VALUE_SPLIT,
4)
NewValueList = []
NewValueList.append(ValueList[0])
for Item in TokenList:
NewValueList.append(Item)
ComBinaryList.append((NewValueList,
LineComment,
NewValueList.append(Item)
ComBinaryList.append((NewValueList,
LineComment,
CurrentLineObj))
elif len(ValueList) == 1:
NewValueList = []
NewValueList.append(ValueList[0])
ComBinaryList.append((NewValueList,
LineComment,
ComBinaryList.append((NewValueList,
LineComment,
CurrentLineObj))
ValueList = []
LineComment = None
TailComments = ''
HeaderComments = []
HeaderComments = []
continue
#
# Current section archs
#
#
ArchList = []
for Item in self.LastSectionHeaderContent:
if Item[1] not in ArchList:
ArchList.append(Item[1])
ArchList.append(Item[1])
InfSectionObject.SetSupArchList(Item[1])
InfSectionObject.SetAllContent(AllSectionContent)
if not InfSectionObject.SetBinary(UiBinaryList,
VerBinaryList,
ComBinaryList,
InfSectionObject.SetAllContent(AllSectionContent)
if not InfSectionObject.SetBinary(UiBinaryList,
VerBinaryList,
ComBinaryList,
ArchList):
Logger.Error('InfParser',
Logger.Error('InfParser',
FORMAT_INVALID,
ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR%("[Binaries]"),
File=FileName,
Line=Item[3])
Line=Item[3])

View File

@@ -1,11 +1,11 @@
## @file
# This file contained the parser for BuildOption sections in INF file
# This file contained the parser for BuildOption sections in INF file
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -36,10 +36,10 @@ class InfBuildOptionSectionParser(InfParserSectionRoot):
#
#
def InfBuildOptionParser(self, SectionString, InfSectionObject, FileName):
BuildOptionList = []
SectionContent = ''
if not GlobalData.gIS_BINARY_INF:
ValueList = []
LineNo = 0
@@ -49,24 +49,24 @@ class InfBuildOptionSectionParser(InfParserSectionRoot):
LineNo = Line[1]
TailComments = ''
ReplaceFlag = False
if LineContent.strip() == '':
SectionContent += LineContent + DT.END_OF_LINE
continue
SectionContent += LineContent + DT.END_OF_LINE
continue
#
# Found Comment
#
if LineContent.strip().startswith(DT.TAB_COMMENT_SPLIT):
SectionContent += LineContent + DT.END_OF_LINE
SectionContent += LineContent + DT.END_OF_LINE
continue
#
# Find Tail comment.
#
if LineContent.find(DT.TAB_COMMENT_SPLIT) > -1:
TailComments = LineContent[LineContent.find(DT.TAB_COMMENT_SPLIT):]
LineContent = LineContent[:LineContent.find(DT.TAB_COMMENT_SPLIT)]
LineContent = LineContent[:LineContent.find(DT.TAB_COMMENT_SPLIT)]
TokenList = GetSplitValueList(LineContent, DT.TAB_DEQUAL_SPLIT, 1)
if len(TokenList) == 2:
#
@@ -82,21 +82,21 @@ class InfBuildOptionSectionParser(InfParserSectionRoot):
if len(TokenList) == 2:
TokenList.append('False')
else:
Logger.Error('InfParser',
Logger.Error('InfParser',
FORMAT_INVALID,
ST.ERR_INF_PARSER_BUILD_OPTION_FORMAT_INVALID,
ExtraData=LineContent,
ExtraData=LineContent,
File=FileName,
Line=LineNo)
Line=LineNo)
ValueList[0:len(TokenList)] = TokenList
#
# Replace with [Defines] section Macro
#
ValueList[0] = InfExpandMacro(ValueList[0], (FileName, LineContent, LineNo),
ValueList[0] = InfExpandMacro(ValueList[0], (FileName, LineContent, LineNo),
self.FileLocalMacros, None)
ValueList[1] = InfExpandMacro(ValueList[1], (FileName, LineContent, LineNo),
ValueList[1] = InfExpandMacro(ValueList[1], (FileName, LineContent, LineNo),
self.FileLocalMacros, None, True)
EqualString = ''
if not ReplaceFlag:
@@ -108,30 +108,30 @@ class InfBuildOptionSectionParser(InfParserSectionRoot):
Family = GetSplitValueList(ValueList[0], DT.TAB_COLON_SPLIT, 1)
if len(Family) == 2:
if not IsValidFamily(Family[0]):
Logger.Error('InfParser',
if not IsValidFamily(Family[0]):
Logger.Error('InfParser',
FORMAT_INVALID,
ST.ERR_INF_PARSER_BUILD_OPTION_FORMAT_INVALID,
ExtraData=LineContent,
ExtraData=LineContent,
File=FileName,
Line=LineNo)
if not IsValidBuildOptionName(Family[1]):
Logger.Error('InfParser',
Logger.Error('InfParser',
FORMAT_INVALID,
ST.ERR_INF_PARSER_BUILD_OPTION_FORMAT_INVALID,
ExtraData=LineContent,
ExtraData=LineContent,
File=FileName,
Line=LineNo)
if len(Family) == 1:
if not IsValidBuildOptionName(Family[0]):
Logger.Error('InfParser',
Logger.Error('InfParser',
FORMAT_INVALID,
ST.ERR_INF_PARSER_BUILD_OPTION_FORMAT_INVALID,
ExtraData=LineContent,
ExtraData=LineContent,
File=FileName,
Line=LineNo)
BuildOptionList.append(ValueList)
BuildOptionList.append(ValueList)
ValueList = []
continue
else:
@@ -147,20 +147,20 @@ class InfBuildOptionSectionParser(InfParserSectionRoot):
if not (Item[1] == '' or Item[1] == '') and Item[1] not in ArchList:
ArchList.append(Item[1])
InfSectionObject.SetSupArchList(Item[1])
InfSectionObject.SetAllContent(SectionContent)
if not InfSectionObject.SetBuildOptions(BuildOptionList, ArchList, SectionContent):
Logger.Error('InfParser',
Logger.Error('InfParser',
FORMAT_INVALID,
ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR%("[BuilOptions]"),
File=FileName,
Line=LastItem[3])
Line=LastItem[3])
## InfBuildOptionParser
#
#
def InfAsBuiltBuildOptionParser(SectionString, FileName):
BuildOptionList = []
BuildOptionList = []
#
# AsBuild Binary INF file.
#
@@ -171,7 +171,7 @@ def InfAsBuiltBuildOptionParser(SectionString, FileName):
Count += 1
LineContent = Line[0]
LineNo = Line[1]
#
# The last line
#
@@ -186,33 +186,33 @@ def InfAsBuiltBuildOptionParser(SectionString, FileName):
else:
if len(BuildOptionItem) > 0:
BuildOptionList.append(BuildOptionItem)
break
break
if LineContent.strip() == '':
AsBuildOptionFlag = False
continue
if LineContent.strip().startswith("##") and AsBuildOptionFlag:
if len(BuildOptionItem) > 0:
BuildOptionList.append(BuildOptionItem)
BuildOptionList.append(BuildOptionItem)
BuildOptionItem = []
if not LineContent.strip().startswith("#"):
Logger.Error('InfParser',
Logger.Error('InfParser',
FORMAT_INVALID,
ST.ERR_BO_CONTATIN_ASBUILD_AND_COMMON,
File=FileName,
Line=LineNo,
ST.ERR_BO_CONTATIN_ASBUILD_AND_COMMON,
File=FileName,
Line=LineNo,
ExtraData=LineContent)
if IsAsBuildOptionInfo(LineContent):
AsBuildOptionFlag = True
continue
if AsBuildOptionFlag:
BuildOptionInfo = GetHelpStringByRemoveHashKey(LineContent)
BuildOptionItem.append(BuildOptionInfo)
return BuildOptionList
return BuildOptionList

View File

@@ -1,11 +1,11 @@
## @file
# This file contained the parser for define sections in INF file
# This file contained the parser for define sections in INF file
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -33,32 +33,32 @@ from Logger import StringTable as ST
from Parser.InfParserMisc import InfParserSectionRoot
## __GetValidateArchList
#
#
#
def GetValidateArchList(LineContent):
TempArch = ''
ArchList = []
ValidateAcrhPatten = re.compile(r"^\s*#\s*VALID_ARCHITECTURES\s*=\s*.*$", re.DOTALL)
if ValidateAcrhPatten.match(LineContent):
TempArch = GetSplitValueList(LineContent, DT.TAB_EQUAL_SPLIT, 1)[1]
TempArch = GetSplitValueList(TempArch, '(', 1)[0]
ArchList = re.split('\s+', TempArch)
NewArchList = []
for Arch in ArchList:
if IsValidArch(Arch):
NewArchList.append(Arch)
ArchList = NewArchList
return ArchList
return ArchList
class InfDefinSectionParser(InfParserSectionRoot):
def InfDefineParser(self, SectionString, InfSectionObject, FileName, SectionComment):
if SectionComment:
pass
#
@@ -74,18 +74,18 @@ class InfDefinSectionParser(InfParserSectionRoot):
# Add WORKSPACE to global Marco dict.
#
self.FileLocalMacros['WORKSPACE'] = GlobalData.gWORKSPACE
for Line in SectionString:
LineContent = Line[0]
LineNo = Line[1]
TailComments = ''
LineComment = None
LineInfo = ['', -1, '']
LineInfo[0] = FileName
LineInfo[1] = LineNo
LineInfo[2] = LineContent
if LineContent.strip() == '':
continue
#
@@ -106,7 +106,7 @@ class InfDefinSectionParser(InfParserSectionRoot):
SectionContent += LineContent + DT.END_OF_LINE
continue
#
# First time encounter comment
# First time encounter comment
#
else:
#
@@ -119,14 +119,14 @@ class InfDefinSectionParser(InfParserSectionRoot):
continue
else:
StillCommentFalg = False
if len(HeaderComments) >= 1:
LineComment = InfLineCommentObject()
LineCommentContent = ''
for Item in HeaderComments:
LineCommentContent += Item[0] + DT.END_OF_LINE
LineComment.SetHeaderComments(LineCommentContent)
#
# Find Tail comment.
#
@@ -136,62 +136,62 @@ class InfDefinSectionParser(InfParserSectionRoot):
if LineComment is None:
LineComment = InfLineCommentObject()
LineComment.SetTailComments(TailComments)
#
# Find Macro
#
Name, Value = MacroParser((LineContent, LineNo),
FileName,
DT.MODEL_META_DATA_HEADER,
Name, Value = MacroParser((LineContent, LineNo),
FileName,
DT.MODEL_META_DATA_HEADER,
self.FileLocalMacros)
if Name is not None:
self.FileLocalMacros[Name] = Value
continue
continue
#
# Replace with [Defines] section Macro
#
LineContent = InfExpandMacro(LineContent,
(FileName, LineContent, LineNo),
self.FileLocalMacros,
LineContent = InfExpandMacro(LineContent,
(FileName, LineContent, LineNo),
self.FileLocalMacros,
None, True)
SectionContent += LineContent + DT.END_OF_LINE
TokenList = GetSplitValueList(LineContent, DT.TAB_EQUAL_SPLIT, 1)
if len(TokenList) < 2:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_NO_VALUE,
LineInfo=LineInfo)
LineInfo=LineInfo)
_ValueList[0:len(TokenList)] = TokenList
if not _ValueList[0]:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_NO_NAME,
LineInfo=LineInfo)
if not _ValueList[1]:
ErrorInInf(ST.ERR_INF_PARSER_DEFINE_ITEM_NO_VALUE,
LineInfo=LineInfo)
Name, Value = _ValueList[0], _ValueList[1]
LineInfo=LineInfo)
Name, Value = _ValueList[0], _ValueList[1]
InfDefMemberObj = InfDefMember(Name, Value)
if (LineComment is not None):
InfDefMemberObj.Comments.SetHeaderComments(LineComment.GetHeaderComments())
InfDefMemberObj.Comments.SetTailComments(LineComment.GetTailComments())
InfDefMemberObj.CurrentLine.SetFileName(self.FullPath)
InfDefMemberObj.CurrentLine.SetLineString(LineContent)
InfDefMemberObj.CurrentLine.SetLineNo(LineNo)
_ContentList.append(InfDefMemberObj)
HeaderComments = []
TailComments = ''
#
# Current Define section archs
#
if not ArchList:
ArchList = ['COMMON']
InfSectionObject.SetAllContent(SectionContent)
InfSectionObject.SetAllContent(SectionContent)
InfSectionObject.SetDefines(_ContentList, Arch=ArchList)

View File

@@ -1,11 +1,11 @@
## @file
# This file contained the parser for [Depex] sections in INF file
# This file contained the parser for [Depex] sections in INF file
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -29,7 +29,7 @@ from Parser.InfParserMisc import InfParserSectionRoot
class InfDepexSectionParser(InfParserSectionRoot):
## InfDepexParser
#
# For now, only separate Depex String and comments.
# For now, only separate Depex String and comments.
# Have two types of section header.
# 1. [Depex.Arch.ModuleType, ...]
# 2. [Depex.Arch|FFE, ...]
@@ -44,7 +44,7 @@ class InfDepexSectionParser(InfParserSectionRoot):
for Line in SectionString:
LineContent = Line[0]
LineNo = Line[1]
#
# Found comment
#
@@ -54,34 +54,34 @@ class InfDepexSectionParser(InfParserSectionRoot):
#
# Replace with [Defines] section Macro
#
LineContent = InfExpandMacro(LineContent,
(FileName, LineContent, Line[1]),
self.FileLocalMacros,
LineContent = InfExpandMacro(LineContent,
(FileName, LineContent, Line[1]),
self.FileLocalMacros,
None, True)
CommentCount = LineContent.find(DT.TAB_COMMENT_SPLIT)
if CommentCount > -1:
DepexComment.append((LineContent[CommentCount:], LineNo))
DepexComment.append((LineContent[CommentCount:], LineNo))
LineContent = LineContent[:CommentCount-1]
CommentCount = -1
DepexContent.append((LineContent, LineNo))
TokenList = GetSplitValueList(LineContent, DT.TAB_COMMENT_SPLIT)
ValueList[0:len(TokenList)] = TokenList
#
# Current section archs
#
#
KeyList = []
LastItem = ''
for Item in self.LastSectionHeaderContent:
LastItem = Item
if (Item[1], Item[2], Item[3]) not in KeyList:
KeyList.append((Item[1], Item[2], Item[3]))
KeyList.append((Item[1], Item[2], Item[3]))
NewCommentList = []
FormatCommentLn = -1
ReFormatComment = re.compile(r"""#(?:\s*)\[(.*?)\](?:.*)""", re.DOTALL)
@@ -90,15 +90,15 @@ class InfDepexSectionParser(InfParserSectionRoot):
if ReFormatComment.match(CommentContent) is not None:
FormatCommentLn = CommentItem[1] + 1
continue
if CommentItem[1] != FormatCommentLn:
NewCommentList.append(CommentContent)
else:
FormatCommentLn = CommentItem[1] + 1
if not InfSectionObject.SetDepex(DepexContent, KeyList = KeyList, CommentList = NewCommentList):
Logger.Error('InfParser',
Logger.Error('InfParser',
FORMAT_INVALID,
ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR%("[Depex]"),
File=FileName,
Line=LastItem[3])
File=FileName,
Line=LastItem[3])

View File

@@ -1,11 +1,11 @@
## @file
# This file contained the parser for [Guids], [Ppis], [Protocols] sections in INF file
# This file contained the parser for [Guids], [Ppis], [Protocols] sections in INF file
#
# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -37,7 +37,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
#
def InfGuidParser(self, SectionString, InfSectionObject, FileName):
#
# Macro defined in this section
# Macro defined in this section
#
SectionMacros = {}
ValueList = []
@@ -88,7 +88,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
#
# Replace with Local section Macro and [Defines] section Macro.
#
#
ValueList = [InfExpandMacro(Value, (FileName, LineContent, LineNo),
self.FileLocalMacros, SectionMacros, True)
for Value in ValueList]
@@ -104,7 +104,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
#
# Current section archs
#
#
ArchList = []
LineIndex = -1
for Item in self.LastSectionHeaderContent:
@@ -124,7 +124,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
#
def InfPpiParser(self, SectionString, InfSectionObject, FileName):
#
# Macro defined in this section
# Macro defined in this section
#
SectionMacros = {}
ValueList = []
@@ -175,7 +175,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
#
# Replace with Local section Macro and [Defines] section Macro.
#
#
ValueList = [InfExpandMacro(Value, (FileName, LineContent, LineNo), self.FileLocalMacros, SectionMacros)
for Value in ValueList]
@@ -189,7 +189,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
#
# Current section archs
#
#
ArchList = []
LineIndex = -1
for Item in self.LastSectionHeaderContent:
@@ -206,7 +206,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
## InfUserExtensionParser
#
#
#
def InfUserExtensionParser(self, SectionString, InfSectionObject, FileName):
UserExtensionContent = ''
@@ -226,7 +226,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
#
# Current section UserId, IdString
#
#
IdContentList = []
LastItem = ''
SectionLineNo = None
@@ -265,14 +265,14 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
IdContentList.append((UserId, IdString, Arch))
else:
#
# Each UserExtensions section header must have a unique set
# Each UserExtensions section header must have a unique set
# of UserId, IdString and Arch values.
# This means that the same UserId can be used in more than one
# section header, provided the IdString or Arch values are
# different. The same IdString values can be used in more than
# one section header if the UserId or Arch values are
# different. The same UserId and the same IdString can be used
# in a section header if the Arch values are different in each
# This means that the same UserId can be used in more than one
# section header, provided the IdString or Arch values are
# different. The same IdString values can be used in more than
# one section header if the UserId or Arch values are
# different. The same UserId and the same IdString can be used
# in a section header if the Arch values are different in each
# of the section headers.
#
Logger.Error('InfParser',
@@ -294,7 +294,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
def InfProtocolParser(self, SectionString, InfSectionObject, FileName):
#
# Macro defined in this section
# Macro defined in this section
#
SectionMacros = {}
ValueList = []
@@ -345,7 +345,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
#
# Replace with Local section Macro and [Defines] section Macro.
#
#
ValueList = [InfExpandMacro(Value, (FileName, LineContent, LineNo), self.FileLocalMacros, SectionMacros)
for Value in ValueList]
@@ -359,7 +359,7 @@ class InfGuidPpiProtocolSectionParser(InfParserSectionRoot):
#
# Current section archs
#
#
ArchList = []
LineIndex = -1
for Item in self.LastSectionHeaderContent:

View File

@@ -1,11 +1,11 @@
## @file
# This file contained the parser for [Libraries] sections in INF file
# This file contained the parser for [Libraries] sections in INF file
#
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -34,14 +34,14 @@ from Parser.InfParserMisc import InfParserSectionRoot
class InfLibrarySectionParser(InfParserSectionRoot):
## InfLibraryParser
#
#
#
def InfLibraryParser(self, SectionString, InfSectionObject, FileName):
#
# For Common INF file
#
if not GlobalData.gIS_BINARY_INF:
#
# Macro defined in this section
# Macro defined in this section
#
SectionMacros = {}
ValueList = []
@@ -60,7 +60,7 @@ class InfLibrarySectionParser(InfParserSectionRoot):
continue
#
# Found Header Comments
# Found Header Comments
#
if LibLineContent.strip().startswith(DT.TAB_COMMENT_SPLIT):
#
@@ -70,7 +70,7 @@ class InfLibrarySectionParser(InfParserSectionRoot):
LibHeaderComments.append(Line)
continue
#
# First time encounter comment
# First time encounter comment
#
else:
#
@@ -118,7 +118,7 @@ class InfLibrarySectionParser(InfParserSectionRoot):
#
# Replace with Local section Macro and [Defines] section Macro.
#
#
ValueList = [InfExpandMacro(Value, (FileName, LibLineContent, LibLineNo),
self.FileLocalMacros, SectionMacros, True)
for Value in ValueList]
@@ -134,7 +134,7 @@ class InfLibrarySectionParser(InfParserSectionRoot):
#
# Current section archs
#
#
KeyList = []
for Item in self.LastSectionHeaderContent:
if (Item[1], Item[2]) not in KeyList:
@@ -188,7 +188,7 @@ class InfLibrarySectionParser(InfParserSectionRoot):
#
# Current section archs
#
#
KeyList = []
Item = ['', '', '']
for Item in self.LastSectionHeaderContent:

View File

@@ -1,11 +1,11 @@
## @file
# This file contained the parser for [Packages] sections in INF file
# This file contained the parser for [Packages] sections in INF file
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -31,29 +31,29 @@ from Parser.InfParserMisc import InfParserSectionRoot
class InfPackageSectionParser(InfParserSectionRoot):
## InfPackageParser
#
#
#
def InfPackageParser(self, SectionString, InfSectionObject, FileName):
#
# Macro defined in this section
# Macro defined in this section
#
SectionMacros = {}
ValueList = []
PackageList = []
StillCommentFalg = False
HeaderComments = []
LineComment = None
LineComment = None
#
# Parse section content
#
for Line in SectionString:
PkgLineContent = Line[0]
PkgLineNo = Line[1]
PkgLineNo = Line[1]
if PkgLineContent.strip() == '':
continue
#
# Find Header Comments
# Find Header Comments
#
if PkgLineContent.strip().startswith(DT.TAB_COMMENT_SPLIT):
#
@@ -63,7 +63,7 @@ class InfPackageSectionParser(InfParserSectionRoot):
HeaderComments.append(Line)
continue
#
# First time encounter comment
# First time encounter comment
#
else:
#
@@ -75,14 +75,14 @@ class InfPackageSectionParser(InfParserSectionRoot):
continue
else:
StillCommentFalg = False
if len(HeaderComments) >= 1:
LineComment = InfLineCommentObject()
LineCommentContent = ''
for Item in HeaderComments:
LineCommentContent += Item[0] + DT.END_OF_LINE
LineComment.SetHeaderComments(LineCommentContent)
#
# Find Tail comment.
#
@@ -91,7 +91,7 @@ class InfPackageSectionParser(InfParserSectionRoot):
PkgLineContent = PkgLineContent[:PkgLineContent.find(DT.TAB_COMMENT_SPLIT)]
if LineComment is None:
LineComment = InfLineCommentObject()
LineComment.SetTailComments(TailComments)
LineComment.SetTailComments(TailComments)
#
# Find Macro
#
@@ -102,39 +102,39 @@ class InfPackageSectionParser(InfParserSectionRoot):
if Name is not None:
SectionMacros[Name] = Value
LineComment = None
HeaderComments = []
HeaderComments = []
continue
TokenList = GetSplitValueList(PkgLineContent, DT.TAB_VALUE_SPLIT, 1)
ValueList[0:len(TokenList)] = TokenList
#
# Replace with Local section Macro and [Defines] section Macro.
#
ValueList = [InfExpandMacro(Value, (FileName, PkgLineContent, PkgLineNo),
#
ValueList = [InfExpandMacro(Value, (FileName, PkgLineContent, PkgLineNo),
self.FileLocalMacros, SectionMacros, True)
for Value in ValueList]
PackageList.append((ValueList, LineComment,
PackageList.append((ValueList, LineComment,
(PkgLineContent, PkgLineNo, FileName)))
ValueList = []
LineComment = None
TailComments = ''
HeaderComments = []
HeaderComments = []
continue
#
# Current section archs
#
#
ArchList = []
for Item in self.LastSectionHeaderContent:
if Item[1] not in ArchList:
ArchList.append(Item[1])
ArchList.append(Item[1])
if not InfSectionObject.SetPackages(PackageList, Arch = ArchList):
Logger.Error('InfParser',
FORMAT_INVALID,
Logger.Error('InfParser',
FORMAT_INVALID,
ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR\
%("[Packages]"),
File=FileName,
Line=Item[3])
Line=Item[3])

View File

@@ -3,9 +3,9 @@
#
# Copyright (c) 2011 - 2018, 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,
@@ -49,24 +49,24 @@ from Parser.InfParserMisc import IsBinaryInf
#
def OpenInfFile(Filename):
FileLinesList = []
try:
FInputfile = open(Filename, "rb", 0)
try:
FileLinesList = FInputfile.readlines()
except BaseException:
Logger.Error("InfParser",
FILE_READ_FAILURE,
Logger.Error("InfParser",
FILE_READ_FAILURE,
ST.ERR_FILE_OPEN_FAILURE,
File=Filename)
finally:
FInputfile.close()
except BaseException:
Logger.Error("InfParser",
FILE_READ_FAILURE,
Logger.Error("InfParser",
FILE_READ_FAILURE,
ST.ERR_FILE_OPEN_FAILURE,
File=Filename)
return FileLinesList
## InfParser
@@ -74,20 +74,20 @@ def OpenInfFile(Filename):
# This class defined the structure used in InfParser object
#
# @param InfObject: Inherited from InfSectionParser class
# @param Filename: Input value for Filename of INF file, default is
# @param Filename: Input value for Filename of INF file, default is
# None
# @param WorkspaceDir: Input value for current workspace directory,
# @param WorkspaceDir: Input value for current workspace directory,
# default is None
#
class InfParser(InfSectionParser):
def __init__(self, Filename = None, WorkspaceDir = None):
#
# Call parent class construct function
#
super(InfParser, self).__init__()
self.WorkspaceDir = WorkspaceDir
self.SupArchList = DT.ARCH_LIST
self.EventList = []
@@ -107,7 +107,7 @@ class InfParser(InfSectionParser):
# @param Filename: Input value for filename of INF file
#
def ParseInfFile(self, Filename):
Filename = NormPath(Filename)
(Path, Name) = os.path.split(Filename)
self.FullPath = Filename
@@ -120,30 +120,30 @@ class InfParser(InfSectionParser):
# Initialize common data
#
LineNo = 0
CurrentSection = DT.MODEL_UNKNOWN
CurrentSection = DT.MODEL_UNKNOWN
SectionLines = []
#
# Flags
#
HeaderCommentStart = False
HeaderCommentStart = False
HeaderCommentEnd = False
HeaderStarLineNo = -1
BinaryHeaderCommentStart = False
BinaryHeaderCommentStart = False
BinaryHeaderCommentEnd = False
BinaryHeaderStarLineNo = -1
#
# While Section ends. parse whole section contents.
#
NewSectionStartFlag = False
FirstSectionStartFlag = False
#
# Parse file content
#
CommentBlock = []
#
# Variables for Event/Hob/BootMode
#
@@ -151,44 +151,44 @@ class InfParser(InfSectionParser):
self.HobList = []
self.BootModeList = []
SectionType = ''
FileLinesList = OpenInfFile (Filename)
#
# One INF file can only has one [Defines] section.
#
DefineSectionParsedFlag = False
#
# Convert special characters in lines to space character.
#
FileLinesList = ConvertSpecialChar(FileLinesList)
#
# Process Line Extender
#
FileLinesList = ProcessLineExtender(FileLinesList)
#
# Process EdkI INF style comment if found
#
OrigLines = [Line for Line in FileLinesList]
FileLinesList, EdkCommentStartPos = ProcessEdkComment(FileLinesList)
#
# Judge whether the INF file is Binary INF or not
#
if IsBinaryInf(FileLinesList):
GlobalData.gIS_BINARY_INF = True
InfSectionCommonDefObj = None
for Line in FileLinesList:
LineNo = LineNo + 1
Line = Line.strip()
if (LineNo < len(FileLinesList) - 1):
NextLine = FileLinesList[LineNo].strip()
#
# blank line
#
@@ -209,7 +209,7 @@ class InfParser(InfSectionParser):
HeaderStarLineNo = LineNo
SectionLines.append((Line, LineNo))
HeaderCommentStart = True
continue
continue
#
# Collect Header content.
@@ -225,11 +225,11 @@ class InfParser(InfSectionParser):
if (Line.startswith(DT.TAB_SPECIAL_COMMENT) or not Line.strip().startswith("#")) and HeaderCommentStart \
and not HeaderCommentEnd:
HeaderCommentEnd = True
BinaryHeaderCommentStart = False
BinaryHeaderCommentStart = False
BinaryHeaderCommentEnd = False
HeaderCommentStart = False
HeaderCommentStart = False
if Line.find(DT.TAB_BINARY_HEADER_COMMENT) > -1:
self.InfHeaderParser(SectionLines, self.InfHeader, self.FileName)
self.InfHeaderParser(SectionLines, self.InfHeader, self.FileName)
SectionLines = []
else:
SectionLines.append((Line, LineNo))
@@ -255,8 +255,8 @@ class InfParser(InfSectionParser):
SectionLines.append((Line, LineNo))
BinaryHeaderCommentStart = True
HeaderCommentEnd = True
continue
continue
#
# check whether there are more than one binary header exist
#
@@ -266,7 +266,7 @@ class InfParser(InfSectionParser):
FORMAT_INVALID,
ST.ERR_MULTIPLE_BINARYHEADER_EXIST,
File=Filename)
#
# Collect Binary Header content.
#
@@ -287,17 +287,17 @@ class InfParser(InfSectionParser):
#
self.InfHeaderParser(SectionLines, self.InfBinaryHeader, self.FileName, True)
SectionLines = []
BinaryHeaderCommentEnd = True
continue
BinaryHeaderCommentEnd = True
continue
#
# Find a new section tab
# Or at the last line of INF file,
# Or at the last line of INF file,
# need to process the last section.
#
LastSectionFalg = False
if LineNo == len(FileLinesList):
LastSectionFalg = True
if Line.startswith(DT.TAB_COMMENT_SPLIT) and not Line.startswith(DT.TAB_SPECIAL_COMMENT):
SectionLines.append((Line, LineNo))
if not LastSectionFalg:
@@ -307,23 +307,23 @@ class InfParser(InfSectionParser):
# Encountered a section. start with '[' and end with ']'
#
if (Line.startswith(DT.TAB_SECTION_START) and \
Line.find(DT.TAB_SECTION_END) > -1) or LastSectionFalg:
HeaderCommentEnd = True
BinaryHeaderCommentEnd = True
Line.find(DT.TAB_SECTION_END) > -1) or LastSectionFalg:
HeaderCommentEnd = True
BinaryHeaderCommentEnd = True
if not LastSectionFalg:
#
# check to prevent '#' inside section header
#
HeaderContent = Line[1:Line.find(DT.TAB_SECTION_END)]
if HeaderContent.find(DT.TAB_COMMENT_SPLIT) != -1:
Logger.Error("InfParser",
Logger.Error("InfParser",
FORMAT_INVALID,
ST.ERR_INF_PARSER_DEFINE_SECTION_HEADER_INVALID,
File=self.FullPath,
Line=LineNo,
ExtraData=Line)
Line=LineNo,
ExtraData=Line)
#
# Keep last time section header content for section parser
@@ -339,7 +339,7 @@ class InfParser(InfSectionParser):
if CommentIndex > -1:
TailComments = Line[CommentIndex:]
Line = Line[:CommentIndex]
InfSectionCommonDefObj = InfSectionCommonDef()
if TailComments != '':
InfSectionCommonDefObj.SetTailComments(TailComments)
@@ -350,8 +350,8 @@ class InfParser(InfSectionParser):
# Call section parser before section header parer to avoid encounter EDKI INF file
#
if CurrentSection == DT.MODEL_META_DATA_DEFINE:
DefineSectionParsedFlag = self._CallSectionParsers(CurrentSection,
DefineSectionParsedFlag, SectionLines,
DefineSectionParsedFlag = self._CallSectionParsers(CurrentSection,
DefineSectionParsedFlag, SectionLines,
InfSectionCommonDefObj, LineNo)
#
# Compare the new section name with current
@@ -377,52 +377,52 @@ class InfParser(InfSectionParser):
#
# End of section content collect.
# Parser the section content collected previously.
#
#
if NewSectionStartFlag or LastSectionFalg:
if CurrentSection != DT.MODEL_META_DATA_DEFINE or \
(LastSectionFalg and CurrentSection == DT.MODEL_META_DATA_DEFINE):
DefineSectionParsedFlag = self._CallSectionParsers(CurrentSection,
DefineSectionParsedFlag, SectionLines,
(LastSectionFalg and CurrentSection == DT.MODEL_META_DATA_DEFINE):
DefineSectionParsedFlag = self._CallSectionParsers(CurrentSection,
DefineSectionParsedFlag, SectionLines,
InfSectionCommonDefObj, LineNo)
CurrentSection = SectionType
#
# Clear section lines
#
SectionLines = []
SectionLines = []
if HeaderStarLineNo == -1:
Logger.Error("InfParser",
Logger.Error("InfParser",
FORMAT_INVALID,
ST.ERR_NO_SOURCE_HEADER,
File=self.FullPath)
File=self.FullPath)
if BinaryHeaderStarLineNo > -1 and HeaderStarLineNo > -1 and HeaderStarLineNo > BinaryHeaderStarLineNo:
Logger.Error("InfParser",
Logger.Error("InfParser",
FORMAT_INVALID,
ST.ERR_BINARY_HEADER_ORDER,
File=self.FullPath)
File=self.FullPath)
#
# EDKII INF should not have EDKI style comment
#
if EdkCommentStartPos != -1:
Logger.Error("InfParser",
FORMAT_INVALID,
ST.ERR_INF_PARSER_EDKI_COMMENT_IN_EDKII,
Logger.Error("InfParser",
FORMAT_INVALID,
ST.ERR_INF_PARSER_EDKI_COMMENT_IN_EDKII,
File=self.FullPath,
Line=EdkCommentStartPos + 1,
ExtraData=OrigLines[EdkCommentStartPos])
#
# extract [Event] [Hob] [BootMode] sections
#
# extract [Event] [Hob] [BootMode] sections
#
self._ExtractEventHobBootMod(FileLinesList)
## _CheckSectionHeaders
#
#
def _CheckSectionHeaders(self, Line, LineNo):
if len(self.SectionHeaderContent) == 0:
Logger.Error("InfParser",
Logger.Error("InfParser",
FORMAT_INVALID,
ST.ERR_INF_PARSER_DEFINE_SECTION_HEADER_INVALID,
File=self.FullPath,
@@ -431,7 +431,7 @@ class InfParser(InfSectionParser):
for SectionItem in self.SectionHeaderContent:
ArchList = []
#
# Not cover Depex/UserExtension section header
# Not cover Depex/UserExtension section header
# check.
#
if SectionItem[0].strip().upper() == DT.TAB_INF_FIXED_PCD.upper() or \
@@ -442,15 +442,15 @@ class InfParser(InfSectionParser):
ArchList = GetSplitValueList(SectionItem[1].strip(), ' ')
else:
ArchList = [SectionItem[1].strip()]
for Arch in ArchList:
if (not IsValidArch(Arch)) and \
(SectionItem[0].strip().upper() != DT.TAB_DEPEX.upper()) and \
(SectionItem[0].strip().upper() != DT.TAB_USER_EXTENSIONS.upper()) and \
(SectionItem[0].strip().upper() != DT.TAB_COMMON_DEFINES.upper()):
Logger.Error("InfParser",
Logger.Error("InfParser",
FORMAT_INVALID,
ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(SectionItem[1]),
ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(SectionItem[1]),
File=self.FullPath,
Line=LineNo, ExtraData=Line)
#
@@ -467,11 +467,11 @@ class InfParser(InfSectionParser):
ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID%(SectionItem[2]),
File=self.FullPath, Line=LineNo,
ExtraData=Line)
## _CallSectionParsers
#
#
def _CallSectionParsers(self, CurrentSection, DefineSectionParsedFlag,
def _CallSectionParsers(self, CurrentSection, DefineSectionParsedFlag,
SectionLines, InfSectionCommonDefObj, LineNo):
if CurrentSection == DT.MODEL_META_DATA_DEFINE:
if not DefineSectionParsedFlag:
@@ -481,22 +481,22 @@ class InfParser(InfSectionParser):
InfSectionCommonDefObj)
DefineSectionParsedFlag = True
else:
Logger.Error("Parser",
PARSER_ERROR,
ST.ERR_INF_PARSER_MULTI_DEFINE_SECTION,
File=self.FullPath,
Logger.Error("Parser",
PARSER_ERROR,
ST.ERR_INF_PARSER_MULTI_DEFINE_SECTION,
File=self.FullPath,
RaiseError = Logger.IS_RAISE_ERROR)
elif CurrentSection == DT.MODEL_META_DATA_BUILD_OPTION:
self.InfBuildOptionParser(SectionLines,
self.InfBuildOptionSection,
self.FullPath)
elif CurrentSection == DT.MODEL_EFI_LIBRARY_CLASS:
self.InfLibraryParser(SectionLines,
self.InfLibraryClassSection,
self.FullPath)
elif CurrentSection == DT.MODEL_META_DATA_PACKAGE:
self.InfPackageParser(SectionLines,
self.InfPackageSection,
@@ -512,37 +512,37 @@ class InfParser(InfSectionParser):
self.InfPcdParser(SectionLines,
self.InfPcdSection,
self.FullPath)
elif CurrentSection == DT.MODEL_EFI_SOURCE_FILE:
self.InfSourceParser(SectionLines,
self.InfSourcesSection,
self.FullPath)
elif CurrentSection == DT.MODEL_META_DATA_USER_EXTENSION:
self.InfUserExtensionParser(SectionLines,
self.InfUserExtensionSection,
self.FullPath)
elif CurrentSection == DT.MODEL_EFI_PROTOCOL:
self.InfProtocolParser(SectionLines,
self.InfProtocolSection,
self.FullPath)
elif CurrentSection == DT.MODEL_EFI_PPI:
self.InfPpiParser(SectionLines,
self.InfPpiSection,
self.FullPath)
elif CurrentSection == DT.MODEL_EFI_GUID:
self.InfGuidParser(SectionLines,
self.InfGuidSection,
self.FullPath)
elif CurrentSection == DT.MODEL_EFI_DEPEX:
self.InfDepexParser(SectionLines,
self.InfDepexSection,
self.FullPath)
elif CurrentSection == DT.MODEL_EFI_BINARY_FILE:
self.InfBinaryParser(SectionLines,
self.InfBinariesSection,
@@ -552,20 +552,20 @@ class InfParser(InfSectionParser):
#
else:
if len(self.SectionHeaderContent) >= 1:
Logger.Error("Parser",
PARSER_ERROR,
ST.ERR_INF_PARSER_UNKNOWN_SECTION,
File=self.FullPath, Line=LineNo,
Logger.Error("Parser",
PARSER_ERROR,
ST.ERR_INF_PARSER_UNKNOWN_SECTION,
File=self.FullPath, Line=LineNo,
RaiseError = Logger.IS_RAISE_ERROR)
else:
Logger.Error("Parser",
PARSER_ERROR,
ST.ERR_INF_PARSER_NO_SECTION_ERROR,
File=self.FullPath, Line=LineNo,
Logger.Error("Parser",
PARSER_ERROR,
ST.ERR_INF_PARSER_NO_SECTION_ERROR,
File=self.FullPath, Line=LineNo,
RaiseError = Logger.IS_RAISE_ERROR)
return DefineSectionParsedFlag
return DefineSectionParsedFlag
def _ExtractEventHobBootMod(self, FileLinesList):
SpecialSectionStart = False
CheckLocation = False
@@ -607,43 +607,43 @@ class InfParser(InfSectionParser):
elif not Line:
SpecialSectionStart = False
CheckLocation = True
Element = []
Element = []
else:
if not Line.startswith(DT.TAB_COMMENT_SPLIT):
Logger.Warn("Parser",
ST.WARN_SPECIAL_SECTION_LOCATION_WRONG,
Logger.Warn("Parser",
ST.WARN_SPECIAL_SECTION_LOCATION_WRONG,
File=self.FullPath, Line=LineNum)
SpecialSectionStart = False
CheckLocation = False
Element = []
else:
Element.append([Line, LineNum])
Element.append([Line, LineNum])
else:
if CheckLocation:
if MatchObject:
CheckLocation = False
elif Line:
Logger.Warn("Parser",
ST.WARN_SPECIAL_SECTION_LOCATION_WRONG,
File=self.FullPath, Line=LineNum)
Logger.Warn("Parser",
ST.WARN_SPECIAL_SECTION_LOCATION_WRONG,
File=self.FullPath, Line=LineNum)
CheckLocation = False
if len(self.BootModeList) >= 1:
self.InfSpecialCommentParser(self.BootModeList,
self.InfSpecialCommentSection,
self.FileName,
DT.TYPE_BOOTMODE_SECTION)
if len(self.EventList) >= 1:
self.InfSpecialCommentParser(self.EventList,
self.InfSpecialCommentParser(self.BootModeList,
self.InfSpecialCommentSection,
self.FileName,
self.FileName,
DT.TYPE_BOOTMODE_SECTION)
if len(self.EventList) >= 1:
self.InfSpecialCommentParser(self.EventList,
self.InfSpecialCommentSection,
self.FileName,
DT.TYPE_EVENT_SECTION)
if len(self.HobList) >= 1:
self.InfSpecialCommentParser(self.HobList,
self.InfSpecialCommentSection,
self.FileName,
self.InfSpecialCommentParser(self.HobList,
self.InfSpecialCommentSection,
self.FileName,
DT.TYPE_HOB_SECTION)
## _ProcessLastSection
#
@@ -652,35 +652,35 @@ class InfParser(InfSectionParser):
#
# The last line is a section header. will discard it.
#
if not (Line.startswith(DT.TAB_SECTION_START) and Line.find(DT.TAB_SECTION_END) > -1):
if not (Line.startswith(DT.TAB_SECTION_START) and Line.find(DT.TAB_SECTION_END) > -1):
SectionLines.append((Line, LineNo))
if len(self.SectionHeaderContent) >= 1:
TemSectionName = self.SectionHeaderContent[0][0].upper()
if TemSectionName.upper() not in gINF_SECTION_DEF.keys():
Logger.Error("InfParser",
FORMAT_INVALID,
ST.ERR_INF_PARSER_UNKNOWN_SECTION,
File=self.FullPath,
Line=LineNo,
Logger.Error("InfParser",
FORMAT_INVALID,
ST.ERR_INF_PARSER_UNKNOWN_SECTION,
File=self.FullPath,
Line=LineNo,
ExtraData=Line,
RaiseError = Logger.IS_RAISE_ERROR
)
)
else:
CurrentSection = gINF_SECTION_DEF[TemSectionName]
self.LastSectionHeaderContent = self.SectionHeaderContent
return SectionLines, CurrentSection
## _ConvertSecNameToType
#
#
def _ConvertSecNameToType(SectionName):
def _ConvertSecNameToType(SectionName):
SectionType = ''
if SectionName.upper() not in gINF_SECTION_DEF.keys():
SectionType = DT.MODEL_UNKNOWN
SectionType = DT.MODEL_UNKNOWN
else:
SectionType = gINF_SECTION_DEF[SectionName.upper()]
return SectionType
SectionType = gINF_SECTION_DEF[SectionName.upper()]
return SectionType

View File

@@ -1,11 +1,11 @@
## @file
# This file contained the miscellaneous functions for INF parser
# This file contained the miscellaneous functions for INF parser
#
# Copyright (c) 2011 - 2018, 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,
@@ -59,39 +59,39 @@ gINF_SECTION_DEF = {
#
# EDK1 section
# TAB_NMAKE.upper() : MODEL_META_DATA_NMAKE
#
#
}
## InfExpandMacro
#
# Expand MACRO definition with MACROs defined in [Defines] section and specific section.
# Expand MACRO definition with MACROs defined in [Defines] section and specific section.
# The MACROs defined in specific section has high priority and will be expanded firstly.
#
# @param LineInfo Contain information of FileName, LineContent, LineNo
# @param GlobalMacros MACROs defined in INF [Defines] section
# @param SectionMacros MACROs defined in INF specific section
# @param Flag If the flag set to True, need to skip macros in a quoted string
# @param Flag If the flag set to True, need to skip macros in a quoted string
#
def InfExpandMacro(Content, LineInfo, GlobalMacros=None, SectionMacros=None, Flag=False):
if GlobalMacros is None:
GlobalMacros = {}
if SectionMacros is None:
SectionMacros = {}
FileName = LineInfo[0]
LineContent = LineInfo[1]
LineNo = LineInfo[2]
# Don't expand macros in comments
if LineContent.strip().startswith("#"):
return Content
NewLineInfo = (FileName, LineNo, LineContent)
#
# First, replace MARCOs with value defined in specific section
#
Content = ReplaceMacro (Content,
Content = ReplaceMacro (Content,
SectionMacros,
False,
(LineContent, LineNo),
@@ -100,13 +100,13 @@ def InfExpandMacro(Content, LineInfo, GlobalMacros=None, SectionMacros=None, Fla
#
# Then replace MARCOs with value defined in [Defines] section
#
Content = ReplaceMacro (Content,
Content = ReplaceMacro (Content,
GlobalMacros,
False,
(LineContent, LineNo),
FileName,
Flag)
MacroUsed = gMACRO_PATTERN.findall(Content)
#
# no macro found in String, stop replacing
@@ -122,9 +122,9 @@ def InfExpandMacro(Content, LineInfo, GlobalMacros=None, SectionMacros=None, Fla
#
ErrorInInf (ERR_MARCO_DEFINITION_MISS_ERROR,
LineInfo=NewLineInfo)
return Content
## IsBinaryInf
#
@@ -135,25 +135,25 @@ def InfExpandMacro(Content, LineInfo, GlobalMacros=None, SectionMacros=None, Fla
def IsBinaryInf(FileLineList):
if not FileLineList:
return False
ReIsSourcesSection = re.compile("^\s*\[Sources.*\]\s.*$", re.IGNORECASE)
ReIsBinarySection = re.compile("^\s*\[Binaries.*\]\s.*$", re.IGNORECASE)
BinarySectionFoundFlag = False
for Line in FileLineList:
if ReIsSourcesSection.match(Line):
return False
if ReIsBinarySection.match(Line):
BinarySectionFoundFlag = True
if BinarySectionFoundFlag:
return True
return False
## IsLibInstanceInfo
#
#
# Judge whether the string contain the information of ## @LIB_INSTANCES.
#
# @param String
@@ -166,10 +166,10 @@ def IsLibInstanceInfo(String):
return True
else:
return False
## IsAsBuildOptionInfo
#
#
# Judge whether the string contain the information of ## @ASBUILD.
#
# @param String
@@ -181,8 +181,8 @@ def IsAsBuildOptionInfo(String):
if ReIsAsBuildInstance.match(String):
return True
else:
return False
return False
class InfParserSectionRoot(object):
def __init__(self):
@@ -190,19 +190,19 @@ class InfParserSectionRoot(object):
# Macros defined in [Define] section are file scope global
#
self.FileLocalMacros = {}
#
# Current Section Header content.
# Current Section Header content.
#
self.SectionHeaderContent = []
#
# Last time Section Header content.
# Last time Section Header content.
#
self.LastSectionHeaderContent = []
self.LastSectionHeaderContent = []
self.FullPath = ''
self.InfDefSection = None
self.InfBuildOptionSection = None
self.InfLibraryClassSection = None
@@ -219,4 +219,4 @@ class InfParserSectionRoot(object):
self.InfSmmDepexSection = None
self.InfBinariesSection = None
self.InfHeader = None
self.InfSpecialCommentSection = None
self.InfSpecialCommentSection = None

View File

@@ -1,11 +1,11 @@
## @file
# This file contained the parser for [Pcds] sections in INF file
# This file contained the parser for [Pcds] sections in INF file
#
# Copyright (c) 2011 - 2018, 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,
@@ -31,49 +31,49 @@ from Parser.InfParserMisc import InfParserSectionRoot
class InfPcdSectionParser(InfParserSectionRoot):
## Section PCD related parser
#
#
# For 5 types of PCD list below, all use this function.
# 'FixedPcd', 'FeaturePcd', 'PatchPcd', 'Pcd', 'PcdEx'
#
# This is a INF independent parser, the validation in this parser only
# This is a INF independent parser, the validation in this parser only
# cover
# INF spec scope, will not cross DEC/DSC to check pcd value
#
def InfPcdParser(self, SectionString, InfSectionObject, FileName):
KeysList = []
PcdList = []
CommentsList = []
ValueList = []
CommentsList = []
ValueList = []
#
# Current section archs
#
#
LineIndex = -1
for Item in self.LastSectionHeaderContent:
if (Item[0], Item[1], Item[3]) not in KeysList:
KeysList.append((Item[0], Item[1], Item[3]))
LineIndex = Item[3]
if (Item[0].upper() == DT.TAB_INF_FIXED_PCD.upper() or \
Item[0].upper() == DT.TAB_INF_FEATURE_PCD.upper() or \
Item[0].upper() == DT.TAB_INF_PCD.upper()) and GlobalData.gIS_BINARY_INF:
Logger.Error('InfParser', FORMAT_INVALID, ST.ERR_ASBUILD_PCD_SECTION_TYPE%("\"" + Item[0] + "\""),
File=FileName, Line=LineIndex)
File=FileName, Line=LineIndex)
#
# For Common INF file
#
if not GlobalData.gIS_BINARY_INF:
if not GlobalData.gIS_BINARY_INF:
#
# Macro defined in this section
# Macro defined in this section
#
SectionMacros = {}
SectionMacros = {}
for Line in SectionString:
PcdLineContent = Line[0]
PcdLineNo = Line[1]
if PcdLineContent.strip() == '':
CommentsList = []
continue
continue
if PcdLineContent.strip().startswith(DT.TAB_COMMENT_SPLIT):
CommentsList.append(Line)
continue
@@ -83,10 +83,10 @@ class InfPcdSectionParser(InfParserSectionRoot):
#
if PcdLineContent.find(DT.TAB_COMMENT_SPLIT) > -1:
CommentsList.append((
PcdLineContent[PcdLineContent.find(DT.TAB_COMMENT_SPLIT):],
PcdLineContent[PcdLineContent.find(DT.TAB_COMMENT_SPLIT):],
PcdLineNo))
PcdLineContent = PcdLineContent[:PcdLineContent.find(DT.TAB_COMMENT_SPLIT)]
PcdLineContent = PcdLineContent[:PcdLineContent.find(DT.TAB_COMMENT_SPLIT)]
if PcdLineContent != '':
#
# Find Macro
@@ -100,23 +100,23 @@ class InfPcdSectionParser(InfParserSectionRoot):
ValueList = []
CommentsList = []
continue
PcdEntryReturn = SplitPcdEntry(PcdLineContent)
if not PcdEntryReturn[1]:
TokenList = ['']
TokenList = ['']
else:
TokenList = PcdEntryReturn[0]
ValueList[0:len(TokenList)] = TokenList
#
# Replace with Local section Macro and [Defines] section Macro.
#
ValueList = [InfExpandMacro(Value, (FileName, PcdLineContent, PcdLineNo),
#
ValueList = [InfExpandMacro(Value, (FileName, PcdLineContent, PcdLineNo),
self.FileLocalMacros, SectionMacros, True)
for Value in ValueList]
if len(ValueList) >= 1:
PcdList.append((ValueList, CommentsList, (PcdLineContent, PcdLineNo, FileName)))
ValueList = []
@@ -129,11 +129,11 @@ class InfPcdSectionParser(InfParserSectionRoot):
for Line in SectionString:
LineContent = Line[0].strip()
LineNo = Line[1]
if LineContent == '':
CommentsList = []
continue
if LineContent.startswith(DT.TAB_COMMENT_SPLIT):
CommentsList.append(LineContent)
continue
@@ -144,7 +144,7 @@ class InfPcdSectionParser(InfParserSectionRoot):
if CommentIndex > -1:
CommentsList.append(LineContent[CommentIndex+1:])
LineContent = LineContent[:CommentIndex]
TokenList = GetSplitValueList(LineContent, DT.TAB_VALUE_SPLIT)
#
# PatchablePcd
@@ -152,33 +152,33 @@ class InfPcdSectionParser(InfParserSectionRoot):
#
if KeysList[0][0].upper() == DT.TAB_INF_PATCH_PCD.upper():
if len(TokenList) != 3:
Logger.Error('InfParser',
FORMAT_INVALID,
Logger.Error('InfParser',
FORMAT_INVALID,
ST.ERR_ASBUILD_PATCHPCD_FORMAT_INVALID,
File=FileName,
Line=LineNo,
ExtraData=LineContent)
#
#
elif KeysList[0][0].upper() == DT.TAB_INF_PCD_EX.upper():
if len(TokenList) != 1:
Logger.Error('InfParser',
FORMAT_INVALID,
Logger.Error('InfParser',
FORMAT_INVALID,
ST.ERR_ASBUILD_PCDEX_FORMAT_INVALID,
File=FileName,
Line=LineNo,
ExtraData=LineContent)
ValueList[0:len(TokenList)] = TokenList
if len(ValueList) >= 1:
PcdList.append((ValueList, CommentsList, (LineContent, LineNo, FileName)))
if len(ValueList) >= 1:
PcdList.append((ValueList, CommentsList, (LineContent, LineNo, FileName)))
ValueList = []
CommentsList = []
continue
if not InfSectionObject.SetPcds(PcdList, KeysList = KeysList,
continue
if not InfSectionObject.SetPcds(PcdList, KeysList = KeysList,
PackageInfo = self.InfPackageSection.GetPackages()):
Logger.Error('InfParser',
FORMAT_INVALID,
Logger.Error('InfParser',
FORMAT_INVALID,
ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR%("[PCD]"),
File=FileName,
Line=LineIndex)
Line=LineIndex)

View File

@@ -1,11 +1,11 @@
## @file
# This file contained the parser for sections in INF file
# This file contained the parser for sections in INF file
#
# Copyright (c) 2011 - 2018, 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,
@@ -95,7 +95,7 @@ def GetSpecialStr2(ItemList, FileName, LineNo, SectionString):
if ItemList[3] != '':
Logger.Error('Parser', FORMAT_INVALID, ST.ERR_INF_PARSER_SOURCE_SECTION_SECTIONNAME_INVALID \
% (SectionString), File=FileName, Line=LineNo, ExtraData=SectionString)
if not ItemList[0].upper() == DT.TAB_USER_EXTENSIONS.upper():
Str2 = ItemList[2] + ' | ' + ItemList[3]
else:
@@ -108,7 +108,7 @@ def GetSpecialStr2(ItemList, FileName, LineNo, SectionString):
return Str2
## ProcessUseExtHeader
#
#
#
def ProcessUseExtHeader(ItemList):
NewItemList = []
@@ -138,12 +138,12 @@ def ProcessUseExtHeader(ItemList):
NewItemList.append(Item)
else:
AppendContent = AppendContent + "." + Item
if len(NewItemList) > 4:
return False, []
return True, NewItemList
## GetArch
#
# GetArch
@@ -244,7 +244,7 @@ class InfSectionParser(InfDefinSectionParser,
#
# A List for store define section content.
#
#
self._PcdNameList = []
self._SectionName = ''
self._SectionType = 0
@@ -253,7 +253,7 @@ class InfSectionParser(InfDefinSectionParser,
#
# File Header content parser
#
#
def InfHeaderParser(self, Content, InfHeaderObject2, FileName, IsBinaryHeader = False):
if IsBinaryHeader:
(Abstract, Description, Copyright, License) = ParseHeaderCommentSection(Content, FileName, True)
@@ -272,7 +272,7 @@ class InfSectionParser(InfDefinSectionParser,
#
# Insert Abstract, Description, CopyRight, License into header object
#
#
InfHeaderObject2.SetAbstract(Abstract)
InfHeaderObject2.SetDescription(Description)
InfHeaderObject2.SetCopyright(Copyright)
@@ -287,7 +287,7 @@ class InfSectionParser(InfDefinSectionParser,
#
# [section_name.arch<.platform|module_type>]
#
# @param String A string contained the content need to be parsed.
# @param String A string contained the content need to be parsed.
#
def SectionHeaderParser(self, SectionString, FileName, LineNo):
_Scope = []
@@ -313,7 +313,7 @@ class InfSectionParser(InfDefinSectionParser,
#
# different section should not mix in one section
# Allow different PCD type sections mixed together
#
#
if _SectionName.upper() not in _PcdNameList:
if _SectionName != '' and _SectionName.upper() != ItemList[0].upper():
Logger.Error('Parser',
@@ -350,7 +350,7 @@ class InfSectionParser(InfDefinSectionParser,
#
# For [Defines] section, do special check.
#
#
if ItemList[0].upper() == DT.TAB_COMMON_DEFINES.upper():
if len(ItemList) != 1:
Logger.Error('Parser',
@@ -360,26 +360,26 @@ class InfSectionParser(InfDefinSectionParser,
#
# For [UserExtension] section, do special check.
#
#
if ItemList[0].upper() == DT.TAB_USER_EXTENSIONS.upper():
RetValue = ProcessUseExtHeader(ItemList)
if not RetValue[0]:
Logger.Error('Parser',
FORMAT_INVALID,
ST.ERR_INF_PARSER_DEFINE_FROMAT_INVALID % (SectionString),
File=FileName, Line=LineNo, ExtraData=SectionString)
else:
ItemList = RetValue[1]
ItemList = RetValue[1]
if len(ItemList) == 3:
ItemList.append('COMMON')
Str1 = ItemList[1]
#
# For Library classes, need to check module type.
# For Library classes, need to check module type.
#
if ItemList[0].upper() == DT.TAB_LIBRARY_CLASSES.upper() and len(ItemList) == 3:
if ItemList[2] != '':
@@ -424,10 +424,10 @@ class InfSectionParser(InfDefinSectionParser,
## GenSpecialSectionList
#
# @param SpecialSectionList: a list of list, of which item's format
# @param SpecialSectionList: a list of list, of which item's format
# (Comment, LineNum)
# @param ContainerFile: Input value for filename of Inf file
#
#
def InfSpecialCommentParser (self, SpecialSectionList, InfSectionObject, ContainerFile, SectionType):
ReFindSpecialCommentRe = re.compile(r"""#(?:\s*)\[(.*?)\](?:.*)""", re.DOTALL)
ReFindHobArchRe = re.compile(r"""[Hh][Oo][Bb]\.([^,]*)""", re.DOTALL)

View File

@@ -1,11 +1,11 @@
## @file
# This file contained the parser for [Sources] sections in INF file
# This file contained the parser for [Sources] sections in INF file
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -31,7 +31,7 @@ from Parser.InfParserMisc import InfParserSectionRoot
class InfSourceSectionParser(InfParserSectionRoot):
## InfSourceParser
#
#
#
def InfSourceParser(self, SectionString, InfSectionObject, FileName):
SectionMacros = {}
ValueList = []
@@ -43,12 +43,12 @@ class InfSourceSectionParser(InfParserSectionRoot):
for Line in SectionString:
SrcLineContent = Line[0]
SrcLineNo = Line[1]
if SrcLineContent.strip() == '':
continue
#
# Found Header Comments
# Found Header Comments
#
if SrcLineContent.strip().startswith(DT.TAB_COMMENT_SPLIT):
#
@@ -59,7 +59,7 @@ class InfSourceSectionParser(InfParserSectionRoot):
SectionContent += SrcLineContent + DT.END_OF_LINE
continue
#
# First time encounter comment
# First time encounter comment
#
else:
#
@@ -68,18 +68,18 @@ class InfSourceSectionParser(InfParserSectionRoot):
HeaderComments = []
HeaderComments.append(Line)
StillCommentFalg = True
SectionContent += SrcLineContent + DT.END_OF_LINE
SectionContent += SrcLineContent + DT.END_OF_LINE
continue
else:
StillCommentFalg = False
if len(HeaderComments) >= 1:
LineComment = InfLineCommentObject()
LineCommentContent = ''
for Item in HeaderComments:
LineCommentContent += Item[0] + DT.END_OF_LINE
LineComment.SetHeaderComments(LineCommentContent)
#
# Find Tail comment.
#
@@ -89,11 +89,11 @@ class InfSourceSectionParser(InfParserSectionRoot):
if LineComment is None:
LineComment = InfLineCommentObject()
LineComment.SetTailComments(TailComments)
#
# Find Macro
#
Name, Value = MacroParser((SrcLineContent, SrcLineNo),
Name, Value = MacroParser((SrcLineContent, SrcLineNo),
FileName,
DT.MODEL_EFI_SOURCE_FILE,
self.FileLocalMacros)
@@ -102,44 +102,44 @@ class InfSourceSectionParser(InfParserSectionRoot):
LineComment = None
HeaderComments = []
continue
#
# Replace with Local section Macro and [Defines] section Macro.
#
SrcLineContent = InfExpandMacro(SrcLineContent,
(FileName, SrcLineContent, SrcLineNo),
self.FileLocalMacros,
#
SrcLineContent = InfExpandMacro(SrcLineContent,
(FileName, SrcLineContent, SrcLineNo),
self.FileLocalMacros,
SectionMacros)
TokenList = GetSplitValueList(SrcLineContent, DT.TAB_VALUE_SPLIT, 4)
ValueList[0:len(TokenList)] = TokenList
#
# Store section content string after MACRO replaced.
#
SectionContent += SrcLineContent + DT.END_OF_LINE
SourceList.append((ValueList, LineComment,
SectionContent += SrcLineContent + DT.END_OF_LINE
SourceList.append((ValueList, LineComment,
(SrcLineContent, SrcLineNo, FileName)))
ValueList = []
LineComment = None
TailComments = ''
HeaderComments = []
continue
#
# Current section archs
#
ArchList = []
for Item in self.LastSectionHeaderContent:
if Item[1] not in ArchList:
ArchList.append(Item[1])
ArchList.append(Item[1])
InfSectionObject.SetSupArchList(Item[1])
InfSectionObject.SetAllContent(SectionContent)
InfSectionObject.SetAllContent(SectionContent)
if not InfSectionObject.SetSources(SourceList, Arch = ArchList):
Logger.Error('InfParser',
Logger.Error('InfParser',
FORMAT_INVALID,
ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR % ("[Sources]"),
File=FileName,
Line=Item[3])
File=FileName,
Line=Item[3])

View File

@@ -4,11 +4,11 @@
# This file is required to make Python interpreter treat the directory
# as containing package.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -17,4 +17,4 @@
'''
Parser
'''
'''

View File

@@ -1,11 +1,11 @@
## @file DecPomAlignment.py
# This file contained the adapter for convert INF parser object to POM Object
#
# Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -106,17 +106,17 @@ class DecPomAlignment(PackageObject):
self.DecParser = None
self.UniFileClassObject = None
self.PcdDefaultValueDict = {}
#
# Load Dec file
#
self.LoadDecFile(Filename)
#
# Transfer to Package Object if IsToPackage is True
#
self.DecToPackage()
## Load Dec file
#
# Load the file if it exists
@@ -132,13 +132,13 @@ class DecPomAlignment(PackageObject):
self.SetFullPath(Filename)
self.SetRelaPath(Path)
self.SetFileName(Name)
self.SetPackagePath(GetRelativePath(Path, self.WorkspaceDir))
self.SetPackagePath(GetRelativePath(Path, self.WorkspaceDir))
self.SetCombinePath(GetRelativePath(Filename, self.WorkspaceDir))
self.DecParser = Dec(Filename)
## Transfer to Package Object
#
#
# Transfer all contents of a Dec file to a standard Package Object
#
def DecToPackage(self):
@@ -146,12 +146,12 @@ class DecPomAlignment(PackageObject):
# Init global information for the file
#
ContainerFile = self.GetFullPath()
#
# Generate Package Header
#
self.GenPackageHeader(ContainerFile)
#
# Generate Includes
#
@@ -171,28 +171,28 @@ class DecPomAlignment(PackageObject):
# Generate Ppis
#
self.GenGuidProtocolPpis(TAB_PPIS, ContainerFile)
#
# Generate LibraryClasses
#
self.GenLibraryClasses(ContainerFile)
#
# Generate Pcds
#
self.GenPcds(ContainerFile)
#
# Generate Module File list, will be used later on to generate
# Generate Module File list, will be used later on to generate
# distribution
#
self.GenModuleFileList(ContainerFile)
#
# Generate user extensions
#
self.GenUserExtensions()
## Generate user extension
#
#
@@ -231,7 +231,7 @@ class DecPomAlignment(PackageObject):
PrivateUserExtension.SetIdentifier(DT.TAB_PRIVATE)
PrivateUserExtension.SetUserID(DT.TAB_INTEL)
self.SetUserExtensionList(self.GetUserExtensionList() + [PrivateUserExtension])
## Generate miscellaneous files on DEC file
#
#
@@ -249,23 +249,23 @@ class DecPomAlignment(PackageObject):
FileObj.SetURI(FileName)
MiscFileObj.SetFileList(MiscFileObj.GetFileList()+[FileObj])
else:
Logger.Error("InfParser",
Logger.Error("InfParser",
FORMAT_INVALID,
ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(Line),
File=self.GetFileName(),
ExtraData=Line)
self.SetMiscFileList(self.GetMiscFileList()+[MiscFileObj])
ExtraData=Line)
self.SetMiscFileList(self.GetMiscFileList()+[MiscFileObj])
## Generate Package Header
#
# Gen Package Header of Dec as <Key> = <Value>
#
# @param ContainerFile: The Dec file full path
# @param ContainerFile: The Dec file full path
#
def GenPackageHeader(self, ContainerFile):
Logger.Debug(2, "Generate PackageHeader ...")
DefinesDict = {}
#
# Update all defines item in database
#
@@ -293,12 +293,12 @@ class DecPomAlignment(PackageObject):
UniFileClassObject([PathClass(os.path.join(DefObj.GetPackagePath(), DefObj.GetPackageUniFile()))])
else:
self.UniFileClassObject = None
if DefinesDict:
UserExtension = UserExtensionObject()
UserExtension.SetDefinesDict(DefinesDict)
UserExtension.SetIdentifier('DefineModifiers')
UserExtension.SetUserID('EDK2')
UserExtension.SetUserID('EDK2')
self.SetUserExtensionList(
self.GetUserExtensionList() + [UserExtension]
)
@@ -321,7 +321,7 @@ class DecPomAlignment(PackageObject):
self.SetCopyright(('', Copyright))
if License:
self.SetLicense(('', License))
#
# Get Binary header information
#
@@ -329,7 +329,7 @@ class DecPomAlignment(PackageObject):
Abstract, Description, Copyright, License = \
ParseHeaderCommentSection(self.DecParser.BinaryHeadComment,
ContainerFile, True)
if not Abstract or not Description or not Copyright or not License:
Logger.Error('MkPkg',
FORMAT_INVALID,
@@ -343,7 +343,7 @@ class DecPomAlignment(PackageObject):
BinaryAbstractList = []
BinaryDescriptionList = []
#Get Binary header from UNI file
# Initialize the UniStrDict dictionary, top keys are language codes
UniStrDict = {}
@@ -359,7 +359,7 @@ class DecPomAlignment(PackageObject):
if StringDefClassObject.StringName == TAB_DEC_BINARY_DESCRIPTION:
if (Lang, ConvertSpecialUnicodes(StringDefClassObject.StringValue)) \
not in self.GetBinaryHeaderDescription():
BinaryDescriptionList.append((Lang,
BinaryDescriptionList.append((Lang,
ConvertSpecialUnicodes(StringDefClassObject.StringValue)))
#Combine Binary header from DEC file and UNI file
BinaryAbstractList = self.GetBinaryHeaderAbstract() + BinaryAbstractList
@@ -376,13 +376,13 @@ class DecPomAlignment(PackageObject):
BinaryUserExtension.SetIdentifier(TAB_BINARY_HEADER_IDENTIFIER)
BinaryUserExtension.SetUserID(TAB_BINARY_HEADER_USERID)
self.SetUserExtensionList(self.GetUserExtensionList() + [BinaryUserExtension])
## GenIncludes
#
# Gen Includes of Dec
#
# @param ContainerFile: The Dec file full path
#
# @param ContainerFile: The Dec file full path
#
def GenIncludes(self, ContainerFile):
if ContainerFile:
@@ -402,17 +402,17 @@ class DecPomAlignment(PackageObject):
IncludesDict[IncludePath] = IncludesDict[IncludePath] + Item.GetArchList()
else:
IncludesDict[IncludePath] = Item.GetArchList()
#
#
# get the standardIncludeFileList(industry), packageIncludeFileList
# (others) for PackageObject
#
# (others) for PackageObject
#
PackagePath = os.path.split(self.GetFullPath())[0]
IncludePathList = \
sorted([os.path.normpath(Path) + sep for Path in IncludesDict.keys()])
#
# get a non-overlap set of include path, IncludePathList should be
# get a non-overlap set of include path, IncludePathList should be
# sorted, and path should be end with path seperator '\'
#
NonOverLapList = []
@@ -429,7 +429,7 @@ class DecPomAlignment(PackageObject):
#
for IndexN in range (0, len(IncludePathList)):
IncludePathList[IndexN] = os.path.normpath(IncludePathList[IndexN])
IncludePathList.sort()
IncludePathList.sort()
IncludePathList.reverse()
#
# save the include path list for later usage
@@ -437,7 +437,7 @@ class DecPomAlignment(PackageObject):
self.SetIncludePathList(IncludePathList)
StandardIncludeFileList = []
PackageIncludeFileList = []
IncludeFileList = []
for Path in NonOverLapList:
FileList = GetFiles(os.path.join(PackagePath, Path), ['CVS', '.svn'], False)
@@ -445,9 +445,9 @@ class DecPomAlignment(PackageObject):
for Includefile in IncludeFileList:
ExtName = os.path.splitext(Includefile)[1]
if ExtName.upper() == '.DEC' and self.CheckMulDec:
Logger.Error('MkPkg',
Logger.Error('MkPkg',
UPT_MUL_DEC_ERROR,
ST.ERR_MUL_DEC_ERROR%(os.path.dirname(ContainerFile),
ST.ERR_MUL_DEC_ERROR%(os.path.dirname(ContainerFile),
os.path.basename(ContainerFile),
Includefile))
@@ -462,15 +462,15 @@ class DecPomAlignment(PackageObject):
if Includefile.find('IndustryStandard') != -1:
StandardIncludeFileList.append(Include)
else:
PackageIncludeFileList.append(Include)
PackageIncludeFileList.append(Include)
self.SetStandardIncludeFileList(StandardIncludeFileList)
#
# put include path into the PackageIncludeFileList
#
PackagePathList = []
IncObj = self.DecParser.GetIncludeSectionObject()
IncObj = self.DecParser.GetIncludeSectionObject()
for Item in IncObj.GetAllIncludes():
IncludePath = Item.File
Include = IncludeObject()
@@ -478,13 +478,13 @@ class DecPomAlignment(PackageObject):
Include.SetSupArchList(Item.GetArchList())
PackagePathList.append(Include)
self.SetPackageIncludeFileList(PackagePathList + PackageIncludeFileList)
## GenPpis
#
# Gen Ppis of Dec
# <CName>=<GuidValue>
#
# @param ContainerFile: The Dec file full path
# @param ContainerFile: The Dec file full path
#
def GenGuidProtocolPpis(self, Type, ContainerFile):
if ContainerFile:
@@ -504,7 +504,7 @@ class DecPomAlignment(PackageObject):
Factory = CreateGuidObject
elif Type == TAB_PROTOCOLS:
Obj = self.DecParser.GetProtocolSectionObject()
def CreateProtocolObject():
return ProtocolObject()
Factory = CreateProtocolObject
@@ -519,9 +519,9 @@ class DecPomAlignment(PackageObject):
# Should not be here
#
return
DeclarationsList = []
#
# Go through each arch
#
@@ -530,7 +530,7 @@ class DecPomAlignment(PackageObject):
Value = Item.GuidString
HelpTxt = ParseGenericComment(Item.GetHeadComment() + \
Item.GetTailComment())
ListObject = Factory()
ListObject.SetCName(Name)
ListObject.SetGuid(Value)
@@ -539,10 +539,10 @@ class DecPomAlignment(PackageObject):
if self.UniFileClassObject:
HelpTxt.SetLang(TAB_LANGUAGE_EN_X)
ListObject.SetHelpTextList([HelpTxt])
DeclarationsList.append(ListObject)
#
#
#GuidTypeList is abstracted from help
#
if Type == TAB_GUIDS:
@@ -551,20 +551,20 @@ class DecPomAlignment(PackageObject):
self.SetProtocolList(self.GetProtocolList() + DeclarationsList)
elif Type == TAB_PPIS:
self.SetPpiList(self.GetPpiList() + DeclarationsList)
## GenLibraryClasses
#
# Gen LibraryClasses of Dec
# <CName>=<GuidValue>
#
# @param ContainerFile: The Dec file full path
# @param ContainerFile: The Dec file full path
#
def GenLibraryClasses(self, ContainerFile):
if ContainerFile:
pass
Logger.Debug(2, "Generate %s ..." % TAB_LIBRARY_CLASSES)
LibraryClassDeclarations = []
LibObj = self.DecParser.GetLibraryClassSectionObject()
for Item in LibObj.GetAllLibraryclasses():
LibraryClass = LibraryClassObject()
@@ -578,44 +578,44 @@ class DecPomAlignment(PackageObject):
HelpTxt.SetLang(TAB_LANGUAGE_EN_X)
LibraryClass.SetHelpTextList([HelpTxt])
LibraryClassDeclarations.append(LibraryClass)
self.SetLibraryClassList(self.GetLibraryClassList() + \
LibraryClassDeclarations)
## GenPcds
#
# Gen Pcds of Dec
# <TokenSpcCName>.<TokenCName>|<Value>|<DatumType>|<Token>
#
# @param ContainerFile: The Dec file full path
# @param ContainerFile: The Dec file full path
#
def GenPcds(self, ContainerFile):
Logger.Debug(2, "Generate %s ..." % TAB_PCDS)
PcdObj = self.DecParser.GetPcdSectionObject()
#
# Get all Pcds
#
#
PcdDeclarations = []
IterList = [
(TAB_PCDS_FIXED_AT_BUILD_NULL, 'FixedPcd'),
(TAB_PCDS_PATCHABLE_IN_MODULE_NULL, 'PatchPcd'),
(TAB_PCDS_PATCHABLE_IN_MODULE_NULL, 'PatchPcd'),
(TAB_PCDS_FEATURE_FLAG_NULL, 'FeaturePcd'),
(TAB_PCDS_DYNAMIC_EX_NULL, 'PcdEx'),
(TAB_PCDS_DYNAMIC_EX_NULL, 'PcdEx'),
(TAB_PCDS_DYNAMIC_NULL, 'Pcd')]
PromptStrList = []
HelpStrList = []
PcdErrStrList = []
# Initialize UniStrDict dictionary, top keys are language codes
UniStrDict = {}
StrList = []
Language = ''
if self.UniFileClassObject:
Language = TAB_LANGUAGE_EN_X
else:
Language = TAB_LANGUAGE_EN_US
if self.UniFileClassObject:
UniStrDict = self.UniFileClassObject.OrderedStringList
for Lang in UniStrDict:
@@ -652,7 +652,7 @@ class DecPomAlignment(PackageObject):
self.DecParser.GetDefineSectionMacro()
)
PcdDeclaration.SetSupArchList(Item.GetArchListOfType(PcdType))
#
# Get PCD error message from PCD error comment section in DEC file
#
@@ -662,7 +662,7 @@ class DecPomAlignment(PackageObject):
Key = (PcdDeclaration.GetTokenSpaceGuidCName(), PcdErr.GetErrorNumber())
PcdErr.SetErrorMessageList(PcdErr.GetErrorMessageList() + \
[(Language, self.DecParser.PcdErrorCommentDict[Key])])
for Index in range(0, len(PromptStrList)):
StrNameList = PromptStrList[Index][1].split('_')
if StrNameList[1].lower() == Item.TokenSpaceGuidCName.lower() and \
@@ -676,7 +676,7 @@ class DecPomAlignment(PackageObject):
break
else:
PcdDeclaration.SetPromptList(PcdDeclaration.GetPromptList() + [TxtObj])
for Index in range(0, len(HelpStrList)):
StrNameList = HelpStrList[Index][1].split('_')
if StrNameList[1].lower() == Item.TokenSpaceGuidCName.lower() and \
@@ -703,7 +703,7 @@ class DecPomAlignment(PackageObject):
(PcdErrStrList[Index][0], PcdErrStrList[Index][2]) not in PcdErr.GetErrorMessageList():
PcdErr.SetErrorMessageList(PcdErr.GetErrorMessageList() + \
[(PcdErrStrList[Index][0], PcdErrStrList[Index][2])])
#
# Check to prevent missing error message if a Pcd has the error code.
#
@@ -715,12 +715,12 @@ class DecPomAlignment(PackageObject):
ST.ERR_DECPARSE_PCD_UNMATCHED_ERRORCODE % PcdErr.GetErrorNumber(),
ContainerFile,
PcdErr.GetLineNum(),
PcdErr.GetFileLine())
PcdErr.GetFileLine())
PcdDeclarations.append(PcdDeclaration)
self.SetPcdList(self.GetPcdList() + PcdDeclarations)
self.CheckPcdValue()
##
# Get error message via language
# @param ErrorMessageList: Error message tuple list the language and its message
@@ -741,17 +741,17 @@ class DecPomAlignment(PackageObject):
return ErrorMessageList[0][1]
except IndexError:
return ''
return ''
return ''
##
# Replace the strings for Python eval function.
# @param ReplaceValue: The string that needs to be replaced.
# @return: The string was replaced, then eval function is always making out it.
# @param ReplaceValue: The string that needs to be replaced.
# @return: The string was replaced, then eval function is always making out it.
def ReplaceForEval(self, ReplaceValue, IsRange=False, IsExpr=False):
if self.FullPath:
pass
#
# deal with "NOT EQ", "NOT LT", "NOT GT", "NOT LE", "NOT GE", "NOT NOT"
# deal with "NOT EQ", "NOT LT", "NOT GT", "NOT LE", "NOT GE", "NOT NOT"
#
NOTNOT_Pattern = '[\t\s]*NOT[\t\s]+NOT[\t\s]*'
NOTGE_Pattern = '[\t\s]*NOT[\t\s]+GE[\t\s]*'
@@ -765,7 +765,7 @@ class DecPomAlignment(PackageObject):
ReplaceValue = re.compile(NOTLE_Pattern).sub('x > ', ReplaceValue)
ReplaceValue = re.compile(NOTGE_Pattern).sub('x < ', ReplaceValue)
ReplaceValue = re.compile(NOTEQ_Pattern).sub('x != ', ReplaceValue)
if IsRange:
ReplaceValue = ReplaceValue.replace('EQ', 'x ==')
ReplaceValue = ReplaceValue.replace('LT', 'x <')
@@ -779,9 +779,9 @@ class DecPomAlignment(PackageObject):
ReplaceValue = ReplaceValue.replace('LT', '<')
ReplaceValue = ReplaceValue.replace('LE', '<=')
ReplaceValue = ReplaceValue.replace('GT', '>')
ReplaceValue = ReplaceValue.replace('GE', '>=')
ReplaceValue = ReplaceValue.replace('XOR', '^')
ReplaceValue = ReplaceValue.replace('GE', '>=')
ReplaceValue = ReplaceValue.replace('XOR', '^')
ReplaceValue = ReplaceValue.replace('AND', 'and')
ReplaceValue = ReplaceValue.replace('&&', ' and ')
ReplaceValue = ReplaceValue.replace('xor', '^')
@@ -789,7 +789,7 @@ class DecPomAlignment(PackageObject):
ReplaceValue = ReplaceValue.replace('||', ' or ')
ReplaceValue = ReplaceValue.replace('NOT', 'not')
if ReplaceValue.find('!') >= 0 and ReplaceValue[ReplaceValue.index('!') + 1] != '=':
ReplaceValue = ReplaceValue.replace('!', ' not ')
ReplaceValue = ReplaceValue.replace('!', ' not ')
if '.' in ReplaceValue:
Pattern = '[a-zA-Z0-9]{1,}\.[a-zA-Z0-9]{1,}'
MatchedList = re.findall(Pattern, ReplaceValue)
@@ -797,7 +797,7 @@ class DecPomAlignment(PackageObject):
if MatchedItem not in self.PcdDefaultValueDict:
Logger.Error("Dec File Parser", FORMAT_INVALID, Message=ST.ERR_DECPARSE_PCD_NODEFINED % MatchedItem,
File=self.FullPath)
ReplaceValue = ReplaceValue.replace(MatchedItem, self.PcdDefaultValueDict[MatchedItem])
return ReplaceValue
@@ -809,7 +809,7 @@ class DecPomAlignment(PackageObject):
for Pcd in self.GetPcdList():
self.PcdDefaultValueDict[TAB_SPLIT.join((Pcd.GetTokenSpaceGuidCName(), Pcd.GetCName())).strip()] = \
Pcd.GetDefaultValue()
for Pcd in self.GetPcdList():
ValidationExpressions = []
PcdGuidName = TAB_SPLIT.join((Pcd.GetTokenSpaceGuidCName(), Pcd.GetCName()))
@@ -825,20 +825,20 @@ class DecPomAlignment(PackageObject):
if QuotedMatchedObj:
MatchedStr = QuotedMatchedObj.group().strip()
if MatchedStr.startswith('L'):
Expression = Expression.replace(MatchedStr, MatchedStr[1:].strip())
Expression = Expression.replace(MatchedStr, MatchedStr[1:].strip())
Expression = self.ReplaceForEval(Expression, IsExpr=True)
Expression = Expression.replace(PcdGuidName, 'x')
Message = self.GetEnErrorMessage(Valid.GetErrorMessageList())
ValidationExpressions.append((Expression, Message))
ValidationExpressions.append((Expression, Message))
ValidList = Valid.GetValidValue()
if ValidList:
ValidValue = 'x in %s' % [eval(v) for v in ValidList.split(' ') if v]
Message = self.GetEnErrorMessage(Valid.GetErrorMessageList())
ValidationExpressions.append((ValidValue, Message))
ValidValueRange = Valid.GetValidValueRange()
ValidValueRange = Valid.GetValidValueRange()
if ValidValueRange:
ValidValueRange = self.ReplaceForEval(ValidValueRange, IsRange=True)
if ValidValueRange.find('-') >= 0:
@@ -848,7 +848,7 @@ class DecPomAlignment(PackageObject):
ValidValueRange = 'x %s' % ValidValueRange
Message = self.GetEnErrorMessage(Valid.GetErrorMessageList())
ValidationExpressions.append((ValidValueRange, Message))
DefaultValue = self.PcdDefaultValueDict[PcdGuidName.strip()]
#
# Delete the 'L' prefix of a quoted string, this operation is for eval()
@@ -859,7 +859,7 @@ class DecPomAlignment(PackageObject):
MatchedStr = QuotedMatchedObj.group().strip()
if MatchedStr.startswith('L'):
DefaultValue = DefaultValue.replace(MatchedStr, MatchedStr[1:].strip())
try:
DefaultValue = eval(DefaultValue.replace('TRUE', 'True').replace('true', 'True')
.replace('FALSE', 'False').replace('false', 'False'))
@@ -877,11 +877,11 @@ class DecPomAlignment(PackageObject):
## GenModuleFileList
#
def GenModuleFileList(self, ContainerFile):
def GenModuleFileList(self, ContainerFile):
ModuleFileList = []
ContainerFileName = os.path.basename(ContainerFile)
ContainerFilePath = os.path.dirname(ContainerFile)
for Item in GetFiles(ContainerFilePath,
for Item in GetFiles(ContainerFilePath,
['CVS', '.svn'] + self.GetIncludePathList(), False):
ExtName = os.path.splitext(Item)[1]
if ExtName.lower() == '.inf':
@@ -889,14 +889,14 @@ class DecPomAlignment(PackageObject):
elif ExtName.upper() == '.DEC' and self.CheckMulDec:
if Item == ContainerFileName:
continue
Logger.Error('MkPkg',
Logger.Error('MkPkg',
UPT_MUL_DEC_ERROR,
ST.ERR_MUL_DEC_ERROR%(ContainerFilePath,
ContainerFileName,
ST.ERR_MUL_DEC_ERROR%(ContainerFilePath,
ContainerFileName,
Item))
self.SetModuleFileList(ModuleFileList)
## Show detailed information of Package
#
# Print all members and their values of Package class
@@ -906,7 +906,7 @@ class DecPomAlignment(PackageObject):
print('\nBaseName =', self.GetBaseName())
print('\nVersion =', self.GetVersion())
print('\nGuid =', self.GetGuid())
print('\nStandardIncludes = %d ' \
% len(self.GetStandardIncludeFileList()), end=' ')
for Item in self.GetStandardIncludeFileList():
@@ -915,7 +915,7 @@ class DecPomAlignment(PackageObject):
% len(self.GetPackageIncludeFileList()), end=' ')
for Item in self.GetPackageIncludeFileList():
print(Item.GetFilePath(), ' ', Item.GetSupArchList())
print('\nGuids =', self.GetGuidList())
for Item in self.GetGuidList():
print(Item.GetCName(), Item.GetGuid(), Item.GetSupArchList())
@@ -937,7 +937,7 @@ class DecPomAlignment(PackageObject):
'ValidUsage=', Item.GetValidUsage(), \
'SupArchList', Item.GetSupArchList(), \
'Token=', Item.GetToken(), 'DatumType=', Item.GetDatumType())
for Item in self.GetMiscFileList():
print(Item.GetName())
for FileObjectItem in Item.GetFileList():
@@ -947,11 +947,11 @@ class DecPomAlignment(PackageObject):
## GenPcdDeclaration
#
# @param ContainerFile: File name of the DEC file
# @param PcdInfo: Pcd information, of format (TokenGuidCName,
# TokenName, Value, DatumType, Token, Type,
# @param PcdInfo: Pcd information, of format (TokenGuidCName,
# TokenName, Value, DatumType, Token, Type,
# GenericComment, TailComment, Arch)
# @param Language: The language of HelpText, Prompt
#
# @param Language: The language of HelpText, Prompt
#
def GenPcdDeclaration(ContainerFile, PcdInfo, Language, MacroReplaceDict):
HelpStr = ''
PromptStr = ''
@@ -973,28 +973,28 @@ def GenPcdDeclaration(ContainerFile, PcdInfo, Language, MacroReplaceDict):
SupArchList = [Arch]
Pcd.SetSupArchList(SupArchList)
if GenericComment:
HelpStr, PcdErrList, PromptStr = ParseDecPcdGenericComment(GenericComment,
ContainerFile,
TokenGuidCName,
HelpStr, PcdErrList, PromptStr = ParseDecPcdGenericComment(GenericComment,
ContainerFile,
TokenGuidCName,
TokenName,
MacroReplaceDict)
if PcdErrList:
Pcd.SetPcdErrorsList(PcdErrList)
if TailComment:
SupModuleList, TailHelpStr = ParseDecPcdTailComment(TailComment,
SupModuleList, TailHelpStr = ParseDecPcdTailComment(TailComment,
ContainerFile)
if SupModuleList:
Pcd.SetSupModuleList(SupModuleList)
if HelpStr and (not HelpStr.endswith('\n')) and TailHelpStr:
HelpStr += '\n'
HelpStr += TailHelpStr
if HelpStr:
HelpTxtObj = TextObject()
HelpTxtObj.SetLang(Language)
HelpTxtObj.SetLang(Language)
HelpTxtObj.SetString(HelpStr)
Pcd.SetHelpTextList([HelpTxtObj])
if PromptStr:

View File

@@ -3,9 +3,9 @@
#
# Copyright (c) 2011 - 2018, 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,
@@ -59,8 +59,8 @@ from Common.MultipleWorkspace import MultipleWorkspace as mws
#
class InfPomAlignment(ModuleObject):
## Construct of InfPomAlignment
# Skip means that UPT don't care the syntax of INF, this may be the not
# distributed INF files during creation or the INF files checked for
# Skip means that UPT don't care the syntax of INF, this may be the not
# distributed INF files during creation or the INF files checked for
# dependency rule during remove.
#
def __init__(self, FileName, WorkSpace=None, PackagePath='', Skip=False):
@@ -90,12 +90,12 @@ class InfPomAlignment(ModuleObject):
self._GenInfPomObjects(Skip)
##
# Generate all POM objects, the original input comes
# Generate all POM objects, the original input comes
# from INF parser's output
#
def _GenInfPomObjects(self, Skip):
#
# Call INF Parser to get information from INF file
# Call INF Parser to get information from INF file
#
self.Parser = InfParser.InfParser(self.FileName, self.WorkSpace)
self.FullPath = self.Parser.FullPath
@@ -144,8 +144,8 @@ class InfPomAlignment(ModuleObject):
self.SetFileName(self.FileName)
self.SetFullPath(self.FullPath)
#
# The INF's filename (without the directory path or the extension)
# must be used for the value of the
# The INF's filename (without the directory path or the extension)
# must be used for the value of the
# ModuleSurfaceArea.Header.Name element
#
self.SetName(os.path.splitext(os.path.basename(self.FileName))[0])
@@ -184,7 +184,7 @@ class InfPomAlignment(ModuleObject):
#
# must exist items in INF define section
# MODULE_TYPE/BASE_NAME/INF_VERSION/FILE_GUID/VERSION_STRING
# MODULE_TYPE/BASE_NAME/INF_VERSION/FILE_GUID/VERSION_STRING
#
if DefineObj.GetModuleType() is None:
Logger.Error("InfParser", FORMAT_INVALID,
@@ -194,7 +194,7 @@ class InfPomAlignment(ModuleObject):
ModuleType = DefineObj.GetModuleType().GetValue()
if ModuleType:
#
# Drivers and applications are not allowed to have a MODULE_TYPE of "BASE". Only
# Drivers and applications are not allowed to have a MODULE_TYPE of "BASE". Only
# libraries are permitted to a have a MODULE_TYPE of "BASE".
#
if len(DefineObj.LibraryClass) == 0 and ModuleType == 'BASE':
@@ -248,7 +248,7 @@ class InfPomAlignment(ModuleObject):
Logger.Error("Parser", PARSER_ERROR, ST.ERR_INF_PARSER_NOT_SUPPORT_EDKI_INF, ExtraData=self.FullPath,
RaiseError=Logger.IS_RAISE_ERROR)
#
# if there is Shadow, Should judge the MODULE_TYPE in
# if there is Shadow, Should judge the MODULE_TYPE in
# SEC, PEI_CORE and PEIM
#
if DefineObj.GetShadow():
@@ -283,7 +283,7 @@ class InfPomAlignment(ModuleObject):
self._GenSpecialComments()
#
# put all define statement into user-extension sections
#
#
DefinesDictNew = GenModuleHeaderUserExt(DefineObj, ArchString)
if DefinesDictNew:
UserExtension = CommonObject.UserExtensionObject()
@@ -293,7 +293,7 @@ class InfPomAlignment(ModuleObject):
self.SetUserExtensionList(self.GetUserExtensionList() + [UserExtension])
#
# Get all meta-file header information
# the record is list of items formated:
# the record is list of items formated:
# [LineValue, Arch, StartLine, ID, Third]
#
InfHeaderObj = self.Parser.InfHeader
@@ -356,13 +356,13 @@ class InfPomAlignment(ModuleObject):
self.SetExternList(self.GetExternList() + [Image])
#
# UNLOAD_IMAGE
#
#
UnloadImageList = DefineObj.GetUnloadImages()
for UnloadImage in UnloadImageList:
Image = ExternObject()
#
# Future enhancement
#
#
Image.SetUnloadImage(UnloadImage.GetCName())
self.SetExternList(self.GetExternList() + [Image])
#
@@ -373,7 +373,7 @@ class InfPomAlignment(ModuleObject):
Image = ExternObject()
#
# Future enhancement
#
#
Image.SetConstructor(ConstructorItem.GetCName())
self.SetExternList(self.GetExternList() + [Image])
#
@@ -384,7 +384,7 @@ class InfPomAlignment(ModuleObject):
Image = ExternObject()
#
# Future enhancement
#
#
Image.SetDestructor(DestructorItem.GetCName())
self.SetExternList(self.GetExternList() + [Image])
@@ -639,7 +639,7 @@ class InfPomAlignment(ModuleObject):
UserExtension = CommonObject.UserExtensionObject()
UserId = UserExtensionDataObj.GetUserId()
if UserId.startswith('"') and UserId.endswith('"'):
UserId = UserId[1:-1]
UserId = UserId[1:-1]
UserExtension.SetUserID(UserId)
Identifier = UserExtensionDataObj.GetIdString()
if Identifier.startswith('"') and Identifier.endswith('"'):
@@ -653,11 +653,11 @@ class InfPomAlignment(ModuleObject):
UserExtension.SetStatement(UserExtensionDataObj.GetContent())
UserExtension.SetSupArchList(ConvertArchList(UserExtensionDataObj.GetSupArchList()))
self.SetUserExtensionList(self.GetUserExtensionList() + [UserExtension])
#
# Gen UserExtensions of TianoCore."BinaryHeader"
#
#Get Binary header from INF file
BinaryAbstractList = self.BinaryHeaderAbstractList
BinaryDescriptionList = self.BinaryHeaderDescriptionList
@@ -684,7 +684,7 @@ class InfPomAlignment(ModuleObject):
BinaryUserExtension.SetIdentifier(DT.TAB_BINARY_HEADER_IDENTIFIER)
BinaryUserExtension.SetUserID(DT.TAB_BINARY_HEADER_USERID)
self.SetUserExtensionList(self.GetUserExtensionList() + [BinaryUserExtension])
def _GenDepexesList(self, SmmDepexList, DxeDepexList, PeiDepexList):
if SmmDepexList:
self.SetSmmDepex(SmmDepexList)
@@ -802,7 +802,7 @@ class InfPomAlignment(ModuleObject):
BinaryData = BinaryObj.keys()
#
# If the INF file does not contain a [Sources] section, and the INF file does contain a [Binaries] section,
# If the INF file does not contain a [Sources] section, and the INF file does contain a [Binaries] section,
# then the ModuleSurfaceArea.BinaryModule attribute must be set to true. Otherwise, do not use the attribute
#
if BinaryObj and not self.Parser.InfSourcesSection.GetSources():
@@ -827,7 +827,7 @@ class InfPomAlignment(ModuleObject):
#
# BuildOption AsBuild Info
#
#
for BuildOptionItem in self.Parser.InfBuildOptionSection.GetBuildOptions():
AsBuildBuildOptionList.append(BuildOptionItem)
AsBuildIns.SetBuildFlagsList(AsBuildBuildOptionList)
@@ -849,14 +849,14 @@ class InfPomAlignment(ModuleObject):
TempPath = ModulePath
ModulePath = os.path.dirname(ModulePath)
PackageName = TempPath
DecFilePath = os.path.normpath(os.path.join(WorkSpace, PackageName))
DecFilePath = os.path.normpath(os.path.join(WorkSpace, PackageName))
if DecFilePath:
for File in os.listdir(DecFilePath):
if File.upper().endswith('.DEC'):
DecFileFullPath = os.path.normpath(os.path.join(DecFilePath, File))
DecObjList.append(DecPomAlignment(DecFileFullPath, self.WorkSpace))
BinariesDict, AsBuildIns, BinaryFileObjectList = GenBinaryData(BinaryData, BinaryObj,
BinariesDict,
AsBuildIns,
@@ -864,7 +864,7 @@ class InfPomAlignment(ModuleObject):
self.GetSupArchList(),
self.BinaryModule,
DecObjList)
BinariesDict2 = {}
for Key in BinariesDict:
ValueList = BinariesDict[Key]
@@ -872,7 +872,7 @@ class InfPomAlignment(ModuleObject):
BinariesDict2[Key] = ValueList
else:
#
# if there is no TagName, ToolCode, HelpStr,
# if there is no TagName, ToolCode, HelpStr,
# then do not need to put them into userextension
#
(Target, Family, TagName, HelpStr) = ValueList[0]
@@ -1000,7 +1000,7 @@ class InfPomAlignment(ModuleObject):
HelpTxtTailObj.SetLang(DT.TAB_LANGUAGE_EN_X)
HelpTxtTailObj.SetString(HelpString)
ListObject.SetHelpTextList([HelpTxtTailObj])
GuidProtocolPpiList.append(ListObject)
elif Type == DT.TAB_PROTOCOLS:
ProtocolData = ProtocolObj.keys()
@@ -1068,10 +1068,10 @@ class InfPomAlignment(ModuleObject):
FileObj.SetURI(FileName)
MiscFileObj.SetFileList(MiscFileObj.GetFileList()+[FileObj])
else:
Logger.Error("InfParser",
Logger.Error("InfParser",
FORMAT_INVALID,
ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID%(Line),
File=GlobalData.gINF_MODULE_NAME,
ExtraData=Line)
self.SetMiscFileList(self.GetMiscFileList()+[MiscFileObj])
ExtraData=Line)
self.SetMiscFileList(self.GetMiscFileList()+[MiscFileObj])

View File

@@ -3,9 +3,9 @@
#
# Copyright (c) 2011 - 2018, 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,
@@ -184,16 +184,16 @@ def GenBinaryData(BinaryData, BinaryObj, BinariesDict, AsBuildIns, BinaryFileObj
else:
TagName = ''
Family = ''
FFE = ItemObj.GetFeatureFlagExp()
#
# If have architecturie specified, then use the specified architecturie;
# If the section tag does not have an architecture modifier or the modifier is "common" (case in-sensitive),
# and the VALID_ARCHITECTURES comment exists, the list from the VALID_ARCHITECTURES comment
# and the VALID_ARCHITECTURES comment exists, the list from the VALID_ARCHITECTURES comment
# can be used for the attribute.
# If both not have VALID_ARCHITECTURE comment and no architecturie specified, then keep it empty.
#
#
SupArchList = sorted(ConvertArchList(ItemObj.GetSupArchList()))
if len(SupArchList) == 1 and SupArchList[0] == 'COMMON':
if not (len(OriSupArchList) == 1 or OriSupArchList[0] == 'COMMON'):
@@ -208,7 +208,7 @@ def GenBinaryData(BinaryData, BinaryObj, BinariesDict, AsBuildIns, BinaryFileObj
#
# Get GUID value of the GUID CName in the DEC file
#
if ItemObj.GetType() == DT.SUBTYPE_GUID_BINARY_FILE_TYPE:
if ItemObj.GetType() == DT.SUBTYPE_GUID_BINARY_FILE_TYPE:
if not CheckGuidRegFormat(ItemObj.GetGuidValue()):
if not DecObjList:
if DT.TAB_HORIZON_LINE_SPLIT in ItemObj.GetGuidValue() or \
@@ -231,12 +231,12 @@ def GenBinaryData(BinaryData, BinaryObj, BinariesDict, AsBuildIns, BinaryFileObj
FileNameObj.SetGuidValue(GuidObj.GetGuid())
break
if not FileNameObj.GetGuidValue():
if not FileNameObj.GetGuidValue():
Logger.Error("\nMkPkg",
FORMAT_INVALID,
ST.ERR_DECPARSE_CGUID_NOT_FOUND % \
(ItemObj.GetGuidValue()),
RaiseError=True)
RaiseError=True)
else:
FileNameObj.SetGuidValue(ItemObj.GetGuidValue().strip())

View File

@@ -4,11 +4,11 @@
# This file is required to make Python interpreter treat the directory
# as containing package.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -17,4 +17,4 @@
'''
PomAdapter
'''
'''

View File

@@ -1,11 +1,11 @@
## @file
# Replace distribution package.
#
# Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2014 - 2018, 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,
@@ -51,26 +51,26 @@ def Main(Options = None):
WorkspaceDir = GlobalData.gWORKSPACE
Dep = DependencyRules(DataBase)
DistPkg, ContentZipFile, DpPkgFileName, DistFile = UnZipDp(WorkspaceDir, Options.PackFileToReplace)
StoredDistFile, OrigDpGuid, OrigDpVersion = GetInstalledDpInfo(Options.PackFileToBeReplaced, \
Dep, DataBase, WorkspaceDir)
#
# check dependency
#
CheckReplaceDpx(Dep, DistPkg, OrigDpGuid, OrigDpVersion)
#
# Remove the old distribution
#
RemoveDist(OrigDpGuid, OrigDpVersion, StoredDistFile, DataBase, WorkspaceDir, Options.Yes)
#
# Install the new distribution
#
InstallDp(DistPkg, DpPkgFileName, ContentZipFile, Options, Dep, WorkspaceDir, DataBase)
ReturnCode = 0
except FatalError as XExcept:
ReturnCode = XExcept.args[0]
if Logger.GetLevel() <= Logger.DEBUG_9:
@@ -102,11 +102,11 @@ def Main(Options = None):
for TempDir in GlobalData.gUNPACK_DIR:
rmtree(TempDir)
GlobalData.gUNPACK_DIR = []
Logger.Quiet(ST.MSG_REMOVE_TEMP_FILE_DONE)
Logger.Quiet(ST.MSG_REMOVE_TEMP_FILE_DONE)
if ReturnCode == 0:
Logger.Quiet(ST.MSG_FINISH)
return ReturnCode
def CheckReplaceDpx(Dep, DistPkg, OrigDpGuid, OrigDpVersion):
@@ -125,18 +125,18 @@ def CheckReplaceDpx(Dep, DistPkg, OrigDpGuid, OrigDpVersion):
if Dep.CheckDpExists(DistPkg.Header.GetGuid(), DistPkg.Header.GetVersion()):
Logger.Error("\nReplacePkg", UPT_ALREADY_INSTALLED_ERROR,
ST.WRN_DIST_PKG_INSTALLED,
ExtraData=ST.MSG_REPLACE_ALREADY_INSTALLED_DP)
ExtraData=ST.MSG_REPLACE_ALREADY_INSTALLED_DP)
#
# check whether the original distribution could be replaced by new distribution
#
#
Logger.Verbose(ST.MSG_CHECK_DP_FOR_REPLACE%(NewDpInfo, OrigDpInfo))
DepInfoResult = Dep.CheckDpDepexForReplace(OrigDpGuid, OrigDpVersion, NewDpPkgList)
Replaceable = DepInfoResult[0]
if not Replaceable:
Logger.Error("\nReplacePkg", UNKNOWN_ERROR,
ST.ERR_PACKAGE_NOT_MATCH_DEPENDENCY)
#
# check whether new distribution could be installed by dependency rule
#

View File

@@ -1,11 +1,11 @@
## @file
# Install distribution package.
#
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -58,7 +58,7 @@ def CheckDpDepex(Dep, Guid, Version, WorkspaceDir):
return 1
else:
#
# report list of modules that are not valid due to force
# report list of modules that are not valid due to force
# remove,
# also generate a log file for reference
#
@@ -72,12 +72,12 @@ def CheckDpDepex(Dep, Guid, Version, WorkspaceDir):
LogFile.write("%s\n"%ModulePath)
Logger.Info(ModulePath)
except IOError:
Logger.Warn("\nRmPkg", ST.ERR_FILE_WRITE_FAILURE,
Logger.Warn("\nRmPkg", ST.ERR_FILE_WRITE_FAILURE,
File=LogFilePath)
except IOError:
Logger.Warn("\nRmPkg", ST.ERR_FILE_OPEN_FAILURE,
Logger.Warn("\nRmPkg", ST.ERR_FILE_OPEN_FAILURE,
File=LogFilePath)
finally:
finally:
LogFile.close()
## Remove Path
@@ -85,7 +85,7 @@ def CheckDpDepex(Dep, Guid, Version, WorkspaceDir):
# removing readonly file on windows will get "Access is denied"
# error, so before removing, change the mode to be writeable
#
# @param Path: The Path to be removed
# @param Path: The Path to be removed
#
def RemovePath(Path):
Logger.Info(ST.MSG_REMOVE_FILE % Path)
@@ -122,43 +122,43 @@ def GetCurrentFileList(DataBase, Guid, Version, WorkspaceDir):
# If no error found, return zero value so the caller of this tool can know
# if it's executed successfully or not.
#
# @param Options: command option
# @param Options: command option
#
def Main(Options = None):
try:
DataBase = GlobalData.gDB
DataBase = GlobalData.gDB
if not Options.DistributionFile:
Logger.Error("RmPkg",
OPTION_MISSING,
Logger.Error("RmPkg",
OPTION_MISSING,
ExtraData=ST.ERR_SPECIFY_PACKAGE)
WorkspaceDir = GlobalData.gWORKSPACE
#
# Prepare check dependency
#
Dep = DependencyRules(DataBase)
#
# Get the Dp information
#
StoredDistFile, Guid, Version = GetInstalledDpInfo(Options.DistributionFile, Dep, DataBase, WorkspaceDir)
#
#
# Check Dp depex
#
CheckDpDepex(Dep, Guid, Version, WorkspaceDir)
#
#
# remove distribution
#
RemoveDist(Guid, Version, StoredDistFile, DataBase, WorkspaceDir, Options.Yes)
Logger.Quiet(ST.MSG_FINISH)
ReturnCode = 0
except FatalError as XExcept:
ReturnCode = XExcept.args[0]
ReturnCode = XExcept.args[0]
if Logger.GetLevel() <= Logger.DEBUG_9:
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + \
format_exc())
@@ -203,7 +203,7 @@ def GetInstalledDpInfo(DistributionFile, Dep, DataBase, WorkspaceDir):
if not Dep.CheckDpExists(Guid, Version):
Logger.Error("RmPkg", UNKNOWN_ERROR, ST.ERR_DISTRIBUTION_NOT_INSTALLED)
#
# Check for Distribution files existence in /conf/upt, if not exist,
# Check for Distribution files existence in /conf/upt, if not exist,
# Warn user and go on.
#
StoredDistFile = os.path.normpath(os.path.join(WorkspaceDir, GlobalData.gUPT_DIR, NewDpFileName))
@@ -252,7 +252,7 @@ def RemoveDist(Guid, Version, StoredDistFile, DataBase, WorkspaceDir, ForceRemov
RemovePath(Path)
else:
MissingFileList.append(Path)
for Path in NewFileList:
if os.path.isfile(Path):
if (not ForceRemove) and (not os.path.split(Path)[1].startswith('.')):

View File

@@ -1,12 +1,12 @@
## @file
#
# This file is the main entry for UPT
# This file is the main entry for UPT
#
# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,

View File

@@ -3,9 +3,9 @@
#
# Copyright (c) 2011 - 2018, 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,
@@ -32,7 +32,7 @@ class ParseHeaderCommentSectionTest(unittest.TestCase):
def tearDown(self):
pass
#
# Normal case1: have license/copyright/license above @file
#
@@ -42,36 +42,36 @@ class ParseHeaderCommentSectionTest(unittest.TestCase):
# License2
#
## @file
# example abstract
#
# example abstract
#
# example description
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
#
# License3
#
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
# License3
#'''
CommentList = GetSplitValueList(TestCommentLines1, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
Abstract, Description, Copyright, License = \
ParseHeaderCommentSection(TestCommentLinesList, "PhonyFile")
ExpectedAbstract = 'example abstract'
self.assertEqual(Abstract, ExpectedAbstract)
ExpectedDescription = 'example description'
self.assertEqual(Description, ExpectedDescription)
ExpectedCopyright = \
'Copyright (c) 2007 - 2010,'\
' Intel Corporation. All rights reserved.<BR>'
self.assertEqual(Copyright, ExpectedCopyright)
ExpectedLicense = 'License1\nLicense2\n\nLicense3'
self.assertEqual(License, ExpectedLicense)
@@ -84,41 +84,41 @@ class ParseHeaderCommentSectionTest(unittest.TestCase):
# License2
#
## @file
# example abstract
#
# example abstract
#
# example description
#
#Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
#Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
##'''
CommentList = GetSplitValueList(TestCommentLines2, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
Abstract, Description, Copyright, License = \
ParseHeaderCommentSection(TestCommentLinesList, "PhonyFile")
ExpectedAbstract = 'example abstract'
self.assertEqual(Abstract, ExpectedAbstract)
ExpectedDescription = 'example description'
self.assertEqual(Description, ExpectedDescription)
ExpectedCopyright = \
'Copyright (c) 2007 - 2010, Intel Corporation.'\
'Copyright (c) 2007 - 2018, Intel Corporation.'\
' All rights reserved.<BR>'
self.assertEqual(Copyright, ExpectedCopyright)
ExpectedLicense = 'License1\nLicense2'
self.assertEqual(License, ExpectedLicense)
#
# Normal case2: have license/copyright/license above @file,
# Normal case2: have license/copyright/license above @file,
# but no abstract/description
#
def testNormalCase3(self):
@@ -126,41 +126,41 @@ class ParseHeaderCommentSectionTest(unittest.TestCase):
''' # License1
# License2
#
## @file
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
## @file
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
# License3 Line1
# License3 Line2
##'''
CommentList = GetSplitValueList(TestCommentLines3, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
Abstract, Description, Copyright, License = \
ParseHeaderCommentSection(TestCommentLinesList, "PhonyFile")
ExpectedAbstract = ''
self.assertEqual(Abstract, ExpectedAbstract)
ExpectedDescription = ''
self.assertEqual(Description, ExpectedDescription)
ExpectedCopyright = \
'Copyright (c) 2007 - 2010,'\
' Intel Corporation. All rights reserved.<BR>'
self.assertEqual(Copyright, ExpectedCopyright)
ExpectedLicense = \
'License1\n' \
'License2\n\n' \
'License3 Line1\n' \
'License3 Line2'
self.assertEqual(License, ExpectedLicense)
self.assertEqual(License, ExpectedLicense)
#
# Normal case4: format example in spec
#
@@ -172,33 +172,33 @@ class ParseHeaderCommentSectionTest(unittest.TestCase):
#
# Description
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
# License
#
##'''
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
Abstract, Description, Copyright, License = \
ParseHeaderCommentSection(TestCommentLinesList, "PhonyFile")
ExpectedAbstract = 'Abstract'
self.assertEqual(Abstract, ExpectedAbstract)
ExpectedDescription = 'Description'
self.assertEqual(Description, ExpectedDescription)
ExpectedCopyright = \
'Copyright (c) 2007 - 2010, Intel Corporation.'\
'Copyright (c) 2007 - 2018, Intel Corporation.'\
' All rights reserved.<BR>'
self.assertEqual(Copyright, ExpectedCopyright)
ExpectedLicense = \
'License'
self.assertEqual(License, ExpectedLicense)
@@ -214,37 +214,37 @@ class ParseHeaderCommentSectionTest(unittest.TestCase):
#
# Description
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# other line
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# other line
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
# License
#
##'''
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
Abstract, Description, Copyright, License = \
ParseHeaderCommentSection(TestCommentLinesList, "PhonyFile")
ExpectedAbstract = 'Abstract'
self.assertEqual(Abstract, ExpectedAbstract)
ExpectedDescription = 'Description'
self.assertEqual(Description, ExpectedDescription)
ExpectedCopyright = \
'Copyright (c) 2007 - 2010, Intel Corporation.'\
'Copyright (c) 2007 - 2018, Intel Corporation.'\
' All rights reserved.<BR>\n'\
'Copyright (c) 2007 - 2010, Intel Corporation.'\
'Copyright (c) 2007 - 2018, Intel Corporation.'\
' All rights reserved.<BR>'
self.assertEqual(Copyright, ExpectedCopyright)
ExpectedLicense = \
'License'
self.assertEqual(License, ExpectedLicense)
@@ -260,39 +260,39 @@ class ParseHeaderCommentSectionTest(unittest.TestCase):
#
# Description
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2010, FOO1 Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2010, FOO1 Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2010, FOO2 Corporation. All rights reserved.<BR>
#
# License
#
##'''
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
Abstract, Description, Copyright, License = \
ParseHeaderCommentSection(TestCommentLinesList, "PhonyFile")
ExpectedAbstract = 'Abstract'
self.assertEqual(Abstract, ExpectedAbstract)
ExpectedDescription = 'Description'
self.assertEqual(Description, ExpectedDescription)
ExpectedCopyright = \
'Copyright (c) 2007 - 2010, Intel Corporation.'\
'Copyright (c) 2007 - 2018, Intel Corporation.'\
' All rights reserved.<BR>\n'\
'Copyright (c) 2007 - 2010, FOO1 Corporation.'\
' All rights reserved.<BR>\n'\
'Copyright (c) 2007 - 2010, FOO2 Corporation.'\
' All rights reserved.<BR>'
self.assertEqual(Copyright, ExpectedCopyright)
ExpectedLicense = \
'License'
self.assertEqual(License, ExpectedLicense)
@@ -307,39 +307,39 @@ class ParseHeaderCommentSectionTest(unittest.TestCase):
#
# Description
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2010, FOO1 Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2010, FOO1 Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2010, FOO2 Corporation. All rights reserved.<BR>
#
# License
#
##'''
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
Abstract, Description, Copyright, License = \
ParseHeaderCommentSection(TestCommentLinesList, "PhonyFile")
ExpectedAbstract = ''
self.assertEqual(Abstract, ExpectedAbstract)
ExpectedDescription = 'Description'
self.assertEqual(Description, ExpectedDescription)
ExpectedCopyright = \
'Copyright (c) 2007 - 2010, Intel Corporation.'\
'Copyright (c) 2007 - 2018, Intel Corporation.'\
' All rights reserved.<BR>\n'\
'Copyright (c) 2007 - 2010, FOO1 Corporation.'\
' All rights reserved.<BR>\n'\
'Copyright (c) 2007 - 2010, FOO2 Corporation.'\
' All rights reserved.<BR>'
self.assertEqual(Copyright, ExpectedCopyright)
ExpectedLicense = \
'License'
self.assertEqual(License, ExpectedLicense)
@@ -353,37 +353,37 @@ class ParseHeaderCommentSectionTest(unittest.TestCase):
## @file
# Abstact
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
# License
#
##'''
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
Abstract, Description, Copyright, License = \
ParseHeaderCommentSection(TestCommentLinesList, "PhonyFile")
ExpectedAbstract = 'Abstact'
self.assertEqual(Abstract, ExpectedAbstract)
ExpectedDescription = ''
self.assertEqual(Description, ExpectedDescription)
ExpectedCopyright = \
'Copyright (c) 2007 - 2010, Intel Corporation.'\
'Copyright (c) 2007 - 2018, Intel Corporation.'\
' All rights reserved.<BR>'
self.assertEqual(Copyright, ExpectedCopyright)
ExpectedLicense = \
'License'
self.assertEqual(License, ExpectedLicense)
#
# Error case1: No copyright found
#
@@ -398,18 +398,18 @@ class ParseHeaderCommentSectionTest(unittest.TestCase):
# License
#
##'''
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
self.assertRaises(Logger.FatalError,
ParseHeaderCommentSection,
self.assertRaises(Logger.FatalError,
ParseHeaderCommentSection,
TestCommentLinesList,
"PhonyFile")
"PhonyFile")
#
# Error case2: non-empty non-comment lines passed in
@@ -423,22 +423,22 @@ class ParseHeaderCommentSectionTest(unittest.TestCase):
this is invalid line
# Description
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# License
#
##'''
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
self.assertRaises(Logger.FatalError,
ParseHeaderCommentSection,
self.assertRaises(Logger.FatalError,
ParseHeaderCommentSection,
TestCommentLinesList,
"PhonyFile")
"PhonyFile")
#
# Test ParseGenericComment
@@ -449,14 +449,14 @@ class ParseGenericCommentTest(unittest.TestCase):
def tearDown(self):
pass
#
# Normal case1: one line of comment
#
def testNormalCase1(self):
TestCommentLines = \
'''# hello world'''
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
@@ -476,17 +476,17 @@ class ParseGenericCommentTest(unittest.TestCase):
TestCommentLines = \
'''## hello world
# second line'''
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
HelptxtObj = ParseGenericComment(TestCommentLinesList, 'testNormalCase2')
self.failIf(not HelptxtObj)
self.assertEqual(HelptxtObj.GetString(),
self.assertEqual(HelptxtObj.GetString(),
'hello world\n' + 'second line')
self.assertEqual(HelptxtObj.GetLang(), TAB_LANGUAGE_EN_US)
@@ -497,17 +497,17 @@ class ParseGenericCommentTest(unittest.TestCase):
TestCommentLines = \
'''## hello world
This is not comment line'''
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
HelptxtObj = ParseGenericComment(TestCommentLinesList, 'testNormalCase3')
self.failIf(not HelptxtObj)
self.assertEqual(HelptxtObj.GetString(),
self.assertEqual(HelptxtObj.GetString(),
'hello world\n\n')
self.assertEqual(HelptxtObj.GetLang(), TAB_LANGUAGE_EN_US)
@@ -520,7 +520,7 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase):
def tearDown(self):
pass
#
# Normal case1: comments with no special comment
#
@@ -528,22 +528,22 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase):
TestCommentLines = \
'''## hello world
# second line'''
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
(HelpTxt, PcdErr) = \
ParseDecPcdGenericComment(TestCommentLinesList, 'testNormalCase1')
self.failIf(not HelpTxt)
self.failIf(PcdErr)
self.assertEqual(HelpTxt,
self.assertEqual(HelpTxt,
'hello world\n' + 'second line')
#
# Normal case2: comments with valid list
#
@@ -553,19 +553,19 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase):
# second line
# @ValidList 1, 2, 3
# other line'''
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
(HelpTxt, PcdErr) = \
ParseDecPcdGenericComment(TestCommentLinesList, 'UnitTest')
self.failIf(not HelpTxt)
self.failIf(not PcdErr)
self.assertEqual(HelpTxt,
self.assertEqual(HelpTxt,
'hello world\n' + 'second line\n' + 'other line')
ExpectedList = GetSplitValueList('1 2 3', TAB_SPACE_SPLIT)
ActualList = [item for item in \
@@ -583,19 +583,19 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase):
# second line
# @ValidRange LT 1 AND GT 2
# other line'''
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
(HelpTxt, PcdErr) = \
ParseDecPcdGenericComment(TestCommentLinesList, 'UnitTest')
self.failIf(not HelpTxt)
self.failIf(not PcdErr)
self.assertEqual(HelpTxt,
self.assertEqual(HelpTxt,
'hello world\n' + 'second line\n' + 'other line')
self.assertEqual(PcdErr.GetValidValueRange().strip(), 'LT 1 AND GT 2')
self.failIf(PcdErr.GetExpression())
@@ -610,19 +610,19 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase):
# second line
# @Expression LT 1 AND GT 2
# other line'''
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
(HelpTxt, PcdErr) = \
ParseDecPcdGenericComment(TestCommentLinesList, 'UnitTest')
self.failIf(not HelpTxt)
self.failIf(not PcdErr)
self.assertEqual(HelpTxt,
self.assertEqual(HelpTxt,
'hello world\n' + 'second line\n' + 'other line')
self.assertEqual(PcdErr.GetExpression().strip(), 'LT 1 AND GT 2')
self.failIf(PcdErr.GetValidValueRange())
@@ -634,14 +634,14 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase):
def testNormalCase5(self):
TestCommentLines = \
'''# @Expression LT 1 AND GT 2'''
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
(HelpTxt, PcdErr) = \
ParseDecPcdGenericComment(TestCommentLinesList, 'UnitTest')
self.failIf(HelpTxt)
@@ -649,28 +649,28 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase):
self.assertEqual(PcdErr.GetExpression().strip(), 'LT 1 AND GT 2')
self.failIf(PcdErr.GetValidValueRange())
self.failIf(PcdErr.GetValidValue())
#
# Normal case6: comments with only generic help text
#
def testNormalCase6(self):
TestCommentLines = \
'''#'''
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
(HelpTxt, PcdErr) = \
ParseDecPcdGenericComment(TestCommentLinesList, 'UnitTest')
self.assertEqual(HelpTxt, '\n')
self.failIf(PcdErr)
#
# Error case1: comments with both expression and valid list, use later
# ignore the former and with a warning message
@@ -679,17 +679,17 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase):
TestCommentLines = \
'''## hello world
# second line
# @ValidList 1, 2, 3
# @ValidList 1, 2, 3
# @Expression LT 1 AND GT 2
# other line'''
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
try:
ParseDecPcdGenericComment(TestCommentLinesList, 'UnitTest')
except Logger.FatalError:
@@ -704,26 +704,26 @@ class ParseDecPcdTailCommentTest(unittest.TestCase):
def tearDown(self):
pass
#
# Normal case1: comments with no SupModeList
#
def testNormalCase1(self):
TestCommentLines = \
'''## #hello world'''
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
(SupModeList, HelpStr) = \
ParseDecPcdTailComment(TestCommentLinesList, 'UnitTest')
self.failIf(not HelpStr)
self.failIf(SupModeList)
self.assertEqual(HelpStr,
self.assertEqual(HelpStr,
'hello world')
#
@@ -732,44 +732,44 @@ class ParseDecPcdTailCommentTest(unittest.TestCase):
def testNormalCase2(self):
TestCommentLines = \
'''## BASE #hello world'''
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
(SupModeList, HelpStr) = \
ParseDecPcdTailComment(TestCommentLinesList, 'UnitTest')
self.failIf(not HelpStr)
self.failIf(not SupModeList)
self.assertEqual(HelpStr,
self.assertEqual(HelpStr,
'hello world')
self.assertEqual(SupModeList,
self.assertEqual(SupModeList,
['BASE'])
#
# Normal case3: comments with more than one SupMode
#
def testNormalCase3(self):
TestCommentLines = \
'''## BASE UEFI_APPLICATION #hello world'''
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
(SupModeList, HelpStr) = \
ParseDecPcdTailComment(TestCommentLinesList, 'UnitTest')
self.failIf(not HelpStr)
self.failIf(not SupModeList)
self.assertEqual(HelpStr,
self.assertEqual(HelpStr,
'hello world')
self.assertEqual(SupModeList,
self.assertEqual(SupModeList,
['BASE', 'UEFI_APPLICATION'])
#
@@ -778,58 +778,58 @@ class ParseDecPcdTailCommentTest(unittest.TestCase):
def testNormalCase4(self):
TestCommentLines = \
'''## BASE UEFI_APPLICATION'''
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
(SupModeList, HelpStr) = \
ParseDecPcdTailComment(TestCommentLinesList, 'UnitTest')
self.failIf(HelpStr)
self.failIf(not SupModeList)
self.assertEqual(SupModeList,
self.assertEqual(SupModeList,
['BASE', 'UEFI_APPLICATION'])
#
# Normal case5: general comments with no supModList, extract from real case
# Normal case5: general comments with no supModList, extract from real case
#
def testNormalCase5(self):
TestCommentLines = \
''' # 1 = 128MB, 2 = 256MB, 3 = MAX'''
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
(SupModeList, HelpStr) = \
ParseDecPcdTailComment(TestCommentLinesList, 'UnitTest')
self.failIf(not HelpStr)
self.assertEqual(HelpStr,
self.assertEqual(HelpStr,
'1 = 128MB, 2 = 256MB, 3 = MAX')
self.failIf(SupModeList)
#
# Error case2: comments with supModList contains valid and invalid
# Error case2: comments with supModList contains valid and invalid
# module type
#
def testErrorCase2(self):
TestCommentLines = \
'''## BASE INVALID_MODULE_TYPE #hello world'''
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
try:
ParseDecPcdTailComment(TestCommentLinesList, 'UnitTest')
except Logger.FatalError:
@@ -869,7 +869,7 @@ class _IsCopyrightLineTest(unittest.TestCase):
Line = 'this is not aCopyright ( line'
Result = _IsCopyrightLine(Line)
self.failIf(Result)
#
# Normal case
#
@@ -917,7 +917,7 @@ class _IsCopyrightLineTest(unittest.TestCase):
Line = 'not a Copyright '
Result = _IsCopyrightLine(Line)
self.failIf(Result)
if __name__ == '__main__':
Logger.Initialize()
unittest.main()
unittest.main()

View File

@@ -1,11 +1,11 @@
## @file
# This file contain unit test for DecParser
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -28,19 +28,19 @@ from Library.ParserValidate import IsValidCFormatGuid
#
def TestToolFuncs():
assert IsValidCArray('{0x1, 0x23}')
# Empty after comma
assert not IsValidCArray('{0x1, 0x23, }')
# 0x2345 too long
assert not IsValidCArray('{0x1, 0x2345}')
# Must end with '}'
assert not IsValidCArray('{0x1, 0x23, ')
# Whitespace between numbers
assert not IsValidCArray('{0x1, 0x2 3, }')
assert IsValidPcdDatum('VOID*', '"test"')[0]
assert IsValidPcdDatum('VOID*', 'L"test"')[0]
assert IsValidPcdDatum('BOOLEAN', 'TRUE')[0]
@@ -48,10 +48,10 @@ def TestToolFuncs():
assert IsValidPcdDatum('BOOLEAN', '0')[0]
assert IsValidPcdDatum('BOOLEAN', '1')[0]
assert IsValidPcdDatum('UINT8', '0xab')[0]
assert not IsValidPcdDatum('UNKNOWNTYPE', '0xabc')[0]
assert not IsValidPcdDatum('UINT8', 'not number')[0]
assert not IsValidPcdDatum('UINT8', 'not number')[0]
assert( IsValidCFormatGuid('{ 0xfa0b1735 , 0x87a0, 0x4193, {0xb2, 0x66 , 0x53, 0x8c , 0x38, 0xaf, 0x48, 0xce }}'))
assert( not IsValidCFormatGuid('{ 0xfa0b1735 , 0x87a0, 0x4193, {0xb2, 0x66 , 0x53, 0x8c , 0x38, 0xaf, 0x48, 0xce }} 0xaa'))
@@ -60,10 +60,10 @@ def TestTemplate(TestString, TestFunc):
Path = os.path.normpath(Path)
try:
f = open(Path, 'w')
# Write test string to file
f.write(TestString)
# Close file
f.close()
except:
@@ -72,7 +72,7 @@ def TestTemplate(TestString, TestFunc):
# Call test function to test
Ret = TestFunc(Path, TestString)
# Test done, remove temporary file
os.remove(Path)
return Ret
@@ -112,13 +112,13 @@ def TestDecDefine():
assert DefObj.GetPackageName() == 'MdePkg'
assert DefObj.GetPackageGuid() == '1E73767F-8F52-4603-AEB4-F29B510B6766'
assert DefObj.GetPackageVersion() == '1.02'
TestString = '''
[Defines]
UNKNOW_KEY = 0x00010005 # A unknown key
'''
assert TestTemplate(TestString, TestError)
TestString = '''
[Defines]
PACKAGE_GUID = F-8F52-4603-AEB4-F29B510B6766 # Error GUID
@@ -138,24 +138,24 @@ def TestDecInclude():
[Includes.IA32]
Include/Ia32
'''
# Create directory in current directory
try:
os.makedirs('Include/Ia32')
except:
pass
Parser = TestTemplate(TestString, TestOK)
IncObj = Parser.GetIncludeSectionObject()
Items = IncObj.GetIncludes()
assert len(Items) == 1
assert Items[0].File == 'Include'
Items = IncObj.GetIncludes('IA32')
assert len(Items) == 1
# normpath is called in DEC parser so '/' is converted to '\'
assert Items[0].File == 'Include\\Ia32'
TestString = '''
[Defines]
DEC_SPECIFICATION = 0x00010005
@@ -166,7 +166,7 @@ def TestDecInclude():
Include_not_exist # directory does not exist
'''
assert TestTemplate(TestString, TestError)
os.removedirs('Include/Ia32')
def TestDecGuidPpiProtocol():
@@ -196,14 +196,14 @@ def TestDecGuidPpiProtocol():
assert len(Items) == 1
assert Items[0].GuidCName == 'gEfiGlobalVariableGuid'
assert Items[0].GuidCValue == '{ 0x8BE4DF61, 0x93CA, 0x11D2, { 0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C }}'
Obj = Parser.GetProtocolSectionObject()
Items = Obj.GetProtocols()
assert Obj.GetSectionName() == 'Protocols'.upper()
assert len(Items) == 1
assert Items[0].GuidCName == 'gEfiBdsArchProtocolGuid'
assert Items[0].GuidCValue == '{ 0x665E3FF6, 0x46CC, 0x11D4, { 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }}'
Obj = Parser.GetPpiSectionObject()
Items = Obj.GetPpis()
assert Obj.GetSectionName() == 'Ppis'.upper()
@@ -221,19 +221,19 @@ def TestDecPcd():
[PcdsFeatureFlag]
## If TRUE, the component name protocol will not be installed.
gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable|FALSE|BOOLEAN|0x0000000d
[PcdsFixedAtBuild]
## Indicates the maximum length of unicode string
gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1000000|UINT32|0x00000001
[PcdsFixedAtBuild.IPF]
## The base address of IO port space for IA64 arch
gEfiMdePkgTokenSpaceGuid.PcdIoBlockBaseAddressForIpf|0x0ffffc000000|UINT64|0x0000000f
[PcdsFixedAtBuild,PcdsPatchableInModule]
## This flag is used to control the printout of DebugLib
gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000000|UINT32|0x00000006
[PcdsFixedAtBuild,PcdsPatchableInModule,PcdsDynamic]
## This value is used to set the base address of pci express hierarchy
gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000|UINT64|0x0000000a
@@ -247,7 +247,7 @@ def TestDecPcd():
assert Items[0].DefaultValue == 'FALSE'
assert Items[0].DatumType == 'BOOLEAN'
assert Items[0].TokenValue == '0x0000000d'
Items = Obj.GetPcdsByType('PcdsFixedAtBuild')
assert len(Items) == 4
assert len(Obj.GetPcdsByType('PcdsPatchableInModule')) == 2

View File

@@ -1,11 +1,11 @@
## @file
# This file contain unit test for DecParser
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -24,7 +24,7 @@ from Parser.DecParser import \
FileContent, \
_DecBase, \
CleanString
from Object.Parser.DecObject import _DecComments
#
@@ -35,19 +35,19 @@ class CleanStringTestCase(unittest.TestCase):
Line, Comment = CleanString('')
self.assertEqual(Line, '')
self.assertEqual(Comment, '')
Line, Comment = CleanString('line without comment')
self.assertEqual(Line, 'line without comment')
self.assertEqual(Comment, '')
Line, Comment = CleanString('# pure comment')
self.assertEqual(Line, '')
self.assertEqual(Comment, '# pure comment')
Line, Comment = CleanString('line # and comment')
self.assertEqual(Line, 'line')
self.assertEqual(Comment, '# and comment')
def testCleanStringCpp(self):
Line, Comment = CleanString('line // and comment', AllowCppStyleComment = True)
self.assertEqual(Line, 'line')
@@ -59,16 +59,16 @@ class CleanStringTestCase(unittest.TestCase):
class MacroParserTestCase(unittest.TestCase):
def setUp(self):
self.dec = _DecBase(FileContent('dummy', []))
def testCorrectMacro(self):
self.dec._MacroParser('DEFINE MARCRO1 = test1')
self.failIf('MARCRO1' not in self.dec._LocalMacro)
self.assertEqual(self.dec._LocalMacro['MARCRO1'], 'test1')
def testErrorMacro1(self):
# Raise fatal error, macro name must be upper case letter
self.assertRaises(FatalError, self.dec._MacroParser, 'DEFINE not_upper_case = test2')
def testErrorMacro2(self):
# No macro name given
self.assertRaises(FatalError, self.dec._MacroParser, 'DEFINE ')
@@ -81,19 +81,19 @@ class TryBackSlashTestCase(unittest.TestCase):
Content = [
# Right case
'test no backslash',
'test with backslash \\',
'continue second line',
# Do not precede with whitespace
'\\',
# Empty line after backlash is not allowed
'line with backslash \\',
''
]
self.dec = _DecBase(FileContent('dummy', Content))
def testBackSlash(self):
#
# Right case, assert return values
@@ -101,11 +101,11 @@ class TryBackSlashTestCase(unittest.TestCase):
ConcatLine, CommentList = self.dec._TryBackSlash(self.dec._RawData.GetNextLine(), [])
self.assertEqual(ConcatLine, 'test no backslash')
self.assertEqual(CommentList, [])
ConcatLine, CommentList = self.dec._TryBackSlash(self.dec._RawData.GetNextLine(), [])
self.assertEqual(CommentList, [])
self.assertEqual(ConcatLine, 'test with backslash continue second line')
#
# Error cases, assert raise exception
#
@@ -130,16 +130,16 @@ class TestInner(_DecBase):
def __init__(self, RawData):
_DecBase.__init__(self, RawData)
self.ItemObject = Data()
def _StopCurrentParsing(self, Line):
return Line == '[TOP]'
def _ParseItem(self):
Item = DataItem()
Item.String = self._RawData.CurrentLine
self.ItemObject.ItemList.append(Item)
return Item
def _TailCommentStrategy(self, Comment):
return Comment.find('@comment') != -1
@@ -148,7 +148,7 @@ class TestTop(_DecBase):
_DecBase.__init__(self, RawData)
# List of Data
self.ItemObject = []
# Top parser
def _StopCurrentParsing(self, Line):
return False
@@ -159,10 +159,10 @@ class TestTop(_DecBase):
self.ItemObject.append(TestParser.ItemObject)
return TestParser.ItemObject
class ParseTestCase(unittest.TestCase):
class ParseTestCase(unittest.TestCase):
def setUp(self):
pass
def testParse(self):
Content = \
'''# Top comment
@@ -172,26 +172,26 @@ class ParseTestCase(unittest.TestCase):
# sub2 head comment
(test item has head and special tail comment)
# @comment test TailCommentStrategy branch
(test item has no comment)
# test NextLine branch
[TOP]
sub-item
'''
dec = TestTop(FileContent('dummy', Content.splitlines()))
dec.Parse()
# Two sections
self.assertEqual(len(dec.ItemObject), 2)
data = dec.ItemObject[0]
self.assertEqual(data._HeadComment[0][0], '# Top comment')
self.assertEqual(data._HeadComment[0][1], 1)
# 3 subitems
self.assertEqual(len(data.ItemList), 3)
dataitem = data.ItemList[0]
self.assertEqual(dataitem.String, '(test item has both head and tail comment)')
# Comment content
@@ -200,7 +200,7 @@ class ParseTestCase(unittest.TestCase):
# Comment line number
self.assertEqual(dataitem._HeadComment[0][1], 3)
self.assertEqual(dataitem._TailComment[0][1], 4)
dataitem = data.ItemList[1]
self.assertEqual(dataitem.String, '(test item has head and special tail comment)')
# Comment content
@@ -209,20 +209,20 @@ class ParseTestCase(unittest.TestCase):
# Comment line number
self.assertEqual(dataitem._HeadComment[0][1], 5)
self.assertEqual(dataitem._TailComment[0][1], 7)
dataitem = data.ItemList[2]
self.assertEqual(dataitem.String, '(test item has no comment)')
# Comment content
self.assertEqual(dataitem._HeadComment, [])
self.assertEqual(dataitem._TailComment, [])
data = dec.ItemObject[1]
self.assertEqual(data._HeadComment[0][0], '# test NextLine branch')
self.assertEqual(data._HeadComment[0][1], 11)
# 1 subitems
self.assertEqual(len(data.ItemList), 1)
dataitem = data.ItemList[0]
self.assertEqual(dataitem.String, 'sub-item')
self.assertEqual(dataitem._HeadComment, [])
@@ -241,15 +241,15 @@ class DecDefineTestCase(unittest.TestCase):
item = self.GetObj('PACKAGE_NAME = MdePkg')._ParseItem()
self.assertEqual(item.Key, 'PACKAGE_NAME')
self.assertEqual(item.Value, 'MdePkg')
def testDecDefine1(self):
obj = self.GetObj('PACKAGE_NAME')
self.assertRaises(FatalError, obj._ParseItem)
def testDecDefine2(self):
obj = self.GetObj('unknown_key = ')
self.assertRaises(FatalError, obj._ParseItem)
def testDecDefine3(self):
obj = self.GetObj('PACKAGE_NAME = ')
self.assertRaises(FatalError, obj._ParseItem)
@@ -262,23 +262,23 @@ class DecLibraryTestCase(unittest.TestCase):
Obj = _DecLibraryclass(FileContent('dummy', Content.splitlines()))
Obj._RawData.CurrentLine = Obj._RawData.GetNextLine()
return Obj
def testNoInc(self):
obj = self.GetObj('UefiRuntimeLib')
self.assertRaises(FatalError, obj._ParseItem)
def testEmpty(self):
obj = self.GetObj(' | ')
self.assertRaises(FatalError, obj._ParseItem)
def testLibclassNaming(self):
obj = self.GetObj('lowercase_efiRuntimeLib|Include/Library/UefiRuntimeLib.h')
self.assertRaises(FatalError, obj._ParseItem)
def testLibclassExt(self):
obj = self.GetObj('RuntimeLib|Include/Library/UefiRuntimeLib.no_h')
self.assertRaises(FatalError, obj._ParseItem)
def testLibclassRelative(self):
obj = self.GetObj('RuntimeLib|Include/../UefiRuntimeLib.h')
self.assertRaises(FatalError, obj._ParseItem)
@@ -292,7 +292,7 @@ class DecPcdTestCase(unittest.TestCase):
Obj._RawData.CurrentLine = Obj._RawData.GetNextLine()
Obj._RawData.CurrentScope = [('PcdsFeatureFlag'.upper(), 'COMMON')]
return Obj
def testOK(self):
item = self.GetObj('gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable|FALSE|BOOLEAN|0x0000000d')._ParseItem()
self.assertEqual(item.TokenSpaceGuidCName, 'gEfiMdePkgTokenSpaceGuid')
@@ -300,26 +300,26 @@ class DecPcdTestCase(unittest.TestCase):
self.assertEqual(item.DefaultValue, 'FALSE')
self.assertEqual(item.DatumType, 'BOOLEAN')
self.assertEqual(item.TokenValue, '0x0000000d')
def testNoCvar(self):
obj = self.GetObj('123ai.PcdComponentNameDisable|FALSE|BOOLEAN|0x0000000d')
self.assertRaises(FatalError, obj._ParseItem)
def testSplit(self):
obj = self.GetObj('gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable FALSE|BOOLEAN|0x0000000d')
self.assertRaises(FatalError, obj._ParseItem)
obj = self.GetObj('gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable|FALSE|BOOLEAN|0x0000000d | abc')
self.assertRaises(FatalError, obj._ParseItem)
def testUnknownType(self):
obj = self.GetObj('gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable|FALSE|unknown|0x0000000d')
self.assertRaises(FatalError, obj._ParseItem)
def testVoid(self):
obj = self.GetObj('gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable|abc|VOID*|0x0000000d')
self.assertRaises(FatalError, obj._ParseItem)
def testUINT(self):
obj = self.GetObj('gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable|0xabc|UINT8|0x0000000d')
self.assertRaises(FatalError, obj._ParseItem)
@@ -342,26 +342,26 @@ class DecGuidTestCase(unittest.TestCase):
Obj._RawData.CurrentLine = Obj._RawData.GetNextLine()
Obj._RawData.CurrentScope = [('guids'.upper(), 'COMMON')]
return Obj
def testCValue(self):
item = self.GetObj('gEfiIpSecProtocolGuid={ 0xdfb386f7, 0xe100, 0x43ad,'
' {0x9c, 0x9a, 0xed, 0x90, 0xd0, 0x8a, 0x5e, 0x12 }}')._ParseItem()
self.assertEqual(item.GuidCName, 'gEfiIpSecProtocolGuid')
self.assertEqual(item.GuidCValue, '{ 0xdfb386f7, 0xe100, 0x43ad, {0x9c, 0x9a, 0xed, 0x90, 0xd0, 0x8a, 0x5e, 0x12 }}')
def testGuidString(self):
item = self.GetObj('gEfiIpSecProtocolGuid=1E73767F-8F52-4603-AEB4-F29B510B6766')._ParseItem()
self.assertEqual(item.GuidCName, 'gEfiIpSecProtocolGuid')
self.assertEqual(item.GuidCValue, '1E73767F-8F52-4603-AEB4-F29B510B6766')
def testNoValue1(self):
obj = self.GetObj('gEfiIpSecProtocolGuid')
self.assertRaises(FatalError, obj._ParseItem)
def testNoValue2(self):
obj = self.GetObj('gEfiIpSecProtocolGuid=')
self.assertRaises(FatalError, obj._ParseItem)
def testNoName(self):
obj = self.GetObj('=')
self.assertRaises(FatalError, obj._ParseItem)
@@ -376,7 +376,7 @@ class DecDecInitTestCase(unittest.TestCase):
class TmpFile:
def __init__(self, File):
self.File = File
def Write(self, Content):
try:
FileObj = open(self.File, 'w')
@@ -384,7 +384,7 @@ class TmpFile:
FileObj.close()
except:
pass
def Remove(self):
try:
os.remove(self.File)
@@ -404,13 +404,13 @@ class DecUESectionTestCase(unittest.TestCase):
[userextensions.intel."myid]
'''
)
def tearDown(self):
self.File.Remove()
def testUserExtentionHeader(self):
dec = Dec('test.dec', False)
# OK: [userextensions.intel."myid"]
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
dec._UserExtentionSectionParser()
@@ -419,7 +419,7 @@ class DecUESectionTestCase(unittest.TestCase):
self.assertEqual(dec._RawData.CurrentScope[0][1], 'intel')
self.assertEqual(dec._RawData.CurrentScope[0][2], '"myid"')
self.assertEqual(dec._RawData.CurrentScope[0][3], 'COMMON')
# OK: [userextensions.intel."myid".IA32]
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
dec._UserExtentionSectionParser()
@@ -428,11 +428,11 @@ class DecUESectionTestCase(unittest.TestCase):
self.assertEqual(dec._RawData.CurrentScope[0][1], 'intel')
self.assertEqual(dec._RawData.CurrentScope[0][2], '"myid"')
self.assertEqual(dec._RawData.CurrentScope[0][3], 'IA32')
# Fail: [userextensions.intel."myid".IA32,]
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
self.assertRaises(FatalError, dec._UserExtentionSectionParser)
# Fail: [userextensions.intel."myid]
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
self.assertRaises(FatalError, dec._UserExtentionSectionParser)
@@ -453,43 +453,43 @@ class DecSectionTestCase(unittest.TestCase):
[Includes, Includes.IA32] # common cannot be with other arch
[Includes.IA32, PcdsFeatureFlag] # different section name
''' )
def tearDown(self):
self.File.Remove()
def testSectionHeader(self):
dec = Dec('test.dec', False)
# [no section start or end
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
self.assertRaises(FatalError, dec._SectionHeaderParser)
#[,] # empty sub-section
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
self.assertRaises(FatalError, dec._SectionHeaderParser)
# [unknow_section_name]
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
self.assertRaises(FatalError, dec._SectionHeaderParser)
# [Includes.IA32.other] # no third one
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
self.assertRaises(FatalError, dec._SectionHeaderParser)
# [PcdsFeatureFlag, PcdsFixedAtBuild]
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
self.assertRaises(FatalError, dec._SectionHeaderParser)
# [Includes.IA32, Includes.IA32]
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
dec._SectionHeaderParser()
self.assertEqual(len(dec._RawData.CurrentScope), 1)
self.assertEqual(dec._RawData.CurrentScope[0][0], 'Includes'.upper())
self.assertEqual(dec._RawData.CurrentScope[0][1], 'IA32')
# [Includes, Includes.IA32] # common cannot be with other arch
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
self.assertRaises(FatalError, dec._SectionHeaderParser)
# [Includes.IA32, PcdsFeatureFlag] # different section name not allowed
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
self.assertRaises(FatalError, dec._SectionHeaderParser)
@@ -511,7 +511,7 @@ class DecDecCommentTestCase(unittest.TestCase):
self.assertEqual(dec._HeadComment[1][0], '##')
self.assertEqual(dec._HeadComment[1][1], 2)
File.Remove()
def testNoDoubleComment(self):
File = TmpFile('test.dec')
File.Write(

View File

@@ -1,11 +1,11 @@
## @file
# This file contain unit test for Test [Binary] section part of InfParser
# This file contain unit test for Test [Binary] section part of InfParser
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -49,7 +49,7 @@ GUID | Test/Test.guid | DEBUG
"""
#
# Have 3 elements, Type | FileName | Target
# Have 3 elements, Type | FileName | Target
# Target with MACRO defined in [Define] section
#
SectionStringsCommonItem4 = \
@@ -58,7 +58,7 @@ GUID | Test/Test.guid | $(TARGET)
"""
#
# Have 3 elements, Type | FileName | Target
# Have 3 elements, Type | FileName | Target
# FileName with MACRO defined in [Binary] section
#
SectionStringsCommonItem5 = \
@@ -115,7 +115,7 @@ GUID | Test/Test.guid | DEBUG | MSFT | TEST | TRUE | OVERFLOW
#-------------start of VER type binary item test input------------------------#
#
# Has 1 element, error format
# Has 1 element, error format
#
SectionStringsVerItem1 = \
"""
@@ -199,7 +199,7 @@ UI | Test/Test2.ui | * | FALSE
"""
#
# Has 1 element, error format
# Has 1 element, error format
#
SectionStringsUiItem4 = \
"""
@@ -253,7 +253,7 @@ def StringToSectionString(String):
continue
SectionString.append((Line, LineNo, ''))
LineNo = LineNo + 1
return SectionString
def PrepareTest(String):
@@ -269,7 +269,7 @@ def PrepareTest(String):
#
FileName = os.path.normpath(os.path.realpath(ValueList[1].strip()))
try:
TempFile = open (FileName, "w")
TempFile = open (FileName, "w")
TempFile.close()
except:
print("File Create Error")
@@ -278,24 +278,24 @@ def PrepareTest(String):
CurrentLine.SetLineString(Item[0])
CurrentLine.SetLineNo(Item[1])
InfLineCommentObject = InfLineCommentObject()
ItemList.append((ValueList, InfLineCommentObject, CurrentLine))
return ItemList
if __name__ == '__main__':
Logger.Initialize()
InfBinariesInstance = InfBinariesObject()
ArchList = ['COMMON']
Global.gINF_MODULE_DIR = os.getcwd()
AllPassedFlag = True
#
# For All Ui test
#
UiStringList = [
UiStringList = [
SectionStringsUiItem1,
SectionStringsUiItem2,
SectionStringsUiItem3,
@@ -303,10 +303,10 @@ if __name__ == '__main__':
SectionStringsUiItem5,
SectionStringsUiItem6,
SectionStringsUiItem7,
SectionStringsUiItem8
SectionStringsUiItem8
]
for Item in UiStringList:
for Item in UiStringList:
Ui = PrepareTest(Item)
if Item == SectionStringsUiItem4 or Item == SectionStringsUiItem5:
try:
@@ -314,11 +314,11 @@ if __name__ == '__main__':
except Logger.FatalError:
pass
else:
try:
try:
InfBinariesInstance.SetBinary(Ui = Ui, ArchList = ArchList)
except:
AllPassedFlag = False
AllPassedFlag = False
#
# For All Ver Test
#
@@ -331,25 +331,25 @@ if __name__ == '__main__':
SectionStringsVerItem6,
SectionStringsVerItem7
]
for Item in VerStringList:
for Item in VerStringList:
Ver = PrepareTest(Item)
if Item == SectionStringsVerItem1 or \
Item == SectionStringsVerItem2:
try:
InfBinariesInstance.SetBinary(Ver = Ver, ArchList = ArchList)
except:
pass
else:
try:
InfBinariesInstance.SetBinary(Ver = Ver, ArchList = ArchList)
except:
AllPassedFlag = False
AllPassedFlag = False
#
# For All Common Test
#
#
CommonStringList = [
SectionStringsCommonItem1,
SectionStringsCommonItem2,
@@ -363,23 +363,23 @@ if __name__ == '__main__':
SectionStringsCommonItem10
]
for Item in CommonStringList:
for Item in CommonStringList:
CommonBin = PrepareTest(Item)
if Item == SectionStringsCommonItem10 or \
Item == SectionStringsCommonItem1:
try:
InfBinariesInstance.SetBinary(CommonBinary = CommonBin, ArchList = ArchList)
except:
pass
else:
try:
InfBinariesInstance.SetBinary(Ver = Ver, ArchList = ArchList)
except:
print("Test Failed!")
AllPassedFlag = False
if AllPassedFlag :
print('All tests passed...')
else:

View File

@@ -3,9 +3,9 @@
#
# Copyright (c) 2011 - 2018, 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,
@@ -123,7 +123,7 @@ class PromptXml(object):
return CreateXmlElement('%s' % Key, Prompt.GetString(), [], [['Lang', Prompt.GetLang()]])
def __str__(self):
return "Prompt = %s Lang = %s" % (self.Prompt, self.Lang)
##
# HelpTextXml
#
@@ -184,7 +184,7 @@ class HeaderXml(object):
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)))
self.LicenseList.append((HeaderLicenseLang, XmlElement(SubItem, '%s/License' % Key)))
ModuleHeader = ModuleObject()
ModuleHeader.SetName(self.Name)
ModuleHeader.SetBaseName(self.BaseName)
@@ -379,7 +379,7 @@ class PackageHeaderXml(object):
NodeList = [Element1,
Element2
]
UNIPackageAbrstractList = []
UNIPackageDescriptionList = []
# Get Abstract and Description from Uni File
@@ -391,11 +391,11 @@ class PackageHeaderXml(object):
if not StringDefClassObject.StringValue:
continue
if StringDefClassObject.StringName == DataType.TAB_DEC_PACKAGE_ABSTRACT:
UNIPackageAbrstractList.append((GetLanguageCode1766(Lang),
UNIPackageAbrstractList.append((GetLanguageCode1766(Lang),
ConvertSpecialUnicodes(StringDefClassObject.StringValue)))
if StringDefClassObject.StringName == DataType.TAB_DEC_PACKAGE_DESCRIPTION:
UNIPackageDescriptionList.append((GetLanguageCode1766(Lang),
UNIPackageDescriptionList.append((GetLanguageCode1766(Lang),
ConvertSpecialUnicodes(StringDefClassObject.StringValue)))
# Get Abstract and Description from DEC File Header
@@ -411,7 +411,7 @@ class PackageHeaderXml(object):
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 = []
@@ -617,16 +617,16 @@ class UserExtensionsXml(object):
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,
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,
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)))
self.BinaryLicenseList.append((BinaryLicenseLang,
XmlElement(SubItem, '%s/BinaryLicense' % Key)))
DefineItem = XmlNode(Item, '%s/Define' % Key)
for SubItem in XmlList(DefineItem, 'Define/Statement'):
@@ -697,7 +697,7 @@ class UserExtensionsXml(object):
if Value:
ChildElement = CreateXmlElement('BinaryLicense', Value, [], [])
Root.appendChild(ChildElement)
NodeList = []
DefineDict = UserExtension.GetDefinesDict()
if DefineDict:
@@ -976,7 +976,7 @@ class FilenameXml(object):
#
if self.FileType == 'UEFI_IMAGE':
self.FileType = 'PE32'
Filename.SetGuidValue(Guid)
Filename.SetFileType(self.FileType)
Filename.SetFilename(self.Filename)

View File

@@ -3,9 +3,9 @@
#
# Copyright (c) 2011 - 2018, 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,
@@ -46,17 +46,17 @@ class GuidProtocolPpiXml(object):
self.CommonDefines = CommonDefinesXml()
self.HelpText = []
#
# Guid/Ppi/Library, internal used for indicate return object for
# Guid/Ppi/Library, internal used for indicate return object for
# FromXml
#
self.Type = ''
self.Type = ''
#
# there are slightly different field between package and module
#
self.Mode = Mode
self.GuidType = ''
self.VariableName = ''
def FromXml(self, Item, Key):
self.UiName = XmlAttribute(XmlNode(Item, '%s' % Key), 'UiName')
self.GuidType = XmlAttribute(XmlNode(Item, '%s' % Key), 'GuidType')
@@ -69,8 +69,8 @@ class GuidProtocolPpiXml(object):
HelpTextObj = HelpTextXml()
HelpTextObj.FromXml(HelpTextItem, '%s/HelpText' % Key)
self.HelpText.append(HelpTextObj)
if self.Type == 'Guid':
if self.Type == 'Guid':
GuidProtocolPpi = GuidObject()
elif self.Type == 'Protocol':
GuidProtocolPpi = ProtocolObject()
@@ -92,7 +92,7 @@ class GuidProtocolPpiXml(object):
['SupModList', GetStringOfList(GuidProtocolPpi.GetSupModuleList())], \
['FeatureFlag', ConvertNEToNOTEQ(GuidProtocolPpi.GetFeatureFlag())]
]
NodeList = [['CName', GuidProtocolPpi.GetCName()],
NodeList = [['CName', GuidProtocolPpi.GetCName()],
['GuidValue', GuidProtocolPpi.GetGuid()],
['VariableName', GuidProtocolPpi.VariableName]
]
@@ -100,7 +100,7 @@ class GuidProtocolPpiXml(object):
Tmp = HelpTextXml()
NodeList.append(Tmp.ToXml(Item))
Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)
return Root
def __str__(self):
@@ -118,12 +118,12 @@ class GuidXml(GuidProtocolPpiXml):
def __init__(self, Mode):
GuidProtocolPpiXml.__init__(self, Mode)
self.Type = 'Guid'
def FromXml(self, Item, Key):
def FromXml(self, Item, Key):
GuidProtocolPpi = GuidProtocolPpiXml.FromXml(self, Item, Key)
if self.Mode == 'Package':
GuidProtocolPpi.SetSupArchList(self.CommonDefines.SupArchList)
GuidProtocolPpi.SetSupModuleList(self.CommonDefines.SupModList)
GuidProtocolPpi.SetCName(self.CName)
@@ -139,16 +139,16 @@ class GuidXml(GuidProtocolPpiXml):
return GuidProtocolPpi
def ToXml(self, GuidProtocolPpi, Key):
if self.Mode == 'Package':
if self.Mode == 'Package':
AttributeList = \
[['GuidType', \
GetStringOfList(GuidProtocolPpi.GetGuidTypeList())], \
['SupArchList', \
GetStringOfList(GuidProtocolPpi.GetSupArchList())], \
['SupModList', \
GetStringOfList(GuidProtocolPpi.GetSupModuleList())],
GetStringOfList(GuidProtocolPpi.GetSupModuleList())],
]
NodeList = [['CName', GuidProtocolPpi.GetCName()],
NodeList = [['CName', GuidProtocolPpi.GetCName()],
['GuidValue', GuidProtocolPpi.GetGuid()],
]
else:
@@ -159,7 +159,7 @@ class GuidXml(GuidProtocolPpiXml):
GetStringOfList(GuidProtocolPpi.GetSupArchList())], \
['FeatureFlag', ConvertNEToNOTEQ(GuidProtocolPpi.GetFeatureFlag())]
]
NodeList = [['CName', GuidProtocolPpi.GetCName()],
NodeList = [['CName', GuidProtocolPpi.GetCName()],
['VariableName', GuidProtocolPpi.GetVariableName()]
]
@@ -167,7 +167,7 @@ class GuidXml(GuidProtocolPpiXml):
Tmp = HelpTextXml()
NodeList.append(Tmp.ToXml(Item))
Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)
return Root
##
#Protocol Xml
@@ -176,11 +176,11 @@ class ProtocolXml(GuidProtocolPpiXml):
def __init__(self, Mode):
GuidProtocolPpiXml.__init__(self, Mode)
self.Type = 'Protocol'
def FromXml(self, Item, Key):
GuidProtocolPpi = GuidProtocolPpiXml.FromXml(self, Item, Key)
if self.Mode == 'Package':
GuidProtocolPpi.SetFeatureFlag(self.CommonDefines.FeatureFlag)
GuidProtocolPpi.SetFeatureFlag(self.CommonDefines.FeatureFlag)
GuidProtocolPpi.SetSupArchList(self.CommonDefines.SupArchList)
GuidProtocolPpi.SetSupModuleList(self.CommonDefines.SupModList)
GuidProtocolPpi.SetCName(self.CName)
@@ -196,11 +196,11 @@ class ProtocolXml(GuidProtocolPpiXml):
GuidProtocolPpi.SetSupArchList(self.CommonDefines.SupArchList)
GuidProtocolPpi.SetFeatureFlag(ConvertNOTEQToNE(self.CommonDefines.FeatureFlag))
GuidProtocolPpi.SetCName(self.CName)
return GuidProtocolPpi
def ToXml(self, GuidProtocolPpi, Key):
if self.Mode == 'Package':
if self.Mode == 'Package':
AttributeList = \
[['SupArchList', \
GetStringOfList(GuidProtocolPpi.GetSupArchList())], \
@@ -208,7 +208,7 @@ class ProtocolXml(GuidProtocolPpiXml):
GetStringOfList(GuidProtocolPpi.GetSupModuleList())], \
['FeatureFlag', GuidProtocolPpi.GetFeatureFlag()]
]
NodeList = [['CName', GuidProtocolPpi.GetCName()],
NodeList = [['CName', GuidProtocolPpi.GetCName()],
['GuidValue', GuidProtocolPpi.GetGuid()],
]
else:
@@ -219,14 +219,14 @@ class ProtocolXml(GuidProtocolPpiXml):
GetStringOfList(GuidProtocolPpi.GetSupArchList())], \
['FeatureFlag', ConvertNEToNOTEQ(GuidProtocolPpi.GetFeatureFlag())]
]
NodeList = [['CName', GuidProtocolPpi.GetCName()],
NodeList = [['CName', GuidProtocolPpi.GetCName()],
]
for Item in GuidProtocolPpi.GetHelpTextList():
Tmp = HelpTextXml()
NodeList.append(Tmp.ToXml(Item))
Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)
return Root
##
#Ppi Xml
@@ -235,7 +235,7 @@ class PpiXml(GuidProtocolPpiXml):
def __init__(self, Mode):
GuidProtocolPpiXml.__init__(self, Mode)
self.Type = 'Ppi'
def FromXml(self, Item, Key):
GuidProtocolPpi = GuidProtocolPpiXml.FromXml(self, Item, Key)
if self.Mode == 'Package':
@@ -254,16 +254,16 @@ class PpiXml(GuidProtocolPpiXml):
GuidProtocolPpi.SetSupArchList(self.CommonDefines.SupArchList)
GuidProtocolPpi.SetFeatureFlag(ConvertNOTEQToNE(self.CommonDefines.FeatureFlag))
GuidProtocolPpi.SetCName(self.CName)
return GuidProtocolPpi
def ToXml(self, GuidProtocolPpi, Key):
if self.Mode == 'Package':
AttributeList = \
[['SupArchList', \
GetStringOfList(GuidProtocolPpi.GetSupArchList())],
GetStringOfList(GuidProtocolPpi.GetSupArchList())],
]
NodeList = [['CName', GuidProtocolPpi.GetCName()],
NodeList = [['CName', GuidProtocolPpi.GetCName()],
['GuidValue', GuidProtocolPpi.GetGuid()],
]
else:
@@ -274,9 +274,9 @@ class PpiXml(GuidProtocolPpiXml):
GetStringOfList(GuidProtocolPpi.GetSupArchList())], \
['FeatureFlag', ConvertNEToNOTEQ(GuidProtocolPpi.GetFeatureFlag())]
]
NodeList = [['CName', GuidProtocolPpi.GetCName()],
NodeList = [['CName', GuidProtocolPpi.GetCName()],
]
for Item in GuidProtocolPpi.GetHelpTextList():
Tmp = HelpTextXml()
NodeList.append(Tmp.ToXml(Item))

View File

@@ -3,9 +3,9 @@
#
# Copyright (c) 2011 - 2018, 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,
@@ -96,20 +96,20 @@ def ParseFileList(Line, Map, CurrentKey, PathFunc):
Attr = Token.split(TAB_EQUAL_SPLIT)
if len(Attr) != 2 or not Attr[0].strip() or not Attr[1].strip():
return False, ST.ERR_WRONG_FILELIST_FORMAT
Key = Attr[0].strip()
Val = Attr[1].strip()
if Key not in ['OS', 'Executable']:
return False, ST.ERR_UNKNOWN_FILELIST_ATTR % Key
if Key == 'OS' and Val not in ["Win32", "Win64", "Linux32",
"Linux64", "OS/X32", "OS/X64",
if Key == 'OS' and Val not in ["Win32", "Win64", "Linux32",
"Linux64", "OS/X32", "OS/X64",
"GenericWin", "GenericNix"]:
return False, ST.ERR_FILELIST_ATTR % 'OS'
elif Key == 'Executable' and Val not in ['true', 'false']:
return False, ST.ERR_FILELIST_ATTR % 'Executable'
FileList[1][Key] = Val
Map[CurrentKey].append(FileList)
return True, ''
@@ -143,7 +143,7 @@ def CreateHeaderXml(DistMap, Root):
#
# @param Map: Map
# @param Root: Root
# @param Tag: Tag
# @param Tag: Tag
#
def CreateToolsXml(Map, Root, Tag):
#
@@ -225,7 +225,7 @@ def ValidateRegValues(Key, Value):
def __ValidateDistHeaderName(Name):
if len(Name) < 1:
return False
for Char in Name:
if ord(Char) < 0x20 or ord(Char) >= 0x7f:
return False
@@ -314,12 +314,12 @@ def IniToXml(IniFile):
'ToolsHeader' : ToolsMap,
'MiscellaneousFilesHeader' : MiscMap
}
PathValidator = {
'ToolsHeader' : ValidateToolsFile,
'MiscellaneousFilesHeader' : ValidateMiscFile
}
ParsedSection = []
SectionName = ''
@@ -339,13 +339,13 @@ def IniToXml(IniFile):
if SectionName not in SectionMap:
IniParseError(ST.ERR_SECTION_NAME_INVALID % SectionName,
IniFile, Index+1)
if SectionName in ParsedSection:
IniParseError(ST.ERR_SECTION_REDEFINE % SectionName,
IniFile, Index+1)
else:
ParsedSection.append(SectionName)
Map = SectionMap[SectionName]
continue
if not Map:
@@ -363,7 +363,7 @@ def IniToXml(IniFile):
#
# Special for FileList
#
Valid, Cause = ParseFileList(Line, Map, CurrentKey,
Valid, Cause = ParseFileList(Line, Map, CurrentKey,
PathValidator[SectionName])
if not Valid:
IniParseError(Cause, IniFile, Index+1)
@@ -374,7 +374,7 @@ def IniToXml(IniFile):
# Or if string on the left side of '=' is not a keyword
#
Map[CurrentKey] = ''.join([Map[CurrentKey], '\n', Line])
Valid, Cause = ValidateValues(CurrentKey,
Valid, Cause = ValidateValues(CurrentKey,
Map[CurrentKey], SectionName)
if not Valid:
IniParseError(Cause, IniFile, Index+1)
@@ -390,7 +390,7 @@ def IniToXml(IniFile):
if Map[CurrentKey]:
IniParseError(ST.ERR_KEYWORD_REDEFINE % CurrentKey,
IniFile, Index+1)
if id(Map) != id(PreMap) and Map['Copyright']:
PreMap = Map
Copyright = Map['Copyright'].lower()
@@ -399,9 +399,9 @@ def IniToXml(IniFile):
IniParseError(ST.ERR_COPYRIGHT_CONTENT, IniFile, Index)
if not Copyright[Pos + len('copyright'):].lstrip(' ').startswith('('):
IniParseError(ST.ERR_COPYRIGHT_CONTENT, IniFile, Index)
if CurrentKey == 'FileList':
Valid, Cause = ParseFileList(TokenList[1], Map, CurrentKey,
Valid, Cause = ParseFileList(TokenList[1], Map, CurrentKey,
PathValidator[SectionName])
if not Valid:
IniParseError(Cause, IniFile, Index+1)
@@ -411,17 +411,17 @@ def IniToXml(IniFile):
Map[CurrentKey], SectionName)
if not Valid:
IniParseError(Cause, IniFile, Index+1)
if id(Map) != id(PreMap) and Map['Copyright'] and 'copyright' not in Map['Copyright'].lower():
IniParseError(ST.ERR_COPYRIGHT_CONTENT, IniFile, LastIndex)
#
# Check mandatory keys
#
CheckMdtKeys(DistMap, IniFile, LastIndex,
#
CheckMdtKeys(DistMap, IniFile, LastIndex,
(('ToolsHeader', ToolsMap), ('MiscellaneousFilesHeader', MiscMap))
)
return CreateXml(DistMap, ToolsMap, MiscMap, IniFile)
@@ -433,15 +433,15 @@ def IniToXml(IniFile):
# @param LastIndex: Last index of Ini file
# @param Maps: Tools and Misc section name and map. (('section_name', map),*)
#
def CheckMdtKeys(DistMap, IniFile, LastIndex, Maps):
def CheckMdtKeys(DistMap, IniFile, LastIndex, Maps):
MdtDistKeys = ['Name', 'GUID', 'Version', 'Vendor', 'Copyright', 'License', 'Abstract', 'XmlSpecification']
for Key in MdtDistKeys:
if Key not in DistMap or DistMap[Key] == '':
IniParseError(ST.ERR_KEYWORD_MANDATORY % Key, IniFile, LastIndex+1)
if '.' not in DistMap['Version']:
DistMap['Version'] = DistMap['Version'] + '.0'
DistMap['Date'] = str(strftime("%Y-%m-%dT%H:%M:%S", localtime()))
#
@@ -464,10 +464,10 @@ def CheckMdtKeys(DistMap, IniFile, LastIndex, Maps):
for Key in Map:
if Map[Key]:
NonEmptyKey += 1
if NonEmptyKey > 0 and not Map['FileList']:
IniParseError(ST.ERR_KEYWORD_MANDATORY % (Item[0] + '.FileList'), IniFile, LastIndex+1)
if NonEmptyKey > 0 and not Map['Name']:
IniParseError(ST.ERR_KEYWORD_MANDATORY % (Item[0] + '.Name'), IniFile, LastIndex+1)
@@ -478,7 +478,7 @@ def CheckMdtKeys(DistMap, IniFile, LastIndex, Maps):
# @param MiscMap: Misc Content
# @param IniFile: Ini File
#
def CreateXml(DistMap, ToolsMap, MiscMap, IniFile):
def CreateXml(DistMap, ToolsMap, MiscMap, IniFile):
Attrs = [['xmlns', 'http://www.uefi.org/2011/1.1'],
['xmlns:xsi', 'http:/www.w3.org/2001/XMLSchema-instance'],
]
@@ -493,7 +493,7 @@ def CreateXml(DistMap, ToolsMap, MiscMap, IniFile):
else:
FileName = IniFile + '.xml'
File = open(FileName, 'w')
try:
File.write(Root.toprettyxml(indent = ' '))
finally:

View File

@@ -3,9 +3,9 @@
#
# Copyright (c) 2011 - 2018, 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,
@@ -173,7 +173,7 @@ class PackageSurfaceAreaXml(object):
if XmlNode(Item, '/PackageSurfaceArea/ClonedFrom'):
ClonedFrom = Tmp.FromXml(XmlNode(Item, '/PackageSurfaceArea/ClonedFrom'), 'ClonedFrom')
Package.SetClonedFromList([ClonedFrom])
#
#
# LibraryClass
#
@@ -254,7 +254,7 @@ class PackageSurfaceAreaXml(object):
Tmp = PcdEntryXml()
PcdEntry = Tmp.FromXml2(SubItem, 'PcdEntry')
Package.SetPcdList(Package.GetPcdList() + [PcdEntry])
#
# Get PcdErrorCommentDict from PcdError in PcdEntry Node
#
@@ -263,7 +263,7 @@ class PackageSurfaceAreaXml(object):
if PcdErrorMessageList:
Package.PcdErrorCommentDict[(PcdEntry.GetTokenSpaceGuidCName(), PcdErrorObj.GetErrorNumber())] = \
PcdErrorMessageList
if XmlList(Item, '/PackageSurfaceArea/PcdDeclarations') and not \
XmlList(Item, '/PackageSurfaceArea/PcdDeclarations/PcdEntry'):
@@ -285,7 +285,7 @@ class PackageSurfaceAreaXml(object):
Module = Tmp.FromXml(SubItem, 'ModuleSurfaceArea')
ModuleDictKey = (Module.GetGuid(), Module.GetVersion(), Module.GetName(), Module.GetModulePath())
Package.ModuleDict[ModuleDictKey] = Module
#
#
# MiscellaneousFile
#
Tmp = MiscellaneousFileXml()
@@ -295,7 +295,7 @@ class PackageSurfaceAreaXml(object):
else:
Package.SetMiscFileList([])
#
#
# UserExtensions
#
for Item in XmlList(Item, '/PackageSurfaceArea/UserExtensions'):
@@ -372,7 +372,7 @@ class PackageSurfaceAreaXml(object):
GuidProtocolPpiNode.appendChild\
(Tmp.ToXml(GuidProtocolPpi, 'Entry'))
DomPackage.appendChild(GuidProtocolPpiNode)
#
#
# Ppi
#
GuidProtocolPpiNode = CreateXmlElement('PpiDeclarations', '', [], [])

View File

@@ -3,9 +3,9 @@
#
# Copyright (c) 2011 - 2018, 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,
@@ -49,7 +49,7 @@ class PcdErrorXml(object):
self.Expression = ''
self.ErrorNumber = ''
self.ErrorMessage = []
def FromXml(self, Item, Key):
self.ValidValueList = XmlElement(Item, '%s/ValidValueList' % Key)
self.ValidValueListLang = \
@@ -62,7 +62,7 @@ class PcdErrorXml(object):
ErrorMessageLang = \
XmlAttribute(XmlNode(ErrMsg, 'ErrorMessage'), 'Lang')
self.ErrorMessage.append((ErrorMessageLang, ErrorMessageString))
Error = PcdErrorObject()
Error.SetValidValue(self.ValidValueList)
Error.SetValidValueLang(self.ValidValueListLang)
@@ -70,7 +70,7 @@ class PcdErrorXml(object):
Error.SetExpression(self.Expression)
Error.SetErrorNumber(self.ErrorNumber)
Error.SetErrorMessageList(self.ErrorMessage)
return Error
def ToXml(self, PcdError, Key):
@@ -100,9 +100,9 @@ class PcdErrorXml(object):
CreateXmlElement('ErrorMessage', Item[1], [], [['Lang', Item[0]]])
NodeList.append(Element)
Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)
return Root
def TransferValidRange2Expr(self, TokenSpaceGuidCName, CName, ValidRange):
if self.Expression:
pass
@@ -125,7 +125,7 @@ class PcdErrorXml(object):
for MatchObj in HexMatch2.finditer(ValidRange):
MatchStr = MatchObj.group()
TransferedRangeStr = ' '.join(['', PcdName, MatchStr.strip()])
ValidRange = ValidRange.replace(MatchStr, TransferedRangeStr)
ValidRange = ValidRange.replace(MatchStr, TransferedRangeStr)
#
# Convert INT2 format range
#
@@ -133,36 +133,36 @@ class PcdErrorXml(object):
for MatchObj in IntMatch2.finditer(ValidRange):
MatchStr = MatchObj.group()
TransferedRangeStr = ' '.join(['', PcdName, MatchStr.strip()])
ValidRange = ValidRange.replace(MatchStr, TransferedRangeStr)
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)
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)
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 = \
@@ -170,16 +170,16 @@ class PcdErrorXml(object):
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:
@@ -188,8 +188,8 @@ class PcdErrorXml(object):
#
RangeItemList = re.compile('[\t\s]*0[xX][0-9a-fA-F]+[\t\s]*').findall(HexMatchedItem)
if RangeItemList and len(RangeItemList) == 2:
HexRangeDict[HexMatchedItem] = RangeItemList
HexRangeDict[HexMatchedItem] = RangeItemList
for Key in HexRangeDict.keys():
MaxItem = MixItem = ''
if int(HexRangeDict[Key][0], 16) > int(HexRangeDict[Key][1], 16):
@@ -198,7 +198,7 @@ class PcdErrorXml(object):
else:
MaxItem = HexRangeDict[Key][1]
MixItem = HexRangeDict[Key][0]
Range = ' %s - %s' % (MixItem.strip(), MaxItem.strip())
ValidRangeExpr = ValidRangeExpr.replace(Key, Range)
#
@@ -211,9 +211,9 @@ class PcdErrorXml(object):
# To match items on both sides of '-'
#
RangeItemList = re.compile('[\t\s]*\d+[\t\s]*').findall(MatchedItem)
if RangeItemList and len(RangeItemList) == 2:
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]):
@@ -222,11 +222,11 @@ class PcdErrorXml(object):
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
# Do the HEX2 conversion
#
for MatchObj in re.compile(HexPattern2).finditer(ValidRangeExpr):
MatchStr = MatchObj.group()
@@ -241,8 +241,8 @@ class PcdErrorXml(object):
ValidRangeExpr = ValidRangeExpr.replace(MatchStr, Range)
return ValidRangeExpr
def __str__(self):
return "ValidValueList = %s ValidValueListLang = %s ValidValueRange \
@@ -275,7 +275,7 @@ class PcdEntryXml(object):
##
# AsBuilt will use FromXml
#
#
def FromXml(self, Item, Key):
self.PcdItemType = \
XmlAttribute(XmlNode(Item, '%s' % Key), 'PcdItemType')
@@ -297,7 +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)
@@ -306,9 +306,9 @@ class PcdEntryXml(object):
PcdErrorObjXml = PcdErrorXml()
PcdErrorObj = PcdErrorObjXml.FromXml(PcdErrorItem, 'PcdError')
self.PcdError.append(PcdErrorObj)
self.DefaultValue = ConvertNOTEQToNE(self.DefaultValue)
PcdEntry = PcdObject()
PcdEntry.SetSupArchList(self.CommonDefines.SupArchList)
PcdEntry.SetTokenSpaceGuidCName(self.TokenSpaceGuidCName)
@@ -326,11 +326,11 @@ class PcdEntryXml(object):
PcdEntry.SetHelpTextList(GetHelpTextList(self.HelpText))
PcdEntry.SetPcdErrorsList(self.PcdError)
return PcdEntry
##
# Package will use FromXml2
#
#
def FromXml2(self, Item, Key):
self.TokenSpaceGuidCName = \
XmlElement(Item, '%s/TokenSpaceGuidCname' % Key)
@@ -353,9 +353,9 @@ class PcdEntryXml(object):
PcdErrorObjXml = PcdErrorXml()
PcdErrorObj = PcdErrorObjXml.FromXml(PcdErrorItem, 'PcdError')
self.PcdError.append(PcdErrorObj)
self.DefaultValue = ConvertNOTEQToNE(self.DefaultValue)
PcdEntry = PcdObject()
PcdEntry.SetSupArchList(self.CommonDefines.SupArchList)
PcdEntry.SetSupModuleList(self.CommonDefines.SupModList)
@@ -367,11 +367,11 @@ 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)
return PcdEntry
##
@@ -394,9 +394,9 @@ class PcdEntryXml(object):
PcdErrorObj = PcdErrorXml()
PcdErrorObj.FromXml(PcdErrorItem, 'PcdError')
self.PcdError.append(PcdErrorObj)
self.DefaultValue = ConvertNOTEQToNE(self.DefaultValue)
PcdEntry = PcdObject()
PcdEntry.SetSupArchList(self.CommonDefines.SupArchList)
PcdEntry.SetTokenSpaceGuidCName(self.TokenSpaceGuidCName)
@@ -408,15 +408,15 @@ class PcdEntryXml(object):
PcdEntry.SetHelpTextList(GetHelpTextList(self.HelpText))
PcdEntry.SetPcdErrorsList(self.PcdError)
return PcdEntry
def ToXml(self, PcdEntry, Key):
if self.PcdCName:
pass
DefaultValue = ConvertNEToNOTEQ(PcdEntry.GetDefaultValue())
AttributeList = \
[['SupArchList', GetStringOfList(PcdEntry.GetSupArchList())], \
['PcdUsage', PcdEntry.GetValidUsage()], \
@@ -425,7 +425,7 @@ class PcdEntryXml(object):
]
NodeList = [['TokenSpaceGuidCname', PcdEntry.GetTokenSpaceGuidCName()],
['TokenSpaceGuidValue', PcdEntry.GetTokenSpaceGuidValue()],
['Token', PcdEntry.GetToken()],
['Token', PcdEntry.GetToken()],
['CName', PcdEntry.GetCName()],
['DatumType', PcdEntry.GetDatumType()],
['ValidUsage', GetStringOfList(PcdEntry.GetValidUsage())],
@@ -433,26 +433,26 @@ class PcdEntryXml(object):
['MaxDatumSize', PcdEntry.GetMaxDatumSize()],
['Offset', PcdEntry.GetOffset()],
]
for Item in PcdEntry.GetHelpTextList():
Tmp = HelpTextXml()
NodeList.append(Tmp.ToXml(Item))
for Item in PcdEntry.GetPcdErrorsList():
Tmp = PcdErrorXml()
NodeList.append(Tmp.ToXml(Item, 'PcdError'))
Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)
return Root
##
# Package will use ToXml2
#
#
def ToXml2(self, PcdEntry, Key):
if self.PcdCName:
pass
DefaultValue = ConvertNEToNOTEQ(PcdEntry.GetDefaultValue())
AttributeList = \
[['SupArchList', GetStringOfList(PcdEntry.GetSupArchList())], \
['SupModList', GetStringOfList(PcdEntry.GetSupModuleList())]
@@ -468,7 +468,7 @@ class PcdEntryXml(object):
for Item in PcdEntry.GetPromptList():
Tmp = PromptXml()
NodeList.append(Tmp.ToXml(Item))
for Item in PcdEntry.GetHelpTextList():
Tmp = HelpTextXml()
NodeList.append(Tmp.ToXml(Item))
@@ -476,9 +476,9 @@ class PcdEntryXml(object):
for Item in PcdEntry.GetPcdErrorsList():
Tmp = PcdErrorXml()
NodeList.append(Tmp.ToXml(Item, 'PcdError'))
Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)
return Root
##
# Module will use ToXml3
@@ -486,9 +486,9 @@ class PcdEntryXml(object):
def ToXml3(self, PcdEntry, Key):
if self.PcdCName:
pass
DefaultValue = ConvertNEToNOTEQ(PcdEntry.GetDefaultValue())
AttributeList = \
[['SupArchList', GetStringOfList(PcdEntry.GetSupArchList())], \
['PcdUsage', PcdEntry.GetValidUsage()], \
@@ -499,29 +499,29 @@ class PcdEntryXml(object):
['TokenSpaceGuidCName', PcdEntry.GetTokenSpaceGuidCName()],
['DefaultValue', DefaultValue],
]
for Item in PcdEntry.GetHelpTextList():
Tmp = HelpTextXml()
NodeList.append(Tmp.ToXml(Item))
for Item in PcdEntry.GetPcdErrorsList():
Tmp = PcdErrorXml()
NodeList.append(Tmp.ToXml(Item, 'PcdError'))
Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)
return Root
##
# AsBuild Module will use ToXml4
#
def ToXml4(self, PcdEntry, Key):
if self.PcdCName:
pass
DefaultValue = ConvertNEToNOTEQ(PcdEntry.GetDefaultValue())
AttributeList = []
NodeList = [
['TokenSpaceGuidValue', PcdEntry.GetTokenSpaceGuidValue()],
['PcdCName', PcdEntry.GetCName()],
@@ -531,18 +531,18 @@ class PcdEntryXml(object):
['Value', DefaultValue],
['Offset', PcdEntry.GetOffset()]
]
for Item in PcdEntry.GetHelpTextList():
Tmp = HelpTextXml()
NodeList.append(Tmp.ToXml(Item))
for Item in PcdEntry.GetPcdErrorsList():
Tmp = PcdErrorXml()
NodeList.append(Tmp.ToXml(Item, 'PcdError'))
Root = CreateXmlElement('%s' % Key, '', NodeList, AttributeList)
return Root
def __str__(self):
Str = \

View File

@@ -1,11 +1,11 @@
## @file
# This file is used to parse a xml file of .PKG file
#
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -89,7 +89,7 @@ class DistributionPackageXml(object):
DPLicense = DpHeader.GetLicense()[0][1]
else:
DPLicense = ''
CheckDict['Name'] = DpHeader.GetName()
CheckDict['GUID'] = DpHeader.GetGuid()
CheckDict['Version'] = DpHeader.GetVersion()
@@ -119,7 +119,7 @@ class DistributionPackageXml(object):
ValidateMS(self.DistP.ModuleSurfaceArea[Key], ['DistributionPackage', 'ModuleSurfaceArea'])
#
# Check Each Tool
# Check Each Tool
#
if self.DistP.Tools:
XmlTreeLevel = ['DistributionPackage', 'Tools', 'Header']
@@ -195,7 +195,7 @@ class DistributionPackageXml(object):
ModuleKey = (Module.GetGuid(), Module.GetVersion(), Module.GetName(), Module.GetModulePath())
self.DistP.ModuleSurfaceArea[ModuleKey] = Module
#
#
# Parse Tools
#
Tmp = MiscellaneousFileXml()
@@ -252,7 +252,7 @@ class DistributionPackageXml(object):
Msa = ModuleSurfaceAreaXml()
DomModule = Msa.ToXml(Module)
Root.appendChild(DomModule)
#
#
# Parse Tools
#
Tmp = MiscellaneousFileXml()
@@ -307,7 +307,7 @@ class DistributionPackageXml(object):
#
# Remove SupModList="COMMON" or "common"
#
#
XmlContent = \
re.sub(r'[\s\r\n]*SupModList[\s\r\n]*=[\s\r\n]*"[\s\r\n]*COMMON'
'[\s\r\n]*"', '', XmlContent)
@@ -324,7 +324,7 @@ class DistributionPackageXml(object):
# Check if any required item is missing in ModuleSurfaceArea
#
# @param Module: The ModuleSurfaceArea to be checked
# @param XmlTreeLevel: The top level of Module
# @param XmlTreeLevel: The top level of Module
#
def ValidateMS(Module, TopXmlTreeLevel):
ValidateMS1(Module, TopXmlTreeLevel)
@@ -336,7 +336,7 @@ def ValidateMS(Module, TopXmlTreeLevel):
# Check if any required item is missing in ModuleSurfaceArea
#
# @param Module: The ModuleSurfaceArea to be checked
# @param XmlTreeLevel: The top level of Module
# @param XmlTreeLevel: The top level of Module
#
def ValidateMS1(Module, TopXmlTreeLevel):
#
@@ -421,10 +421,10 @@ def ValidateMS1(Module, TopXmlTreeLevel):
IsRequiredItemListNull(CheckDict, XmlTreeLevel)
#
# If SupArchList is used to identify different EntryPoint, UnloadImage, Constructor/Destructor elements and
# If SupArchList is used to identify different EntryPoint, UnloadImage, Constructor/Destructor elements and
# that SupArchList does not match ModuleSurfaceArea.ModuleProperties:SupArchList, the tool must exit gracefully,
# informing the user that the EDK II Build system does not support different EntryPoint, UnloadImage,
# Constructor or Destructor elements based on Architecture type. Two SupArchList attributes are considered
# informing the user that the EDK II Build system does not support different EntryPoint, UnloadImage,
# Constructor or Destructor elements based on Architecture type. Two SupArchList attributes are considered
# identical if it lists the same CPU architectures in any order.
#
for Item in Module.GetExternList():
@@ -459,7 +459,7 @@ def ValidateMS1(Module, TopXmlTreeLevel):
# Check if any required item is missing in ModuleSurfaceArea
#
# @param Module: The ModuleSurfaceArea to be checked
# @param XmlTreeLevel: The top level of Module
# @param XmlTreeLevel: The top level of Module
#
def ValidateMS2(Module, TopXmlTreeLevel):
#
@@ -485,7 +485,7 @@ def ValidateMS2(Module, TopXmlTreeLevel):
Logger.Error("UPT", FORMAT_INVALID, ERR_FILE_NAME_INVALIDE % Module.GetModulePath())
#
# Check ModuleProperties->BootMode
# Check ModuleProperties->BootMode
#
XmlTreeLevel = TopXmlTreeLevel + ['ModuleProperties'] + ['BootMode']
for Item in Module.GetBootModeList():
@@ -494,7 +494,7 @@ def ValidateMS2(Module, TopXmlTreeLevel):
IsRequiredItemListNull(CheckDict, XmlTreeLevel)
#
# Check ModuleProperties->Event
# Check ModuleProperties->Event
#
XmlTreeLevel = TopXmlTreeLevel + ['ModuleProperties'] + ['Event']
for Item in Module.GetEventList():
@@ -503,7 +503,7 @@ def ValidateMS2(Module, TopXmlTreeLevel):
IsRequiredItemListNull(CheckDict, XmlTreeLevel)
#
# Check ModuleProperties->Hob
# Check ModuleProperties->Hob
#
XmlTreeLevel = TopXmlTreeLevel + ['ModuleProperties'] + ['HOB']
for Item in Module.GetHobList():
@@ -512,8 +512,8 @@ def ValidateMS2(Module, TopXmlTreeLevel):
IsRequiredItemListNull(CheckDict, XmlTreeLevel)
#
# The UDP Specification supports the module type of UEFI_RUNTIME_DRIVER, which is not present in the EDK II INF
# File Specification v. 1.23, so UPT must perform the following translation that include the generation of a
# The UDP Specification supports the module type of UEFI_RUNTIME_DRIVER, which is not present in the EDK II INF
# File Specification v. 1.23, so UPT must perform the following translation that include the generation of a
# [Depex] section.
#
if Module.ModuleType == "UEFI_RUNTIME_DRIVER":
@@ -549,7 +549,7 @@ def ValidateMS2(Module, TopXmlTreeLevel):
'Usage':Item.GetUsage()}
IsRequiredItemListNull(CheckDict, XmlTreeLevel)
#
# If the LibraryClass:SupModList is not "UNDEFINED" the LIBRARY_CLASS entry must have the list
# If the LibraryClass:SupModList is not "UNDEFINED" the LIBRARY_CLASS entry must have the list
# appended using the format:
# LIBRARY_CLASS = <ClassName> ["|" <Edk2ModuleTypeList>]
#
@@ -574,10 +574,10 @@ def ValidateMS2(Module, TopXmlTreeLevel):
#
# For Library modules (indicated by a LIBRARY_CLASS statement in the [Defines] section)
# If the SupModList attribute of the CONSTRUCTOR or DESTRUCTOR element does not match the Supported Module
# Types listed after "LIBRARY_CLASS = <Keyword> |", the tool should gracefully exit with an error message
# stating that there is a conflict in the module types the CONSTRUCTOR/DESTRUCTOR is to be used with and
# For Library modules (indicated by a LIBRARY_CLASS statement in the [Defines] section)
# If the SupModList attribute of the CONSTRUCTOR or DESTRUCTOR element does not match the Supported Module
# Types listed after "LIBRARY_CLASS = <Keyword> |", the tool should gracefully exit with an error message
# stating that there is a conflict in the module types the CONSTRUCTOR/DESTRUCTOR is to be used with and
# the Module types this Library supports.
#
if IsLibraryModule:
@@ -591,10 +591,10 @@ def ValidateMS2(Module, TopXmlTreeLevel):
RaiseError=True)
#
# If the module is not a library module, the MODULE_TYPE listed in the ModuleSurfaceArea.Header must match the
# SupModList attribute. If these conditions cannot be met, the tool must exit gracefully, informing the user
# If the module is not a library module, the MODULE_TYPE listed in the ModuleSurfaceArea.Header must match the
# SupModList attribute. If these conditions cannot be met, the tool must exit gracefully, informing the user
# that the EDK II Build system does not currently support the features required by this Module.
#
#
if not IsLibraryModule:
for Item in Module.GetExternList():
if hasattr(Item, 'SupModList') and len(Item.SupModList) > 0 and \
@@ -628,7 +628,7 @@ def ValidateMS2(Module, TopXmlTreeLevel):
# Check if any required item is missing in ModuleSurfaceArea
#
# @param Module: The ModuleSurfaceArea to be checked
# @param XmlTreeLevel: The top level of Module
# @param XmlTreeLevel: The top level of Module
#
def ValidateMS3(Module, TopXmlTreeLevel):
#
@@ -666,12 +666,12 @@ def ValidateMS3(Module, TopXmlTreeLevel):
for AsBuilt in Item.GetAsBuiltList():
#
# Check LibInstance
#
#
if len(AsBuilt.LibraryInstancesList) == 1 and not AsBuilt.LibraryInstancesList[0]:
CheckDict = {'GUID':''}
XmlTreeLevel = TopXmlTreeLevel + ['BinaryFiles', 'BinaryFile', 'AsBuilt', 'LibraryInstances']
IsRequiredItemListNull(CheckDict, XmlTreeLevel)
for LibItem in AsBuilt.LibraryInstancesList:
CheckDict = {'Guid':LibItem.Guid,
'Version':LibItem.Version}
@@ -925,7 +925,7 @@ def ValidatePS2(Package):
#
# Check if any required item is missing in PackageSurfaceArea
#
# @param Package: The PackageSurfaceArea to be checked
# @param Package: The PackageSurfaceArea to be checked
#
def ValidatePackageSurfaceArea(Package):
ValidatePS1(Package)

View File

@@ -1,11 +1,11 @@
## @file
# This file is used to parse a xml file of .PKG file
#
# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -21,7 +21,7 @@ from Logger.ToolError import PARSER_ERROR
import Logger.Log as Logger
## ConvertVariableName()
# Convert VariableName to be L"string",
# Convert VariableName to be L"string",
# input of UCS-2 format Hex Array or L"string" (C style.) could be converted successfully,
# others will not.
#
@@ -31,11 +31,11 @@ import Logger.Log as Logger
def ConvertVariableName(VariableName):
VariableName = VariableName.strip()
#
# check for L quoted string
# check for L quoted string
#
if VariableName.startswith('L"') and VariableName.endswith('"'):
return VariableName
#
# check for Hex Array, it should be little endian even number of hex numbers
#
@@ -52,7 +52,7 @@ def ConvertVariableName(VariableName):
SecondByte = int(ValueList[Index + 1], 16)
if SecondByte != 0:
return None
if FirstByte not in xrange(0x20, 0x7F):
return None
TransferedStr += ('%c')%FirstByte
@@ -63,10 +63,10 @@ def ConvertVariableName(VariableName):
## IsRequiredItemListNull
#
# Check if a required XML section item/attribue is NULL
#
#
# @param ItemList: The list of items to be checked
# @param XmlTreeLevel: The error message tree level
#
#
def IsRequiredItemListNull(ItemDict, XmlTreeLevel):
for Key in ItemDict:
if not ItemDict[Key]:
@@ -74,7 +74,7 @@ def IsRequiredItemListNull(ItemDict, XmlTreeLevel):
ErrorMsg = ERR_XML_PARSER_REQUIRED_ITEM_MISSING % (Key, Msg)
Logger.Error('\nUPT', PARSER_ERROR, ErrorMsg, RaiseError=True)
## Get help text
## Get help text
#
# @param HelpText
#
@@ -86,8 +86,8 @@ def GetHelpTextList(HelpText):
HelpTextObj.SetString(HelT.HelpText)
HelpTextList.append(HelpTextObj)
return HelpTextList
## Get Prompt text
## Get Prompt text
#
# @param Prompt
#

View File

@@ -4,11 +4,11 @@
# This file is required to make Python interpreter treat the directory
# as containing package.
#
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, 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,
@@ -17,4 +17,4 @@
'''
Xml
'''
'''