]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Ecc/Check.py
BaseTools: Enhance BaseTools supports FixedAtBuild usage in VFR file
[mirror_edk2.git] / BaseTools / Source / Python / Ecc / Check.py
index dbfedb514bc809020d9e822da3f7c9a456708be8..a22da3d85a1d0d24a93258bbd96ef2fd3a5062b0 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file is used to define checkpoints used by ECC tool\r
 #\r
-# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 #\r
-import os\r
+import Common.LongFilePathOs as os\r
 import re\r
 from CommonDataClass.DataClass import *\r
-from Common.DataType import SUP_MODULE_LIST_STRING, TAB_VALUE_SPLIT\r
+import Common.DataType as DT\r
 from EccToolError import *\r
+from MetaDataParser import ParseHeaderCommentSection\r
 import EccGlobalData\r
 import c\r
+from Common.LongFilePathSupport import OpenLongFilePath as open\r
+from Common.MultipleWorkspace import MultipleWorkspace as mws\r
 \r
 ## Check\r
 #\r
@@ -30,6 +33,7 @@ class Check(object):
 \r
     # Check all required checkpoints\r
     def Check(self):\r
+        self.GeneralCheck()\r
         self.MetaDataFileCheck()\r
         self.DoxygenCheck()\r
         self.IncludeFileCheck()\r
@@ -38,6 +42,43 @@ class Check(object):
         self.FunctionLayoutCheck()\r
         self.NamingConventionCheck()\r
 \r
+    # Check UNI files\r
+    def UniCheck(self):\r
+        if EccGlobalData.gConfig.GeneralCheckUni == '1' or EccGlobalData.gConfig.GeneralCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
+            EdkLogger.quiet("Checking whether UNI file is UTF-16 ...")\r
+            SqlCommand = """select ID, FullPath, ExtName from File where ExtName like 'uni'"""\r
+            RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)\r
+            for Record in RecordSet:\r
+                File = Record[1]\r
+                FileIn = open(File, 'rb').read(2)\r
+                if FileIn != '\xff\xfe':\r
+                    OtherMsg = "File %s is not a valid UTF-16 UNI file" % Record[1]\r
+                    EccGlobalData.gDb.TblReport.Insert(ERROR_GENERAL_CHECK_UNI, OtherMsg=OtherMsg, BelongsToTable='File', BelongsToItem=Record[0])\r
+\r
+    # General Checking\r
+    def GeneralCheck(self):\r
+        self.GeneralCheckNonAcsii()\r
+        self.UniCheck()\r
+\r
+    # Check whether file has non ACSII char\r
+    def GeneralCheckNonAcsii(self):\r
+        if EccGlobalData.gConfig.GeneralCheckNonAcsii == '1' or EccGlobalData.gConfig.GeneralCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
+            EdkLogger.quiet("Checking Non-ACSII char in file ...")\r
+            SqlCommand = """select ID, FullPath, ExtName from File where ExtName in ('.dec', '.inf', '.dsc', 'c', 'h')"""\r
+            RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)\r
+            for Record in RecordSet:\r
+                if Record[2].upper() not in EccGlobalData.gConfig.BinaryExtList:\r
+                    op = open(Record[1]).readlines()\r
+                    IndexOfLine = 0\r
+                    for Line in op:\r
+                        IndexOfLine += 1\r
+                        IndexOfChar = 0\r
+                        for Char in Line:\r
+                            IndexOfChar += 1\r
+                            if ord(Char) > 126:\r
+                                OtherMsg = "File %s has Non-ASCII char at line %s column %s" % (Record[1], IndexOfLine, IndexOfChar)\r
+                                EccGlobalData.gDb.TblReport.Insert(ERROR_GENERAL_CHECK_NON_ACSII, OtherMsg=OtherMsg, BelongsToTable='File', BelongsToItem=Record[0])\r
+\r
     # C Function Layout Checking\r
     def FunctionLayoutCheck(self):\r
         self.FunctionLayoutCheckReturnType()\r
@@ -60,6 +101,9 @@ class Check(object):
                         Dirnames.append(Dirname)\r
             if IgnoredPattern.match(Dirpath.upper()):\r
                 continue\r
+            for f in Filenames[:]:\r
+                if f.lower() in EccGlobalData.gConfig.SkipFileList:\r
+                    Filenames.remove(f)\r
             yield (Dirpath, Dirnames, Filenames)\r
 \r
     # Check whether return type exists and in the first line\r
@@ -67,22 +111,26 @@ class Check(object):
         if EccGlobalData.gConfig.CFunctionLayoutCheckReturnType == '1' or EccGlobalData.gConfig.CFunctionLayoutCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking function layout return type ...")\r
 \r
-            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
-                for F in Filenames:\r
-                    if os.path.splitext(F)[1] in ('.c', '.h'):\r
-                        FullName = os.path.join(Dirpath, F)\r
-                        c.CheckFuncLayoutReturnType(FullName)\r
+#            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
+#                for F in Filenames:\r
+#                    if os.path.splitext(F)[1] in ('.c', '.h'):\r
+#                        FullName = os.path.join(Dirpath, F)\r
+#                        c.CheckFuncLayoutReturnType(FullName)\r
+            for FullName in EccGlobalData.gCFileList + EccGlobalData.gHFileList:\r
+                c.CheckFuncLayoutReturnType(FullName)\r
 \r
     # Check whether any optional functional modifiers exist and next to the return type\r
     def FunctionLayoutCheckModifier(self):\r
         if EccGlobalData.gConfig.CFunctionLayoutCheckOptionalFunctionalModifier == '1' or EccGlobalData.gConfig.CFunctionLayoutCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking function layout modifier ...")\r
 \r
-            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
-                for F in Filenames:\r
-                    if os.path.splitext(F)[1] in ('.c', '.h'):\r
-                        FullName = os.path.join(Dirpath, F)\r
-                        c.CheckFuncLayoutModifier(FullName)\r
+#            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
+#                for F in Filenames:\r
+#                    if os.path.splitext(F)[1] in ('.c', '.h'):\r
+#                        FullName = os.path.join(Dirpath, F)\r
+#                        c.CheckFuncLayoutModifier(FullName)\r
+            for FullName in EccGlobalData.gCFileList + EccGlobalData.gHFileList:\r
+                c.CheckFuncLayoutModifier(FullName)\r
 \r
     # Check whether the next line contains the function name, left justified, followed by the beginning of the parameter list\r
     # Check whether the closing parenthesis is on its own line and also indented two spaces\r
@@ -90,33 +138,41 @@ class Check(object):
         if EccGlobalData.gConfig.CFunctionLayoutCheckFunctionName == '1' or EccGlobalData.gConfig.CFunctionLayoutCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking function layout function name ...")\r
 \r
-            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
-                for F in Filenames:\r
-                    if os.path.splitext(F)[1] in ('.c', '.h'):\r
-                        FullName = os.path.join(Dirpath, F)\r
-                        c.CheckFuncLayoutName(FullName)\r
+#            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
+#                for F in Filenames:\r
+#                    if os.path.splitext(F)[1] in ('.c', '.h'):\r
+#                        FullName = os.path.join(Dirpath, F)\r
+#                        c.CheckFuncLayoutName(FullName)\r
+            for FullName in EccGlobalData.gCFileList + EccGlobalData.gHFileList:\r
+                c.CheckFuncLayoutName(FullName)\r
+\r
     # Check whether the function prototypes in include files have the same form as function definitions\r
     def FunctionLayoutCheckPrototype(self):\r
         if EccGlobalData.gConfig.CFunctionLayoutCheckFunctionPrototype == '1' or EccGlobalData.gConfig.CFunctionLayoutCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking function layout function prototype ...")\r
 \r
-            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
-                for F in Filenames:\r
-                    if os.path.splitext(F)[1] in ('.c'):\r
-                        FullName = os.path.join(Dirpath, F)\r
-                        EdkLogger.quiet("[PROTOTYPE]" + FullName)\r
-                        c.CheckFuncLayoutPrototype(FullName)\r
+#            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
+#                for F in Filenames:\r
+#                    if os.path.splitext(F)[1] in ('.c'):\r
+#                        FullName = os.path.join(Dirpath, F)\r
+#                        EdkLogger.quiet("[PROTOTYPE]" + FullName)\r
+#                        c.CheckFuncLayoutPrototype(FullName)\r
+            for FullName in EccGlobalData.gCFileList:\r
+                EdkLogger.quiet("[PROTOTYPE]" + FullName)\r
+                c.CheckFuncLayoutPrototype(FullName)\r
 \r
     # Check whether the body of a function is contained by open and close braces that must be in the first column\r
     def FunctionLayoutCheckBody(self):\r
         if EccGlobalData.gConfig.CFunctionLayoutCheckFunctionBody == '1' or EccGlobalData.gConfig.CFunctionLayoutCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking function layout function body ...")\r
 \r
-            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
-                for F in Filenames:\r
-                    if os.path.splitext(F)[1] in ('.c'):\r
-                        FullName = os.path.join(Dirpath, F)\r
-                        c.CheckFuncLayoutBody(FullName)\r
+#            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
+#                for F in Filenames:\r
+#                    if os.path.splitext(F)[1] in ('.c'):\r
+#                        FullName = os.path.join(Dirpath, F)\r
+#                        c.CheckFuncLayoutBody(FullName)\r
+            for FullName in EccGlobalData.gCFileList:\r
+                c.CheckFuncLayoutBody(FullName)\r
 \r
     # Check whether the data declarations is the first code in a module.\r
     # self.CFunctionLayoutCheckDataDeclaration = 1\r
@@ -125,11 +181,14 @@ class Check(object):
         if EccGlobalData.gConfig.CFunctionLayoutCheckNoInitOfVariable == '1' or EccGlobalData.gConfig.CFunctionLayoutCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking function layout local variables ...")\r
 \r
-            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
-                for F in Filenames:\r
-                    if os.path.splitext(F)[1] in ('.c'):\r
-                        FullName = os.path.join(Dirpath, F)\r
-                        c.CheckFuncLayoutLocalVariable(FullName)\r
+#            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
+#                for F in Filenames:\r
+#                    if os.path.splitext(F)[1] in ('.c'):\r
+#                        FullName = os.path.join(Dirpath, F)\r
+#                        c.CheckFuncLayoutLocalVariable(FullName)\r
+\r
+            for FullName in EccGlobalData.gCFileList:\r
+                c.CheckFuncLayoutLocalVariable(FullName)\r
 \r
     # Check whether no use of STATIC for functions\r
     # self.CFunctionLayoutCheckNoStatic = 1\r
