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.136; helo=mga12.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (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 495FE224DCA48 for ; Thu, 8 Mar 2018 18:03:06 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Mar 2018 18:09:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,443,1515484800"; d="scan'208";a="181186733" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga004.jf.intel.com with ESMTP; 08 Mar 2018 18:09:22 -0800 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 8 Mar 2018 18:09:21 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 8 Mar 2018 18:09:20 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.226]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.108]) with mapi id 14.03.0319.002; Fri, 9 Mar 2018 10:09:19 +0800 From: "Gao, Liming" To: "Feng, Bob C" , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [Patch] BaseTools: Fixed Pcd from command line issue. Thread-Index: AQHTtqJGsZYHIaJ4rU6amT3aG/AcsaPHKfYw Date: Fri, 9 Mar 2018 02:09:18 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E1E1EDE@SHSMSX104.ccr.corp.intel.com> References: <20180308055621.10952-1-bob.c.feng@intel.com> In-Reply-To: <20180308055621.10952-1-bob.c.feng@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] BaseTools: Fixed Pcd from command line 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, 09 Mar 2018 02:03:06 -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 >BobCF >Sent: Thursday, March 08, 2018 1:56 PM >To: edk2-devel@lists.01.org >Cc: Gao, Liming >Subject: [edk2] [Patch] BaseTools: Fixed Pcd from command line issue. > >Save the pcd command line value in Pcd object > >Contributed-under: TianoCore Contribution Agreement 1.1 >Signed-off-by: Bob Feng >Cc: Liming Gao >--- > BaseTools/Source/Python/AutoGen/GenC.py | 15 +++-------- > BaseTools/Source/Python/AutoGen/GenMake.py | 28 +++++++----------= - >- > .../Source/Python/Workspace/BuildClassObject.py | 4 +-- > BaseTools/Source/Python/Workspace/DscBuildData.py | 31 +++++++++++--- >-------- > 4 files changed, 31 insertions(+), 47 deletions(-) > >diff --git a/BaseTools/Source/Python/AutoGen/GenC.py >b/BaseTools/Source/Python/AutoGen/GenC.py >index 3e98506cc8..481c4dda14 100644 >--- a/BaseTools/Source/Python/AutoGen/GenC.py >+++ b/BaseTools/Source/Python/AutoGen/GenC.py >@@ -914,15 +914,12 @@ def CreateModulePcdCode(Info, AutoGenC, >AutoGenH, Pcd): > PcdTokenName =3D '_PCD_TOKEN_' + TokenCName > PatchPcdSizeTokenName =3D '_PCD_PATCHABLE_' + TokenCName +'_SIZE' > PatchPcdSizeVariableName =3D '_gPcd_BinaryPatch_Size_' + TokenCName > FixPcdSizeTokenName =3D '_PCD_SIZE_' + TokenCName > >- if GlobalData.BuildOptionPcd: >- for PcdItem in GlobalData.BuildOptionPcd: >- if (Pcd.TokenSpaceGuidCName, TokenCName) =3D=3D (PcdItem[0], >PcdItem[1]): >- Pcd.DefaultValue =3D PcdItem[2] >- break >+ if Pcd.PcdValueFromComm: >+ Pcd.DefaultValue =3D Pcd.PcdValueFromComm > > if Pcd.Type in gDynamicExPcd: > TokenNumber =3D int(Pcd.TokenValue, 0) > # Add TokenSpaceGuidValue value to PcdTokenName to discriminate t= he >DynamicEx PCDs with > # different Guids but same TokenCName >@@ -1213,16 +1210,12 @@ def CreateLibraryPcdCode(Info, AutoGenC, >AutoGenH, Pcd): > PcdTokenName =3D '_PCD_TOKEN_' + TokenCName > FixPcdSizeTokenName =3D '_PCD_SIZE_' + TokenCName > PatchPcdSizeTokenName =3D '_PCD_PATCHABLE_' + TokenCName +'_SIZE' > PatchPcdSizeVariableName =3D '_gPcd_BinaryPatch_Size_' + TokenCName > >- if GlobalData.BuildOptionPcd: >- for PcdItem in GlobalData.BuildOptionPcd: >- if (Pcd.TokenSpaceGuidCName, TokenCName) =3D=3D (PcdItem[0], >PcdItem[1]): >- Pcd.DefaultValue =3D PcdItem[2] >- break >- >+ if Pcd.PcdValueFromComm: >+ Pcd.DefaultValue =3D Pcd.PcdValueFromComm > # > # Write PCDs > # > if Pcd.Type in gDynamicExPcd: > TokenNumber =3D int(Pcd.TokenValue, 0) >diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py >b/BaseTools/Source/Python/AutoGen/GenMake.py >index 1b0cf17e25..60bd625cd2 100644 >--- a/BaseTools/Source/Python/AutoGen/GenMake.py >+++ b/BaseTools/Source/Python/AutoGen/GenMake.py >@@ -1549,29 +1549,19 @@ class TopLevelMakefile(BuildFile): > if GlobalData.gEnableGenfdsMultiThread: > ExtraOption +=3D " --genfds-multi-thread" > if GlobalData.gIgnoreSource: > ExtraOption +=3D " --ignore-sources" > >- 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.startswit= h('"'): >- pcdValue, Size =3D ParseFieldValue(pcdValue) >- NewVal =3D '{' >- for S in range(Size): >- NewVal =3D NewVal + '0x%02X' % ((pcdValue= >> S * 8) & 0xff) >- NewVal +=3D ',' >- pcdValue =3D NewVal[:-1] + '}' >- break >- if pcdValue.startswith('{'): >- pcdValue =3D 'H' + '"' + pcdValue + '"' >- ExtraOption +=3D " --pcd " + pcdName + '=3D' + pcdVal= ue >- else: >- ExtraOption +=3D " --pcd " + GlobalData.gCommand[inde= x+1] >+ for pcd in GlobalData.BuildOptionPcd: >+ if pcd[2]: >+ pcdname =3D '.'.join(pcd[0:3]) >+ else: >+ pcdname =3D '.'.join(pcd[0:2]) >+ if pcd[3].startswith('{'): >+ ExtraOption +=3D " --pcd " + pcdname + '=3D' + 'H' + '"' = + pcd[3] + '"' >+ else: >+ ExtraOption +=3D " --pcd " + pcdname + '=3D' + pcd[3] > > MakefileName =3D self._FILE_NAME_[self._FileType] > SubBuildCommandList =3D [] > for A in PlatformInfo.ArchList: > Command =3D self._MAKE_TEMPLATE_[self._FileType] % >{"file":os.path.join("$(BUILD_DIR)", A, MakefileName)} >diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py >b/BaseTools/Source/Python/Workspace/BuildClassObject.py >index 711ba492ef..1352fa21c8 100644 >--- a/BaseTools/Source/Python/Workspace/BuildClassObject.py >+++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py >@@ -66,10 +66,11 @@ class PcdClassObject(object): > self.expressions =3D expressions > self.DscDefaultValue =3D None > self.DscRawValue =3D None > if IsDsc: > self.DscDefaultValue =3D Value >+ self.PcdValueFromComm =3D "" > > ## Convert the class to a string > # > # Convert each member of the class to string > # Organize to a signle line format string >@@ -127,11 +128,10 @@ 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 > > def AddDefaultValue (self, FieldName, Value, FileName=3D"", LineNo=3D= 0): >@@ -175,10 +175,11 @@ class StructurePcd(PcdClassObject): > self.IsFromDsc =3D PcdObject.IsFromDsc if PcdObject.IsFromDsc els= e >self.IsFromDsc > self.validateranges =3D PcdObject.validateranges if >PcdObject.validateranges else self.validateranges > self.validlists =3D PcdObject.validlists if PcdObject.validlists = else self.validlists > self.expressions =3D PcdObject.expressions if PcdObject.expressio= ns else >self.expressions > self.DscRawValue =3D PcdObject.DscRawValue if PcdObject.DscRawVal= ue >else self.DscRawValue >+ self.PcdValueFromComm =3D PcdObject.PcdValueFromComm if >PcdObject.PcdValueFromComm else self.PcdValueFromComm > if type(PcdObject) is StructurePcd: > self.StructuredPcdIncludeFile =3D PcdObject.StructuredPcdIncl= udeFile if >PcdObject.StructuredPcdIncludeFile else self.StructuredPcdIncludeFile > self.PackageDecs =3D PcdObject.PackageDecs if PcdObject.Packa= geDecs >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 >@@ -188,11 +189,10 @@ class StructurePcd(PcdClassObject): > self.FlexibleFieldName =3D PcdObject.FlexibleFieldName if >PcdObject.FlexibleFieldName else self.FlexibleFieldName > self.StructName =3D PcdObject.DatumType if PcdObject.DatumTyp= e else >self.StructName > self.PcdDefineLineNo =3D PcdObject.PcdDefineLineNo if >PcdObject.PcdDefineLineNo else self.PcdDefineLineNo > self.PkgPath =3D PcdObject.PkgPath if PcdObject.PkgPath else >self.PkgPath > self.ValueChain =3D PcdObject.ValueChain if PcdObject.ValueCh= ain else >self.ValueChain >- self.PcdValueFromComm =3D PcdObject.PcdValueFromComm if >PcdObject.PcdValueFromComm else self.PcdValueFromComm > self.PcdFieldValueFromComm =3D PcdObject.PcdFieldValueFromCom= m if >PcdObject.PcdFieldValueFromComm else self.PcdFieldValueFromComm > > ## 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 9d787702c2..e72b7779ce 100644 >--- a/BaseTools/Source/Python/Workspace/DscBuildData.py >+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py >@@ -891,22 +891,22 @@ class DscBuildData(PlatformBuildClassObject): > mindefaultstorename =3D >DefaultStoreMgr.GetMin(PcdDefaultStoreSet) > skuobj.DefaultStoreDict['STANDARD'] =3D >copy.deepcopy(skuobj.DefaultStoreDict[mindefaultstorename]) > return Pcds > > 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: >- if (pcd[1],pcd[0]) not in self._Pcds: >- pcdvalue =3D pcd[3] if len(pcd) =3D=3D 4 else pcd= [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 UpdateCommandLineValue(pcd): >+ if pcd.Type in >[self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], >+ >self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]: >+ pcd.PcdValueFromComm =3D pcd.DefaultValue >+ elif pcd.Type in >[self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], >self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]: >+ pcd.PcdValueFromComm =3D >pcd.SkuInfoList.get("DEFAULT").HiiDefaultValue >+ else: >+ pcd.PcdValueFromComm =3D >pcd.SkuInfoList.get("DEFAULT").DefaultValue >+ for pcd in self._Pcds: >+ if isinstance(self._Pcds[pcd],StructurePcd) and >(self._Pcds[pcd].PcdValueFromComm or >self._Pcds[pcd].PcdFieldValueFromComm): >+ UpdateCommandLineValue(self._Pcds[pcd]) >+ > def GetFieldValueFromComm(self,ValueStr,TokenSpaceGuidCName, >TokenCName, FieldName): > PredictedFieldType =3D "VOID*" > if ValueStr.startswith('L'): > if not ValueStr[1]: > EdkLogger.error("build", FORMAT_INVALID, 'For Void* type = PCD, >when specify the Value in the command line, please use the following forma= t: >"string", L"string", H"{...}"') >@@ -1240,10 +1240,11 @@ class DscBuildData(PlatformBuildClassObject): > if (Name,Guid) in AllPcds: > Pcd =3D AllPcds.get((Name,Guid)) > if >isinstance(self._DecPcds.get((Pcd.TokenCName,Pcd.TokenSpaceGuidCName), >None),StructurePcd): > >self._DecPcds.get((Pcd.TokenCName,Pcd.TokenSpaceGuidCName)).PcdValu >eFromComm =3D >NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0] > else: >+ Pcd.PcdValueFromComm =3D >NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0] > Pcd.DefaultValue =3D >NoFiledValues[(Pcd.TokenSpaceGuidCName,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] >@@ -1264,13 +1265,12 @@ class DscBuildData(PlatformBuildClassObject): > else: > MaxSize =3D max([len(Pcd.DefaultValue),MaxSiz= e]) > Pcd.MaxDatumSize =3D str(MaxSize) > else: > PcdInDec =3D self.DecPcds.get((Name,Guid)) >- if isinstance(PcdInDec,StructurePcd): >- PcdInDec.PcdValueFromComm =3D NoFiledValues[(Guid,Nam= e)][0] > if PcdInDec: >+ PcdInDec.PcdValueFromComm =3D NoFiledValues[(Guid,Nam= e)][0] > if PcdInDec.Type in >[self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD], > >self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]: > self.Pcds[Name, Guid] =3D copy.deepcopy(PcdInDec) > self.Pcds[Name, Guid].DefaultValue =3D >NoFiledValues[( Guid,Name)][0] > return AllPcds >@@ -1709,10 +1709,11 @@ class DscBuildData(PlatformBuildClassObject): > try: > DefaultValueFromDec =3D >ValueExpressionEx(Pcd.DefaultValueFromDec, "VOID*")(True) > except BadExpression: > EdkLogger.error("Build", FORMAT_INVALID, "Invalid value f= ormat >for %s.%s, from DEC: %s" % > (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, >DefaultValueFromDec)) >+ DefaultValueFromDec =3D StringToArray(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: > # >@@ -1848,11 +1849,11 @@ class DscBuildData(PlatformBuildClassObject): > 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" % >+ EdkLogger.error("Build", FORMAT_INVALID, "Invalid= value >format for %s.%s, from Command: %s" % > (Pcd.TokenSpaceGuidCName, Pcd.Tok= enCName, >FieldList)) > Value, ValueSize =3D ParseFieldValue (FieldList) > > if isinstance(Value, str): > CApp =3D CApp + ' Pcd =3D %s; // From Command Line \= n' % (Value) >-- >2.14.3.windows.1 > >_______________________________________________ >edk2-devel mailing list >edk2-devel@lists.01.org >https://lists.01.org/mailman/listinfo/edk2-devel