BaseTools: Latter full value should overwrite the former field value.

For structure Pcd, the latter full assign value in commandLine should
override the former field assign value. For example in commandLine,
build --pcd Token.pcd.field="haha" --pcd Token.pcd=H"{0x01,0x02}",
the former field value "haha" will be ignored and overwrite by the latter
full value "{0x01,0x02}".

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: ZhiqiangX Zhao <zhiqiangx.zhao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Zhao, ZhiqiangX 2018-09-12 17:19:26 +08:00 committed by Liming Gao
parent b602265d55
commit 0fd04efd01
2 changed files with 33 additions and 4 deletions

View File

@ -1067,6 +1067,23 @@ class DscBuildData(PlatformBuildClassObject):
PcdItem = BuildData.Pcds[key] PcdItem = BuildData.Pcds[key]
if (TokenSpaceGuidCName, TokenCName) == (PcdItem.TokenSpaceGuidCName, PcdItem.TokenCName) and FieldName =="": if (TokenSpaceGuidCName, TokenCName) == (PcdItem.TokenSpaceGuidCName, PcdItem.TokenCName) and FieldName =="":
PcdItem.DefaultValue = pcdvalue PcdItem.DefaultValue = pcdvalue
#In command line, the latter full assign value in commandLine should override the former field assign value.
#For example, --pcd Token.pcd.field="" --pcd Token.pcd=H"{}"
delete_assign = []
field_assign = {}
if GlobalData.BuildOptionPcd:
for pcdTuple in GlobalData.BuildOptionPcd:
TokenSpaceGuid, Token, Field = pcdTuple[0], pcdTuple[1], pcdTuple[2]
if Field:
if (TokenSpaceGuid, Token) not in field_assign:
field_assign[TokenSpaceGuid, Token] = []
field_assign[TokenSpaceGuid, Token].append(pcdTuple)
else:
if (TokenSpaceGuid, Token) in field_assign:
delete_assign.extend(field_assign[TokenSpaceGuid, Token])
field_assign[TokenSpaceGuid, Token] = []
for item in delete_assign:
GlobalData.BuildOptionPcd.remove(item)
@staticmethod @staticmethod
def HandleFlexiblePcd(TokenSpaceGuidCName, TokenCName, PcdValue, PcdDatumType, GuidDict, FieldName=''): def HandleFlexiblePcd(TokenSpaceGuidCName, TokenCName, PcdValue, PcdDatumType, GuidDict, FieldName=''):

View File

@ -992,11 +992,15 @@ class PcdReport(object):
PcdValue = DecDefaultValue PcdValue = DecDefaultValue
if DscDefaultValue: if DscDefaultValue:
PcdValue = DscDefaultValue PcdValue = DscDefaultValue
#The DefaultValue of StructurePcd already be the latest, no need to update.
if not self.IsStructurePcd(Pcd.TokenCName, Pcd.TokenSpaceGuidCName):
Pcd.DefaultValue = PcdValue Pcd.DefaultValue = PcdValue
if ModulePcdSet is not None: if ModulePcdSet is not None:
if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type) not in ModulePcdSet: if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type) not in ModulePcdSet:
continue continue
InfDefaultValue, PcdValue = ModulePcdSet[Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type] InfDefaultValue, PcdValue = ModulePcdSet[Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type]
#The DefaultValue of StructurePcd already be the latest, no need to update.
if not self.IsStructurePcd(Pcd.TokenCName, Pcd.TokenSpaceGuidCName):
Pcd.DefaultValue = PcdValue Pcd.DefaultValue = PcdValue
if InfDefaultValue: if InfDefaultValue:
try: try:
@ -1013,6 +1017,8 @@ class PcdReport(object):
if pcd[2]: if pcd[2]:
continue continue
PcdValue = pcd[3] PcdValue = pcd[3]
#The DefaultValue of StructurePcd already be the latest, no need to update.
if not self.IsStructurePcd(Pcd.TokenCName, Pcd.TokenSpaceGuidCName):
Pcd.DefaultValue = PcdValue Pcd.DefaultValue = PcdValue
BuildOptionMatch = True BuildOptionMatch = True
break break
@ -1060,7 +1066,7 @@ class PcdReport(object):
DscMatch = (DscDefaultValue.strip() == PcdValue.strip()) DscMatch = (DscDefaultValue.strip() == PcdValue.strip())
IsStructure = False IsStructure = False
if GlobalData.gStructurePcd and (self.Arch in GlobalData.gStructurePcd) and ((Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.gStructurePcd[self.Arch]): if self.IsStructurePcd(Pcd.TokenCName, Pcd.TokenSpaceGuidCName):
IsStructure = True IsStructure = True
if TypeName in ('DYNVPD', 'DEXVPD'): if TypeName in ('DYNVPD', 'DEXVPD'):
SkuInfoList = Pcd.SkuInfoList SkuInfoList = Pcd.SkuInfoList
@ -1438,6 +1444,12 @@ class PcdReport(object):
else: else:
return value return value
def IsStructurePcd(self, PcdToken, PcdTokenSpaceGuid):
if GlobalData.gStructurePcd and (self.Arch in GlobalData.gStructurePcd) and ((PcdToken, PcdTokenSpaceGuid) in GlobalData.gStructurePcd[self.Arch]):
return True
else:
return False
## ##
# Reports platform and module Prediction information # Reports platform and module Prediction information
# #