@@ -150,22 +209,26 @@ class Check(object):
         if EccGlobalData.gConfig.DeclarationDataTypeCheckNoUseCType == '1' or EccGlobalData.gConfig.DeclarationDataTypeCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking Declaration No use C type ...")\r
 \r
-            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
-                for F in Filenames:\r
-                    if os.path.splitext(F)[1] in ('.h', '.c'):\r
-                        FullName = os.path.join(Dirpath, F)\r
-                        c.CheckDeclNoUseCType(FullName)\r
+#            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
+#                for F in Filenames:\r
+#                    if os.path.splitext(F)[1] in ('.h', '.c'):\r
+#                        FullName = os.path.join(Dirpath, F)\r
+#                        c.CheckDeclNoUseCType(FullName)\r
+            for FullName in EccGlobalData.gCFileList + EccGlobalData.gHFileList:\r
+                c.CheckDeclNoUseCType(FullName)\r
 \r
     # Check whether the modifiers IN, OUT, OPTIONAL, and UNALIGNED are used only to qualify arguments to a function and should not appear in a data type declaration\r
     def DeclCheckInOutModifier(self):\r
         if EccGlobalData.gConfig.DeclarationDataTypeCheckInOutModifier == '1' or EccGlobalData.gConfig.DeclarationDataTypeCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking Declaration argument modifier ...")\r
 \r
-            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
-                for F in Filenames:\r
-                    if os.path.splitext(F)[1] in ('.h', '.c'):\r
-                        FullName = os.path.join(Dirpath, F)\r
-                        c.CheckDeclArgModifier(FullName)\r
+#            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
+#                for F in Filenames:\r
+#                    if os.path.splitext(F)[1] in ('.h', '.c'):\r
+#                        FullName = os.path.join(Dirpath, F)\r
+#                        c.CheckDeclArgModifier(FullName)\r
+            for FullName in EccGlobalData.gCFileList + EccGlobalData.gHFileList:\r
+                c.CheckDeclArgModifier(FullName)\r
 \r
     # Check whether the EFIAPI modifier should be used at the entry of drivers, events, and member functions of protocols\r
     def DeclCheckEFIAPIModifier(self):\r
@@ -177,24 +240,30 @@ class Check(object):
         if EccGlobalData.gConfig.DeclarationDataTypeCheckEnumeratedType == '1' or EccGlobalData.gConfig.DeclarationDataTypeCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking Declaration enum typedef ...")\r
 \r
-            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
-                for F in Filenames:\r
-                    if os.path.splitext(F)[1] in ('.h', '.c'):\r
-                        FullName = os.path.join(Dirpath, F)\r
-                        EdkLogger.quiet("[ENUM]" + FullName)\r
-                        c.CheckDeclEnumTypedef(FullName)\r
+#            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
+#                for F in Filenames:\r
+#                    if os.path.splitext(F)[1] in ('.h', '.c'):\r
+#                        FullName = os.path.join(Dirpath, F)\r
+#                        EdkLogger.quiet("[ENUM]" + FullName)\r
+#                        c.CheckDeclEnumTypedef(FullName)\r
+            for FullName in EccGlobalData.gCFileList + EccGlobalData.gHFileList:\r
+                EdkLogger.quiet("[ENUM]" + FullName)\r
+                c.CheckDeclEnumTypedef(FullName)\r
 \r
     # Check whether Structure Type has a 'typedef' and the name is capital\r
     def DeclCheckStructureDeclaration(self):\r
         if EccGlobalData.gConfig.DeclarationDataTypeCheckStructureDeclaration == '1' or EccGlobalData.gConfig.DeclarationDataTypeCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking Declaration struct typedef ...")\r
 \r
-            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
-                for F in Filenames:\r
-                    if os.path.splitext(F)[1] in ('.h', '.c'):\r
-                        FullName = os.path.join(Dirpath, F)\r
-                        EdkLogger.quiet("[STRUCT]" + FullName)\r
-                        c.CheckDeclStructTypedef(FullName)\r
+#            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
+#                for F in Filenames:\r
+#                    if os.path.splitext(F)[1] in ('.h', '.c'):\r
+#                        FullName = os.path.join(Dirpath, F)\r
+#                        EdkLogger.quiet("[STRUCT]" + FullName)\r
+#                        c.CheckDeclStructTypedef(FullName)\r
+            for FullName in EccGlobalData.gCFileList + EccGlobalData.gHFileList:\r
+                EdkLogger.quiet("[STRUCT]" + FullName)\r
+                c.CheckDeclStructTypedef(FullName)\r
 \r
     # Check whether having same Structure\r
     def DeclCheckSameStructure(self):\r
@@ -202,7 +271,7 @@ class Check(object):
             EdkLogger.quiet("Checking same struct ...")\r
             AllStructure = {}\r
             for IdentifierTable in EccGlobalData.gIdentifierTableList:\r
-                SqlCommand = """select ID, Name, BelongsToFile from %s where Model = %s""" %(IdentifierTable, MODEL_IDENTIFIER_STRUCTURE)\r
+                SqlCommand = """select ID, Name, BelongsToFile from %s where Model = %s""" % (IdentifierTable, MODEL_IDENTIFIER_STRUCTURE)\r
                 RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)\r
                 for Record in RecordSet:\r
                     if Record[1] != '':\r
@@ -216,19 +285,22 @@ class Check(object):
                             if NewRecordSet != []:\r
                                 OtherMsg = "The structure name [%s] is duplicate with the one defined in %s, maybe struct NOT typedefed or the typedef new type NOT used to qualify variables" % (Record[1], NewRecordSet[0][0])\r
                             if not EccGlobalData.gException.IsException(ERROR_DECLARATION_DATA_TYPE_CHECK_SAME_STRUCTURE, Record[1]):\r
-                                EccGlobalData.gDb.TblReport.Insert(ERROR_DECLARATION_DATA_TYPE_CHECK_SAME_STRUCTURE, OtherMsg = OtherMsg, BelongsToTable = IdentifierTable, BelongsToItem = Record[0])\r
+                                EccGlobalData.gDb.TblReport.Insert(ERROR_DECLARATION_DATA_TYPE_CHECK_SAME_STRUCTURE, OtherMsg=OtherMsg, BelongsToTable=IdentifierTable, BelongsToItem=Record[0])\r
 \r
     # Check whether Union Type has a 'typedef' and the name is capital\r
     def DeclCheckUnionType(self):\r
         if EccGlobalData.gConfig.DeclarationDataTypeCheckUnionType == '1' or EccGlobalData.gConfig.DeclarationDataTypeCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking Declaration union typedef ...")\r
 \r
-            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
-                for F in Filenames:\r
-                    if os.path.splitext(F)[1] in ('.h', '.c'):\r
-                        FullName = os.path.join(Dirpath, F)\r
-                        EdkLogger.quiet("[UNION]" + FullName)\r
-                        c.CheckDeclUnionTypedef(FullName)\r
+#            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
+#                for F in Filenames:\r
+#                    if os.path.splitext(F)[1] in ('.h', '.c'):\r
+#                        FullName = os.path.join(Dirpath, F)\r
+#                        EdkLogger.quiet("[UNION]" + FullName)\r
+#                        c.CheckDeclUnionTypedef(FullName)\r
+            for FullName in EccGlobalData.gCFileList + EccGlobalData.gHFileList:\r
+                EdkLogger.quiet("[UNION]" + FullName)\r
+                c.CheckDeclUnionTypedef(FullName)\r
 \r
     # Predicate Expression Checking\r
     def PredicateExpressionCheck(self):\r
@@ -241,35 +313,46 @@ class Check(object):
         if EccGlobalData.gConfig.PredicateExpressionCheckBooleanValue == '1' or EccGlobalData.gConfig.PredicateExpressionCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking predicate expression Boolean value ...")\r
 \r
-            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
-                for F in Filenames:\r
-                    if os.path.splitext(F)[1] in ('.c'):\r
-                        FullName = os.path.join(Dirpath, F)\r
-                        EdkLogger.quiet("[BOOLEAN]" + FullName)\r
-                        c.CheckBooleanValueComparison(FullName)\r
+#            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
+#                for F in Filenames:\r
+#                    if os.path.splitext(F)[1] in ('.c'):\r
+#                        FullName = os.path.join(Dirpath, F)\r
+#                        EdkLogger.quiet("[BOOLEAN]" + FullName)\r
+#                        c.CheckBooleanValueComparison(FullName)\r
+            for FullName in EccGlobalData.gCFileList:\r
+                EdkLogger.quiet("[BOOLEAN]" + FullName)\r
+                c.CheckBooleanValueComparison(FullName)\r
 \r
     # Check whether Non-Boolean comparisons use a compare operator (==, !=, >, < >=, <=).\r
     def PredicateExpressionCheckNonBooleanOperator(self):\r
         if EccGlobalData.gConfig.PredicateExpressionCheckNonBooleanOperator == '1' or EccGlobalData.gConfig.PredicateExpressionCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking predicate expression Non-Boolean variable...")\r
 \r
-            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
-                for F in Filenames:\r
-                    if os.path.splitext(F)[1] in ('.c'):\r
-                        FullName = os.path.join(Dirpath, F)\r
-                        EdkLogger.quiet("[NON-BOOLEAN]" + FullName)\r
-                        c.CheckNonBooleanValueComparison(FullName)\r
+#            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
+#                for F in Filenames:\r
+#                    if os.path.splitext(F)[1] in ('.c'):\r
+#                        FullName = os.path.join(Dirpath, F)\r
+#                        EdkLogger.quiet("[NON-BOOLEAN]" + FullName)\r
+#                        c.CheckNonBooleanValueComparison(FullName)\r
+            for FullName in EccGlobalData.gCFileList:\r
+                EdkLogger.quiet("[NON-BOOLEAN]" + FullName)\r
+                c.CheckNonBooleanValueComparison(FullName)\r
+\r
     # Check whether a comparison of any pointer to zero must be done via the NULL type\r
     def PredicateExpressionCheckComparisonNullType(self):\r
         if EccGlobalData.gConfig.PredicateExpressionCheckComparisonNullType == '1' or EccGlobalData.gConfig.PredicateExpressionCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking predicate expression NULL pointer ...")\r
 \r
