From nobody Mon Dec 23 05:26:21 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 1519899713171457.54060049005216; Thu, 1 Mar 2018 02:21:53 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7420521F6A6FE; Thu, 1 Mar 2018 02:15:43 -0800 (PST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 163232242383C for ; Thu, 1 Mar 2018 02:15:41 -0800 (PST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Mar 2018 02:21:49 -0800 Received: from shwdeopenpsi105.ccr.corp.intel.com ([10.239.9.129]) by fmsmga006.fm.intel.com with ESMTP; 01 Mar 2018 02:21:48 -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.31; helo=mga06.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.47,408,1515484800"; d="scan'208";a="208042888" From: BobCF To: edk2-devel@lists.01.org Date: Thu, 1 Mar 2018 18:21:45 +0800 Message-Id: <20180301102145.37392-1-bob.c.feng@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 Subject: [edk2] [Patch] BaseTools: Fixed Pcd value override issue. 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" The Pcd value override in commandline. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bob Feng Cc: Liming Gao --- .../Source/Python/Workspace/BuildClassObject.py | 4 + BaseTools/Source/Python/Workspace/DscBuildData.py | 136 +++++++++++++++++= +--- BaseTools/Source/Python/build/build.py | 2 +- 3 files changed, 121 insertions(+), 21 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTo= ols/Source/Python/Workspace/BuildClassObject.py index edf2bdf4b9..711ba492ef 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -127,10 +127,12 @@ class StructurePcd(PcdClassObject): self.StructName =3D None self.PcdDefineLineNo =3D 0 self.PkgPath =3D "" self.DefaultValueFromDec =3D "" self.ValueChain =3D dict() + self.PcdValueFromComm =3D "" + self.PcdFieldValueFromComm =3D collections.OrderedDict({}) def __repr__(self): return self.TypeName =20 def AddDefaultValue (self, FieldName, Value, FileName=3D"", LineNo=3D0= ): if FieldName in self.DefaultValues: @@ -186,10 +188,12 @@ class StructurePcd(PcdClassObject): self.FlexibleFieldName =3D PcdObject.FlexibleFieldName if PcdO= bject.FlexibleFieldName else self.FlexibleFieldName self.StructName =3D PcdObject.DatumType if PcdObject.DatumType= else self.StructName self.PcdDefineLineNo =3D PcdObject.PcdDefineLineNo if PcdObjec= t.PcdDefineLineNo else self.PcdDefineLineNo self.PkgPath =3D PcdObject.PkgPath if PcdObject.PkgPath else s= elf.PkgPath self.ValueChain =3D PcdObject.ValueChain if PcdObject.ValueCha= in else self.ValueChain + self.PcdValueFromComm =3D PcdObject.PcdValueFromComm if PcdObj= ect.PcdValueFromComm else self.PcdValueFromComm + self.PcdFieldValueFromComm =3D PcdObject.PcdFieldValueFromComm= if PcdObject.PcdFieldValueFromComm else self.PcdFieldValueFromComm =20 ## LibraryClassObject # # This Class defines LibraryClassObject used in BuildDatabase # diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/= Source/Python/Workspace/DscBuildData.py index a5089a900b..06d2f2fbcd 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1131,14 +1131,15 @@ class DscBuildData(PlatformBuildClassObject): self._Pcds.update(self._GetDynamicPcd(MODEL_PCD_DYNAMIC_EX_DEF= AULT)) self._Pcds.update(self._GetDynamicHiiPcd(MODEL_PCD_DYNAMIC_EX_= HII)) self._Pcds.update(self._GetDynamicVpdPcd(MODEL_PCD_DYNAMIC_EX_= VPD)) =20 self._Pcds =3D self.CompletePcdValues(self._Pcds) + self._Pcds =3D self.OverrideByFdfCommOverAll(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: @@ -1201,24 +1202,28 @@ class DscBuildData(PlatformBuildClassObject): 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 {} + StructurePcdInCom =3D OrderedDict() + for item in GlobalData.BuildOptionPcd: + if len(item) =3D=3D 5 and (item[1],item[0]) in StruPcds: + StructurePcdInCom[(item[0],item[1],item[2] )] =3D (item[3]= ,item[4]) 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] + FieldValues =3D OrderedDict() + for item in StructurePcdInCom: + if (Pcd.TokenSpaceGuidCName,Pcd.TokenCName) =3D=3D (item[0= ],item[1]) and item[2]: + FieldValues[item[2]] =3D StructurePcdInCom[item] + for field in FieldValues: + if field not in Pcd.PcdFieldValueFromComm: + Pcd.PcdFieldValueFromComm[field] =3D ["","",""] + Pcd.PcdFieldValueFromComm[field][0] =3D FieldValues[field]= [0] + Pcd.PcdFieldValueFromComm[field][1] =3D FieldValues[field]= [1][0] + Pcd.PcdFieldValueFromComm[field][2] =3D FieldValues[field]= [1][1] return StruPcds def OverrideByFdfCommOverAll(self,AllPcds): def CheckStructureInComm(commpcds): if not commpcds: return False @@ -1232,19 +1237,22 @@ class DscBuildData(PlatformBuildClassObject): 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] + if isinstance(self._DecPcds.get((Pcd.TokenCName,Pcd.TokenS= paceGuidCName), None),StructurePcd): + self._DecPcds.get((Pcd.TokenCName,Pcd.TokenSpaceGuidCN= ame)).PcdValueFromComm =3D NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.Token= CName)][0] + else: + Pcd.DefaultValue =3D NoFiledValues[(Pcd.TokenSpaceGuid= CName,Pcd.TokenCName)][0] + for sku in Pcd.SkuInfoList: + SkuInfo =3D Pcd.SkuInfoList[sku] + if SkuInfo.DefaultValue: + SkuInfo.DefaultValue =3D NoFiledValues[(Pcd.To= kenSpaceGuidCName,Pcd.TokenCName)][0] + else: + SkuInfo.HiiDefaultValue =3D NoFiledValues[(Pcd= .TokenSpaceGuidCName,Pcd.TokenCName)][0] + for defaultstore in SkuInfo.DefaultStoreDict: + SkuInfo.DefaultStoreDict[defaultstore] =3D= NoFiledValues[(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]]: @@ -1623,10 +1631,34 @@ class DscBuildData(PlatformBuildClassObject): FieldName =3D FieldName.split(']', 1)[1] FieldName =3D NewFieldName + FieldName while '[' in FieldName: FieldName =3D FieldName.rsplit('[', 1)[0] CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, = %s, %s, %d); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.st= rip("."), ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_= ori][2], FieldList[FieldName_ori][0]) + if Pcd.PcdFieldValueFromComm: + CApp =3D CApp + "// From Command Line \n" + for FieldName in Pcd.PcdFieldValueFromComm: + FieldName =3D "." + FieldName + IsArray =3D self.IsFieldValueAnArray(FieldList[FieldName.strip= (".")][0]) + if IsArray and not (FieldList[FieldName.strip(".")][0].startsw= ith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')): + try: + Value =3D ValueExpressionEx(FieldList[FieldName.strip(= ".")][0], "VOID*", self._GuidDict)(True) + except BadExpression: + EdkLogger.error('Build', FORMAT_INVALID, "Invalid valu= e format for %s. From %s Line %d " % + (".".join((Pcd.TokenSpaceGuidCName, Pc= d.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], F= ieldList[FieldName.strip(".")][2])) + Value, ValueSize =3D ParseFieldValue(Value) + CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d / __A= RRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0))= ; // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), Va= lueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, Fie= ldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.= strip(".")][2], FieldList[FieldName.strip(".")][0]); + else: + NewFieldName =3D '' + FieldName_ori =3D FieldName.strip('.') + while '[' in FieldName: + NewFieldName =3D NewFieldName + FieldName.split('[', 1= )[0] + '[0]' + ArrayIndex =3D int(FieldName.split('[', 1)[1].split(']= ', 1)[0]) + FieldName =3D FieldName.split(']', 1)[1] + FieldName =3D NewFieldName + FieldName + while '[' in FieldName: + FieldName =3D FieldName.rsplit('[', 1)[0] + CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d);= // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), Ar= rayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], Fie= ldList[FieldName_ori][0]) CApp =3D CApp + "}\n" return CApp def GenerateSizeStatments(self,Pcd): CApp =3D ' Size =3D sizeof(%s);\n' % (Pcd.DatumType) CApp =3D CApp + ' Cal_%s_%s_Size(&Size);\n' % (Pcd.TokenSpaceGuid= CName, Pcd.TokenCName) @@ -1762,10 +1794,72 @@ class DscBuildData(PlatformBuildClassObject): CApp =3D CApp + "}\n" return CApp def GenerateInitValueStatement(self,Pcd,SkuName,DefaultStoreName): CApp =3D ' Assign_%s_%s_%s_%s_Value(Pcd);\n' % (Pcd.TokenSpaceGui= dCName, Pcd.TokenCName,SkuName,DefaultStoreName) return CApp + def GenerateCommandLineValue(self,Pcd): + CApp =3D "// Value in CommandLine\n" + CApp =3D CApp + "void Assign_%s_%s_CommandLine_Value(%s *Pcd){\n" = % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,Pcd.DatumType) + CApp =3D CApp + ' UINT32 FieldSize;\n' + CApp =3D CApp + ' CHAR8 *Value;\n' + + pcddefaultvalue =3D Pcd.PcdValueFromComm + for FieldList in [pcddefaultvalue,Pcd.PcdFieldValueFromComm]: + if not FieldList: + continue + if pcddefaultvalue and FieldList =3D=3D pcddefaultvalue: + IsArray =3D self.IsFieldValueAnArray(FieldList) + if IsArray: + try: + FieldList =3D ValueExpressionEx(FieldList, "VOID*"= )(True) + except BadExpression: + EdkLogger.error("Build", FORMAT_INVALID, "Invalid = value format for %s.%s, from DSC: %s" % + (Pcd.TokenSpaceGuidCName, Pcd.Toke= nCName, FieldList)) + Value, ValueSize =3D ParseFieldValue (FieldList) + + if isinstance(Value, str): + CApp =3D CApp + ' Pcd =3D %s; // From Command Line \n= ' % (Value) + elif IsArray: + # + # Use memcpy() to copy value into field + # + CApp =3D CApp + ' Value =3D %s; // From Command L= ine.\n' % (self.IntToCString(Value, ValueSize)) + CApp =3D CApp + ' memcpy (Pcd, Value, %d);\n' % (Valu= eSize) + continue + for FieldName in FieldList: + IsArray =3D self.IsFieldValueAnArray(FieldList[FieldName][= 0]) + if IsArray: + try: + FieldList[FieldName][0] =3D ValueExpressionEx(Fiel= dList[FieldName][0], "VOID*", self._GuidDict)(True) + except BadExpression: + 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])) + except: + print "error" + try: + Value, ValueSize =3D ParseFieldValue (FieldList[FieldN= ame][0]) + except Exception: + EdkLogger.error('Build', FORMAT_INVALID, "Invalid valu= e format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName,Pcd= .TokenCName,FieldName)),FieldList[FieldName][1], FieldList[FieldName][2])) + if isinstance(Value, str): + CApp =3D CApp + ' Pcd->%s =3D %s; // From %s Line %d = Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldNa= me][2], FieldList[FieldName][0]) + elif IsArray: + # + # Use memcpy() to copy value into field + # + CApp =3D CApp + ' FieldSize =3D __FIELD_SIZE(%s, %s);= \n' % (Pcd.DatumType, FieldName) + CApp =3D CApp + ' Value =3D %s; // From %s Line %= d Value %s\n' % (self.IntToCString(Value, ValueSize), FieldList[FieldName][= 1], FieldList[FieldName][2], FieldList[FieldName][0]) + CApp =3D CApp + ' memcpy (&Pcd->%s, Value, (FieldSize= > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, Valu= eSize) + else: + if ValueSize > 4: + CApp =3D CApp + ' Pcd->%s =3D %dULL; // From %s L= ine %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[= FieldName][2], FieldList[FieldName][0]) + else: + 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]) + CApp =3D CApp + "}\n" + return CApp + def GenerateCommandLineValueStatement(self,Pcd): + CApp =3D ' Assign_%s_%s_CommandLine_Value(Pcd);\n' % (Pcd.TokenSp= aceGuidCName, Pcd.TokenCName) + return CApp def GenerateInitializeFunc(self, SkuName, DefaultStore, Pcd, InitByteV= alue, CApp): OverrideValues =3D {DefaultStore:""} if Pcd.SkuOverrideValues: OverrideValues =3D Pcd.SkuOverrideValues[SkuName] for DefaultStoreName in OverrideValues.keys(): @@ -1833,10 +1927,11 @@ class DscBuildData(PlatformBuildClassObject): if skuname =3D=3D SkuName: break else: CApp =3D CApp + "// SkuName: DEFAULT, DefaultStoreName: S= TANDARD \n" CApp =3D CApp + self.GenerateInitValueStatement(Pcd,"DEFAU= LT","STANDARD") + CApp =3D CApp + self.GenerateCommandLineValueStatement(Pcd) # # Set new PCD value and size # CApp =3D CApp + ' PcdSetPtr (%s, %s, %s, %s, Size, (UINT8 *)P= cd);\n' % (SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.TokenCNa= me) =20 @@ -1868,10 +1963,11 @@ class DscBuildData(PlatformBuildClassObject): CApp =3D CApp + '\n' for PcdName in StructuredPcds: Pcd =3D StructuredPcds[PcdName] CApp =3D CApp + self.GenerateSizeFunction(Pcd) CApp =3D CApp + self.GenerateDefaultValueAssignFunction(Pcd) + CApp =3D CApp + self.GenerateCommandLineValue(Pcd) if not Pcd.SkuOverrideValues or Pcd.Type in [self._PCD_TYPE_ST= RING_[MODEL_PCD_FIXED_AT_BUILD], self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODU= LE]]: CApp =3D CApp + self.GenerateInitValueFunction(Pcd,self.Sk= uIdMgr.SystemSkuId, 'STANDARD') else: for SkuName in self.SkuIdMgr.SkuOverrideOrder(): diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Pyth= on/build/build.py index 14a2ceb4bc..1371791e52 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 if BuildO= ptions.OptionPcd else {} + 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