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.100; helo=mga07.intel.com; envelope-from=bob.c.feng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 8C758224DCA3D for ; Wed, 7 Mar 2018 19:21:34 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Mar 2018 19:27:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,438,1515484800"; d="scan'208";a="23850071" Received: from shwdeopenpsi105.ccr.corp.intel.com ([10.239.9.129]) by orsmga006.jf.intel.com with ESMTP; 07 Mar 2018 19:27:48 -0800 From: BobCF To: edk2-devel@lists.01.org Cc: Bob Feng , Liming Gao Date: Thu, 8 Mar 2018 11:27:46 +0800 Message-Id: <20180308032746.7788-1-bob.c.feng@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 Subject: [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: Thu, 08 Mar 2018 03:21:34 -0000 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 | 25 +++++------------ .../Source/Python/Workspace/BuildClassObject.py | 4 +-- BaseTools/Source/Python/Workspace/DscBuildData.py | 31 +++++++++++----------- 4 files changed, 28 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 = '_PCD_TOKEN_' + TokenCName PatchPcdSizeTokenName = '_PCD_PATCHABLE_' + TokenCName +'_SIZE' PatchPcdSizeVariableName = '_gPcd_BinaryPatch_Size_' + TokenCName FixPcdSizeTokenName = '_PCD_SIZE_' + TokenCName - if GlobalData.BuildOptionPcd: - for PcdItem in GlobalData.BuildOptionPcd: - if (Pcd.TokenSpaceGuidCName, TokenCName) == (PcdItem[0], PcdItem[1]): - Pcd.DefaultValue = PcdItem[2] - break + if Pcd.PcdValueFromComm: + Pcd.DefaultValue = Pcd.PcdValueFromComm if Pcd.Type in gDynamicExPcd: TokenNumber = int(Pcd.TokenValue, 0) # Add TokenSpaceGuidValue value to PcdTokenName to discriminate the DynamicEx PCDs with # different Guids but same TokenCName @@ -1213,16 +1210,12 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): PcdTokenName = '_PCD_TOKEN_' + TokenCName FixPcdSizeTokenName = '_PCD_SIZE_' + TokenCName PatchPcdSizeTokenName = '_PCD_PATCHABLE_' + TokenCName +'_SIZE' PatchPcdSizeVariableName = '_gPcd_BinaryPatch_Size_' + TokenCName - if GlobalData.BuildOptionPcd: - for PcdItem in GlobalData.BuildOptionPcd: - if (Pcd.TokenSpaceGuidCName, TokenCName) == (PcdItem[0], PcdItem[1]): - Pcd.DefaultValue = PcdItem[2] - break - + if Pcd.PcdValueFromComm: + Pcd.DefaultValue = Pcd.PcdValueFromComm # # Write PCDs # if Pcd.Type in gDynamicExPcd: TokenNumber = int(Pcd.TokenValue, 0) diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index 1b0cf17e25..0a3cc32155 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -1549,29 +1549,16 @@ class TopLevelMakefile(BuildFile): if GlobalData.gEnableGenfdsMultiThread: ExtraOption += " --genfds-multi-thread" if GlobalData.gIgnoreSource: ExtraOption += " --ignore-sources" - for index, option in enumerate(GlobalData.gCommand): - if "--pcd" == option and GlobalData.gCommand[index+1]: - pcdName, pcdValue = GlobalData.gCommand[index+1].split('=') - for Item in GlobalData.BuildOptionPcd: - if '.'.join(Item[0:2]) == pcdName: - pcdValue = Item[2] - if pcdValue.startswith('L') or pcdValue.startswith('"'): - pcdValue, Size = ParseFieldValue(pcdValue) - NewVal = '{' - for S in range(Size): - NewVal = NewVal + '0x%02X' % ((pcdValue >> S * 8) & 0xff) - NewVal += ',' - pcdValue = NewVal[:-1] + '}' - break - if pcdValue.startswith('{'): - pcdValue = 'H' + '"' + pcdValue + '"' - ExtraOption += " --pcd " + pcdName + '=' + pcdValue - else: - ExtraOption += " --pcd " + GlobalData.gCommand[index+1] + for pcd in GlobalData.BuildOptionPcd: + if pcd[2]: + pcdname = '.'.join(pcd[0:3]) + else: + pcdname = '.'.join(pcd[0:2]) + ExtraOption += " --pcd " + pcdname + '=' + pcd[3] MakefileName = self._FILE_NAME_[self._FileType] SubBuildCommandList = [] for A in PlatformInfo.ArchList: Command = 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 = expressions self.DscDefaultValue = None self.DscRawValue = None if IsDsc: self.DscDefaultValue = Value + self.PcdValueFromComm = "" ## 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 = None self.PcdDefineLineNo = 0 self.PkgPath = "" self.DefaultValueFromDec = "" self.ValueChain = dict() - self.PcdValueFromComm = "" self.PcdFieldValueFromComm = collections.OrderedDict({}) def __repr__(self): return self.TypeName def AddDefaultValue (self, FieldName, Value, FileName="", LineNo=0): @@ -175,10 +175,11 @@ class StructurePcd(PcdClassObject): self.IsFromDsc = PcdObject.IsFromDsc if PcdObject.IsFromDsc else self.IsFromDsc self.validateranges = PcdObject.validateranges if PcdObject.validateranges else self.validateranges self.validlists = PcdObject.validlists if PcdObject.validlists else self.validlists self.expressions = PcdObject.expressions if PcdObject.expressions else self.expressions self.DscRawValue = PcdObject.DscRawValue if PcdObject.DscRawValue else self.DscRawValue + self.PcdValueFromComm = PcdObject.PcdValueFromComm if PcdObject.PcdValueFromComm else self.PcdValueFromComm if type(PcdObject) is StructurePcd: self.StructuredPcdIncludeFile = PcdObject.StructuredPcdIncludeFile if PcdObject.StructuredPcdIncludeFile else self.StructuredPcdIncludeFile self.PackageDecs = PcdObject.PackageDecs if PcdObject.PackageDecs else self.PackageDecs self.DefaultValues = PcdObject.DefaultValues if PcdObject.DefaultValues else self.DefaultValues self.PcdMode = PcdObject.PcdMode if PcdObject.PcdMode else self.PcdMode @@ -188,11 +189,10 @@ class StructurePcd(PcdClassObject): self.FlexibleFieldName = PcdObject.FlexibleFieldName if PcdObject.FlexibleFieldName else self.FlexibleFieldName self.StructName = PcdObject.DatumType if PcdObject.DatumType else self.StructName self.PcdDefineLineNo = PcdObject.PcdDefineLineNo if PcdObject.PcdDefineLineNo else self.PcdDefineLineNo self.PkgPath = PcdObject.PkgPath if PcdObject.PkgPath else self.PkgPath self.ValueChain = PcdObject.ValueChain if PcdObject.ValueChain else self.ValueChain - self.PcdValueFromComm = PcdObject.PcdValueFromComm if PcdObject.PcdValueFromComm else self.PcdValueFromComm self.PcdFieldValueFromComm = PcdObject.PcdFieldValueFromComm 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 = DefaultStoreMgr.GetMin(PcdDefaultStoreSet) skuobj.DefaultStoreDict['STANDARD'] = copy.deepcopy(skuobj.DefaultStoreDict[mindefaultstorename]) return Pcds def RecoverCommandLinePcd(self): - pcdset = [] - if GlobalData.BuildOptionPcd: - for pcd in GlobalData.BuildOptionPcd: - if pcd[2] == "": - pcdset.append((pcd[0],pcd[1],pcd[3])) - else: - if (pcd[1],pcd[0]) not in self._Pcds: - pcdvalue = pcd[3] if len(pcd) == 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 = 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 = 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 = pcd.SkuInfoList.get("DEFAULT").HiiDefaultValue + else: + pcd.PcdValueFromComm = 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 = "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 format: "string", L"string", H"{...}"') @@ -1240,10 +1240,11 @@ class DscBuildData(PlatformBuildClassObject): if (Name,Guid) in AllPcds: Pcd = AllPcds.get((Name,Guid)) if isinstance(self._DecPcds.get((Pcd.TokenCName,Pcd.TokenSpaceGuidCName), None),StructurePcd): self._DecPcds.get((Pcd.TokenCName,Pcd.TokenSpaceGuidCName)).PcdValueFromComm = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0] else: + Pcd.PcdValueFromComm = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0] Pcd.DefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0] for sku in Pcd.SkuInfoList: SkuInfo = Pcd.SkuInfoList[sku] if SkuInfo.DefaultValue: SkuInfo.DefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0] @@ -1264,13 +1265,12 @@ class DscBuildData(PlatformBuildClassObject): else: MaxSize = max([len(Pcd.DefaultValue),MaxSize]) Pcd.MaxDatumSize = str(MaxSize) else: PcdInDec = self.DecPcds.get((Name,Guid)) - if isinstance(PcdInDec,StructurePcd): - PcdInDec.PcdValueFromComm = NoFiledValues[(Guid,Name)][0] if PcdInDec: + PcdInDec.PcdValueFromComm = NoFiledValues[(Guid,Name)][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] = copy.deepcopy(PcdInDec) self.Pcds[Name, Guid].DefaultValue = NoFiledValues[( Guid,Name)][0] return AllPcds @@ -1709,10 +1709,11 @@ class DscBuildData(PlatformBuildClassObject): try: DefaultValueFromDec = ValueExpressionEx(Pcd.DefaultValueFromDec, "VOID*")(True) except BadExpression: EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from DEC: %s" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, DefaultValueFromDec)) + DefaultValueFromDec = StringToArray(DefaultValueFromDec) Value, ValueSize = ParseFieldValue (DefaultValueFromDec) if isinstance(Value, str): CApp = CApp + ' Pcd = %s; // From DEC Default Value %s\n' % (Value, Pcd.DefaultValueFromDec) elif IsArray: # @@ -1848,11 +1849,11 @@ class DscBuildData(PlatformBuildClassObject): IsArray = self.IsFieldValueAnArray(FieldList) if IsArray: try: FieldList = 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.TokenCName, FieldList)) Value, ValueSize = ParseFieldValue (FieldList) if isinstance(Value, str): CApp = CApp + ' Pcd = %s; // From Command Line \n' % (Value) -- 2.14.3.windows.1