-            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
-                for F in Filenames:\r
-                    if os.path.splitext(F)[1] in ('.c'):\r
-                        FullName = os.path.join(Dirpath, F)\r
-                        EdkLogger.quiet("[POINTER]" + FullName)\r
-                        c.CheckPointerNullComparison(FullName)\r
+#            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
+#                for F in Filenames:\r
+#                    if os.path.splitext(F)[1] in ('.c'):\r
+#                        FullName = os.path.join(Dirpath, F)\r
+#                        EdkLogger.quiet("[POINTER]" + FullName)\r
+#                        c.CheckPointerNullComparison(FullName)\r
+            for FullName in EccGlobalData.gCFileList:\r
+                EdkLogger.quiet("[POINTER]" + FullName)\r
+                c.CheckPointerNullComparison(FullName)\r
+\r
     # Include file checking\r
     def IncludeFileCheck(self):\r
         self.IncludeFileCheckIfndef()\r
@@ -298,33 +381,35 @@ class Check(object):
             for Key in RecordDict:\r
                 if len(RecordDict[Key]) > 1:\r
                     for Item in RecordDict[Key]:\r
-                        Path = Item[1].replace(EccGlobalData.gWorkspace, '')\r
-                        if Path.startswith('\\') or Path.startswith('/'):\r
-                            Path = Path[1:]\r
+                        Path = mws.relpath(Item[1], EccGlobalData.gWorkspace)\r
                         if not EccGlobalData.gException.IsException(ERROR_INCLUDE_FILE_CHECK_NAME, Path):\r
-                            EccGlobalData.gDb.TblReport.Insert(ERROR_INCLUDE_FILE_CHECK_NAME, OtherMsg = "The file name for [%s] is duplicate" % Path, BelongsToTable = 'File', BelongsToItem = Item[0])\r
+                            EccGlobalData.gDb.TblReport.Insert(ERROR_INCLUDE_FILE_CHECK_NAME, OtherMsg="The file name for [%s] is duplicate" % Path, BelongsToTable='File', BelongsToItem=Item[0])\r
 \r
     # Check whether all include file contents is guarded by a #ifndef statement.\r
     def IncludeFileCheckIfndef(self):\r
         if EccGlobalData.gConfig.IncludeFileCheckIfndefStatement == '1' or EccGlobalData.gConfig.IncludeFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking header file ifndef ...")\r
 \r
-            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
-                for F in Filenames:\r
-                    if os.path.splitext(F)[1] in ('.h'):\r
-                        FullName = os.path.join(Dirpath, F)\r
-                        MsgList = c.CheckHeaderFileIfndef(FullName)\r
+#            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
+#                for F in Filenames:\r
+#                    if os.path.splitext(F)[1] in ('.h'):\r
+#                        FullName = os.path.join(Dirpath, F)\r
+#                        MsgList = c.CheckHeaderFileIfndef(FullName)\r
+            for FullName in EccGlobalData.gHFileList:\r
+                MsgList = c.CheckHeaderFileIfndef(FullName)\r
 \r
     # Check whether include files NOT contain code or define data variables\r
     def IncludeFileCheckData(self):\r
         if EccGlobalData.gConfig.IncludeFileCheckData == '1' or EccGlobalData.gConfig.IncludeFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking header file data ...")\r
 \r
-            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
-                for F in Filenames:\r
-                    if os.path.splitext(F)[1] in ('.h'):\r
-                        FullName = os.path.join(Dirpath, F)\r
-                        MsgList = c.CheckHeaderFileData(FullName)\r
+#            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
+#                for F in Filenames:\r
+#                    if os.path.splitext(F)[1] in ('.h'):\r
+#                        FullName = os.path.join(Dirpath, F)\r
+#                        MsgList = c.CheckHeaderFileData(FullName)\r
+            for FullName in EccGlobalData.gHFileList:\r
+                MsgList = c.CheckHeaderFileData(FullName)\r
 \r
     # Doxygen document checking\r
     def DoxygenCheck(self):\r
@@ -347,24 +432,96 @@ class Check(object):
                         MsgList = c.CheckFileHeaderDoxygenComments(FullName)\r
                     elif Ext in ('.inf', '.dec', '.dsc', '.fdf'):\r
                         FullName = os.path.join(Dirpath, F)\r
-                        if not open(FullName).read().startswith('## @file'):\r
+                        op = open(FullName).readlines()\r
+                        FileLinesList = op\r
+                        LineNo             = 0\r
+                        CurrentSection     = MODEL_UNKNOWN \r
+                        HeaderSectionLines       = []\r
+                        HeaderCommentStart = False \r
+                        HeaderCommentEnd   = False\r
+                        \r
+                        for Line in FileLinesList:\r
+                            LineNo   = LineNo + 1\r
+                            Line     = Line.strip()\r
+                            if (LineNo < len(FileLinesList) - 1):\r
+                                NextLine = FileLinesList[LineNo].strip()\r
+            \r
+                            #\r
+                            # blank line\r
+                            #\r
+                            if (Line == '' or not Line) and LineNo == len(FileLinesList):\r
+                                LastSectionFalg = True\r
+\r
+                            #\r
+                            # check whether file header comment section started\r
+                            #\r
+                            if Line.startswith('#') and \\r
+                                (Line.find('@file') > -1) and \\r
+                                not HeaderCommentStart:\r
+                                if CurrentSection != MODEL_UNKNOWN:\r
+                                    SqlStatement = """ select ID from File where FullPath like '%s'""" % FullName\r
+                                    ResultSet = EccGlobalData.gDb.TblFile.Exec(SqlStatement)\r
+                                    for Result in ResultSet:\r
+                                        Msg = 'INF/DEC/DSC/FDF file header comment should begin with ""## @file"" or ""# @file""at the very top file'\r
+                                        EccGlobalData.gDb.TblReport.Insert(ERROR_DOXYGEN_CHECK_FILE_HEADER, Msg, "File", Result[0])\r
+\r
+                                else:\r
+                                    CurrentSection = MODEL_IDENTIFIER_FILE_HEADER\r
+                                    #\r
+                                    # Append the first line to section lines.\r
+                                    #\r
+                                    HeaderSectionLines.append((Line, LineNo))\r
+                                    HeaderCommentStart = True\r
+                                    continue        \r
+            \r
+                            #\r
+                            # Collect Header content.\r
+                            #\r
+                            if (Line.startswith('#') and CurrentSection == MODEL_IDENTIFIER_FILE_HEADER) and\\r
+                                HeaderCommentStart and not Line.startswith('##') and not\\r
+                                HeaderCommentEnd and NextLine != '':\r
+                                HeaderSectionLines.append((Line, LineNo))\r
+                                continue\r
+                            #\r
+                            # Header content end\r
+                            #\r
+                            if (Line.startswith('##') or not Line.strip().startswith("#")) and HeaderCommentStart \\r
+                                and not HeaderCommentEnd:\r
+                                if Line.startswith('##'):\r
+                                    HeaderCommentEnd = True\r
+                                HeaderSectionLines.append((Line, LineNo))\r
+                                ParseHeaderCommentSection(HeaderSectionLines, FullName)\r
+                                break\r
+                        if HeaderCommentStart == False:\r
                             SqlStatement = """ select ID from File where FullPath like '%s'""" % FullName\r
                             ResultSet = EccGlobalData.gDb.TblFile.Exec(SqlStatement)\r
                             for Result in ResultSet:\r
-                                Msg = 'INF/DEC/DSC/FDF file header comment should begin with ""## @file""'\r
+                                Msg = 'INF/DEC/DSC/FDF file header comment should begin with ""## @file"" or ""# @file"" at the very top file'\r
                                 EccGlobalData.gDb.TblReport.Insert(ERROR_DOXYGEN_CHECK_FILE_HEADER, Msg, "File", Result[0])\r
-                                        \r
+                        if HeaderCommentEnd == False:\r
+                            SqlStatement = """ select ID from File where FullPath like '%s'""" % FullName\r
+                            ResultSet = EccGlobalData.gDb.TblFile.Exec(SqlStatement)\r
+                            for Result in ResultSet:\r
+                                Msg = 'INF/DEC/DSC/FDF file header comment should end with ""##"" at the end of file header comment block'\r
+                                # Check whether File header Comment End with '##'\r
+                                if EccGlobalData.gConfig.HeaderCheckFileCommentEnd == '1' or EccGlobalData.gConfig.HeaderCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
+                                    EccGlobalData.gDb.TblReport.Insert(ERROR_DOXYGEN_CHECK_FILE_HEADER, Msg, "File", Result[0])\r
+\r
+                                     \r
 \r
     # Check whether the function headers are followed Doxygen special documentation blocks in section 2.3.5\r
     def DoxygenCheckFunctionHeader(self):\r
         if EccGlobalData.gConfig.DoxygenCheckFunctionHeader == '1' or EccGlobalData.gConfig.DoxygenCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking Doxygen function header ...")\r
 \r
-            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
-                for F in Filenames:\r
-                    if os.path.splitext(F)[1] in ('.h', '.c'):\r
-                        FullName = os.path.join(Dirpath, F)\r
-                        MsgList = c.CheckFuncHeaderDoxygenComments(FullName)\r
+#            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
+#                for F in Filenames:\r
+#                    if os.path.splitext(F)[1] in ('.h', '.c'):\r
+#                        FullName = os.path.join(Dirpath, F)\r
+#                        MsgList = c.CheckFuncHeaderDoxygenComments(FullName)\r
+            for FullName in EccGlobalData.gCFileList + EccGlobalData.gHFileList:\r
+                MsgList = c.CheckFuncHeaderDoxygenComments(FullName)\r
+\r
 \r
     # Check whether the first line of text in a comment block is a brief description of the element being documented.\r
     # The brief description must end with a period.\r
@@ -377,22 +534,26 @@ class Check(object):
         if EccGlobalData.gConfig.DoxygenCheckCommentFormat == '1' or EccGlobalData.gConfig.DoxygenCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking Doxygen comment ///< ...")\r
 \r
-            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
-                for F in Filenames:\r
-                    if os.path.splitext(F)[1] in ('.h', '.c'):\r
-                        FullName = os.path.join(Dirpath, F)\r
-                        MsgList = c.CheckDoxygenTripleForwardSlash(FullName)\r
+#            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
+#                for F in Filenames:\r
+#                    if os.path.splitext(F)[1] in ('.h', '.c'):\r
+#                        FullName = os.path.join(Dirpath, F)\r
+#                        MsgList = c.CheckDoxygenTripleForwardSlash(FullName)\r
+            for FullName in EccGlobalData.gCFileList + EccGlobalData.gHFileList:\r
+                MsgList = c.CheckDoxygenTripleForwardSlash(FullName)\r
 \r
     # Check whether only Doxygen commands allowed to mark the code are @bug and @todo.\r
     def DoxygenCheckCommand(self):\r
         if EccGlobalData.gConfig.DoxygenCheckCommand == '1' or EccGlobalData.gConfig.DoxygenCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking Doxygen command ...")\r
 \r
