From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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 331FE2267F11B for ; Mon, 9 Apr 2018 14:11:42 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Apr 2018 14:11:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,427,1517904000"; d="scan'208";a="44803395" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga004.fm.intel.com with ESMTP; 09 Apr 2018 14:11:41 -0700 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 9 Apr 2018 14:11:41 -0700 Received: from fmsmsx103.amr.corp.intel.com ([169.254.2.89]) by FMSMSX154.amr.corp.intel.com ([169.254.6.109]) with mapi id 14.03.0319.002; Mon, 9 Apr 2018 14:11:40 -0700 From: "Carsey, Jaben" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" CC: "Gao, Liming" Thread-Topic: [PATCH v1 2/2] BaseTools: Remove unneeded files Thread-Index: AQHTzxHq+IxeyiGDZE68KrIG7axauKP479Yg Date: Mon, 9 Apr 2018 21:11:40 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNWI2Y2U1YjYtZTI5NS00ZjVmLTlkNjItZjBjOTNlYjdlZTI0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6ImpOdTQzbDJTZHFCNHlHa1VwRTVmRTU5OFhRN0VxOWtiUTJcL21FRFJ3cFZFPSJ9 x-ctpclassification: CTP_NT x-originating-ip: [10.1.200.107] MIME-Version: 1.0 Subject: Re: [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: , X-List-Received-Date: Mon, 09 Apr 2018 21:11:43 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 1) Yes. 2) I didn't do this since EdkIIWorkspaceBuild is already pending removal in= a separate patch from Feng. Shall I send out a v2 with workspace fixed or with both?j I didn't want to= conflict with Feng's patch. -Jaben > -----Original Message----- > From: Zhu, Yonghong > Sent: Sunday, April 08, 2018 1:17 AM > To: Carsey, Jaben ; edk2-devel@lists.01.org > Cc: Gao, Liming ; Zhu, Yonghong > > Subject: RE: [PATCH v1 2/2] BaseTools: Remove unneeded files > Importance: High >=20 > Hi Jaben, >=20 > 1. the BaseTools/Source/Python/Makefile also need remove those .py files, > otherwise it would cause freeze binary failure. > 2. EdkIIWorkspaceBuild.py use some function in those .py files, but in fa= ct > the EdkIIWorkspaceBuild.py also can be removed, so how about in your V2 > patch also remove this file ? >=20 > Best Regards, > Zhu Yonghong >=20 >=20 > -----Original Message----- > From: Carsey, Jaben > Sent: Wednesday, April 04, 2018 11:02 PM > To: edk2-devel@lists.01.org > Cc: Gao, Liming ; Zhu, Yonghong > > Subject: [PATCH v1 2/2] BaseTools: Remove unneeded files >=20 > 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 >=20 > 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(-) >=20 > diff --git a/BaseTools/Source/Python/Common/DecClassObject.py > b/BaseTools/Source/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 > BSD License > -# which accompanies this distribution. The full text of the license may= be > found at > -# http://opensource.org/licenses/bsd-license.php > -# > -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > -# > - > -## > -# 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 > -# > -# @param Filename: Input value for Filename of Dec file, defaul= t 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 automat= ically > -# False is not to transfer to PackageObject au= tomatically > -# default is False > -# @param WorkspaceDir: Input value for current workspace directory, > default is None > -# > -# @var Identification: To store value for Identification, it is a s= tructure as > Identification > -# @var Defines: To store value for Defines, it is a structur= e as > DecDefines > -# @var UserExtensions: To store value for UserExtensions > -# @var Package: To store value for Package, it is a structur= e as > PackageClass > -# @var WorkspaceDir: To store value for WorkspaceDir > -# @var Contents: To store value for Contents, it is a structu= re as > DecContents > -# @var KeyList: To store value for KeyList, a list for all K= eys 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_NULL, > TAB_PCDS_FEATURE_FLAG_NULL, \ > - TAB_PCDS_DYNAMIC_NULL, TAB_PCDS_DYNAMIC_EX_NULL, > TAB_DEC_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 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.FileN= ame) =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, > IncludeFiles =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_STAR= T, 1)[0] > - IsFindBlockComment =3D True > - if Line.find(TAB_COMMENT_EDK_END) > -1: > - Line =3D ReservedLine + GetSplitList(Line, TAB_COMMENT_E= DK_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_SECTION_END): > - # > - # Insert items data of previous section > - # > - Model =3D Section[CurrentSection.upper()] > - InsertSectionItemsIntoDatabase(self.TblDec, self.FileID,= Filename, > Model, CurrentSection, SectionItemList, ArchList, ThirdList, IfDefList, > self.RecordSet) > - > - # > - # Parse the new section > - # > - SectionItemList =3D [] > - ArchList =3D [] > - ThirdList =3D [] > - > - CurrentSection =3D '' > - LineList =3D GetSplitValueList(Line[len(TAB_SECTION_STAR= T):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, "Dif= ferent section > names '%s' and '%s' are found in one section definition, this is not allo= wed." > % (CurrentSection, ItemList[0]), File=3DFilename, Line=3DLineNo, > 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() n= ot in > ARCH_LIST_FULL: > - EdkLogger.error("Parser", PARSER_ERROR, "Inv= alid Arch > definition '%s' found" % ItemList[1], File=3DFilename, Line=3DLineNo, > 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= =3DFilename, > 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, Filenam= e, > Model, CurrentSection, SectionItemList, ArchList, ThirdList, IfDefList, > self.RecordSet) > - > - # > - # Replace all DEFINE macros with its actual values > - # > - ParseDefineMacro2(self.TblDec, self.RecordSet, > GlobalData.gGlobalDefines) > - > - ## Transfer to Package Object > - # > - # 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 > - # > - 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, '<= Key> =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, > ConvertToSqlString2(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_DEFINES_PACKAGE_NAME, Arch, self.FileID)[0] > - PackageHeader.Guid =3D QueryDefinesItem(self.TblDec, > TAB_DEC_DEFINES_PACKAGE_GUID, Arch, self.FileID)[0] > - PackageHeader.Version =3D QueryDefinesItem(self.TblDec, > TAB_DEC_DEFINES_PACKAGE_VERSION, Arch, self.FileID)[0] > - PackageHeader.FileName =3D self.Identification.FileName > - PackageHeader.FullPath =3D self.Identification.FileFullPath > - PackageHeader.DecSpecification =3D QueryDefinesItem(self.Tbl= Dec, > TAB_DEC_DEFINES_DEC_SPECIFICATION, Arch, self.FileID)[0] > - > - self.Package.Header[Arch] =3D PackageHeader > - > - ## GenIncludes > - # > - # Gen Includes of Dec > - # > - # > - # @param ContainerFile: The Dec file full path > - # > - 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_CO= MMON: > - 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 > - # > - 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_CO= MMON: > - (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',= Value2 =3D '%s' > - where ID =3D %s""" % (self.TblDe= c.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 > - # > - 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_CO= MMON: > - List =3D GetSplitValueList(Record[0], DataType.TAB_V= ALUE_SPLIT) > - if len(List) !=3D 2: > - RaiseParserError(Record[0], 'LibraryClasses', Co= ntainerFile, > '|', Record[2]) > - else: > - CheckFileExist(self.Identification.FileRelativeP= ath, List[1], > ContainerFile, 'LibraryClasses', Record[0]) > - MergeArches(LibraryClasses, (List[0], List[1]), Arch= ) > - if self.IsToDatabase: > - SqlCommand =3D """update %s set Value1 =3D '%s',= Value2 =3D '%s', > Value3 =3D '%s' > - where ID =3D %s""" % (self.TblDe= c.Table, > ConvertToSqlString2(List[0]), ConvertToSqlString2(List[1]), > SUP_MODULE_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 > - # > - 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_CO= MMON: > - (TokenGuidCName, TokenName, Value, DatumType, Token, > Type) =3D GetPcdOfDec(Record[0], TAB_PCDS_FIXED_AT_BUILD, > ContainerFile, Record[2]) > - MergeArches(Pcds, (TokenGuidCName, TokenName, Value, > DatumType, 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_CO= MMON: > - (TokenGuidCName, TokenName, Value, DatumType, Token, > Type) =3D GetPcdOfDec(Record[0], TAB_PCDS_PATCHABLE_IN_MODULE, > ContainerFile, Record[2]) > - MergeArches(Pcds, (TokenGuidCName, TokenName, Value, > DatumType, 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_CO= MMON: > - (TokenGuidCName, TokenName, Value, DatumType, Token, > Type) =3D GetPcdOfDec(Record[0], TAB_PCDS_FEATURE_FLAG, ContainerFile, > Record[2]) > - MergeArches(Pcds, (TokenGuidCName, TokenName, Value, > DatumType, 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_CO= MMON: > - (TokenGuidCName, TokenName, Value, DatumType, Token, > Type) =3D GetPcdOfDec(Record[0], TAB_PCDS_DYNAMIC_EX, ContainerFile, > Record[2]) > - MergeArches(Pcds, (TokenGuidCName, TokenName, Value, > DatumType, 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_CO= MMON: > - (TokenGuidCName, TokenName, Value, DatumType, Token, > Type) =3D GetPcdOfDec(Record[0], TAB_PCDS_DYNAMIC, ContainerFile, > Record[2]) > - MergeArches(Pcds, (TokenGuidCName, TokenName, Value, > DatumType, 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].DecSpecificatio= n > - 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.SupModuleList, Item.SupArchList > - print '\nPcds =3D', M.PcdDeclarations > - for Item in M.PcdDeclarations: > - print 'CName=3D', Item.CName, 'TokenSpaceGuidCName=3D', > Item.TokenSpaceGuidCName, 'DefaultValue=3D', Item.DefaultValue, > 'ItemType=3D', Item.ItemType, 'Token=3D', Item.Token, 'DatumType=3D', > Item.DatumType, Item.SupArchList > - > -## > -# > -# This acts like the main() function for the script, unless it is 'impor= t'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/Source/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 > BSD License > -# which accompanies this distribution. The full text of the license may= be > found at > -# http://opensource.org/licenses/bsd-license.php > -# > -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > -# > - > -## > -# 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_EX_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_DEFAULT, > - 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, defau= lt 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 automati= cally > -# False is not to transfer to ModuleObject aut= omatically > -# default is False > -# @param WorkspaceDir: Input value for current workspace directory, > default is None > -# > -# @var _NullClassIndex: To store value for _NullClassIndex, default = is 0 > -# @var Identification: To store value for Identification, it is a s= tructure as > Identification > -# @var Defines: To store value for Defines, it is a structur= e as > DscDefines > -# @var Contents: To store value for Contents, it is a structu= re as > DscContents > -# @var UserExtensions: To store value for UserExtensions > -# @var Platform: To store value for Platform, it is a structu= re as > PlatformClass > -# @var WorkspaceDir: To store value for WorkspaceDir > -# @var KeyList: To store value for KeyList, a list for all K= eys 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_OPTIONS, 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, > ContainerFile) > - > self.GenDynamicDefaultPcds(DataType.TAB_PCDS_DYNAMIC_DEFAULT, > ContainerFile) > - > self.GenDynamicDefaultPcds(DataType.TAB_PCDS_DYNAMIC_EX_DEFAULT, > ContainerFile) > - self.GenDynamicHiiPcds(DataType.TAB_PCDS_DYNAMIC_HII, > ContainerFile) > - self.GenDynamicHiiPcds(DataType.TAB_PCDS_DYNAMIC_EX_HII, > ContainerFile) > - self.GenDynamicVpdPcds(DataType.TAB_PCDS_DYNAMIC_VPD, > ContainerFile) > - self.GenDynamicVpdPcds(DataType.TAB_PCDS_DYNAMIC_EX_VPD, > ContainerFile) > - > - # > - # 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.PcdToken[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_META_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, '<= Key> =3D > ', Record[3]) > - ID, Value1, Value2, Arch =3D Record[0], ValueList[0], ValueL= ist[1], > Record[2] > - SqlCommand =3D """update %s set Value1 =3D '%s', Value2 =3D = '%s' > - where ID =3D %s""" % (self.TblDsc.Table, > ConvertToSqlString2(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_DSC_DEFINES_PLATFORM_VERSION, Arch, self.FileID)[0] > - PlatformHeader.FileName =3D self.Identification.FileName > - PlatformHeader.FullPath =3D self.Identification.FileFullPath > - PlatformHeader.DscSpecification =3D QueryDefinesItem(self.Tb= lDsc, > 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, > TAB_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(self.TblDsc, > TAB_DSC_DEFINES_OUTPUT_DIRECTORY, Arch, self.FileID)[0]) > - PlatformHeader.BuildNumber =3D QueryDefinesItem(self.TblDsc, > TAB_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.TblDs= c, > TAB_DSC_DEFINES_BS_BASE_ADDRESS, Arch, self.FileID)[0] > - PlatformHeader.RtBaseAddress =3D QueryDefinesItem(self.TblDs= c, > 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_DSC_DEFINES_FLASH_DEFINITION, Arch, self.FileID)[0]) > - self.Platform.FlashDefinitionFile =3D Fdf > - Prebuild =3D BuildScriptClass() > - Prebuild.FilePath =3D NormPath(QueryDefinesItem(self.TblDsc, > TAB_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_OPTION, -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, Inclu= deFile[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(New= Item, Filename, > -1) > - MergeArches(BuildOptions, (Family, ToolChain, Fl= ag), Arch) > - > - for Record in RecordSet: > - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_CO= MMON.upper(): > - (Family, ToolChain, Flag) =3D GetBuildOption(Record[= 0], > ContainerFile, Record[2]) > - MergeArches(BuildOptions, (Family, ToolChain, Flag),= Arch) > - # > - # Update to Database > - # > - if self.IsToDatabase: > - SqlCommand =3D """update %s set Value1 =3D '%s',= Value2 =3D '%s', > Value3 =3D '%s' > - where ID =3D %s""" % (self.TblDs= c.Table, > ConvertToSqlString2(Family), ConvertToSqlString2(ToolChain), > ConvertToSqlString2(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(BuildOptio= n) > - > - ## 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, Inclu= deFile[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, Filena= me, > '|') > - 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_CO= MMON.upper(): > - List =3D GetSplitValueList(Record[0]) > - if len(List) !=3D 2: > - RaiseParserError(Record[0], TAB_SKUIDS, Containe= rFile, > '|') > - else: > - self.Platform.SkuInfos.SkuInfoList[List[1]] =3D = List[0] > - # > - # Update to Database > - # > - if self.IsToDatabase: > - SqlCommand =3D """update %s set Value1 =3D '= %s', Value2 =3D '%s' > - where ID =3D %s""" % (self.T= blDsc.Table, > ConvertToSqlString2(List[0]), ConvertToSqlString2(List[1]), Record[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, Inclu= deFile[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_CO= MMON.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, Inclu= deFile[0], > ContainerFile, TAB_LIBRARY_CLASSES, '', IncludeFile[2]) > - for NewItem in open(Filename, 'r').readlines(): > - if CleanString(NewItem) =3D=3D '': > - continue > - MergeArches(LibraryClasses, GetLibraryClass([New= Item, > IncludeFile[4]], Filename, self.WorkspaceDir, -1), Arch) > - > - for Record in RecordSet: > - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_CO= MMON.upper(): > - (LibClassName, LibClassIns, SupModelList) =3D > GetLibraryClass([Record[0], Record[4]], ContainerFile, self.WorkspaceDir, > Record[2]) > - MergeArches(LibraryClasses, (LibClassName, LibClassI= ns, > SupModelList), Arch) > - # > - # Update to Database > - # > - if self.IsToDatabase: > - SqlCommand =3D """update %s set Value1 =3D '%s',= Value2 =3D '%s', > Value3 =3D '%s' > - where ID =3D %s""" % (self.TblDs= c.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 > .|[|| mDatumSize>] > - # > - # @param Type: The type of Pcd > - # @param ContainerFile: The file which describes the pcd, used for = error > 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, Inclu= deFile[0], > ContainerFile, Type, '', IncludeFile[2]) > - for NewItem in open(Filename, 'r').readlines(): > - if CleanString(NewItem) =3D=3D '': > - continue > - (TokenName, TokenGuidCName, Value, DatumType, > MaxDatumSize, Type) =3D GetPcd(NewItem, Type, Filename, -1) > - MergeArches(Pcds, (TokenName, TokenGuidCName, Va= lue, > DatumType, MaxDatumSize, Type), Arch) > - self.PcdToken[Record[3]] =3D (TokenGuidCName, To= kenName) > - > - for Record in RecordSet: > - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_CO= MMON.upper(): > - (TokenName, TokenGuidCName, Value, DatumType, > MaxDatumSize, Type) =3D GetPcd(Record[0], Type, ContainerFile, Record[2]) > - MergeArches(Pcds, (TokenName, TokenGuidCName, Value, > DatumType, MaxDatumSize, Type), Arch) > - self.PcdToken[Record[3]] =3D (TokenGuidCName, TokenN= ame) > - > - for Key in Pcds: > - Pcd =3D PcdClass(Key[0], '', Key[1], Key[3], Key[4], Key[2],= Key[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 = error > 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, Inclu= deFile[0], > ContainerFile, Type, '', IncludeFile[2]) > - for NewItem in open(Filename, 'r').readlines(): > - if CleanString(NewItem) =3D=3D '': > - continue > - (TokenName, TokenGuidCName, Value, Type) =3D > GetFeatureFlagPcd(NewItem, Type, Filename, -1) > - MergeArches(Pcds, (TokenName, TokenGuidCName, Va= lue, > Type), Arch) > - self.PcdToken[Record[3]] =3D (TokenGuidCName, To= kenName) > - > - for Record in RecordSet: > - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_CO= MMON.upper(): > - (TokenName, TokenGuidCName, Value, Type) =3D > GetFeatureFlagPcd(Record[0], Type, ContainerFile, Record[2]) > - MergeArches(Pcds, (TokenName, TokenGuidCName, Value, > Type), Arch) > - self.PcdToken[Record[3]] =3D (TokenGuidCName, TokenN= ame) > - > - 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 > .|[|[|< > MaxDatumSize>]] > - # > - # @param Type: The type of Pcd > - # @param ContainerFile: The file which describes the pcd, used for = error > 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, Inclu= deFile[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 GetDynamicDefaultPc= d(NewItem, > Type, Filename, -1) > - MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, Inclu= deFile[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_CO= MMON.upper(): > - (K1, K2, K3, K4, K5, K6) =3D GetDynamicDefaultPcd(Re= cord[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.Platform.SkuInfos.SkuInfoList, '', '', '', '', '', Key[2]) > - if Status =3D=3D False: > - ErrorMsg =3D "The SKUID '%s' used in section '%s' is not= defined in > section [SkuIds]" % (SkuInfoList, Type) > - EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMs= g, > ContainerFile, RaiseError=3DEdkLogger.IsRaiseError) > - Pcd =3D PcdClass(Key[0], '', Key[1], Key[3], Key[4], Key[2],= Key[5], [], > SkuInfoList, []) > - Pcd.SupArchList =3D Pcds[Key] > - self.Platform.DynamicPcdBuildDefinitions.append(Pcd) > - > - ## Gen DynamicHiiPcds > - # > - # Gen DynamicHiiPcds of Dsc as > .|| me>|[|[|]] > - # > - # @param Type: The type of Pcd > - # @param ContainerFile: The file which describes the pcd, used for = error > 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, Inclu= deFile[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 GetDynamicH= iiPcd(NewItem, > Type, Filename, -1) > - MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, K7, K= 8, > 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_CO= MMON.upper(): > - (K1, K2, K3, K4, K5, K6, K7, K8) =3D GetDynamicHiiPc= d(Record[0], > Type, ContainerFile, Record[2]) > - MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, K7, K8, R= ecord[4]), > Arch) > - self.PcdToken[Record[3]] =3D (K2, K1) > - > - for Key in Pcds: > - (Status, SkuInfoList) =3D self.GenSkuInfoList(Key[8], > self.Platform.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= defined in > section [SkuIds]" % (SkuInfoList, Type) > - EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMs= g, > 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 > .|[| atumSize>] > - # > - # @param Type: The type of Pcd > - # @param ContainerFile: The file which describes the pcd, used for = error > 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, Inclu= deFile[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(NewIte= m, Type, > Filename, -1) > - MergeArches(Pcds, (K1, K2, K3, K4, K5, IncludeFi= le[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_CO= MMON.upper(): > - (K1, K2, K3, K4, K5) =3D GetDynamicVpdPcd(Record[0],= Type, > ContainerFile, Record[2]) > - MergeArches(Pcds, (K1, K2, K3, K4, K5, Record[4]), A= rch) > - self.PcdToken[Record[3]] =3D (K2, K1) > - > - for Key in Pcds: > - (Status, SkuInfoList) =3D self.GenSkuInfoList(Key[5], > self.Platform.SkuInfos.SkuInfoList, '', '', '', '', Key[2], '') > - if Status =3D=3D False: > - ErrorMsg =3D "The SKUID '%s' used in section '%s' is not= defined in > section [SkuIds]" % (SkuInfoList, Type) > - EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMs= g, > 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, us= ed > 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, Inclu= deFile[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_COMPONENTS, NewItems, TAB_COMMENT_SPLIT) > - for NewComponent in NewItems: > - MergeArches(Components, > self.GenComponent(NewComponent, Filename), Arch) > - > - for Record in RecordSet: > - if Record[1] =3D=3D Arch or Record[1] =3D=3D TAB_ARCH_CO= MMON.upper(): > - Lib, Bo, Pcd =3D [], [], [] > - > - SubLibSet =3D QueryDscItem(self.TblDsc, > MODEL_EFI_LIBRARY_CLASS, Record[3], self.FileID) > - for SubLib in SubLibSet: > - Lib.append(TAB_VALUE_SPLIT.join([SubLib[0], SubL= ib[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_FIXED_AT_BUILD, Record[3], self.FileID) > - SubPcdSet2 =3D QueryDscItem(self.TblDsc, > MODEL_PCD_PATCHABLE_IN_MODULE, Record[3], self.FileID) > - SubPcdSet3 =3D QueryDscItem(self.TblDsc, > MODEL_PCD_FEATURE_FLAG, Record[3], self.FileID) > - SubPcdSet4 =3D QueryDscItem(self.TblDsc, > MODEL_PCD_DYNAMIC_EX_DEFAULT, Record[3], self.FileID) > - SubPcdSet5 =3D QueryDscItem(self.TblDsc, > MODEL_PCD_DYNAMIC_DEFAULT, Record[3], self.FileID) > - for SubPcd in SubPcdSet1: > - Pcd.append([DataType.TAB_PCDS_FIXED_AT_BUILD, > SubPcd[0], SubPcd[3]]) > - for SubPcd in SubPcdSet2: > - Pcd.append([DataType.TAB_PCDS_PATCHABLE_IN_MODUL= E, > SubPcd[0], SubPcd[3]]) > - for SubPcd in SubPcdSet3: > - Pcd.append([DataType.TAB_PCDS_FEATURE_FLAG, SubP= cd[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, > ContainerFile), 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,= used > 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, 'compon= ent > name', Item[0], LineNo) > - CheckFileExist(self.WorkspaceDir, Component.FilePath, ContainerF= ile, > '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 insta= nce of > component ', Lib, LineNo) > - CheckFileExist(self.WorkspaceDir, LibFile, ContainerFile, 'l= ibrary > instance of component', Lib, LineNo) > - > Component.LibraryClasses.LibraryList.append(PlatformLibraryClass(LibName, > LibFile)) > - for BuildOption in BuildOptions: > - Key =3D GetBuildOption(BuildOption, ContainerFile) > - > Component.ModuleSaBuildOption.BuildOptionList.append(BuildOptionClass( > 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_SP= LIT) > - 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= , > '.|[| e>]') > - > - CheckPcdTokenInfo(List[0], 'Components', ContainerFile) > - TokenInfo =3D GetSplitValueList(List[0], DataType.TAB_SP= LIT) > - 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 > DataType.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_SP= LIT) > - 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'', > VariableGuid=3D'', VariableOffset=3D'', HiiDefaultValue=3D'', VpdOffset= =3D'', > DefaultValue=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, Vari= ableGuid, > 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' foun= d > in section %s" % (LineValue, SectionName)) > - SectionModel =3D Section[SectionName.upper()] > - IncludeFile =3D > CleanString(LineValue[LineValue.upper().find(DataType.TAB_INCLUDE.uppe > r() + ' ') + len(DataType.TAB_INCLUDE + ' ') : ]) > - Table.Insert(Model, IncludeFile, '', '', Arch, SectionModel, Fil= eID, > 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, > SectionName, 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.T= A > B_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, F= ilename, > 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, '', Start= Line) > - self.TblDsc.Insert(Model, Defines[0], Defines[1], '', Arch, -1, = FileID, > 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' %= Filename > - EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, > Filename, 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(PreviousIf)) > - > - # > - # !ifdef and !ifndef > - # > - if PreviousIf[2] in > (MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF, > MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF): > - Value1 =3D PreviousIf[0] > - Model =3D PreviousIf[2] > - self.TblDsc.Insert(Model, Value1, Value2, Value3, ArchLi= st, > BelongsToItem, self.FileID, PreviousIf[1], StartColumn, EndLine, EndColum= n, > Enabled) > - # > - # !if and !elseif > - # > - elif PreviousIf[2] in > (MODEL_META_DATA_CONDITIONAL_STATEMENT_IF, 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, ArchLi= st, > BelongsToItem, self.FileID, PreviousIf[1], StartColumn, EndLine, EndColum= n, > Enabled) > - # > - # !else > - # > - elif PreviousIf[2] in > (MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE, Model): > - Value1 =3D PreviousIf[0].strip() > - Model =3D PreviousIf[2] > - self.TblDsc.Insert(Model, Value1, Value2, Value3, ArchLi= st, > 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.FileN= ame) =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, > IncludeFiles =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_STAR= T, 1)[0] > - IsFindBlockComment =3D True > - if Line.find(TAB_COMMENT_EDK_END) > -1: > - Line =3D ReservedLine + GetSplitList(Line, TAB_COMMENT_E= DK_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_SECTION_END): > - # > - # Insert items data of previous section > - # > - self.InsertSectionItemsIntoDatabase(self.FileID, Filenam= e, > CurrentSection, SectionItemList, ArchList, ThirdList, IfDefList) > - # > - # Parse the new section > - # > - SectionItemList =3D [] > - ArchList =3D [] > - ThirdList =3D [] > - > - CurrentSection =3D '' > - LineList =3D GetSplitValueList(Line[len(TAB_SECTION_STAR= T):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, "Dif= ferent section > names '%s' and '%s' are found in one section definition, this is not allo= wed." > % (CurrentSection, ItemList[0]), File=3DFilename, Line=3DLineNo, > 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() n= ot in > ARCH_LIST_FULL: > - EdkLogger.error("Parser", PARSER_ERROR, "Inv= alid Arch > definition '%s' found" % ItemList[1], File=3DFilename, Line=3DLineNo, > 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= =3DFilename, > 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, > CurrentSection, SectionItemList, ArchList, ThirdList, IfDefList) > - > - # > - # Parse conditional statements > - # > - self.ParseConditionalStatement() > - > - # > - # Replace all DEFINE macros with its actual values > - # > - #ParseDefineMacro2(self.TblDsc, self.RecordSet, > GlobalData.gGlobalDefines) > - 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.StartLi= ne > - and A.Arch =3D B.Arch > - and A.BelongsToItem =3D B.B= elongsToItem > - and A.BelongsToFile =3D B.B= elongsToFile) """ % \ > - (self.TblDsc.Table, \ > - MODEL_META_DATA_CONDITIONAL_STATEMENT_IF, > MODEL_META_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 StartLi= ne >=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.Belon= gsToItem > - and A.BelongsToFile =3D B.Belon= gsToFile)""" % \ > - (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 StartLi= ne >=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_META_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= StartLine >=3D > %s and EndLine <=3D %s""" % (self.TblDsc.Table, Record[4], Record[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 Sta= rtLine >=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 fo= r > LibraryClass and SkuId for Dynamic Pcds > - # @param IfDefList: A list of all conditional statements > - # > - def InsertSectionItemsIntoDatabase(self, FileID, Filename, > CurrentSection, 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], Sectio= nItem[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):].stri= p(), > 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):].stri= p(), > StartLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF)) > - continue > - > - # > - # Parse '!endif' > - # > - if LineValue.upper().find(TAB_END_IF.upper()) > -1: > - self.InsertConditionalStatement(Filename, FileID, Mo= del, > IfDefList, StartLine, Arch) > - continue > - # > - # Parse '!if' > - # > - if LineValue.upper().find(TAB_IF.upper()) > -1: > - IfDefList.append((LineValue[len(TAB_IF):].strip(), S= tartLine, > MODEL_META_DATA_CONDITIONAL_STATEMENT_IF)) > - continue > - > - # > - # Parse '!elseif' > - # > - if LineValue.upper().find(TAB_ELSE_IF.upper()) > -1: > - self.InsertConditionalStatement(Filename, FileID, Mo= del, > 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, Mo= del, > IfDefList, StartLine, Arch) > - IfDefList.append((Key, StartLine, > MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE)) > - continue > - > - # > - # Parse !include statement first > - # > - if LineValue.upper().find(DataType.TAB_INCLUDE.upper() += ' ') > -1: > - self.ParseInclude(LineValue, StartLine, self.TblDsc,= FileID, > 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, = FileID, > Filename, CurrentSection, MODEL_META_DATA_DEFINE, Arch) > - continue > - > - # > - # At last parse other sections > - # > - if CurrentSection =3D=3D TAB_LIBRARY_CLASSES or CurrentS= ection in > TAB_PCD_DYNAMIC_TYPE_LIST or CurrentSection in > TAB_PCD_DYNAMIC_EX_TYPE_LIST: > - ID =3D self.TblDsc.Insert(Model, LineValue, Third, '= ', Arch, -1, FileID, > StartLine, -1, StartLine, -1, 0) > - #Records.append([LineValue, Arch, StartLine, ID, Thi= rd]) > - continue > - elif CurrentSection !=3D TAB_COMPONENTS: > - ID =3D self.TblDsc.Insert(Model, LineValue, '', '', = Arch, -1, FileID, > StartLine, -1, StartLine, -1, 0) > - #Records.append([LineValue, Arch, StartLine, ID, Thi= rd]) > - 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 ..." % Comp= onent) > - DscItmeID =3D > self.TblDsc.Insert(MODEL_META_DATA_COMPONENT, 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, LibN= ame, LibIns, > '', Arch, DscItmeID, FileID, StartLine, -1, StartLine, -1, 0) > - for Item in Component[2]: > - self.TblDsc.Insert(MODEL_META_DATA_BUILD_OPTION,= Item, > '', '', 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,= DscItmeID, 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[= arch]." + 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].DscSpecificatio= n > - 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.Inclu= deFiles > - for Item in M.BuildOptions.BuildOptionList: > - print '\t', 'ToolChainFamily =3D', Item.ToolChainFamily, 'To= olChain =3D', > Item.ToolChain, 'Option =3D', Item.Option, 'Arch =3D', Item.SupArchList > - print '\nSkuIds =3D', M.SkuInfos.SkuInfoList, M.SkuInfos.Include= Files > - 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.IncludeFiles > - 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.TokenSpaceGui= dCName, > 'Value=3D', Item.DefaultValue, 'Token=3D', Item.Token, 'Type=3D', Item.It= emType, > '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.IncludeFiles > - for Item in M.Modules.ModuleList: > - print '\t', Item.FilePath, Item.ExecFilePath, Item.SupArchLi= st > - 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.ToolCha= in, > 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 'impor= t'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/Source/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 > BSD License > -# which accompanies this distribution. The full text of the license may= be > found at > -# http://opensource.org/licenses/bsd-license.php > -# > -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > -# > - > -## > -# Import Modules > -# > -from FdfParserLite import FdfParser > -from Table.TableFdf import TableFdf > -from CommonDataClass.DataClass import MODEL_FILE_FDF, MODEL_PCD, > MODEL_META_DATA_COMPONENT > -from String import NormPath > - > - > -## Fdf > -# > -# This class defined the structure used in Fdf object > -# > -# @param Filename: Input value for Ffilename of Fdf file, default i= s None > -# @param WorkspaceDir: Input value for current workspace directory, > default is None > -# > -class Fdf(object): > - def __init__(self, Filename =3D None, IsToDatabase =3D False, Worksp= aceDir =3D > None, Database =3D None): > - self.WorkspaceDir =3D WorkspaceDir > - self.IsToDatabase =3D IsToDatabase > - > - 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] > - > - > - ## Load Fdf file > - # > - # Load the file if it exists > - # > - # @param Filename: Input value for filename of Fdf file > - # > - def LoadFdfFile(self, Filename): > - 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, Belongs= ToFile, > 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, > BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, > Enabled) > - 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, > BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, > Enabled) > - > -## > -# > -# This acts like the main() function for the script, unless it is 'impor= t'ed into > another > -# script. > -# > -if __name__ =3D=3D '__main__': > - pass > diff --git a/BaseTools/Source/Python/Common/InfClassObject.py > b/BaseTools/Source/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 > BSD License > -# which accompanies this distribution. The full text of the license may= be > found at > -# http://opensource.org/licenses/bsd-license.php > -# > -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > -# > - > -## > -# 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_)?FLAGS(?:_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 : > "UefiSpecificationVersion", > - TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION : > "UefiSpecificationVersion", > - 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, defau= lt 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 automati= cally > -# False is not to transfer to ModuleObject aut= omatically > -# default is False > -# @param WorkspaceDir: Input value for current workspace directory, > default is None > -# > -# @var Identification: To store value for Identification, it is a s= tructure as > Identification > -# @var UserExtensions: To store value for UserExtensions > -# @var Module: To store value for Module, it is a structure= as > ModuleClass > -# @var WorkspaceDir: To store value for WorkspaceDir > -# @var KeyList: To store value for KeyList, a list for all K= eys 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, > TAB_GUIDS, > - TAB_PROTOCOLS, TAB_PPIS, TAB_LIBRARY_CLASSES, TAB_PACKAGES, > TAB_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] fo= rmat (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].DefinesDictionary, > - TAB_COMMENT_SPLIT, TAB_EQUAL_SPLIT,= False, 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.FileN= ame) =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, > IncludeFiles =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_STAR= T, 1)[0] > - IsFindBlockComment =3D True > - if Line.find(TAB_COMMENT_EDK_END) > -1: > - Line =3D ReservedLine + GetSplitList(Line, TAB_COMMENT_E= DK_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_SECTION_END): > - if Line[1:3] =3D=3D "--": > - continue > - Model =3D Section[CurrentSection.upper()] > - # > - # Insert items data of previous section > - # > - InsertSectionItemsIntoDatabase(self.TblInf, self.FileID,= Filename, > Model, CurrentSection, SectionItemList, ArchList, ThirdList, IfDefList, > self.RecordSet) > - # > - # Parse the new section > - # > - SectionItemList =3D [] > - ArchList =3D [] > - ThirdList =3D [] > - > - CurrentSection =3D '' > - LineList =3D GetSplitValueList(Line[len(TAB_SECTION_STAR= T):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, "Dif= ferent section > names '%s' and '%s' are found in one section definition, this is not allo= wed." > % (CurrentSection, ItemList[0]), File=3DFilename, Line=3DLineNo, > 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() n= ot in > ARCH_LIST_FULL: > - EdkLogger.error("Parser", PARSER_ERROR, "Inv= alid Arch > definition '%s' found" % ItemList[1], File=3DFilename, Line=3DLineNo, > 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= =3DFilename, > 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, Filenam= e, > Model, CurrentSection, SectionItemList, ArchList, ThirdList, IfDefList, > self.RecordSet) > - > - # > - # Replace all DEFINE macros with its actual values > - # > - ParseDefineMacro2(self.TblInf, self.RecordSet, > GlobalData.gGlobalDefines) > - > - ## 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].UefiSpecificationVersion > - print 'EdkReleaseVersion =3D', M.Header[Arch].EdkReleaseVers= ion > - 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].TianoEdkFlash= Map_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(Item.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.ModuleEntryPoint, Item.ModuleUnloadImage) > - for Item in self.Module.ExternLibraries: > - print 'Constructor =3D %s, Destructor =3D %s' % (Item.Constr= uctor, > 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.FeatureFlag, 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, '= Pcd=3D', > Source.FeatureFlag, 'Tag=3D', Source.TagName, 'ToolCode=3D', Source.ToolC= ode, > Source.SupArchList > - print '\nUserExtensions =3D', M.UserExtensions > - for UserExtension in M.UserExtensions: > - print UserExtension.UserID, UserExtension.Identifier, > UserExtension.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, 'SupArchList=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, '<= Key> =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, > ConvertToSqlString2(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.Fil= eID) > - > - 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_= SPLIT, 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(CleanStr= ing(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 Defin= es', 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 > CleanString(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, = 'SPEC =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= file %s > should be modified to use VERSION_STRING instead.' % > self.Identification.FileFullPath) > - ModuleHeader.Version =3D VersionNumber > - if len(VersionString) > 0: > - if len(VersionNumber) > 0: > - EdkLogger.warn(2001, 'INF file %s defines both > VERSION_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= Edk > component type [%s]" % ModuleHeader.ComponentType, ExtraData=3DFile, > RaiseError=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_CO= MMON: > - (Family, ToolChain, Flag) =3D GetBuildOption(Record[= 0], > ContainerFile, Record[2]) > - MergeArches(BuildOptions, (Family, ToolChain, Flag),= Arch) > - # > - # Update to Database > - # > - if self.IsToDatabase: > - SqlCommand =3D """update %s set Value1 =3D '%s',= Value2 =3D '%s', > Value3 =3D '%s' > - where ID =3D %s""" % (self.TblIn= f.Table, > ConvertToSqlString2(Family), ConvertToSqlString2(ToolChain), > ConvertToSqlString2(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_CO= MMON: > - 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_CO= MMON: > - 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_CO= MMON: > - (LibClassName, LibClassIns, Pcd, SupModelList) =3D > GetLibraryClassOfInf([Record[0], Record[4]], ContainerFile, > self.WorkspaceDir, Record[2]) > - MergeArches(LibraryClasses, (LibClassName, LibClassI= ns, Pcd, > SupModelList), Arch) > - # > - # Update to Database > - # > - if self.IsToDatabase: > - SqlCommand =3D """update %s set Value1 =3D '%s',= Value2 =3D '%s', > Value3 =3D '%s' > - where ID =3D %s""" % (self.TblIn= f.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_CO= MMON: > - (Package, Pcd) =3D GetPackage(Record[0], ContainerFi= le, > self.WorkspaceDir, Record[2]) > - MergeArches(Packages, (Package, Pcd), Arch) > - if self.IsToDatabase: > - SqlCommand =3D """update %s set Value1 =3D '%s',= Value2 =3D '%s' > - where ID =3D %s""" % (self.TblIn= f.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_CO= MMON: > - MergeArches(Nmakes, Record[0], Arch) > - > - for Key in Nmakes.keys(): > - List =3D GetSplitValueList(Key, DataType.TAB_EQUAL_SPLIT, Ma= xSplit=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 wit= h 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_F= LAGS" % > 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_CO= MMON: > - if self.Module.Header[Arch].LibraryClass !=3D {}: > - pass > - (TokenGuidCName, TokenName, Value, Type) =3D > GetPcdOfInf(Record[0], TAB_PCDS_FIXED_AT_BUILD, ContainerFile, > Record[2]) > - MergeArches(Pcds, (TokenGuidCName, TokenName, Value, > 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_CO= MMON: > - (TokenGuidCName, TokenName, Value, Type) =3D > GetPcdOfInf(Record[0], TAB_PCDS_PATCHABLE_IN_MODULE, ContainerFile, > Record[2]) > - MergeArches(Pcds, (TokenGuidCName, TokenName, Value, > 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_CO= MMON: > - (TokenGuidCName, TokenName, Value, Type) =3D > GetPcdOfInf(Record[0], TAB_PCDS_FEATURE_FLAG, ContainerFile, > Record[2]) > - MergeArches(Pcds, (TokenGuidCName, TokenName, Value, > 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_CO= MMON: > - (TokenGuidCName, TokenName, Value, Type) =3D > GetPcdOfInf(Record[0], TAB_PCDS_DYNAMIC_EX, ContainerFile, Record[2]) > - MergeArches(Pcds, (TokenGuidCName, TokenName, Value, > 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_CO= MMON: > - (TokenGuidCName, TokenName, Value, Type) =3D > GetPcdOfInf(Record[0], "", ContainerFile, Record[2]) > - MergeArches(Pcds, (TokenGuidCName, TokenName, Value, > 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.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_CO= MMON: > - (Filename, Family, TagName, ToolCode, Pcd) =3D > GetSource(Record[0], ContainerFile, self.Identification.FileRelativePath, > Record[2]) > - MergeArches(Sources, (Filename, Family, TagName, Too= lCode, > Pcd), Arch) > - if self.IsToDatabase: > - SqlCommand =3D """update %s set Value1 =3D '%s',= Value2 =3D '%s', > Value3 =3D '%s', Value4 =3D '%s', Value5 =3D '%s' > - where ID =3D %s""" % (self.TblIn= f.Table, > ConvertToSqlString2(Filename), ConvertToSqlString2(Family), > ConvertToSqlString2(TagName), ConvertToSqlString2(ToolCode), > ConvertToSqlString2(Pcd), 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, > "UserExtensions.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 + > CleanString(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_CO= MMON: > - 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_CO= MMON: > - (FileType, Filename, Target, Pcd) =3D GetBinary(Reco= rd[0], > ContainerFile, self.Identification.FileRelativePath, Record[2]) > - MergeArches(Binaries, (FileType, Filename, Target, P= cd), Arch) > - if self.IsToDatabase: > - SqlCommand =3D """update %s set Value1 =3D '%s',= Value2 =3D '%s', > Value3 =3D '%s', Value4 =3D '%s' > - where ID =3D %s""" % (self.TblIn= f.Table, > ConvertToSqlString2(FileType), ConvertToSqlString2(Filename), > ConvertToSqlString2(Target), ConvertToSqlString2(Pcd), Record[3]) > - self.TblInf.Exec(SqlCommand) > - > - for Key in Binaries.keys(): > - Binary =3D ModuleBinaryFileClass(NormPath(Key[1]), Key[0], K= ey[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_CO= MMON: > - (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',= Value2 =3D '%s' > - where ID =3D %s""" % (self.TblIn= f.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 'impor= t'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() > -- > 2.16.2.windows.1