From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 BB4F12034D8CA for ; Tue, 27 Feb 2018 22:50:52 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Feb 2018 22:56:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,404,1515484800"; d="scan'208";a="207644143" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga006.fm.intel.com with ESMTP; 27 Feb 2018 22:46:56 -0800 Received: from fmsmsx111.amr.corp.intel.com (10.18.116.5) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 27 Feb 2018 22:46:56 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx111.amr.corp.intel.com (10.18.116.5) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 27 Feb 2018 22:46:55 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.125]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.116]) with mapi id 14.03.0319.002; Wed, 28 Feb 2018 14:46:54 +0800 From: "Gao, Liming" To: "Feng, Bob C" , "edk2-devel@lists.01.org" Thread-Topic: [Patch 1/4] BaseTools: Fixed the pcd value override issue. Thread-Index: AQHTsFlP2cF3DvnMb0e4FCiUMB3XVqO5Xx0Q Date: Wed, 28 Feb 2018 06:46:54 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E1D4BE2@SHSMSX104.ccr.corp.intel.com> References: <20180228055921.35432-1-bob.c.feng@intel.com> In-Reply-To: <20180228055921.35432-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/4] BaseTools: Fixed the 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: Wed, 28 Feb 2018 06:50:54 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: Feng, Bob C > Sent: Wednesday, February 28, 2018 1:59 PM > To: edk2-devel@lists.01.org > Cc: Feng, Bob C ; Gao, Liming > Subject: [Patch 1/4] BaseTools: Fixed the pcd value override issue. >=20 > 1. the issue in the overriding value from command line. > 2. dec fully value < dec field assign value < > dsc fully value < dsc field assign value >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Bob Feng > Cc: Liming Gao > --- > BaseTools/Source/Python/AutoGen/GenMake.py | 39 +++++++++++-----= ------ > .../Source/Python/Workspace/BuildClassObject.py | 4 +++ > BaseTools/Source/Python/Workspace/DecBuildData.py | 1 + > BaseTools/Source/Python/Workspace/DscBuildData.py | 24 ++++++++++--- > 4 files changed, 44 insertions(+), 24 deletions(-) >=20 > diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Sourc= e/Python/AutoGen/GenMake.py > index 4b924d21e0..1b0cf17e25 100644 > --- a/BaseTools/Source/Python/AutoGen/GenMake.py > +++ b/BaseTools/Source/Python/AutoGen/GenMake.py > @@ -1549,30 +1549,29 @@ class TopLevelMakefile(BuildFile): > if GlobalData.gEnableGenfdsMultiThread: > ExtraOption +=3D " --genfds-multi-thread" > if GlobalData.gIgnoreSource: > ExtraOption +=3D " --ignore-sources" >=20 > - if GlobalData.BuildOptionPcd: > - for index, option in enumerate(GlobalData.gCommand): > - if "--pcd" =3D=3D option and GlobalData.gCommand[index+1= ]: > - pcdName, pcdValue =3D GlobalData.gCommand[index+1].s= plit('=3D') > - for Item in GlobalData.BuildOptionPcd: > - if '.'.join(Item[0:2]) =3D=3D pcdName: > - pcdValue =3D Item[2] > - if pcdValue.startswith('L') or pcdValue.star= tswith('"'): > - pcdValue, Size =3D ParseFieldValue(pcdVa= lue) > - NewVal =3D '{' > - for S in range(Size): > - NewVal =3D NewVal + '0x%02X' % ((pcd= Value >> S * 8) & 0xff) > - NewVal +=3D ',' > - pcdValue =3D NewVal[:-1] + '}' > - break > - if pcdValue.startswith('{'): > - pcdValue =3D 'H' + '"' + pcdValue + '"' > - ExtraOption +=3D " --pcd " + pcdName + '=3D' + p= cdValue > - else: > - ExtraOption +=3D " --pcd " + GlobalData.gCommand= [index+1] > + for index, option in enumerate(GlobalData.gCommand): > + if "--pcd" =3D=3D option and GlobalData.gCommand[index+1]: > + pcdName, pcdValue =3D GlobalData.gCommand[index+1].split= ('=3D') > + for Item in GlobalData.BuildOptionPcd: > + if '.'.join(Item[0:2]) =3D=3D pcdName: > + pcdValue =3D Item[2] > + if pcdValue.startswith('L') or pcdValue.startswi= th('"'): > + pcdValue, Size =3D ParseFieldValue(pcdValue) > + NewVal =3D '{' > + for S in range(Size): > + NewVal =3D NewVal + '0x%02X' % ((pcdValu= e >> S * 8) & 0xff) > + NewVal +=3D ',' > + pcdValue =3D NewVal[:-1] + '}' > + break > + if pcdValue.startswith('{'): > + pcdValue =3D 'H' + '"' + pcdValue + '"' > + ExtraOption +=3D " --pcd " + pcdName + '=3D' + pcdVa= lue > + else: > + ExtraOption +=3D " --pcd " + GlobalData.gCommand[ind= ex+1] >=20 > MakefileName =3D self._FILE_NAME_[self._FileType] > SubBuildCommandList =3D [] > for A in PlatformInfo.ArchList: > Command =3D self._MAKE_TEMPLATE_[self._FileType] % {"file":o= s.path.join("$(BUILD_DIR)", A, MakefileName)} > diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/Base= Tools/Source/Python/Workspace/BuildClassObject.py > index f499cbd58b..05a83e84ac 100644 > --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py > +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py > @@ -124,19 +124,22 @@ class StructurePcd(PcdClassObject): > self.SkuOverrideValues =3D collections.OrderedDict({}) > self.FlexibleFieldName =3D None > self.StructName =3D None > self.PcdDefineLineNo =3D 0 > self.PkgPath =3D "" > + self.DefaultValueFromDec =3D "" > def __repr__(self): > return self.TypeName >=20 > def AddDefaultValue (self, FieldName, Value, FileName=3D"", LineNo= =3D0): > if FieldName in self.DefaultValues: > del self.DefaultValues[FieldName] > self.DefaultValues[FieldName] =3D [Value.strip(), FileName, Line= No] > return self.DefaultValues[FieldName] >=20 > + def SetDecDefaultValue(self,DefaultValue): > + self.DefaultValueFromDec =3D DefaultValue > def AddOverrideValue (self, FieldName, Value, SkuName, DefaultStoreN= ame, FileName=3D"", LineNo=3D0): > if SkuName not in self.SkuOverrideValues: > self.SkuOverrideValues[SkuName] =3D collections.OrderedDict(= {}) > if DefaultStoreName not in self.SkuOverrideValues[SkuName]: > self.SkuOverrideValues[SkuName][DefaultStoreName] =3D collec= tions.OrderedDict({}) > @@ -173,10 +176,11 @@ class StructurePcd(PcdClassObject): > self.StructuredPcdIncludeFile =3D PcdObject.StructuredPcdInc= ludeFile if PcdObject.StructuredPcdIncludeFile else > self.StructuredPcdIncludeFile > self.PackageDecs =3D PcdObject.PackageDecs if PcdObject.Pack= ageDecs else self.PackageDecs > self.DefaultValues =3D PcdObject.DefaultValues if PcdObject.= DefaultValues else self.DefaultValues > self.PcdMode =3D PcdObject.PcdMode if PcdObject.PcdMode else= self.PcdMode > self.DefaultFromDSC=3DNone > + self.DefaultValueFromDec =3D PcdObject.DefaultValueFromDec i= f PcdObject.DefaultValueFromDec else > self.DefaultValueFromDec > self.SkuOverrideValues =3D PcdObject.SkuOverrideValues if Pc= dObject.SkuOverrideValues else self.SkuOverrideValues > 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 > diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTool= s/Source/Python/Workspace/DecBuildData.py > index 99c3bf14f1..61f15086d0 100644 > --- a/BaseTools/Source/Python/Workspace/DecBuildData.py > +++ b/BaseTools/Source/Python/Workspace/DecBuildData.py > @@ -383,10 +383,11 @@ class DecBuildData(PackageBuildClassObject): > struct_pcd.copy(item) > struct_pcd.TokenValue =3D struct_pcd.TokenValue.stri= p("{").strip() > struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCNam= e =3D pcdname.split(".") > struct_pcd.PcdDefineLineNo =3D LineNo > struct_pcd.PkgPath =3D self.MetaFile.File > + struct_pcd.SetDecDefaultValue(item.DefaultValue) > else: > struct_pcd.AddDefaultValue(item.TokenCName, item.Def= aultValue,self.MetaFile.File,LineNo) >=20 > struct_pcd.PackageDecs =3D dep_pkgs > if not struct_pcd.StructuredPcdIncludeFile: > diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTool= s/Source/Python/Workspace/DscBuildData.py > index ea8d1847f7..393ad0265f 100644 > --- a/BaseTools/Source/Python/Workspace/DscBuildData.py > +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py > @@ -892,16 +892,15 @@ class DscBuildData(PlatformBuildClassObject): > 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.DefaultValu= e)) > - else: > + if (pcd[1],pcd[0]) not in self._Pcds: > pcdvalue =3D pcd[3] if len(pcd) =3D=3D 4 else pc= d[2] > pcdset.append((pcd[0],pcd[1],pcdvalue)) > + #else: > + # remove the settings from command line since it= has been handled. > GlobalData.BuildOptionPcd =3D pcdset > def GetFieldValueFromComm(self,ValueStr,TokenSpaceGuidCName, TokenCN= ame, FieldName): > PredictedFieldType =3D "VOID*" > if ValueStr.startswith('L'): > if not ValueStr[1]: > @@ -1674,10 +1673,27 @@ class DscBuildData(PlatformBuildClassObject): >=20 > # > # Assign field values in PCD > # > CApp =3D CApp + "// Default value in Dec \n" > + DefaultValueFromDec =3D Pcd.DefaultValueFromDec > + IsArray =3D self.IsFieldValueAnArray(Pcd.DefaultValueFromDec= ) > + if IsArray: > + try: > + DefaultValueFromDec =3D ValueExpressionEx(Pcd.Defaul= tValueFromDec, "VOID*")(True) > + except BadExpression: > + EdkLogger.error("Build", FORMAT_INVALID, "Invalid va= lue format for %s.%s, from DEC: %s" % > + (Pcd.TokenSpaceGuidCName, Pcd.TokenC= Name, DefaultValueFromDec)) > + Value, ValueSize =3D ParseFieldValue (DefaultValueFromDec) > + if isinstance(Value, str): > + CApp =3D CApp + ' Pcd =3D %s; // From DEC Default Value= %s\n' % (Value, Pcd.DefaultValueFromDec) > + elif IsArray: > + # > + # Use memcpy() to copy value into field > + # > + CApp =3D CApp + ' Value =3D %s; // From DEC Default= Value %s\n' % (self.IntToCString(Value, ValueSize), > Pcd.DefaultValueFromDec) > + CApp =3D CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueS= ize) > for FieldList in [Pcd.DefaultValues]: > if not FieldList: > continue > for FieldName in FieldList: > IsArray =3D self.IsFieldValueAnArray(FieldList[Field= Name][0]) > -- > 2.14.3.windows.1