From nobody Wed May 1 22:27:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1529377645780734.4366081132542; Mon, 18 Jun 2018 20:07:25 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E99A421122944; Mon, 18 Jun 2018 20:07:24 -0700 (PDT) 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 EDC8421122940 for ; Mon, 18 Jun 2018 20:07:22 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jun 2018 20:07:22 -0700 Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.129]) by fmsmga002.fm.intel.com with ESMTP; 18 Jun 2018 20:07:21 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,241,1526367600"; d="scan'208";a="58794515" From: Yonghong Zhu To: edk2-devel@lists.01.org Date: Tue, 19 Jun 2018 11:07:02 +0800 Message-Id: <1529377622-3704-1-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 Subject: [edk2] [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: , Cc: Yunhua Feng , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Yunhua Feng The DSC and FDF file can use `!error` statement. The argument of this statement is an error message, it causes build tool to stop at the location where the statement is encountered and error message following the `!error` statement 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 Reviewed-by: Yonghong Zhu =20 --- 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_ATTRIBUTES_ERROR =3D 0xF012 PCD_VARIABLE_INFO_ERROR =3D 0xF016 PCD_VARIABLE_ATTRIBUTES_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], Fil= e=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] --=20 2.6.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel