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.31; helo=mga06.intel.com; envelope-from=bob.c.feng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 EA3D7211B6C0E for ; Wed, 16 Jan 2019 23:47:31 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2019 23:47:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,488,1539673200"; d="scan'208";a="107255347" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga007.jf.intel.com with ESMTP; 16 Jan 2019 23:47:31 -0800 Received: from fmsmsx118.amr.corp.intel.com (10.18.116.18) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 16 Jan 2019 23:47:31 -0800 Received: from shsmsx154.ccr.corp.intel.com (10.239.6.54) by fmsmsx118.amr.corp.intel.com (10.18.116.18) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 16 Jan 2019 23:47:30 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.196]) by SHSMSX154.ccr.corp.intel.com ([169.254.7.46]) with mapi id 14.03.0415.000; Thu, 17 Jan 2019 15:47:27 +0800 From: "Feng, Bob C" To: "Carsey, Jaben" , "edk2-devel@lists.01.org" CC: "Gao, Liming" Thread-Topic: [Patch v1 3/5] BaseTools/DscBuildData: move function Thread-Index: AQHUqRPjLzHIqDZGtkqIPqx1i19XCqWzH5GA Date: Thu, 17 Jan 2019 07:47:27 +0000 Message-ID: <08650203BA1BD64D8AD9B6D5D74A85D16005CFBA@SHSMSX101.ccr.corp.intel.com> References: In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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, 17 Jan 2019 07:47:32 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Bob Feng -----Original Message----- From: Carsey, Jaben=20 Sent: Friday, January 11, 2019 2:40 AM To: edk2-devel@lists.01.org Cc: Feng, Bob C ; Gao, Liming Subject: [Patch v1 3/5] BaseTools/DscBuildData: move function 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/Pyth= on/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=20 +reserved.
# This program and the accompanying materials # are licensed and made ava= ilable under the terms and conditions of the BSD License # which accompani= es this distribution. The full text of the license may be found at @@ -114= 9,22 +1149,6 @@ class tdict: keys |=3D self.data[Key].GetKeys(KeyIndex - 1) return keys =20 -def IsFieldValueAnArray (Value): - Value =3D 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] =3D=3D '"' and Value[-1] =3D=3D '"' and len(list(Value[1:-= 1])) > 1: - return True - if Value[0] =3D=3D '{' and Value[-1] =3D=3D '}': - return True - if Value.startswith("L'") and Value.endswith("'") and len(list(Value[2= :-1])) > 1: - return True - if Value[0] =3D=3D "'" and Value[-1] =3D=3D "'" and len(list(Value[1:-= 1])) > 1: - return True - return False - def AnalyzePcdExpression(Setting): RanStr =3D ''.join(sample(string.ascii_letters + string.digits, 8)) Setting =3D Setting.replace('\\\\', RanStr).strip() diff --git a/BaseT= ools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Work= space/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 # -# Copyrigh= t (c) 2008 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2008 - 2019, Intel Corporation. All rights=20 +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 W= orkspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, P = from collections import OrderedDict, defaultdict from .BuildClassObject i= mport ArrayIndex =20 +def _IsFieldValueAnArray (Value): + Value =3D 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] =3D=3D '"' and Value[-1] =3D=3D '"' and len(list(Value[1:-= 1])) > 1: + return True + if Value[0] =3D=3D '{' and Value[-1] =3D=3D '}': + return True + if Value.startswith("L'") and Value.endswith("'") and len(list(Value[2= :-1])) > 1: + return True + if Value[0] =3D=3D "'" and Value[-1] =3D=3D "'" and len(list(Value[1:-= 1])) > 1: + return True + return False + PcdValueInitName =3D 'PcdValueInit' =20 PcdMainCHeader =3D ''' @@ -1105,7 +1121,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray =3D False TokenCName +=3D '.' + FieldName if PcdValue.startswith('H'): - if FieldName and IsFieldValueAnArray(PcdValue[1:]): + if FieldName and _IsFieldValueAnArray(PcdValue[1:]): PcdDatumType =3D TAB_VOID IsArray =3D True if FieldName and not IsArray: @@ -1116,7 +1132,7 @@ class DscBuildData(PlatformBuildClassObject): EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Val= ue "%s", %s' % (TokenSpaceGuidCName, TokenCName, PcdValue= , Value)) elif PcdValue.startswith("L'") or PcdValue.startswith("'"): - if FieldName and IsFieldValueAnArray(PcdValue): + if FieldName and _IsFieldValueAnArray(PcdValue): PcdDatumType =3D TAB_VOID IsArray =3D True if FieldName and not IsArray: @@ -1128,7 +1144,7 @@ class DscBuildData(PlatformBuildClassObject): (TokenSpaceGuidCName, TokenCName, PcdValue= , Value)) elif PcdValue.startswith('L'): PcdValue =3D 'L"' + PcdValue[1:] + '"' - if FieldName and IsFieldValueAnArray(PcdValue): + if FieldName and _IsFieldValueAnArray(PcdValue): PcdDatumType =3D TAB_VOID IsArray =3D True if FieldName and not IsArray: @@ -1157,7 +1173,7 @@ class DscBuildData(PlatformBuildClassObject): Num =3D int(PcdValue, Base) except: PcdValue =3D '"' + PcdValue + '"' - if IsFieldValueAnArray(PcdValue): + if _IsFieldValueAnArray(PcdValue): PcdDatumType =3D TAB_VOID IsArray =3D True if not IsArray: @@ -1762,7 +1778,7 @@ class DscBuildData(PlatformBuildClassObject): continue for FieldName in FieldList: FieldName =3D "." + FieldName - IsArray =3D IsFieldValueAnArray(FieldList[FieldName.strip(= ".")][0]) + IsArray =3D=20 + _IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) if IsArray and not (FieldList[FieldName.strip(".")][0].sta= rtswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')): try: Value =3D ValueExpressionEx(FieldList[FieldName.st= rip(".")][0], TAB_VOID, self._GuidDict)(True) @@ -1793,7 +1809,7 @@ class D= scBuildData(PlatformBuildClassObject): continue for FieldName in FieldList: FieldName =3D "." + FieldName - IsArray =3D IsFieldValueAnArray(FieldList[Fiel= dName.strip(".")][0]) + IsArray =3D=20 + _IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) if IsArray and not (FieldList[FieldName.strip(= ".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswit= h('}')): try: Value =3D ValueExpressionEx(FieldList[= FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True) @@ -1817,7 +1833,= 7 @@ class DscBuildData(PlatformBuildClassObject): CApp =3D CApp + "// From fdf \n" for FieldName in Pcd.PcdFieldValueFromFdf: FieldName =3D "." + FieldName - IsArray =3D IsFieldValueAnArray(Pcd.PcdFieldValueFromFdf[Field= Name.strip(".")][0]) + IsArray =3D=20 + _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 =3D ValueExpressionEx(Pcd.PcdFieldValueFromFdf[F= ieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True) @@ -1841,7 +1857,7= @@ class DscBuildData(PlatformBuildClassObject): CApp =3D CApp + "// From Command Line \n" for FieldName in Pcd.PcdFieldValueFromComm: FieldName =3D "." + FieldName - IsArray =3D IsFieldValueAnArray(Pcd.PcdFieldValueFromComm[Fiel= dName.strip(".")][0]) + IsArray =3D=20 + _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 =3D ValueExpressionEx(Pcd.PcdFieldValueFromComm[= FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True) @@ -1943,7 +1959,= 7 @@ class DscBuildData(PlatformBuildClassObject): CApp =3D CApp + ' UINT32 FieldSize;\n' CApp =3D CApp + ' CHAR8 *Value;\n' DefaultValueFromDec =3D Pcd.DefaultValueFromDec - IsArray =3D IsFieldValueAnArray(Pcd.DefaultValueFromDec) + IsArray =3D _IsFieldValueAnArray(Pcd.DefaultValueFromDec) if IsArray: try: DefaultValueFromDec =3D ValueExpressionEx(Pcd.DefaultValue= FromDec, TAB_VOID)(True) @@ -1968,7 +1984,7 @@ class DscBuildData(PlatformB= uildClassObject): if not FieldList: continue for FieldName in FieldList: - IsArray =3D IsFieldValueAnArray(FieldList[FieldName][0]) + IsArray =3D _IsFieldValueAnArray(FieldList[FieldName][0]) if IsArray: try: FieldList[FieldName][0] =3D ValueExpressionEx(Fiel= dList[FieldName][0], TAB_VOID, self._GuidDict)(True) @@ -2032,7 +2048,7 @@ = class DscBuildData(PlatformBuildClassObject): pcddefaultvalue =3D self.GetPcdDscRawDefaultValue(Pcd, SkuName, De= faultStoreName) if pcddefaultvalue: FieldList =3D pcddefaultvalue - IsArray =3D IsFieldValueAnArray(FieldList) + IsArray =3D _IsFieldValueAnArray(FieldList) if IsArray: if "{CODE(" not in FieldList: try: @@ -2083,7 +2099,7 @@ class DscBuildData(PlatformBuildClassObject): if (SkuName, DefaultStoreName) =3D=3D (TAB_DEFAULT, TAB_DEFAUL= T_STORES_DEFAULT) or (( (SkuName, '') not in Pcd.ValueChain) and ( (SkuName= , DefaultStoreName) not in Pcd.ValueChain )): for FieldName in FieldList: indicator =3D self.GetIndicator(index, FieldName,Pcd) - IsArray =3D IsFieldValueAnArray(FieldList[FieldName][0= ]) + IsArray =3D=20 + _IsFieldValueAnArray(FieldList[FieldName][0]) if IsArray: try: FieldList[FieldName][0] =3D ValueExpressionEx(= FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True) @@ -2132,7 +2148,7= @@ class DscBuildData(PlatformBuildClassObject): if not FieldList: continue if pcddefaultvalue and FieldList =3D=3D pcddefaultvalue: - IsArray =3D IsFieldValueAnArray(FieldList) + IsArray =3D _IsFieldValueAnArray(FieldList) if IsArray: try: FieldList =3D ValueExpressionEx(FieldList, TAB_VOI= D)(True) @@ -2151,7 +2167,7 @@ class DscBuildData(PlatformBuildClassObject)= : CApp =3D CApp + ' memcpy (Pcd, Value, %d);\n' % (Valu= eSize) continue for FieldName in FieldList: - IsArray =3D IsFieldValueAnArray(FieldList[FieldName][0]) + IsArray =3D _IsFieldValueAnArray(FieldList[FieldName][0]) if IsArray: try: FieldList[FieldName][0] =3D ValueExpressionEx(Fiel= dList[FieldName][0], TAB_VOID, self._GuidDict)(True) @@ -2200,7 +2216,7 @@ = class DscBuildData(PlatformBuildClassObject): if not FieldList: continue if pcddefaultvalue and FieldList =3D=3D pcddefaultvalue: - IsArray =3D IsFieldValueAnArray(FieldList) + IsArray =3D _IsFieldValueAnArray(FieldList) if IsArray: try: FieldList =3D ValueExpressionEx(FieldList, TAB_VOI= D)(True) @@ -2219,7 +2235,7 @@ class DscBuildData(PlatformBuildClassObject)= : CApp =3D CApp + ' memcpy (Pcd, Value, %d);\n' % (Valu= eSize) continue for FieldName in FieldList: - IsArray =3D IsFieldValueAnArray(FieldList[FieldName][0]) + IsArray =3D _IsFieldValueAnArray(FieldList[FieldName][0]) if IsArray: try: FieldList[FieldName][0] =3D ValueExpressionEx(Fiel= dList[FieldName][0], TAB_VOID, self._GuidDict)(True) -- 2.16.2.windows.1