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.24; helo=mga09.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 B16ED22436945 for ; Sun, 25 Feb 2018 23:43:13 -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 orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Feb 2018 23:49:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,396,1515484800"; d="scan'208";a="203749673" Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.129]) by orsmga005.jf.intel.com with ESMTP; 25 Feb 2018 23:49:17 -0800 From: Yonghong Zhu To: edk2-devel@lists.01.org Date: Mon, 26 Feb 2018 15:49:16 +0800 Message-Id: <1519631356-2620-1-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 Subject: [Patch] BaseTools: Fix a bug override Pcd by DSC Components section 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: Mon, 26 Feb 2018 07:43:14 -0000 The case is: define a VOID* pcd in DEC file, eg: Value is {0x1}. then override this PCD on DSC component section, eg: Value is {0x1, 0x2, 0x3}, the max size of this PCD is calculate wrong which cause build error. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu --- BaseTools/Source/Python/AutoGen/AutoGen.py | 15 ++++++++++++++- BaseTools/Source/Python/Workspace/DscBuildData.py | 5 +++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 405bfa1..19c65b3 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -2412,11 +2412,11 @@ class PlatformAutoGen(AutoGen): ExtraData="%s.%s" % (ToPcd.TokenSpaceGuidCName, TokenCName)) ToPcd.validateranges = FromPcd.validateranges ToPcd.validlists = FromPcd.validlists ToPcd.expressions = FromPcd.expressions - if ToPcd.DatumType == "VOID*" and ToPcd.MaxDatumSize in ['', None]: + if FromPcd != None and ToPcd.DatumType == "VOID*" and ToPcd.MaxDatumSize in ['', None]: EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified for PCD %s.%s" \ % (ToPcd.TokenSpaceGuidCName, TokenCName)) Value = ToPcd.DefaultValue if Value in [None, '']: ToPcd.MaxDatumSize = '1' @@ -2485,10 +2485,23 @@ class PlatformAutoGen(AutoGen): ToPcd = Pcds[PcdItem] Flag = True break if Flag: self._OverridePcd(ToPcd, PlatformModule.Pcds[Key], Module) + # use PCD value to calculate the MaxDatumSize when it is not specified + for Name, Guid in Pcds: + Pcd = Pcds[Name, Guid] + if Pcd.DatumType == "VOID*" and Pcd.MaxDatumSize in ['', None]: + Value = Pcd.DefaultValue + if Value in [None, '']: + Pcd.MaxDatumSize = '1' + elif Value[0] == 'L': + Pcd.MaxDatumSize = str((len(Value) - 2) * 2) + elif Value[0] == '{': + Pcd.MaxDatumSize = str(len(Value.split(','))) + else: + Pcd.MaxDatumSize = str(len(Value) - 1) return Pcds.values() ## Resolve library names to library modules # # (for Edk.x modules) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 75b877a..32b1df9 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -677,12 +677,13 @@ class DscBuildData(PlatformBuildClassObject): MODEL_PCD_FEATURE_FLAG, MODEL_PCD_DYNAMIC, MODEL_PCD_DYNAMIC_EX]: RecordList = self._RawData[Type, self._Arch, None, ModuleId] for TokenSpaceGuid, PcdCName, Setting, Dummy1, Dummy2, Dummy3, Dummy4,Dummy5 in RecordList: TokenList = GetSplitValueList(Setting) DefaultValue = TokenList[0] - if len(TokenList) > 1: - MaxDatumSize = TokenList[1] + # the format is PcdName| Value | VOID* | MaxDatumSize + if len(TokenList) > 2: + MaxDatumSize = TokenList[2] else: MaxDatumSize = '' TypeString = self._PCD_TYPE_STRING_[Type] Pcd = PcdClassObject( PcdCName, -- 2.6.1.windows.1