-            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
-                for F in Filenames:\r
-                    if os.path.splitext(F)[1] in ('.h', '.c'):\r
-                        FullName = os.path.join(Dirpath, F)\r
-                        MsgList = c.CheckDoxygenCommand(FullName)\r
+#            for Dirpath, Dirnames, Filenames in self.WalkTree():\r
+#                for F in Filenames:\r
+#                    if os.path.splitext(F)[1] in ('.h', '.c'):\r
+#                        FullName = os.path.join(Dirpath, F)\r
+#                        MsgList = c.CheckDoxygenCommand(FullName)\r
+            for FullName in EccGlobalData.gCFileList + EccGlobalData.gHFileList:\r
+                MsgList = c.CheckDoxygenCommand(FullName)\r
 \r
     # Meta-Data File Processing Checking\r
     def MetaDataFileCheck(self):\r
@@ -402,6 +563,7 @@ class Check(object):
         self.MetaDataFileCheckLibraryInstanceDependent()\r
         self.MetaDataFileCheckLibraryInstanceOrder()\r
         self.MetaDataFileCheckLibraryNoUse()\r
+        self.MetaDataFileCheckLibraryDefinedInDec()\r
         self.MetaDataFileCheckBinaryInfInFdf()\r
         self.MetaDataFileCheckPcdDuplicate()\r
         self.MetaDataFileCheckPcdFlash()\r
@@ -410,6 +572,10 @@ class Check(object):
         self.MetaDataFileCheckModuleFileNoUse()\r
         self.MetaDataFileCheckPcdType()\r
         self.MetaDataFileCheckModuleFileGuidDuplication()\r
+        self.MetaDataFileCheckModuleFileGuidFormat()\r
+        self.MetaDataFileCheckModuleFileProtocolFormat()\r
+        self.MetaDataFileCheckModuleFilePpiFormat()\r
+        self.MetaDataFileCheckModuleFilePcdFormat()\r
 \r
     # Check whether each file defined in meta-data exists\r
     def MetaDataFileCheckPathName(self):\r
@@ -429,9 +595,9 @@ class Check(object):
     def MetaDataFileCheckLibraryInstance(self):\r
         if EccGlobalData.gConfig.MetaDataFileCheckLibraryInstance == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking for library instance type issue ...")\r
-            SqlCommand = """select A.ID, A.Value2, B.Value2 from Inf as A left join Inf as B\r
-                            where A.Value1 = 'LIBRARY_CLASS' and A.Model = %s\r
-                            and B.Value1 = 'MODULE_TYPE' and B.Model = %s and A.BelongsToFile = B.BelongsToFile\r
+            SqlCommand = """select A.ID, A.Value3, B.Value3 from Inf as A left join Inf as B\r
+                            where A.Value2 = 'LIBRARY_CLASS' and A.Model = %s\r
+                            and B.Value2 = 'MODULE_TYPE' and B.Model = %s and A.BelongsToFile = B.BelongsToFile\r
                             group by A.BelongsToFile""" % (MODEL_META_DATA_HEADER, MODEL_META_DATA_HEADER)\r
             RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)\r
             LibraryClasses = {}\r
@@ -439,7 +605,7 @@ class Check(object):
                 List = Record[1].split('|', 1)\r
                 SupModType = []\r
                 if len(List) == 1:\r
-                    SupModType = SUP_MODULE_LIST_STRING.split(TAB_VALUE_SPLIT)\r
+                    SupModType = DT.SUP_MODULE_LIST_STRING.split(DT.TAB_VALUE_SPLIT)\r
                 elif len(List) == 2:\r
                     SupModType = List[1].split()\r
 \r
@@ -451,10 +617,10 @@ class Check(object):
                             LibraryClasses[List[0]].append(Item)\r
 \r
                 if Record[2] != 'BASE' and Record[2] not in SupModType:\r
-                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_2, OtherMsg = "The Library Class '%s' does not specify its supported module types" % (List[0]), BelongsToTable = 'Inf', BelongsToItem = Record[0])\r
+                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_2, OtherMsg="The Library Class '%s' does not specify its supported module types" % (List[0]), BelongsToTable='Inf', BelongsToItem=Record[0])\r
 \r
-            SqlCommand = """select A.ID, A.Value1, B.Value2 from Inf as A left join Inf as B\r
-                            where A.Model = %s and B.Value1 = '%s' and B.Model = %s\r
+            SqlCommand = """select A.ID, A.Value1, B.Value3 from Inf as A left join Inf as B\r
+                            where A.Model = %s and B.Value2 = '%s' and B.Model = %s\r
                             and B.BelongsToFile = A.BelongsToFile""" \\r
                             % (MODEL_EFI_LIBRARY_CLASS, 'MODULE_TYPE', MODEL_META_DATA_HEADER)\r
             RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)\r
@@ -471,10 +637,10 @@ class Check(object):
                 if Record[1] in LibraryClasses:\r
                     if Record[2] not in LibraryClasses[Record[1]] and 'BASE' not in RecordDict[Record[1]]:\r
                         if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_1, Record[1]):\r
-                            EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_1, OtherMsg = "The type of Library Class [%s] defined in Inf file does not match the type of the module" % (Record[1]), BelongsToTable = 'Inf', BelongsToItem = Record[0])\r
+                            EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_1, OtherMsg="The type of Library Class [%s] defined in Inf file does not match the type of the module" % (Record[1]), BelongsToTable='Inf', BelongsToItem=Record[0])\r
                 else:\r
                     if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_1, Record[1]):\r
-                        EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_1, OtherMsg = "The type of Library Class [%s] defined in Inf file does not match the type of the module" % (Record[1]), BelongsToTable = 'Inf', BelongsToItem = Record[0])\r
+                        EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_1, OtherMsg="The type of Library Class [%s] defined in Inf file does not match the type of the module" % (Record[1]), BelongsToTable='Inf', BelongsToItem=Record[0])\r
 \r
     # Check whether a Library Instance has been defined for all dependent library classes\r
     def MetaDataFileCheckLibraryInstanceDependent(self):\r
@@ -483,11 +649,17 @@ class Check(object):
             SqlCommand = """select ID, Value1, Value2 from Dsc where Model = %s""" % MODEL_EFI_LIBRARY_CLASS\r
             LibraryClasses = EccGlobalData.gDb.TblDsc.Exec(SqlCommand)\r
             for LibraryClass in LibraryClasses:\r
-                if LibraryClass[1].upper() != 'NULL':\r
-                    LibraryIns = os.path.normpath(os.path.join(EccGlobalData.gWorkspace, LibraryClass[2]))\r
-                    SqlCommand = """select Value2 from Inf where BelongsToFile =\r
+                if LibraryClass[1].upper() == 'NULL' or LibraryClass[1].startswith('!ifdef') or LibraryClass[1].startswith('!ifndef') or LibraryClass[1].endswith('!endif'):\r
+                    continue\r
+                else:\r
+                    LibraryIns = os.path.normpath(mws.join(EccGlobalData.gWorkspace, LibraryClass[2]))\r
+                    SkipDirString = '|'.join(EccGlobalData.gConfig.SkipDirList)\r
+                    p = re.compile(r'.*[\\/](?:%s^\S)[\\/]?.*' % SkipDirString)\r
+                    if p.match(os.path.split(LibraryIns)[0].upper()):\r
+                        continue\r
+                    SqlCommand = """select Value3 from Inf where BelongsToFile =\r
                                     (select ID from File where lower(FullPath) = lower('%s'))\r
-                                    and Value1 = '%s'""" % (LibraryIns, 'LIBRARY_CLASS')\r
+                                    and Value2 = '%s'""" % (LibraryIns, 'LIBRARY_CLASS')\r
                     RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)\r
                     IsFound = False\r
                     for Record in RecordSet:\r
@@ -496,7 +668,7 @@ class Check(object):
                             IsFound = True\r
                     if not IsFound:\r
                         if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_DEPENDENT, LibraryClass[1]):\r
-                            EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_DEPENDENT, OtherMsg = "The Library Class [%s] is not specified in '%s'" % (LibraryClass[1], LibraryClass[2]), BelongsToTable = 'Dsc', BelongsToItem = LibraryClass[0])\r
+                            EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_LIBRARY_INSTANCE_DEPENDENT, OtherMsg="The Library Class [%s] is not specified in '%s'" % (LibraryClass[1], LibraryClass[2]), BelongsToTable='Dsc', BelongsToItem=LibraryClass[0])\r
 \r
     # Check whether the Library Instances specified by the LibraryClasses sections are listed in order of dependencies\r
     def MetaDataFileCheckLibraryInstanceOrder(self):\r
@@ -505,6 +677,7 @@ class Check(object):
             pass\r
 \r
     # Check whether the unnecessary inclusion of library classes in the Inf file\r
+    # Check whether the unnecessary duplication of library classe names in the DSC file\r
     def MetaDataFileCheckLibraryNoUse(self):\r
         if EccGlobalData.gConfig.MetaDataFileCheckLibraryNoUse == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking for library instance not used ...")\r
@@ -512,8 +685,38 @@ class Check(object):
             RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)\r
             for Record in RecordSet:\r
                 if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_LIBRARY_NO_USE, Record[1]):\r
