From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 4444B21A04E31 for ; Thu, 11 May 2017 22:11:59 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 May 2017 22:11:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,327,1491289200"; d="scan'208";a="260202162" Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.121]) by fmsmga004.fm.intel.com with ESMTP; 11 May 2017 22:11:57 -0700 From: Yonghong Zhu To: edk2-devel@lists.01.org Cc: Liming Gao Date: Fri, 12 May 2017 13:11:54 +0800 Message-Id: <1494565914-75644-1-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 Subject: [Patch] BaseTools: Fix the bug for CArray PCD override in command line X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 May 2017 05:11:59 -0000 This patch updated the CArray PCD override format from B"{}" to H"{}" which align to build spec. Besides, it also do the clean up for the function BuildOptionPcdValueFormat. Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu --- BaseTools/Source/Python/AutoGen/AutoGen.py | 29 ++--------------------------- BaseTools/Source/Python/AutoGen/GenMake.py | 12 ++++++++++-- BaseTools/Source/Python/Common/Misc.py | 26 ++++++++++++++++++++++++++ BaseTools/Source/Python/GenFds/GenFds.py | 26 +------------------------- 4 files changed, 39 insertions(+), 54 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 8d8957b..736c1ae 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -414,20 +414,20 @@ class WorkspaceAutoGen(AutoGen): for key in package.Pcds: PcdItem = package.Pcds[key] if HasTokenSpace: if (PcdItem.TokenCName, PcdItem.TokenSpaceGuidCName) == (TokenCName, TokenSpaceGuidCName): PcdDatumType = PcdItem.DatumType - NewValue = self._BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue) + NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue) FoundFlag = True else: if PcdItem.TokenCName == TokenCName: if not PcdItem.TokenSpaceGuidCName in TokenSpaceGuidCNameList: if len (TokenSpaceGuidCNameList) < 1: TokenSpaceGuidCNameList.append(PcdItem.TokenSpaceGuidCName) PcdDatumType = PcdItem.DatumType TokenSpaceGuidCName = PcdItem.TokenSpaceGuidCName - NewValue = self._BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue) + NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue) FoundFlag = True else: EdkLogger.error( 'build', AUTOGEN_ERROR, @@ -695,35 +695,10 @@ class WorkspaceAutoGen(AutoGen): with open(os.path.join(self.BuildDir, 'AutoGen'), 'w+') as file: for f in AllWorkSpaceMetaFiles: print >> file, f return True - def _BuildOptionPcdValueFormat(self, TokenSpaceGuidCName, TokenCName, PcdDatumType, Value): - if PcdDatumType == 'VOID*': - if Value.startswith('L'): - if not Value[1]: - EdkLogger.error('build', OPTION_VALUE_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", B"{...}"') - Value = Value[0] + '"' + Value[1:] + '"' - elif Value.startswith('B'): - if not Value[1]: - EdkLogger.error('build', OPTION_VALUE_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", B"{...}"') - Value = Value[1:] - else: - if not Value[0]: - EdkLogger.error('build', OPTION_VALUE_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", B"{...}"') - Value = '"' + Value + '"' - - IsValid, Cause = CheckPcdDatum(PcdDatumType, Value) - if not IsValid: - EdkLogger.error('build', FORMAT_INVALID, Cause, ExtraData="%s.%s" % (TokenSpaceGuidCName, TokenCName)) - if PcdDatumType == 'BOOLEAN': - Value = Value.upper() - if Value == 'TRUE' or Value == '1': - Value = '1' - elif Value == 'FALSE' or Value == '0': - Value = '0' - return Value def _GetMetaFiles(self, Target, Toolchain, Arch): AllWorkSpaceMetaFiles = set() # # add fdf diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index ac24bd8..0f3ddd5 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -1,9 +1,9 @@ ## @file # Create makefile for MS nmake and GNU make # -# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at # http://opensource.org/licenses/bsd-license.php # @@ -1451,11 +1451,19 @@ class TopLevelMakefile(BuildFile): ExtraOption += " --ignore-sources" if GlobalData.BuildOptionPcd: for index, option in enumerate(GlobalData.gCommand): if "--pcd" == option and GlobalData.gCommand[index+1]: - ExtraOption += " --pcd " + GlobalData.gCommand[index+1] + pcdName, pcdValue = GlobalData.gCommand[index+1].split('=') + if pcdValue.startswith('H'): + pcdValue = 'H' + '"' + pcdValue[1:] + '"' + ExtraOption += " --pcd " + pcdName + '=' + pcdValue + elif pcdValue.startswith('L'): + pcdValue = 'L' + '"' + pcdValue[1:] + '"' + 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/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 390ef36..dbb711e 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -2060,10 +2060,36 @@ def PackRegistryFormatGuid(Guid): int(Guid[4][-6:-4], 16), int(Guid[4][-4:-2], 16), int(Guid[4][-2:], 16) ) +def BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, Value): + if PcdDatumType == 'VOID*': + if Value.startswith('L'): + if not Value[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"{...}"') + Value = Value[0] + '"' + Value[1:] + '"' + elif Value.startswith('H'): + if not Value[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"{...}"') + Value = Value[1:] + else: + if not Value[0]: + 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"{...}"') + Value = '"' + Value + '"' + + IsValid, Cause = CheckPcdDatum(PcdDatumType, Value) + if not IsValid: + EdkLogger.error("build", FORMAT_INVALID, Cause, ExtraData="%s.%s" % (TokenSpaceGuidCName, TokenCName)) + if PcdDatumType == 'BOOLEAN': + Value = Value.upper() + if Value == 'TRUE' or Value == '1': + Value = '1' + elif Value == 'FALSE' or Value == '0': + Value = '0' + return Value + ## # # This acts like the main() function for the script, unless it is 'import'ed into another # script. # diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py index aa8c041..277da35 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -37,10 +37,11 @@ from Common.String import * from Common.Misc import DirCache, PathClass from Common.Misc import SaveFileOnChange from Common.Misc import ClearDuplicatedInf from Common.Misc import GuidStructureStringToGuidString from Common.Misc import CheckPcdDatum +from Common.Misc import BuildOptionPcdValueFormat from Common.BuildVersion import gBUILD_VERSION from Common.MultipleWorkspace import MultipleWorkspace as mws ## Version and Copyright versionNumber = "1.0" + ' ' + gBUILD_VERSION @@ -406,35 +407,10 @@ def CheckBuildOptionPcd(): "The Pcd %s is found under multiple different TokenSpaceGuid: %s and %s." % (TokenCName, PcdItem.TokenSpaceGuidCName, TokenSpaceGuidCNameList[0]) ) GlobalData.BuildOptionPcd[i] = (TokenSpaceGuidCName, TokenCName, NewValue) -def BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, Value): - if PcdDatumType == 'VOID*': - if Value.startswith('L'): - if not Value[1]: - EdkLogger.error('GenFds', OPTION_VALUE_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", B"{...}"') - Value = Value[0] + '"' + Value[1:] + '"' - elif Value.startswith('B'): - if not Value[1]: - EdkLogger.error('GenFds', OPTION_VALUE_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", B"{...}"') - Value = Value[1:] - else: - if not Value[0]: - EdkLogger.error('GenFds', OPTION_VALUE_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", B"{...}"') - Value = '"' + Value + '"' - - IsValid, Cause = CheckPcdDatum(PcdDatumType, Value) - if not IsValid: - EdkLogger.error('build', FORMAT_INVALID, Cause, ExtraData="%s.%s" % (TokenSpaceGuidCName, TokenCName)) - if PcdDatumType == 'BOOLEAN': - Value = Value.upper() - if Value == 'TRUE' or Value == '1': - Value = '1' - elif Value == 'FALSE' or Value == '0': - Value = '0' - return Value ## FindExtendTool() # # Find location of tools to process data # -- 2.6.1.windows.1