public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] BaseTools: Fix two drivers include the same file issue
@ 2018-06-25  0:48 Yonghong Zhu
  2018-06-26  2:34 ` Zhu, Yonghong
  0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Zhu @ 2018-06-25  0:48 UTC (permalink / raw)
  To: edk2-devel; +Cc: Yunhua Feng, Liming Gao

From: Yunhua Feng <yunhuax.feng@intel.com>

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 {
  <PcdsFixedAtBuild>
  !include Test.txt
  }
  Testpkg/Testdriver2.inf {
  <PcdsFixedAtBuild>
  !include Test.txt
  }

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
---
 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')
 
     ## 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, FromItem=0):
         (Name, ExtName, Path, FullPath) = ConvertToSqlString((Name, ExtName, Path, FullPath))
         return Table.Insert(
             self,
             Name,
             ExtName,
             Path,
             FullPath,
             Model,
-            TimeStamp
+            TimeStamp,
+            FromItem
             )
 
     ## 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=''):
+        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 = "select ID from %s where FullPath = '%s'" % (self.Table, str(File))
+    def GetFileId(self, File, FromItem=None):
+        if FromItem:
+            QueryScript = "select ID from %s where FullPath = '%s' and FromItem = %s" % (self.Table, str(File), str(FromItem))
+        else:
+            QueryScript = "select ID from %s where FullPath = '%s'" % (self.Table, str(File))
         RecordList = self.Exec(QueryScript)
         if len(RecordList) == 0:
             return None
         return RecordList[0][0]
 
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/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 !INCLUDE directive)
     #
     def __init__(self, FilePath, FileType, Arch, Table, Owner= -1, From= -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, Owner, From)
         self._Version = 0x00010005  # Only EDK2 dsc file is supported
         # to store conditional directive evaluation result
         self._DirectiveStack = []
@@ -1550,16 +1550,16 @@ class DscParser(MetaFileParser):
                     EdkLogger.error('parser', ErrorCode, File=self._FileWithError,
                                     Line=self._LineIndex + 1, ExtraData=ErrorInfo1 + "\n" + ErrorInfo2)
 
             self._FileWithError = IncludedFile1
 
-            IncludedFileTable = MetaFileStorage(self._Table.Cur, IncludedFile1, MODEL_FILE_DSC, False)
             FromItem = self._Content[self._ContentIndex - 1][0]
             if self._InSubsection:
                 Owner = self._Content[self._ContentIndex - 1][8]
             else:
                 Owner = self._Content[self._ContentIndex - 1][0]
+            IncludedFileTable = MetaFileStorage(self._Table.Cur, IncludedFile1, MODEL_FILE_DSC, False, FromItem=FromItem)
             Parser = DscParser(IncludedFile1, self._FileType, self._Arch, IncludedFileTable,
                                Owner=Owner, From=FromItem)
 
             self.IncludedFiles.add (IncludedFile1)
 
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_ = 0.00000001
     _ID_MAX_ = 0.99999999
 
     ## Constructor
-    def __init__(self, Cursor, MetaFile, FileType, Temporary):
+    def __init__(self, Cursor, MetaFile, FileType, Temporary, FromItem=None):
         self.MetaFile = MetaFile
 
         self._FileIndexTable = TableFile(Cursor)
         self._FileIndexTable.Create(False)
 
-        FileId = self._FileIndexTable.GetFileId(MetaFile)
+        FileId = self._FileIndexTable.GetFileId(MetaFile, FromItem)
         if not FileId:
-            FileId = self._FileIndexTable.InsertFile(MetaFile, FileType)
+            FileId = self._FileIndexTable.InsertFile(MetaFile, FileType, FromItem)
 
         if Temporary:
             TableName = "_%s_%s_%s" % (FileType, FileId, uuid.uuid4().hex)
         else:
             TableName = "_%s_%s" % (FileType, FileId)
@@ -283,12 +283,12 @@ class PlatformTable(MetaFileTable):
         '''
     # used as table end flag, in case the changes to database is not committed to db file
     _DUMMY_ = "-1, -1, '====', '====', '====', '====', '====','====', -1, -1, -1, -1, -1, -1, -1"
 
     ## Constructor
-    def __init__(self, Cursor, MetaFile, Temporary):
-        MetaFileTable.__init__(self, Cursor, MetaFile, MODEL_FILE_DSC, Temporary)
+    def __init__(self, Cursor, MetaFile, Temporary, FromItem=0):
+        MetaFileTable.__init__(self, Cursor, MetaFile, MODEL_FILE_DSC, Temporary, FromItem)
 
     ## Insert table
     #
     # Insert a record into table Dsc
     #
@@ -377,11 +377,11 @@ class MetaFileStorage(object):
         ".dec"  : MODEL_FILE_DEC,
         ".dsc"  : MODEL_FILE_DSC,
     }
 
     ## Constructor
-    def __new__(Class, Cursor, MetaFile, FileType=None, Temporary=False):
+    def __new__(Class, Cursor, MetaFile, FileType=None, Temporary=False, FromItem=None):
         # no type given, try to find one
         if not FileType:
             if MetaFile.Type in self._FILE_TYPE_:
                 FileType = 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 == MODEL_FILE_OTHERS:
             Args = (Cursor, MetaFile, FileType, Temporary)
         else:
             Args = (Cursor, MetaFile, Temporary)
+        if FromItem:
+            Args = Args + (FromItem,)
 
         # create the storage object and return it to caller
         return Class._FILE_TABLE_[FileType](*Args)
 
-- 
2.6.1.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Patch] BaseTools: Fix two drivers include the same file issue
  2018-06-25  0:48 [Patch] BaseTools: Fix two drivers include the same file issue Yonghong Zhu
@ 2018-06-26  2:34 ` Zhu, Yonghong
  0 siblings, 0 replies; 2+ messages in thread
