From 855698fb69fdb85fa24c4374d07947106f4de828 Mon Sep 17 00:00:00 2001 From: hchen30 Date: Wed, 8 Aug 2018 11:18:06 +0800 Subject: [PATCH] BaseTools/Ecc: Fix import issues 1. Complete the full path for import statement. Use "EccMain" to replace "Ecc" for the absolute path support. 2. Fix some issues on configuration file. 3. Fix an issue of RaiseError not working in EdkLogger. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hess Chen Reviewed-by: Liming Gao --- BaseTools/BinWrappers/PosixLike/Ecc | 2 +- BaseTools/BinWrappers/WindowsLike/Ecc.bat | 2 +- BaseTools/Source/Python/Common/EdkLogger.py | 3 ++- BaseTools/Source/Python/Ecc/CParser.py | 4 ++-- BaseTools/Source/Python/Ecc/Check.py | 8 +++---- .../Python/Ecc/CodeFragmentCollector.py | 12 +++++----- BaseTools/Source/Python/Ecc/Configuration.py | 2 ++ BaseTools/Source/Python/Ecc/Database.py | 6 ++--- .../Source/Python/Ecc/{Ecc.py => EccMain.py} | 24 +++++++++---------- BaseTools/Source/Python/Ecc/Exception.py | 2 +- BaseTools/Source/Python/Ecc/FileProfile.py | 2 +- BaseTools/Source/Python/Ecc/MetaDataParser.py | 4 ++-- .../Ecc/MetaFileWorkspace/MetaFileParser.py | 6 ++--- .../Ecc/MetaFileWorkspace/MetaFileTable.py | 6 ++--- BaseTools/Source/Python/Ecc/c.py | 12 +++++----- BaseTools/Source/Python/Ecc/config.ini | 4 ++-- .../Source/Python/Table/TableDataModel.py | 2 +- BaseTools/Source/Python/Table/TableDec.py | 2 +- BaseTools/Source/Python/Table/TableDsc.py | 2 +- .../Source/Python/Table/TableEotReport.py | 2 +- BaseTools/Source/Python/Table/TableFdf.py | 2 +- BaseTools/Source/Python/Table/TableFile.py | 2 +- .../Source/Python/Table/TableFunction.py | 2 +- .../Source/Python/Table/TableIdentifier.py | 2 +- BaseTools/Source/Python/Table/TableInf.py | 2 +- BaseTools/Source/Python/Table/TablePcd.py | 2 +- BaseTools/Source/Python/Table/TableQuery.py | 2 +- BaseTools/Source/Python/Table/TableReport.py | 6 ++--- 28 files changed, 65 insertions(+), 62 deletions(-) rename BaseTools/Source/Python/Ecc/{Ecc.py => EccMain.py} (95%) diff --git a/BaseTools/BinWrappers/PosixLike/Ecc b/BaseTools/BinWrappers/PosixLike/Ecc index bca1bae96a..1142964028 100755 --- a/BaseTools/BinWrappers/PosixLike/Ecc +++ b/BaseTools/BinWrappers/PosixLike/Ecc @@ -11,4 +11,4 @@ dir=$(dirname "$full_cmd") cmd=${full_cmd##*/} export PYTHONPATH="$dir/../../Source/Python${PYTHONPATH:+:"$PYTHONPATH"}" -exec "${python_exe:-python}" -m $cmd.$cmd "$@" +exec "${python_exe:-python}" -m $cmd.EccMain "$@" diff --git a/BaseTools/BinWrappers/WindowsLike/Ecc.bat b/BaseTools/BinWrappers/WindowsLike/Ecc.bat index 98095cfbd4..8705e7541e 100644 --- a/BaseTools/BinWrappers/WindowsLike/Ecc.bat +++ b/BaseTools/BinWrappers/WindowsLike/Ecc.bat @@ -1,4 +1,4 @@ @setlocal @set ToolName=%~n0% @set PYTHONPATH=%PYTHONPATH%;%BASE_TOOLS_PATH%\Source\Python -@%PYTHON_HOME%\python.exe -m %ToolName%.%ToolName% %* +@%PYTHON_HOME%\python.exe -m %ToolName%.EccMain %* diff --git a/BaseTools/Source/Python/Common/EdkLogger.py b/BaseTools/Source/Python/Common/EdkLogger.py index 19749066ec..80697bf09b 100644 --- a/BaseTools/Source/Python/Common/EdkLogger.py +++ b/BaseTools/Source/Python/Common/EdkLogger.py @@ -1,7 +1,7 @@ ## @file # This file implements the log mechanism for Python tools. # -# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2018, 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 @@ -198,6 +198,7 @@ def error(ToolName, ErrorCode, Message=None, File=None, Line=None, ExtraData=Non LogText = _ErrorMessageTemplateWithoutFile % TemplateDict _ErrorLogger.log(ERROR, LogText) + RaiseError = IsRaiseError if RaiseError: raise FatalError(ErrorCode) diff --git a/BaseTools/Source/Python/Ecc/CParser.py b/BaseTools/Source/Python/Ecc/CParser.py index 0b74b53ae7..a3ab8e7bf4 100644 --- a/BaseTools/Source/Python/Ecc/CParser.py +++ b/BaseTools/Source/Python/Ecc/CParser.py @@ -24,8 +24,8 @@ from antlr3.compat import set, frozenset # ## -from . import CodeFragment -from . import FileProfile +from Ecc import CodeFragment +from Ecc import FileProfile diff --git a/BaseTools/Source/Python/Ecc/Check.py b/BaseTools/Source/Python/Ecc/Check.py index 6803afdfdd..fc86ad96f2 100644 --- a/BaseTools/Source/Python/Ecc/Check.py +++ b/BaseTools/Source/Python/Ecc/Check.py @@ -15,10 +15,10 @@ import Common.LongFilePathOs as os import re from CommonDataClass.DataClass import * import Common.DataType as DT -from .EccToolError import * -from .MetaDataParser import ParseHeaderCommentSection -from . import EccGlobalData -from . import c +from Ecc.EccToolError import * +from Ecc.MetaDataParser import ParseHeaderCommentSection +from Ecc import EccGlobalData +from Ecc import c from Common.LongFilePathSupport import OpenLongFilePath as open from Common.MultipleWorkspace import MultipleWorkspace as mws diff --git a/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py b/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py index 28b4e0196f..d12232cc6f 100644 --- a/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py +++ b/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py @@ -23,13 +23,13 @@ import Common.LongFilePathOs as os import sys import antlr3 -from .CLexer import CLexer -from .CParser import CParser +from Ecc.CLexer import CLexer +from Ecc.CParser import CParser -from . import FileProfile -from .CodeFragment import Comment -from .CodeFragment import PP_Directive -from .ParserWarning import Warning +from Ecc import FileProfile +from Ecc.CodeFragment import Comment +from Ecc.CodeFragment import PP_Directive +from Ecc.ParserWarning import Warning ##define T_CHAR_SPACE ' ' diff --git a/BaseTools/Source/Python/Ecc/Configuration.py b/BaseTools/Source/Python/Ecc/Configuration.py index f58adbf736..c19a3990c7 100644 --- a/BaseTools/Source/Python/Ecc/Configuration.py +++ b/BaseTools/Source/Python/Ecc/Configuration.py @@ -60,12 +60,14 @@ _ConfigFileToInternalTranslation = { "GeneralCheckIndentation":"GeneralCheckIndentation", "GeneralCheckIndentationWidth":"GeneralCheckIndentationWidth", "GeneralCheckLine":"GeneralCheckLine", + "GeneralCheckLineEnding":"GeneralCheckLineEnding", "GeneralCheckLineWidth":"GeneralCheckLineWidth", "GeneralCheckNoProgma":"GeneralCheckNoProgma", "GeneralCheckNoTab":"GeneralCheckNoTab", "GeneralCheckNo_Asm":"GeneralCheckNo_Asm", "GeneralCheckNonAcsii":"GeneralCheckNonAcsii", "GeneralCheckTabWidth":"GeneralCheckTabWidth", + "GeneralCheckTrailingWhiteSpaceLine":"GeneralCheckTrailingWhiteSpaceLine", "GeneralCheckUni":"GeneralCheckUni", "HeaderCheckAll":"HeaderCheckAll", "HeaderCheckCFileCommentLicenseFormat":"HeaderCheckCFileCommentLicenseFormat", diff --git a/BaseTools/Source/Python/Ecc/Database.py b/BaseTools/Source/Python/Ecc/Database.py index 34f49f3cba..9d4acac7b7 100644 --- a/BaseTools/Source/Python/Ecc/Database.py +++ b/BaseTools/Source/Python/Ecc/Database.py @@ -27,9 +27,9 @@ from Table.TableFunction import TableFunction from Table.TablePcd import TablePcd from Table.TableIdentifier import TableIdentifier from Table.TableReport import TableReport -from .MetaFileWorkspace.MetaFileTable import ModuleTable -from .MetaFileWorkspace.MetaFileTable import PackageTable -from .MetaFileWorkspace.MetaFileTable import PlatformTable +from Ecc.MetaFileWorkspace.MetaFileTable import ModuleTable +from Ecc.MetaFileWorkspace.MetaFileTable import PackageTable +from Ecc.MetaFileWorkspace.MetaFileTable import PlatformTable from Table.TableFdf import TableFdf ## diff --git a/BaseTools/Source/Python/Ecc/Ecc.py b/BaseTools/Source/Python/Ecc/EccMain.py similarity index 95% rename from BaseTools/Source/Python/Ecc/Ecc.py rename to BaseTools/Source/Python/Ecc/EccMain.py index 8f96bdf977..5f9e497e37 100644 --- a/BaseTools/Source/Python/Ecc/Ecc.py +++ b/BaseTools/Source/Python/Ecc/EccMain.py @@ -17,12 +17,12 @@ from __future__ import absolute_import import Common.LongFilePathOs as os, time, glob, sys import Common.EdkLogger as EdkLogger -from . import Database -from . import EccGlobalData -from .MetaDataParser import * +from Ecc import Database +from Ecc import EccGlobalData +from Ecc.MetaDataParser import * from optparse import OptionParser -from .Configuration import Configuration -from .Check import Check +from Ecc.Configuration import Configuration +from Ecc.Check import Check import Common.GlobalData as GlobalData from Common.StringUtils import NormPath @@ -30,14 +30,14 @@ from Common.BuildVersion import gBUILD_VERSION from Common import BuildToolError from Common.Misc import PathClass from Common.Misc import DirCache -from .MetaFileWorkspace.MetaFileParser import DscParser -from .MetaFileWorkspace.MetaFileParser import DecParser -from .MetaFileWorkspace.MetaFileParser import InfParser -from .MetaFileWorkspace.MetaFileParser import Fdf -from .MetaFileWorkspace.MetaFileTable import MetaFileStorage -from . import c +from Ecc.MetaFileWorkspace.MetaFileParser import DscParser +from Ecc.MetaFileWorkspace.MetaFileParser import DecParser +from Ecc.MetaFileWorkspace.MetaFileParser import InfParser +from Ecc.MetaFileWorkspace.MetaFileParser import Fdf +from Ecc.MetaFileWorkspace.MetaFileTable import MetaFileStorage +from Ecc import c import re, string -from .Exception import * +from Ecc.Exception import * from Common.LongFilePathSupport import OpenLongFilePath as open from Common.MultipleWorkspace import MultipleWorkspace as mws diff --git a/BaseTools/Source/Python/Ecc/Exception.py b/BaseTools/Source/Python/Ecc/Exception.py index 340e0e9752..8b827d7cfe 100644 --- a/BaseTools/Source/Python/Ecc/Exception.py +++ b/BaseTools/Source/Python/Ecc/Exception.py @@ -16,7 +16,7 @@ # from __future__ import print_function from __future__ import absolute_import -from .Xml.XmlRoutines import * +from Ecc.Xml.XmlRoutines import * import Common.LongFilePathOs as os # ExceptionXml to parse Exception Node of XML file diff --git a/BaseTools/Source/Python/Ecc/FileProfile.py b/BaseTools/Source/Python/Ecc/FileProfile.py index 1d3fbf2d3b..4434981628 100644 --- a/BaseTools/Source/Python/Ecc/FileProfile.py +++ b/BaseTools/Source/Python/Ecc/FileProfile.py @@ -19,7 +19,7 @@ from __future__ import absolute_import import re import Common.LongFilePathOs as os -from .ParserWarning import Warning +from Ecc.ParserWarning import Warning from Common.LongFilePathSupport import OpenLongFilePath as open CommentList = [] diff --git a/BaseTools/Source/Python/Ecc/MetaDataParser.py b/BaseTools/Source/Python/Ecc/MetaDataParser.py index e5744dd5cc..d0a94153d4 100644 --- a/BaseTools/Source/Python/Ecc/MetaDataParser.py +++ b/BaseTools/Source/Python/Ecc/MetaDataParser.py @@ -14,9 +14,9 @@ from __future__ import absolute_import import Common.LongFilePathOs as os from CommonDataClass.DataClass import * -from .EccToolError import * +from Ecc.EccToolError import * from Common.MultipleWorkspace import MultipleWorkspace as mws -from . import EccGlobalData +from Ecc import EccGlobalData import re ## Get the inlcude path list for a source file # diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py index 51669815b5..a2cd30d3d9 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py @@ -22,8 +22,8 @@ import copy import Common.EdkLogger as EdkLogger import Common.GlobalData as GlobalData -import EccGlobalData -import EccToolError +import Ecc.EccGlobalData as EccGlobalData +import Ecc.EccToolError as EccToolError from CommonDataClass.DataClass import * from Common.DataType import * @@ -32,7 +32,7 @@ from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClas from Common.Expression import * from CommonDataClass.Exceptions import * -from .MetaFileTable import MetaFileStorage +from Ecc.MetaFileWorkspace.MetaFileTable import MetaFileStorage from GenFds.FdfParser import FdfParser from Common.LongFilePathSupport import OpenLongFilePath as open from Common.LongFilePathSupport import CodecOpenLongFilePath diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py index 7e0afd5d70..a2319a94f6 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py @@ -18,10 +18,10 @@ from __future__ import absolute_import import uuid import Common.EdkLogger as EdkLogger -import EccGlobalData +import Ecc.EccGlobalData as EccGlobalData -from .MetaDataTable import Table -from .MetaDataTable import ConvertToSqlString +from Ecc.MetaFileWorkspace.MetaDataTable import Table +from Ecc.MetaFileWorkspace.MetaDataTable import ConvertToSqlString from CommonDataClass.DataClass import MODEL_FILE_DSC, MODEL_FILE_DEC, MODEL_FILE_INF, \ MODEL_FILE_OTHERS diff --git a/BaseTools/Source/Python/Ecc/c.py b/BaseTools/Source/Python/Ecc/c.py index 5616c10853..953f1630b6 100644 --- a/BaseTools/Source/Python/Ecc/c.py +++ b/BaseTools/Source/Python/Ecc/c.py @@ -17,14 +17,14 @@ import sys import Common.LongFilePathOs as os import re import string -from . import CodeFragmentCollector -from . import FileProfile +from Ecc import CodeFragmentCollector +from Ecc import FileProfile from CommonDataClass import DataClass -from . import Database +from Ecc import Database from Common import EdkLogger -from .EccToolError import * -from . import EccGlobalData -from . import MetaDataParser +from Ecc.EccToolError import * +from Ecc import EccGlobalData +from Ecc import MetaDataParser IncludeFileListDict = {} AllIncludeFileListDict = {} diff --git a/BaseTools/Source/Python/Ecc/config.ini b/BaseTools/Source/Python/Ecc/config.ini index 6c86da74d6..00c98c6232 100644 --- a/BaseTools/Source/Python/Ecc/config.ini +++ b/BaseTools/Source/Python/Ecc/config.ini @@ -73,9 +73,9 @@ GeneralCheckNonAcsii = 1 # Check whether UNI file is valid GeneralCheckUni = 1 # Check Only use CRLF (Carriage Return Line Feed) line endings. -self.GeneralCheckLineEnding = 1 +GeneralCheckLineEnding = 1 # Check if there is no trailing white space in one line. -self.GeneralCheckTrailingWhiteSpaceLine = 1 +GeneralCheckTrailingWhiteSpaceLine = 1 # # Space Checking diff --git a/BaseTools/Source/Python/Table/TableDataModel.py b/BaseTools/Source/Python/Table/TableDataModel.py index ea0996f663..b01c3ecf6a 100644 --- a/BaseTools/Source/Python/Table/TableDataModel.py +++ b/BaseTools/Source/Python/Table/TableDataModel.py @@ -17,7 +17,7 @@ from __future__ import absolute_import import Common.EdkLogger as EdkLogger import CommonDataClass.DataClass as DataClass -from .Table import Table +from Table.Table import Table from Common.StringUtils import ConvertToSqlString ## TableDataModel diff --git a/BaseTools/Source/Python/Table/TableDec.py b/BaseTools/Source/Python/Table/TableDec.py index bbae3e857e..1d887dc1e1 100644 --- a/BaseTools/Source/Python/Table/TableDec.py +++ b/BaseTools/Source/Python/Table/TableDec.py @@ -17,7 +17,7 @@ from __future__ import absolute_import import Common.EdkLogger as EdkLogger import CommonDataClass.DataClass as DataClass -from .Table import Table +from Table.Table import Table from Common.StringUtils import ConvertToSqlString ## TableDec diff --git a/BaseTools/Source/Python/Table/TableDsc.py b/BaseTools/Source/Python/Table/TableDsc.py index 6436973c45..0a45f7f5b6 100644 --- a/BaseTools/Source/Python/Table/TableDsc.py +++ b/BaseTools/Source/Python/Table/TableDsc.py @@ -17,7 +17,7 @@ from __future__ import absolute_import # import Common.EdkLogger as EdkLogger import CommonDataClass.DataClass as DataClass -from .Table import Table +from Table.Table import Table from Common.StringUtils import ConvertToSqlString ## TableDsc diff --git a/BaseTools/Source/Python/Table/TableEotReport.py b/BaseTools/Source/Python/Table/TableEotReport.py index 0a490161cd..6f2fb37189 100644 --- a/BaseTools/Source/Python/Table/TableEotReport.py +++ b/BaseTools/Source/Python/Table/TableEotReport.py @@ -17,7 +17,7 @@ from __future__ import absolute_import import Common.EdkLogger as EdkLogger import Common.LongFilePathOs as os, time -from .Table import Table +from Table.Table import Table from Common.StringUtils import ConvertToSqlString2 import Eot.EotToolError as EotToolError import Eot.EotGlobalData as EotGlobalData diff --git a/BaseTools/Source/Python/Table/TableFdf.py b/BaseTools/Source/Python/Table/TableFdf.py index 80be9532ca..668f56269a 100644 --- a/BaseTools/Source/Python/Table/TableFdf.py +++ b/BaseTools/Source/Python/Table/TableFdf.py @@ -17,7 +17,7 @@ from __future__ import absolute_import import Common.EdkLogger as EdkLogger import CommonDataClass.DataClass as DataClass -from .Table import Table +from Table.Table import Table from Common.StringUtils import ConvertToSqlString ## TableFdf diff --git a/BaseTools/Source/Python/Table/TableFile.py b/BaseTools/Source/Python/Table/TableFile.py index 689264c257..805a528cea 100644 --- a/BaseTools/Source/Python/Table/TableFile.py +++ b/BaseTools/Source/Python/Table/TableFile.py @@ -16,7 +16,7 @@ # from __future__ import absolute_import import Common.EdkLogger as EdkLogger -from .Table import Table +from Table.Table import Table from Common.StringUtils import ConvertToSqlString import Common.LongFilePathOs as os from CommonDataClass.DataClass import FileClass diff --git a/BaseTools/Source/Python/Table/TableFunction.py b/BaseTools/Source/Python/Table/TableFunction.py index 1667180606..ee677cf107 100644 --- a/BaseTools/Source/Python/Table/TableFunction.py +++ b/BaseTools/Source/Python/Table/TableFunction.py @@ -16,7 +16,7 @@ # from __future__ import absolute_import import Common.EdkLogger as EdkLogger -from .Table import Table +from Table.Table import Table from Common.StringUtils import ConvertToSqlString ## TableFunction diff --git a/BaseTools/Source/Python/Table/TableIdentifier.py b/BaseTools/Source/Python/Table/TableIdentifier.py index 8b4dd1d310..6b658cf357 100644 --- a/BaseTools/Source/Python/Table/TableIdentifier.py +++ b/BaseTools/Source/Python/Table/TableIdentifier.py @@ -17,7 +17,7 @@ from __future__ import absolute_import import Common.EdkLogger as EdkLogger from Common.StringUtils import ConvertToSqlString -from .Table import Table +from Table.Table import Table ## TableIdentifier # diff --git a/BaseTools/Source/Python/Table/TableInf.py b/BaseTools/Source/Python/Table/TableInf.py index a00096ac30..e0ffb170f9 100644 --- a/BaseTools/Source/Python/Table/TableInf.py +++ b/BaseTools/Source/Python/Table/TableInf.py @@ -17,7 +17,7 @@ from __future__ import absolute_import import Common.EdkLogger as EdkLogger import CommonDataClass.DataClass as DataClass -from .Table import Table +from Table.Table import Table from Common.StringUtils import ConvertToSqlString ## TableInf diff --git a/BaseTools/Source/Python/Table/TablePcd.py b/BaseTools/Source/Python/Table/TablePcd.py index d58a3ef49e..5096862e6e 100644 --- a/BaseTools/Source/Python/Table/TablePcd.py +++ b/BaseTools/Source/Python/Table/TablePcd.py @@ -16,7 +16,7 @@ # from __future__ import absolute_import import Common.EdkLogger as EdkLogger -from .Table import Table +from Table.Table import Table from Common.StringUtils import ConvertToSqlString ## TablePcd diff --git a/BaseTools/Source/Python/Table/TableQuery.py b/BaseTools/Source/Python/Table/TableQuery.py index a991e610da..8e7d313c71 100644 --- a/BaseTools/Source/Python/Table/TableQuery.py +++ b/BaseTools/Source/Python/Table/TableQuery.py @@ -17,7 +17,7 @@ from __future__ import absolute_import import Common.EdkLogger as EdkLogger from Common.StringUtils import ConvertToSqlString -from .Table import Table +from Table.Table import Table ## TableQuery # diff --git a/BaseTools/Source/Python/Table/TableReport.py b/BaseTools/Source/Python/Table/TableReport.py index c4a622953e..00022962ff 100644 --- a/BaseTools/Source/Python/Table/TableReport.py +++ b/BaseTools/Source/Python/Table/TableReport.py @@ -17,10 +17,10 @@ from __future__ import absolute_import import Common.EdkLogger as EdkLogger import Common.LongFilePathOs as os, time -from .Table import Table +from Table.Table import Table from Common.StringUtils import ConvertToSqlString2 -import EccToolError as EccToolError -import EccGlobalData as EccGlobalData +import Ecc.EccToolError as EccToolError +import Ecc.EccGlobalData as EccGlobalData from Common.LongFilePathSupport import OpenLongFilePath as open ## TableReport -- 2.39.2