From nobody Fri Nov 1 10:32:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1517388566968968.7937133905385; Wed, 31 Jan 2018 00:49:26 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0D0442222C229; Wed, 31 Jan 2018 00:43:46 -0800 (PST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 C40F02215BD87 for ; Wed, 31 Jan 2018 00:43:44 -0800 (PST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Jan 2018 00:49:19 -0800 Received: from shwdeopenpsi105.ccr.corp.intel.com ([10.239.9.129]) by orsmga003.jf.intel.com with ESMTP; 31 Jan 2018 00:49:18 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=bob.c.feng@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,438,1511856000"; d="scan'208";a="23608492" From: BobCF To: edk2-devel@lists.01.org Date: Wed, 31 Jan 2018 16:49:14 +0800 Message-Id: <20180131084914.12604-1-bob.c.feng@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 Subject: [edk2] [Patch] BaseTools: Structure Pcd in CommandLine. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao Reviewed-by: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py | 110 +++--------- BaseTools/Source/Python/Common/Expression.py | 2 +- BaseTools/Source/Python/Common/Misc.py | 2 +- BaseTools/Source/Python/GenFds/FfsInfStatement.py | 1 + BaseTools/Source/Python/GenFds/GenFds.py | 4 +- BaseTools/Source/Python/Workspace/DscBuildData.py | 210 ++++++++++++++++++= +++- BaseTools/Source/Python/build/build.py | 2 +- 7 files changed, 233 insertions(+), 98 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/= Python/AutoGen/AutoGen.py index 1cf50e872f..405bfa145a 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -396,100 +396,22 @@ class WorkspaceAutoGen(AutoGen): =20 # apply SKU and inject PCDs from Flash Definition file for Arch in self.ArchList: Platform =3D self.BuildDatabase[self.MetaFile, Arch, Target, T= oolchain] =20 - DecPcds =3D {} - DecPcdsKey =3D set() - PGen =3D PlatformAutoGen(self, self.MetaFile, Target, Toolchai= n, Arch) - if GlobalData.BuildOptionPcd: - for i, pcd in enumerate(GlobalData.BuildOptionPcd): - if type(pcd) is tuple: - continue - (pcdname, pcdvalue) =3D pcd.split('=3D') - if not pcdvalue: - EdkLogger.error('build', AUTOGEN_ERROR, "No Value = specified for the PCD %s." % (pcdname)) - if '.' in pcdname: - (TokenSpaceGuidCName, TokenCName) =3D pcdname.spli= t('.') - HasTokenSpace =3D True - else: - TokenCName =3D pcdname - TokenSpaceGuidCName =3D '' - HasTokenSpace =3D False - TokenSpaceGuidCNameList =3D [] - FoundFlag =3D False - PcdDatumType =3D '' - NewValue =3D '' - for package in PGen.PackageList: - Guids =3D package.Guids - self._GuidDict.update(Guids) - for package in PGen.PackageList: - for key in package.Pcds: - PcdItem =3D package.Pcds[key] - if HasTokenSpace: - if (PcdItem.TokenCName, PcdItem.TokenSpace= GuidCName) =3D=3D (TokenCName, TokenSpaceGuidCName): - PcdDatumType =3D PcdItem.DatumType - if pcdvalue.startswith('H'): - try: - pcdvalue =3D ValueExpressionEx= (pcdvalue[1:], PcdDatumType, self._GuidDict)(True) - except BadExpression, Value: - if Value.result > 1: - EdkLogger.error('Parser', = FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' % - (TokenSpac= eGuidCName, TokenCName, pcdvalue, Value)) - pcdvalue =3D 'H' + pcdvalue - NewValue =3D BuildOptionPcdValueFormat= (TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue) - FoundFlag =3D True - else: - if PcdItem.TokenCName =3D=3D TokenCName: - if not PcdItem.TokenSpaceGuidCName in = TokenSpaceGuidCNameList: - if len (TokenSpaceGuidCNameList) <= 1: - TokenSpaceGuidCNameList.append= (PcdItem.TokenSpaceGuidCName) - PcdDatumType =3D PcdItem.Datum= Type - TokenSpaceGuidCName =3D PcdIte= m.TokenSpaceGuidCName - if pcdvalue.startswith('H'): - try: - pcdvalue =3D ValueExpr= essionEx(pcdvalue[1:], PcdDatumType, self._GuidDict)(True) - except BadExpression, Valu= e: - EdkLogger.error('Parse= r', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' % - (Token= SpaceGuidCName, TokenCName, pcdvalue, Value)) - pcdvalue =3D 'H' + pcdvalue - NewValue =3D BuildOptionPcdVal= ueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue) - FoundFlag =3D True - else: - EdkLogger.error( - 'build', - AUTOGEN_ERROR, - "The Pcd %s is found u= nder multiple different TokenSpaceGuid: %s and %s." % (TokenCName, PcdItem.= TokenSpaceGuidCName, TokenSpaceGuidCNameList[0]) - ) =20 - GlobalData.BuildOptionPcd[i] =3D (TokenSpaceGuidCName,= TokenCName, NewValue) =20 - if not FoundFlag: - if HasTokenSpace: - EdkLogger.error('build', AUTOGEN_ERROR, "The P= cd %s.%s is not found in the DEC file." % (TokenSpaceGuidCName, TokenCName)) - else: - EdkLogger.error('build', AUTOGEN_ERROR, "The P= cd %s is not found in the DEC file." % (TokenCName)) =20 - for BuildData in PGen.BuildDatabase._CACHE_.values(): - if BuildData.Arch !=3D Arch: - continue - if BuildData.MetaFile.Ext =3D=3D '.dec': - continue - for key in BuildData.Pcds: - PcdItem =3D BuildData.Pcds[key] - if (TokenSpaceGuidCName, TokenCName) =3D=3D (P= cdItem.TokenSpaceGuidCName, PcdItem.TokenCName): - PcdItem.DefaultValue =3D NewValue =20 - if (TokenCName, TokenSpaceGuidCName) in PcdSet: - PcdSet[(TokenCName, TokenSpaceGuidCName)] =3D NewV= alue =20 SourcePcdDict =3D {'DynamicEx':[], 'PatchableInModule':[],'Dyn= amic':[],'FixedAtBuild':[]} BinaryPcdDict =3D {'DynamicEx':[], 'PatchableInModule':[]} SourcePcdDict_Keys =3D SourcePcdDict.keys() BinaryPcdDict_Keys =3D BinaryPcdDict.keys() =20 # generate the SourcePcdDict and BinaryPcdDict + PGen =3D PlatformAutoGen(self, self.MetaFile, Target, Toolchai= n, Arch) for BuildData in PGen.BuildDatabase._CACHE_.values(): if BuildData.Arch !=3D Arch: continue if BuildData.MetaFile.Ext =3D=3D '.inf': for key in BuildData.Pcds: @@ -628,10 +550,12 @@ class WorkspaceAutoGen(AutoGen): if ModuleFile in Platform.Modules: continue ModuleData =3D self.BuildDatabase[ModuleFile, Arch, Target= , Toolchain] PkgSet.update(ModuleData.Packages) Pkgs =3D list(PkgSet) + list(PGen.PackageList) + DecPcds =3D {} + DecPcdsKey =3D set() for Pkg in Pkgs: for Pcd in Pkg.Pcds: DecPcds[Pcd[0], Pcd[1]] =3D Pkg.Pcds[Pcd] DecPcdsKey.add((Pcd[0], Pcd[1], Pcd[2])) =20 @@ -1444,19 +1368,29 @@ class PlatformAutoGen(AutoGen): # This interface should be invoked explicitly when platform action is= created. # def CollectPlatformDynamicPcds(self): # Override the platform Pcd's value by build option if GlobalData.BuildOptionPcd: - for key in self.Platform.Pcds: - PlatformPcd =3D self.Platform.Pcds[key] - for PcdItem in GlobalData.BuildOptionPcd: - if (PlatformPcd.TokenSpaceGuidCName, PlatformPcd.Token= CName) =3D=3D (PcdItem[0], PcdItem[1]): - PlatformPcd.DefaultValue =3D PcdItem[2] - if PlatformPcd.SkuInfoList: - Sku =3D PlatformPcd.SkuInfoList[PlatformPcd.Sk= uInfoList.keys()[0]] - Sku.DefaultValue =3D PcdItem[2] - break + for PcdItem in GlobalData.BuildOptionPcd: + PlatformPcd =3D self.Platform.Pcds.get((PcdItem[1],PcdItem= [0])) + if PlatformPcd: + if PlatformPcd.DatumType in [TAB_UINT8, TAB_UINT16, TA= B_UINT32, TAB_UINT64,'BOOLEAN']: + for sku in PlatformPcd.SkuInfoList: + PlatformPcd.SkuInfoList[sku].DefaultValue =3D = PcdItem[2] + else: + PcdDefaultValue =3D StringToArray(PcdItem[2]) + for sku in PlatformPcd.SkuInfoList: + skuinfo =3D PlatformPcd.SkuInfoList[sku] + if skuinfo.VariableGuid: + skuinfo.HiiDefaultValue =3D PcdDefaultValue + else: + skuinfo.DefaultValue =3D PcdDefaultValue + PlatformPcd.DefaultValue =3D PcdDefaultValue + if PlatformPcd.MaxDatumSize: + PlatformPcd.MaxDatumSize =3D str(max([int(Plat= formPcd.MaxDatumSize),len(PcdDefaultValue.split(","))])) + else: + PlatformPcd.MaxDatumSize =3D str(len(PcdDefaul= tValue.split(","))) =20 for key in self.Platform.Pcds: for SinglePcd in GlobalData.MixedPcd: if (self.Platform.Pcds[key].TokenCName, self.Platform.Pcds= [key].TokenSpaceGuidCName) =3D=3D SinglePcd: for item in GlobalData.MixedPcd[SinglePcd]: diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Sourc= e/Python/Common/Expression.py index 486c537029..b8c48460ff 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -789,11 +789,11 @@ class ValueExpressionEx(ValueExpression): raise BadExpression('Type %s PCD Value Size is Larger = than 2 byte' % self.PcdType) if self.PcdType =3D=3D 'UINT32' and Size > 4: raise BadExpression('Type %s PCD Value Size is Larger = than 4 byte' % self.PcdType) if self.PcdType =3D=3D 'UINT64' and Size > 8: raise BadExpression('Type %s PCD Value Size is Larger = than 8 byte' % self.PcdType) - if self.PcdType in ['VOID*']: + else: try: TmpValue =3D long(PcdValue) TmpList =3D [] if TmpValue.bit_length() =3D=3D 0: PcdValue =3D '{0x00}' diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Pyth= on/Common/Misc.py index a8ed718aa5..5d2bc40275 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -2346,11 +2346,11 @@ def PackRegistryFormatGuid(Guid): int(Guid[4][-4:-2], 16), int(Guid[4][-2:], 16) ) =20 def BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumTyp= e, Value): - if PcdDatumType =3D=3D 'VOID*': + if PcdDatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64,= 'BOOLEAN']: if Value.startswith('L'): if not Value[1]: EdkLogger.error("build", FORMAT_INVALID, 'For Void* type P= CD, when specify the Value in the command line, please use the following fo= rmat: "string", L"string", H"{...}"') Value =3D Value[0] + '"' + Value[1:] + '"' elif Value.startswith('H'): diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/= Source/Python/GenFds/FfsInfStatement.py index baee543698..b0b242be8d 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -235,10 +235,11 @@ class FfsInfStatement(FfsInfStatementClassObject): =20 self.PatchPcds =3D [] InfPcds =3D Inf.Pcds Platform =3D GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlob= alVariable.ActivePlatform, self.CurrentArch, GenFdsGlobalVariable.TargetNam= e, GenFdsGlobalVariable.ToolChainTag] FdfPcdDict =3D GenFdsGlobalVariable.FdfParser.Profile.PcdDict + PlatformPcds =3D Platform.Pcds =20 # Workaround here: both build and GenFds tool convert the workspac= e path to lower case # But INF file path in FDF and DSC file may have real case charact= ers. # Try to convert the path to lower case to see if PCDs value are o= verride by DSC. DscModules =3D {} diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Py= thon/GenFds/GenFds.py index 4a5d6f476a..dcba9f24cb 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -300,13 +300,11 @@ def main(): =20 GenFdsGlobalVariable.WorkSpace =3D BuildWorkSpace if ArchList !=3D None: GenFdsGlobalVariable.ArchList =3D ArchList =20 - if Options.OptionPcd: - GlobalData.BuildOptionPcd =3D Options.OptionPcd - CheckBuildOptionPcd() + # Dsc Build Data will handle Pcd Settings from CommandLine. =20 """Modify images from build output if the feature of loading drive= r at fixed address is on.""" if GenFdsGlobalVariable.FixedLoadAddress: GenFds.PreprocessImage(BuildWorkSpace, GenFdsGlobalVariable.Ac= tivePlatform) =20 diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/= Source/Python/Workspace/DscBuildData.py index 012e16a488..2bdeb1e4f1 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -160,11 +160,10 @@ class DscBuildData(PlatformBuildClassObject): self.OutputPath =3D os.path.join(os.getenv("WORKSPACE"), 'Buil= d', PcdValueInitName) else: self.OutputPath =3D os.path.dirname(self.DscFile) self.DefaultStores =3D None self.SkuIdMgr =3D SkuClass(self.SkuName, self.SkuIds) - arraystr =3D self.SkuIdMgr.DumpSkuIdArrary() =20 ## XXX[key] =3D value def __setitem__(self, key, value): self.__dict__[self._PROPERTY_[key]] =3D value =20 @@ -449,11 +448,10 @@ class DscBuildData(PlatformBuildClassObject): return self._SkuName =20 ## Override SKUID_IDENTIFIER def _SetSkuName(self, Value): self._SkuName =3D Value - self._Pcds =3D None =20 def _GetFdfFile(self): if self._FlashDefinition =3D=3D None: if self._Header =3D=3D None: self._GetHeaderInfo() @@ -887,14 +885,168 @@ class DscBuildData(PlatformBuildClassObject): PcdDefaultStoreSet =3D set([defaultstorename for defa= ultstorename in skuobj.DefaultStoreDict]) mindefaultstorename =3D DefaultStoreMgr.GetMin(PcdDefa= ultStoreSet) skuobj.DefaultStoreDict['STANDARD'] =3D copy.deepcopy(= skuobj.DefaultStoreDict[mindefaultstorename]) return Pcds =20 + def RecoverCommandLinePcd(self): + pcdset =3D [] + if GlobalData.BuildOptionPcd: + for pcd in GlobalData.BuildOptionPcd: + if pcd[2] =3D=3D "": + pcdset.append((pcd[0],pcd[1],pcd[3])) + else: + pcdobj =3D self._Pcds.get((pcd[1],pcd[0])) + if pcdobj: + pcdset.append((pcd[0],pcd[1], pcdobj.DefaultValue)) + else: + pcdset.append((pcd[0],pcd[1],pcd[3])) + GlobalData.BuildOptionPcd =3D pcdset + def GetFieldValueFromComm(self,ValueStr,TokenSpaceGuidCName, TokenCNam= e, FieldName): + PredictedFieldType =3D "VOID*" + if ValueStr.startswith('L'): + if not ValueStr[1]: + EdkLogger.error("build", FORMAT_INVALID, 'For Void* type P= CD, when specify the Value in the command line, please use the following fo= rmat: "string", L"string", H"{...}"') + ValueStr =3D ValueStr[0] + '"' + ValueStr[1:] + '"' + PredictedFieldType =3D "VOID*" + elif ValueStr.startswith('H') or ValueStr.startswith('{'): + EdkLogger.error("build", FORMAT_INVALID, 'Currently we do not = support assign H"{...}" format for Pcd field.', ExtraData=3D"%s.%s.%s from = command line" % (TokenSpaceGuidCName, TokenCName, FieldName)) + ValueStr =3D ValueStr[1:] + PredictedFieldType =3D "VOID*" + elif ValueStr.upper() in ['TRUE', '0X1', '0X01', '1', 'FALSE', '0X= 0', '0X00', '0']: + PredictedFieldType =3D "BOOLEAN" + elif ValueStr.isdigit() or ValueStr.upper().startswith('0X'): + PredictedFieldType =3D TAB_UINT16 + else: + if not ValueStr[0]: + EdkLogger.error("build", FORMAT_INVALID, 'For Void* type P= CD, when specify the Value in the command line, please use the following fo= rmat: "string", L"string", H"{...}"') + ValueStr =3D '"' + ValueStr + '"' + PredictedFieldType =3D "VOID*" + IsValid, Cause =3D CheckPcdDatum(PredictedFieldType, ValueStr) + if not IsValid: + EdkLogger.error("build", FORMAT_INVALID, Cause, ExtraData=3D"%= s.%s.%s from command line" % (TokenSpaceGuidCName, TokenCName, FieldName)) + if PredictedFieldType =3D=3D 'BOOLEAN': + ValueStr =3D ValueStr.upper() + if ValueStr =3D=3D 'TRUE' or ValueStr =3D=3D '1': + ValueStr =3D '1' + elif ValueStr =3D=3D 'FALSE' or ValueStr =3D=3D '0': + ValueStr =3D '0' + return ValueStr + def __ParsePcdFromCommandLine(self): + if GlobalData.BuildOptionPcd: + for i, pcd in enumerate(GlobalData.BuildOptionPcd): + if type(pcd) is tuple: + continue + (pcdname, pcdvalue) =3D pcd.split('=3D') + if not pcdvalue: + EdkLogger.error('build', AUTOGEN_ERROR, "No Value spec= ified for the PCD %s." % (pcdname)) + if '.' in pcdname: + (Name1, Name2) =3D pcdname.split('.',1) + if "." in Name2: + (Name3, FieldName) =3D Name2.split(".",1) + if ((Name3,Name1)) in self.DecPcds: + HasTokenSpace =3D True + TokenCName =3D Name3 + TokenSpaceGuidCName =3D Name1 + else: + FieldName =3D Name2 + TokenCName =3D Name1 + TokenSpaceGuidCName =3D '' + HasTokenSpace =3D False + else: + if ((Name2,Name1)) in self.DecPcds: + HasTokenSpace =3D True + TokenCName =3D Name2 + TokenSpaceGuidCName =3D Name1 + FieldName =3D"" + else: + FieldName =3D Name2 + TokenCName =3D Name1 + TokenSpaceGuidCName =3D '' + HasTokenSpace =3D False + else: + FieldName =3D "" + TokenCName =3D pcdname + TokenSpaceGuidCName =3D '' + HasTokenSpace =3D False + TokenSpaceGuidCNameList =3D [] + FoundFlag =3D False + PcdDatumType =3D '' + NewValue =3D '' + if not HasTokenSpace: + for key in self.DecPcds: + if TokenCName =3D=3D key[0]: + if TokenSpaceGuidCName: + EdkLogger.error( + 'build', + AUTOGEN_ERROR, + "The Pcd %s is found under= multiple different TokenSpaceGuid: %s and %s." % (TokenCName, TokenSpaceGu= idCName, key[1]) + ) + else: + TokenSpaceGuidCName =3D key[1] + FoundFlag =3D True + else: + if (TokenCName, TokenSpaceGuidCName) in self.DecPcds: + FoundFlag =3D True + if FieldName: + NewValue =3D self.GetFieldValueFromComm(pcdvalue, Toke= nSpaceGuidCName, TokenCName, FieldName) + GlobalData.BuildOptionPcd[i] =3D (TokenSpaceGuidCName,= TokenCName, FieldName,NewValue,("build command options",1)) + else: + for key in self.DecPcds: + PcdItem =3D self.DecPcds[key] + if HasTokenSpace: + if (PcdItem.TokenCName, PcdItem.TokenSpaceGuid= CName) =3D=3D (TokenCName, TokenSpaceGuidCName): + PcdDatumType =3D PcdItem.DatumType + if pcdvalue.startswith('H'): + try: + pcdvalue =3D ValueExpressionEx(pcd= value[1:], PcdDatumType, self._GuidDict)(True) + except BadExpression, Value: + if Value.result > 1: + EdkLogger.error('Parser', FORM= AT_INVALID, 'PCD [%s.%s] Value "%s", %s' % + (TokenSpaceGui= dCName, TokenCName, pcdvalue, Value)) + pcdvalue =3D 'H' + pcdvalue + NewValue =3D BuildOptionPcdValueFormat(Tok= enSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue) + FoundFlag =3D True + else: + if PcdItem.TokenCName =3D=3D TokenCName: + if not PcdItem.TokenSpaceGuidCName in Toke= nSpaceGuidCNameList: + if len (TokenSpaceGuidCNameList) < 1: + TokenSpaceGuidCNameList.append(Pcd= Item.TokenSpaceGuidCName) + PcdDatumType =3D PcdItem.DatumType + TokenSpaceGuidCName =3D PcdItem.To= kenSpaceGuidCName + if pcdvalue.startswith('H'): + try: + pcdvalue =3D ValueExpressi= onEx(pcdvalue[1:], PcdDatumType, self._GuidDict)(True) + except BadExpression, Value: + EdkLogger.error('Parser', = FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' % + (TokenSpac= eGuidCName, TokenCName, pcdvalue, Value)) + pcdvalue =3D 'H' + pcdvalue + NewValue =3D BuildOptionPcdValueFo= rmat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue) + FoundFlag =3D True + else: + EdkLogger.error( + 'build', + AUTOGEN_ERROR, + "The Pcd %s is found under= multiple different TokenSpaceGuid: %s and %s." % (TokenCName, PcdItem.Toke= nSpaceGuidCName, TokenSpaceGuidCNameList[0]) + ) + GlobalData.BuildOptionPcd[i] =3D (TokenSpaceGuidCName,= TokenCName, FieldName,NewValue,("build command options",1)) + if not FoundFlag: + if HasTokenSpace: + EdkLogger.error('build', AUTOGEN_ERROR, "The Pcd %= s.%s is not found in the DEC file." % (TokenSpaceGuidCName, TokenCName)) + else: + EdkLogger.error('build', AUTOGEN_ERROR, "The Pcd %= s is not found in the DEC file." % (TokenCName)) + for BuildData in self._Bdb._CACHE_.values(): + if BuildData.MetaFile.Ext =3D=3D '.dec' or BuildData.M= etaFile.Ext =3D=3D '.dsc': + continue + for key in BuildData.Pcds: + PcdItem =3D BuildData.Pcds[key] + if (TokenSpaceGuidCName, TokenCName) =3D=3D (PcdIt= em.TokenSpaceGuidCName, PcdItem.TokenCName) and FieldName =3D=3D"": + PcdItem.DefaultValue =3D NewValue ## Retrieve all PCD settings in platform def _GetPcds(self): if self._Pcds =3D=3D None: self._Pcds =3D sdict() + self.__ParsePcdFromCommandLine() self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD)) self._Pcds.update(self._GetPcd(MODEL_PCD_PATCHABLE_IN_MODULE)) self._Pcds.update(self._GetPcd(MODEL_PCD_FEATURE_FLAG)) self._Pcds.update(self._GetDynamicPcd(MODEL_PCD_DYNAMIC_DEFAUL= T)) self._Pcds.update(self._GetDynamicHiiPcd(MODEL_PCD_DYNAMIC_HII= )) @@ -905,10 +1057,12 @@ class DscBuildData(PlatformBuildClassObject): =20 self._Pcds =3D self.CompletePcdValues(self._Pcds) self._Pcds =3D self.UpdateStructuredPcds(MODEL_PCD_TYPE_LIST, = self._Pcds) self._Pcds =3D self.CompleteHiiPcdsDefaultStores(self._Pcds) self._Pcds =3D self._FilterPcdBySkuUsage(self._Pcds) + self._Pcds =3D self.OverrideByFdfCommOverAll(self._Pcds) + self.RecoverCommandLinePcd() return self._Pcds =20 def _dumpPcdInfo(self,Pcds): for pcd in Pcds: pcdobj =3D Pcds[pcd] @@ -969,11 +1123,59 @@ class DscBuildData(PlatformBuildClassObject): if (item[0],item[1]) not in structure_pcd_data: structure_pcd_data[(item[0],item[1])] =3D [] structure_pcd_data[(item[0],item[1])].append(item) =20 return structure_pcd_data + def OverrideByFdfComm(self,StruPcds): + StructurePcdInCom =3D {(item[0],item[1],item[2] ):(item[3],item[4]= ) for item in GlobalData.BuildOptionPcd if len(item) =3D=3D 5 and (item[1],= item[0]) in StruPcds } if GlobalData.BuildOptionPcd else {} + GlobalPcds =3D set([(item[0],item[1]) for item in StructurePcdInCo= m.keys()]) + for Pcd in StruPcds.values(): + if (Pcd.TokenSpaceGuidCName,Pcd.TokenCName) not in GlobalPcds: + continue + FieldValues =3D {item[2]:StructurePcdInCom[item] for item in S= tructurePcdInCom if (Pcd.TokenSpaceGuidCName,Pcd.TokenCName) =3D=3D (item[0= ],item[1]) and item[2]} + for sku in Pcd.SkuOverrideValues: + for defaultstore in Pcd.SkuOverrideValues[sku]: + for field in FieldValues: + if field not in Pcd.SkuOverrideValues[sku][default= store]: + Pcd.SkuOverrideValues[sku][defaultstore][field= ] =3D ["","",""] + Pcd.SkuOverrideValues[sku][defaultstore][field][0]= =3D FieldValues[field][0] + Pcd.SkuOverrideValues[sku][defaultstore][field][1]= =3D FieldValues[field][1][0] + Pcd.SkuOverrideValues[sku][defaultstore][field][2]= =3D FieldValues[field][1][1] + return StruPcds + def OverrideByFdfCommOverAll(self,AllPcds): + def CheckStructureInComm(commpcds): + if not commpcds: + return False + if len(commpcds[0]) =3D=3D 5: + return True + return False =20 + if CheckStructureInComm(GlobalData.BuildOptionPcd): + StructurePcdInCom =3D {(item[0],item[1],item[2] ):(item[3],ite= m[4]) for item in GlobalData.BuildOptionPcd } if GlobalData.BuildOptionPcd = else {} + NoFiledValues =3D {(item[0],item[1]):StructurePcdInCom[item] f= or item in StructurePcdInCom if not item[2]} + else: + NoFiledValues =3D {(item[0],item[1]):[item[2]] for item in Glo= balData.BuildOptionPcd} + for Guid,Name in NoFiledValues: + if (Name,Guid) in AllPcds: + Pcd =3D AllPcds.get((Name,Guid)) + Pcd.DefaultValue =3D NoFiledValues[(Pcd.TokenSpaceGuidCNam= e,Pcd.TokenCName)][0] + for sku in Pcd.SkuInfoList: + SkuInfo =3D Pcd.SkuInfoList[sku] + if SkuInfo.DefaultValue: + SkuInfo.DefaultValue =3D NoFiledValues[(Pcd.TokenS= paceGuidCName,Pcd.TokenCName)][0] + else: + SkuInfo.HiiDefaultValue =3D NoFiledValues[(Pcd.Tok= enSpaceGuidCName,Pcd.TokenCName)][0] + for defaultstore in SkuInfo.DefaultStoreDict: + SkuInfo.DefaultStoreDict[defaultstore] =3D NoF= iledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0] + else: + PcdInDec =3D self.DecPcds.get((Name,Guid)) + if PcdInDec: + if PcdInDec.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_= FIXED_AT_BUILD], + self._PCD_TYPE_STRING_[MODEL_PCD_P= ATCHABLE_IN_MODULE]]: + self.Pcds[Name, Guid] =3D copy.deepcopy(PcdInDec) + self.Pcds[Name, Guid].DefaultValue =3D NoFiledValu= es[( Guid,Name)][0] + return AllPcds def UpdateStructuredPcds(self, TypeList, AllPcds): =20 DynamicPcdType =3D [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_DEFAU= LT], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_VPD], @@ -1000,11 +1202,11 @@ class DscBuildData(PlatformBuildClassObject): SkuName =3D 'DEFAULT' if SkuName =3D=3D 'COMMON' else SkuName if SkuName not in SkuIds: continue =20 if SkuName in SkuIds and "." in TokenSpaceGuid: - S_PcdSet.append(( TokenSpaceGuid.split(".")[0],TokenSpaceG= uid.split(".")[1], PcdCName,SkuName, default_store,Dummy5, AnalyzePcdExpres= sion(Setting)[0])) + S_PcdSet.append([ TokenSpaceGuid.split(".")[0],TokenSpaceG= uid.split(".")[1], PcdCName,SkuName, default_store,Dummy5, AnalyzePcdExpres= sion(Setting)[0]]) =20 # handle pcd value override StrPcdSet =3D self.GetStructurePcdInfo(S_PcdSet) S_pcd_set =3D {} for str_pcd in StrPcdSet: @@ -1067,11 +1269,11 @@ class DscBuildData(PlatformBuildClassObject): mindefaultstorename =3D DefaultStoreMgr.GetMin(PcdDefa= ultStoreSet) =20 for defaultstoreid in DefaultStores: if defaultstoreid not in stru_pcd.SkuOverrideValue= s[skuid]: stru_pcd.SkuOverrideValues[skuid][defaultstore= id] =3D copy.deepcopy(stru_pcd.SkuOverrideValues[nextskuid][mindefaultstore= name]) - + S_pcd_set =3D self.OverrideByFdfComm(S_pcd_set) Str_Pcd_Values =3D self.GenerateByteArrayValue(S_pcd_set) if Str_Pcd_Values: for (skuname,StoreName,PcdGuid,PcdName,PcdValue) in Str_Pcd_Va= lues: str_pcd_obj =3D S_pcd_set.get((PcdName, PcdGuid)) if str_pcd_obj is None: diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Pyth= on/build/build.py index e4adee2beb..24f9962c9d 100644 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -770,11 +770,11 @@ class Build(): self.TargetTxt =3D TargetTxtClassObject() self.ToolDef =3D ToolDefClassObject() self.AutoGenTime =3D 0 self.MakeTime =3D 0 self.GenFdsTime =3D 0 - GlobalData.BuildOptionPcd =3D BuildOptions.OptionPcd + GlobalData.BuildOptionPcd =3D BuildOptions.OptionPcd if BuildO= ptions.OptionPcd else {} #Set global flag for build mode GlobalData.gIgnoreSource =3D BuildOptions.IgnoreSources GlobalData.gUseHashCache =3D BuildOptions.UseHashCache GlobalData.gBinCacheDest =3D BuildOptions.BinCacheDest GlobalData.gBinCacheSource =3D BuildOptions.BinCacheSource --=20 2.14.3.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel