From nobody Sat May 4 08:38:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1529887716876839.9091217733923; Sun, 24 Jun 2018 17:48:36 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E8CE82097411D; Sun, 24 Jun 2018 17:48:35 -0700 (PDT) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 9772F2097E27B for ; Sun, 24 Jun 2018 17:48:34 -0700 (PDT) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jun 2018 17:48:34 -0700 Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.129]) by orsmga005.jf.intel.com with ESMTP; 24 Jun 2018 17:48:33 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,268,1526367600"; d="scan'208";a="235252116" From: Yonghong Zhu To: edk2-devel@lists.01.org Date: Mon, 25 Jun 2018 08:48:17 +0800 Message-Id: <1529887697-24584-1-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 Subject: [edk2] [Patch] BaseTools: Fix two drivers include the same file issue X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yunhua Feng , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Yunhua Feng Two drivers include the same PCD file, the PCD value in the first driver is correct, but it in the second driver is incorrect. DSC: [Components] Testpkg/Testdriver1.inf { !include Test.txt } Testpkg/Testdriver2.inf { !include Test.txt } Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng Reviewed-by: Yonghong Zhu =20 --- BaseTools/Source/Python/Workspace/MetaDataTable.py | 27 +++++++++++++++++-= ---- .../Source/Python/Workspace/MetaFileParser.py | 4 ++-- BaseTools/Source/Python/Workspace/MetaFileTable.py | 14 ++++++----- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/MetaDataTable.py b/BaseTools= /Source/Python/Workspace/MetaDataTable.py index e37a10c..bd751ea 100644 --- a/BaseTools/Source/Python/Workspace/MetaDataTable.py +++ b/BaseTools/Source/Python/Workspace/MetaDataTable.py @@ -166,11 +166,12 @@ class TableFile(Table): Name VARCHAR NOT NULL, ExtName VARCHAR, Path VARCHAR, FullPath VARCHAR NOT NULL, Model INTEGER DEFAULT 0, - TimeStamp SINGLE NOT NULL + TimeStamp SINGLE NOT NULL, + FromItem REAL NOT NULL ''' def __init__(self, Cursor): Table.__init__(self, Cursor, 'File') =20 ## Insert table @@ -182,20 +183,21 @@ class TableFile(Table): # @param Path: Path of a File # @param FullPath: FullPath of a File # @param Model: Model of a File # @param TimeStamp: TimeStamp of a File # - def Insert(self, Name, ExtName, Path, FullPath, Model, TimeStamp): + def Insert(self, Name, ExtName, Path, FullPath, Model, TimeStamp, From= Item=3D0): (Name, ExtName, Path, FullPath) =3D ConvertToSqlString((Name, ExtN= ame, Path, FullPath)) return Table.Insert( self, Name, ExtName, Path, FullPath, Model, - TimeStamp + TimeStamp, + FromItem ) =20 ## InsertFile # # Insert one file to table @@ -203,11 +205,21 @@ class TableFile(Table): # @param FileFullPath: The full path of the file # @param Model: The model of the file # # @retval FileID: The ID after record is inserted # - def InsertFile(self, File, Model): + def InsertFile(self, File, Model, FromItem=3D''): + if FromItem: + return self.Insert( + File.Name, + File.Ext, + File.Dir, + File.Path, + Model, + File.TimeStamp, + FromItem + ) return self.Insert( File.Name, File.Ext, File.Dir, File.Path, @@ -219,12 +231,15 @@ class TableFile(Table): # # @param FilePath Path of file # # @retval ID ID value of given file in the table # - def GetFileId(self, File): - QueryScript =3D "select ID from %s where FullPath =3D '%s'" % (sel= f.Table, str(File)) + def GetFileId(self, File, FromItem=3DNone): + if FromItem: + QueryScript =3D "select ID from %s where FullPath =3D '%s' and= FromItem =3D %s" % (self.Table, str(File), str(FromItem)) + else: + QueryScript =3D "select ID from %s where FullPath =3D '%s'" % = (self.Table, str(File)) RecordList =3D self.Exec(QueryScript) if len(RecordList) =3D=3D 0: return None return RecordList[0][0] =20 diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTool= s/Source/Python/Workspace/MetaFileParser.py index f03b264..f3eb0c1 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -883,11 +883,11 @@ class DscParser(MetaFileParser): # @param Owner Owner ID (for sub-section parsing) # @param From ID from which the data comes (for !INC= LUDE directive) # def __init__(self, FilePath, FileType, Arch, Table, Owner=3D -1, From= =3D -1): # prevent re-initialization - if hasattr(self, "_Table"): + if hasattr(self, "_Table") and self._Table is Table: return MetaFileParser.__init__(self, FilePath, FileType, Arch, Table, Own= er, From) self._Version =3D 0x00010005 # Only EDK2 dsc file is supported # to store conditional directive evaluation result self._DirectiveStack =3D [] @@ -1550,16 +1550,16 @@ class DscParser(MetaFileParser): EdkLogger.error('parser', ErrorCode, File=3Dself._File= WithError, Line=3Dself._LineIndex + 1, ExtraData= =3DErrorInfo1 + "\n" + ErrorInfo2) =20 self._FileWithError =3D IncludedFile1 =20 - IncludedFileTable =3D MetaFileStorage(self._Table.Cur, Include= dFile1, MODEL_FILE_DSC, False) FromItem =3D self._Content[self._ContentIndex - 1][0] if self._InSubsection: Owner =3D self._Content[self._ContentIndex - 1][8] else: Owner =3D self._Content[self._ContentIndex - 1][0] + IncludedFileTable =3D MetaFileStorage(self._Table.Cur, Include= dFile1, MODEL_FILE_DSC, False, FromItem=3DFromItem) Parser =3D DscParser(IncludedFile1, self._FileType, self._Arch= , IncludedFileTable, Owner=3DOwner, From=3DFromItem) =20 self.IncludedFiles.add (IncludedFile1) =20 diff --git a/BaseTools/Source/Python/Workspace/MetaFileTable.py b/BaseTools= /Source/Python/Workspace/MetaFileTable.py index 3c8dae0..93a2b97 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileTable.py +++ b/BaseTools/Source/Python/Workspace/MetaFileTable.py @@ -29,19 +29,19 @@ class MetaFileTable(Table): # TRICK: use file ID as the part before '.' _ID_STEP_ =3D 0.00000001 _ID_MAX_ =3D 0.99999999 =20 ## Constructor - def __init__(self, Cursor, MetaFile, FileType, Temporary): + def __init__(self, Cursor, MetaFile, FileType, Temporary, FromItem=3DN= one): self.MetaFile =3D MetaFile =20 self._FileIndexTable =3D TableFile(Cursor) self._FileIndexTable.Create(False) =20 - FileId =3D self._FileIndexTable.GetFileId(MetaFile) + FileId =3D self._FileIndexTable.GetFileId(MetaFile, FromItem) if not FileId: - FileId =3D self._FileIndexTable.InsertFile(MetaFile, FileType) + FileId =3D self._FileIndexTable.InsertFile(MetaFile, FileType,= FromItem) =20 if Temporary: TableName =3D "_%s_%s_%s" % (FileType, FileId, uuid.uuid4().he= x) else: TableName =3D "_%s_%s" % (FileType, FileId) @@ -283,12 +283,12 @@ class PlatformTable(MetaFileTable): ''' # used as table end flag, in case the changes to database is not commi= tted to db file _DUMMY_ =3D "-1, -1, '=3D=3D=3D=3D', '=3D=3D=3D=3D', '=3D=3D=3D=3D', '= =3D=3D=3D=3D', '=3D=3D=3D=3D','=3D=3D=3D=3D', -1, -1, -1, -1, -1, -1, -1" =20 ## Constructor - def __init__(self, Cursor, MetaFile, Temporary): - MetaFileTable.__init__(self, Cursor, MetaFile, MODEL_FILE_DSC, Tem= porary) + def __init__(self, Cursor, MetaFile, Temporary, FromItem=3D0): + MetaFileTable.__init__(self, Cursor, MetaFile, MODEL_FILE_DSC, Tem= porary, FromItem) =20 ## Insert table # # Insert a record into table Dsc # @@ -377,11 +377,11 @@ class MetaFileStorage(object): ".dec" : MODEL_FILE_DEC, ".dsc" : MODEL_FILE_DSC, } =20 ## Constructor - def __new__(Class, Cursor, MetaFile, FileType=3DNone, Temporary=3DFals= e): + def __new__(Class, Cursor, MetaFile, FileType=3DNone, Temporary=3DFals= e, FromItem=3DNone): # no type given, try to find one if not FileType: if MetaFile.Type in self._FILE_TYPE_: FileType =3D Class._FILE_TYPE_[MetaFile.Type] else: @@ -390,9 +390,11 @@ class MetaFileStorage(object): # don't pass the type around if it's well known if FileType =3D=3D MODEL_FILE_OTHERS: Args =3D (Cursor, MetaFile, FileType, Temporary) else: Args =3D (Cursor, MetaFile, Temporary) + if FromItem: + Args =3D Args + (FromItem,) =20 # create the storage object and return it to caller return Class._FILE_TABLE_[FileType](*Args) =20 --=20 2.6.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel