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=bob.c.feng@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 E0D7D2034D8CB for ; Tue, 27 Feb 2018 21:53:21 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Feb 2018 21:59:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,404,1515484800"; d="scan'208";a="204307326" Received: from shwdeopenpsi105.ccr.corp.intel.com ([10.239.9.129]) by orsmga005.jf.intel.com with ESMTP; 27 Feb 2018 21:59:26 -0800 From: BobCF To: edk2-devel@lists.01.org Cc: Bob Feng , Liming Gao Date: Wed, 28 Feb 2018 13:59:18 +0800 Message-Id: <20180228055921.35432-1-bob.c.feng@intel.com> X-Mailer: git-send-email 2.14.3.windows.1 Subject: [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 05:53:22 -0000 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 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(-) diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/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 += " --genfds-multi-thread" if GlobalData.gIgnoreSource: ExtraOption += " --ignore-sources" - if GlobalData.BuildOptionPcd: - 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 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] 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 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 = collections.OrderedDict({}) self.FlexibleFieldName = None self.StructName = None self.PcdDefineLineNo = 0 self.PkgPath = "" + self.DefaultValueFromDec = "" def __repr__(self): return self.TypeName def AddDefaultValue (self, FieldName, Value, FileName="", LineNo=0): if FieldName in self.DefaultValues: del self.DefaultValues[FieldName] self.DefaultValues[FieldName] = [Value.strip(), FileName, LineNo] return self.DefaultValues[FieldName] + def SetDecDefaultValue(self,DefaultValue): + self.DefaultValueFromDec = DefaultValue def AddOverrideValue (self, FieldName, Value, SkuName, DefaultStoreName, FileName="", LineNo=0): if SkuName not in self.SkuOverrideValues: self.SkuOverrideValues[SkuName] = collections.OrderedDict({}) if DefaultStoreName not in self.SkuOverrideValues[SkuName]: self.SkuOverrideValues[SkuName][DefaultStoreName] = collections.OrderedDict({}) @@ -173,10 +176,11 @@ class StructurePcd(PcdClassObject): 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 self.DefaultFromDSC=None + self.DefaultValueFromDec = PcdObject.DefaultValueFromDec if PcdObject.DefaultValueFromDec else self.DefaultValueFromDec self.SkuOverrideValues = PcdObject.SkuOverrideValues if PcdObject.SkuOverrideValues else self.SkuOverrideValues 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 diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/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 = struct_pcd.TokenValue.strip("{").strip() struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName = pcdname.split(".") struct_pcd.PcdDefineLineNo = LineNo struct_pcd.PkgPath = self.MetaFile.File + struct_pcd.SetDecDefaultValue(item.DefaultValue) else: struct_pcd.AddDefaultValue(item.TokenCName, item.DefaultValue,self.MetaFile.File,LineNo) struct_pcd.PackageDecs = dep_pkgs if not struct_pcd.StructuredPcdIncludeFile: diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/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] == "": pcdset.append((pcd[0],pcd[1],pcd[3])) else: - pcdobj = self._Pcds.get((pcd[1],pcd[0])) - if pcdobj: - pcdset.append((pcd[0],pcd[1], pcdobj.DefaultValue)) - 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 GetFieldValueFromComm(self,ValueStr,TokenSpaceGuidCName, TokenCName, FieldName): PredictedFieldType = "VOID*" if ValueStr.startswith('L'): if not ValueStr[1]: @@ -1674,10 +1673,27 @@ class DscBuildData(PlatformBuildClassObject): # # Assign field values in PCD # CApp = CApp + "// Default value in Dec \n" + DefaultValueFromDec = Pcd.DefaultValueFromDec + IsArray = self.IsFieldValueAnArray(Pcd.DefaultValueFromDec) + if IsArray: + 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)) + Value, ValueSize = ParseFieldValue (DefaultValueFromDec) + if isinstance(Value, str): + CApp = CApp + ' Pcd = %s; // From DEC Default Value %s\n' % (Value, Pcd.DefaultValueFromDec) + elif IsArray: + # + # Use memcpy() to copy value into field + # + CApp = CApp + ' Value = %s; // From DEC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DefaultValueFromDec) + CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize) for FieldList in [Pcd.DefaultValues]: if not FieldList: continue for FieldName in FieldList: IsArray = self.IsFieldValueAnArray(FieldList[FieldName][0]) -- 2.14.3.windows.1