BaseTools: Fix two drivers include the same file issue

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>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
Yunhua Feng 2018-06-21 15:17:24 +08:00 committed by Yonghong Zhu
parent cd7bd491f3
commit 395f333686
3 changed files with 31 additions and 14 deletions

View File

@ -168,7 +168,8 @@ class TableFile(Table):
Path VARCHAR, Path VARCHAR,
FullPath VARCHAR NOT NULL, FullPath VARCHAR NOT NULL,
Model INTEGER DEFAULT 0, Model INTEGER DEFAULT 0,
TimeStamp SINGLE NOT NULL TimeStamp SINGLE NOT NULL,
FromItem REAL NOT NULL
''' '''
def __init__(self, Cursor): def __init__(self, Cursor):
Table.__init__(self, Cursor, 'File') Table.__init__(self, Cursor, 'File')
@ -184,7 +185,7 @@ class TableFile(Table):
# @param Model: Model of a File # @param Model: Model of a File
# @param TimeStamp: TimeStamp 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)) (Name, ExtName, Path, FullPath) = ConvertToSqlString((Name, ExtName, Path, FullPath))
return Table.Insert( return Table.Insert(
self, self,
@ -193,7 +194,8 @@ class TableFile(Table):
Path, Path,
FullPath, FullPath,
Model, Model,
TimeStamp TimeStamp,
FromItem
) )
## InsertFile ## InsertFile
@ -205,7 +207,17 @@ class TableFile(Table):
# #
# @retval FileID: The ID after record is inserted # @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( return self.Insert(
File.Name, File.Name,
File.Ext, File.Ext,
@ -221,8 +233,11 @@ class TableFile(Table):
# #
# @retval ID ID value of given file in the table # @retval ID ID value of given file in the table
# #
def GetFileId(self, File): def GetFileId(self, File, FromItem=None):
QueryScript = "select ID from %s where FullPath = '%s'" % (self.Table, str(File)) 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) RecordList = self.Exec(QueryScript)
if len(RecordList) == 0: if len(RecordList) == 0:
return None return None

View File

@ -886,7 +886,7 @@ class DscParser(MetaFileParser):
# #
def __init__(self, FilePath, FileType, Arch, Table, Owner= -1, From= -1): def __init__(self, FilePath, FileType, Arch, Table, Owner= -1, From= -1):
# prevent re-initialization # prevent re-initialization
if hasattr(self, "_Table"): if hasattr(self, "_Table") and self._Table is Table:
return return
MetaFileParser.__init__(self, FilePath, FileType, Arch, Table, Owner, From) MetaFileParser.__init__(self, FilePath, FileType, Arch, Table, Owner, From)
self._Version = 0x00010005 # Only EDK2 dsc file is supported self._Version = 0x00010005 # Only EDK2 dsc file is supported
@ -1557,12 +1557,12 @@ class DscParser(MetaFileParser):
self._FileWithError = IncludedFile1 self._FileWithError = IncludedFile1
IncludedFileTable = MetaFileStorage(self._Table.Cur, IncludedFile1, MODEL_FILE_DSC, False)
FromItem = self._Content[self._ContentIndex - 1][0] FromItem = self._Content[self._ContentIndex - 1][0]
if self._InSubsection: if self._InSubsection:
Owner = self._Content[self._ContentIndex - 1][8] Owner = self._Content[self._ContentIndex - 1][8]
else: else:
Owner = self._Content[self._ContentIndex - 1][0] 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, Parser = DscParser(IncludedFile1, self._FileType, self._Arch, IncludedFileTable,
Owner=Owner, From=FromItem) Owner=Owner, From=FromItem)

View File

@ -31,15 +31,15 @@ class MetaFileTable(Table):
_ID_MAX_ = 0.99999999 _ID_MAX_ = 0.99999999
## Constructor ## Constructor
def __init__(self, Cursor, MetaFile, FileType, Temporary): def __init__(self, Cursor, MetaFile, FileType, Temporary, FromItem=None):
self.MetaFile = MetaFile self.MetaFile = MetaFile
self._FileIndexTable = TableFile(Cursor) self._FileIndexTable = TableFile(Cursor)
self._FileIndexTable.Create(False) self._FileIndexTable.Create(False)
FileId = self._FileIndexTable.GetFileId(MetaFile) FileId = self._FileIndexTable.GetFileId(MetaFile, FromItem)
if not FileId: if not FileId:
FileId = self._FileIndexTable.InsertFile(MetaFile, FileType) FileId = self._FileIndexTable.InsertFile(MetaFile, FileType, FromItem)
if Temporary: if Temporary:
TableName = "_%s_%s_%s" % (FileType, FileId, uuid.uuid4().hex) TableName = "_%s_%s_%s" % (FileType, FileId, uuid.uuid4().hex)
@ -285,8 +285,8 @@ class PlatformTable(MetaFileTable):
_DUMMY_ = "-1, -1, '====', '====', '====', '====', '====','====', -1, -1, -1, -1, -1, -1, -1" _DUMMY_ = "-1, -1, '====', '====', '====', '====', '====','====', -1, -1, -1, -1, -1, -1, -1"
## Constructor ## Constructor
def __init__(self, Cursor, MetaFile, Temporary): def __init__(self, Cursor, MetaFile, Temporary, FromItem=0):
MetaFileTable.__init__(self, Cursor, MetaFile, MODEL_FILE_DSC, Temporary) MetaFileTable.__init__(self, Cursor, MetaFile, MODEL_FILE_DSC, Temporary, FromItem)
## Insert table ## Insert table
# #
@ -379,7 +379,7 @@ class MetaFileStorage(object):
} }
## Constructor ## 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 # no type given, try to find one
if not FileType: if not FileType:
if MetaFile.Type in self._FILE_TYPE_: if MetaFile.Type in self._FILE_TYPE_:
@ -392,6 +392,8 @@ class MetaFileStorage(object):
Args = (Cursor, MetaFile, FileType, Temporary) Args = (Cursor, MetaFile, FileType, Temporary)
else: else:
Args = (Cursor, MetaFile, Temporary) Args = (Cursor, MetaFile, Temporary)
if FromItem:
Args = Args + (FromItem,)
# create the storage object and return it to caller # create the storage object and return it to caller
return Class._FILE_TABLE_[FileType](*Args) return Class._FILE_TABLE_[FileType](*Args)