from Common.String import NormPath\r
from Common import BuildToolError\r
import c\r
+import re, string\r
from Exception import *\r
\r
## Ecc\r
self.IsInit = True\r
self.ScanSourceCode = True\r
self.ScanMetaData = True\r
- \r
+\r
# Parse the options and args\r
self.ParseOption()\r
\r
# Generate checkpoints list\r
EccGlobalData.gConfig = Configuration(self.ConfigFile)\r
- \r
+\r
# Generate exception list\r
EccGlobalData.gException = ExceptionCheck(self.ExceptionFile)\r
- \r
+\r
# Init Ecc database\r
EccGlobalData.gDb = Database.Database(Database.DATABASE_PATH)\r
EccGlobalData.gDb.InitDatabase(self.IsInit)\r
- \r
+\r
# Build ECC database\r
self.BuildDatabase()\r
- \r
+\r
# Start to check\r
self.Check()\r
- \r
+\r
# Show report\r
self.GenReport()\r
- \r
+\r
# Close Database\r
EccGlobalData.gDb.Close()\r
\r
# Clean report table\r
EccGlobalData.gDb.TblReport.Drop()\r
EccGlobalData.gDb.TblReport.Create()\r
- \r
+\r
# Build database\r
if self.IsInit:\r
if self.ScanSourceCode:\r
if self.ScanMetaData:\r
EdkLogger.quiet("Building database for source code done!")\r
self.BuildMetaDataFileDatabase()\r
- \r
+\r
EccGlobalData.gIdentifierTableList = GetTableList((MODEL_FILE_C, MODEL_FILE_H), 'Identifier', EccGlobalData.gDb)\r
- \r
+\r
## BuildMetaDataFileDatabase\r
#\r
# Build the database for meta data files\r
Op = open(EccGlobalData.gConfig.MetaDataFileCheckPathOfGenerateFileList, 'w+')\r
#SkipDirs = Read from config file\r
SkipDirs = EccGlobalData.gConfig.SkipDirList\r
+ SkipDirString = string.join(SkipDirs, '|')\r
+ p = re.compile(r'.*[\\/](?:%s)[\\/]?.*' % SkipDirString)\r
for Root, Dirs, Files in os.walk(EccGlobalData.gTarget):\r
- for Dir in Dirs:\r
- if Dir.upper() in SkipDirs:\r
- Dirs.remove(Dir)\r
+ if p.match(Root.upper()):\r
+ continue\r
\r
for Dir in Dirs:\r
Dirname = os.path.join(Root, Dir)\r
Filename = os.path.normpath(os.path.join(Root, File))\r
EdkLogger.quiet("Parsing %s" % Filename)\r
Op.write("%s\r" % Filename)\r
- Fdf(Filename, True, EccGlobalData.gWorkspace, EccGlobalData.gDb) \r
+ Fdf(Filename, True, EccGlobalData.gWorkspace, EccGlobalData.gDb)\r
continue\r
Op.close()\r
- \r
+\r
# Commit to database\r
EccGlobalData.gDb.Conn.commit()\r
- \r
+\r
EdkLogger.quiet("Building database for meta data files done!")\r
- \r
+\r
##\r
#\r
# Check each checkpoint\r
EccCheck = Check()\r
EccCheck.Check()\r
EdkLogger.quiet("Checking done!")\r
- \r
+\r
##\r
#\r
# Generate the scan report\r
EdkLogger.quiet("Generating report ...")\r
EccGlobalData.gDb.TblReport.ToCSV(self.ReportFile)\r
EdkLogger.quiet("Generating report done!")\r
- \r
+\r
def GetRealPathCase(self, path):\r
TmpPath = path.rstrip(os.sep)\r
PathParts = TmpPath.split(os.sep)\r
for Dir in Dirs:\r
if Dir.upper() == PathParts[0].upper():\r
return Dir\r
- \r
+\r
if PathParts[0].strip().endswith(':'):\r
PathParts[0] = PathParts[0].upper()\r
ParentDir = PathParts[0]\r
if PathParts[0] == '':\r
RealPath = os.sep\r
ParentDir = os.sep\r
- \r
+\r
PathParts.remove(PathParts[0]) # need to remove the parent\r
for Part in PathParts:\r
Dirs = os.listdir(ParentDir + os.sep)\r
break\r
ParentDir += os.sep\r
ParentDir += Dir\r
- \r
+\r
return RealPath\r
- \r
+\r
## ParseOption\r
#\r
# Parse options\r
def ParseOption(self):\r
EdkLogger.quiet("Loading ECC configuration ... done")\r
(Options, Target) = self.EccOptionParser()\r
- \r
+\r
# Check workspace envirnoment\r
if "WORKSPACE" not in os.environ:\r
- EdkLogger.error("ECC", BuildToolError.ATTRIBUTE_NOT_AVAILABLE, "Environment variable not found", \r
+ EdkLogger.error("ECC", BuildToolError.ATTRIBUTE_NOT_AVAILABLE, "Environment variable not found",\r
ExtraData="WORKSPACE")\r
else:\r
EccGlobalData.gWorkspace = os.path.normpath(os.getenv("WORKSPACE"))\r
os.environ["WORKSPACE"] = EccGlobalData.gWorkspace\r
# Set log level\r
self.SetLogLevel(Options)\r
- \r
+\r
# Set other options\r
if Options.ConfigFile != None:\r
self.ConfigFile = Options.ConfigFile\r
self.ScanSourceCode = False\r
if Options.sourcecode != None:\r
self.ScanMetaData = False\r
- \r
+\r
## SetLogLevel\r
#\r
# Set current log level of the tool based on args\r
#\r
- # @param Option: The option list including log level setting \r
+ # @param Option: The option list including log level setting\r
#\r
def SetLogLevel(self, Option):\r
if Option.verbose != None:\r
Parser.add_option("-m", "--metadata", action="store_true", type=None, help="Only scan meta-data files information if this option is specified.")\r
Parser.add_option("-s", "--sourcecode", action="store_true", type=None, help="Only scan source code files information if this option is specified.")\r
Parser.add_option("-k", "--keepdatabase", action="store_true", type=None, help="The existing Ecc database will not be cleaned except report information if this option is specified.")\r
- Parser.add_option("-l", "--log filename", action="store", dest="LogFile", help="""If specified, the tool should emit the changes that \r
- were made by the tool after printing the result message. \r
- If filename, the emit to the file, otherwise emit to \r
- standard output. If no modifications were made, then do not \r
+ Parser.add_option("-l", "--log filename", action="store", dest="LogFile", help="""If specified, the tool should emit the changes that\r
+ were made by the tool after printing the result message.\r
+ If filename, the emit to the file, otherwise emit to\r
+ standard output. If no modifications were made, then do not\r
create a log file, or output a log message.""")\r
Parser.add_option("-q", "--quiet", action="store_true", type=None, help="Disable all messages except FATAL ERRORS.")\r
Parser.add_option("-v", "--verbose", action="store_true", type=None, help="Turn on verbose output with informational messages printed, "\\r
"including library instances selected, final dependency expression, "\\r
"and warning messages, etc.")\r
Parser.add_option("-d", "--debug", action="store", type="int", help="Enable debug messages at specified level.")\r
- \r
+\r
(Opt, Args)=Parser.parse_args()\r
- \r
+\r
return (Opt, Args)\r
\r
##\r