-                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_LIBRARY_NO_USE, OtherMsg = "The Library Class [%s] is not used in any platform" % (Record[1]), BelongsToTable = 'Inf', BelongsToItem = Record[0])\r
-\r
+                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_LIBRARY_NO_USE, OtherMsg="The Library Class [%s] is not used in any platform" % (Record[1]), BelongsToTable='Inf', BelongsToItem=Record[0])\r
+            SqlCommand = """\r
+                         select A.ID, A.Value1, A.BelongsToFile, A.StartLine, B.StartLine from Dsc as A left join Dsc as B\r
+                         where A.Model = %s and B.Model = %s and A.Scope1 = B.Scope1 and A.Scope2 = B.Scope2 and A.ID <> B.ID\r
+                         and A.Value1 = B.Value1 and A.Value2 <> B.Value2 and A.BelongsToItem = -1 and B.BelongsToItem = -1 and A.StartLine <> B.StartLine and B.BelongsToFile = A.BelongsToFile""" \\r
+                            % (MODEL_EFI_LIBRARY_CLASS, MODEL_EFI_LIBRARY_CLASS)\r
+            RecordSet = EccGlobalData.gDb.TblDsc.Exec(SqlCommand)\r
+            for Record in RecordSet:\r
+                if Record[3] and Record[4] and Record[3] != Record[4] and Record[1] != 'NULL':\r
+                    SqlCommand = """select FullPath from File where ID = %s""" % (Record[2])\r
+                    FilePathList = EccGlobalData.gDb.TblFile.Exec(SqlCommand)\r
+                    for FilePath in FilePathList:\r
+                        if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_LIBRARY_NAME_DUPLICATE, Record[1]):\r
+                            EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_LIBRARY_NAME_DUPLICATE, OtherMsg="The Library Class [%s] is duplicated in '%s' line %s and line %s." % (Record[1], FilePath, Record[3], Record[4]), BelongsToTable='Dsc', BelongsToItem=Record[0])\r
+    \r
+    # Check the header file in Include\Library directory whether be defined in the package DEC file.\r
+    def MetaDataFileCheckLibraryDefinedInDec(self):\r
+        if EccGlobalData.gConfig.MetaDataFileCheckLibraryDefinedInDec == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
+            EdkLogger.quiet("Checking for library instance whether be defined in the package dec file ...")\r
+            SqlCommand = """\r
+                    select A.Value1, A.StartLine, A.ID, B.Value1 from Inf as A left join Dec as B\r
+                    on A.Model = B.Model and A.Value1 = B.Value1 where A.Model=%s\r
+                    """ % MODEL_EFI_LIBRARY_CLASS\r
+            RecordSet = EccGlobalData.gDb.TblDsc.Exec(SqlCommand)\r
+            for Record in RecordSet:\r
+                LibraryInInf, Line, ID, LibraryDec = Record\r
+                if not LibraryDec:\r
+                    if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_LIBRARY_NOT_DEFINED, LibraryInInf):\r
+                        EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_LIBRARY_NOT_DEFINED, \\r
+                                            OtherMsg="The Library Class [%s] in %s line is not defined in the associated package file." % (LibraryInInf, Line), \r
+                                            BelongsToTable='Inf', BelongsToItem=ID)\r
+    \r
     # Check whether an Inf file is specified in the FDF file, but not in the Dsc file, then the Inf file must be for a Binary module only\r
     def MetaDataFileCheckBinaryInfInFdf(self):\r
         if EccGlobalData.gConfig.MetaDataFileCheckBinaryInfInFdf == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
@@ -529,95 +732,98 @@ class Check(object):
             for Record in RecordSet:\r
                 FdfID = Record[0]\r
                 FilePath = Record[1]\r
-                FilePath = os.path.normpath(os.path.join(EccGlobalData.gWorkspace, FilePath))\r
+                FilePath = os.path.normpath(mws.join(EccGlobalData.gWorkspace, FilePath))\r
                 SqlCommand = """select ID from Inf where Model = %s and BelongsToFile = (select ID from File where FullPath like '%s')\r
                                 """ % (MODEL_EFI_SOURCE_FILE, FilePath)\r
                 NewRecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)\r
-                if NewRecordSet!= []:\r
+                if NewRecordSet != []:\r
                     if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_BINARY_INF_IN_FDF, FilePath):\r
-                        EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_BINARY_INF_IN_FDF, OtherMsg = "File [%s] defined in FDF file and not in DSC file must be a binary module" % (FilePath), BelongsToTable = 'Fdf', BelongsToItem = FdfID)\r
+                        EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_BINARY_INF_IN_FDF, OtherMsg="File [%s] defined in FDF file and not in DSC file must be a binary module" % (FilePath), BelongsToTable='Fdf', BelongsToItem=FdfID)\r
 \r
     # Check whether a PCD is set in a Dsc file or the FDF file, but not in both.\r
     def MetaDataFileCheckPcdDuplicate(self):\r
         if EccGlobalData.gConfig.MetaDataFileCheckPcdDuplicate == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking for duplicate PCDs defined in both DSC and FDF files ...")\r
             SqlCommand = """\r
-                         select A.ID, A.Value2, A.BelongsToFile, B.ID, B.Value2, B.BelongsToFile from Dsc as A, Fdf as B\r
+                         select A.ID, A.Value1, A.Value2, A.BelongsToFile, B.ID, B.Value1, B.Value2, B.BelongsToFile from Dsc as A, Fdf as B\r
                          where A.Model >= %s and A.Model < %s\r
                          and B.Model >= %s and B.Model < %s\r
+                         and A.Value1 = B.Value1\r
                          and A.Value2 = B.Value2\r
                          and A.Enabled > -1\r
                          and B.Enabled > -1\r
                          group by A.ID\r
-                         """% (MODEL_PCD, MODEL_META_DATA_HEADER, MODEL_PCD, MODEL_META_DATA_HEADER)\r
+                         """ % (MODEL_PCD, MODEL_META_DATA_HEADER, MODEL_PCD, MODEL_META_DATA_HEADER)\r
             RecordSet = EccGlobalData.gDb.TblDsc.Exec(SqlCommand)\r
             for Record in RecordSet:\r
-                SqlCommand1 = """select Name from File where ID = %s""" %Record[2]\r
-                SqlCommand2 = """select Name from File where ID = %s""" %Record[5]\r
+                SqlCommand1 = """select Name from File where ID = %s""" % Record[3]\r
+                SqlCommand2 = """select Name from File where ID = %s""" % Record[7]\r
                 DscFileName = os.path.splitext(EccGlobalData.gDb.TblDsc.Exec(SqlCommand1)[0][0])[0]\r
                 FdfFileName = os.path.splitext(EccGlobalData.gDb.TblDsc.Exec(SqlCommand2)[0][0])[0]\r
-                print DscFileName, 111, FdfFileName\r
                 if DscFileName != FdfFileName:\r
                     continue\r
-                if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, Record[1]):\r
-                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, OtherMsg = "The PCD [%s] is defined in both FDF file and DSC file" % (Record[1]), BelongsToTable = 'Dsc', BelongsToItem = Record[0])\r
-                if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, Record[3]):\r
-                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, OtherMsg = "The PCD [%s] is defined in both FDF file and DSC file" % (Record[4]), BelongsToTable = 'Fdf', BelongsToItem = Record[3])\r
+                if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, Record[1] + '.' + Record[2]):\r
+                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, OtherMsg="The PCD [%s] is defined in both FDF file and DSC file" % (Record[1] + '.' + Record[2]), BelongsToTable='Dsc', BelongsToItem=Record[0])\r
+                if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, Record[5] + '.' + Record[6]):\r
+                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, OtherMsg="The PCD [%s] is defined in both FDF file and DSC file" % (Record[5] + '.' + Record[6]), BelongsToTable='Fdf', BelongsToItem=Record[4])\r
 \r
             EdkLogger.quiet("Checking for duplicate PCDs defined in DEC files ...")\r
             SqlCommand = """\r
-                         select A.ID, A.Value2 from Dec as A, Dec as B\r
+                         select A.ID, A.Value1, A.Value2, A.Model, B.Model from Dec as A left join Dec as B\r
                          where A.Model >= %s and A.Model < %s\r
                          and B.Model >= %s and B.Model < %s\r
+                         and A.Value1 = B.Value1\r
                          and A.Value2 = B.Value2\r
-                         and ((A.Arch = B.Arch) and (A.Arch != 'COMMON' or B.Arch != 'COMMON'))\r
-                         and A.ID != B.ID\r
+                         and A.Scope1 = B.Scope1\r
+                         and A.ID <> B.ID\r
+                         and A.Model = B.Model\r
                          and A.Enabled > -1\r
                          and B.Enabled > -1\r
                          and A.BelongsToFile = B.BelongsToFile\r
                          group by A.ID\r
-                         """% (MODEL_PCD, MODEL_META_DATA_HEADER, MODEL_PCD, MODEL_META_DATA_HEADER)\r
-            RecordSet = EccGlobalData.gDb.TblDsc.Exec(SqlCommand)\r
+                         """ % (MODEL_PCD, MODEL_META_DATA_HEADER, MODEL_PCD, MODEL_META_DATA_HEADER)\r
+            RecordSet = EccGlobalData.gDb.TblDec.Exec(SqlCommand)\r
             for Record in RecordSet:\r
-                if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, Record[1]):\r
-                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, OtherMsg = "The PCD [%s] is defined duplicated in DEC file" % (Record[1]), BelongsToTable = 'Dec', BelongsToItem = Record[0])\r
+                RecordCat = Record[1] + '.' + Record[2]\r
+                if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, RecordCat):\r
+                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_DUPLICATE, OtherMsg="The PCD [%s] is defined duplicated in DEC file" % RecordCat, BelongsToTable='Dec', BelongsToItem=Record[0])\r
 \r
     # Check whether PCD settings in the FDF file can only be related to flash.\r
     def MetaDataFileCheckPcdFlash(self):\r
         if EccGlobalData.gConfig.MetaDataFileCheckPcdFlash == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking only Flash related PCDs are used in FDF ...")\r
             SqlCommand = """\r
-                         select ID, Value2, BelongsToFile from Fdf as A\r
+                         select ID, Value1, Value2, BelongsToFile from Fdf as A\r
                          where A.Model >= %s and Model < %s\r
                          and A.Enabled > -1\r
                          and A.Value2 not like '%%Flash%%'\r
-                         """% (MODEL_PCD, MODEL_META_DATA_HEADER)\r
+                         """ % (MODEL_PCD, MODEL_META_DATA_HEADER)\r
             RecordSet = EccGlobalData.gDb.TblFdf.Exec(SqlCommand)\r
             for Record in RecordSet:\r
-                if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_FLASH, Record[1]):\r
-                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_FLASH, OtherMsg = "The PCD [%s] defined in FDF file is not related to Flash" % (Record[1]), BelongsToTable = 'Fdf', BelongsToItem = Record[0])\r
+                if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_FLASH, Record[1] + '.' + Record[2]):\r
+                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_FLASH, OtherMsg="The PCD [%s] defined in FDF file is not related to Flash" % (Record[1] + '.' + Record[2]), BelongsToTable='Fdf', BelongsToItem=Record[0])\r
 \r
     # Check whether PCDs used in Inf files but not specified in Dsc or FDF files\r
     def MetaDataFileCheckPcdNoUse(self):\r
         if EccGlobalData.gConfig.MetaDataFileCheckPcdNoUse == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking for non-specified PCDs ...")\r
             SqlCommand = """\r
-                         select ID, Value2, BelongsToFile from Inf as A\r
+                         select ID, Value1, Value2, BelongsToFile from Inf as A\r
                          where A.Model >= %s and Model < %s\r
                          and A.Enabled > -1\r
