]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Scripts/FormatDosFiles.py
BaseTools:Add the Judgment Method of "--exclude"
[mirror_edk2.git] / BaseTools / Scripts / FormatDosFiles.py
index d9a880f299fbe27ac6065248bd68769e2f52bbdd..3150bef3c2015a706d3aadb40d265fe2873aaa64 100644 (file)
@@ -20,7 +20,7 @@ import copy
 \r
 __prog__        = 'FormatDosFiles'\r
 __version__     = '%s Version %s' % (__prog__, '0.10 ')\r
-__copyright__   = 'Copyright (c) 2018, Intel Corporation. All rights reserved.'\r
+__copyright__   = 'Copyright (c) 2018-2019, Intel Corporation. All rights reserved.'\r
 __description__ = 'Convert source files to meet the EDKII C Coding Standards Specification.\n'\r
 DEFAULT_EXT_LIST = ['.h', '.c', '.nasm', '.nasmb', '.asm', '.S', '.inf', '.dec', '.dsc', '.fdf', '.uni', '.asl', '.aslc', '.vfr', '.idf', '.txt', '.bat', '.py']\r
 \r
@@ -46,10 +46,26 @@ def FormatFile(FilePath, Args):
 def FormatFilesInDir(DirPath, ExtList, Args):\r
 \r
     FileList = []\r
+    ExcludeDir = DirPath\r
     for DirPath, DirNames, FileNames in os.walk(DirPath):\r
         if Args.Exclude:\r
             DirNames[:] = [d for d in DirNames if d not in Args.Exclude]\r
             FileNames[:] = [f for f in FileNames if f not in Args.Exclude]\r
+            Continue = False\r
+            for Path in Args.Exclude:\r
+                if not os.path.isdir(Path) and not os.path.isfile(Path):\r
+                    Path = os.path.join(ExcludeDir, Path)\r
+                if os.path.isdir(Path) and Path.endswith(DirPath):\r
+                    DirNames[:] = []\r
+                    Continue = True\r
+                elif os.path.isfile(Path):\r
+                    FilePaths = FileNames\r
+                    for ItemPath in FilePaths:\r
+                        FilePath = os.path.join(DirPath, ItemPath)\r
+                        if Path.endswith(FilePath):\r
+                            FileNames.remove(ItemPath)\r
+            if Continue:\r
+                continue\r
         for FileName in [f for f in FileNames if any(f.endswith(ext) for ext in ExtList)]:\r
                 FileList.append(os.path.join(DirPath, FileName))\r
     for File in FileList:\r