]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools:Add the Judgment Method of "--exclude"
authorFan, ZhijuX <zhijux.fan@intel.com>
Fri, 28 Jun 2019 07:01:11 +0000 (15:01 +0800)
committerLiming Gao <liming.gao@intel.com>
Thu, 8 Aug 2019 13:45:35 +0000 (21:45 +0800)
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1944

--exclude cannot be used under certain circumstances
1.The value of the parameter USES an absolute path
2.The value of Exclude parameters is based on the value
  of the Path parameter
Neither of these approaches currently works

This patch is going to fix that issue.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
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