-                         and A.Value2 not in\r
-                             (select Value2 from Dsc as B\r
+                         and (A.Value1, A.Value2) not in\r
+                             (select Value1, Value2 from Dsc as B\r
                               where B.Model >= %s and B.Model < %s\r
                               and B.Enabled > -1)\r
-                         and A.Value2 not in\r
-                             (select Value2 from Fdf as C\r
+                         and (A.Value1, A.Value2) not in\r
+                             (select Value1, Value2 from Fdf as C\r
                               where C.Model >= %s and C.Model < %s\r
                               and C.Enabled > -1)\r
-                         """% (MODEL_PCD, MODEL_META_DATA_HEADER, MODEL_PCD, MODEL_META_DATA_HEADER, MODEL_PCD, MODEL_META_DATA_HEADER)\r
+                         """ % (MODEL_PCD, MODEL_META_DATA_HEADER, MODEL_PCD, MODEL_META_DATA_HEADER, MODEL_PCD, MODEL_META_DATA_HEADER)\r
             RecordSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)\r
             for Record in RecordSet:\r
-                if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_NO_USE, Record[1]):\r
-                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_NO_USE, OtherMsg = "The PCD [%s] defined in INF file is not specified in either DSC or FDF files" % (Record[1]), BelongsToTable = 'Inf', BelongsToItem = Record[0])\r
+                if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_NO_USE, Record[1] + '.' + Record[2]):\r
+                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_NO_USE, OtherMsg="The PCD [%s] defined in INF file is not specified in either DSC or FDF files" % (Record[1] + '.' + Record[2]), BelongsToTable='Inf', BelongsToItem=Record[0])\r
 \r
     # Check whether having duplicate guids defined for Guid/Protocol/Ppi\r
     def MetaDataFileCheckGuidDuplicate(self):\r
@@ -641,7 +847,7 @@ class Check(object):
         if EccGlobalData.gConfig.MetaDataFileCheckModuleFileNoUse == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking for no used module files ...")\r
             SqlCommand = """\r
-                         select upper(Path) from File where ID in (select BelongsToFile from INF where BelongsToFile != -1)\r
+                         select upper(Path) from File where ID in (select BelongsToFile from Inf where BelongsToFile != -1)\r
                          """\r
             InfPathSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)\r
             InfPathList = []\r
@@ -661,27 +867,27 @@ class Check(object):
                 Path = Path.upper().replace('\X64', '').replace('\IA32', '').replace('\EBC', '').replace('\IPF', '').replace('\ARM', '')\r
                 if Path in InfPathList:\r
                     if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_MODULE_FILE_NO_USE, Record[2]):\r
-                        EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_MODULE_FILE_NO_USE, OtherMsg = "The source file [%s] is existing in module directory but it is not described in INF file." % (Record[2]), BelongsToTable = 'File', BelongsToItem = Record[0])\r
+                        EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_MODULE_FILE_NO_USE, OtherMsg="The source file [%s] is existing in module directory but it is not described in INF file." % (Record[2]), BelongsToTable='File', BelongsToItem=Record[0])\r
 \r
     # Check whether the PCD is correctly used in C function via its type\r
     def MetaDataFileCheckPcdType(self):\r
         if EccGlobalData.gConfig.MetaDataFileCheckPcdType == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking for pcd type in c code function usage ...")\r
             SqlCommand = """\r
-                         select ID, Model, Value1, BelongsToFile from INF where Model > %s and Model < %s\r
+                         select ID, Model, Value1, Value2, BelongsToFile from INF where Model > %s and Model < %s\r
                          """ % (MODEL_PCD, MODEL_META_DATA_HEADER)\r
             PcdSet = EccGlobalData.gDb.TblInf.Exec(SqlCommand)\r
             for Pcd in PcdSet:\r
                 Model = Pcd[1]\r
                 PcdName = Pcd[2]\r
-                if len(Pcd[2].split(".")) > 1:\r
-                    PcdName = Pcd[2].split(".")[1]\r
-                BelongsToFile = Pcd[3]\r
+                if Pcd[3]:\r
+                    PcdName = Pcd[3]\r
+                BelongsToFile = Pcd[4]\r
                 SqlCommand = """\r
                              select ID from File where FullPath in\r
                             (select B.Path || '\\' || A.Value1 from INF as A, File as B where A.Model = %s and A.BelongsToFile = %s\r
-                             and B.ID = %s)\r
-                             """ %(MODEL_EFI_SOURCE_FILE, BelongsToFile, BelongsToFile)\r
+                             and B.ID = %s and (B.Model = %s or B.Model = %s))\r
+                             """ % (MODEL_EFI_SOURCE_FILE, BelongsToFile, BelongsToFile, MODEL_FILE_C, MODEL_FILE_H)\r
                 TableSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)\r
                 for Tbl in TableSet:\r
                     TblName = 'Identifier' + str(Tbl[0])\r
@@ -694,11 +900,11 @@ class Check(object):
                         FunName = Record[0]\r
                         if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_PCD_TYPE, FunName):\r
                             if Model in [MODEL_PCD_FIXED_AT_BUILD] and not FunName.startswith('FixedPcdGet'):\r
-                                EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_TYPE, OtherMsg = "The pcd '%s' is defined as a FixPcd but now it is called by c function [%s]" % (PcdName, FunName), BelongsToTable = TblName, BelongsToItem = Record[1])\r
+                                EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_TYPE, OtherMsg="The pcd '%s' is defined as a FixPcd but now it is called by c function [%s]" % (PcdName, FunName), BelongsToTable=TblName, BelongsToItem=Record[1])\r
                             if Model in [MODEL_PCD_FEATURE_FLAG] and (not FunName.startswith('FeaturePcdGet') and not FunName.startswith('FeaturePcdSet')):\r
-                                EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_TYPE, OtherMsg = "The pcd '%s' is defined as a FeaturePcd but now it is called by c function [%s]" % (PcdName, FunName), BelongsToTable = TblName, BelongsToItem = Record[1])\r
+                                EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_TYPE, OtherMsg="The pcd '%s' is defined as a FeaturePcd but now it is called by c function [%s]" % (PcdName, FunName), BelongsToTable=TblName, BelongsToItem=Record[1])\r
                             if Model in [MODEL_PCD_PATCHABLE_IN_MODULE] and (not FunName.startswith('PatchablePcdGet') and not FunName.startswith('PatchablePcdSet')):\r
-                                EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_TYPE, OtherMsg = "The pcd '%s' is defined as a PatchablePcd but now it is called by c function [%s]" % (PcdName, FunName), BelongsToTable = TblName, BelongsToItem = Record[1])\r
+                                EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_PCD_TYPE, OtherMsg="The pcd '%s' is defined as a PatchablePcd but now it is called by c function [%s]" % (PcdName, FunName), BelongsToTable=TblName, BelongsToItem=Record[1])\r
 \r
             #ERROR_META_DATA_FILE_CHECK_PCD_TYPE\r
         pass\r
@@ -710,20 +916,18 @@ class Check(object):
         RecordSet = Table.Exec(SqlCommand)\r
         Path = ""\r
         for Record in RecordSet:\r
-            Path = Record[0].replace(EccGlobalData.gWorkspace, '')\r
-            if Path.startswith('\\') or Path.startswith('/'):\r
-                Path = Path[1:]\r
+            Path = mws.relpath(Record[0], EccGlobalData.gWorkspace)\r
         return Path\r
-    \r
+\r
     # Check whether two module INFs under one workspace has the same FILE_GUID value\r
     def MetaDataFileCheckModuleFileGuidDuplication(self):\r
         if EccGlobalData.gConfig.MetaDataFileCheckModuleFileGuidDuplication == '1' or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking for pcd type in c code function usage ...")\r
             Table = EccGlobalData.gDb.TblInf\r
             SqlCommand = """\r
