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 52305211BED5F for ; Wed, 20 Jun 2018 19:53:40 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Jun 2018 19:53:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,249,1526367600"; d="scan'208";a="60964627" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga003.jf.intel.com with ESMTP; 20 Jun 2018 19:53:40 -0700 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 20 Jun 2018 19:53:39 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 20 Jun 2018 19:53:39 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.51]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.87]) with mapi id 14.03.0319.002; Thu, 21 Jun 2018 10:53:37 +0800 From: "Zhu, Yonghong" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" CC: "Feng, YunhuaX" , "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [edk2] [Patch] BaseTools: introduce !error statement Thread-Index: AQHUB3qqPrBSf6OAQ0qFUtAAkD2ZL6RqBxXw Date: Thu, 21 Jun 2018 02:53:37 +0000 Message-ID: References: <1529377622-3704-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1529377622-3704-1-git-send-email-yonghong.zhu@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] BaseTools: introduce !error statement X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2018 02:53:42 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Yonghong Zhu =20 Best Regards, Zhu Yonghong -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Yong= hong Zhu Sent: Tuesday, June 19, 2018 11:07 AM To: edk2-devel@lists.01.org Cc: Feng, YunhuaX ; Gao, Liming Subject: [edk2] [Patch] BaseTools: introduce !error statement From: Yunhua Feng The DSC and FDF file can use `!error` statement. The argument of this state= ment is an error message, it causes build tool to stop at the location wher= e the statement is encountered and error message following the `!error` sta= tement is output as a message. Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=3D701 Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/Python/Common/BuildToolError.py | 2 ++ BaseTools/Source/Python/Common/DataType.py | 2 +- BaseTools/Source/Python/GenFds/FdfParser.py | 12 ++++++++++++ BaseTools/Source/Python/Workspace/MetaFileParser.py | 10 +++++++++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/Python/Common/BuildToolError.py b/BaseTools/S= ource/Python/Common/BuildToolError.py index 27779c5..fc2503e 100644 --- a/BaseTools/Source/Python/Common/BuildToolError.py +++ b/BaseTools/Source/Python/Common/BuildToolError.py @@ -87,10 +87,11 @@ PCD_VALIDATION_INFO_ERROR =3D 0xF011 PCD_VARIABLE_ATTR= IBUTES_ERROR =3D 0xF012 PCD_VARIABLE_INFO_ERROR =3D 0xF016 PCD_VARIABLE_A= TTRIBUTES_CONFLICT_ERROR =3D 0xF013 PCD_STRUCTURE_PCD_INVALID_FIELD_ERROR = =3D 0xF014 PCD_STRUCTURE_PCD_ERROR =3D 0xF015 +ERROR_STATEMENT =3D 0xFFFD ABORT_ERROR =3D 0xFFFE UNKNOWN_ERROR =3D 0xFFFF =20 ## Error message of each error code gErrorMessage =3D { @@ -149,10 +150,11 @@ gErrorMessage =3D { IO_NOT_READY : "Not ready", IO_BUSY : "Busy", IO_TIMEOUT : "Timeout", IO_UNKNOWN_ERROR : "Unknown error in IO operation", =20 + ERROR_STATEMENT : "!error statement", UNKNOWN_ERROR : "Unknown error", } =20 ## Exception indicating a fatal error class FatalError(Exception): diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/= Python/Common/DataType.py index a72c7e6..154245c 100644 --- a/BaseTools/Source/Python/Common/DataType.py +++ b/BaseTools/Source/Python/Common/DataType.py @@ -469,11 +469,11 @@ TAB_END_IF =3D '!endif' TAB_ELSE_IF =3D '!elseif' TAB_ELSE =3D '!else' TAB_IF_DEF =3D '!ifdef' TAB_IF_N_DEF =3D '!ifndef' TAB_IF_EXIST =3D '!if exist' -TAB_ERROR =3D '!ERROR' +TAB_ERROR =3D '!error' =20 # # Unknown section # TAB_UNKNOWN =3D 'UNKNOWN' diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source= /Python/GenFds/FdfParser.py index 78cb049..023cd72 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -1359,10 +1359,11 @@ class FdfParser: # def ParseFile(self): =20 try: self.Preprocess() + self.__GetError() # # Keep processing sections of the FDF until no new sections or= a syntax error is found # while self.__GetFd() or self.__GetFv() or self.__GetFmp() or s= elf.__GetCapsule() or self.__GetVtf() or self.__GetRule() or self.__GetOpti= onRom(): pass @@ -1439,10 +1440,21 @@ class FdfParser: raise Warning("expected MACRO value", self.FileName, self.= CurrentLineNumber) Value =3D self.__Token =20 return False =20 + ##__GetError() method + def __GetError(self): + #save the Current information + CurrentLine =3D self.CurrentLineNumber + CurrentOffset =3D self.CurrentOffsetWithinLine + while self.__GetNextToken(): + if self.__Token =3D=3D TAB_ERROR: + EdkLogger.error('FdfParser', ERROR_STATEMENT, self.__Curre= ntLine().replace(TAB_ERROR, '', 1), File=3Dself.FileName, Line=3Dself.Curre= ntLineNumber) + self.CurrentLineNumber =3D CurrentLine + self.CurrentOffsetWithinLine =3D CurrentOffset + ## __GetFd() method # # Get FD section contents and store its data into FD dictionary of s= elf.Profile # # @param self The object pointer diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTool= s/Source/Python/Workspace/MetaFileParser.py index a2ded0c..51a788b 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -836,10 +836,11 @@ class DscParser(MetaFileParser): TAB_IF_N_DEF.upper() : MODEL_META_DATA_CO= NDITIONAL_STATEMENT_IFNDEF, TAB_ELSE_IF.upper() : MODEL_META_DATA_CO= NDITIONAL_STATEMENT_ELSEIF, TAB_ELSE.upper() : MODEL_META_DATA_CO= NDITIONAL_STATEMENT_ELSE, TAB_END_IF.upper() : MODEL_META_DATA_CO= NDITIONAL_STATEMENT_ENDIF, TAB_USER_EXTENSIONS.upper() : MODEL_META_DATA_US= ER_EXTENSION, + TAB_ERROR.upper() : MODEL_META_DATA_CO= NDITIONAL_STATEMENT_ERROR, } =20 # Valid names in define section DefineKeywords =3D [ "DSC_SPECIFICATION", @@ -1026,10 +1027,12 @@ class DscParser(MetaFileParser): =20 ItemType =3D self.DataType[DirectiveName] Scope =3D [[TAB_COMMON, TAB_COMMON, TAB_COMMON]] if ItemType =3D=3D MODEL_META_DATA_INCLUDE: Scope =3D self._Scope + elif ItemType =3D=3D MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR: + Scope =3D self._Scope if ItemType =3D=3D MODEL_META_DATA_CONDITIONAL_STATEMENT_ENDIF: # Remove all directives between !if and !endif, including them= selves while self._DirectiveStack: # Remove any !else or !elseif DirectiveInfo =3D self._DirectiveStack.pop() @@ -1039,11 += 1042,11 @@ class DscParser(MetaFileParser): break else: EdkLogger.error("Parser", FORMAT_INVALID, "Redundant '!end= if'", File=3Dself.MetaFile, Line=3Dself._LineInd= ex + 1, ExtraData=3Dself._CurrentLine) - elif ItemType !=3D MODEL_META_DATA_INCLUDE: + elif ItemType not in {MODEL_META_DATA_INCLUDE, MODEL_META_DATA_CON= DITIONAL_STATEMENT_ERROR}: # Break if there's a !else is followed by a !elseif if ItemType =3D=3D MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSEI= F and \ self._DirectiveStack and \ self._DirectiveStack[-1][0] =3D=3D MODEL_META_DATA_CONDITIO= NAL_STATEMENT_ELSE: EdkLogger.error("Parser", FORMAT_INVALID, "'!elseif' after= '!else'", @@ -1285,10 +1288,11 @@ class DscParser(MetaFileParser): MODEL_META_DATA_COMPONENT : self.__Pro= cessComponent, MODEL_META_DATA_COMPONENT_SOURCE_OVERRIDE_PATH : self.__Pro= cessSourceOverridePath, MODEL_META_DATA_BUILD_OPTION : self.__Pro= cessBuildOption, MODEL_UNKNOWN : self._Skip= , MODEL_META_DATA_USER_EXTENSION : self._Skip= UserExtension, + MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR : self._Proc= essError, } =20 self._Table =3D MetaFileStorage(self._RawTable.Cur, self.MetaFile,= MODEL_FILE_DSC, True) self._Table.Create() self._DirectiveStack =3D [] @@ -1388,10 +1392,14 @@ class DscParser(MetaFileParser): self._IdMapping[Id] =3D self._LastItem =20 GlobalData.gPlatformDefines.update(self._FileLocalMacros) self._PostProcessed =3D True self._Content =3D None + def _ProcessError(self): + if not self._Enabled: + return + EdkLogger.error('Parser', ERROR_STATEMENT, self._ValueList[1],=20 + File=3Dself.MetaFile, Line=3Dself._LineIndex + 1) =20 def __ProcessSectionHeader(self): self._SectionName =3D self._ValueList[0] if self._SectionName in self.DataType: self._SectionType =3D self.DataType[self._SectionName] -- 2.6.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel