## @file
# This file is used to be the main entrance of ECC tool
#
# Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
# 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
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
# Import Modules
#
import Database
import EccGlobalData
from MetaDataParser import *
import c
from Exception import *
## Ecc
#
# This class is used to define Ecc main entrance
#
# @param object: Inherited from object class
#
# Version and Copyright
# Parse the options and args
#
# Check EFI_SOURCE (Edk build convention). EDK_SOURCE will always point to ECP
#
#
# Unify case of characters on case-insensitive systems
#
# Generate checkpoints list
# Generate exception list
# Init Ecc database
#
# Get files real name in workspace dir
#
# Build ECC database
# Start to check
# Show report
# Close Database
return
## BuildDatabase
#
# Build the database for target
#
# Clean report table
# Build database
if self.ScanMetaData:
if self.ScanSourceCode:
EccGlobalData.gIdentifierTableList = GetTableList((MODEL_FILE_C, MODEL_FILE_H), 'Identifier', EccGlobalData.gDb)
## BuildMetaDataFileDatabase
#
# Build the database for meta data files
#
#SkipDirs = Read from config file
continue
# symlinks to directories are treated as directories
#Dec(Filename, True, True, EccGlobalData.gWorkspace, EccGlobalData.gDb)
continue
#Dsc(Filename, True, True, EccGlobalData.gWorkspace, EccGlobalData.gDb)
self.MetaFile = DscParser(PathClass(Filename, Root), MODEL_FILE_DSC, MetaFileStorage(EccGlobalData.gDb.TblDsc.Cur, Filename, MODEL_FILE_DSC, True))
# alwasy do post-process, in case of macros change
continue
#Inf(Filename, True, True, EccGlobalData.gWorkspace, EccGlobalData.gDb)
continue
continue
# Commit to database
##
#
# Check each checkpoint
#
##
#
# Generate the scan report
#
return path
# Relative dir, list . current dir
return Dir
break
return RealPath
## ParseOption
#
# Parse options
#
# Check workspace envirnoment
ExtraData="WORKSPACE")
else:
EdkLogger.error("ECC", BuildToolError.FILE_NOT_FOUND, ExtraData="WORKSPACE = %s" % EccGlobalData.gWorkspace)
# Set log level
# Set other options
if Options.ConfigFile != None:
if Options.OutputFile != None:
if Options.ReportFile != None:
if Options.ExceptionFile != None:
EdkLogger.error("ECC", BuildToolError.OPTION_VALUE_INVALID, ExtraData="Target [%s] does NOT exist" % Options.Target)
else:
else:
EdkLogger.warn("Ecc", EdkLogger.ECC_ERROR, "The target source tree was not specified, using current WORKSPACE instead!")
if Options.keepdatabase != None:
EdkLogger.error("ECC", BuildToolError.OPTION_CONFLICT, ExtraData="-m and -s can't be specified at one time")
if Options.sourcecode != None:
## SetLogLevel
#
# Set current log level of the tool based on args
#
# @param Option: The option list including log level setting
#
else:
## Parse command line options
#
# Using standard Python module optparse to parse command line option of this tool.
#
# @retval Opt A optparse.Values object containing the parsed options
# @retval Args Target of build command
#
Parser = OptionParser(description = self.Copyright, version = self.Version, prog = "Ecc.exe", usage = "%prog [options]")
help="Check all files under the target workspace.")
help="Specify a configuration file. Defaultly use config.ini under ECC tool directory.")
help="Specify the name of an output file, if and only if one filename was specified.")
help="Specify the name of an report file, if and only if one filename was specified.")
Parser.add_option("-e", "--exceptionfile filename", action="store", type="string", dest="ExceptionFile",
help="Specify the name of an exception file, if and only if one filename was specified.")
Parser.add_option("-m", "--metadata", action="store_true", type=None, help="Only scan meta-data files information if this option is specified.")
Parser.add_option("-s", "--sourcecode", action="store_true", type=None, help="Only scan source code files information if this option is specified.")
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.")
Parser.add_option("-l", "--log filename", action="store", dest="LogFile", help="""If specified, the tool should emit the changes that
were made by the tool after printing the result message.
If filename, the emit to the file, otherwise emit to
standard output. If no modifications were made, then do not
create a log file, or output a log message.""")
Parser.add_option("-q", "--quiet", action="store_true", type=None, help="Disable all messages except FATAL ERRORS.")
Parser.add_option("-v", "--verbose", action="store_true", type=None, help="Turn on verbose output with informational messages printed, "\
"including library instances selected, final dependency expression, "\
"and warning messages, etc.")
Parser.add_option("-d", "--debug", action="store", type="int", help="Enable debug messages at specified level.")
Parser.add_option("-w", "--workspace", action="store", type="string", dest='Workspace', help="Specify workspace.")
##
#
# This acts like the main() function for the script, unless it is 'import'ed into another
# script.
#
if __name__ == '__main__':
# Initialize log system
EdkLogger.quiet("\n%s [%s]" % (time.strftime("%H:%M:%S, %b.%d %Y", time.localtime()), BuildDuration))