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.43; helo=mga05.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 2345921BADAB2 for ; Thu, 10 Jan 2019 10:39:54 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jan 2019 10:39:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,462,1539673200"; d="scan'208";a="117134387" Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.149]) by orsmga003.jf.intel.com with ESMTP; 10 Jan 2019 10:39:51 -0800 From: Jaben Carsey To: edk2-devel@lists.01.org Cc: Bob Feng , Liming Gao Date: Thu, 10 Jan 2019 10:39:47 -0800 Message-Id: X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: In-Reply-To: References: Subject: [Patch v1 3/5] BaseTools/DscBuildData: move function 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: Thu, 10 Jan 2019 18:39:54 -0000 Move IsFieldValuieAnArray from Common.Misc to this file. There were no other consumers of the function. Cc: Bob Feng Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/Common/Misc.py | 18 +------ BaseTools/Source/Python/Workspace/DscBuildData.py | 50 +++++++++++++------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 25d8f9807fa3..7e8077558da5 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -1,7 +1,7 @@ ## @file # Common routines used by all tools # -# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2019, 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 @@ -1149,22 +1149,6 @@ class tdict: keys |= self.data[Key].GetKeys(KeyIndex - 1) return keys -def IsFieldValueAnArray (Value): - Value = Value.strip() - if Value.startswith(TAB_GUID) and Value.endswith(')'): - return True - if Value.startswith('L"') and Value.endswith('"') and len(list(Value[2:-1])) > 1: - return True - if Value[0] == '"' and Value[-1] == '"' and len(list(Value[1:-1])) > 1: - return True - if Value[0] == '{' and Value[-1] == '}': - return True - if Value.startswith("L'") and Value.endswith("'") and len(list(Value[2:-1])) > 1: - return True - if Value[0] == "'" and Value[-1] == "'" and len(list(Value[1:-1])) > 1: - return True - return False - def AnalyzePcdExpression(Setting): RanStr = ''.join(sample(string.ascii_letters + string.digits, 8)) Setting = Setting.replace('\\\\', RanStr).strip() diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 3b0b23ca8fcb..f4a8212f412d 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1,7 +1,7 @@ ## @file # This file is used to create a database used by build tool # -# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2008 - 2019, Intel Corporation. All rights reserved.
# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -44,6 +44,22 @@ from Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, P from collections import OrderedDict, defaultdict from .BuildClassObject import ArrayIndex +def _IsFieldValueAnArray (Value): + Value = Value.strip() + if Value.startswith(TAB_GUID) and Value.endswith(')'): + return True + if Value.startswith('L"') and Value.endswith('"') and len(list(Value[2:-1])) > 1: + return True + if Value[0] == '"' and Value[-1] == '"' and len(list(Value[1:-1])) > 1: + return True + if Value[0] == '{' and Value[-1] == '}': + return True + if Value.startswith("L'") and Value.endswith("'") and len(list(Value[2:-1])) > 1: + return True + if Value[0] == "'" and Value[-1] == "'" and len(list(Value[1:-1])) > 1: + return True + return False + PcdValueInitName = 'PcdValueInit' PcdMainCHeader = ''' @@ -1105,7 +1121,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray = False TokenCName += '.' + FieldName if PcdValue.startswith('H'): - if FieldName and IsFieldValueAnArray(PcdValue[1:]): + if FieldName and _IsFieldValueAnArray(PcdValue[1:]): PcdDatumType = TAB_VOID IsArray = True if FieldName and not IsArray: @@ -1116,7 +1132,7 @@ class DscBuildData(PlatformBuildClassObject): EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' % (TokenSpaceGuidCName, TokenCName, PcdValue, Value)) elif PcdValue.startswith("L'") or PcdValue.startswith("'"): - if FieldName and IsFieldValueAnArray(PcdValue): + if FieldName and _IsFieldValueAnArray(PcdValue): PcdDatumType = TAB_VOID IsArray = True if FieldName and not IsArray: @@ -1128,7 +1144,7 @@ class DscBuildData(PlatformBuildClassObject): (TokenSpaceGuidCName, TokenCName, PcdValue, Value)) elif PcdValue.startswith('L'): PcdValue = 'L"' + PcdValue[1:] + '"' - if FieldName and IsFieldValueAnArray(PcdValue): + if FieldName and _IsFieldValueAnArray(PcdValue): PcdDatumType = TAB_VOID IsArray = True if FieldName and not IsArray: @@ -1157,7 +1173,7 @@ class DscBuildData(PlatformBuildClassObject): Num = int(PcdValue, Base) except: PcdValue = '"' + PcdValue + '"' - if IsFieldValueAnArray(PcdValue): + if _IsFieldValueAnArray(PcdValue): PcdDatumType = TAB_VOID IsArray = True if not IsArray: @@ -1762,7 +1778,7 @@ class DscBuildData(PlatformBuildClassObject): continue for FieldName in FieldList: FieldName = "." + FieldName - IsArray = IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) + IsArray = _IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')): try: Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True) @@ -1793,7 +1809,7 @@ class DscBuildData(PlatformBuildClassObject): continue for FieldName in FieldList: FieldName = "." + FieldName - IsArray = IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) + IsArray = _IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')): try: Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True) @@ -1817,7 +1833,7 @@ class DscBuildData(PlatformBuildClassObject): CApp = CApp + "// From fdf \n" for FieldName in Pcd.PcdFieldValueFromFdf: FieldName = "." + FieldName - IsArray = IsFieldValueAnArray(Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0]) + IsArray = _IsFieldValueAnArray(Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0]) if IsArray and not (Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0].startswith('{GUID') and Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0].endswith('}')): try: Value = ValueExpressionEx(Pcd.PcdFieldValueFromFdf[FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True) @@ -1841,7 +1857,7 @@ class DscBuildData(PlatformBuildClassObject): CApp = CApp + "// From Command Line \n" for FieldName in Pcd.PcdFieldValueFromComm: FieldName = "." + FieldName - IsArray = IsFieldValueAnArray(Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0]) + IsArray = _IsFieldValueAnArray(Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0]) if IsArray and not (Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0].startswith('{GUID') and Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0].endswith('}')): try: Value = ValueExpressionEx(Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True) @@ -1943,7 +1959,7 @@ class DscBuildData(PlatformBuildClassObject): CApp = CApp + ' UINT32 FieldSize;\n' CApp = CApp + ' CHAR8 *Value;\n' DefaultValueFromDec = Pcd.DefaultValueFromDec - IsArray = IsFieldValueAnArray(Pcd.DefaultValueFromDec) + IsArray = _IsFieldValueAnArray(Pcd.DefaultValueFromDec) if IsArray: try: DefaultValueFromDec = ValueExpressionEx(Pcd.DefaultValueFromDec, TAB_VOID)(True) @@ -1968,7 +1984,7 @@ class DscBuildData(PlatformBuildClassObject): if not FieldList: continue for FieldName in FieldList: - IsArray = IsFieldValueAnArray(FieldList[FieldName][0]) + IsArray = _IsFieldValueAnArray(FieldList[FieldName][0]) if IsArray: try: FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True) @@ -2032,7 +2048,7 @@ class DscBuildData(PlatformBuildClassObject): pcddefaultvalue = self.GetPcdDscRawDefaultValue(Pcd, SkuName, DefaultStoreName) if pcddefaultvalue: FieldList = pcddefaultvalue - IsArray = IsFieldValueAnArray(FieldList) + IsArray = _IsFieldValueAnArray(FieldList) if IsArray: if "{CODE(" not in FieldList: try: @@ -2083,7 +2099,7 @@ class DscBuildData(PlatformBuildClassObject): if (SkuName, DefaultStoreName) == (TAB_DEFAULT, TAB_DEFAULT_STORES_DEFAULT) or (( (SkuName, '') not in Pcd.ValueChain) and ( (SkuName, DefaultStoreName) not in Pcd.ValueChain )): for FieldName in FieldList: indicator = self.GetIndicator(index, FieldName,Pcd) - IsArray = IsFieldValueAnArray(FieldList[FieldName][0]) + IsArray = _IsFieldValueAnArray(FieldList[FieldName][0]) if IsArray: try: FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True) @@ -2132,7 +2148,7 @@ class DscBuildData(PlatformBuildClassObject): if not FieldList: continue if pcddefaultvalue and FieldList == pcddefaultvalue: - IsArray = IsFieldValueAnArray(FieldList) + IsArray = _IsFieldValueAnArray(FieldList) if IsArray: try: FieldList = ValueExpressionEx(FieldList, TAB_VOID)(True) @@ -2151,7 +2167,7 @@ class DscBuildData(PlatformBuildClassObject): CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize) continue for FieldName in FieldList: - IsArray = IsFieldValueAnArray(FieldList[FieldName][0]) + IsArray = _IsFieldValueAnArray(FieldList[FieldName][0]) if IsArray: try: FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True) @@ -2200,7 +2216,7 @@ class DscBuildData(PlatformBuildClassObject): if not FieldList: continue if pcddefaultvalue and FieldList == pcddefaultvalue: - IsArray = IsFieldValueAnArray(FieldList) + IsArray = _IsFieldValueAnArray(FieldList) if IsArray: try: FieldList = ValueExpressionEx(FieldList, TAB_VOID)(True) @@ -2219,7 +2235,7 @@ class DscBuildData(PlatformBuildClassObject): CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize) continue for FieldName in FieldList: - IsArray = IsFieldValueAnArray(FieldList[FieldName][0]) + IsArray = _IsFieldValueAnArray(FieldList[FieldName][0]) if IsArray: try: FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True) -- 2.16.2.windows.1