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.65; helo=mga03.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 AD4B8202E53F2 for ; Mon, 25 Jun 2018 19:34:24 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jun 2018 19:34:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,272,1526367600"; d="scan'208";a="49892621" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga007.fm.intel.com with ESMTP; 25 Jun 2018 19:34:19 -0700 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 25 Jun 2018 19:34:19 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 25 Jun 2018 19:34:19 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.51]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.87]) with mapi id 14.03.0319.002; Tue, 26 Jun 2018 10:34:17 +0800 From: "Zhu, Yonghong" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" CC: "Feng, YunhuaX" , "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [edk2] [Patch] BaseTools: Fix two drivers include the same file issue Thread-Index: AQHUDB5EH5/WWZHnbkKtjMbA8XOk2KRx1AOw Date: Tue, 26 Jun 2018 02:34:16 +0000 Message-ID: References: <1529887697-24584-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1529887697-24584-1-git-send-email-yonghong.zhu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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: , X-List-Received-Date: Tue, 26 Jun 2018 02:34:24 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Yonghong Zhu =20 Best Regards, Zhu Yonghong -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Yong= hong Zhu Sent: Monday, June 25, 2018 8:48 AM To: edk2-devel@lists.01.org Cc: Feng, YunhuaX ; Gao, Liming Subject: [edk2] [Patch] BaseTools: Fix two drivers include the same file is= sue 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 --- 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'" %= =20 + (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,=20 + IncludedFile1, 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,=20 + 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,=20 + Temporary, 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 -- 2.6.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel