From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web12.8009.1604458915902968038 for ; Tue, 03 Nov 2020 19:01:56 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: bob.c.feng@intel.com) IronPort-SDR: +FrQn6XQPOtnE9+2yjmjt3w+bT0nGOJHr9AQr1IFKCZHohdVDjj3oGh5jx3YqRIv/fkbuMrq0f 0T/Lbb9E9EiQ== X-IronPort-AV: E=McAfee;i="6000,8403,9794"; a="169295965" X-IronPort-AV: E=Sophos;i="5.77,449,1596524400"; d="scan'208";a="169295965" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 19:01:55 -0800 IronPort-SDR: YjgkwueHRucnKQ0QdlHiy1Ui9PkU+Hu05ySM1CkM2YK7Djq8ikrfNp9SP2zSEayk41d5JZsyYY 8aalXgeBCNUg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,449,1596524400"; d="scan'208";a="363830740" Received: from shwdepsi1121.ccr.corp.intel.com ([10.239.158.66]) by orsmga007.jf.intel.com with ESMTP; 03 Nov 2020 19:01:53 -0800 From: "Bob Feng" To: devel@edk2.groups.io Cc: Liming Gao , Yuwei Chen Subject: [Patch V5] BaseTools: Enable Module Scope Structure Pcd Date: Wed, 4 Nov 2020 11:01:39 +0800 Message-Id: <20201104030139.1706-1-bob.c.feng@intel.com> X-Mailer: git-send-email 2.29.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2648=0D This patch is to enable the Module scoped Structure Pcd usage. User can set structure pcd field value in module scope. For example, under the [components] section of a dsc file, user can override some field value for a specific module. Package/Module.inf{ gUefiTokenSpaceGuid.StructurePcdModule.FieldName | 5 } Signed-off-by: Bob Feng Cc: Liming Gao Cc: Yuwei Chen ---=0D V5:=0D Append the Bugzilla link.=0D =0D V4: =0D 1. change the variable name mlist to ModuleList=0D 2. change the variable name module_guid to ModuleGuid=0D V3: =0D 1. Place the the module level PCD value assignment =0D before Fdf PCD value assignment.=0D 2. Fixed the incorrect value format for module level =0D structure PCD in build report. BaseTools/Source/Python/AutoGen/DataPipe.py | 5 +- .../Source/Python/AutoGen/ModuleAutoGen.py | 4 +- .../Python/AutoGen/ModuleAutoGenHelper.py | 10 +- .../Source/Python/AutoGen/PlatformAutoGen.py | 8 +- .../Python/Workspace/BuildClassObject.py | 12 + .../Source/Python/Workspace/DscBuildData.py | 244 ++++++++++++++++-- BaseTools/Source/Python/build/BuildReport.py | 117 +++++---- 7 files changed, 326 insertions(+), 74 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/DataPipe.py b/BaseTools/Source= /Python/AutoGen/DataPipe.py index 50403fbfb5..86ac2b928d 100755 --- a/BaseTools/Source/Python/AutoGen/DataPipe.py +++ b/BaseTools/Source/Python/AutoGen/DataPipe.py @@ -70,13 +70,14 @@ class MemoryDataPipe(DataPipe): }=0D =0D #Platform Module Pcds=0D ModulePcds =3D {}=0D for m in PlatformInfo.Platform.Modules:=0D - m_pcds =3D PlatformInfo.Platform.Modules[m].Pcds=0D + module =3D PlatformInfo.Platform.Modules[m]=0D + m_pcds =3D module.Pcds=0D if m_pcds:=0D - ModulePcds[(m.File,m.Root,m.Arch)] =3D [PCD_DATA(=0D + ModulePcds[module.Guid] =3D [PCD_DATA(=0D pcd.TokenCName,pcd.TokenSpaceGuidCName,pcd.Type,=0D pcd.DatumType,pcd.SkuInfoList,pcd.DefaultValue,=0D pcd.MaxDatumSize,pcd.UserDefinedDefaultStoresFlag,pcd.validate= ranges,=0D pcd.validlists,pcd.expressions,pcd.CustomAttribute,pcd.To= kenValue)=0D for pcd in PlatformInfo.Platform.Modules[m].Pcds.values()]=0D diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py b/BaseTools/S= ource/Python/AutoGen/ModuleAutoGen.py index eebf6e87f5..d70b0d7ae8 100755 --- a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py +++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py @@ -1030,11 +1030,11 @@ class ModuleAutoGen(AutoGen): # @retval list The list of PCD=0D #=0D @cached_property=0D def ModulePcdList(self):=0D # apply PCD settings from platform=0D - RetVal =3D self.PlatformInfo.ApplyPcdSetting(self.Module, self.Mod= ule.Pcds)=0D + RetVal =3D self.PlatformInfo.ApplyPcdSetting(self, self.Module.Pcd= s)=0D =0D return RetVal=0D @cached_property=0D def _PcdComments(self):=0D ReVal =3D OrderedListDict()=0D @@ -1061,11 +1061,11 @@ class ModuleAutoGen(AutoGen): # skip duplicated PCDs=0D if Key in self.Module.Pcds or Key in Pcds:=0D continue=0D Pcds.add(Key)=0D PcdsInLibrary[Key] =3D copy.copy(Library.Pcds[Key])=0D - RetVal.extend(self.PlatformInfo.ApplyPcdSetting(self.Module, P= cdsInLibrary, Library=3DLibrary))=0D + RetVal.extend(self.PlatformInfo.ApplyPcdSetting(self, PcdsInLi= brary, Library=3DLibrary))=0D return RetVal=0D =0D ## Get the GUID value mapping=0D #=0D # @retval dict The mapping between GUID cname and its value=0D diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py b/BaseT= ools/Source/Python/AutoGen/ModuleAutoGenHelper.py index 9dd93b9beb..8e60643d1f 100644 --- a/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py +++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py @@ -477,12 +477,13 @@ class PlatformInfo(AutoGenInfo): SkuName =3D TAB_DEFAULT=0D ToPcd.SkuInfoList =3D {=0D SkuName : SkuInfoClass(SkuName, self.Platform.SkuIds[SkuNa= me][0], '', '', '', '', '', ToPcd.DefaultValue)=0D }=0D =0D - def ApplyPcdSetting(self, Module, Pcds, Library=3D""):=0D + def ApplyPcdSetting(self, Ma, Pcds, Library=3D""):=0D # for each PCD in module=0D + Module=3DMa.Module=0D for Name, Guid in Pcds:=0D PcdInModule =3D Pcds[Name, Guid]=0D # find out the PCD setting in platform=0D if (Name, Guid) in self.Pcds:=0D PcdInPlatform =3D self.Pcds[Name, Guid]=0D @@ -505,13 +506,16 @@ class PlatformInfo(AutoGenInfo): % (Guid, Name, str= (Module)),=0D File=3Dself.MetaFile=0D )=0D =0D # override PCD settings with module specific setting=0D + ModuleScopePcds =3D self.DataPipe.Get("MOL_PCDS")=0D if Module in self.Platform.Modules:=0D PlatformModule =3D self.Platform.Modules[str(Module)]=0D - for Key in PlatformModule.Pcds:=0D + PCD_DATA =3D ModuleScopePcds.get(Ma.Guid,{})=0D + mPcds =3D {(pcd.TokenCName,pcd.TokenSpaceGuidCName): pcd for p= cd in PCD_DATA}=0D + for Key in mPcds:=0D if self.BuildOptionPcd:=0D for pcd in self.BuildOptionPcd:=0D (TokenSpaceGuidCName, TokenCName, FieldName, pcdva= lue, _) =3D pcd=0D if (TokenCName, TokenSpaceGuidCName) =3D=3D Key an= d FieldName =3D=3D"":=0D PlatformModule.Pcds[Key].DefaultValue =3D pcdv= alue=0D @@ -526,11 +530,11 @@ class PlatformInfo(AutoGenInfo): if PcdItem in Pcds:=0D ToPcd =3D Pcds[PcdItem]=0D Flag =3D True=0D break=0D if Flag:=0D - self._OverridePcd(ToPcd, PlatformModule.Pcds[Key], Mod= ule, Msg=3D"DSC Components Module scoped PCD section", Library=3DLibrary)=0D + self._OverridePcd(ToPcd, mPcds[Key], Module, Msg=3D"DS= C Components Module scoped PCD section", Library=3DLibrary)=0D # use PCD value to calculate the MaxDatumSize when it is not speci= fied=0D for Name, Guid in Pcds:=0D Pcd =3D Pcds[Name, Guid]=0D if Pcd.DatumType =3D=3D TAB_VOID and not Pcd.MaxDatumSize:=0D Pcd.MaxSizeUserSet =3D None=0D diff --git a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py b/BaseTools= /Source/Python/AutoGen/PlatformAutoGen.py index 26ab8e7f36..c001828937 100644 --- a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py +++ b/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py @@ -1041,11 +1041,17 @@ class PlatformAutoGen(AutoGen): TokenNumber +=3D 1=0D return RetVal=0D =0D @cached_property=0D def _MbList(self):=0D - return [self.BuildDatabase[m, self.Arch, self.BuildTarget, self.To= olChain] for m in self.Platform.Modules]=0D + ModuleList =3D []=0D + for m in self.Platform.Modules:=0D + component =3D self.Platform.Modules[m]=0D + module =3D self.BuildDatabase[m, self.Arch, self.BuildTarget, = self.ToolChain]=0D + module.Guid =3D component.Guid=0D + ModuleList.append(module)=0D + return ModuleList=0D =0D @cached_property=0D def _MaList(self):=0D for ModuleFile in self.Platform.Modules:=0D Ma =3D ModuleAutoGen(=0D diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTo= ols/Source/Python/Workspace/BuildClassObject.py index db40e3b10c..ebb65fc2fe 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -68,10 +68,11 @@ class PcdClassObject(object): self.DscRawValueInfo =3D {}=0D if IsDsc:=0D self.DscDefaultValue =3D Value=0D self.PcdValueFromComm =3D ""=0D self.PcdValueFromFdf =3D ""=0D + self.PcdValueFromComponents =3D {} #{ModuleGuid:value, file_path,l= ineNo}=0D self.CustomAttribute =3D {}=0D self.UserDefinedDefaultStoresFlag =3D UserDefinedDefaultStoresFlag= =0D self._Capacity =3D None=0D =0D @property=0D @@ -296,10 +297,11 @@ class StructurePcd(PcdClassObject): self.DefaultValueFromDecInfo =3D None=0D self.ValueChain =3D set()=0D self.PcdFieldValueFromComm =3D OrderedDict()=0D self.PcdFieldValueFromFdf =3D OrderedDict()=0D self.DefaultFromDSC=3DNone=0D + self.PcdFiledValueFromDscComponent =3D OrderedDict()=0D def __repr__(self):=0D return self.TypeName=0D =0D def AddDefaultValue (self, FieldName, Value, FileName=3D"", LineNo=3D0= ,DimensionAttr =3D"-1"):=0D if DimensionAttr not in self.DefaultValues:=0D @@ -322,10 +324,16 @@ class StructurePcd(PcdClassObject): if FieldName in self.SkuOverrideValues[SkuName][DefaultStoreName][= DimensionAttr]:=0D del self.SkuOverrideValues[SkuName][DefaultStoreName][Dimensio= nAttr][FieldName]=0D self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr][F= ieldName] =3D [Value.strip(), FileName, LineNo]=0D return self.SkuOverrideValues[SkuName][DefaultStoreName][Dimension= Attr][FieldName]=0D =0D + def AddComponentOverrideValue(self,FieldName, Value, ModuleGuid, FileN= ame=3D"", LineNo=3D0, DimensionAttr =3D '-1'):=0D + self.PcdFiledValueFromDscComponent.setdefault(ModuleGuid, OrderedD= ict())=0D + self.PcdFiledValueFromDscComponent[ModuleGuid].setdefault(Dimensio= nAttr,OrderedDict())=0D + self.PcdFiledValueFromDscComponent[ModuleGuid][DimensionAttr][Fiel= dName] =3D [Value.strip(), FileName, LineNo]=0D + return self.PcdFiledValueFromDscComponent[ModuleGuid][DimensionAtt= r][FieldName]=0D +=0D def SetPcdMode (self, PcdMode):=0D self.PcdMode =3D PcdMode=0D =0D def copy(self, PcdObject):=0D self.TokenCName =3D PcdObject.TokenCName if PcdObject.TokenCName e= lse self.TokenCName=0D @@ -363,10 +371,11 @@ class StructurePcd(PcdClassObject): self.PcdDefineLineNo =3D PcdObject.PcdDefineLineNo if PcdObjec= t.PcdDefineLineNo else self.PcdDefineLineNo=0D self.PkgPath =3D PcdObject.PkgPath if PcdObject.PkgPath else s= elf.PkgPath=0D self.ValueChain =3D PcdObject.ValueChain if PcdObject.ValueCha= in else self.ValueChain=0D self.PcdFieldValueFromComm =3D PcdObject.PcdFieldValueFromComm= if PcdObject.PcdFieldValueFromComm else self.PcdFieldValueFromComm=0D self.PcdFieldValueFromFdf =3D PcdObject.PcdFieldValueFromFdf i= f PcdObject.PcdFieldValueFromFdf else self.PcdFieldValueFromFdf=0D + self.PcdFiledValueFromDscComponent =3D PcdObject.PcdFiledValue= FromDscComponent if PcdObject.PcdFiledValueFromDscComponent else self.PcdFi= ledValueFromDscComponent=0D =0D def __deepcopy__(self,memo):=0D new_pcd =3D StructurePcd()=0D self.sharedcopy(new_pcd)=0D =0D @@ -381,10 +390,11 @@ class StructurePcd(PcdClassObject): new_pcd.DefaultValues =3D CopyDict(self.DefaultValues)=0D new_pcd.DefaultFromDSC=3DCopyDict(self.DefaultFromDSC)=0D new_pcd.SkuOverrideValues =3D CopyDict(self.SkuOverrideValues)=0D new_pcd.PcdFieldValueFromComm =3D CopyDict(self.PcdFieldValueFromC= omm)=0D new_pcd.PcdFieldValueFromFdf =3D CopyDict(self.PcdFieldValueFromFd= f)=0D + new_pcd.PcdFiledValueFromDscComponent =3D CopyDict(self.PcdFiledVa= lueFromDscComponent)=0D new_pcd.ValueChain =3D {item for item in self.ValueChain}=0D return new_pcd=0D =0D LibraryClassObject =3D namedtuple('LibraryClassObject', ['LibraryClass','S= upModList'])=0D =0D @@ -461,10 +471,12 @@ class ModuleBuildClassObject(object): self.Includes =3D []=0D self.Packages =3D []=0D self.Pcds =3D {}=0D self.BuildOptions =3D {}=0D self.Depex =3D {}=0D + self.StrPcdSet =3D []=0D + self.StrPcdOverallValue =3D {}=0D =0D ## Convert the class to a string=0D #=0D # Convert member MetaFile of the class to a string=0D #=0D diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/= Source/Python/Workspace/DscBuildData.py index 1ed3d9b909..5f07d3e75c 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -753,13 +753,14 @@ class DscBuildData(PlatformBuildClassObject): ErrorCode, ErrorInfo =3D ModuleFile.Validate('.inf')=0D if ErrorCode !=3D 0:=0D EdkLogger.error('build', ErrorCode, File=3Dself.MetaFile, = Line=3DLineNo,=0D ExtraData=3DErrorInfo)=0D =0D + ModuleBuildData =3D self._Bdb[ModuleFile, self._Arch, self._Ta= rget, self._Toolchain]=0D Module =3D ModuleBuildClassObject()=0D Module.MetaFile =3D ModuleFile=0D -=0D + Module.Guid =3D ModuleBuildData.Guid=0D # get module private library instance=0D RecordList =3D self._RawData[MODEL_EFI_LIBRARY_CLASS, self._Ar= ch, None, ModuleId]=0D for Record in RecordList:=0D LibraryClass =3D Record[0]=0D LibraryPath =3D PathClass(NormPath(Record[1], Macros), Glo= balData.gWorkspace, Arch=3Dself._Arch)=0D @@ -776,11 +777,11 @@ class DscBuildData(PlatformBuildClassObject): LibraryClass =3D 'NULL%d' % self._NullLibraryNumber=0D EdkLogger.verbose("Found forced library for %s\n\t%s [= %s]" % (ModuleFile, LibraryPath, LibraryClass))=0D Module.LibraryClasses[LibraryClass] =3D LibraryPath=0D if LibraryPath not in self.LibraryInstances:=0D self.LibraryInstances.append(LibraryPath)=0D -=0D + S_PcdSet =3D []=0D # get module private PCD setting=0D for Type in [MODEL_PCD_FIXED_AT_BUILD, MODEL_PCD_PATCHABLE_IN_= MODULE, \=0D MODEL_PCD_FEATURE_FLAG, MODEL_PCD_DYNAMIC, MODEL_= PCD_DYNAMIC_EX]:=0D RecordList =3D self._RawData[Type, self._Arch, None, Modul= eId]=0D for TokenSpaceGuid, PcdCName, Setting, Dummy1, Dummy2, Dum= my3, Dummy4, Dummy5 in RecordList:=0D @@ -790,24 +791,35 @@ class DscBuildData(PlatformBuildClassObject): if len(TokenList) > 2:=0D MaxDatumSize =3D TokenList[2]=0D else:=0D MaxDatumSize =3D ''=0D TypeString =3D self._PCD_TYPE_STRING_[Type]=0D - Pcd =3D PcdClassObject(=0D - PcdCName,=0D - TokenSpaceGuid,=0D - TypeString,=0D - '',=0D - DefaultValue,=0D - '',=0D - MaxDatumSize,=0D - {},=0D - False,=0D - None=0D - )=0D - Module.Pcds[PcdCName, TokenSpaceGuid] =3D Pcd=0D =0D + TCName,PCName,DimensionAttr,Field =3D self.ParsePcdNam= eStruct(TokenSpaceGuid, PcdCName)=0D +=0D + if ("." in TokenSpaceGuid or "[" in PcdCName):=0D + S_PcdSet.append([ TCName,PCName,DimensionAttr,Fiel= d, ModuleBuildData.Guid, "", Dummy5, AnalyzePcdExpression(Setting)[0]])=0D + DefaultValue =3D ''=0D + if ( PCName,TCName) not in Module.Pcds:=0D + Pcd =3D PcdClassObject(=0D + PCName,=0D + TCName,=0D + TypeString,=0D + '',=0D + DefaultValue,=0D + '',=0D + MaxDatumSize,=0D + {},=0D + False,=0D + None,=0D + IsDsc=3DTrue)=0D + Module.Pcds[PCName, TCName] =3D Pcd=0D +=0D + Module.StrPcdSet =3D S_PcdSet=0D + for TCName,PCName, _,_,_,_,_,_ in S_PcdSet:=0D + if (PCName,TCName) in Module.Pcds:=0D + Module.StrPcdOverallValue[(PCName,TCName)] =3D Module.= Pcds[(PCName,TCName)].DefaultValue, self.MetaFile,Dummy5=0D # get module private build options=0D RecordList =3D self._RawData[MODEL_META_DATA_BUILD_OPTION, sel= f._Arch, None, ModuleId]=0D for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, Dummy3= , Dummy4, Dummy5 in RecordList:=0D if (ToolChainFamily, ToolChain) not in Module.BuildOptions= :=0D Module.BuildOptions[ToolChainFamily, ToolChain] =3D Op= tion=0D @@ -820,11 +832,13 @@ class DscBuildData(PlatformBuildClassObject): if len(RecordList) !=3D 1:=0D EdkLogger.error('build', OPTION_UNKNOWN, 'Only FILE_GU= ID can be listed in section.',=0D File=3Dself.MetaFile, ExtraData=3Dstr(= ModuleFile), Line=3DLineNo)=0D ModuleFile =3D ProcessDuplicatedInf(ModuleFile, RecordList= [0][2], GlobalData.gWorkspace)=0D ModuleFile.Arch =3D self._Arch=0D -=0D + Module.Guid =3D RecordList[0][2]=0D + for item in Module.StrPcdSet:=0D + item[4] =3D RecordList[0][2]=0D self._Modules[ModuleFile] =3D Module=0D return self._Modules=0D =0D ## Retrieve all possible library instances used in this platform=0D @property=0D @@ -1497,11 +1511,19 @@ class DscBuildData(PlatformBuildClassObject): EdkLogger.error('build', PARSER_ERROR,=0D "Pcd (%s.%s) is not declared as Structure = PCD in DEC files. Arch: ['%s']" % (TCName, PCName, self._Arch),=0D File=3Dself.MetaFile, Line =3D Dummy5)=0D =0D S_PcdSet.append([ TCName,PCName,DimensionAttr,Field, SkuNa= me, default_store, Dummy5, AnalyzePcdExpression(Setting)[0]])=0D -=0D + ModuleScopeOverallValue =3D {}=0D + for m in self.Modules.values():=0D + mguid =3D m.Guid=0D + if m.StrPcdSet:=0D + S_PcdSet.extend(m.StrPcdSet)=0D + mguid =3D m.StrPcdSet[0][4]=0D + for (PCName,TCName) in m.StrPcdOverallValue:=0D + Value, dsc_file, lineNo =3D m.StrPcdOverallValue[(PCName,T= CName)]=0D + ModuleScopeOverallValue.setdefault((PCName,TCName),{})[mgu= id] =3D Value, dsc_file, lineNo=0D # handle pcd value override=0D StrPcdSet =3D DscBuildData.GetStructurePcdInfo(S_PcdSet)=0D S_pcd_set =3D OrderedDict()=0D for str_pcd in StrPcdSet:=0D str_pcd_obj =3D Pcds.get((str_pcd[1], str_pcd[0]), None)=0D @@ -1515,10 +1537,15 @@ class DscBuildData(PlatformBuildClassObject): else:=0D str_pcd_obj_str.DefaultFromDSC =3D {skuname:{defaultst= ore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, st= r_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultSto= res} for skuname in str_pcd_obj.SkuInfoList}=0D for str_pcd_data in StrPcdSet[str_pcd]:=0D if str_pcd_data[4] in SkuIds:=0D str_pcd_obj_str.AddOverrideValue(str_pcd_data[3], str(= str_pcd_data[7]), TAB_DEFAULT if str_pcd_data[4] =3D=3D TAB_COMMON else str= _pcd_data[4], TAB_DEFAULT_STORES_DEFAULT if str_pcd_data[5] =3D=3D TAB_COMM= ON else str_pcd_data[5], self.MetaFile.File if self.WorkspaceDir not in sel= f.MetaFile.File else self.MetaFile.File[len(self.WorkspaceDir) if self.Work= spaceDir.endswith(os.path.sep) else len(self.WorkspaceDir)+1:], LineNo=3Dst= r_pcd_data[6],DimensionAttr =3D str_pcd_data[2])=0D + elif GlobalData.gGuidPattern.match(str_pcd_data[4]):=0D + str_pcd_obj_str.AddComponentOverrideValue(str_pcd_data= [3], str(str_pcd_data[7]), str_pcd_data[4].replace("-","S"), self.MetaFile.= File if self.WorkspaceDir not in self.MetaFile.File else self.MetaFile.File= [len(self.WorkspaceDir) if self.WorkspaceDir.endswith(os.path.sep) else len= (self.WorkspaceDir)+1:], LineNo=3Dstr_pcd_data[6],DimensionAttr =3D str_pcd= _data[2])=0D + PcdComponentValue =3D ModuleScopeOverallValue.get((str= _pcd_obj_str.TokenCName,str_pcd_obj_str.TokenSpaceGuidCName))=0D + for module_guid in PcdComponentValue:=0D + str_pcd_obj_str.PcdValueFromComponents[module_guid= .replace("-","S")] =3D PcdComponentValue[module_guid]=0D S_pcd_set[str_pcd[1], str_pcd[0]] =3D str_pcd_obj_str=0D =0D # Add the Structure PCD that only defined in DEC, don't have overr= ide in DSC file=0D for Pcd in self.DecPcds:=0D if isinstance(self._DecPcds[Pcd], StructurePcd):=0D @@ -1573,11 +1600,14 @@ class DscBuildData(PlatformBuildClassObject): if defaultstoreid not in stru_pcd.SkuOverrideValue= s[skuid]:=0D stru_pcd.SkuOverrideValues[skuid][defaultstore= id] =3D CopyDict(stru_pcd.SkuOverrideValues[nextskuid][mindefaultstorename]= )=0D stru_pcd.ValueChain.add((skuid, defaultstoreid= ))=0D S_pcd_set =3D DscBuildData.OverrideByFdf(S_pcd_set,self.WorkspaceD= ir)=0D S_pcd_set =3D DscBuildData.OverrideByComm(S_pcd_set)=0D +=0D + # Create a tool to caculate structure pcd value=0D Str_Pcd_Values =3D self.GenerateByteArrayValue(S_pcd_set)=0D +=0D if Str_Pcd_Values:=0D for (skuname, StoreName, PcdGuid, PcdName, PcdValue) in Str_Pc= d_Values:=0D str_pcd_obj =3D S_pcd_set.get((PcdName, PcdGuid))=0D if str_pcd_obj is None:=0D print(PcdName, PcdGuid)=0D @@ -1591,10 +1621,18 @@ class DscBuildData(PlatformBuildClassObject): str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.= update({StoreName:PcdValue})=0D elif str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD= _FIXED_AT_BUILD],=0D self._PCD_TYPE_STRING_[MODEL_PCD_P= ATCHABLE_IN_MODULE]]:=0D if skuname in (self.SkuIdMgr.SystemSkuId, TAB_DEFAULT,= TAB_COMMON):=0D str_pcd_obj.DefaultValue =3D PcdValue=0D + else:=0D + #Module Scope Structure Pcd=0D + moduleguid =3D skuname.replace("S","-")=0D + if GlobalData.gGuidPattern.match(moduleguid):=0D + for component in self.Modules.values():=0D + if component.Guid =3D=3D moduleguid:=0D + component.Pcds[(PcdName, PcdGuid)].Def= aultValue =3D PcdValue=0D +=0D else:=0D if skuname not in str_pcd_obj.SkuInfoList:=0D nextskuid =3D self.SkuIdMgr.GetNextSkuId(skuname)= =0D NoDefault =3D False=0D while nextskuid not in str_pcd_obj.SkuInfoList:=0D @@ -2339,10 +2377,79 @@ class DscBuildData(PlatformBuildClassObject): else:=0D CApp =3D CApp + ' Pcd->%s =3D %d; // From %s Line= %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[Fie= ldName][2], FieldList[FieldName][0])=0D CApp =3D CApp + "}\n"=0D return CApp=0D =0D + def GenerateModuleScopeValue(self, Pcd):=0D + CApp =3D "// Value in Dsc Module scope \n"=0D + for ModuleGuid in Pcd.PcdFiledValueFromDscComponent:=0D +=0D + CApp =3D CApp + "void Assign_%s_%s_%s_Value(%s *Pcd){\n" % (Pc= d.TokenSpaceGuidCName, Pcd.TokenCName, ModuleGuid,Pcd.BaseDatumType)=0D + CApp =3D CApp + ' UINT32 FieldSize;\n'=0D + CApp =3D CApp + ' CHAR8 *Value;\n'=0D + pcddefaultvalue, file_path,lineNo =3D Pcd.PcdValueFromComponen= ts.get(ModuleGuid,(None,None,None))=0D +=0D + if pcddefaultvalue:=0D + IsArray =3D _IsFieldValueAnArray(pcddefaultvalue)=0D + if IsArray:=0D + try:=0D + FieldList =3D ValueExpressionEx(pcddefaultvalue, T= AB_VOID)(True)=0D + except BadExpression:=0D + EdkLogger.error("Build", FORMAT_INVALID, "Invalid = value format for %s.%s, from %s Line %s: %s" %=0D + (Pcd.TokenSpaceGuidCName, Pcd.Toke= nCName, file_path, lineNo, FieldList))=0D + Value, ValueSize =3D ParseFieldValue (FieldList)=0D +=0D + if isinstance(Value, str):=0D + CApp =3D CApp + ' Pcd =3D %s; // From %s Line %s \n' = % (Value, file_path, lineNo)=0D + elif IsArray:=0D + #=0D + # Use memcpy() to copy value into field=0D + #=0D + CApp =3D CApp + ' Value =3D %s; // From %s Line %= s.\n' % (DscBuildData.IntToCString(Value, ValueSize), file_path, lineNo)=0D + CApp =3D CApp + ' memcpy (Pcd, Value, %d);\n' % (Valu= eSize)=0D +=0D +=0D + PcdFiledValue =3D Pcd.PcdFiledValueFromDscComponent.get(Module= Guid)=0D + for index in PcdFiledValue:=0D + FieldList =3D PcdFiledValue[index]=0D + if not FieldList:=0D + continue=0D + for FieldName in FieldList:=0D + IsArray =3D _IsFieldValueAnArray(FieldList[FieldName][= 0])=0D + if IsArray:=0D + try:=0D + FieldList[FieldName][0] =3D ValueExpressionEx(= FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True)=0D + except BadExpression:=0D + EdkLogger.error('Build', FORMAT_INVALID, "Inva= lid value format for %s. From %s Line %d " %=0D + (".".join((Pcd.TokenSpaceGuidC= Name, Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[Field= Name][2]))=0D + except:=0D + print("error")=0D + try:=0D + Value, ValueSize =3D ParseFieldValue (FieldList[Fi= eldName][0])=0D + except Exception:=0D + EdkLogger.error('Build', FORMAT_INVALID, "Invalid = value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName= , Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName= ][2]))=0D + if isinstance(Value, str):=0D + CApp =3D CApp + ' Pcd->%s =3D %s; // From %s Line= %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[Fie= ldName][2], FieldList[FieldName][0])=0D + elif IsArray:=0D + #=0D + # Use memcpy() to copy value into field=0D + #=0D + CApp =3D CApp + ' FieldSize =3D __FIELD_SIZE(%s, = %s);\n' % (Pcd.BaseDatumType, FieldName)=0D + CApp =3D CApp + ' Value =3D %s; // From %s Li= ne %d Value %s\n' % (DscBuildData.IntToCString(Value, ValueSize), FieldList= [FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])=0D + CApp =3D CApp + ' __STATIC_ASSERT((__FIELD_SIZE(%= s, %s) >=3D %d) || (__FIELD_SIZE(%s, %s) =3D=3D 0), "Input buffer exceeds t= he buffer array"); // From %s Line %d Value %s\n' % (Pcd.BaseDatumType, Fie= ldName, ValueSize, Pcd.BaseDatumType, FieldName, FieldList[FieldName][1], F= ieldList[FieldName][2], FieldList[FieldName][0])=0D + CApp =3D CApp + ' memcpy (&Pcd->%s, Value, (Field= Size > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, = ValueSize)=0D + else:=0D + if '[' in FieldName and ']' in FieldName:=0D + Index =3D int(FieldName.split('[')[1].split(']= ')[0])=0D + CApp =3D CApp + ' __STATIC_ASSERT((%d < __ARR= AY_SIZE(Pcd->%s)) || (__ARRAY_SIZE(Pcd->%s) =3D=3D 0), "array index exceeds= the array number"); // From %s Line %d Index of %s\n' % (Index, FieldName.= split('[')[0], FieldName.split('[')[0], FieldList[FieldName][1], FieldList[= FieldName][2], FieldName)=0D + if ValueSize > 4:=0D + CApp =3D CApp + ' Pcd->%s =3D %dULL; // From = %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldL= ist[FieldName][2], FieldList[FieldName][0])=0D + else:=0D + CApp =3D CApp + ' Pcd->%s =3D %d; // From %s = Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList= [FieldName][2], FieldList[FieldName][0])=0D + CApp =3D CApp + "}\n"=0D + return CApp=0D +=0D @staticmethod=0D def GenerateCommandLineValueStatement(Pcd):=0D CApp =3D ' Assign_%s_%s_CommandLine_Value(Pcd);\n' % (Pcd.TokenSp= aceGuidCName, Pcd.TokenCName)=0D return CApp=0D def GenerateFdfValue(self,Pcd):=0D @@ -2412,10 +2519,89 @@ class DscBuildData(PlatformBuildClassObject): @staticmethod=0D def GenerateFdfValueStatement(Pcd):=0D CApp =3D ' Assign_%s_%s_Fdf_Value(Pcd);\n' % (Pcd.TokenSpaceGuidC= Name, Pcd.TokenCName)=0D return CApp=0D =0D + @staticmethod=0D + def GenerateModuleValueStatement(module_guid, Pcd):=0D + CApp =3D " Assign_%s_%s_%s_Value(Pcd);\n" % (Pcd.TokenSpaceGuidCN= ame, Pcd.TokenCName, module_guid)=0D + return CApp=0D + def GenerateModuleScopeInitializeFunc(self,SkuName, Pcd, InitByteValu= e, CApp):=0D + for module_guid in Pcd.PcdFiledValueFromDscComponent:=0D + CApp =3D CApp + 'void\n'=0D + CApp =3D CApp + 'Initialize_%s_%s_%s_%s(\n' % (module_guid, TA= B_DEFAULT_STORES_DEFAULT, Pcd.TokenSpaceGuidCName, Pcd.TokenCName)=0D + CApp =3D CApp + ' void\n'=0D + CApp =3D CApp + ' )\n'=0D + CApp =3D CApp + '{\n'=0D + CApp =3D CApp + ' UINT32 Size;\n'=0D + CApp =3D CApp + ' UINT32 FieldSize;\n'=0D + CApp =3D CApp + ' CHAR8 *Value;\n'=0D + CApp =3D CApp + ' UINT32 OriginalSize;\n'=0D + CApp =3D CApp + ' VOID *OriginalPcd;\n'=0D +=0D + CApp =3D CApp + ' %s *Pcd; // From %s Line %d \n' % (Pc= d.BaseDatumType,Pcd.PkgPath, Pcd.PcdDefineLineNo)=0D +=0D + CApp =3D CApp + '\n'=0D +=0D + PcdDefaultValue =3D StringToArray(Pcd.DefaultValueFromDec.stri= p())=0D + InitByteValue +=3D '%s.%s.%s.%s|%s|%s\n' % (module_guid, TAB_D= EFAULT_STORES_DEFAULT, Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.DatumTy= pe, PcdDefaultValue)=0D + #=0D + # Get current PCD value and size=0D + #=0D + CApp =3D CApp + ' OriginalPcd =3D PcdGetPtr (%s, %s, %s, %s, = &OriginalSize);\n' % (module_guid, TAB_DEFAULT_STORES_DEFAULT, Pcd.TokenSpa= ceGuidCName, Pcd.TokenCName)=0D +=0D + #=0D + # Determine the size of the PCD. For simple structures, sizeo= f(TYPE) provides=0D + # the correct value. For structures with a flexible array mem= ber, the flexible=0D + # array member is detected, and the size is based on the highe= st index used with=0D + # the flexible array member. The flexible array member must b= e the last field=0D + # in a structure. The size formula for this case is:=0D + # OFFSET_OF(FlexbleArrayField) + sizeof(FlexibleArray[0]) * (H= ighestIndex + 1)=0D + #=0D + CApp =3D CApp + DscBuildData.GenerateSizeStatments(Pcd,SkuName= ,TAB_DEFAULT_STORES_DEFAULT)=0D + if Pcd.IsArray() and Pcd.Capacity[-1] !=3D "-1":=0D + CApp =3D CApp + ' OriginalSize =3D OriginalSize < sizeof(= %s) * %d? OriginalSize:sizeof(%s) * %d; \n' % (Pcd.BaseDatumType,Pcd.PcdArr= aySize(),Pcd.BaseDatumType,Pcd.PcdArraySize())=0D + CApp =3D CApp + ' Size =3D sizeof(%s) * %d; \n' % (Pcd.Ba= seDatumType,Pcd.PcdArraySize())=0D +=0D + #=0D + # Allocate and zero buffer for the PCD=0D + # Must handle cases where current value is smaller, larger, or= same size=0D + # Always keep that larger one as the current size=0D + #=0D + CApp =3D CApp + ' Size =3D (OriginalSize > Size ? OriginalSiz= e : Size);\n'=0D + CApp =3D CApp + ' Pcd =3D (%s *)malloc (Size);\n' % (Pcd.= BaseDatumType,)=0D + CApp =3D CApp + ' memset (Pcd, 0, Size);\n'=0D +=0D + #=0D + # Copy current PCD value into allocated buffer.=0D + #=0D + CApp =3D CApp + ' memcpy (Pcd, OriginalPcd, OriginalSize);\n'= =0D +=0D + #=0D + # Assign field values in PCD=0D + #=0D + CApp =3D CApp + DscBuildData.GenerateDefaultValueAssignStateme= nt(Pcd)=0D +=0D + CApp =3D CApp + "// SkuName: %s, DefaultStoreName: STANDARD \= n" % self.SkuIdMgr.SystemSkuId=0D + CApp =3D CApp + DscBuildData.GenerateInitValueStatement(Pcd, s= elf.SkuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT)=0D + CApp =3D CApp + DscBuildData.GenerateModuleValueStatement(modu= le_guid,Pcd)=0D + CApp =3D CApp + DscBuildData.GenerateFdfValueStatement(Pcd)=0D + CApp =3D CApp + DscBuildData.GenerateCommandLineValueStatement= (Pcd)=0D +=0D + #=0D + # Set new PCD value and size=0D + #=0D + CApp =3D CApp + ' PcdSetPtr (%s, %s, %s, %s, Size, (void *)Pc= d);\n' % (module_guid, TAB_DEFAULT_STORES_DEFAULT, Pcd.TokenSpaceGuidCName,= Pcd.TokenCName)=0D +=0D + #=0D + # Free PCD=0D + #=0D + CApp =3D CApp + ' free (Pcd);\n'=0D + CApp =3D CApp + '}\n'=0D + CApp =3D CApp + '\n'=0D + return InitByteValue,CApp=0D +=0D def GenerateInitializeFunc(self, SkuName, DefaultStore, Pcd, InitByteV= alue, CApp):=0D OverrideValues =3D {DefaultStore:{}}=0D if Pcd.SkuOverrideValues:=0D OverrideValues =3D Pcd.SkuOverrideValues[SkuName]=0D if not OverrideValues:=0D @@ -2584,26 +2770,42 @@ class DscBuildData(PlatformBuildClassObject): CApp =3D CApp + '\n'=0D for Pcd in StructuredPcds.values():=0D CApp =3D CApp + self.GenerateArrayAssignment(Pcd)=0D for PcdName in sorted(StructuredPcds.keys()):=0D Pcd =3D StructuredPcds[PcdName]=0D +=0D + #create void void Cal_tocken_cname_Size functions=0D CApp =3D CApp + self.GenerateSizeFunction(Pcd)=0D +=0D + #create void Assign_ functions=0D +=0D + # From DEC=0D CApp =3D CApp + self.GenerateDefaultValueAssignFunction(Pcd)=0D + # From Fdf=0D CApp =3D CApp + self.GenerateFdfValue(Pcd)=0D + # From CommandLine=0D CApp =3D CApp + self.GenerateCommandLineValue(Pcd)=0D +=0D + # From Dsc Global setting=0D if self.SkuOverrideValuesEmpty(Pcd.SkuOverrideValues) or Pcd.T= ype in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],=0D self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODU= LE]]:=0D CApp =3D CApp + self.GenerateInitValueFunction(Pcd, self.S= kuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT)=0D else:=0D for SkuName in self.SkuIdMgr.SkuOverrideOrder():=0D if SkuName not in Pcd.SkuOverrideValues:=0D continue=0D for DefaultStoreName in Pcd.SkuOverrideValues[SkuName]= :=0D CApp =3D CApp + self.GenerateInitValueFunction(Pcd= , SkuName, DefaultStoreName)=0D +=0D + # From Dsc module scope setting=0D + CApp =3D CApp + self.GenerateModuleScopeValue(Pcd)=0D +=0D + #create Initialize_ functions=0D if self.SkuOverrideValuesEmpty(Pcd.SkuOverrideValues) or Pcd.T= ype in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],=0D self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODU= LE]]:=0D InitByteValue, CApp =3D self.GenerateInitializeFunc(self.S= kuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT, Pcd, InitByteValue, CApp)= =0D + InitByteValue, CApp =3D self.GenerateModuleScopeInitializ= eFunc(self.SkuIdMgr.SystemSkuId,Pcd,InitByteValue,CApp)=0D else:=0D for SkuName in self.SkuIdMgr.SkuOverrideOrder():=0D if SkuName not in Pcd.SkuOverrideValues:=0D continue=0D for DefaultStoreName in Pcd.DefaultStoreName:=0D @@ -2616,10 +2818,12 @@ class DscBuildData(PlatformBuildClassObject): CApp =3D CApp + ' )\n'=0D CApp =3D CApp + '{\n'=0D for Pcd in StructuredPcds.values():=0D if self.SkuOverrideValuesEmpty(Pcd.SkuOverrideValues) or Pcd.T= ype in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], self._PCD_TYPE_ST= RING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:=0D CApp =3D CApp + ' Initialize_%s_%s_%s_%s();\n' % (self.Sk= uIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT, Pcd.TokenSpaceGuidCName, Pc= d.TokenCName)=0D + for ModuleGuid in Pcd.PcdFiledValueFromDscComponent:=0D + CApp +=3D " Initialize_%s_%s_%s_%s();\n" % (ModuleGui= d,TAB_DEFAULT_STORES_DEFAULT ,Pcd.TokenSpaceGuidCName, Pcd.TokenCName)=0D else:=0D for SkuName in self.SkuIdMgr.SkuOverrideOrder():=0D if SkuName not in self.SkuIdMgr.AvailableSkuIdSet:=0D continue=0D for DefaultStoreName in Pcd.SkuOverrideValues[SkuName]= :=0D @@ -2631,10 +2835,11 @@ class DscBuildData(PlatformBuildClassObject): if not os.path.exists(self.OutputPath):=0D os.makedirs(self.OutputPath)=0D CAppBaseFileName =3D os.path.join(self.OutputPath, PcdValueInitNam= e)=0D SaveFileOnChange(CAppBaseFileName + '.c', CApp, False)=0D =0D + # start generating makefile=0D MakeApp =3D PcdMakefileHeader=0D if sys.platform =3D=3D "win32":=0D MakeApp =3D MakeApp + 'APPFILE =3D %s\%s.exe\n' % (self.Output= Path, PcdValueInitName) + 'APPNAME =3D %s\n' % (PcdValueInitName) + 'OBJECT= S =3D %s\%s.obj %s.obj\n' % (self.OutputPath, PcdValueInitName, os.path.joi= n(self.OutputPath, PcdValueCommonName)) + 'INC =3D '=0D else:=0D MakeApp =3D MakeApp + PcdGccMakefile=0D @@ -2753,19 +2958,22 @@ class DscBuildData(PlatformBuildClassObject): MakeApp =3D MakeApp + '\tcp -f %s %s/PcdValueCommon.c\n' % (Pc= dValueCommonPath, self.OutputPath)=0D MakeFileName =3D os.path.join(self.OutputPath, 'Makefile')=0D MakeApp +=3D "$(OBJECTS) : %s\n" % MakeFileName=0D SaveFileOnChange(MakeFileName, MakeApp, False)=0D =0D + # start generating input file=0D InputValueFile =3D os.path.join(self.OutputPath, 'Input.txt')=0D OutputValueFile =3D os.path.join(self.OutputPath, 'Output.txt')=0D SaveFileOnChange(InputValueFile, InitByteValue, False)=0D =0D Dest_PcdValueInitExe =3D PcdValueInitName=0D if not sys.platform =3D=3D "win32":=0D Dest_PcdValueInitExe =3D os.path.join(self.OutputPath, PcdValu= eInitName)=0D else:=0D Dest_PcdValueInitExe =3D os.path.join(self.OutputPath, PcdValu= eInitName) +".exe"=0D +=0D + #start building the structure pcd value tool=0D Messages =3D ''=0D if sys.platform =3D=3D "win32":=0D MakeCommand =3D 'nmake -f %s' % (MakeFileName)=0D returncode, StdOut, StdErr =3D DscBuildData.ExecuteCommand (Ma= keCommand)=0D Messages =3D StdOut=0D @@ -2824,17 +3032,19 @@ class DscBuildData(PlatformBuildClassObject): if MessageGroup:=0D EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "\n".joi= n(MessageGroup) )=0D else:=0D EdkLogger.error('Build', COMMAND_FAILURE, 'Can not execute= command: %s\n%s\n%s' % (MakeCommand, StdOut, StdErr))=0D =0D + #start executing the structure pcd value tool=0D if DscBuildData.NeedUpdateOutput(OutputValueFile, Dest_PcdValueIni= tExe, InputValueFile):=0D Command =3D Dest_PcdValueInitExe + ' -i %s -o %s' % (InputValu= eFile, OutputValueFile)=0D returncode, StdOut, StdErr =3D DscBuildData.ExecuteCommand (Co= mmand)=0D EdkLogger.verbose ('%s\n%s\n%s' % (Command, StdOut, StdErr))=0D if returncode !=3D 0:=0D EdkLogger.warn('Build', COMMAND_FAILURE, 'Can not collect = output from command: %s\n%s\n' % (Command, StdOut, StdErr))=0D =0D + #start update structure pcd final value=0D File =3D open (OutputValueFile, 'r')=0D FileBuffer =3D File.readlines()=0D File.close()=0D =0D StructurePcdSet =3D []=0D diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Sourc= e/Python/build/BuildReport.py index 8efa869162..a95bb36811 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -694,11 +694,11 @@ class ModuleReport(object): FileWrite(File, "PCI Class Code: %s" % self.PciClassCode= )=0D =0D FileWrite(File, gSectionSep)=0D =0D if "PCD" in ReportType:=0D - GlobalPcdReport.GenerateReport(File, self.ModulePcdSet)=0D + GlobalPcdReport.GenerateReport(File, self.ModulePcdSet,self.Fi= leGuid)=0D =0D if "LIBRARY" in ReportType:=0D self.LibraryReport.GenerateReport(File)=0D =0D if "DEPEX" in ReportType:=0D @@ -879,11 +879,11 @@ class PcdReport(object): for (TokenCName, TokenSpaceGuidCName) in Pa.Platform.Pcds:=0D DscDefaultValue =3D Pa.Platform.Pcds[(TokenCName, TokenSpa= ceGuidCName)].DscDefaultValue=0D if DscDefaultValue:=0D self.DscPcdDefault[(TokenCName, TokenSpaceGuidCName)] = =3D DscDefaultValue=0D =0D - def GenerateReport(self, File, ModulePcdSet):=0D + def GenerateReport(self, File, ModulePcdSet,ModuleGuid=3DNone):=0D if not ModulePcdSet:=0D if self.ConditionalPcds:=0D self.GenerateReportDetail(File, ModulePcdSet, 1)=0D if self.UnusedPcds:=0D IsEmpty =3D True=0D @@ -895,11 +895,11 @@ class PcdReport(object): break=0D if not IsEmpty:=0D break=0D if not IsEmpty:=0D self.GenerateReportDetail(File, ModulePcdSet, 2)=0D - self.GenerateReportDetail(File, ModulePcdSet)=0D + self.GenerateReportDetail(File, ModulePcdSet,ModuleGuid =3D Module= Guid)=0D =0D ##=0D # Generate report for PCD information=0D #=0D # This function generates report for separate module expression=0D @@ -911,11 +911,11 @@ class PcdReport(object): # platform PCD report=0D # @param ReportySubType 0 means platform/module PCD report, 1 means C= onditional=0D # directives section report, 2 means Unused Pcd= s section report=0D # @param DscOverridePcds Module DSC override PCDs set=0D #=0D - def GenerateReportDetail(self, File, ModulePcdSet, ReportSubType =3D 0= ):=0D + def GenerateReportDetail(self, File, ModulePcdSet, ReportSubType =3D 0= ,ModuleGuid=3DNone):=0D PcdDict =3D self.AllPcds=0D if ReportSubType =3D=3D 1:=0D PcdDict =3D self.ConditionalPcds=0D elif ReportSubType =3D=3D 2:=0D PcdDict =3D self.UnusedPcds=0D @@ -991,14 +991,16 @@ class PcdReport(object): if DscDefaultValue:=0D PcdValue =3D DscDefaultValue=0D #The DefaultValue of StructurePcd already be the latest, n= o need to update.=0D if not self.IsStructurePcd(Pcd.TokenCName, Pcd.TokenSpaceG= uidCName):=0D Pcd.DefaultValue =3D PcdValue=0D + PcdComponentValue =3D None=0D if ModulePcdSet is not None:=0D if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type) not= in ModulePcdSet:=0D continue=0D - InfDefaultValue, PcdValue =3D ModulePcdSet[Pcd.TokenCN= ame, Pcd.TokenSpaceGuidCName, Type]=0D + InfDefaultValue, PcdComponentValue =3D ModulePcdSet[Pc= d.TokenCName, Pcd.TokenSpaceGuidCName, Type]=0D + PcdValue =3D PcdComponentValue=0D #The DefaultValue of StructurePcd already be the lates= t, no need to update.=0D if not self.IsStructurePcd(Pcd.TokenCName, Pcd.TokenSp= aceGuidCName):=0D Pcd.DefaultValue =3D PcdValue=0D if InfDefaultValue:=0D try:=0D @@ -1079,62 +1081,72 @@ class PcdReport(object): if self.IsStructurePcd(Pcd.TokenCName, Pcd.TokenSpaceGuidC= Name):=0D IsStructure =3D True=0D if TypeName in ('DYNVPD', 'DEXVPD'):=0D SkuInfoList =3D Pcd.SkuInfoList=0D Pcd =3D GlobalData.gStructurePcd[self.Arch][(Pcd.Token= CName, Pcd.TokenSpaceGuidCName)]=0D + if ModulePcdSet and ModulePcdSet.get((Pcd.TokenCName, = Pcd.TokenSpaceGuidCName, Type)):=0D + InfDefaultValue, PcdComponentValue =3D ModulePcdSe= t[Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type]=0D + DscDefaultValBak =3D Pcd.DefaultValue=0D + Pcd.DefaultValue =3D PcdComponentValue=0D +=0D Pcd.DatumType =3D Pcd.StructName=0D if TypeName in ('DYNVPD', 'DEXVPD'):=0D Pcd.SkuInfoList =3D SkuInfoList=0D if Pcd.PcdValueFromComm or Pcd.PcdFieldValueFromComm:= =0D BuildOptionMatch =3D True=0D DecMatch =3D False=0D elif Pcd.PcdValueFromFdf or Pcd.PcdFieldValueFromFdf:= =0D DscDefaultValue =3D True=0D DscMatch =3D True=0D DecMatch =3D False=0D - elif Pcd.SkuOverrideValues:=0D - DscOverride =3D False=0D - if Pcd.DefaultFromDSC:=0D - DscOverride =3D True=0D - else:=0D - DictLen =3D 0=0D - for item in Pcd.SkuOverrideValues:=0D - DictLen +=3D len(Pcd.SkuOverrideValues[ite= m])=0D - if not DictLen:=0D - DscOverride =3D False=0D + else:=0D + if Pcd.Type in PCD_DYNAMIC_TYPE_SET | PCD_DYNAMIC_= EX_TYPE_SET:=0D + DscOverride =3D False=0D + if Pcd.DefaultFromDSC:=0D + DscOverride =3D True=0D else:=0D - if not Pcd.SkuInfoList:=0D - OverrideValues =3D Pcd.SkuOverrideValu= es=0D - if OverrideValues:=0D - for Data in OverrideValues.values(= ):=0D - Struct =3D list(Data.values())= =0D - if Struct:=0D - DscOverride =3D self.Parse= Struct(Struct[0])=0D - break=0D + DictLen =3D 0=0D + for item in Pcd.SkuOverrideValues:=0D + DictLen +=3D len(Pcd.SkuOverrideValues= [item])=0D + if not DictLen:=0D + DscOverride =3D False=0D else:=0D - SkuList =3D sorted(Pcd.SkuInfoList.key= s())=0D - for Sku in SkuList:=0D - SkuInfo =3D Pcd.SkuInfoList[Sku]=0D - if SkuInfo.DefaultStoreDict:=0D - DefaultStoreList =3D sorted(Sk= uInfo.DefaultStoreDict.keys())=0D - for DefaultStore in DefaultSto= reList:=0D - OverrideValues =3D Pcd.Sku= OverrideValues[Sku]=0D - DscOverride =3D self.Parse= Struct(OverrideValues[DefaultStore])=0D - if DscOverride:=0D + if not Pcd.SkuInfoList:=0D + OverrideValues =3D Pcd.SkuOverride= Values=0D + if OverrideValues:=0D + for Data in OverrideValues.val= ues():=0D + Struct =3D list(Data.value= s())=0D + if Struct:=0D + DscOverride =3D self.P= arseStruct(Struct[0])=0D break=0D - if DscOverride:=0D - break=0D - if DscOverride:=0D - DscDefaultValue =3D True=0D - DscMatch =3D True=0D - DecMatch =3D False=0D + else:=0D + SkuList =3D sorted(Pcd.SkuInfoList= .keys())=0D + for Sku in SkuList:=0D + SkuInfo =3D Pcd.SkuInfoList[Sk= u]=0D + if SkuInfo.DefaultStoreDict:=0D + DefaultStoreList =3D sorte= d(SkuInfo.DefaultStoreDict.keys())=0D + for DefaultStore in Defaul= tStoreList:=0D + OverrideValues =3D Pcd= .SkuOverrideValues[Sku]=0D + DscOverride =3D self.P= arseStruct(OverrideValues[DefaultStore])=0D + if DscOverride:=0D + break=0D + if DscOverride:=0D + break=0D + if DscOverride:=0D + DscDefaultValue =3D True=0D + DscMatch =3D True=0D + DecMatch =3D False=0D + else:=0D + DecMatch =3D True=0D else:=0D - DecMatch =3D True=0D - else:=0D - DscDefaultValue =3D True=0D - DscMatch =3D True=0D - DecMatch =3D False=0D + if Pcd.DscRawValue or (ModuleGuid and ModuleGu= id.replace("-","S") in Pcd.PcdValueFromComponents):=0D + DscDefaultValue =3D True=0D + DscMatch =3D True=0D + DecMatch =3D False=0D + else:=0D + DscDefaultValue =3D False=0D + DecMatch =3D True=0D =0D #=0D # Report PCD item according to their override relationship= =0D #=0D if Pcd.DatumType =3D=3D 'BOOLEAN':=0D @@ -1151,17 +1163,18 @@ class PcdReport(object): elif InfDefaultValue and InfMatch:=0D self.PrintPcdValue(File, Pcd, PcdTokenCName, TypeName,= IsStructure, DscMatch, DscDefaultValBak, InfMatch, InfDefaultValue, DecMat= ch, DecDefaultValue, '*M')=0D elif BuildOptionMatch:=0D self.PrintPcdValue(File, Pcd, PcdTokenCName, TypeName,= IsStructure, DscMatch, DscDefaultValBak, InfMatch, InfDefaultValue, DecMat= ch, DecDefaultValue, '*B')=0D else:=0D - if DscDefaultValue and DscMatch:=0D + if PcdComponentValue:=0D + self.PrintPcdValue(File, Pcd, PcdTokenCName, TypeN= ame, IsStructure, DscMatch, DscDefaultValBak, InfMatch, PcdComponentValue, = DecMatch, DecDefaultValue, '*M', ModuleGuid)=0D + elif DscDefaultValue and DscMatch:=0D if (Pcd.TokenCName, Key, Field) in self.FdfPcdSet:= =0D self.PrintPcdValue(File, Pcd, PcdTokenCName, T= ypeName, IsStructure, DscMatch, DscDefaultValBak, InfMatch, InfDefaultValue= , DecMatch, DecDefaultValue, '*F')=0D else:=0D self.PrintPcdValue(File, Pcd, PcdTokenCName, T= ypeName, IsStructure, DscMatch, DscDefaultValBak, InfMatch, InfDefaultValue= , DecMatch, DecDefaultValue, '*P')=0D - else:=0D - self.PrintPcdValue(File, Pcd, PcdTokenCName, TypeN= ame, IsStructure, DscMatch, DscDefaultValBak, InfMatch, InfDefaultValue, De= cMatch, DecDefaultValue, '*M')=0D +=0D =0D if ModulePcdSet is None:=0D if IsStructure:=0D continue=0D if not TypeName in ('PATCH', 'FLAG', 'FIXED'):=0D @@ -1263,11 +1276,11 @@ class PcdReport(object): self.PrintStructureInfo(File, filedvalues)=0D if DecMatch and IsStructure:=0D for filedvalues in Pcd.DefaultValues.values():=0D self.PrintStructureInfo(File, filedvalues)=0D =0D - def PrintPcdValue(self, File, Pcd, PcdTokenCName, TypeName, IsStructur= e, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, DecDefau= ltValue, Flag =3D ' '):=0D + def PrintPcdValue(self, File, Pcd, PcdTokenCName, TypeName, IsStructur= e, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, DecDefau= ltValue, Flag =3D ' ',ModuleGuid=3DNone):=0D if not Pcd.SkuInfoList:=0D Value =3D Pcd.DefaultValue=0D IsByteArray, ArrayList =3D ByteArrayForamt(Value)=0D if IsByteArray:=0D FileWrite(File, ' %-*s : %6s %10s =3D %s' % (self.MaxLen= , Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', '{'))=0D @@ -1286,18 +1299,24 @@ class PcdReport(object): FiledOverrideFlag =3D False=0D if (Pcd.TokenCName,Pcd.TokenSpaceGuidCName) in GlobalData.= gPcdSkuOverrides:=0D OverrideValues =3D GlobalData.gPcdSkuOverrides[(Pcd.To= kenCName,Pcd.TokenSpaceGuidCName)]=0D else:=0D OverrideValues =3D Pcd.SkuOverrideValues=0D + FieldOverrideValues =3D None=0D if OverrideValues:=0D for Data in OverrideValues.values():=0D Struct =3D list(Data.values())=0D if Struct:=0D - OverrideFieldStruct =3D self.OverrideFieldValu= e(Pcd, Struct[0])=0D - self.PrintStructureInfo(File, OverrideFieldStr= uct)=0D + FieldOverrideValues =3D Struct[0]=0D FiledOverrideFlag =3D True=0D break=0D + if Pcd.PcdFiledValueFromDscComponent and ModuleGuid and Mo= duleGuid.replace("-","S") in Pcd.PcdFiledValueFromDscComponent:=0D + FieldOverrideValues =3D Pcd.PcdFiledValueFromDscCompon= ent[ModuleGuid.replace("-","S")]=0D + if FieldOverrideValues:=0D + OverrideFieldStruct =3D self.OverrideFieldValue(Pcd, F= ieldOverrideValues)=0D + self.PrintStructureInfo(File, OverrideFieldStruct)=0D +=0D if not FiledOverrideFlag and (Pcd.PcdFieldValueFromComm or= Pcd.PcdFieldValueFromFdf):=0D OverrideFieldStruct =3D self.OverrideFieldValue(Pcd, {= })=0D self.PrintStructureInfo(File, OverrideFieldStruct)=0D self.PrintPcdDefault(File, Pcd, IsStructure, DscMatch, DscDefa= ultValue, InfMatch, InfDefaultValue, DecMatch, DecDefaultValue)=0D else:=0D --=20 2.29.1.windows.1