]> 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 7932fb3394a9e1553f55854964d1caf47911ce93..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 - 2015, 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
@@ -19,6 +19,7 @@ from MetaDataParser import ParseHeaderCommentSection
 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
@@ -380,9 +381,7 @@ 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
 \r
@@ -653,7 +652,11 @@ class Check(object):
                 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(os.path.join(EccGlobalData.gWorkspace, LibraryClass[2]))\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 Value2 = '%s'""" % (LibraryIns, 'LIBRARY_CLASS')\r
@@ -729,7 +732,7 @@ 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
@@ -913,9 +916,7 @@ 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
     # Check whether two module INFs under one workspace has the same FILE_GUID value\r
@@ -1086,7 +1087,7 @@ 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
@@ -1110,7 +1111,7 @@ class Check(object):
         SqlCommand = """\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
@@ -1223,7 +1224,10 @@ class Check(object):
             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
 \r