-                         select A.ID, A.Value2, A.BelongsToFile, B.BelongsToFile from %s as A, %s as B\r
-                         where A.Value1 = 'FILE_GUID' and B.Value1 = 'FILE_GUID' and\r
-                         A.Value2 = B.Value2 and A.ID <> B.ID group by A.ID\r
+                         select A.ID, A.Value3, A.BelongsToFile, B.BelongsToFile from %s as A, %s as B\r
+                         where A.Value2 = 'FILE_GUID' and B.Value2 = 'FILE_GUID' and\r
+                         A.Value3 = B.Value3 and A.ID <> B.ID group by A.ID\r
                          """ % (Table.Table, Table.Table)\r
             RecordSet = Table.Exec(SqlCommand)\r
             for Record in RecordSet:\r
@@ -732,8 +936,144 @@ class Check(object):
                 if InfPath1 and InfPath2:\r
                     if not EccGlobalData.gException.IsException(ERROR_META_DATA_FILE_CHECK_MODULE_FILE_GUID_DUPLICATION, InfPath1):\r
                         Msg = "The FILE_GUID of INF file [%s] is duplicated with that of %s" % (InfPath1, InfPath2)\r
-                        EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_MODULE_FILE_GUID_DUPLICATION, OtherMsg = Msg, BelongsToTable = Table.Table, BelongsToItem = Record[0])\r
-        \r
+                        EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_MODULE_FILE_GUID_DUPLICATION, OtherMsg=Msg, BelongsToTable=Table.Table, BelongsToItem=Record[0])\r
+\r
+\r
+    # Check Guid Format in module INF\r
+    def MetaDataFileCheckModuleFileGuidFormat(self):\r
+        if EccGlobalData.gConfig.MetaDataFileCheckModuleFileGuidFormat or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
+            EdkLogger.quiet("Check Guid Format in module INF ...")\r
+            Table = EccGlobalData.gDb.TblInf\r
+            SqlCommand = """\r
+                         select ID, Value1, Usage, BelongsToFile from %s where Model = %s group by ID\r
+                         """ % (Table.Table, MODEL_EFI_GUID)\r
+            RecordSet = Table.Exec(SqlCommand)\r
+            for Record in RecordSet:\r
+                Value1 = Record[1]\r
+                Value2 = Record[2]\r
+                GuidCommentList = []\r
+                InfPath = self.GetInfFilePathFromID(Record[3])\r
+                Msg = "The GUID format of %s in INF file [%s] does not follow rules" % (Value1, InfPath)\r
+                if Value2.startswith(DT.TAB_SPECIAL_COMMENT):\r
+                    GuidCommentList = Value2[2:].split(DT.TAB_SPECIAL_COMMENT)\r
+                    if GuidCommentList[0].strip().startswith(DT.TAB_INF_USAGE_UNDEFINED):\r
+                        continue\r
+                    elif len(GuidCommentList) > 1:\r
+                        if not GuidCommentList[0].strip().startswith((DT.TAB_INF_USAGE_PRO,\r
+                                                                      DT.TAB_INF_USAGE_SOME_PRO,\r
+                                                                      DT.TAB_INF_USAGE_CON,\r
+                                                                      DT.TAB_INF_USAGE_SOME_CON)):\r
+                            EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_FORMAT_GUID, OtherMsg=Msg, BelongsToTable=Table.Table, BelongsToItem=Record[0])\r
+                        if not (GuidCommentList[1].strip()).startswith(DT.TAB_INF_GUIDTYPE_VAR) and \\r
+                            not GuidCommentList[1].strip().startswith((DT.TAB_INF_GUIDTYPE_EVENT,\r
+                                                                       DT.TAB_INF_GUIDTYPE_HII,\r
+                                                                       DT.TAB_INF_GUIDTYPE_FILE,\r
+                                                                       DT.TAB_INF_GUIDTYPE_HOB,\r
+                                                                       DT.TAB_INF_GUIDTYPE_FV,\r
+                                                                       DT.TAB_INF_GUIDTYPE_ST,\r
+                                                                       DT.TAB_INF_GUIDTYPE_TSG,\r
+                                                                       DT.TAB_INF_GUIDTYPE_GUID,\r
+                                                                       DT.TAB_INF_GUIDTYPE_PROTOCOL,\r
+                                                                       DT.TAB_INF_GUIDTYPE_PPI,\r
+                                                                       DT.TAB_INF_USAGE_UNDEFINED)):\r
+                                EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_FORMAT_GUID, OtherMsg=Msg, BelongsToTable=Table.Table, BelongsToItem=Record[0])\r
+                    else:\r
+                        EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_FORMAT_GUID, OtherMsg=Msg, BelongsToTable=Table.Table, BelongsToItem=Record[0])\r
+                else:\r
+                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_FORMAT_GUID, OtherMsg=Msg, BelongsToTable=Table.Table, BelongsToItem=Record[0])\r
+\r
+    # Check Protocol Format in module INF\r
+    def MetaDataFileCheckModuleFileProtocolFormat(self):\r
+        if EccGlobalData.gConfig.MetaDataFileCheckModuleFileProtocolFormat or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
+            EdkLogger.quiet("Check Protocol Format in module INF ...")\r
+            Table = EccGlobalData.gDb.TblInf\r
+            SqlCommand = """\r
+                         select ID, Value1, Usage, BelongsToFile from %s where Model = %s group by ID\r
+                         """ % (Table.Table, MODEL_EFI_PROTOCOL)\r
+            RecordSet = Table.Exec(SqlCommand)\r
+            for Record in RecordSet:\r
+                Value1 = Record[1]\r
+                Value2 = Record[2]\r
+                GuidCommentList = []\r
+                InfPath = self.GetInfFilePathFromID(Record[3])\r
+                Msg = "The Protocol format of %s in INF file [%s] does not follow rules" % (Value1, InfPath)\r
+                if Value2.startswith(DT.TAB_SPECIAL_COMMENT):\r
+                    GuidCommentList = Value2[2:].split(DT.TAB_SPECIAL_COMMENT)\r
+                    if len(GuidCommentList) >= 1:\r
+                        if not GuidCommentList[0].strip().startswith((DT.TAB_INF_USAGE_PRO,\r
+                                                                      DT.TAB_INF_USAGE_SOME_PRO,\r
+                                                                      DT.TAB_INF_USAGE_CON,\r
+                                                                      DT.TAB_INF_USAGE_SOME_CON,\r
+                                                                      DT.TAB_INF_USAGE_NOTIFY,\r
+                                                                      DT.TAB_INF_USAGE_TO_START,\r
+                                                                      DT.TAB_INF_USAGE_BY_START,\r
+                                                                      DT.TAB_INF_USAGE_UNDEFINED)):\r
+                            EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_FORMAT_PROTOCOL, OtherMsg=Msg, BelongsToTable=Table.Table, BelongsToItem=Record[0])\r
+                else:\r
+                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_FORMAT_PROTOCOL, OtherMsg=Msg, BelongsToTable=Table.Table, BelongsToItem=Record[0])\r
+\r
+\r
+    # Check Ppi Format in module INF\r
+    def MetaDataFileCheckModuleFilePpiFormat(self):\r
+        if EccGlobalData.gConfig.MetaDataFileCheckModuleFilePpiFormat or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
+            EdkLogger.quiet("Check Ppi Format in module INF ...")\r
+            Table = EccGlobalData.gDb.TblInf\r
+            SqlCommand = """\r
+                         select ID, Value1, Usage, BelongsToFile from %s where Model = %s group by ID\r
+                         """ % (Table.Table, MODEL_EFI_PPI)\r
+            RecordSet = Table.Exec(SqlCommand)\r
+            for Record in RecordSet:\r
+                Value1 = Record[1]\r
+                Value2 = Record[2]\r
+                GuidCommentList = []\r
+                InfPath = self.GetInfFilePathFromID(Record[3])\r
+                Msg = "The Ppi format of %s in INF file [%s] does not follow rules" % (Value1, InfPath)\r
+                if Value2.startswith(DT.TAB_SPECIAL_COMMENT):\r
+                    GuidCommentList = Value2[2:].split(DT.TAB_SPECIAL_COMMENT)\r
+                    if len(GuidCommentList) >= 1:\r
+                        if not GuidCommentList[0].strip().startswith((DT.TAB_INF_USAGE_PRO,\r
+                                                                      DT.TAB_INF_USAGE_SOME_PRO,\r
+                                                                      DT.TAB_INF_USAGE_CON,\r
+                                                                      DT.TAB_INF_USAGE_SOME_CON,\r
+                                                                      DT.TAB_INF_USAGE_NOTIFY,\r
+                                                                      DT.TAB_INF_USAGE_UNDEFINED)):\r
+                            EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_FORMAT_PPI, OtherMsg=Msg, BelongsToTable=Table.Table, BelongsToItem=Record[0])\r
+                else:\r
+                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_FORMAT_PPI, OtherMsg=Msg, BelongsToTable=Table.Table, BelongsToItem=Record[0])\r
+\r
+    # Check Pcd Format in module INF\r
+    def MetaDataFileCheckModuleFilePcdFormat(self):\r
+        if EccGlobalData.gConfig.MetaDataFileCheckModuleFilePcdFormat or EccGlobalData.gConfig.MetaDataFileCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
+            EdkLogger.quiet("Check Pcd Format in module INF ...")\r
+            Table = EccGlobalData.gDb.TblInf\r
+            SqlCommand = """\r
+                         select ID, Model, Value1, Value2, Usage, BelongsToFile from %s where Model >= %s and Model < %s group by ID\r
+                         """ % (Table.Table, MODEL_PCD, MODEL_META_DATA_HEADER)\r
+            RecordSet = Table.Exec(SqlCommand)\r
+            for Record in RecordSet:\r
+                Model = Record[1]\r
+                PcdName = Record[2] + '.' + Record[3]\r
+                Usage = Record[4]\r
+                PcdCommentList = []\r
+                InfPath = self.GetInfFilePathFromID(Record[5])\r
+                Msg = "The Pcd format of %s in INF file [%s] does not follow rules" % (PcdName, InfPath)\r
+                if Usage.startswith(DT.TAB_SPECIAL_COMMENT):\r
+                    PcdCommentList = Usage[2:].split(DT.TAB_SPECIAL_COMMENT)\r
+                    if len(PcdCommentList) >= 1:\r
+                        if Model in [MODEL_PCD_FIXED_AT_BUILD, MODEL_PCD_FEATURE_FLAG] \\r
+                            and not PcdCommentList[0].strip().startswith((DT.TAB_INF_USAGE_SOME_PRO,\r
+                                                                          DT.TAB_INF_USAGE_CON,\r
+                                                                          DT.TAB_INF_USAGE_UNDEFINED)):\r
+                            EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_FORMAT_PCD, OtherMsg=Msg, BelongsToTable=Table.Table, BelongsToItem=Record[0])\r
+                        if Model in [MODEL_PCD_PATCHABLE_IN_MODULE, MODEL_PCD_DYNAMIC, MODEL_PCD_DYNAMIC_EX] \\r
+                            and not PcdCommentList[0].strip().startswith((DT.TAB_INF_USAGE_PRO,\r
+                                                                          DT.TAB_INF_USAGE_SOME_PRO,\r
+                                                                          DT.TAB_INF_USAGE_CON,\r
+                                                                          DT.TAB_INF_USAGE_SOME_CON,\r
+                                                                          DT.TAB_INF_USAGE_UNDEFINED)):\r
+                            EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_FORMAT_PCD, OtherMsg=Msg, BelongsToTable=Table.Table, BelongsToItem=Record[0])\r
+                else:\r
+                    EccGlobalData.gDb.TblReport.Insert(ERROR_META_DATA_FILE_CHECK_FORMAT_PCD, OtherMsg=Msg, BelongsToTable=Table.Table, BelongsToItem=Record[0])\r
 \r
     # Check whether these is duplicate Guid/Ppi/Protocol name\r
     def CheckGuidProtocolPpi(self, ErrorID, Model, Table):\r
@@ -747,7 +1087,8 @@ class Check(object):
         SqlCommand = """\r
                      select A.ID, A.Value1 from %s as A, %s as B\r
                      where A.Model = %s and B.Model = %s\r
-                     and A.Value1 = B.Value1 and A.ID <> B.ID\r
+                     and A.Value1 like B.Value1 and A.ID <> B.ID\r
+                     and A.Scope1 = B.Scope1\r
                      and A.Enabled > -1\r
                      and B.Enabled > -1\r
                      group by A.ID\r
@@ -755,7 +1096,7 @@ class Check(object):
         RecordSet = Table.Exec(SqlCommand)\r
         for Record in RecordSet:\r
             if not EccGlobalData.gException.IsException(ErrorID, Record[1]):\r
-                EccGlobalData.gDb.TblReport.Insert(ErrorID, OtherMsg = "The %s name [%s] is defined more than one time" % (Name.upper(), Record[1]), BelongsToTable = Table.Table, BelongsToItem = Record[0])\r
+                EccGlobalData.gDb.TblReport.Insert(ErrorID, OtherMsg="The %s name [%s] is defined more than one time" % (Name.upper(), Record[1]), BelongsToTable=Table.Table, BelongsToItem=Record[0])\r
 \r
     # Check whether these is duplicate Guid/Ppi/Protocol value\r
     def CheckGuidProtocolPpiValue(self, ErrorID, Model):\r
@@ -768,15 +1109,16 @@ class Check(object):
         if Model == MODEL_EFI_PPI:\r
             Name = 'ppi'\r
         SqlCommand = """\r
-                     select A.ID, A.Value2 from %s as A, %s as B\r
+                     select A.ID, A.Value1, A.Value2 from %s as A, %s as B\r
                      where A.Model = %s and B.Model = %s\r
-                     and A.Value2 = B.Value2 and A.ID <> B.ID\r
+                     and A.Value2 like B.Value2 and A.ID <> B.ID\r
+                     and A.Scope1 = B.Scope1 and A.Value1 <> B.Value1\r
                      group by A.ID\r
                      """ % (Table.Table, Table.Table, Model, Model)\r
         RecordSet = Table.Exec(SqlCommand)\r
-        for Record in RecordSet:\r
-            if not EccGlobalData.gException.IsException(ErrorID, Record[1]):\r
-                EccGlobalData.gDb.TblReport.Insert(ErrorID, OtherMsg = "The %s value [%s] is used more than one time" % (Name.upper(), Record[1]), BelongsToTable = Table.Table, BelongsToItem = Record[0])\r
+        for Record in RecordSet:     \r
+            if not EccGlobalData.gException.IsException(ErrorID, Record[2]):\r
+                EccGlobalData.gDb.TblReport.Insert(ErrorID, OtherMsg="The %s value [%s] is used more than one time" % (Name.upper(), Record[2]), BelongsToTable=Table.Table, BelongsToItem=Record[0])\r
 \r
     # Naming Convention Check\r
     def NamingConventionCheck(self):\r
@@ -809,7 +1151,7 @@ class Check(object):
         if EccGlobalData.gConfig.NamingConventionCheckDefineStatement == '1' or EccGlobalData.gConfig.NamingConventionCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking naming covention of #define statement ...")\r
 \r
-            SqlCommand = """select ID, Value from %s where Model = %s""" %(FileTable, MODEL_IDENTIFIER_MACRO_DEFINE)\r
+            SqlCommand = """select ID, Value from %s where Model = %s""" % (FileTable, MODEL_IDENTIFIER_MACRO_DEFINE)\r
             RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)\r
             for Record in RecordSet:\r
                 Name = Record[1].strip().split()[1]\r
@@ -817,14 +1159,14 @@ class Check(object):
                     Name = Name[0:Name.find('(')]\r
                 if Name.upper() != Name:\r
                     if not EccGlobalData.gException.IsException(ERROR_NAMING_CONVENTION_CHECK_DEFINE_STATEMENT, Name):\r
-                        EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CONVENTION_CHECK_DEFINE_STATEMENT, OtherMsg = "The #define name [%s] does not follow the rules" % (Name), BelongsToTable = FileTable, BelongsToItem = Record[0])\r
+                        EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CONVENTION_CHECK_DEFINE_STATEMENT, OtherMsg="The #define name [%s] does not follow the rules" % (Name), BelongsToTable=FileTable, BelongsToItem=Record[0])\r
 \r
     # Check whether only capital letters are used for typedef declarations\r
     def NamingConventionCheckTypedefStatement(self, FileTable):\r
         if EccGlobalData.gConfig.NamingConventionCheckTypedefStatement == '1' or EccGlobalData.gConfig.NamingConventionCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking naming covention of #typedef statement ...")\r
 \r
-            SqlCommand = """select ID, Name from %s where Model = %s""" %(FileTable, MODEL_IDENTIFIER_TYPEDEF)\r
+            SqlCommand = """select ID, Name from %s where Model = %s""" % (FileTable, MODEL_IDENTIFIER_TYPEDEF)\r
             RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)\r
             for Record in RecordSet:\r
                 Name = Record[1].strip()\r
@@ -837,20 +1179,20 @@ class Check(object):
                     Name = Name.replace('*', '').strip()\r
                     if Name.upper() != Name:\r
                         if not EccGlobalData.gException.IsException(ERROR_NAMING_CONVENTION_CHECK_TYPEDEF_STATEMENT, Name):\r
-                            EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CONVENTION_CHECK_TYPEDEF_STATEMENT, OtherMsg = "The #typedef name [%s] does not follow the rules" % (Name), BelongsToTable = FileTable, BelongsToItem = Record[0])\r
+                            EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CONVENTION_CHECK_TYPEDEF_STATEMENT, OtherMsg="The #typedef name [%s] does not follow the rules" % (Name), BelongsToTable=FileTable, BelongsToItem=Record[0])\r
 \r
     # Check whether the #ifndef at the start of an include file uses both prefix and postfix underscore characters, '_'.\r
     def NamingConventionCheckIfndefStatement(self, FileTable):\r
         if EccGlobalData.gConfig.NamingConventionCheckTypedefStatement == '1' or EccGlobalData.gConfig.NamingConventionCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking naming covention of #ifndef statement ...")\r
 \r
-            SqlCommand = """select ID, Value from %s where Model = %s""" %(FileTable, MODEL_IDENTIFIER_MACRO_IFNDEF)\r
+            SqlCommand = """select ID, Value from %s where Model = %s""" % (FileTable, MODEL_IDENTIFIER_MACRO_IFNDEF)\r
             RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)\r
             for Record in RecordSet:\r
                 Name = Record[1].replace('#ifndef', '').strip()\r
                 if Name[0] != '_' or Name[-1] != '_':\r
                     if not EccGlobalData.gException.IsException(ERROR_NAMING_CONVENTION_CHECK_IFNDEF_STATEMENT, Name):\r
-                        EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CONVENTION_CHECK_IFNDEF_STATEMENT, OtherMsg = "The #ifndef name [%s] does not follow the rules" % (Name), BelongsToTable = FileTable, BelongsToItem = Record[0])\r
+                        EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CONVENTION_CHECK_IFNDEF_STATEMENT, OtherMsg="The #ifndef name [%s] does not follow the rules" % (Name), BelongsToTable=FileTable, BelongsToItem=Record[0])\r
 \r
     # Rule for path name, variable name and function name\r
     # 1. First character should be upper case\r
@@ -866,7 +1208,7 @@ class Check(object):
             for Record in RecordSet:\r
                 if not Pattern.match(Record[1]):\r
                     if not EccGlobalData.gException.IsException(ERROR_NAMING_CONVENTION_CHECK_PATH_NAME, Record[1]):\r
-                        EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CONVENTION_CHECK_PATH_NAME, OtherMsg = "The file path [%s] does not follow the rules" % (Record[1]), BelongsToTable = 'File', BelongsToItem = Record[0])\r
+                        EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CONVENTION_CHECK_PATH_NAME, OtherMsg="The file path [%s] does not follow the rules" % (Record[1]), BelongsToTable='File', BelongsToItem=Record[0])\r
 \r
     # Rule for path name, variable name and function name\r
     # 1. First character should be upper case\r
@@ -879,12 +1221,15 @@ class Check(object):
             EdkLogger.quiet("Checking naming covention of variable name ...")\r
             Pattern = re.compile(r'^[A-Zgm]+\S*[a-z]\S*$')\r
 \r
-            SqlCommand = """select ID, Name from %s where Model = %s""" %(FileTable, MODEL_IDENTIFIER_VARIABLE)\r
+            SqlCommand = """select ID, Name from %s where Model = %s""" % (FileTable, MODEL_IDENTIFIER_VARIABLE)\r
             RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)\r
             for Record in RecordSet:\r
-                if not Pattern.match(Record[1]):\r
+                Var = Record[1]\r
+                if Var.startswith('CONST'):\r
+                    Var = Var[5:].lstrip()\r
+                if not Pattern.match(Var):\r
                     if not EccGlobalData.gException.IsException(ERROR_NAMING_CONVENTION_CHECK_VARIABLE_NAME, Record[1]):\r
-                        EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CONVENTION_CHECK_VARIABLE_NAME, OtherMsg = "The variable name [%s] does not follow the rules" % (Record[1]), BelongsToTable = FileTable, BelongsToItem = Record[0])\r
+                        EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CONVENTION_CHECK_VARIABLE_NAME, OtherMsg="The variable name [%s] does not follow the rules" % (Record[1]), BelongsToTable=FileTable, BelongsToItem=Record[0])\r
 \r
     # Rule for path name, variable name and function name\r
     # 1. First character should be upper case\r
@@ -900,20 +1245,20 @@ class Check(object):
             for Record in RecordSet:\r
                 if not Pattern.match(Record[1]):\r
                     if not EccGlobalData.gException.IsException(ERROR_NAMING_CONVENTION_CHECK_FUNCTION_NAME, Record[1]):\r
-                        EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CONVENTION_CHECK_FUNCTION_NAME, OtherMsg = "The function name [%s] does not follow the rules" % (Record[1]), BelongsToTable = 'Function', BelongsToItem = Record[0])\r
+                        EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CONVENTION_CHECK_FUNCTION_NAME, OtherMsg="The function name [%s] does not follow the rules" % (Record[1]), BelongsToTable='Function', BelongsToItem=Record[0])\r
 \r
     # Check whether NO use short variable name with single character\r
     def NamingConventionCheckSingleCharacterVariable(self, FileTable):\r
         if EccGlobalData.gConfig.NamingConventionCheckSingleCharacterVariable == '1' or EccGlobalData.gConfig.NamingConventionCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':\r
             EdkLogger.quiet("Checking naming covention of single character variable name ...")\r
 \r
-            SqlCommand = """select ID, Name from %s where Model = %s""" %(FileTable, MODEL_IDENTIFIER_VARIABLE)\r
+            SqlCommand = """select ID, Name from %s where Model = %s""" % (FileTable, MODEL_IDENTIFIER_VARIABLE)\r
             RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)\r
             for Record in RecordSet:\r
                 Variable = Record[1].replace('*', '')\r
                 if len(Variable) == 1:\r
                     if not EccGlobalData.gException.IsException(ERROR_NAMING_CONVENTION_CHECK_SINGLE_CHARACTER_VARIABLE, Record[1]):\r
-                        EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CONVENTION_CHECK_SINGLE_CHARACTER_VARIABLE, OtherMsg = "The variable name [%s] does not follow the rules" % (Record[1]), BelongsToTable = FileTable, BelongsToItem = Record[0])\r
+                        EccGlobalData.gDb.TblReport.Insert(ERROR_NAMING_CONVENTION_CHECK_SINGLE_CHARACTER_VARIABLE, OtherMsg="The variable name [%s] does not follow the rules" % (Record[1]), BelongsToTable=FileTable, BelongsToItem=Record[0])\r
 \r
 ##\r
 #\r