From: Zhu, Yonghong @ 2018-06-26  2:34 UTC (permalink / raw)
  To: Zhu, Yonghong, edk2-devel@lists.01.org
  Cc: Feng, YunhuaX, Gao, Liming, Zhu, Yonghong


Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> 

Best Regards,
Zhu Yonghong


-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Yonghong Zhu
Sent: Monday, June 25, 2018 8:48 AM
To: edk2-devel@lists.01.org
Cc: Feng, YunhuaX <yunhuax.feng@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: [edk2] [Patch] BaseTools: Fix two drivers include the same file issue

From: Yunhua Feng <yunhuax.feng@intel.com>

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 {
  <PcdsFixedAtBuild>
  !include Test.txt
  }
  Testpkg/Testdriver2.inf {
  <PcdsFixedAtBuild>
  !include Test.txt
  }

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
---
 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')
 
     ## 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, FromItem=0):
         (Name, ExtName, Path, FullPath) = ConvertToSqlString((Name, ExtName, Path, FullPath))
         return Table.Insert(
             self,
             Name,
             ExtName,
             Path,
             FullPath,
             Model,
-            TimeStamp
+            TimeStamp,
+            FromItem
             )
 
     ## 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=''):
+        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 = "select ID from %s where FullPath = '%s'" % (self.Table, str(File))
+    def GetFileId(self, File, FromItem=None):
+        if FromItem:
+            QueryScript = "select ID from %s where FullPath = '%s' and FromItem = %s" % (self.Table, str(File), str(FromItem))
+        else:
+            QueryScript = "select ID from %s where FullPath = '%s'" % 
+ (self.Table, str(File))
         RecordList = self.Exec(QueryScript)
         if len(RecordList) == 0:
             return None
         return RecordList[0][0]
 
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/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 !INCLUDE directive)
     #
     def __init__(self, FilePath, FileType, Arch, Table, Owner= -1, From= -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, Owner, From)
         self._Version = 0x00010005  # Only EDK2 dsc file is supported
         # to store conditional directive evaluation result
         self._DirectiveStack = []
