From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 9FB9E20955F3E for ; Fri, 2 Mar 2018 05:29:12 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2018 05:35:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,412,1515484800"; d="scan'208";a="21566940" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga008.fm.intel.com with ESMTP; 02 Mar 2018 05:35:21 -0800 Received: from fmsmsx111.amr.corp.intel.com (10.18.116.5) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 2 Mar 2018 05:35:20 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx111.amr.corp.intel.com (10.18.116.5) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 2 Mar 2018 05:35:20 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.125]) by shsmsx102.ccr.corp.intel.com ([169.254.2.124]) with mapi id 14.03.0319.002; Fri, 2 Mar 2018 21:35:18 +0800 From: "Gao, Liming" To: "Feng, Bob C" , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [Patch 1/2] BaseTools: Fixed Pcd value override issue. Thread-Index: AQHTsg7V6hInzU3Omku0Cn0fycjufqO88njA Date: Fri, 2 Mar 2018 13:35:18 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E1D66E5@SHSMSX104.ccr.corp.intel.com> References: <20180302101114.9488-1-bob.c.feng@intel.com> In-Reply-To: <20180302101114.9488-1-bob.c.feng@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch 1/2] 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: , X-List-Received-Date: Fri, 02 Mar 2018 13:29:13 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Bo= bCF > Sent: Friday, March 2, 2018 6:11 PM > To: edk2-devel@lists.01.org > Cc: Gao, Liming > Subject: [edk2] [Patch 1/2] BaseTools: Fixed Pcd value override issue. >=20 > 1. Handle the Pcd maxsize issue for the case > that the length of Pcd value from CommandLine > bigger that its maxsize >=20 > 2. The Pcd value override in commandline. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Bob Feng > Cc: Liming Gao > --- > BaseTools/Source/Python/AutoGen/AutoGen.py | 26 --- > BaseTools/Source/Python/AutoGen/GenPcdDb.py | 12 -- > .../Source/Python/Workspace/BuildClassObject.py | 4 + > BaseTools/Source/Python/Workspace/DscBuildData.py | 175 +++++++++++++++= +++--- > BaseTools/Source/Python/build/build.py | 2 +- > 5 files changed, 157 insertions(+), 62 deletions(-) >=20 > diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Sourc= e/Python/AutoGen/AutoGen.py > index e2589cfbae..439e360955 100644 > --- a/BaseTools/Source/Python/AutoGen/AutoGen.py > +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py > @@ -1366,31 +1366,10 @@ class PlatformAutoGen(AutoGen): > # > # Gather dynamic PCDs list from each module and their settings from= platform > # 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 PcdItem in GlobalData.BuildOptionPcd: > - PlatformPcd =3D self.Platform.Pcds.get((PcdItem[1],PcdIt= em[0])) > - if PlatformPcd: > - if PlatformPcd.DatumType in [TAB_UINT8, TAB_UINT16, = TAB_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 PcdDefaultVa= lue > - else: > - skuinfo.DefaultValue =3D PcdDefaultValue > - PlatformPcd.DefaultValue =3D PcdDefaultValue > - if PlatformPcd.MaxDatumSize: > - PlatformPcd.MaxDatumSize =3D > str(max([int(PlatformPcd.MaxDatumSize),len(PcdDefaultValue.split(","))])) > - else: > - PlatformPcd.MaxDatumSize =3D str(len(PcdDefa= ultValue.split(","))) >=20 > for key in self.Platform.Pcds: > for SinglePcd in GlobalData.MixedPcd: > if (self.Platform.Pcds[key].TokenCName, self.Platform.Pc= ds[key].TokenSpaceGuidCName) =3D=3D SinglePcd: > for item in GlobalData.MixedPcd[SinglePcd]: > @@ -2371,15 +2350,10 @@ class PlatformAutoGen(AutoGen): > for PcdItem in GlobalData.MixedPcd: > if (ToPcd.TokenCName, ToPcd.TokenSpaceGuidCName) in GlobalDa= ta.MixedPcd[PcdItem]: > TokenCName =3D PcdItem[0] > break > if FromPcd !=3D None: > - if GlobalData.BuildOptionPcd: > - for pcd in GlobalData.BuildOptionPcd: > - if (FromPcd.TokenSpaceGuidCName, FromPcd.TokenCName)= =3D=3D (pcd[0], pcd[1]): > - FromPcd.DefaultValue =3D pcd[2] > - break > if ToPcd.Pending and FromPcd.Type not in [None, '']: > ToPcd.Type =3D FromPcd.Type > elif (ToPcd.Type not in [None, '']) and (FromPcd.Type not in= [None, ''])\ > and (ToPcd.Type !=3D FromPcd.Type) and (ToPcd.Type in Fr= omPcd.Type): > if ToPcd.Type.strip() =3D=3D "DynamicEx": > diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Sour= ce/Python/AutoGen/GenPcdDb.py > index 82360ae57d..e2848e7aaf 100644 > --- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py > +++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py > @@ -1182,16 +1182,10 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platfo= rm, DynamicPcdList, Phase): >=20 > for PcdItem in GlobalData.MixedPcd: > if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.M= ixedPcd[PcdItem]: > CName =3D PcdItem[0] >=20 > - if GlobalData.BuildOptionPcd: > - for PcdItem in GlobalData.BuildOptionPcd: > - if (Pcd.TokenSpaceGuidCName, CName) =3D=3D (PcdItem[0], = PcdItem[1]): > - Pcd.DefaultValue =3D PcdItem[2] > - break > - > EdkLogger.debug(EdkLogger.DEBUG_3, "PCD: %s %s (%s : %s)" % (CNa= me, TokenSpaceGuidCName, Pcd.Phase, Phase)) >=20 > if Pcd.Phase =3D=3D 'PEI': > NumberOfPeiLocalTokens +=3D 1 > if Pcd.Phase =3D=3D 'DXE': > @@ -1503,16 +1497,10 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platfo= rm, DynamicPcdList, Phase): >=20 > for PcdItem in GlobalData.MixedPcd: > if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.M= ixedPcd[PcdItem]: > CName =3D PcdItem[0] >=20 > - if GlobalData.BuildOptionPcd: > - for PcdItem in GlobalData.BuildOptionPcd: > - if (Pcd.TokenSpaceGuidCName, CName) =3D=3D (PcdItem[0], = PcdItem[1]): > - Pcd.DefaultValue =3D PcdItem[2] > - break > - > EdkLogger.debug(EdkLogger.DEBUG_1, "PCD =3D %s.%s" % (CName, Tok= enSpaceGuidCName)) > EdkLogger.debug(EdkLogger.DEBUG_1, "phase =3D %s" % Phase) > EdkLogger.debug(EdkLogger.DEBUG_1, "GeneratedTokenNumber =3D %s"= % str(GeneratedTokenNumber)) >=20 > # > diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/Base= Tools/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 Pc= dObject.FlexibleFieldName else self.FlexibleFieldName > self.StructName =3D PcdObject.DatumType if PcdObject.DatumTy= pe else self.StructName > self.PcdDefineLineNo =3D PcdObject.PcdDefineLineNo if PcdObj= ect.PcdDefineLineNo else self.PcdDefineLineNo > self.PkgPath =3D PcdObject.PkgPath if PcdObject.PkgPath else= self.PkgPath > self.ValueChain =3D PcdObject.ValueChain if PcdObject.ValueC= hain else self.ValueChain > + self.PcdValueFromComm =3D PcdObject.PcdValueFromComm if PcdO= bject.PcdValueFromComm else > self.PcdValueFromComm > + self.PcdFieldValueFromComm =3D PcdObject.PcdFieldValueFromCo= mm 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/BaseTool= s/Source/Python/Workspace/DscBuildData.py > index a5089a900b..239531cd1c 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_D= EFAULT)) > self._Pcds.update(self._GetDynamicHiiPcd(MODEL_PCD_DYNAMIC_E= X_HII)) > self._Pcds.update(self._GetDynamicVpdPcd(MODEL_PCD_DYNAMIC_E= X_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 StructurePcdIn= Com.keys()]) > for Pcd in StruPcds.values(): > if (Pcd.TokenSpaceGuidCName,Pcd.TokenCName) not in GlobalPcd= s: > continue > - FieldValues =3D {item[2]:StructurePcdInCom[item] for item in= StructurePcdInCom if > (Pcd.TokenSpaceGuidCName,Pcd.TokenCName) =3D=3D (item[0],item[1]) and ite= m[2]} > - for sku in Pcd.SkuOverrideValues: > - for defaultstore in Pcd.SkuOverrideValues[sku]: > - for field in FieldValues: > - if field not in Pcd.SkuOverrideValues[sku][defau= ltstore]: > - Pcd.SkuOverrideValues[sku][defaultstore][fie= ld] =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[fiel= d][0] > + Pcd.PcdFieldValueFromComm[field][1] =3D FieldValues[fiel= d][1][0] > + Pcd.PcdFieldValueFromComm[field][2] =3D FieldValues[fiel= d][1][1] > return StruPcds > def OverrideByFdfCommOverAll(self,AllPcds): > def CheckStructureInComm(commpcds): > if not commpcds: > return False > @@ -1232,19 +1237,35 @@ class DscBuildData(PlatformBuildClassObject): > else: > NoFiledValues =3D {(item[0],item[1]):[item[2]] for item in G= lobalData.BuildOptionPcd} > for Guid,Name in NoFiledValues: > if (Name,Guid) in AllPcds: > Pcd =3D AllPcds.get((Name,Guid)) > - Pcd.DefaultValue =3D NoFiledValues[(Pcd.TokenSpaceGuidCN= ame,Pcd.TokenCName)][0] > - for sku in Pcd.SkuInfoList: > - SkuInfo =3D Pcd.SkuInfoList[sku] > - if SkuInfo.DefaultValue: > - SkuInfo.DefaultValue =3D NoFiledValues[(Pcd.Toke= nSpaceGuidCName,Pcd.TokenCName)][0] > - else: > - SkuInfo.HiiDefaultValue =3D NoFiledValues[(Pcd.T= okenSpaceGuidCName,Pcd.TokenCName)][0] > - for defaultstore in SkuInfo.DefaultStoreDict: > - SkuInfo.DefaultStoreDict[defaultstore] =3D > NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0] > + if isinstance(self._DecPcds.get((Pcd.TokenCName,Pcd.Toke= nSpaceGuidCName), None),StructurePcd): > + self._DecPcds.get((Pcd.TokenCName,Pcd.TokenSpaceGuid= CName)).PcdValueFromComm =3D > NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0] > + else: > + Pcd.DefaultValue =3D NoFiledValues[(Pcd.TokenSpaceGu= idCName,Pcd.TokenCName)][0] > + for sku in Pcd.SkuInfoList: > + SkuInfo =3D Pcd.SkuInfoList[sku] > + if SkuInfo.DefaultValue: > + SkuInfo.DefaultValue =3D NoFiledValues[(Pcd.= TokenSpaceGuidCName,Pcd.TokenCName)][0] > + else: > + SkuInfo.HiiDefaultValue =3D NoFiledValues[(P= cd.TokenSpaceGuidCName,Pcd.TokenCName)][0] > + for defaultstore in SkuInfo.DefaultStoreDict= : > + SkuInfo.DefaultStoreDict[defaultstore] = =3D > NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0] > + if Pcd.DatumType =3D=3D "VOID*": > + if Pcd.MaxDatumSize is None: > + Pcd.MaxDatumSize =3D '0' > + MaxSize =3D int(Pcd.MaxDatumSize,10) > + if Pcd.DefaultValue.startswith("{") and Pcd.Defa= ultValue.endswith("}"): > + MaxSize =3D max([len(Pcd.DefaultValue.split(= ",")),MaxSize]) > + elif Pcd.DefaultValue.startswith("\"") or Pcd.De= faultValue.startswith("\'"): > + MaxSize =3D max([len(Pcd.DefaultValue)-2+1,M= axSize]) > + elif Pcd.DefaultValue.startswith("L\""): > + MaxSize =3D max([2*(len(Pcd.DefaultValue)-3+= 1),MaxSize]) > + else: > + MaxSize =3D max([len(Pcd.DefaultValue),MaxSi= ze]) > + Pcd.MaxDatumSize =3D str(MaxSize) > else: > PcdInDec =3D self.DecPcds.get((Name,Guid)) > if PcdInDec: > if PcdInDec.Type in [self._PCD_TYPE_STRING_[MODEL_PC= D_FIXED_AT_BUILD], > self._PCD_TYPE_STRING_[MODEL_PCD= _PATCHABLE_IN_MODULE]]: > @@ -1541,14 +1562,12 @@ class DscBuildData(PlatformBuildClassObject): > if Value[0] =3D=3D '"' and Value[-1] =3D=3D '"' and len(list(Val= ue[1:-1])) > 1: > return True > if Value[0] =3D=3D '{' and Value[-1] =3D=3D '}': > return True > if Value.startswith("L'") and Value.endswith("'") and len(list(V= alue[2:-1])) > 1: > - print 'foo =3D ', list(Value[2:-1]) > return True > if Value[0] =3D=3D "'" and Value[-1] =3D=3D "'" and len(list(Val= ue[1:-1])) > 1: > - print 'bar =3D ', list(Value[1:-1]) > return True > return False >=20 > def ExecuteCommand (self, Command): > try: > @@ -1565,10 +1584,31 @@ class DscBuildData(PlatformBuildClassObject): > Result =3D Result + '\\x%02x' % (Value & 0xff) > Value =3D Value >> 8 > Result =3D Result + '"' > return Result >=20 > + def GetPcdMaxSize(self,Pcd): > + MaxSize =3D int(Pcd.MaxDatumSize,10) if Pcd.MaxDatumSize else 0 > + if Pcd.DatumType not in ['BOOLEAN','UINT8','UINT16','UINT32','UI= NT64']: > + if Pcd.PcdValueFromComm: > + if Pcd.PcdValueFromComm.startswith("{") and Pcd.PcdValue= FromComm.endswith("}"): > + MaxSize =3D max([len(Pcd.PcdValueFromComm.split(",")= ),MaxSize]) > + elif Pcd.PcdValueFromComm.startswith("\"") or Pcd.PcdVal= ueFromComm.startswith("\'"): > + MaxSize =3D max([len(Pcd.PcdValueFromComm)-2+1,MaxSi= ze]) > + elif Pcd.PcdValueFromComm.startswith("L\""): > + MaxSize =3D max([2*(len(Pcd.PcdValueFromComm)-3+1),M= axSize]) > + else: > + MaxSize =3D max([len(Pcd.PcdValueFromComm),MaxSize]) > + elif Pcd.DatumType not in ['BOOLEAN','UINT8']: > + MaxSize =3D 1 > + elif Pcd.DatumType =3D=3D 'UINT16': > + MaxSize =3D 2 > + elif Pcd.DatumType =3D=3D 'UINT32': > + MaxSize =3D 4 > + elif Pcd.DatumType =3D=3D 'UINT64': > + MaxSize =3D 8 > + return MaxSize > def GenerateSizeFunction(self,Pcd): > CApp =3D "// Default Value in Dec \n" > CApp =3D CApp + "void Cal_%s_%s_Size(UINT32 *Size){\n" % (Pcd.To= kenSpaceGuidCName, Pcd.TokenCName) > for FieldList in [Pcd.DefaultValues]: > if not FieldList: > @@ -1623,10 +1663,35 @@ 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.strip("."), 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.str= ip(".")][0]) > + if IsArray and not (FieldList[FieldName.strip(".")][0].start= swith('{GUID') and > FieldList[FieldName.strip(".")][0].endswith('}')): > + try: > + Value =3D ValueExpressionEx(FieldList[FieldName.stri= p(".")][0], "VOID*", self._GuidDict)(True) > + except BadExpression: > + EdkLogger.error('Build', FORMAT_INVALID, "Invalid va= lue format for %s. From %s Line %d " % > + (".".join((Pcd.TokenSpaceGuidCName, = Pcd.TokenCName, FieldName.strip('.'))), > FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2])) > + Value, ValueSize =3D ParseFieldValue(Value) > + CApp =3D CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d / _= _ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% > __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s\n' %= (Pcd.DatumType, FieldName.strip("."), ValueSize, > Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.= 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("."), ArrayIndex + 1, FieldList[FieldName_ori][1], FieldL= ist[FieldName_ori][2], FieldList[FieldName_ori][0]) > + CApp =3D CApp + " *Size =3D (%d > *Size ? %d : *Size); // The P= cd maxsize is %d \n" % > (self.GetPcdMaxSize(Pcd),self.GetPcdMaxSize(Pcd),self.GetPcdMaxSize(Pcd)) > 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.TokenSpaceGu= idCName, Pcd.TokenCName) > @@ -1762,10 +1827,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.TokenSpaceG= uidCName, > 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, "Invali= d value format for %s.%s, from DSC: %s" % > + (Pcd.TokenSpaceGuidCName, Pcd.To= kenCName, 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= Line.\n' % (self.IntToCString(Value, ValueSize)) > + CApp =3D CApp + ' memcpy (Pcd, Value, %d);\n' % (Va= lueSize) > + continue > + for FieldName in FieldList: > + IsArray =3D self.IsFieldValueAnArray(FieldList[FieldName= ][0]) > + if IsArray: > + try: > + FieldList[FieldName][0] =3D ValueExpressionEx(Fi= eldList[FieldName][0], "VOID*", self._GuidDict)(True) > + except BadExpression: > + EdkLogger.error('Build', FORMAT_INVALID, "Invali= d value format for %s. From %s Line %d " % > + (".".join((Pcd.TokenSpaceGuidCNa= me, Pcd.TokenCName, FieldName)), > FieldList[FieldName][1], FieldList[FieldName][2])) > + except: > + print "error" > + try: > + Value, ValueSize =3D ParseFieldValue (FieldList[Fiel= dName][0]) > + except Exception: > + EdkLogger.error('Build', FORMAT_INVALID, "Invalid va= lue format for %s. From %s Line %d " % > (".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName,FieldName)),FieldList[F= ieldName][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[FieldName][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, (FieldSi= ze > 0 && FieldSize < %d) ? FieldSize : %d);\n' % > (FieldName, ValueSize, ValueSize) > + else: > + if ValueSize > 4: > + CApp =3D CApp + ' Pcd->%s =3D %dULL; // From %s= Line %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 Li= ne %d Value %s\n' % (FieldName, Value, > FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0]= ) > + CApp =3D CApp + "}\n" > + return CApp > + def GenerateCommandLineValueStatement(self,Pcd): > + CApp =3D ' Assign_%s_%s_CommandLine_Value(Pcd);\n' % (Pcd.Token= SpaceGuidCName, Pcd.TokenCName) > + return CApp > def GenerateInitializeFunc(self, SkuName, DefaultStore, Pcd, InitByt= eValue, CApp): > OverrideValues =3D {DefaultStore:""} > if Pcd.SkuOverrideValues: > OverrideValues =3D Pcd.SkuOverrideValues[SkuName] > for DefaultStoreName in OverrideValues.keys(): > @@ -1833,10 +1960,11 @@ class DscBuildData(PlatformBuildClassObject): > if skuname =3D=3D SkuName: > break > else: > CApp =3D CApp + "// SkuName: DEFAULT, DefaultStoreName:= STANDARD \n" > CApp =3D CApp + self.GenerateInitValueStatement(Pcd,"DEF= AULT","STANDARD") > + CApp =3D CApp + self.GenerateCommandLineValueStatement(Pcd) > # > # Set new PCD value and size > # > CApp =3D CApp + ' PcdSetPtr (%s, %s, %s, %s, Size, (UINT8 *= )Pcd);\n' % (SkuName, DefaultStoreName, > Pcd.TokenSpaceGuidCName, Pcd.TokenCName) >=20 > @@ -1868,10 +1996,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_= STRING_[MODEL_PCD_FIXED_AT_BUILD], > self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MO= DULE]]: > CApp =3D CApp + self.GenerateInitValueFunction(Pcd,self.= SkuIdMgr.SystemSkuId, 'STANDARD') > else: > for SkuName in self.SkuIdMgr.SkuOverrideOrder(): > @@ -2372,11 +2501,11 @@ class DscBuildData(PlatformBuildClassObject): >=20 > if pcd.MaxDatumSize.strip(): > MaxSize =3D int(pcd.MaxDatumSize, 0) > else: > MaxSize =3D 0 > - if pcdDecObject.DatumType =3D=3D 'VOID*': > + if pcd.DatumType not in ['BOOLEAN','UINT8','UINT16','UINT32'= ,'UINT64']: > for (_, skuobj) in pcd.SkuInfoList.items(): > datalen =3D 0 > skuobj.HiiDefaultValue =3D StringToArray(skuobj.HiiD= efaultValue) > datalen =3D len(skuobj.HiiDefaultValue.split(",")) > if datalen > MaxSize: > diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Py= thon/build/build.py > index bb130a02cc..85612d90ce 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 Buil= dOptions.OptionPcd else {} > + GlobalData.BuildOptionPcd =3D BuildOptions.OptionPcd if Buil= dOptions.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 > -- > 2.14.3.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel