From nobody Sun May 5 07:52:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1522854116199731.7139388132031; Wed, 4 Apr 2018 08:01:56 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 009E5224A9ECA; Wed, 4 Apr 2018 08:01:54 -0700 (PDT) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1053321FB7D45 for ; Wed, 4 Apr 2018 08:01:53 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Apr 2018 08:01:52 -0700 Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.141]) by orsmga002.jf.intel.com with ESMTP; 04 Apr 2018 08:01:52 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,406,1517904000"; d="scan'208";a="47914450" From: Jaben Carsey To: edk2-devel@lists.01.org Date: Wed, 4 Apr 2018 08:01:44 -0700 Message-Id: <43079dcb6b2f922ea3319930df21c31062f39a56.1522854049.git.jaben.carsey@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: In-Reply-To: References: Subject: [edk2] [PATCH v1 1/2] BaseTools: copy a dictionary from InfClassObject to BuildReport X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" InfClassObject will be deleted. Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey Reviewed-by: Yonghong Zhu =20 --- BaseTools/Source/Python/build/BuildReport.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Sourc= e/Python/build/BuildReport.py index 966a2aa5abf1..a0499e884a0a 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -33,7 +33,6 @@ from Common import EdkLogger from Common.Misc import SaveFileOnChange from Common.Misc import GuidStructureByteArrayToGuidString from Common.Misc import GuidStructureStringToGuidString -from Common.InfClassObject import gComponentType2ModuleType from Common.BuildToolError import FILE_WRITE_FAILURE from Common.BuildToolError import CODE_ERROR from Common.BuildToolError import COMMAND_FAILURE @@ -48,6 +47,21 @@ from Common.DataType import * import collections from Common.Expression import * =20 +gComponentType2ModuleType =3D { + "LIBRARY" : "BASE", + "SECURITY_CORE" : "SEC", + "PEI_CORE" : "PEI_CORE", + "COMBINED_PEIM_DRIVER" : "PEIM", + "PIC_PEIM" : "PEIM", + "RELOCATABLE_PEIM" : "PEIM", + "PE32_PEIM" : "PEIM", + "BS_DRIVER" : "DXE_DRIVER", + "RT_DRIVER" : "DXE_RUNTIME_DRIVER", + "SAL_RT_DRIVER" : "DXE_SAL_DRIVER", + "APPLICATION" : "UEFI_APPLICATION", + "LOGO" : "BASE", +} + ## Pattern to extract contents in EDK DXS files gDxsDependencyPattern =3D re.compile(r"DEPENDENCY_START(.+)DEPENDENCY_END"= , re.DOTALL) =20 --=20 2.16.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun May 5 07:52:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1522854119733113.44845989130431; Wed, 4 Apr 2018 08:01:59 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2CB52225501CF; Wed, 4 Apr 2018 08:01:54 -0700 (PDT) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2BE2521FB7D5A for ; Wed, 4 Apr 2018 08:01:53 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Apr 2018 08:01:52 -0700 Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.141]) by orsmga002.jf.intel.com with ESMTP; 04 Apr 2018 08:01:52 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,406,1517904000"; d="scan'208";a="47914453" From: Jaben Carsey To: edk2-devel@lists.01.org Date: Wed, 4 Apr 2018 08:01:45 -0700 Message-Id: X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: In-Reply-To: References: Subject: [edk2] [PATCH v1 2/2] BaseTools: Remove unneeded files X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" These files are not used by any tool: BaseTools/Source/Python/Common/DecClassObject.py BaseTools/Source/Python/Common/DscClassObject.py BaseTools/Source/Python/Common/FdfClassObject.py BaseTools/Source/Python/Common/InfClassObject.py Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/Common/DecClassObject.py | 553 -------- BaseTools/Source/Python/Common/DscClassObject.py | 1434 ------------------= -- BaseTools/Source/Python/Common/FdfClassObject.py | 106 -- BaseTools/Source/Python/Common/InfClassObject.py | 1105 --------------- 4 files changed, 3198 deletions(-) diff --git a/BaseTools/Source/Python/Common/DecClassObject.py b/BaseTools/S= ource/Python/Common/DecClassObject.py deleted file mode 100644 index ed998d3b677d..000000000000 --- a/BaseTools/Source/Python/Common/DecClassObject.py +++ /dev/null @@ -1,553 +0,0 @@ -## @file -# This file is used to define each component of DEC file -# -# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BS= D License -# which accompanies this distribution. The full text of the license may b= e found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. -# - -## -# Import Modules -# -import Common.LongFilePathOs as os -from String import * -from DataType import * -from Identification import * -from Dictionary import * -from CommonDataClass.PackageClass import * -from CommonDataClass.CommonClass import PcdClass -from BuildToolError import * -from Table.TableDec import TableDec -import Database -from Parsing import * -import GlobalData -from Common.LongFilePathSupport import OpenLongFilePath as open - -# -# Global variable -# -Section =3D {TAB_UNKNOWN.upper() : MODEL_UNKNOWN, - TAB_DEC_DEFINES.upper() : MODEL_META_DATA_HEADER, - TAB_INCLUDES.upper() : MODEL_EFI_INCLUDE, - TAB_LIBRARY_CLASSES.upper() : MODEL_EFI_LIBRARY_CLASS, - TAB_COMPONENTS.upper() : MODEL_META_DATA_COMPONENT, - TAB_GUIDS.upper() : MODEL_EFI_GUID, - TAB_PROTOCOLS.upper() : MODEL_EFI_PROTOCOL, - TAB_PPIS.upper() : MODEL_EFI_PPI, - TAB_PCDS_FIXED_AT_BUILD_NULL.upper() : MODEL_PCD_FIXED_AT_BUILD, - TAB_PCDS_PATCHABLE_IN_MODULE_NULL.upper() : MODEL_PCD_PATCHABLE= _IN_MODULE, - TAB_PCDS_FEATURE_FLAG_NULL.upper() : MODEL_PCD_FEATURE_FLAG, - TAB_PCDS_DYNAMIC_EX_NULL.upper() : MODEL_PCD_DYNAMIC_EX, - TAB_PCDS_DYNAMIC_NULL.upper() : MODEL_PCD_DYNAMIC, - TAB_USER_EXTENSIONS.upper() : MODEL_META_DATA_USER_EXTENSION - } - - -## Dec -# -# This class defined the structure used in Dec object -#=20 -# @param Filename: Input value for Filename of Dec file, default = is None -# @param IsMergeAllArches: Input value for IsMergeAllArches -# True is to merge all arches -# Fales is not to merge all arches -# default is False -# @param IsToPackage: Input value for IsToPackage -# True is to transfer to PackageObject automatic= ally -# False is not to transfer to PackageObject auto= matically -# default is False -# @param WorkspaceDir: Input value for current workspace directory, d= efault is None -# -# @var Identification: To store value for Identification, it is a str= ucture as Identification -# @var Defines: To store value for Defines, it is a structure = as DecDefines -# @var UserExtensions: To store value for UserExtensions -# @var Package: To store value for Package, it is a structure = as PackageClass -# @var WorkspaceDir: To store value for WorkspaceDir -# @var Contents: To store value for Contents, it is a structure= as DecContents -# @var KeyList: To store value for KeyList, a list for all Key= s used in Dec -# -class Dec(object): - def __init__(self, Filename=3DNone, IsToDatabase=3DFalse, IsToPackage= =3DFalse, WorkspaceDir=3DNone, Database=3DNone, SupArchList=3DDataType.ARCH= _LIST): - self.Identification =3D Identification() - self.Package =3D PackageClass() - self.UserExtensions =3D '' - self.WorkspaceDir =3D WorkspaceDir - self.SupArchList =3D SupArchList - self.IsToDatabase =3D IsToDatabase - - self.Cur =3D Database.Cur - self.TblFile =3D Database.TblFile - self.TblDec =3D Database.TblDec - self.FileID =3D -1 - - self.KeyList =3D [ - TAB_INCLUDES, TAB_GUIDS, TAB_PROTOCOLS, TAB_PPIS, TAB_LIBRARY_= CLASSES, \ - TAB_PCDS_FIXED_AT_BUILD_NULL, TAB_PCDS_PATCHABLE_IN_MODULE_NUL= L, TAB_PCDS_FEATURE_FLAG_NULL, \ - TAB_PCDS_DYNAMIC_NULL, TAB_PCDS_DYNAMIC_EX_NULL, TAB_DEC_DEFIN= ES - ] - # - # Upper all KEYs to ignore case sensitive when parsing - # - self.KeyList =3D map(lambda c: c.upper(), self.KeyList) - - # - # Init RecordSet - # - self.RecordSet =3D {} - for Key in self.KeyList: - self.RecordSet[Section[Key]] =3D [] - - # - # Load Dec file if filename is not None - # - if Filename is not None: - self.LoadDecFile(Filename) - - # - # Transfer to Package Object if IsToPackage is True - # - if IsToPackage: - self.DecToPackage() - - ## Load Dec file - # - # Load the file if it exists - # - # @param Filename: Input value for filename of Dec file - # - def LoadDecFile(self, Filename): - # - # Insert a record for file - # - Filename =3D NormPath(Filename) - self.Identification.FileFullPath =3D Filename - (self.Identification.FileRelativePath, self.Identification.FileNam= e) =3D os.path.split(Filename) - self.FileID =3D self.TblFile.InsertFile(Filename, MODEL_FILE_DEC) - - # - # Init DecTable - # - #self.TblDec.Table =3D "Dec%s" % self.FileID - #self.TblDec.Create() - - # - # Init common datas - # - IfDefList, SectionItemList, CurrentSection, ArchList, ThirdList, I= ncludeFiles =3D \ - [], [], TAB_UNKNOWN, [], [], [] - LineNo =3D 0 - - # - # Parse file content - # - IsFindBlockComment =3D False - ReservedLine =3D '' - for Line in open(Filename, 'r'): - LineNo =3D LineNo + 1 - # - # Remove comment block - # - if Line.find(TAB_COMMENT_EDK_START) > -1: - ReservedLine =3D GetSplitList(Line, TAB_COMMENT_EDK_START,= 1)[0] - IsFindBlockComment =3D True - if Line.find(TAB_COMMENT_EDK_END) > -1: - Line =3D ReservedLine + GetSplitList(Line, TAB_COMMENT_EDK= _END, 1)[1] - ReservedLine =3D '' - IsFindBlockComment =3D False - if IsFindBlockComment: - continue - - # - # Remove comments at tail and remove spaces again - # - Line =3D CleanString(Line) - if Line =3D=3D '': - continue - - # - # Find a new section tab - # First insert previous section items - # And then parse the content of the new section - # - if Line.startswith(TAB_SECTION_START) and Line.endswith(TAB_SE= CTION_END): - # - # Insert items data of previous section - # - Model =3D Section[CurrentSection.upper()] - InsertSectionItemsIntoDatabase(self.TblDec, self.FileID, F= ilename, Model, CurrentSection, SectionItemList, ArchList, ThirdList, IfDef= List, self.RecordSet) - - # - # Parse the new section - # - SectionItemList =3D [] - ArchList =3D [] - ThirdList =3D [] - - CurrentSection =3D '' - LineList =3D GetSplitValueList(Line[len(TAB_SECTION_START)= :len(Line) - len(TAB_SECTION_END)], TAB_COMMA_SPLIT) - for Item in LineList: - ItemList =3D GetSplitValueList(Item, TAB_SPLIT) - if CurrentSection =3D=3D '': - CurrentSection =3D ItemList[0] - else: - if CurrentSection !=3D ItemList[0]: - EdkLogger.error("Parser", PARSER_ERROR, "Diffe= rent section names '%s' and '%s' are found in one section definition, this = is not allowed." % (CurrentSection, ItemList[0]), File=3DFilename, Line=3DL= ineNo, RaiseError=3DEdkLogger.IsRaiseError) - if CurrentSection.upper() not in self.KeyList: - RaiseParserError(Line, CurrentSection, Filename, '= ', LineNo) - ItemList.append('') - ItemList.append('') - if len(ItemList) > 5: - RaiseParserError(Line, CurrentSection, Filename, '= ', LineNo) - else: - if ItemList[1] !=3D '' and ItemList[1].upper() not= in ARCH_LIST_FULL: - EdkLogger.error("Parser", PARSER_ERROR, "Inval= id Arch definition '%s' found" % ItemList[1], File=3DFilename, Line=3DLineN= o, RaiseError=3DEdkLogger.IsRaiseError) - ArchList.append(ItemList[1].upper()) - ThirdList.append(ItemList[2]) - - continue - - # - # Not in any defined section - # - if CurrentSection =3D=3D TAB_UNKNOWN: - ErrorMsg =3D "%s is not in any defined section" % Line - EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=3DF= ilename, Line=3DLineNo, RaiseError=3DEdkLogger.IsRaiseError) - - # - # Add a section item - # - SectionItemList.append([Line, LineNo]) - # End of parse - #End of For - - # - # Insert items data of last section - # - Model =3D Section[CurrentSection.upper()] - InsertSectionItemsIntoDatabase(self.TblDec, self.FileID, Filename,= Model, CurrentSection, SectionItemList, ArchList, ThirdList, IfDefList, se= lf.RecordSet) - - # - # Replace all DEFINE macros with its actual values - # - ParseDefineMacro2(self.TblDec, self.RecordSet, GlobalData.gGlobalD= efines) - - ## Transfer to Package Object - #=20 - # Transfer all contents of a Dec file to a standard Package Object - # - def DecToPackage(self): - # - # Init global information for the file - # - ContainerFile =3D self.Identification.FileFullPath - - # - # Generate Package Header - # - self.GenPackageHeader(ContainerFile) - - # - # Generate Includes - # - self.GenIncludes(ContainerFile) - - # - # Generate Guids - # - self.GenGuidProtocolPpis(DataType.TAB_GUIDS, ContainerFile) - - # - # Generate Protocols - # - self.GenGuidProtocolPpis(DataType.TAB_PROTOCOLS, ContainerFile) - - # - # Generate Ppis - # - self.GenGuidProtocolPpis(DataType.TAB_PPIS, ContainerFile) - - # - # Generate LibraryClasses - # - self.GenLibraryClasses(ContainerFile) - - # - # Generate Pcds - # - self.GenPcds(ContainerFile) - - ## Get Package Header - # - # Gen Package Header of Dec as =3D - # - # @param ContainerFile: The Dec file full path=20 - # - def GenPackageHeader(self, ContainerFile): - EdkLogger.debug(2, "Generate PackageHeader ...") - # - # Update all defines item in database - # - RecordSet =3D self.RecordSet[MODEL_META_DATA_HEADER] - for Record in RecordSet: - ValueList =3D GetSplitValueList(Record[0], TAB_EQUAL_SPLIT) - if len(ValueList) !=3D 2: - RaiseParserError(Record[0], 'Defines', ContainerFile, ' =3D ', Record[2]) - ID, Value1, Value2, Arch, LineNo =3D Record[3], ValueList[0], = ValueList[1], Record[1], Record[2] - SqlCommand =3D """update %s set Value1 =3D '%s', Value2 =3D '%= s' - where ID =3D %s""" % (self.TblDec.Table, Conve= rtToSqlString2(Value1), ConvertToSqlString2(Value2), ID) - self.TblDec.Exec(SqlCommand) - - # - # Get detailed information - # - for Arch in self.SupArchList: - PackageHeader =3D PackageHeaderClass() - - PackageHeader.Name =3D QueryDefinesItem(self.TblDec, TAB_DEC_D= EFINES_PACKAGE_NAME, Arch, self.FileID)[0] - PackageHeader.Guid =3D QueryDefinesItem(self.TblDec, TAB_DEC_D= EFINES_PACKAGE_GUID, Arch, self.FileID)[0] - PackageHeader.Version =3D QueryDefinesItem(self.TblDec, TAB_DE= C_DEFINES_PACKAGE_VERSION, Arch, self.FileID)[0] - PackageHeader.FileName =3D self.Identification.FileName - PackageHeader.FullPath =3D self.Identification.FileFullPath - PackageHeader.DecSpecification =3D QueryDefinesItem(self.TblDe= c, TAB_DEC_DEFINES_DEC_SPECIFICATION, Arch, self.FileID)[0] - - self.Package.Header[Arch] =3D PackageHeader - - ## GenIncludes - # - # Gen Includes of Dec - #=20 - # - # @param ContainerFile: The Dec file full path=20 - # - def GenIncludes(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_INCLUDES) - Includes =3D {} - # - # Get all Includes - # - RecordSet =3D self.RecordSet[MODEL_EFI_INCLUDE] - - # - # Go through each arch - # - for Arch in self.SupArchList: - for Record in RecordSet: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON: - MergeArches(Includes, Record[0], Arch) - - for Key in Includes.keys(): - Include =3D IncludeClass() - Include.FilePath =3D NormPath(Key) - Include.SupArchList =3D Includes[Key] - self.Package.Includes.append(Include) - - ## GenPpis - # - # Gen Ppis of Dec - # =3D - # - # @param ContainerFile: The Dec file full path=20 - # - def GenGuidProtocolPpis(self, Type, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % Type) - Lists =3D {} - # - # Get all Items - # - RecordSet =3D self.RecordSet[Section[Type.upper()]] - - # - # Go through each arch - # - for Arch in self.SupArchList: - for Record in RecordSet: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON: - (Name, Value) =3D GetGuidsProtocolsPpisOfDec(Record[0]= , Type, ContainerFile, Record[2]) - MergeArches(Lists, (Name, Value), Arch) - if self.IsToDatabase: - SqlCommand =3D """update %s set Value1 =3D '%s', V= alue2 =3D '%s' - where ID =3D %s""" % (self.TblDec.= Table, ConvertToSqlString2(Name), ConvertToSqlString2(Value), Record[3]) - self.TblDec.Exec(SqlCommand) - - ListMember =3D None - if Type =3D=3D TAB_GUIDS: - ListMember =3D self.Package.GuidDeclarations - elif Type =3D=3D TAB_PROTOCOLS: - ListMember =3D self.Package.ProtocolDeclarations - elif Type =3D=3D TAB_PPIS: - ListMember =3D self.Package.PpiDeclarations - - for Key in Lists.keys(): - ListClass =3D GuidProtocolPpiCommonClass() - ListClass.CName =3D Key[0] - ListClass.Guid =3D Key[1] - ListClass.SupArchList =3D Lists[Key] - ListMember.append(ListClass) - - - ## GenLibraryClasses - # - # Gen LibraryClasses of Dec - # =3D - # - # @param ContainerFile: The Dec file full path=20 - # - def GenLibraryClasses(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_LIBRARY_CLASSES) - LibraryClasses =3D {} - # - # Get all Guids - # - RecordSet =3D self.RecordSet[MODEL_EFI_LIBRARY_CLASS] - - # - # Go through each arch - # - for Arch in self.SupArchList: - for Record in RecordSet: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON: - List =3D GetSplitValueList(Record[0], DataType.TAB_VAL= UE_SPLIT) - if len(List) !=3D 2: - RaiseParserError(Record[0], 'LibraryClasses', Cont= ainerFile, '|', Record[2]) - else: - CheckFileExist(self.Identification.FileRelativePat= h, List[1], ContainerFile, 'LibraryClasses', Record[0]) - MergeArches(LibraryClasses, (List[0], List[1]), Arch) - if self.IsToDatabase: - SqlCommand =3D """update %s set Value1 =3D '%s', V= alue2 =3D '%s', Value3 =3D '%s' - where ID =3D %s""" % (self.TblDec.= Table, ConvertToSqlString2(List[0]), ConvertToSqlString2(List[1]), SUP_MODU= LE_LIST_STRING, Record[3]) - self.TblDec.Exec(SqlCommand) - - - for Key in LibraryClasses.keys(): - LibraryClass =3D LibraryClassClass() - LibraryClass.LibraryClass =3D Key[0] - LibraryClass.RecommendedInstance =3D NormPath(Key[1]) - LibraryClass.SupModuleList =3D SUP_MODULE_LIST - LibraryClass.SupArchList =3D LibraryClasses[Key] - self.Package.LibraryClassDeclarations.append(LibraryClass) - - ## GenPcds - # - # Gen Pcds of Dec - # .||| - # - # @param ContainerFile: The Dec file full path=20 - # - def GenPcds(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_PCDS) - Pcds =3D {} - PcdToken =3D {} - # - # Get all Guids - # - RecordSet1 =3D self.RecordSet[MODEL_PCD_FIXED_AT_BUILD] - RecordSet2 =3D self.RecordSet[MODEL_PCD_PATCHABLE_IN_MODULE] - RecordSet3 =3D self.RecordSet[MODEL_PCD_FEATURE_FLAG] - RecordSet4 =3D self.RecordSet[MODEL_PCD_DYNAMIC_EX] - RecordSet5 =3D self.RecordSet[MODEL_PCD_DYNAMIC] - - # - # Go through each arch - # - for Arch in self.SupArchList: - for Record in RecordSet1: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON: - (TokenGuidCName, TokenName, Value, DatumType, Token, T= ype) =3D GetPcdOfDec(Record[0], TAB_PCDS_FIXED_AT_BUILD, ContainerFile, Rec= ord[2]) - MergeArches(Pcds, (TokenGuidCName, TokenName, Value, D= atumType, Token, Type), Arch) - PcdToken[Record[3]] =3D (TokenGuidCName, TokenName) - for Record in RecordSet2: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON: - (TokenGuidCName, TokenName, Value, DatumType, Token, T= ype) =3D GetPcdOfDec(Record[0], TAB_PCDS_PATCHABLE_IN_MODULE, ContainerFile= , Record[2]) - MergeArches(Pcds, (TokenGuidCName, TokenName, Value, D= atumType, Token, Type), Arch) - PcdToken[Record[3]] =3D (TokenGuidCName, TokenName) - for Record in RecordSet3: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON: - (TokenGuidCName, TokenName, Value, DatumType, Token, T= ype) =3D GetPcdOfDec(Record[0], TAB_PCDS_FEATURE_FLAG, ContainerFile, Recor= d[2]) - MergeArches(Pcds, (TokenGuidCName, TokenName, Value, D= atumType, Token, Type), Arch) - PcdToken[Record[3]] =3D (TokenGuidCName, TokenName) - for Record in RecordSet4: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON: - (TokenGuidCName, TokenName, Value, DatumType, Token, T= ype) =3D GetPcdOfDec(Record[0], TAB_PCDS_DYNAMIC_EX, ContainerFile, Record[= 2]) - MergeArches(Pcds, (TokenGuidCName, TokenName, Value, D= atumType, Token, Type), Arch) - PcdToken[Record[3]] =3D (TokenGuidCName, TokenName) - for Record in RecordSet5: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON: - (TokenGuidCName, TokenName, Value, DatumType, Token, T= ype) =3D GetPcdOfDec(Record[0], TAB_PCDS_DYNAMIC, ContainerFile, Record[2]) - MergeArches(Pcds, (TokenGuidCName, TokenName, Value, D= atumType, Token, Type), Arch) - PcdToken[Record[3]] =3D (TokenGuidCName, TokenName) - # - # Update to database - # - if self.IsToDatabase: - for Key in PcdToken.keys(): - SqlCommand =3D """update %s set Value2 =3D '%s' where ID = =3D %s""" % (self.TblDec.Table, ".".join((PcdToken[Key][0], PcdToken[Key][1= ])), Key) - self.TblDec.Exec(SqlCommand) - - for Key in Pcds.keys(): - Pcd =3D PcdClass() - Pcd.CName =3D Key[1] - Pcd.Token =3D Key[4] - Pcd.TokenSpaceGuidCName =3D Key[0] - Pcd.DatumType =3D Key[3] - Pcd.DefaultValue =3D Key[2] - Pcd.ItemType =3D Key[5] - Pcd.SupArchList =3D Pcds[Key] - self.Package.PcdDeclarations.append(Pcd) - - ## Show detailed information of Package - # - # Print all members and their values of Package class - # - def ShowPackage(self): - M =3D self.Package - for Arch in M.Header.keys(): - print '\nArch =3D', Arch - print 'Filename =3D', M.Header[Arch].FileName - print 'FullPath =3D', M.Header[Arch].FullPath - print 'BaseName =3D', M.Header[Arch].Name - print 'Guid =3D', M.Header[Arch].Guid - print 'Version =3D', M.Header[Arch].Version - print 'DecSpecification =3D', M.Header[Arch].DecSpecification - print '\nIncludes =3D', M.Includes - for Item in M.Includes: - print Item.FilePath, Item.SupArchList - print '\nGuids =3D', M.GuidDeclarations - for Item in M.GuidDeclarations: - print Item.CName, Item.Guid, Item.SupArchList - print '\nProtocols =3D', M.ProtocolDeclarations - for Item in M.ProtocolDeclarations: - print Item.CName, Item.Guid, Item.SupArchList - print '\nPpis =3D', M.PpiDeclarations - for Item in M.PpiDeclarations: - print Item.CName, Item.Guid, Item.SupArchList - print '\nLibraryClasses =3D', M.LibraryClassDeclarations - for Item in M.LibraryClassDeclarations: - print Item.LibraryClass, Item.RecommendedInstance, Item.SupMod= uleList, Item.SupArchList - print '\nPcds =3D', M.PcdDeclarations - for Item in M.PcdDeclarations: - print 'CName=3D', Item.CName, 'TokenSpaceGuidCName=3D', Item.T= okenSpaceGuidCName, 'DefaultValue=3D', Item.DefaultValue, 'ItemType=3D', It= em.ItemType, 'Token=3D', Item.Token, 'DatumType=3D', Item.DatumType, Item.S= upArchList - -## -# -# This acts like the main() function for the script, unless it is 'import'= ed into another -# script. -# -if __name__ =3D=3D '__main__': - EdkLogger.Initialize() - EdkLogger.SetLevel(EdkLogger.DEBUG_0) - - W =3D os.getenv('WORKSPACE') - F =3D os.path.join(W, 'Nt32Pkg/Nt32Pkg.dec') - - Db =3D Database.Database('Dec.db') - Db.InitDatabase() - - P =3D Dec(os.path.normpath(F), True, True, W, Db) - P.ShowPackage() - - Db.Close() diff --git a/BaseTools/Source/Python/Common/DscClassObject.py b/BaseTools/S= ource/Python/Common/DscClassObject.py deleted file mode 100644 index da3101ae0fe9..000000000000 --- a/BaseTools/Source/Python/Common/DscClassObject.py +++ /dev/null @@ -1,1434 +0,0 @@ -## @file -# This file is used to define each component of DSC file -# -# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BS= D License -# which accompanies this distribution. The full text of the license may b= e found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. -# - -## -# Import Modules -# -import Common.LongFilePathOs as os -import EdkLogger as EdkLogger -import Database -from String import * -from Parsing import * -from DataType import * -from Identification import * -from Dictionary import * -from CommonDataClass.PlatformClass import * -from CommonDataClass.CommonClass import SkuInfoClass -from BuildToolError import * -from Misc import sdict -import GlobalData -from Table.TableDsc import TableDsc -from Common.LongFilePathSupport import OpenLongFilePath as open - -# -# Global variable -# -Section =3D {TAB_UNKNOWN.upper() : MODEL_UNKNOWN, - TAB_DSC_DEFINES.upper() : MODEL_META_DATA_HEADER, - TAB_BUILD_OPTIONS.upper() : MODEL_META_DATA_BUILD_OPTION, - TAB_SKUIDS.upper() : MODEL_EFI_SKU_ID, - TAB_LIBRARIES.upper() : MODEL_EFI_LIBRARY_INSTANCE, - TAB_LIBRARY_CLASSES.upper() : MODEL_EFI_LIBRARY_CLASS, - TAB_PCDS_FIXED_AT_BUILD_NULL.upper() : MODEL_PCD_FIXED_AT_BUILD, - TAB_PCDS_PATCHABLE_IN_MODULE_NULL.upper() : MODEL_PCD_PATCHABLE= _IN_MODULE, - TAB_PCDS_FEATURE_FLAG_NULL.upper() : MODEL_PCD_FEATURE_FLAG, - TAB_PCDS_DYNAMIC_EX_NULL.upper() : MODEL_PCD_DYNAMIC_EX, - TAB_PCDS_DYNAMIC_EX_DEFAULT_NULL.upper() : MODEL_PCD_DYNAMIC_E= X_DEFAULT, - TAB_PCDS_DYNAMIC_EX_VPD_NULL.upper() : MODEL_PCD_DYNAMIC_EX_VPD, - TAB_PCDS_DYNAMIC_EX_HII_NULL.upper() : MODEL_PCD_DYNAMIC_EX_HII, - TAB_PCDS_DYNAMIC_NULL.upper() : MODEL_PCD_DYNAMIC, - TAB_PCDS_DYNAMIC_DEFAULT_NULL.upper() : MODEL_PCD_DYNAMIC_DEFAU= LT, - TAB_PCDS_DYNAMIC_VPD_NULL.upper() : MODEL_PCD_DYNAMIC_VPD, - TAB_PCDS_DYNAMIC_HII_NULL.upper() : MODEL_PCD_DYNAMIC_HII, - TAB_COMPONENTS.upper() : MODEL_META_DATA_COMPONENT, - TAB_USER_EXTENSIONS.upper() : MODEL_META_DATA_USER_EXTENSION - } - -## Dsc -# -# This class defined the structure used in Dsc object -# -# @param Ffilename: Input value for Ffilename of Inf file, default= is None -# @param IsMergeAllArches: Input value for IsMergeAllArches -# True is to merge all arches -# Fales is not to merge all arches -# default is False -# @param IsToPlatform: Input value for IsToPlatform -# True is to transfer to ModuleObject automatica= lly -# False is not to transfer to ModuleObject autom= atically -# default is False -# @param WorkspaceDir: Input value for current workspace directory, d= efault is None -# -# @var _NullClassIndex: To store value for _NullClassIndex, default is= 0 -# @var Identification: To store value for Identification, it is a str= ucture as Identification -# @var Defines: To store value for Defines, it is a structure = as DscDefines -# @var Contents: To store value for Contents, it is a structure= as DscContents -# @var UserExtensions: To store value for UserExtensions -# @var Platform: To store value for Platform, it is a structure= as PlatformClass -# @var WorkspaceDir: To store value for WorkspaceDir -# @var KeyList: To store value for KeyList, a list for all Key= s used in Dec -# -class Dsc(object): - _NullClassIndex =3D 0 - - def __init__(self, Filename=3DNone, IsToDatabase=3DFalse, IsToPlatform= =3DFalse, WorkspaceDir=3DNone, Database=3DNone): - self.Identification =3D Identification() - self.Platform =3D PlatformClass() - self.UserExtensions =3D '' - self.WorkspaceDir =3D WorkspaceDir - self.IsToDatabase =3D IsToDatabase - if Database: - self.Cur =3D Database.Cur - self.TblFile =3D Database.TblFile - self.TblDsc =3D Database.TblDsc - - self.KeyList =3D [ - TAB_SKUIDS, TAB_LIBRARIES, TAB_LIBRARY_CLASSES, TAB_BUILD_OPTI= ONS, TAB_PCDS_FIXED_AT_BUILD_NULL, \ - TAB_PCDS_PATCHABLE_IN_MODULE_NULL, TAB_PCDS_FEATURE_FLAG_NULL,= \ - TAB_PCDS_DYNAMIC_DEFAULT_NULL, TAB_PCDS_DYNAMIC_HII_NULL, TAB_= PCDS_DYNAMIC_VPD_NULL, \ - TAB_PCDS_DYNAMIC_EX_DEFAULT_NULL, TAB_PCDS_DYNAMIC_EX_HII_NULL= , TAB_PCDS_DYNAMIC_EX_VPD_NULL, \ - TAB_COMPONENTS, TAB_DSC_DEFINES - ] - - self.PcdToken =3D {} - - # - # Upper all KEYs to ignore case sensitive when parsing - # - self.KeyList =3D map(lambda c: c.upper(), self.KeyList) - - # - # Init RecordSet - # -# self.RecordSet =3D {} -# for Key in self.KeyList: -# self.RecordSet[Section[Key]] =3D [] - - # - # Load Dsc file if filename is not None - # - if Filename is not None: - self.LoadDscFile(Filename) - - # - # Transfer to Platform Object if IsToPlatform is True - # - if IsToPlatform: - self.DscToPlatform() - - ## Transfer to Platform Object - # - # Transfer all contents of an Inf file to a standard Module Object - # - def DscToPlatform(self): - # - # Init global information for the file - # - ContainerFile =3D self.Identification.FileFullPath - - # - # Generate Platform Header - # - self.GenPlatformHeader(ContainerFile) - - # - # Generate BuildOptions - # - self.GenBuildOptions(ContainerFile) - - # - # Generate SkuInfos - # - self.GenSkuInfos(ContainerFile) - - # - # Generate Libraries - # - self.GenLibraries(ContainerFile) - - # - # Generate LibraryClasses - # - self.GenLibraryClasses(ContainerFile) - - # - # Generate Pcds - # - self.GenPcds(DataType.TAB_PCDS_FIXED_AT_BUILD, ContainerFile) - self.GenPcds(DataType.TAB_PCDS_PATCHABLE_IN_MODULE, ContainerFile) - self.GenFeatureFlagPcds(DataType.TAB_PCDS_FEATURE_FLAG, ContainerF= ile) - self.GenDynamicDefaultPcds(DataType.TAB_PCDS_DYNAMIC_DEFAULT, Cont= ainerFile) - self.GenDynamicDefaultPcds(DataType.TAB_PCDS_DYNAMIC_EX_DEFAULT, C= ontainerFile) - self.GenDynamicHiiPcds(DataType.TAB_PCDS_DYNAMIC_HII, ContainerFil= e) - self.GenDynamicHiiPcds(DataType.TAB_PCDS_DYNAMIC_EX_HII, Container= File) - self.GenDynamicVpdPcds(DataType.TAB_PCDS_DYNAMIC_VPD, ContainerFil= e) - self.GenDynamicVpdPcds(DataType.TAB_PCDS_DYNAMIC_EX_VPD, Container= File) - - # - # Generate Components - # - self.GenComponents(ContainerFile) - - # - # Update to database - # - if self.IsToDatabase: - for Key in self.PcdToken.keys(): - SqlCommand =3D """update %s set Value2 =3D '%s' where ID = =3D %s""" % (self.TblDsc.Table, ".".join((self.PcdToken[Key][0], self.PcdTo= ken[Key][1])), Key) - self.TblDsc.Exec(SqlCommand) - #End of DscToPlatform - - ## Get Platform Header - # - # Gen Platform Header of Dsc as =3D - # - # @param ContainerFile: The Dsc file full path - # - def GenPlatformHeader(self, ContainerFile): - EdkLogger.debug(2, "Generate PlatformHeader ...") - # - # Update all defines item in database - # - SqlCommand =3D """select ID, Value1, Arch, StartLine from %s - where Model =3D %s - and BelongsToFile =3D %s - and Enabled > -1""" % (self.TblDsc.Table, MODEL_ME= TA_DATA_HEADER, self.FileID) - RecordSet =3D self.TblDsc.Exec(SqlCommand) - for Record in RecordSet: - ValueList =3D GetSplitValueList(Record[1], TAB_EQUAL_SPLIT) - if len(ValueList) !=3D 2: - RaiseParserError(Record[1], 'Defines', ContainerFile, ' =3D ', Record[3]) - ID, Value1, Value2, Arch =3D Record[0], ValueList[0], ValueLis= t[1], Record[2] - SqlCommand =3D """update %s set Value1 =3D '%s', Value2 =3D '%= s' - where ID =3D %s""" % (self.TblDsc.Table, Conve= rtToSqlString2(Value1), ConvertToSqlString2(Value2), ID) - self.TblDsc.Exec(SqlCommand) - - # - # Get detailed information - # - for Arch in DataType.ARCH_LIST: - PlatformHeader =3D PlatformHeaderClass() - - PlatformHeader.Name =3D QueryDefinesItem(self.TblDsc, TAB_DSC_= DEFINES_PLATFORM_NAME, Arch, self.FileID)[0] - PlatformHeader.Guid =3D QueryDefinesItem(self.TblDsc, TAB_DSC_= DEFINES_PLATFORM_GUID, Arch, self.FileID)[0] - PlatformHeader.Version =3D QueryDefinesItem(self.TblDsc, TAB_D= SC_DEFINES_PLATFORM_VERSION, Arch, self.FileID)[0] - PlatformHeader.FileName =3D self.Identification.FileName - PlatformHeader.FullPath =3D self.Identification.FileFullPath - PlatformHeader.DscSpecification =3D QueryDefinesItem(self.TblD= sc, TAB_DSC_DEFINES_DSC_SPECIFICATION, Arch, self.FileID)[0] - - PlatformHeader.SkuIdName =3D QueryDefinesItem(self.TblDsc, TAB= _DSC_DEFINES_SKUID_IDENTIFIER, Arch, self.FileID) - PlatformHeader.SupArchList =3D QueryDefinesItem(self.TblDsc, T= AB_DSC_DEFINES_SUPPORTED_ARCHITECTURES, Arch, self.FileID) - PlatformHeader.BuildTargets =3D QueryDefinesItem(self.TblDsc, = TAB_DSC_DEFINES_BUILD_TARGETS, Arch, self.FileID) - PlatformHeader.OutputDirectory =3D NormPath(QueryDefinesItem(s= elf.TblDsc, TAB_DSC_DEFINES_OUTPUT_DIRECTORY, Arch, self.FileID)[0]) - PlatformHeader.BuildNumber =3D QueryDefinesItem(self.TblDsc, T= AB_DSC_DEFINES_BUILD_NUMBER, Arch, self.FileID)[0] - PlatformHeader.MakefileName =3D QueryDefinesItem(self.TblDsc, = TAB_DSC_DEFINES_MAKEFILE_NAME, Arch, self.FileID)[0] - - PlatformHeader.BsBaseAddress =3D QueryDefinesItem(self.TblDsc,= TAB_DSC_DEFINES_BS_BASE_ADDRESS, Arch, self.FileID)[0] - PlatformHeader.RtBaseAddress =3D QueryDefinesItem(self.TblDsc,= TAB_DSC_DEFINES_RT_BASE_ADDRESS, Arch, self.FileID)[0] - - self.Platform.Header[Arch] =3D PlatformHeader - Fdf =3D PlatformFlashDefinitionFileClass() - Fdf.FilePath =3D NormPath(QueryDefinesItem(self.TblDsc, TAB_DS= C_DEFINES_FLASH_DEFINITION, Arch, self.FileID)[0]) - self.Platform.FlashDefinitionFile =3D Fdf - Prebuild =3D BuildScriptClass() - Prebuild.FilePath =3D NormPath(QueryDefinesItem(self.TblDsc, T= AB_DSC_PREBUILD, Arch, self.FileID)[0]) - self.Platform.Prebuild =3D Prebuild - Postbuild =3D BuildScriptClass() - Postbuild.FilePath =3D NormPath(QueryDefinesItem(self.TblDsc, = TAB_DSC_POSTBUILD, Arch, self.FileID)[0]) - self.Platform.Postbuild =3D Postbuild - - ## GenBuildOptions - # - # Gen BuildOptions of Dsc - # [:]=3DFlag - # - # @param ContainerFile: The Dsc file full path - # - def GenBuildOptions(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_BUILD_OPTIONS) - BuildOptions =3D {} - # - # Get all include files - # - IncludeFiles =3D QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE= , MODEL_META_DATA_BUILD_OPTION, self.FileID) - - # - # Get all BuildOptions - # - RecordSet =3D QueryDscItem(self.TblDsc, MODEL_META_DATA_BUILD_OPTI= ON, -1, self.FileID) - - # - # Go through each arch - # - for Arch in DataType.ARCH_LIST: - for IncludeFile in IncludeFiles: - if IncludeFile[1] =3D=3D Arch or IncludeFile[1] =3D=3D TAB= _ARCH_COMMON.upper(): - Filename =3D CheckFileExist(self.WorkspaceDir, Include= File[0], ContainerFile, TAB_BUILD_OPTIONS, '', IncludeFile[2]) - for NewItem in open(Filename, 'r').readlines(): - if CleanString(NewItem) =3D=3D '': - continue - (Family, ToolChain, Flag) =3D GetBuildOption(NewIt= em, Filename, -1) - MergeArches(BuildOptions, (Family, ToolChain, Flag= ), Arch) - - for Record in RecordSet: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON.upper(): - (Family, ToolChain, Flag) =3D GetBuildOption(Record[0]= , ContainerFile, Record[2]) - MergeArches(BuildOptions, (Family, ToolChain, Flag), A= rch) - # - # Update to Database - # - if self.IsToDatabase: - SqlCommand =3D """update %s set Value1 =3D '%s', V= alue2 =3D '%s', Value3 =3D '%s' - where ID =3D %s""" % (self.TblDsc.= Table, ConvertToSqlString2(Family), ConvertToSqlString2(ToolChain), Convert= ToSqlString2(Flag), Record[3]) - self.TblDsc.Exec(SqlCommand) - - for Key in BuildOptions.keys(): - BuildOption =3D BuildOptionClass(Key[0], Key[1], Key[2]) - BuildOption.SupArchList =3D BuildOptions[Key] - self.Platform.BuildOptions.BuildOptionList.append(BuildOption) - - ## GenSkuInfos - # - # Gen SkuInfos of Dsc - # | - # - # @param ContainerFile: The Dsc file full path - # - def GenSkuInfos(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_SKUIDS) - # - # SkuIds - # | - # - self.Platform.SkuInfos.SkuInfoList['DEFAULT'] =3D '0' - - # - # Get all include files - # - IncludeFiles =3D QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE= , MODEL_EFI_SKU_ID, self.FileID) - - # - # Get all SkuInfos - # - RecordSet =3D QueryDscItem(self.TblDsc, MODEL_EFI_SKU_ID, -1, self= .FileID) - - # - # Go through each arch - # - for Arch in DataType.ARCH_LIST: - for IncludeFile in IncludeFiles: - if IncludeFile[1] =3D=3D Arch or IncludeFile[1] =3D=3D TAB= _ARCH_COMMON.upper(): - Filename =3D CheckFileExist(self.WorkspaceDir, Include= File[0], ContainerFile, TAB_SKUIDS, '', IncludeFile[2]) - for NewItem in open(Filename, 'r').readlines(): - if CleanString(NewItem) =3D=3D '': - continue - List =3D GetSplitValueList(NewItem) - if len(List) !=3D 2: - RaiseParserError(NewItem, TAB_SKUIDS, Filename= , '|') - else: - self.Platform.SkuInfos.SkuInfoList[List[1]] = =3D List[0] - - for Record in RecordSet: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON.upper(): - List =3D GetSplitValueList(Record[0]) - if len(List) !=3D 2: - RaiseParserError(Record[0], TAB_SKUIDS, ContainerF= ile, '|') - else: - self.Platform.SkuInfos.SkuInfoList[List[1]] =3D Li= st[0] - # - # Update to Database - # - if self.IsToDatabase: - SqlCommand =3D """update %s set Value1 =3D '%s= ', Value2 =3D '%s' - where ID =3D %s""" % (self.Tbl= Dsc.Table, ConvertToSqlString2(List[0]), ConvertToSqlString2(List[1]), Reco= rd[3]) - self.TblDsc.Exec(SqlCommand) - - ## GenLibraries - # - # Gen Libraries of Dsc - # - # - # @param ContainerFile: The Dsc file full path - # - def GenLibraries(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_LIBRARIES) - Libraries =3D {} - # - # Get all include files - # - IncludeFiles =3D QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE= , MODEL_EFI_LIBRARY_INSTANCE, self.FileID) - - # - # Get all Libraries - # - RecordSet =3D QueryDscItem(self.TblDsc, MODEL_EFI_LIBRARY_INSTANCE= , -1, self.FileID) - - # - # Go through each arch - # - for Arch in DataType.ARCH_LIST: - for IncludeFile in IncludeFiles: - if IncludeFile[1] =3D=3D Arch or IncludeFile[1] =3D=3D TAB= _ARCH_COMMON.upper(): - Filename =3D CheckFileExist(self.WorkspaceDir, Include= File[0], ContainerFile, TAB_LIBRARIES, '', IncludeFile[2]) - if os.path.exists(Filename): - for NewItem in open(Filename, 'r').readlines(): - if CleanString(NewItem) =3D=3D '': - continue - MergeArches(Libraries, NewItem, Arch) - - for Record in RecordSet: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON.upper(): - MergeArches(Libraries, Record[0], Arch) - - for Key in Libraries.keys(): - Library =3D PlatformLibraryClass() - Library.FilePath =3D NormPath(Key) - Library.SupArchList =3D Libraries[Key] - self.Platform.Libraries.LibraryList.append(Library) - - ## GenLibraryClasses - # - # Get LibraryClasses of Dsc - # | - # - # @param ContainerFile: The Dsc file full path - # - def GenLibraryClasses(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_LIBRARY_CLASSES) - LibraryClasses =3D {} - # - # Get all include files - # - IncludeFiles =3D QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE= , MODEL_EFI_LIBRARY_CLASS, self.FileID) - - # - # Get all LibraryClasses - # - RecordSet =3D QueryDscItem(self.TblDsc, MODEL_EFI_LIBRARY_CLASS, -= 1, self.FileID) - - # - # Go through each arch - # - for Arch in DataType.ARCH_LIST: - for IncludeFile in IncludeFiles: - if IncludeFile[1] =3D=3D Arch or IncludeFile[1] =3D=3D TAB= _ARCH_COMMON.upper(): - Filename =3D CheckFileExist(self.WorkspaceDir, Include= File[0], ContainerFile, TAB_LIBRARY_CLASSES, '', IncludeFile[2]) - for NewItem in open(Filename, 'r').readlines(): - if CleanString(NewItem) =3D=3D '': - continue - MergeArches(LibraryClasses, GetLibraryClass([NewIt= em, IncludeFile[4]], Filename, self.WorkspaceDir, -1), Arch) - - for Record in RecordSet: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON.upper(): - (LibClassName, LibClassIns, SupModelList) =3D GetLibra= ryClass([Record[0], Record[4]], ContainerFile, self.WorkspaceDir, Record[2]) - MergeArches(LibraryClasses, (LibClassName, LibClassIns= , SupModelList), Arch) - # - # Update to Database - # - if self.IsToDatabase: - SqlCommand =3D """update %s set Value1 =3D '%s', V= alue2 =3D '%s', Value3 =3D '%s' - where ID =3D %s""" % (self.TblDsc.= Table, ConvertToSqlString2(LibClassName), ConvertToSqlString2(LibClassIns),= ConvertToSqlString2(SupModelList), Record[3]) - self.TblDsc.Exec(SqlCommand) - - for Key in LibraryClasses.keys(): - Library =3D PlatformLibraryClass() - Library.Name =3D Key[0] - Library.FilePath =3D NormPath(Key[1]) - Library.SupModuleList =3D GetSplitValueList(Key[2]) - Library.SupArchList =3D LibraryClasses[Key] - self.Platform.LibraryClasses.LibraryList.append(Library) - - ## Gen Pcds - # - # Gen Pcd of Dsc as .|[||] - # - # @param Type: The type of Pcd - # @param ContainerFile: The file which describes the pcd, used for er= ror report - # - def GenPcds(self, Type=3D'', ContainerFile=3D''): - Pcds =3D {} - if Type =3D=3D DataType.TAB_PCDS_PATCHABLE_IN_MODULE: - Model =3D MODEL_PCD_PATCHABLE_IN_MODULE - elif Type =3D=3D DataType.TAB_PCDS_FIXED_AT_BUILD: - Model =3D MODEL_PCD_FIXED_AT_BUILD - else: - pass - EdkLogger.debug(2, "Generate %s ..." % Type) - - # - # Get all include files - # - IncludeFiles =3D QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE= , Model, self.FileID) - - # - # Get all Pcds - # - RecordSet =3D QueryDscItem(self.TblDsc, Model, -1, self.FileID) - - # - # Go through each arch - # - for Arch in DataType.ARCH_LIST: - for IncludeFile in IncludeFiles: - if IncludeFile[1] =3D=3D Arch or IncludeFile[1] =3D=3D TAB= _ARCH_COMMON.upper(): - Filename =3D CheckFileExist(self.WorkspaceDir, Include= File[0], ContainerFile, Type, '', IncludeFile[2]) - for NewItem in open(Filename, 'r').readlines(): - if CleanString(NewItem) =3D=3D '': - continue - (TokenName, TokenGuidCName, Value, DatumType, MaxD= atumSize, Type) =3D GetPcd(NewItem, Type, Filename, -1) - MergeArches(Pcds, (TokenName, TokenGuidCName, Valu= e, DatumType, MaxDatumSize, Type), Arch) - self.PcdToken[Record[3]] =3D (TokenGuidCName, Toke= nName) - - for Record in RecordSet: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON.upper(): - (TokenName, TokenGuidCName, Value, DatumType, MaxDatum= Size, Type) =3D GetPcd(Record[0], Type, ContainerFile, Record[2]) - MergeArches(Pcds, (TokenName, TokenGuidCName, Value, D= atumType, MaxDatumSize, Type), Arch) - self.PcdToken[Record[3]] =3D (TokenGuidCName, TokenNam= e) - - for Key in Pcds: - Pcd =3D PcdClass(Key[0], '', Key[1], Key[3], Key[4], Key[2], K= ey[5], [], {}, []) - Pcd.SupArchList =3D Pcds[Key] - self.Platform.DynamicPcdBuildDefinitions.append(Pcd) - - ## Gen FeatureFlagPcds - # - # Gen FeatureFlagPcds of Dsc file as .|TRUE/FALSE - # - # @param Type: The type of Pcd - # @param ContainerFile: The file which describes the pcd, used for er= ror report - # - def GenFeatureFlagPcds(self, Type=3D'', ContainerFile=3D''): - Pcds =3D {} - if Type =3D=3D DataType.TAB_PCDS_FEATURE_FLAG: - Model =3D MODEL_PCD_FEATURE_FLAG - else: - pass - EdkLogger.debug(2, "Generate %s ..." % Type) - - # - # Get all include files - # - IncludeFiles =3D QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE= , Model, self.FileID) - - # - # Get all FeatureFlagPcds - # - RecordSet =3D QueryDscItem(self.TblDsc, Model, -1, self.FileID) - - # - # Go through each arch - # - for Arch in DataType.ARCH_LIST: - for IncludeFile in IncludeFiles: - if IncludeFile[1] =3D=3D Arch or IncludeFile[1] =3D=3D TAB= _ARCH_COMMON.upper(): - Filename =3D CheckFileExist(self.WorkspaceDir, Include= File[0], ContainerFile, Type, '', IncludeFile[2]) - for NewItem in open(Filename, 'r').readlines(): - if CleanString(NewItem) =3D=3D '': - continue - (TokenName, TokenGuidCName, Value, Type) =3D GetFe= atureFlagPcd(NewItem, Type, Filename, -1) - MergeArches(Pcds, (TokenName, TokenGuidCName, Valu= e, Type), Arch) - self.PcdToken[Record[3]] =3D (TokenGuidCName, Toke= nName) - - for Record in RecordSet: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON.upper(): - (TokenName, TokenGuidCName, Value, Type) =3D GetFeatur= eFlagPcd(Record[0], Type, ContainerFile, Record[2]) - MergeArches(Pcds, (TokenName, TokenGuidCName, Value, T= ype), Arch) - self.PcdToken[Record[3]] =3D (TokenGuidCName, TokenNam= e) - - for Key in Pcds: - Pcd =3D PcdClass(Key[0], '', Key[1], '', '', Key[2], Key[3], [= ], {}, []) - Pcd.SupArchList =3D Pcds[Key] - self.Platform.DynamicPcdBuildDefinitions.append(Pcd) - - ## Gen DynamicDefaultPcds - # - # Gen DynamicDefaultPcds of Dsc as .|[|[|]] - # - # @param Type: The type of Pcd - # @param ContainerFile: The file which describes the pcd, used for er= ror report - # - def GenDynamicDefaultPcds(self, Type=3D'', ContainerFile=3D''): - Pcds =3D {} - SkuInfoList =3D {} - if Type =3D=3D DataType.TAB_PCDS_DYNAMIC_DEFAULT: - Model =3D MODEL_PCD_DYNAMIC_DEFAULT - elif Type =3D=3D DataType.TAB_PCDS_DYNAMIC_EX_DEFAULT: - Model =3D MODEL_PCD_DYNAMIC_EX_DEFAULT - else: - pass - EdkLogger.debug(2, "Generate %s ..." % Type) - - # - # Get all include files - # - IncludeFiles =3D QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE= , Model, self.FileID) - - # - # Get all DynamicDefaultPcds - # - RecordSet =3D QueryDscItem(self.TblDsc, Model, -1, self.FileID) - - # - # Go through each arch - # - for Arch in DataType.ARCH_LIST: - for IncludeFile in IncludeFiles: - if IncludeFile[1] =3D=3D Arch or IncludeFile[1] =3D=3D TAB= _ARCH_COMMON.upper(): - Filename =3D CheckFileExist(self.WorkspaceDir, Include= File[0], ContainerFile, Type, '', IncludeFile[2]) - for NewItem in open(Filename, 'r').readlines(): - if CleanString(NewItem) =3D=3D '': - continue - (K1, K2, K3, K4, K5, K6) =3D GetDynamicDefaultPcd(= NewItem, Type, Filename, -1) - MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, Include= File[4]), Arch) - self.PcdToken[Record[3]] =3D (K2, K1) - - for Record in RecordSet: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON.upper(): - (K1, K2, K3, K4, K5, K6) =3D GetDynamicDefaultPcd(Reco= rd[0], Type, ContainerFile, Record[2]) - MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, Record[4]),= Arch) - self.PcdToken[Record[3]] =3D (K2, K1) - - for Key in Pcds: - (Status, SkuInfoList) =3D self.GenSkuInfoList(Key[6], self.Pla= tform.SkuInfos.SkuInfoList, '', '', '', '', '', Key[2]) - if Status =3D=3D False: - ErrorMsg =3D "The SKUID '%s' used in section '%s' is not d= efined in section [SkuIds]" % (SkuInfoList, Type) - EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg,= ContainerFile, RaiseError=3DEdkLogger.IsRaiseError) - Pcd =3D PcdClass(Key[0], '', Key[1], Key[3], Key[4], Key[2], K= ey[5], [], SkuInfoList, []) - Pcd.SupArchList =3D Pcds[Key] - self.Platform.DynamicPcdBuildDefinitions.append(Pcd) - - ## Gen DynamicHiiPcds - # - # Gen DynamicHiiPcds of Dsc as .|<= String>||[|[|]] - # - # @param Type: The type of Pcd - # @param ContainerFile: The file which describes the pcd, used for er= ror report - # - def GenDynamicHiiPcds(self, Type=3D'', ContainerFile=3D''): - Pcds =3D {} - SkuInfoList =3D {} - if Type =3D=3D DataType.TAB_PCDS_DYNAMIC_HII: - Model =3D MODEL_PCD_DYNAMIC_HII - elif Type =3D=3D DataType.TAB_PCDS_DYNAMIC_EX_HII: - Model =3D MODEL_PCD_DYNAMIC_EX_HII - else: - pass - EdkLogger.debug(2, "Generate %s ..." % Type) - - # - # Get all include files - # - IncludeFiles =3D QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE= , Model, self.FileID) - - # - # Get all DynamicHiiPcds - # - RecordSet =3D QueryDscItem(self.TblDsc, Model, -1, self.FileID) - - # - # Go through each arch - # - for Arch in DataType.ARCH_LIST: - for IncludeFile in IncludeFiles: - if IncludeFile[1] =3D=3D Arch or IncludeFile[1] =3D=3D TAB= _ARCH_COMMON.upper(): - Filename =3D CheckFileExist(self.WorkspaceDir, Include= File[0], ContainerFile, Type, '', IncludeFile[2]) - for NewItem in open(Filename, 'r').readlines(): - if CleanString(NewItem) =3D=3D '': - continue - (K1, K2, K3, K4, K5, K6, K7, K8) =3D GetDynamicHii= Pcd(NewItem, Type, Filename, -1) - MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, K7, K8,= IncludeFile[4]), Arch) - self.PcdToken[Record[3]] =3D (K2, K1) - - for Record in RecordSet: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON.upper(): - (K1, K2, K3, K4, K5, K6, K7, K8) =3D GetDynamicHiiPcd(= Record[0], Type, ContainerFile, Record[2]) - MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, K7, K8, Rec= ord[4]), Arch) - self.PcdToken[Record[3]] =3D (K2, K1) - - for Key in Pcds: - (Status, SkuInfoList) =3D self.GenSkuInfoList(Key[8], self.Pla= tform.SkuInfos.SkuInfoList, Key[2], Key[3], Key[4], Key[5], '', '') - if Status =3D=3D False: - ErrorMsg =3D "The SKUID '%s' used in section '%s' is not d= efined in section [SkuIds]" % (SkuInfoList, Type) - EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg,= ContainerFile, RaiseError=3DEdkLogger.IsRaiseError) - Pcd =3D PcdClass(Key[0], '', Key[1], '', Key[6], Key[5], Key[7= ], [], SkuInfoList, []) - Pcd.SupArchList =3D Pcds[Key] - self.Platform.DynamicPcdBuildDefinitions.append(Pcd) - - ## Gen DynamicVpdPcds - # - # Gen DynamicVpdPcds of Dsc as .|<= VpdOffset>[|] - # - # @param Type: The type of Pcd - # @param ContainerFile: The file which describes the pcd, used for er= ror report - # - def GenDynamicVpdPcds(self, Type=3D'', ContainerFile=3D''): - Pcds =3D {} - SkuInfoList =3D {} - if Type =3D=3D DataType.TAB_PCDS_DYNAMIC_VPD: - Model =3D MODEL_PCD_DYNAMIC_VPD - elif Type =3D=3D DataType.TAB_PCDS_DYNAMIC_EX_VPD: - Model =3D MODEL_PCD_DYNAMIC_EX_VPD - else: - pass - EdkLogger.debug(2, "Generate %s ..." % Type) - - # - # Get all include files - # - IncludeFiles =3D QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE= , Model, self.FileID) - - # - # Get all DynamicVpdPcds - # - RecordSet =3D QueryDscItem(self.TblDsc, Model, -1, self.FileID) - - # - # Go through each arch - # - for Arch in DataType.ARCH_LIST: - for IncludeFile in IncludeFiles: - if IncludeFile[1] =3D=3D Arch or IncludeFile[1] =3D=3D TAB= _ARCH_COMMON.upper(): - Filename =3D CheckFileExist(self.WorkspaceDir, Include= File[0], ContainerFile, Type, '', IncludeFile[2]) - for NewItem in open(Filename, 'r').readlines(): - if CleanString(NewItem) =3D=3D '': - continue - (K1, K2, K3, K4, K5) =3D GetDynamicVpdPcd(NewItem,= Type, Filename, -1) - MergeArches(Pcds, (K1, K2, K3, K4, K5, IncludeFile= [4]), Arch) - self.PcdToken[Record[3]] =3D (K2, K1) - - for Record in RecordSet: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON.upper(): - (K1, K2, K3, K4, K5) =3D GetDynamicVpdPcd(Record[0], T= ype, ContainerFile, Record[2]) - MergeArches(Pcds, (K1, K2, K3, K4, K5, Record[4]), Arc= h) - self.PcdToken[Record[3]] =3D (K2, K1) - - for Key in Pcds: - (Status, SkuInfoList) =3D self.GenSkuInfoList(Key[5], self.Pla= tform.SkuInfos.SkuInfoList, '', '', '', '', Key[2], '') - if Status =3D=3D False: - ErrorMsg =3D "The SKUID '%s' used in section '%s' is not d= efined in section [SkuIds]" % (SkuInfoList, Type) - EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg,= ContainerFile, RaiseError=3DEdkLogger.IsRaiseError) - Pcd =3D PcdClass(Key[0], '', Key[1], '', Key[3], '', Key[4], [= ], SkuInfoList, []) - Pcd.SupArchList =3D Pcds[Key] - self.Platform.DynamicPcdBuildDefinitions.append(Pcd) - - - ## Get Component - # - # Get Component section defined in Dsc file - # - # @param ContainerFile: The file which describes the Components, used= for error report - # - # @retval PlatformModuleClass() A instance for PlatformModuleClass - # - def GenComponents(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_COMPONENTS) - Components =3D sdict() - # - # Get all include files - # - IncludeFiles =3D QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE= , MODEL_META_DATA_COMPONENT, self.FileID) - - # - # Get all Components - # - RecordSet =3D QueryDscItem(self.TblDsc, MODEL_META_DATA_COMPONENT,= -1, self.FileID) - - # - # Go through each arch - # - for Arch in DataType.ARCH_LIST: - for IncludeFile in IncludeFiles: - if IncludeFile[1] =3D=3D Arch or IncludeFile[1] =3D=3D TAB= _ARCH_COMMON.upper(): - Filename =3D CheckFileExist(self.WorkspaceDir, Include= File[0], ContainerFile, TAB_COMPONENTS, '', IncludeFile[2]) - for NewItem in open(Filename, 'r').readlines(): - if CleanString(NewItem) =3D=3D '': - continue - NewItems =3D [] - GetComponents(open(Filename, 'r').read(), TAB_COMP= ONENTS, NewItems, TAB_COMMENT_SPLIT) - for NewComponent in NewItems: - MergeArches(Components, self.GenComponent(NewC= omponent, Filename), Arch) - - for Record in RecordSet: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON.upper(): - Lib, Bo, Pcd =3D [], [], [] - - SubLibSet =3D QueryDscItem(self.TblDsc, MODEL_EFI_LIBR= ARY_CLASS, Record[3], self.FileID) - for SubLib in SubLibSet: - Lib.append(TAB_VALUE_SPLIT.join([SubLib[0], SubLib= [4]])) - - SubBoSet =3D QueryDscItem(self.TblDsc, MODEL_META_DATA= _BUILD_OPTION, Record[3], self.FileID) - for SubBo in SubBoSet: - Bo.append(SubBo[0]) - - SubPcdSet1 =3D QueryDscItem(self.TblDsc, MODEL_PCD_FIX= ED_AT_BUILD, Record[3], self.FileID) - SubPcdSet2 =3D QueryDscItem(self.TblDsc, MODEL_PCD_PAT= CHABLE_IN_MODULE, Record[3], self.FileID) - SubPcdSet3 =3D QueryDscItem(self.TblDsc, MODEL_PCD_FEA= TURE_FLAG, Record[3], self.FileID) - SubPcdSet4 =3D QueryDscItem(self.TblDsc, MODEL_PCD_DYN= AMIC_EX_DEFAULT, Record[3], self.FileID) - SubPcdSet5 =3D QueryDscItem(self.TblDsc, MODEL_PCD_DYN= AMIC_DEFAULT, Record[3], self.FileID) - for SubPcd in SubPcdSet1: - Pcd.append([DataType.TAB_PCDS_FIXED_AT_BUILD, SubP= cd[0], SubPcd[3]]) - for SubPcd in SubPcdSet2: - Pcd.append([DataType.TAB_PCDS_PATCHABLE_IN_MODULE,= SubPcd[0], SubPcd[3]]) - for SubPcd in SubPcdSet3: - Pcd.append([DataType.TAB_PCDS_FEATURE_FLAG, SubPcd= [0], SubPcd[3]]) - for SubPcd in SubPcdSet4: - Pcd.append([DataType.TAB_PCDS_DYNAMIC_EX, SubPcd[0= ], SubPcd[3]]) - for SubPcd in SubPcdSet5: - Pcd.append([DataType.TAB_PCDS_DYNAMIC, SubPcd[0], = SubPcd[3]]) - Item =3D [Record[0], Lib, Bo, Pcd] - MergeArches(Components, self.GenComponent(Item, Contai= nerFile), Arch) - - for Key in Components.keys(): - Key.SupArchList =3D Components[Key] - self.Platform.Modules.ModuleList.append(Key) - - ## Get Component - # - # Get Component section defined in Dsc file - # - # @param Item: Contents includes a component block - # @param ContainerFile: The file which describes the library class, u= sed for error report - # - # @retval PlatformModuleClass() A instance for PlatformModuleClass - # - def GenComponent(self, Item, ContainerFile, LineNo=3D -1): - (InfFilename, ExecFilename) =3D GetExec(Item[0]) - LibraryClasses =3D Item[1] - BuildOptions =3D Item[2] - Pcds =3D Item[3] - Component =3D PlatformModuleClass() - Component.FilePath =3D NormPath(InfFilename) - Component.ExecFilePath =3D NormPath(ExecFilename) - CheckFileType(Component.FilePath, '.Inf', ContainerFile, 'componen= t name', Item[0], LineNo) - CheckFileExist(self.WorkspaceDir, Component.FilePath, ContainerFil= e, 'component', Item[0], LineNo) - for Lib in LibraryClasses: - List =3D GetSplitValueList(Lib) - if len(List) !=3D 2: - RaiseParserError(Lib, 'LibraryClasses', ContainerFile, '|') - LibName =3D List[0] - LibFile =3D NormPath(List[1]) - if LibName =3D=3D "" or LibName =3D=3D "NULL": - LibName =3D "NULL%d" % self._NullClassIndex - self._NullClassIndex +=3D 1 - CheckFileType(List[1], '.Inf', ContainerFile, 'library instanc= e of component ', Lib, LineNo) - CheckFileExist(self.WorkspaceDir, LibFile, ContainerFile, 'lib= rary instance of component', Lib, LineNo) - Component.LibraryClasses.LibraryList.append(PlatformLibraryCla= ss(LibName, LibFile)) - for BuildOption in BuildOptions: - Key =3D GetBuildOption(BuildOption, ContainerFile) - Component.ModuleSaBuildOption.BuildOptionList.append(BuildOpti= onClass(Key[0], Key[1], Key[2])) - for Pcd in Pcds: - Type =3D Pcd[0] - List =3D GetSplitValueList(Pcd[1]) - PcdId =3D Pcd[2] - - TokenInfo =3D None - # - # For FeatureFlag - # - if Type =3D=3D DataType.TAB_PCDS_FEATURE_FLAG: - if len(List) !=3D 2: - RaiseParserError(Pcd[1], 'Components', ContainerFile, = '.|TRUE/FALSE') - - CheckPcdTokenInfo(List[0], 'Components', ContainerFile) - TokenInfo =3D GetSplitValueList(List[0], DataType.TAB_SPLI= T) - Component.PcdBuildDefinitions.append(PcdClass(TokenInfo[1]= , '', TokenInfo[0], '', '', List[1], Type, [], {}, [])) - # - # For FixedAtBuild or PatchableInModule - # - if Type =3D=3D DataType.TAB_PCDS_FIXED_AT_BUILD or Type =3D=3D= DataType.TAB_PCDS_PATCHABLE_IN_MODULE: - List.append('') - if len(List) !=3D 3 and len(List) !=3D 4: - RaiseParserError(Pcd[1], 'Components', ContainerFile, = '.|[|]') - - CheckPcdTokenInfo(List[0], 'Components', ContainerFile) - TokenInfo =3D GetSplitValueList(List[0], DataType.TAB_SPLI= T) - Component.PcdBuildDefinitions.append(PcdClass(TokenInfo[1]= , '', TokenInfo[0], '', List[2], List[1], Type, [], {}, [])) - - # - # For Dynamic or DynamicEx - # - if Type =3D=3D DataType.TAB_PCDS_DYNAMIC or Type =3D=3D DataTy= pe.TAB_PCDS_DYNAMIC_EX: - if len(List) !=3D 1: - RaiseParserError(Pcd[1], 'Components', ContainerFile, = '.') - - CheckPcdTokenInfo(List[0], 'Components', ContainerFile) - TokenInfo =3D GetSplitValueList(List[0], DataType.TAB_SPLI= T) - Component.PcdBuildDefinitions.append(PcdClass(TokenInfo[1]= , '', TokenInfo[0], '', '', '', Type, [], {}, [])) - - # - # Add to PcdToken - # - self.PcdToken[PcdId] =3D (TokenInfo[0], TokenInfo[1]) - - return Component - #End of GenComponent - - ## Gen SkuInfoList - # - # Gen SkuInfoList section defined in Dsc file - # - # @param SkuNameList: Input value for SkuNameList - # @param SkuInfo: Input value for SkuInfo - # @param VariableName: Input value for VariableName - # @param VariableGuid: Input value for VariableGuid - # @param VariableOffset: Input value for VariableOffset - # @param HiiDefaultValue: Input value for HiiDefaultValue - # @param VpdOffset: Input value for VpdOffset - # @param DefaultValue: Input value for DefaultValue - # - # @retval (False, SkuName) Not found in section SkuId Dsc file - # @retval (True, SkuInfoList) Found in section SkuId of Dsc file - # - def GenSkuInfoList(self, SkuNameList, SkuInfo, VariableName=3D'', Vari= ableGuid=3D'', VariableOffset=3D'', HiiDefaultValue=3D'', VpdOffset=3D'', D= efaultValue=3D''): - SkuNameList =3D GetSplitValueList(SkuNameList) - if SkuNameList is None or SkuNameList =3D=3D [] or SkuNameList =3D= =3D ['']: - SkuNameList =3D ['DEFAULT'] - SkuInfoList =3D {} - for Item in SkuNameList: - if Item not in SkuInfo: - return False, Item - Sku =3D SkuInfoClass(Item, SkuInfo[Item], VariableName, Variab= leGuid, VariableOffset, HiiDefaultValue, VpdOffset, DefaultValue) - SkuInfoList[Item] =3D Sku - - return True, SkuInfoList - - ## Parse Include statement - # - # Get include file path - # - # 1. Insert a record into TblFile ??? - # 2. Insert a record into TblDsc - # Value1: IncludeFilePath - # - # @param LineValue: The line of incude statement - def ParseInclude(self, LineValue, StartLine, Table, FileID, Filename, = SectionName, Model, Arch): - EdkLogger.debug(EdkLogger.DEBUG_2, "!include statement '%s' found = in section %s" % (LineValue, SectionName)) - SectionModel =3D Section[SectionName.upper()] - IncludeFile =3D CleanString(LineValue[LineValue.upper().find(DataT= ype.TAB_INCLUDE.upper() + ' ') + len(DataType.TAB_INCLUDE + ' ') : ]) - Table.Insert(Model, IncludeFile, '', '', Arch, SectionModel, FileI= D, StartLine, -1, StartLine, -1, 0) - - ## Parse DEFINE statement - # - # Get DEFINE macros - # - # 1. Insert a record into TblDsc - # Value1: Macro Name - # Value2: Macro Value - # - def ParseDefine(self, LineValue, StartLine, Table, FileID, Filename, S= ectionName, Model, Arch): - EdkLogger.debug(EdkLogger.DEBUG_2, "DEFINE statement '%s' found in= section %s" % (LineValue, SectionName)) - SectionModel =3D Section[SectionName.upper()] - Define =3D GetSplitValueList(CleanString(LineValue[LineValue.upper= ().find(DataType.TAB_DEFINE.upper() + ' ') + len(DataType.TAB_DEFINE + ' ')= : ]), TAB_EQUAL_SPLIT, 1) - Table.Insert(Model, Define[0], Define[1], '', Arch, SectionModel, = FileID, StartLine, -1, StartLine, -1, 0) - - ## Parse Defines section - # - # Get one item in defines section - # - # Value1: Item Name - # Value2: Item Value - # - def ParseDefinesSection(self, LineValue, StartLine, Table, FileID, Fil= ename, SectionName, Model, Arch): - EdkLogger.debug(EdkLogger.DEBUG_2, "Parse '%s' found in section %s= " % (LineValue, SectionName)) - Defines =3D GetSplitValueList(LineValue, TAB_EQUAL_SPLIT, 1) - if len(Defines) !=3D 2: - RaiseParserError(LineValue, SectionName, Filename, '', StartLi= ne) - self.TblDsc.Insert(Model, Defines[0], Defines[1], '', Arch, -1, Fi= leID, StartLine, -1, StartLine, -1, 0) - - ## Insert conditional statements - # - # Pop an item from IfDefList - # Insert conditional statements to database - # - # @param Filename: Path of parsing file - # @param IfDefList: A list stored current conditional statements - # @param EndLine: The end line no - # @param ArchList: Support arch list - # - def InsertConditionalStatement(self, Filename, FileID, BelongsToItem, = IfDefList, EndLine, ArchList): - (Value1, Value2, Value3, Model, StartColumn, EndColumn, Enabled) = =3D ('', '', '', -1, -1, -1, 0) - if IfDefList =3D=3D []: - ErrorMsg =3D 'Not suited conditional statement in file %s' % F= ilename - EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, Fil= ename, RaiseError=3DEdkLogger.IsRaiseError) - else: - # - # Get New Dsc item ID - # - DscID =3D self.TblDsc.GetCount() + 1 - - # - # Pop the conditional statements which is closed - # - PreviousIf =3D IfDefList.pop() - EdkLogger.debug(EdkLogger.DEBUG_5, 'Previous IfDef: ' + str(Pr= eviousIf)) - - # - # !ifdef and !ifndef - # - if PreviousIf[2] in (MODEL_META_DATA_CONDITIONAL_STATEMENT_IFD= EF, MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF): - Value1 =3D PreviousIf[0] - Model =3D PreviousIf[2] - self.TblDsc.Insert(Model, Value1, Value2, Value3, ArchList= , BelongsToItem, self.FileID, PreviousIf[1], StartColumn, EndLine, EndColum= n, Enabled) - # - # !if and !elseif - # - elif PreviousIf[2] in (MODEL_META_DATA_CONDITIONAL_STATEMENT_I= F, Model): - List =3D PreviousIf[0].split(' ') - Value1, Value2, Value3 =3D '', '=3D=3D', '0' - if len(List) =3D=3D 3: - Value1 =3D List[0] - Value2 =3D List[1] - Value3 =3D List[2] - Value3 =3D SplitString(Value3) - if len(List) =3D=3D 1: - Value1 =3D List[0] - Model =3D PreviousIf[2] - self.TblDsc.Insert(Model, Value1, Value2, Value3, ArchList= , BelongsToItem, self.FileID, PreviousIf[1], StartColumn, EndLine, EndColum= n, Enabled) - # - # !else - # - elif PreviousIf[2] in (MODEL_META_DATA_CONDITIONAL_STATEMENT_E= LSE, Model): - Value1 =3D PreviousIf[0].strip() - Model =3D PreviousIf[2] - self.TblDsc.Insert(Model, Value1, Value2, Value3, ArchList= , BelongsToItem, self.FileID, PreviousIf[1], StartColumn, EndLine, EndColum= n, Enabled) - - ## Load Dsc file - # - # Load the file if it exists - # - # @param Filename: Input value for filename of Dsc file - # - def LoadDscFile(self, Filename): - # - # Insert a record for file - # - Filename =3D NormPath(Filename) - self.Identification.FileFullPath =3D Filename - (self.Identification.FileRelativePath, self.Identification.FileNam= e) =3D os.path.split(Filename) - self.FileID =3D self.TblFile.InsertFile(Filename, MODEL_FILE_DSC) - - # - # Init DscTable - # - #self.TblDsc.Table =3D "Dsc%s" % FileID - #self.TblDsc.Create() - - # - # Init common datas - # - IfDefList, SectionItemList, CurrentSection, ArchList, ThirdList, I= ncludeFiles =3D \ - [], [], TAB_UNKNOWN, [], [], [] - LineNo =3D 0 - - # - # Parse file content - # - IsFindBlockComment =3D False - ReservedLine =3D '' - for Line in open(Filename, 'r'): - LineNo =3D LineNo + 1 - # - # Remove comment block - # - if Line.find(TAB_COMMENT_EDK_START) > -1: - ReservedLine =3D GetSplitList(Line, TAB_COMMENT_EDK_START,= 1)[0] - IsFindBlockComment =3D True - if Line.find(TAB_COMMENT_EDK_END) > -1: - Line =3D ReservedLine + GetSplitList(Line, TAB_COMMENT_EDK= _END, 1)[1] - ReservedLine =3D '' - IsFindBlockComment =3D False - if IsFindBlockComment: - continue - - # - # Remove comments at tail and remove spaces again - # - Line =3D CleanString(Line) - if Line =3D=3D '': - continue - - # - # Find a new section tab - # First insert previous section items - # And then parse the content of the new section - # - if Line.startswith(TAB_SECTION_START) and Line.endswith(TAB_SE= CTION_END): - # - # Insert items data of previous section - # - self.InsertSectionItemsIntoDatabase(self.FileID, Filename,= CurrentSection, SectionItemList, ArchList, ThirdList, IfDefList) - # - # Parse the new section - # - SectionItemList =3D [] - ArchList =3D [] - ThirdList =3D [] - - CurrentSection =3D '' - LineList =3D GetSplitValueList(Line[len(TAB_SECTION_START)= :len(Line) - len(TAB_SECTION_END)], TAB_COMMA_SPLIT) - for Item in LineList: - ItemList =3D GetSplitValueList(Item, TAB_SPLIT) - if CurrentSection =3D=3D '': - CurrentSection =3D ItemList[0] - else: - if CurrentSection !=3D ItemList[0]: - EdkLogger.error("Parser", PARSER_ERROR, "Diffe= rent section names '%s' and '%s' are found in one section definition, this = is not allowed." % (CurrentSection, ItemList[0]), File=3DFilename, Line=3DL= ineNo, RaiseError=3DEdkLogger.IsRaiseError) - if CurrentSection.upper() not in self.KeyList: - RaiseParserError(Line, CurrentSection, Filename, '= ', LineNo) - CurrentSection =3D TAB_UNKNOWN - continue - ItemList.append('') - ItemList.append('') - if len(ItemList) > 5: - RaiseParserError(Line, CurrentSection, Filename, '= ', LineNo) - else: - if ItemList[1] !=3D '' and ItemList[1].upper() not= in ARCH_LIST_FULL: - EdkLogger.error("Parser", PARSER_ERROR, "Inval= id Arch definition '%s' found" % ItemList[1], File=3DFilename, Line=3DLineN= o, RaiseError=3DEdkLogger.IsRaiseError) - ArchList.append(ItemList[1].upper()) - ThirdList.append(ItemList[2]) - - continue - - # - # Not in any defined section - # - if CurrentSection =3D=3D TAB_UNKNOWN: - ErrorMsg =3D "%s is not in any defined section" % Line - EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=3DF= ilename, Line=3DLineNo, RaiseError=3DEdkLogger.IsRaiseError) - - # - # Add a section item - # - SectionItemList.append([Line, LineNo]) - # End of parse - #End of For - - # - # Insert items data of last section - # - self.InsertSectionItemsIntoDatabase(self.FileID, Filename, Current= Section, SectionItemList, ArchList, ThirdList, IfDefList) - - # - # Parse conditional statements - # - self.ParseConditionalStatement() - - # - # Replace all DEFINE macros with its actual values - # - #ParseDefineMacro2(self.TblDsc, self.RecordSet, GlobalData.gGlobal= Defines) - ParseDefineMacro(self.TblDsc, GlobalData.gGlobalDefines) - - - ## ParseConditionalStatement - # - # Search all conditional statement and disable no match records - # - def ParseConditionalStatement(self): - # - # Disabled all !if/!elif/!ifdef statements without DEFINE - # - SqlCommand =3D """select A.StartLine, A.EndLine from %s as A - where A.Model in (%s, %s, %s) - and A.Enabled =3D 0 - and A.BelongsToFile =3D %s - and A.Value1 not in (select B.Value1 from %s as B - where B.Model =3D %s - and B.Enabled =3D 0 - and A.StartLine > B.StartLine - and A.Arch =3D B.Arch - and A.BelongsToItem =3D B.Bel= ongsToItem - and A.BelongsToFile =3D B.Bel= ongsToFile) """ % \ - (self.TblDsc.Table, \ - MODEL_META_DATA_CONDITIONAL_STATEMENT_IF, MODEL_M= ETA_DATA_CONDITIONAL_STATEMENT_ELSE, MODEL_META_DATA_CONDITIONAL_STATEMENT_= IFDEF, \ - self.FileID, \ - self.TblDsc.Table, \ - MODEL_META_DATA_DEFINE) - RecordSet =3D self.TblDsc.Exec(SqlCommand) - for Record in RecordSet: - SqlCommand =3D """Update %s set Enabled =3D -1 where StartLine= >=3D %s and EndLine <=3D %s""" % (self.TblDsc.Table, Record[0], Record[1]) - self.TblDsc.Exec(SqlCommand) - - # - # Disabled !ifndef with DEFINE - # - SqlCommand =3D """select A.StartLine, A.EndLine from %s as A - where A.Model =3D %s - and A.Enabled =3D 0 - and A.BelongsToFile =3D %s - and A.Value1 in (select B.Value1 from %s as B - where B.Model =3D %s - and B.Enabled =3D 0 - and A.StartLine > B.StartLine - and A.Arch =3D B.Arch - and A.BelongsToItem =3D B.Belongs= ToItem - and A.BelongsToFile =3D B.Belongs= ToFile)""" % \ - (self.TblDsc.Table, \ - MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF, \ - self.FileID, \ - self.TblDsc.Table, \ - MODEL_META_DATA_DEFINE) - RecordSet =3D self.TblDsc.Exec(SqlCommand) - for Record in RecordSet: - SqlCommand =3D """Update %s set Enabled =3D -1 where StartLine= >=3D %s and EndLine <=3D %s""" % (self.TblDsc.Table, Record[0], Record[1]) - EdkLogger.debug(4, "SqlCommand: %s" % SqlCommand) - self.Cur.execute(SqlCommand) - - # - # Disabled !if, !elif and !else with un-match value - # - SqlCommand =3D """select A.Model, A.Value1, A.Value2, A.Value3, A.= StartLine, A.EndLine, B.Value2 from %s as A join %s as B - where A.Model in (%s, %s) - and A.Enabled =3D 0 - and A.BelongsToFile =3D %s - and B.Enabled =3D 0 - and B.Model =3D %s - and A.Value1 =3D B.Value1 - and A.StartLine > B.StartLine - and A.BelongsToItem =3D B.BelongsToItem - and A.BelongsToFile =3D B.BelongsToFile""" % \ - (self.TblDsc.Table, self.TblDsc.Table, \ - MODEL_META_DATA_CONDITIONAL_STATEMENT_IF, MODEL_M= ETA_DATA_CONDITIONAL_STATEMENT_ELSE, \ - self.FileID, MODEL_META_DATA_DEFINE) - RecordSet =3D self.TblDsc.Exec(SqlCommand) - DisabledList =3D [] - for Record in RecordSet: - if Record[0] =3D=3D MODEL_META_DATA_CONDITIONAL_STATEMENT_IF: - if not self.Compare(Record[6], Record[2], Record[3]): - SqlCommand =3D """Update %s set Enabled =3D -1 where S= tartLine >=3D %s and EndLine <=3D %s""" % (self.TblDsc.Table, Record[4], Re= cord[5]) - self.TblDsc.Exec(SqlCommand) - else: - DisabledList.append(Record[1]) - continue - if Record[0] =3D=3D MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE= and Record[1] in DisabledList: - SqlCommand =3D """Update %s set Enabled =3D -1 where Start= Line >=3D %s and EndLine <=3D %s""" % (self.TblDsc.Table, Record[4], Record= [5]) - self.TblDsc.Exec(SqlCommand) - - ## Compare - # - # Compare two values - # @param Value1: - # @param CompareType: - # @param Value2: - # - def Compare(self, Value1, CompareType, Value2): - Command =3D """Value1 %s Value2""" % CompareType - return eval(Command) - - ## First time to insert records to database - # - # Insert item data of a section to database - # @param FileID: The ID of belonging file - # @param Filename: The name of belonging file - # @param CurrentSection: The name of currect section - # @param SectionItemList: A list of items of the section - # @param ArchList: A list of arches - # @param ThirdList: A list of third parameters, ModuleType for = LibraryClass and SkuId for Dynamic Pcds - # @param IfDefList: A list of all conditional statements - # - def InsertSectionItemsIntoDatabase(self, FileID, Filename, CurrentSect= ion, SectionItemList, ArchList, ThirdList, IfDefList): - # - # Insert each item data of a section - # - for Index in range(0, len(ArchList)): - Arch =3D ArchList[Index] - Third =3D ThirdList[Index] - if Arch =3D=3D '': - Arch =3D TAB_ARCH_COMMON.upper() - - Model =3D Section[CurrentSection.upper()] - #Records =3D self.RecordSet[Model] - - for SectionItem in SectionItemList: - BelongsToItem, EndLine, EndColumn =3D -1, -1, -1 - LineValue, StartLine, EndLine =3D SectionItem[0], SectionI= tem[1], SectionItem[1] - - - EdkLogger.debug(4, "Parsing %s ..." % LineValue) - # - # Parse '!ifdef' - # - if LineValue.upper().find(TAB_IF_DEF.upper()) > -1: - IfDefList.append((LineValue[len(TAB_IF_N_DEF):].strip(= ), StartLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF)) - continue - - # - # Parse '!ifndef' - # - if LineValue.upper().find(TAB_IF_N_DEF.upper()) > -1: - IfDefList.append((LineValue[len(TAB_IF_N_DEF):].strip(= ), StartLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF)) - continue - - # - # Parse '!endif' - # - if LineValue.upper().find(TAB_END_IF.upper()) > -1: - self.InsertConditionalStatement(Filename, FileID, Mode= l, IfDefList, StartLine, Arch) - continue - # - # Parse '!if' - # - if LineValue.upper().find(TAB_IF.upper()) > -1: - IfDefList.append((LineValue[len(TAB_IF):].strip(), Sta= rtLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_IF)) - continue - - # - # Parse '!elseif' - # - if LineValue.upper().find(TAB_ELSE_IF.upper()) > -1: - self.InsertConditionalStatement(Filename, FileID, Mode= l, IfDefList, StartLine - 1, Arch) - IfDefList.append((LineValue[len(TAB_ELSE_IF):].strip()= , StartLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_IF)) - continue - - # - # Parse '!else' - # - if LineValue.upper().find(TAB_ELSE.upper()) > -1: - Key =3D IfDefList[-1][0].split(' ' , 1)[0].strip() - self.InsertConditionalStatement(Filename, FileID, Mode= l, IfDefList, StartLine, Arch) - IfDefList.append((Key, StartLine, MODEL_META_DATA_COND= ITIONAL_STATEMENT_ELSE)) - continue - - # - # Parse !include statement first - # - if LineValue.upper().find(DataType.TAB_INCLUDE.upper() + '= ') > -1: - self.ParseInclude(LineValue, StartLine, self.TblDsc, F= ileID, Filename, CurrentSection, MODEL_META_DATA_INCLUDE, Arch) - continue - - # - # And then parse DEFINE statement - # - if LineValue.upper().find(DataType.TAB_DEFINE.upper() + ' = ') > -1: - self.ParseDefine(LineValue, StartLine, self.TblDsc, Fi= leID, Filename, CurrentSection, MODEL_META_DATA_DEFINE, Arch) - continue - - # - # At last parse other sections - # - if CurrentSection =3D=3D TAB_LIBRARY_CLASSES or CurrentSec= tion in TAB_PCD_DYNAMIC_TYPE_LIST or CurrentSection in TAB_PCD_DYNAMIC_EX_T= YPE_LIST: - ID =3D self.TblDsc.Insert(Model, LineValue, Third, '',= Arch, -1, FileID, StartLine, -1, StartLine, -1, 0) - #Records.append([LineValue, Arch, StartLine, ID, Third= ]) - continue - elif CurrentSection !=3D TAB_COMPONENTS: - ID =3D self.TblDsc.Insert(Model, LineValue, '', '', Ar= ch, -1, FileID, StartLine, -1, StartLine, -1, 0) - #Records.append([LineValue, Arch, StartLine, ID, Third= ]) - continue - - # - # Parse COMPONENT section - # - if CurrentSection =3D=3D TAB_COMPONENTS: - Components =3D [] - GetComponent(SectionItemList, Components) - for Component in Components: - EdkLogger.debug(4, "Parsing component %s ..." % Compon= ent) - DscItmeID =3D self.TblDsc.Insert(MODEL_META_DATA_COMPO= NENT, Component[0], '', '', Arch, -1, FileID, StartLine, -1, StartLine, -1,= 0) - for Item in Component[1]: - List =3D GetSplitValueList(Item, MaxSplit=3D2) - LibName, LibIns =3D '', '' - if len(List) =3D=3D 2: - LibName =3D List[0] - LibIns =3D List[1] - else: - LibName =3D List[0] - self.TblDsc.Insert(MODEL_EFI_LIBRARY_CLASS, LibNam= e, LibIns, '', Arch, DscItmeID, FileID, StartLine, -1, StartLine, -1, 0) - for Item in Component[2]: - self.TblDsc.Insert(MODEL_META_DATA_BUILD_OPTION, I= tem, '', '', Arch, DscItmeID, FileID, StartLine, -1, StartLine, -1, 0) - for Item in Component[3]: - Model =3D Section[Item[0].upper()] - self.TblDsc.Insert(Model, Item[1], '', '', Arch, D= scItmeID, FileID, StartLine, -1, StartLine, -1, 0) - - ## Show detailed information of Dsc - # - # Print all members and their values of Dsc class - # - def ShowDsc(self): - print TAB_SECTION_START + TAB_INF_DEFINES + TAB_SECTION_END - printDict(self.Defines.DefinesDictionary) - - for Key in self.KeyList: - for Arch in DataType.ARCH_LIST_FULL: - Command =3D "printList(TAB_SECTION_START + '" + \ - Key + DataType.TAB_SPLIT + Arch + \ - "' + TAB_SECTION_END, self.Contents[ar= ch]." + Key + ')' - eval(Command) - - ## Show detailed information of Platform - # - # Print all members and their values of Platform class - # - def ShowPlatform(self): - M =3D self.Platform - for Arch in M.Header.keys(): - print '\nArch =3D', Arch - print 'Filename =3D', M.Header[Arch].FileName - print 'FullPath =3D', M.Header[Arch].FullPath - print 'BaseName =3D', M.Header[Arch].Name - print 'Guid =3D', M.Header[Arch].Guid - print 'Version =3D', M.Header[Arch].Version - print 'DscSpecification =3D', M.Header[Arch].DscSpecification - print 'SkuId =3D', M.Header[Arch].SkuIdName - print 'SupArchList =3D', M.Header[Arch].SupArchList - print 'BuildTargets =3D', M.Header[Arch].BuildTargets - print 'OutputDirectory =3D', M.Header[Arch].OutputDirectory - print 'BuildNumber =3D', M.Header[Arch].BuildNumber - print 'MakefileName =3D', M.Header[Arch].MakefileName - print 'BsBaseAddress =3D', M.Header[Arch].BsBaseAddress - print 'RtBaseAddress =3D', M.Header[Arch].RtBaseAddress - print 'Define =3D', M.Header[Arch].Define - print 'Fdf =3D', M.FlashDefinitionFile.FilePath - print '\nBuildOptions =3D', M.BuildOptions, M.BuildOptions.Include= Files - for Item in M.BuildOptions.BuildOptionList: - print '\t', 'ToolChainFamily =3D', Item.ToolChainFamily, 'Tool= Chain =3D', Item.ToolChain, 'Option =3D', Item.Option, 'Arch =3D', Item.Sup= ArchList - print '\nSkuIds =3D', M.SkuInfos.SkuInfoList, M.SkuInfos.IncludeFi= les - print '\nLibraries =3D', M.Libraries, M.Libraries.IncludeFiles - for Item in M.Libraries.LibraryList: - print '\t', Item.FilePath, Item.SupArchList, Item.Define - print '\nLibraryClasses =3D', M.LibraryClasses, M.LibraryClasses.I= ncludeFiles - for Item in M.LibraryClasses.LibraryList: - print '\t', Item.Name, Item.FilePath, Item.SupModuleList, Item= .SupArchList, Item.Define - print '\nPcds =3D', M.DynamicPcdBuildDefinitions - for Item in M.DynamicPcdBuildDefinitions: - print '\tCname=3D', Item.CName, 'TSG=3D', Item.TokenSpaceGuidC= Name, 'Value=3D', Item.DefaultValue, 'Token=3D', Item.Token, 'Type=3D', Ite= m.ItemType, 'Datum=3D', Item.DatumType, 'Size=3D', Item.MaxDatumSize, 'Arch= =3D', Item.SupArchList, Item.SkuInfoList - for Sku in Item.SkuInfoList.values(): - print '\t\t', str(Sku) - print '\nComponents =3D', M.Modules.ModuleList, M.Modules.IncludeF= iles - for Item in M.Modules.ModuleList: - print '\t', Item.FilePath, Item.ExecFilePath, Item.SupArchList - for Lib in Item.LibraryClasses.LibraryList: - print '\t\tLib:', Lib.Name, Lib.FilePath - for Bo in Item.ModuleSaBuildOption.BuildOptionList: - print '\t\tBuildOption:', Bo.ToolChainFamily, Bo.ToolChain= , Bo.Option - for Pcd in Item.PcdBuildDefinitions: - print '\t\tPcd:', Pcd.CName, Pcd.TokenSpaceGuidCName, Pcd.= MaxDatumSize, Pcd.DefaultValue, Pcd.ItemType - -## -# -# This acts like the main() function for the script, unless it is 'import'= ed into another -# script. -# -if __name__ =3D=3D '__main__': - EdkLogger.Initialize() - EdkLogger.SetLevel(EdkLogger.DEBUG_0) - - W =3D os.getenv('WORKSPACE') - F =3D os.path.join(W, 'Nt32Pkg/Nt32Pkg.dsc') - - Db =3D Database.Database('Dsc.db') - Db.InitDatabase() - - P =3D Dsc(os.path.normpath(F), True, True, W, Db) - P.ShowPlatform() - - Db.Close() diff --git a/BaseTools/Source/Python/Common/FdfClassObject.py b/BaseTools/S= ource/Python/Common/FdfClassObject.py deleted file mode 100644 index 9a7d6494d331..000000000000 --- a/BaseTools/Source/Python/Common/FdfClassObject.py +++ /dev/null @@ -1,106 +0,0 @@ -## @file -# This file is used to define each component of FDF file -# -# Copyright (c) 2008, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BS= D License -# which accompanies this distribution. The full text of the license may b= e found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. -# - -## -# Import Modules -# -from FdfParserLite import FdfParser -from Table.TableFdf import TableFdf -from CommonDataClass.DataClass import MODEL_FILE_FDF, MODEL_PCD, MODEL_MET= A_DATA_COMPONENT -from String import NormPath - - -## Fdf -# -# This class defined the structure used in Fdf object -#=20 -# @param Filename: Input value for Ffilename of Fdf file, default is = None -# @param WorkspaceDir: Input value for current workspace directory, defau= lt is None -# -class Fdf(object): - def __init__(self, Filename =3D None, IsToDatabase =3D False, Workspac= eDir =3D None, Database =3D None): - self.WorkspaceDir =3D WorkspaceDir - self.IsToDatabase =3D IsToDatabase - =20 - self.Cur =3D Database.Cur - self.TblFile =3D Database.TblFile - self.TblFdf =3D Database.TblFdf - self.FileID =3D -1 - self.FileList =3D {} - - # - # Load Fdf file if filename is not None - # - if Filename is not None: - self.LoadFdfFile(Filename) - - # - # Insert a FDF file record into database - # - def InsertFile(self, Filename): - FileID =3D -1 - Filename =3D NormPath(Filename) - if Filename not in self.FileList: - FileID =3D self.TblFile.InsertFile(Filename, MODEL_FILE_FDF) - self.FileList[Filename] =3D FileID - - return self.FileList[Filename] - =20 - =20 - ## Load Fdf file - # - # Load the file if it exists - # - # @param Filename: Input value for filename of Fdf file - # - def LoadFdfFile(self, Filename): =20 - FileList =3D [] - # - # Parse Fdf file - # - Filename =3D NormPath(Filename) - Fdf =3D FdfParser(Filename) - Fdf.ParseFile() - - # - # Insert inf file and pcd information - # - if self.IsToDatabase: - (Model, Value1, Value2, Value3, Arch, BelongsToItem, BelongsTo= File, StartLine, StartColumn, EndLine, EndColumn, Enabled) =3D \ - (0, '', '', '', 'COMMON', -1, -1, -1, -1, -1, -1, 0) - for Index in range(0, len(Fdf.Profile.PcdDict)): - pass - for Key in Fdf.Profile.PcdDict.keys(): - Model =3D MODEL_PCD - Value1 =3D '' - Value2 =3D ".".join((Key[1], Key[0])) - FileName =3D Fdf.Profile.PcdFileLineDict[Key][0] - StartLine =3D Fdf.Profile.PcdFileLineDict[Key][1] - BelongsToFile =3D self.InsertFile(FileName) - self.TblFdf.Insert(Model, Value1, Value2, Value3, Arch, Be= longsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Ena= bled) - for Index in range(0, len(Fdf.Profile.InfList)): - Model =3D MODEL_META_DATA_COMPONENT - Value1 =3D Fdf.Profile.InfList[Index] - Value2 =3D '' - FileName =3D Fdf.Profile.InfFileLineList[Index][0] - StartLine =3D Fdf.Profile.InfFileLineList[Index][1] - BelongsToFile =3D self.InsertFile(FileName) - self.TblFdf.Insert(Model, Value1, Value2, Value3, Arch, Be= longsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Ena= bled) - -## -# -# This acts like the main() function for the script, unless it is 'import'= ed into another -# script. -# -if __name__ =3D=3D '__main__': - pass diff --git a/BaseTools/Source/Python/Common/InfClassObject.py b/BaseTools/S= ource/Python/Common/InfClassObject.py deleted file mode 100644 index 7a5ba4eb84ce..000000000000 --- a/BaseTools/Source/Python/Common/InfClassObject.py +++ /dev/null @@ -1,1105 +0,0 @@ -## @file -# This file is used to define each component of INF file -# -# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
-# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BS= D License -# which accompanies this distribution. The full text of the license may b= e found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. -# - -## -# Import Modules -# -import Common.LongFilePathOs as os -import re -import EdkLogger -from CommonDataClass.CommonClass import LibraryClassClass -from CommonDataClass.ModuleClass import * -from String import * -from DataType import * -from Identification import * -from Dictionary import * -from BuildToolError import * -from Misc import sdict -import GlobalData -from Table.TableInf import TableInf -import Database -from Parsing import * -from Common.LongFilePathSupport import OpenLongFilePath as open - -# -# Global variable -# -Section =3D {TAB_UNKNOWN.upper() : MODEL_UNKNOWN, - TAB_INF_DEFINES.upper() : MODEL_META_DATA_HEADER, - TAB_BUILD_OPTIONS.upper() : MODEL_META_DATA_BUILD_OPTION, - TAB_INCLUDES.upper() : MODEL_EFI_INCLUDE, - TAB_LIBRARIES.upper() : MODEL_EFI_LIBRARY_INSTANCE, - TAB_LIBRARY_CLASSES.upper() : MODEL_EFI_LIBRARY_CLASS, - TAB_PACKAGES.upper() : MODEL_META_DATA_PACKAGE, - TAB_NMAKE.upper() : MODEL_META_DATA_NMAKE, - TAB_INF_FIXED_PCD.upper() : MODEL_PCD_FIXED_AT_BUILD, - TAB_INF_PATCH_PCD.upper() : MODEL_PCD_PATCHABLE_IN_MODULE, - TAB_INF_FEATURE_PCD.upper() : MODEL_PCD_FEATURE_FLAG, - TAB_INF_PCD_EX.upper() : MODEL_PCD_DYNAMIC_EX, - TAB_INF_PCD.upper() : MODEL_PCD_DYNAMIC, - TAB_SOURCES.upper() : MODEL_EFI_SOURCE_FILE, - TAB_GUIDS.upper() : MODEL_EFI_GUID, - TAB_PROTOCOLS.upper() : MODEL_EFI_PROTOCOL, - TAB_PPIS.upper() : MODEL_EFI_PPI, - TAB_DEPEX.upper() : MODEL_EFI_DEPEX, - TAB_BINARIES.upper() : MODEL_EFI_BINARY_FILE, - TAB_USER_EXTENSIONS.upper() : MODEL_META_DATA_USER_EXTENSION - } - -gComponentType2ModuleType =3D { - "LIBRARY" : "BASE", - "SECURITY_CORE" : "SEC", - "PEI_CORE" : "PEI_CORE", - "COMBINED_PEIM_DRIVER" : "PEIM", - "PIC_PEIM" : "PEIM", - "RELOCATABLE_PEIM" : "PEIM", - "PE32_PEIM" : "PEIM", - "BS_DRIVER" : "DXE_DRIVER", - "RT_DRIVER" : "DXE_RUNTIME_DRIVER", - "SAL_RT_DRIVER" : "DXE_SAL_DRIVER", - "APPLICATION" : "UEFI_APPLICATION", - "LOGO" : "BASE", -} - -gNmakeFlagPattern =3D re.compile("(?:EBC_)?([A-Z]+)_(?:STD_|PROJ_|ARCH_)?F= LAGS(?:_DLL|_ASL|_EXE)?", re.UNICODE) -gNmakeFlagName2ToolCode =3D { - "C" : "CC", - "LIB" : "SLINK", - "LINK" : "DLINK", -} - -class InfHeader(ModuleHeaderClass): - _Mapping_ =3D { - # - # Required Fields - # - TAB_INF_DEFINES_BASE_NAME : "Name", - TAB_INF_DEFINES_FILE_GUID : "Guid", - TAB_INF_DEFINES_MODULE_TYPE : "ModuleType", - TAB_INF_DEFINES_EFI_SPECIFICATION_VERSION : "UefiSpecificationVe= rsion", - TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION : "UefiSpecificationVe= rsion", - TAB_INF_DEFINES_EDK_RELEASE_VERSION : "EdkReleaseVersion", - # - # Optional Fields - # - TAB_INF_DEFINES_INF_VERSION : "InfVersion", - TAB_INF_DEFINES_BINARY_MODULE : "BinaryModule", - TAB_INF_DEFINES_COMPONENT_TYPE : "ComponentType", - TAB_INF_DEFINES_MAKEFILE_NAME : "MakefileName", - TAB_INF_DEFINES_BUILD_NUMBER : "BuildNumber", - TAB_INF_DEFINES_BUILD_TYPE : "BuildType", - TAB_INF_DEFINES_FFS_EXT : "FfsExt", - TAB_INF_DEFINES_FV_EXT : "FvExt", - TAB_INF_DEFINES_SOURCE_FV : "SourceFv", - TAB_INF_DEFINES_VERSION_NUMBER : "VersionNumber", - TAB_INF_DEFINES_VERSION_STRING : "VersionString", - TAB_INF_DEFINES_VERSION : "Version", - TAB_INF_DEFINES_PCD_IS_DRIVER : "PcdIsDriver", - TAB_INF_DEFINES_TIANO_EDK_FLASHMAP_H : "TianoEdkFlashMap_h= ", - TAB_INF_DEFINES_SHADOW : "Shadow", -# TAB_INF_DEFINES_LIBRARY_CLASS : "LibraryClass", -# TAB_INF_DEFINES_ENTRY_POINT : "ExternImages", -# TAB_INF_DEFINES_UNLOAD_IMAGE : "ExternImages", -# TAB_INF_DEFINES_CONSTRUCTOR : , -# TAB_INF_DEFINES_DESTRUCTOR : , -# TAB_INF_DEFINES_DEFINE : "Define", -# TAB_INF_DEFINES_SPEC : "Specification", -# TAB_INF_DEFINES_CUSTOM_MAKEFILE : "CustomMakefile", -# TAB_INF_DEFINES_MACRO : - } - - def __init__(self): - ModuleHeaderClass.__init__(self) - self.VersionNumber =3D '' - self.VersionString =3D '' - #print self.__dict__ - def __setitem__(self, key, value): - self.__dict__[self._Mapping_[key]] =3D value - def __getitem__(self, key): - return self.__dict__[self._Mapping_[key]] - ## "in" test support - def __contains__(self, key): - return key in self._Mapping_ - -## Inf -# -# This class defined the structure used in Inf object -# -# @param Ffilename: Input value for Ffilename of Inf file, default= is None -# @param IsMergeAllArches: Input value for IsMergeAllArches -# True is to merge all arches -# Fales is not to merge all arches -# default is False -# @param IsToModule: Input value for IsToModule -# True is to transfer to ModuleObject automatica= lly -# False is not to transfer to ModuleObject autom= atically -# default is False -# @param WorkspaceDir: Input value for current workspace directory, d= efault is None -# -# @var Identification: To store value for Identification, it is a str= ucture as Identification -# @var UserExtensions: To store value for UserExtensions -# @var Module: To store value for Module, it is a structure a= s ModuleClass -# @var WorkspaceDir: To store value for WorkspaceDir -# @var KeyList: To store value for KeyList, a list for all Key= s used in Inf -# -class Inf(object): - def __init__(self, Filename=3DNone, IsToDatabase=3DFalse, IsToModule= =3DFalse, WorkspaceDir=3DNone, Database=3DNone, SupArchList=3DDataType.ARCH= _LIST): - self.Identification =3D Identification() - self.Module =3D ModuleClass() - self.UserExtensions =3D '' - self.WorkspaceDir =3D WorkspaceDir - self.SupArchList =3D SupArchList - self.IsToDatabase =3D IsToDatabase - - self.Cur =3D Database.Cur - self.TblFile =3D Database.TblFile - self.TblInf =3D Database.TblInf - self.FileID =3D -1 - #self.TblInf =3D TableInf(Database.Cur) - - self.KeyList =3D [ - TAB_SOURCES, TAB_BUILD_OPTIONS, TAB_BINARIES, TAB_INCLUDES, TA= B_GUIDS, - TAB_PROTOCOLS, TAB_PPIS, TAB_LIBRARY_CLASSES, TAB_PACKAGES, TA= B_LIBRARIES, - TAB_INF_FIXED_PCD, TAB_INF_PATCH_PCD, TAB_INF_FEATURE_PCD, TAB= _INF_PCD, - TAB_INF_PCD_EX, TAB_DEPEX, TAB_NMAKE, TAB_INF_DEFINES - ] - # - # Upper all KEYs to ignore case sensitive when parsing - # - self.KeyList =3D map(lambda c: c.upper(), self.KeyList) - - # - # Init RecordSet - # - self.RecordSet =3D {} - for Key in self.KeyList: - self.RecordSet[Section[Key]] =3D [] - - # - # Load Inf file if filename is not None - # - if Filename is not None: - self.LoadInfFile(Filename) - - # - # Transfer to Module Object if IsToModule is True - # - if IsToModule: - self.InfToModule() - - ## Transfer to Module Object - # - # Transfer all contents of an Inf file to a standard Module Object - # - def InfToModule(self): - # - # Init global information for the file - # - ContainerFile =3D self.Identification.FileFullPath - - # - # Generate Package Header - # - self.GenModuleHeader(ContainerFile) - - # - # Generate BuildOptions - # - self.GenBuildOptions(ContainerFile) - - # - # Generate Includes - # - self.GenIncludes(ContainerFile) - - # - # Generate Libraries - # - self.GenLibraries(ContainerFile) - - # - # Generate LibraryClasses - # - self.GenLibraryClasses(ContainerFile) - - # - # Generate Packages - # - self.GenPackages(ContainerFile) - - # - # Generate Nmakes - # - self.GenNmakes(ContainerFile) - - # - # Generate Pcds - # - self.GenPcds(ContainerFile) - - # - # Generate Sources - # - self.GenSources(ContainerFile) - - # - # Generate UserExtensions - # - self.GenUserExtensions(ContainerFile) - - # - # Generate Guids - # - self.GenGuidProtocolPpis(DataType.TAB_GUIDS, ContainerFile) - - # - # Generate Protocols - # - self.GenGuidProtocolPpis(DataType.TAB_PROTOCOLS, ContainerFile) - - # - # Generate Ppis - # - self.GenGuidProtocolPpis(DataType.TAB_PPIS, ContainerFile) - - # - # Generate Depexes - # - self.GenDepexes(ContainerFile) - - # - # Generate Binaries - # - self.GenBinaries(ContainerFile) - - ## Parse [Defines] section - # - # Parse [Defines] section into InfDefines object - # - # @param InfFile The path of the INF file - # @param Section The title of "Defines" section - # @param Lines The content of "Defines" section - # - def ParseDefines(self, InfFile, Section, Lines): - TokenList =3D Section.split(TAB_SPLIT) - if len(TokenList) =3D=3D 3: - RaiseParserError(Section, "Defines", InfFile, "[xx.yy.%s] form= at (with platform) is not supported") - if len(TokenList) =3D=3D 2: - Arch =3D TokenList[1].upper() - else: - Arch =3D TAB_ARCH_COMMON - - if Arch not in self.Defines: - self.Defines[Arch] =3D InfDefines() - GetSingleValueOfKeyFromLines(Lines, self.Defines[Arch].DefinesDict= ionary, - TAB_COMMENT_SPLIT, TAB_EQUAL_SPLIT, F= alse, None) - - ## Load Inf file - # - # Load the file if it exists - # - # @param Filename: Input value for filename of Inf file - # - def LoadInfFile(self, Filename): - # - # Insert a record for file - # - Filename =3D NormPath(Filename) - self.Identification.FileFullPath =3D Filename - (self.Identification.FileRelativePath, self.Identification.FileNam= e) =3D os.path.split(Filename) - self.FileID =3D self.TblFile.InsertFile(Filename, MODEL_FILE_INF) - - # - # Init InfTable - # - #self.TblInf.Table =3D "Inf%s" % self.FileID - #self.TblInf.Create() - - # - # Init common datas - # - IfDefList, SectionItemList, CurrentSection, ArchList, ThirdList, I= ncludeFiles =3D \ - [], [], TAB_UNKNOWN, [], [], [] - LineNo =3D 0 - - # - # Parse file content - # - IsFindBlockComment =3D False - ReservedLine =3D '' - for Line in open(Filename, 'r'): - LineNo =3D LineNo + 1 - # - # Remove comment block - # - if Line.find(TAB_COMMENT_EDK_START) > -1: - ReservedLine =3D GetSplitList(Line, TAB_COMMENT_EDK_START,= 1)[0] - IsFindBlockComment =3D True - if Line.find(TAB_COMMENT_EDK_END) > -1: - Line =3D ReservedLine + GetSplitList(Line, TAB_COMMENT_EDK= _END, 1)[1] - ReservedLine =3D '' - IsFindBlockComment =3D False - if IsFindBlockComment: - continue - - # - # Remove comments at tail and remove spaces again - # - Line =3D CleanString(Line) - if Line =3D=3D '': - continue - - # - # Find a new section tab - # First insert previous section items - # And then parse the content of the new section - # - if Line.startswith(TAB_SECTION_START) and Line.endswith(TAB_SE= CTION_END): - if Line[1:3] =3D=3D "--": - continue - Model =3D Section[CurrentSection.upper()] - # - # Insert items data of previous section - # - InsertSectionItemsIntoDatabase(self.TblInf, self.FileID, F= ilename, Model, CurrentSection, SectionItemList, ArchList, ThirdList, IfDef= List, self.RecordSet) - # - # Parse the new section - # - SectionItemList =3D [] - ArchList =3D [] - ThirdList =3D [] - - CurrentSection =3D '' - LineList =3D GetSplitValueList(Line[len(TAB_SECTION_START)= :len(Line) - len(TAB_SECTION_END)], TAB_COMMA_SPLIT) - for Item in LineList: - ItemList =3D GetSplitValueList(Item, TAB_SPLIT) - if CurrentSection =3D=3D '': - CurrentSection =3D ItemList[0] - else: - if CurrentSection !=3D ItemList[0]: - EdkLogger.error("Parser", PARSER_ERROR, "Diffe= rent section names '%s' and '%s' are found in one section definition, this = is not allowed." % (CurrentSection, ItemList[0]), File=3DFilename, Line=3DL= ineNo, RaiseError=3DEdkLogger.IsRaiseError) - if CurrentSection.upper() not in self.KeyList: - RaiseParserError(Line, CurrentSection, Filename, '= ', LineNo) - CurrentSection =3D TAB_UNKNOWN - continue - ItemList.append('') - ItemList.append('') - if len(ItemList) > 5: - RaiseParserError(Line, CurrentSection, Filename, '= ', LineNo) - else: - if ItemList[1] !=3D '' and ItemList[1].upper() not= in ARCH_LIST_FULL: - EdkLogger.error("Parser", PARSER_ERROR, "Inval= id Arch definition '%s' found" % ItemList[1], File=3DFilename, Line=3DLineN= o, RaiseError=3DEdkLogger.IsRaiseError) - ArchList.append(ItemList[1].upper()) - ThirdList.append(ItemList[2]) - - continue - - # - # Not in any defined section - # - if CurrentSection =3D=3D TAB_UNKNOWN: - ErrorMsg =3D "%s is not in any defined section" % Line - EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=3DF= ilename, Line=3DLineNo, RaiseError=3DEdkLogger.IsRaiseError) - - # - # Add a section item - # - SectionItemList.append([Line, LineNo]) - # End of parse - #End of For - - # - # Insert items data of last section - # - Model =3D Section[CurrentSection.upper()] - InsertSectionItemsIntoDatabase(self.TblInf, self.FileID, Filename,= Model, CurrentSection, SectionItemList, ArchList, ThirdList, IfDefList, se= lf.RecordSet) - - # - # Replace all DEFINE macros with its actual values - # - ParseDefineMacro2(self.TblInf, self.RecordSet, GlobalData.gGlobalD= efines) - - ## Show detailed information of Module - # - # Print all members and their values of Module class - # - def ShowModule(self): - M =3D self.Module - for Arch in M.Header.keys(): - print '\nArch =3D', Arch - print 'Filename =3D', M.Header[Arch].FileName - print 'FullPath =3D', M.Header[Arch].FullPath - print 'BaseName =3D', M.Header[Arch].Name - print 'Guid =3D', M.Header[Arch].Guid - print 'Version =3D', M.Header[Arch].Version - print 'InfVersion =3D', M.Header[Arch].InfVersion - print 'UefiSpecificationVersion =3D', M.Header[Arch].UefiSpeci= ficationVersion - print 'EdkReleaseVersion =3D', M.Header[Arch].EdkReleaseVersion - print 'ModuleType =3D', M.Header[Arch].ModuleType - print 'BinaryModule =3D', M.Header[Arch].BinaryModule - print 'ComponentType =3D', M.Header[Arch].ComponentType - print 'MakefileName =3D', M.Header[Arch].MakefileName - print 'BuildNumber =3D', M.Header[Arch].BuildNumber - print 'BuildType =3D', M.Header[Arch].BuildType - print 'FfsExt =3D', M.Header[Arch].FfsExt - print 'FvExt =3D', M.Header[Arch].FvExt - print 'SourceFv =3D', M.Header[Arch].SourceFv - print 'PcdIsDriver =3D', M.Header[Arch].PcdIsDriver - print 'TianoEdkFlashMap_h =3D', M.Header[Arch].TianoEdkFlashMa= p_h - print 'Shadow =3D', M.Header[Arch].Shadow - print 'LibraryClass =3D', M.Header[Arch].LibraryClass - for Item in M.Header[Arch].LibraryClass: - print Item.LibraryClass, DataType.TAB_VALUE_SPLIT.join(Ite= m.SupModuleList) - print 'CustomMakefile =3D', M.Header[Arch].CustomMakefile - print 'Define =3D', M.Header[Arch].Define - print 'Specification =3D', M.Header[Arch].Specification - for Item in self.Module.ExternImages: - print '\nEntry_Point =3D %s, UnloadImage =3D %s' % (Item.Modul= eEntryPoint, Item.ModuleUnloadImage) - for Item in self.Module.ExternLibraries: - print 'Constructor =3D %s, Destructor =3D %s' % (Item.Construc= tor, Item.Destructor) - print '\nBuildOptions =3D', M.BuildOptions - for Item in M.BuildOptions: - print Item.ToolChainFamily, Item.ToolChain, Item.Option, Item.= SupArchList - print '\nIncludes =3D', M.Includes - for Item in M.Includes: - print Item.FilePath, Item.SupArchList - print '\nLibraries =3D', M.Libraries - for Item in M.Libraries: - print Item.Library, Item.SupArchList - print '\nLibraryClasses =3D', M.LibraryClasses - for Item in M.LibraryClasses: - print Item.LibraryClass, Item.RecommendedInstance, Item.Featur= eFlag, Item.SupModuleList, Item.SupArchList, Item.Define - print '\nPackageDependencies =3D', M.PackageDependencies - for Item in M.PackageDependencies: - print Item.FilePath, Item.SupArchList, Item.FeatureFlag - print '\nNmake =3D', M.Nmake - for Item in M.Nmake: - print Item.Name, Item.Value, Item.SupArchList - print '\nPcds =3D', M.PcdCodes - for Item in M.PcdCodes: - print '\tCName=3D', Item.CName, 'TokenSpaceGuidCName=3D', Item= .TokenSpaceGuidCName, 'DefaultValue=3D', Item.DefaultValue, 'ItemType=3D', = Item.ItemType, Item.SupArchList - print '\nSources =3D', M.Sources - for Source in M.Sources: - print Source.SourceFile, 'Fam=3D', Source.ToolChainFamily, 'Pc= d=3D', Source.FeatureFlag, 'Tag=3D', Source.TagName, 'ToolCode=3D', Source.= ToolCode, Source.SupArchList - print '\nUserExtensions =3D', M.UserExtensions - for UserExtension in M.UserExtensions: - print UserExtension.UserID, UserExtension.Identifier, UserExte= nsion.Content - print '\nGuids =3D', M.Guids - for Item in M.Guids: - print Item.CName, Item.SupArchList, Item.FeatureFlag - print '\nProtocols =3D', M.Protocols - for Item in M.Protocols: - print Item.CName, Item.SupArchList, Item.FeatureFlag - print '\nPpis =3D', M.Ppis - for Item in M.Ppis: - print Item.CName, Item.SupArchList, Item.FeatureFlag - print '\nDepex =3D', M.Depex - for Item in M.Depex: - print Item.Depex, Item.SupArchList, Item.Define - print '\nBinaries =3D', M.Binaries - for Binary in M.Binaries: - print 'Type=3D', Binary.FileType, 'Target=3D', Binary.Target, = 'Name=3D', Binary.BinaryFile, 'FeatureFlag=3D', Binary.FeatureFlag, 'SupArc= hList=3D', Binary.SupArchList - - ## Convert [Defines] section content to ModuleHeaderClass - # - # Convert [Defines] section content to ModuleHeaderClass - # - # @param Defines The content under [Defines] section - # @param ModuleHeader An object of ModuleHeaderClass - # @param Arch The supported ARCH - # - def GenModuleHeader(self, ContainerFile): - EdkLogger.debug(2, "Generate ModuleHeader ...") - File =3D self.Identification.FileFullPath - # - # Update all defines item in database - # - RecordSet =3D self.RecordSet[MODEL_META_DATA_HEADER] - for Record in RecordSet: - ValueList =3D GetSplitValueList(Record[0], TAB_EQUAL_SPLIT) - if len(ValueList) !=3D 2: - RaiseParserError(Record[0], 'Defines', ContainerFile, ' =3D ', Record[2]) - ID, Value1, Value2, Arch, LineNo =3D Record[3], ValueList[0], = ValueList[1], Record[1], Record[2] - SqlCommand =3D """update %s set Value1 =3D '%s', Value2 =3D '%= s' - where ID =3D %s""" % (self.TblInf.Table, Conve= rtToSqlString2(Value1), ConvertToSqlString2(Value2), ID) - self.TblInf.Exec(SqlCommand) - - for Arch in DataType.ARCH_LIST: - ModuleHeader =3D InfHeader() - ModuleHeader.FileName =3D self.Identification.FileName - ModuleHeader.FullPath =3D self.Identification.FileFullPath - DefineList =3D QueryDefinesItem2(self.TblInf, Arch, self.FileI= D) - - NotProcessedDefineList =3D [] - for D in DefineList: - if D[0] in ModuleHeader: - ModuleHeader[D[0]] =3D GetSplitValueList(D[1])[0] - else: - NotProcessedDefineList.append(D) - - if ModuleHeader.ComponentType =3D=3D "LIBRARY": - Lib =3D LibraryClassClass() - Lib.LibraryClass =3D ModuleHeader.Name - Lib.SupModuleList =3D DataType.SUP_MODULE_LIST - ModuleHeader.LibraryClass.append(Lib) - - # we need to make some key defines resolved first - for D in NotProcessedDefineList: - if D[0] =3D=3D TAB_INF_DEFINES_LIBRARY_CLASS: - List =3D GetSplitValueList(D[1], DataType.TAB_VALUE_SP= LIT, 1) - Lib =3D LibraryClassClass() - Lib.LibraryClass =3D CleanString(List[0]) - if len(List) =3D=3D 1: - Lib.SupModuleList =3D DataType.SUP_MODULE_LIST - elif len(List) =3D=3D 2: - Lib.SupModuleList =3D GetSplitValueList(CleanStrin= g(List[1]), ' ') - ModuleHeader.LibraryClass.append(Lib) - elif D[0] =3D=3D TAB_INF_DEFINES_CUSTOM_MAKEFILE: - List =3D D[1].split(DataType.TAB_VALUE_SPLIT) - if len(List) =3D=3D 2: - ModuleHeader.CustomMakefile[CleanString(List[0])] = =3D CleanString(List[1]) - else: - RaiseParserError(D[1], 'CUSTOM_MAKEFILE of Defines= ', File, 'CUSTOM_MAKEFILE=3D|', D[2]) - elif D[0] =3D=3D TAB_INF_DEFINES_ENTRY_POINT: - Image =3D ModuleExternImageClass() - Image.ModuleEntryPoint =3D CleanString(D[1]) - self.Module.ExternImages.append(Image) - elif D[0] =3D=3D TAB_INF_DEFINES_UNLOAD_IMAGE: - Image =3D ModuleExternImageClass() - Image.ModuleUnloadImage =3D CleanString(D[1]) - self.Module.ExternImages.append(Image) - elif D[0] =3D=3D TAB_INF_DEFINES_CONSTRUCTOR: - LibraryClass =3D ModuleExternLibraryClass() - LibraryClass.Constructor =3D CleanString(D[1]) - self.Module.ExternLibraries.append(LibraryClass) - elif D[0] =3D=3D TAB_INF_DEFINES_DESTRUCTOR: - LibraryClass =3D ModuleExternLibraryClass() - LibraryClass.Destructor =3D CleanString(D[1]) - self.Module.ExternLibraries.append(LibraryClass) - elif D[0] =3D=3D TAB_INF_DEFINES_DEFINE: - List =3D D[1].split(DataType.TAB_EQUAL_SPLIT) - if len(List) !=3D 2: - RaiseParserError(Item, 'DEFINE of Defines', File, = 'DEFINE =3D ', D[2]) - else: - ModuleHeader.Define[CleanString(List[0])] =3D Clea= nString(List[1]) - elif D[0] =3D=3D TAB_INF_DEFINES_SPEC: - List =3D D[1].split(DataType.TAB_EQUAL_SPLIT) - if len(List) !=3D 2: - RaiseParserError(Item, 'SPEC of Defines', File, 'S= PEC =3D ', D[2]) - else: - ModuleHeader.Specification[CleanString(List[0])] = =3D CleanString(List[1]) - - # - # Get version of INF - # - if ModuleHeader.InfVersion !=3D "": - # EdkII inf - VersionNumber =3D ModuleHeader.VersionNumber - VersionString =3D ModuleHeader.VersionString - if len(VersionNumber) > 0 and len(VersionString) =3D=3D 0: - EdkLogger.warn(2000, 'VERSION_NUMBER depricated; INF f= ile %s should be modified to use VERSION_STRING instead.' % self.Identifica= tion.FileFullPath) - ModuleHeader.Version =3D VersionNumber - if len(VersionString) > 0: - if len(VersionNumber) > 0: - EdkLogger.warn(2001, 'INF file %s defines both VER= SION_NUMBER and VERSION_STRING, using VERSION_STRING' % self.Identification= .FileFullPath) - ModuleHeader.Version =3D VersionString - else: - # Edk inf - ModuleHeader.InfVersion =3D "0x00010000" - if ModuleHeader.ComponentType in gComponentType2ModuleType: - ModuleHeader.ModuleType =3D gComponentType2ModuleType[= ModuleHeader.ComponentType] - elif ModuleHeader.ComponentType !=3D '': - EdkLogger.error("Parser", PARSER_ERROR, "Unsupported E= dk component type [%s]" % ModuleHeader.ComponentType, ExtraData=3DFile, Rai= seError=3DEdkLogger.IsRaiseError) - - self.Module.Header[Arch] =3D ModuleHeader - - - ## GenBuildOptions - # - # Gen BuildOptions of Inf - # [:]=3DFlag - # - # @param ContainerFile: The Inf file full path - # - def GenBuildOptions(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_BUILD_OPTIONS) - BuildOptions =3D {} - # - # Get all BuildOptions - # - RecordSet =3D self.RecordSet[MODEL_META_DATA_BUILD_OPTION] - - # - # Go through each arch - # - for Arch in self.SupArchList: - for Record in RecordSet: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON: - (Family, ToolChain, Flag) =3D GetBuildOption(Record[0]= , ContainerFile, Record[2]) - MergeArches(BuildOptions, (Family, ToolChain, Flag), A= rch) - # - # Update to Database - # - if self.IsToDatabase: - SqlCommand =3D """update %s set Value1 =3D '%s', V= alue2 =3D '%s', Value3 =3D '%s' - where ID =3D %s""" % (self.TblInf.= Table, ConvertToSqlString2(Family), ConvertToSqlString2(ToolChain), Convert= ToSqlString2(Flag), Record[3]) - self.TblInf.Exec(SqlCommand) - - for Key in BuildOptions.keys(): - BuildOption =3D BuildOptionClass(Key[0], Key[1], Key[2]) - BuildOption.SupArchList =3D BuildOptions[Key] - self.Module.BuildOptions.append(BuildOption) - - ## GenIncludes - # - # Gen Includes of Inf - # - # - # @param ContainerFile: The Inf file full path - # - def GenIncludes(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_INCLUDES) - Includes =3D sdict() - # - # Get all Includes - # - RecordSet =3D self.RecordSet[MODEL_EFI_INCLUDE] - - # - # Go through each arch - # - for Arch in self.SupArchList: - for Record in RecordSet: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON: - MergeArches(Includes, Record[0], Arch) - - for Key in Includes.keys(): - Include =3D IncludeClass() - Include.FilePath =3D NormPath(Key) - Include.SupArchList =3D Includes[Key] - self.Module.Includes.append(Include) - - ## GenLibraries - # - # Gen Libraries of Inf - # - # - # @param ContainerFile: The Inf file full path - # - def GenLibraries(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_LIBRARIES) - Libraries =3D sdict() - # - # Get all Includes - # - RecordSet =3D self.RecordSet[MODEL_EFI_LIBRARY_INSTANCE] - - # - # Go through each arch - # - for Arch in self.SupArchList: - for Record in RecordSet: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON: - MergeArches(Libraries, Record[0], Arch) - - for Key in Libraries.keys(): - Library =3D ModuleLibraryClass() - # replace macro and remove file extension - Library.Library =3D Key.rsplit('.', 1)[0] - Library.SupArchList =3D Libraries[Key] - self.Module.Libraries.append(Library) - - ## GenLibraryClasses - # - # Get LibraryClass of Inf - # | - # - # @param ContainerFile: The Inf file full path - # - def GenLibraryClasses(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_LIBRARY_CLASSES) - LibraryClasses =3D {} - # - # Get all LibraryClasses - # - RecordSet =3D self.RecordSet[MODEL_EFI_LIBRARY_CLASS] - - # - # Go through each arch - # - for Arch in self.SupArchList: - for Record in RecordSet: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON: - (LibClassName, LibClassIns, Pcd, SupModelList) =3D Get= LibraryClassOfInf([Record[0], Record[4]], ContainerFile, self.WorkspaceDir,= Record[2]) - MergeArches(LibraryClasses, (LibClassName, LibClassIns= , Pcd, SupModelList), Arch) - # - # Update to Database - # - if self.IsToDatabase: - SqlCommand =3D """update %s set Value1 =3D '%s', V= alue2 =3D '%s', Value3 =3D '%s' - where ID =3D %s""" % (self.TblInf.= Table, ConvertToSqlString2(LibClassName), ConvertToSqlString2(LibClassIns),= ConvertToSqlString2(SupModelList), Record[3]) - self.TblInf.Exec(SqlCommand) - - for Key in LibraryClasses.keys(): - KeyList =3D Key[0].split(DataType.TAB_VALUE_SPLIT) - LibraryClass =3D LibraryClassClass() - LibraryClass.LibraryClass =3D Key[0] - LibraryClass.RecommendedInstance =3D NormPath(Key[1]) - LibraryClass.FeatureFlag =3D Key[2] - LibraryClass.SupArchList =3D LibraryClasses[Key] - LibraryClass.SupModuleList =3D GetSplitValueList(Key[3]) - self.Module.LibraryClasses.append(LibraryClass) - - ## GenPackages - # - # Gen Packages of Inf - # - # - # @param ContainerFile: The Inf file full path - # - def GenPackages(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_PACKAGES) - Packages =3D {} - # - # Get all Packages - # - RecordSet =3D self.RecordSet[MODEL_META_DATA_PACKAGE] - - # - # Go through each arch - # - for Arch in self.SupArchList: - for Record in RecordSet: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON: - (Package, Pcd) =3D GetPackage(Record[0], ContainerFile= , self.WorkspaceDir, Record[2]) - MergeArches(Packages, (Package, Pcd), Arch) - if self.IsToDatabase: - SqlCommand =3D """update %s set Value1 =3D '%s', V= alue2 =3D '%s' - where ID =3D %s""" % (self.TblInf.= Table, ConvertToSqlString2(Package), ConvertToSqlString2(Pcd), Record[3]) - self.TblInf.Exec(SqlCommand) - - - for Key in Packages.keys(): - Package =3D ModulePackageDependencyClass() - Package.FilePath =3D NormPath(Key[0]) - Package.SupArchList =3D Packages[Key] - Package.FeatureFlag =3D Key[1] - self.Module.PackageDependencies.append(Package) - - ## GenNmakes - # - # Gen Nmakes of Inf - # - # - # @param ContainerFile: The Inf file full path - # - def GenNmakes(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_NMAKE) - Nmakes =3D sdict() - # - # Get all Nmakes - # - RecordSet =3D self.RecordSet[MODEL_META_DATA_NMAKE] - - - # - # Go through each arch - # - for Arch in self.SupArchList: - for Record in RecordSet: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON: - MergeArches(Nmakes, Record[0], Arch) - - for Key in Nmakes.keys(): - List =3D GetSplitValueList(Key, DataType.TAB_EQUAL_SPLIT, MaxS= plit=3D1) - if len(List) !=3D 2: - RaiseParserError(Key, 'Nmake', ContainerFile, '= =3D ') - continue - Nmake =3D ModuleNmakeClass() - Nmake.Name =3D List[0] - Nmake.Value =3D List[1] - Nmake.SupArchList =3D Nmakes[Key] - self.Module.Nmake.append(Nmake) - - # convert Edk format to EdkII format - if Nmake.Name =3D=3D "IMAGE_ENTRY_POINT": - Image =3D ModuleExternImageClass() - Image.ModuleEntryPoint =3D Nmake.Value - self.Module.ExternImages.append(Image) - elif Nmake.Name =3D=3D "DPX_SOURCE": - Source =3D ModuleSourceFileClass(NormPath(Nmake.Value), ""= , "", "", "", Nmake.SupArchList) - self.Module.Sources.append(Source) - else: - ToolList =3D gNmakeFlagPattern.findall(Nmake.Name) - if len(ToolList) =3D=3D 0 or len(ToolList) !=3D 1: - EdkLogger.warn("\nParser", "Don't know how to do with = MACRO: %s" % Nmake.Name, - ExtraData=3DContainerFile) - else: - if ToolList[0] in gNmakeFlagName2ToolCode: - Tool =3D gNmakeFlagName2ToolCode[ToolList[0]] - else: - Tool =3D ToolList[0] - BuildOption =3D BuildOptionClass("MSFT", "*_*_*_%s_FLA= GS" % Tool, Nmake.Value) - BuildOption.SupArchList =3D Nmake.SupArchList - self.Module.BuildOptions.append(BuildOption) - - ## GenPcds - # - # Gen Pcds of Inf - # .[|] - # - # @param ContainerFile: The Dec file full path - # - def GenPcds(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_PCDS) - Pcds =3D {} - PcdToken =3D {} - - # - # Get all Guids - # - RecordSet1 =3D self.RecordSet[MODEL_PCD_FIXED_AT_BUILD] - RecordSet2 =3D self.RecordSet[MODEL_PCD_PATCHABLE_IN_MODULE] - RecordSet3 =3D self.RecordSet[MODEL_PCD_FEATURE_FLAG] - RecordSet4 =3D self.RecordSet[MODEL_PCD_DYNAMIC_EX] - RecordSet5 =3D self.RecordSet[MODEL_PCD_DYNAMIC] - - # - # Go through each arch - # - for Arch in self.SupArchList: - for Record in RecordSet1: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON: - if self.Module.Header[Arch].LibraryClass !=3D {}: - pass - (TokenGuidCName, TokenName, Value, Type) =3D GetPcdOfI= nf(Record[0], TAB_PCDS_FIXED_AT_BUILD, ContainerFile, Record[2]) - MergeArches(Pcds, (TokenGuidCName, TokenName, Value, T= ype), Arch) - PcdToken[Record[3]] =3D (TokenGuidCName, TokenName) - for Record in RecordSet2: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON: - (TokenGuidCName, TokenName, Value, Type) =3D GetPcdOfI= nf(Record[0], TAB_PCDS_PATCHABLE_IN_MODULE, ContainerFile, Record[2]) - MergeArches(Pcds, (TokenGuidCName, TokenName, Value, T= ype), Arch) - PcdToken[Record[3]] =3D (TokenGuidCName, TokenName) - for Record in RecordSet3: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON: - (TokenGuidCName, TokenName, Value, Type) =3D GetPcdOfI= nf(Record[0], TAB_PCDS_FEATURE_FLAG, ContainerFile, Record[2]) - MergeArches(Pcds, (TokenGuidCName, TokenName, Value, T= ype), Arch) - PcdToken[Record[3]] =3D (TokenGuidCName, TokenName) - for Record in RecordSet4: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON: - (TokenGuidCName, TokenName, Value, Type) =3D GetPcdOfI= nf(Record[0], TAB_PCDS_DYNAMIC_EX, ContainerFile, Record[2]) - MergeArches(Pcds, (TokenGuidCName, TokenName, Value, T= ype), Arch) - PcdToken[Record[3]] =3D (TokenGuidCName, TokenName) - for Record in RecordSet5: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON: - (TokenGuidCName, TokenName, Value, Type) =3D GetPcdOfI= nf(Record[0], "", ContainerFile, Record[2]) - MergeArches(Pcds, (TokenGuidCName, TokenName, Value, T= ype), Arch) - PcdToken[Record[3]] =3D (TokenGuidCName, TokenName) - # - # Update to database - # - if self.IsToDatabase: - for Key in PcdToken.keys(): - SqlCommand =3D """update %s set Value2 =3D '%s' where ID = =3D %s""" % (self.TblInf.Table, ".".join((PcdToken[Key][0], PcdToken[Key][1= ])), Key) - self.TblInf.Exec(SqlCommand) - - for Key in Pcds.keys(): - Pcd =3D PcdClass() - Pcd.CName =3D Key[1] - Pcd.TokenSpaceGuidCName =3D Key[0] - Pcd.DefaultValue =3D Key[2] - Pcd.ItemType =3D Key[3] - Pcd.SupArchList =3D Pcds[Key] - self.Module.PcdCodes.append(Pcd) - - ## GenSources - # - # Gen Sources of Inf - # [|[|[|[|]]]] - # - # @param ContainerFile: The Dec file full path - # - def GenSources(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_SOURCES) - Sources =3D {} - - # - # Get all Nmakes - # - RecordSet =3D self.RecordSet[MODEL_EFI_SOURCE_FILE] - - # - # Go through each arch - # - for Arch in self.SupArchList: - for Record in RecordSet: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON: - (Filename, Family, TagName, ToolCode, Pcd) =3D GetSour= ce(Record[0], ContainerFile, self.Identification.FileRelativePath, Record[2= ]) - MergeArches(Sources, (Filename, Family, TagName, ToolC= ode, Pcd), Arch) - if self.IsToDatabase: - SqlCommand =3D """update %s set Value1 =3D '%s', V= alue2 =3D '%s', Value3 =3D '%s', Value4 =3D '%s', Value5 =3D '%s' - where ID =3D %s""" % (self.TblInf.= Table, ConvertToSqlString2(Filename), ConvertToSqlString2(Family), ConvertT= oSqlString2(TagName), ConvertToSqlString2(ToolCode), ConvertToSqlString2(Pc= d), Record[3]) - self.TblInf.Exec(SqlCommand) - - for Key in Sources.keys(): - Source =3D ModuleSourceFileClass(Key[0], Key[2], Key[3], Key[1= ], Key[4], Sources[Key]) - self.Module.Sources.append(Source) - - ## GenUserExtensions - # - # Gen UserExtensions of Inf - # - def GenUserExtensions(self, ContainerFile): -# # -# # UserExtensions -# # -# if self.UserExtensions !=3D '': -# UserExtension =3D UserExtensionsClass() -# Lines =3D self.UserExtensions.splitlines() -# List =3D GetSplitValueList(Lines[0], DataType.TAB_SPLIT, 2) -# if len(List) !=3D 3: -# RaiseParserError(Lines[0], 'UserExtensions', File, "UserE= xtensions.UserId.'Identifier'") -# else: -# UserExtension.UserID =3D List[1] -# UserExtension.Identifier =3D List[2][0:-1].replace("'", '= ').replace('\"', '') -# for Line in Lines[1:]: -# UserExtension.Content =3D UserExtension.Content + Cle= anString(Line) + '\n' -# self.Module.UserExtensions.append(UserExtension) - pass - - ## GenDepexes - # - # Gen Depex of Inf - # - # @param ContainerFile: The Inf file full path - # - def GenDepexes(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_DEPEX) - Depex =3D {} - # - # Get all Depexes - # - RecordSet =3D self.RecordSet[MODEL_EFI_DEPEX] - - # - # Go through each arch - # - for Arch in self.SupArchList: - Line =3D '' - for Record in RecordSet: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON: - Line =3D Line + Record[0] + ' ' - if Line !=3D '': - MergeArches(Depex, Line, Arch) - - for Key in Depex.keys(): - Dep =3D ModuleDepexClass() - Dep.Depex =3D Key - Dep.SupArchList =3D Depex[Key] - self.Module.Depex.append(Dep) - - ## GenBinaries - # - # Gen Binary of Inf - # ||[|.] - # - # @param ContainerFile: The Dec file full path - # - def GenBinaries(self, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % TAB_BINARIES) - Binaries =3D {} - - # - # Get all Guids - # - RecordSet =3D self.RecordSet[MODEL_EFI_BINARY_FILE] - - # - # Go through each arch - # - for Arch in self.SupArchList: - for Record in RecordSet: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON: - (FileType, Filename, Target, Pcd) =3D GetBinary(Record= [0], ContainerFile, self.Identification.FileRelativePath, Record[2]) - MergeArches(Binaries, (FileType, Filename, Target, Pcd= ), Arch) - if self.IsToDatabase: - SqlCommand =3D """update %s set Value1 =3D '%s', V= alue2 =3D '%s', Value3 =3D '%s', Value4 =3D '%s' - where ID =3D %s""" % (self.TblInf.= Table, ConvertToSqlString2(FileType), ConvertToSqlString2(Filename), Conver= tToSqlString2(Target), ConvertToSqlString2(Pcd), Record[3]) - self.TblInf.Exec(SqlCommand) - - for Key in Binaries.keys(): - Binary =3D ModuleBinaryFileClass(NormPath(Key[1]), Key[0], Key= [2], Key[3], Binaries[Key]) - self.Module.Binaries.append(Binary) - - ## GenGuids - # - # Gen Guids of Inf - # =3D - # - # @param ContainerFile: The Inf file full path - # - def GenGuidProtocolPpis(self, Type, ContainerFile): - EdkLogger.debug(2, "Generate %s ..." % Type) - Lists =3D {} - # - # Get all Items - # - RecordSet =3D self.RecordSet[Section[Type.upper()]] - - # - # Go through each arch - # - for Arch in self.SupArchList: - for Record in RecordSet: - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_COMM= ON: - (Name, Value) =3D GetGuidsProtocolsPpisOfInf(Record[0]= , Type, ContainerFile, Record[2]) - MergeArches(Lists, (Name, Value), Arch) - if self.IsToDatabase: - SqlCommand =3D """update %s set Value1 =3D '%s', V= alue2 =3D '%s' - where ID =3D %s""" % (self.TblInf.= Table, ConvertToSqlString2(Name), ConvertToSqlString2(Value), Record[3]) - self.TblInf.Exec(SqlCommand) - - ListMember =3D None - if Type =3D=3D TAB_GUIDS: - ListMember =3D self.Module.Guids - elif Type =3D=3D TAB_PROTOCOLS: - ListMember =3D self.Module.Protocols - elif Type =3D=3D TAB_PPIS: - ListMember =3D self.Module.Ppis - - for Key in Lists.keys(): - ListClass =3D GuidProtocolPpiCommonClass() - ListClass.CName =3D Key[0] - ListClass.SupArchList =3D Lists[Key] - ListClass.FeatureFlag =3D Key[1] - ListMember.append(ListClass) - -## -# -# This acts like the main() function for the script, unless it is 'import'= ed into another -# script. -# -if __name__ =3D=3D '__main__': - EdkLogger.Initialize() - EdkLogger.SetLevel(EdkLogger.DEBUG_0) - - W =3D os.getenv('WORKSPACE') - F =3D os.path.join(W, 'MdeModulePkg/Application/HelloWorld/HelloWorld.= inf') - - Db =3D Database.Database('Inf.db') - Db.InitDatabase() - - P =3D Inf(os.path.normpath(F), True, True, W, Db) - P.ShowModule() - - Db.Close() --=20 2.16.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel