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 CC7252116821B for ; Wed, 24 Oct 2018 07:05:53 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Oct 2018 07:05:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,420,1534834800"; d="scan'208";a="275205395" Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.127]) by fmsmga006.fm.intel.com with ESMTP; 24 Oct 2018 07:05:52 -0700 From: Yonghong Zhu To: edk2-devel@lists.01.org Date: Wed, 24 Oct 2018 22:05:50 +0800 Message-Id: <1540389950-18188-1-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 Subject: [Patch V2] BaseTools: Fix the bug for Pcd used in command line's override X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Oct 2018 14:05:54 -0000 V2: remove the not used parameter i Fix the bug for Pcd used in command line not override the Pcd used in the [component] driver's sub-section. Case: DSC file: [PcdsFixedAtBuild] TokenSpaceGuid.PcdTest [Components] TestPkg/TestDriver.inf { TokenSpaceGuid.PcdTest|"b" } build command with --pcd TokenSpaceGuid.PcdTest="AAAABB" Then we found the Pcd value in the AutoGen.c file is incorrect, because of the incorrect logic that use the pcd in the [component] section to re-override it. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu --- BaseTools/Source/Python/AutoGen/AutoGen.py | 7 +++++++ BaseTools/Source/Python/Workspace/DscBuildData.py | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 804f579..84645e3 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -2118,10 +2118,17 @@ class PlatformAutoGen(AutoGen): # override PCD settings with module specific setting if Module in self.Platform.Modules: PlatformModule = self.Platform.Modules[str(Module)] for Key in PlatformModule.Pcds: + if GlobalData.BuildOptionPcd: + for pcd in GlobalData.BuildOptionPcd: + (TokenSpaceGuidCName, TokenCName, FieldName, pcdvalue, _) = pcd + if (TokenCName, TokenSpaceGuidCName) == Key and FieldName =="": + PlatformModule.Pcds[Key].DefaultValue = pcdvalue + PlatformModule.Pcds[Key].PcdValueFromComm = pcdvalue + break Flag = False if Key in Pcds: ToPcd = Pcds[Key] Flag = True elif Key in GlobalData.MixedPcd: diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index b0e88a9..162360c 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1058,11 +1058,16 @@ class DscBuildData(PlatformBuildClassObject): IsValid, Cause = CheckPcdDatum(PcdDatumType, pcdvalue) if not IsValid: EdkLogger.error("build", FORMAT_INVALID, Cause, ExtraData="%s.%s" % (TokenSpaceGuidCName, TokenCName)) GlobalData.BuildOptionPcd[i] = (TokenSpaceGuidCName, TokenCName, FieldName, pcdvalue, ("build command options", 1)) + if GlobalData.BuildOptionPcd: + for pcd in GlobalData.BuildOptionPcd: + (TokenSpaceGuidCName, TokenCName, FieldName, pcdvalue, _) = pcd for BuildData in self._Bdb._CACHE_.values(): + if BuildData.Arch != self.Arch: + continue if BuildData.MetaFile.Ext == '.dec' or BuildData.MetaFile.Ext == '.dsc': continue for key in BuildData.Pcds: PcdItem = BuildData.Pcds[key] if (TokenSpaceGuidCName, TokenCName) == (PcdItem.TokenSpaceGuidCName, PcdItem.TokenCName) and FieldName =="": -- 2.6.1.windows.1