From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ml01.01.org (Postfix) with ESMTP id 26BB61A1E24 for ; Mon, 1 Aug 2016 21:03:12 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP; 01 Aug 2016 21:03:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,458,1464678000"; d="scan'208";a="1033364683" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga002.fm.intel.com with ESMTP; 01 Aug 2016 21:03:12 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 1 Aug 2016 21:03:11 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.181]) by shsmsx102.ccr.corp.intel.com ([169.254.2.147]) with mapi id 14.03.0248.002; Tue, 2 Aug 2016 12:03:09 +0800 From: "Zhu, Yonghong" To: "Chen, Hesheng" , "edk2-devel@lists.01.org" Thread-Topic: [patch 2/2] BaseTool/Upt: Add support for Private Thread-Index: AQHR6UFo2ovqII1iUkOv6AMI6hqnDqA1Ecog Date: Tue, 2 Aug 2016 04:03:08 +0000 Message-ID: References: <1469759456-133160-1-git-send-email-hesheng.chen@intel.com> In-Reply-To: <1469759456-133160-1-git-send-email-hesheng.chen@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [patch 2/2] BaseTool/Upt: Add support for Private X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Aug 2016 04:03:12 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Please remove the trailing whitespace when commit. Reviewed-by: Yonghong Zhu =20 Best Regards, Zhu Yonghong -----Original Message----- From: Chen, Hesheng=20 Sent: Friday, July 29, 2016 10:31 AM To: edk2-devel@lists.01.org Cc: Zhu, Yonghong Subject: [patch 2/2] BaseTool/Upt: Add support for Private Support new syntax in package DEC file as below: [Includes.Common.Private] [Ppis.Common.Private] [Guids.Common.Private] [Protocols.Common.Private] Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: hesschen --- .../Source/Python/UPT/GenMetaFile/GenDecFile.py | 9 +++++++- BaseTools/Source/Python/UPT/Library/DataType.py | 4 +++- .../Source/Python/UPT/Library/UniClassObject.py | 16 +++++++------- BaseTools/Source/Python/UPT/Parser/DecParser.py | 25 ++++++++++++++++++= ++-- .../Python/UPT/PomAdapter/DecPomAlignment.py | 11 +++++++++- 5 files changed, 52 insertions(+), 13 deletions(-) diff --git a/BaseTools/Source/Python/UPT/GenMetaFile/GenDecFile.py b/BaseTo= ols/Source/Python/UPT/GenMetaFile/GenDecFile.py index f22363b..31abd23 100644 --- a/BaseTools/Source/Python/UPT/GenMetaFile/GenDecFile.py +++ b/BaseTools/Source/Python/UPT/GenMetaFile/GenDecFile.py @@ -2,7 +2,7 @@ # # This file contained the logical of transfer package object to DEC files. # -# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 2016, Intel Corporation. All rights=20 +reserved.
# # This program and the accompanying materials are licensed and made availa= ble # under the terms and conditions of the BSD License which accompanies = this @@ -63,6 +63,7 @@ from Library.DataType import TAB_PCD_ERROR from Lib= rary.DataType import TAB_SECTION_START from Library.DataType import TAB_SE= CTION_END from Library.DataType import TAB_SPLIT +import Library.DataType as DT from Library.UniClassObject import FormatUniEntry =20 def GenPcd(Package, Content): @@ -487,6 +488,12 @@ def PackageToDec(Package, DistHeader =3D None): if UserExtension.GetUserID() =3D=3D TAB_BINARY_HEADER_USERID and \ UserExtension.GetIdentifier() =3D=3D TAB_BINARY_HEADER_IDENTIF= IER: continue + + # Generate Private Section first + if UserExtension.GetUserID() =3D=3D DT.TAB_INTEL and UserExtension= .GetIdentifier() =3D=3D DT.TAB_PRIVATE: + Content +=3D '\n' + UserExtension.GetStatement() + continue + Statement =3D UserExtension.GetStatement() if not Statement: continue diff --git a/BaseTools/Source/Python/UPT/Library/DataType.py b/BaseTools/So= urce/Python/UPT/Library/DataType.py index 8449dc8..c151be3 100644 --- a/BaseTools/Source/Python/UPT/Library/DataType.py +++ b/BaseTools/Source/Python/UPT/Library/DataType.py @@ -1,7 +1,7 @@ ## @file # This file is used to define class for data type structure # -# Copyrigh= t (c) 2011 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 2016, Intel Corporation. All rights=20 +reserved.
# # This program and the accompanying materials are licensed and made availa= ble # under the terms and conditions of the BSD License which accompanies = this @@ -680,6 +680,8 @@ TAB_DEFINE =3D 'DEFINE' TAB_NMAKE =3D 'Nmake' TAB_USER_EXTENSIONS =3D 'UserExtensions' TAB_INCLUDE =3D '!include' +TAB_PRIVATE =3D 'Private' +TAB_INTEL =3D 'Intel' =20 # # Common Define diff --git a/BaseTools/Source/Python/UPT/Library/UniClassObject.py b/BaseTo= ols/Source/Python/UPT/Library/UniClassObject.py index 1e73d3e..27804cc 100644 --- a/BaseTools/Source/Python/UPT/Library/UniClassObject.py +++ b/BaseTools/Source/Python/UPT/Library/UniClassObject.py @@ -328,11 +328,11 @@ class UniFileClassObject(object): Lang =3D distutils.util.split_quoted((Line.split(u"//")[0])) if len(Lang) !=3D 3: try: - FileIn =3D codecs.open(File.Path, mode=3D'rb', encoding=3D= 'utf_8').read() + FileIn =3D codecs.open(File.Path, mode=3D'rb',=20 + encoding=3D'utf_8').readlines() except UnicodeError, Xstr: - FileIn =3D codecs.open(File.Path, mode=3D'rb', encoding=3D= 'utf_16').read() + FileIn =3D codecs.open(File.Path, mode=3D'rb',=20 + encoding=3D'utf_16').readlines() except UnicodeError, Xstr: - FileIn =3D codecs.open(File.Path, mode=3D'rb', encoding=3D= 'utf_16_le').read() + FileIn =3D codecs.open(File.Path, mode=3D'rb',=20 + encoding=3D'utf_16_le').readlines() except: EdkLogger.Error("Unicode File Parser",=20 ToolError.FILE_OPEN_FAILURE, @@ -437,7 +43= 7,7 @@ class UniFileClassObject(object): # ExtraData=3D'The file %s is either invalid U= TF-16LE or it is missing the BOM.' % File.Path) =20 try: - FileIn =3D codecs.open(File.Path, mode=3D'rb', encoding=3D'utf= _8').read() + FileIn =3D codecs.open(File.Path, mode=3D'rb',=20 + encoding=3D'utf_8').readlines() except UnicodeError, Xstr: FileIn =3D codecs.open(File.Path, mode=3D'rb', encoding=3D'utf= _16').readlines() except UnicodeError: @@ -579,9 +579,9 @@ class UniFileClassObject(object): # if Line.startswith(u'"'): if StringEntryExistsFlag =3D=3D 2: - EdkLogger.Error("Unicode File Parser", ToolError.FORMA= T_INVALID,=20 + EdkLogger.Error("Unicode File Parser",=20 + ToolError.FORMAT_INVALID, Message=3DST.ERR_UNIPARSE_LINEFEED_UP_= EXIST % Line, ExtraData=3DFile.Path) - =20 + StringEntryExistsFlag =3D 1 if not Line.endswith('"'): EdkLogger.Error("Unicode File Parser", ToolError.FORMA= T_INVALID, @@ -589,7 +589,7 @@ class UniFileClassObject(object): % (LineCount, File.Path)) elif Line.startswith(u'#language'): if StringEntryExistsFlag =3D=3D 2: - EdkLogger.Error("Unicode File Parser", ToolError.FORMA= T_INVALID,=20 + EdkLogger.Error("Unicode File Parser",=20 + ToolError.FORMAT_INVALID, Message=3DST.ERR_UNI_MISS_STRING_ENTRY= % Line, ExtraData=3DFile.Path) StringEntryExistsFlag =3D 0 else: @@ -1050,7 +1050,7 @@ class UniFileClassObject(object): ToolError.FILE_NOT_FOUND, ExtraData=3DFilaPath) try: - FileIn =3D codecs.open(FilaPath, mode=3D'rb', encoding=3D'utf_= 8').read() + FileIn =3D codecs.open(FilaPath, mode=3D'rb',=20 + encoding=3D'utf_8').readlines() except UnicodeError, Xstr: FileIn =3D codecs.open(FilaPath, mode=3D'rb', encoding=3D'utf_= 16').readlines() except UnicodeError: diff --git a/BaseTools/Source/Python/UPT/Parser/DecParser.py b/BaseTools/So= urce/Python/UPT/Parser/DecParser.py index 23d1ed4..e6658a9 100644 --- a/BaseTools/Source/Python/UPT/Parser/DecParser.py +++ b/BaseTools/Source/Python/UPT/Parser/DecParser.py @@ -1,7 +1,7 @@ ## @file # This file is used to parse DEC file. It will consumed by DecParser # -#= Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 2016, Intel Corporation. All rights=20 +reserved.
# # This program and the accompanying materials are licensed and made availa= ble # under the terms and conditions of the BSD License which accompanies = this @@ -742,7 +742,26 @@ class Dec(_DecBase, _DecComments): except BaseException: Logger.Error(TOOL_NAME, FILE_OPEN_FAILURE, File=3DDecFile, ExtraData=3DST.ERR_DECPARSE_FILEOPEN % DecFile) - RawData =3D FileContent(DecFile, Content) + =20 + # + # Pre-parser for Private section + # + self._Private =3D '' + __IsFoundPrivate =3D False + NewContent =3D [] + for Line in Content: + Line =3D Line.strip() + if Line.startswith(DT.TAB_SECTION_START) and Line.endswith(DT.= TAB_PRIVATE + DT.TAB_SECTION_END): + __IsFoundPrivate =3D True + if Line.startswith(DT.TAB_SECTION_START) and Line.endswith(DT.= TAB_SECTION_END)\ + and not Line.endswith(DT.TAB_PRIVATE + DT.TAB_SECTION_END): + __IsFoundPrivate =3D False + if __IsFoundPrivate: + self._Private +=3D Line + '\r' + if not __IsFoundPrivate: + NewContent.append(Line + '\r') + =20 + RawData =3D FileContent(DecFile, NewContent) =20 _DecComments.__init__(self) _DecBase.__init__(self, RawData) @@ -1060,3 +1079,5 @@ class Dec(_= DecBase, _DecComments): return self._Define.GetDataObject().GetPackageVersion() def GetPackageUniFile(self): return self._Define.GetDataObject().GetPackageUniFile() + def GetPrivateSections(self): + return self._Private diff --git a/BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py b/Ba= seTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py index 11b0359..88edf35 100644 --- a/BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py +++ b/BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py @@ -1,7 +1,7 @@ ## @file DecPomAlignment.py # This file contained the adapter for convert INF parser object to POM Obj= ect # -# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved= .
+# Copyright (c) 2011 - 2016, Intel Corporation. All rights=20 +reserved.
# # This program and the accompanying materials are licensed and made availa= ble # under the terms and conditions of the BSD License which accompanies = this @@ -63,6 +63,7 @@ from Library.DataType import TAB_STR_TOKENHELP from= Library.DataType import TAB_STR_TOKENERR from Library.DataType import TAB= _HEX_START from Library.DataType import TAB_SPLIT +import Library.DataType as DT from Library.CommentParsing import ParseHeaderCommentSection from Library= .CommentParsing import ParseGenericComment from Library.CommentParsing imp= ort ParseDecPcdGenericComment @@ -221,6 +222,14 @@ class DecPomAlignment(Pa= ckageObject): self.SetUserExtensionList( self.GetUserExtensionList() + [UserExtension] ) + =20 + # Add Private sections to UserExtension + if self.DecParser.GetPrivateSections(): + PrivateUserExtension =3D UserExtensionObject() + PrivateUserExtension.SetStatement(self.DecParser.GetPrivateSec= tions()) + PrivateUserExtension.SetIdentifier(DT.TAB_PRIVATE) + PrivateUserExtension.SetUserID(DT.TAB_INTEL) + self.SetUserExtensionList(self.GetUserExtensionList() +=20 + [PrivateUserExtension]) =20 ## Generate miscellaneous files on DEC file # -- 2.7.2.windows.1