@@ -1550,16 +1550,16 @@ class DscParser(MetaFileParser):
                     EdkLogger.error('parser', ErrorCode, File=self._FileWithError,
                                     Line=self._LineIndex + 1, ExtraData=ErrorInfo1 + "\n" + ErrorInfo2)
 
             self._FileWithError = IncludedFile1
 
-            IncludedFileTable = MetaFileStorage(self._Table.Cur, IncludedFile1, MODEL_FILE_DSC, False)
             FromItem = self._Content[self._ContentIndex - 1][0]
             if self._InSubsection:
                 Owner = self._Content[self._ContentIndex - 1][8]
             else:
                 Owner = self._Content[self._ContentIndex - 1][0]
+            IncludedFileTable = MetaFileStorage(self._Table.Cur, 
+ IncludedFile1, MODEL_FILE_DSC, False, FromItem=FromItem)
             Parser = DscParser(IncludedFile1, self._FileType, self._Arch, IncludedFileTable,
                                Owner=Owner, From=FromItem)
 
             self.IncludedFiles.add (IncludedFile1)
 
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_ = 0.00000001
     _ID_MAX_ = 0.99999999
 
     ## Constructor
-    def __init__(self, Cursor, MetaFile, FileType, Temporary):
+    def __init__(self, Cursor, MetaFile, FileType, Temporary, FromItem=None):
         self.MetaFile = MetaFile
 
         self._FileIndexTable = TableFile(Cursor)
         self._FileIndexTable.Create(False)
 
-        FileId = self._FileIndexTable.GetFileId(MetaFile)
+        FileId = self._FileIndexTable.GetFileId(MetaFile, FromItem)
         if not FileId:
-            FileId = self._FileIndexTable.InsertFile(MetaFile, FileType)
+            FileId = self._FileIndexTable.InsertFile(MetaFile, 
+ FileType, FromItem)
 
         if Temporary:
             TableName = "_%s_%s_%s" % (FileType, FileId, uuid.uuid4().hex)
         else:
             TableName = "_%s_%s" % (FileType, FileId) @@ -283,12 +283,12 @@ class PlatformTable(MetaFileTable):
         '''
     # used as table end flag, in case the changes to database is not committed to db file
     _DUMMY_ = "-1, -1, '====', '====', '====', '====', '====','====', -1, -1, -1, -1, -1, -1, -1"
 
     ## Constructor
-    def __init__(self, Cursor, MetaFile, Temporary):
-        MetaFileTable.__init__(self, Cursor, MetaFile, MODEL_FILE_DSC, Temporary)
+    def __init__(self, Cursor, MetaFile, Temporary, FromItem=0):
+        MetaFileTable.__init__(self, Cursor, MetaFile, MODEL_FILE_DSC, 
+ Temporary, FromItem)
 
     ## Insert table
     #
     # Insert a record into table Dsc
     #
@@ -377,11 +377,11 @@ class MetaFileStorage(object):
         ".dec"  : MODEL_FILE_DEC,
         ".dsc"  : MODEL_FILE_DSC,
     }
 
     ## Constructor
-    def __new__(Class, Cursor, MetaFile, FileType=None, Temporary=False):
+    def __new__(Class, Cursor, MetaFile, FileType=None, Temporary=False, FromItem=None):
         # no type given, try to find one
         if not FileType:
             if MetaFile.Type in self._FILE_TYPE_:
                 FileType = 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 == MODEL_FILE_OTHERS:
             Args = (Cursor, MetaFile, FileType, Temporary)
         else:
             Args = (Cursor, MetaFile, Temporary)
+        if FromItem:
+            Args = Args + (FromItem,)
 
         # create the storage object and return it to caller
         return Class._FILE_TABLE_[FileType](*Args)
 
--
2.6.1.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-26  2:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-25  0:48 [Patch] BaseTools: Fix two drivers include the same file issue Yonghong Zhu
2018-06-26  2:34 ` Zhu, Yonghong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox