Commit 0f8001b5 by Geoff Lang

Improve the enumerate_files.py script.

Cleaned up the agument parsing and added support for excluding files/folders. BUG=angle:552 Change-Id: I0d59f83fe2e20b8bc23564ecfb1f98c08c70ca94 Reviewed-on: https://chromium-review.googlesource.com/187532Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 823c8cd5
...@@ -2,25 +2,52 @@ import fnmatch ...@@ -2,25 +2,52 @@ import fnmatch
import os import os
import sys import sys
rootdirs = [ ] dirs = [ ]
filetypes = [ ] types = [ ]
excludes = [ ]
foundTypesArg = False # Default to accepting a list of directories first
curArray = dirs
# Iterate over the arguments and add them to the arrays
for i in range(1, len(sys.argv)): for i in range(1, len(sys.argv)):
arg = sys.argv[i] arg = sys.argv[i]
if arg == "-dirs":
curArray = dirs
continue
if arg == "-types": if arg == "-types":
foundTypesArg = True curArray = types
continue continue
if foundTypesArg: if arg == "-excludes":
filetypes.append(arg) curArray = excludes
else: continue
rootdirs.append(arg)
for rootdir in rootdirs: curArray.append(arg)
# If no directories were specified, use the current directory
if len(dirs) == 0:
dirs.append(".")
# If no types were specified, accept all types
if len(types) == 0:
types.append("*")
# Walk the directories listed and compare with type and exclude lists
for rootdir in dirs:
for root, dirnames, filenames in os.walk(rootdir): for root, dirnames, filenames in os.walk(rootdir):
for file in filenames: for file in filenames:
for type in filetypes: fullPath = os.path.join(root, file).replace("\\", "/")
if fnmatch.fnmatchcase(file, type): for type in types:
print os.path.join(root, file).replace("\\", "/") if fnmatch.fnmatchcase(fullPath, type):
break excluded = False
for exclude in excludes:
if fnmatch.fnmatchcase(fullPath, exclude):
excluded = True
break
if not excluded:
print fullPath
break
...@@ -26,7 +26,12 @@ ...@@ -26,7 +26,12 @@
[ [
'ANGLE_TRANSLATOR_IMPLEMENTATION', 'ANGLE_TRANSLATOR_IMPLEMENTATION',
], ],
'sources': [ '<!@(python <(angle_build_scripts_path)/enumerate_files.py compiler/translator third_party/compiler common ../include -types *.cpp *.h *.y *.l )', ], 'sources':
[
'<!@(python <(angle_build_scripts_path)/enumerate_files.py \
-dirs compiler/translator third_party/compiler common ../include \
-types *.cpp *.h *.y *.l)',
],
'conditions': 'conditions':
[ [
['OS=="win"', ['OS=="win"',
......
...@@ -20,7 +20,12 @@ ...@@ -20,7 +20,12 @@
'libGLESv2', 'libGLESv2',
'<(SHARED_INTERMEDIATE_DIR)', '<(SHARED_INTERMEDIATE_DIR)',
], ],
'sources': [ '<!@(python <(angle_build_scripts_path)/enumerate_files.py common libEGL ../include -types *.cpp *.h *.def libEGL.rc)' ], 'sources':
[
'<!@(python <(angle_build_scripts_path)/enumerate_files.py \
-dirs common libEGL ../include \
-types *.cpp *.h *.def *.rc)',
],
'msvs_disabled_warnings': [ 4267 ], 'msvs_disabled_warnings': [ 4267 ],
'msvs_settings': 'msvs_settings':
{ {
......
...@@ -28,7 +28,12 @@ ...@@ -28,7 +28,12 @@
'libGLESv2', 'libGLESv2',
'<(SHARED_INTERMEDIATE_DIR)', '<(SHARED_INTERMEDIATE_DIR)',
], ],
'sources': [ '<!@(python <(angle_build_scripts_path)/enumerate_files.py common libGLESv2 third_party/murmurhash ../include -types *.cpp *.h *.hlsl *.vs *.ps *.bat *.def libGLESv2.rc)', ], 'sources':
[
'<!@(python <(angle_build_scripts_path)/enumerate_files.py \
-dirs common libGLESv2 third_party/murmurhash ../include \
-types *.cpp *.h *.hlsl *.vs *.ps *.bat *.def *.rc)',
],
'msvs_disabled_warnings': [ 4267 ], 'msvs_disabled_warnings': [ 4267 ],
'msvs_settings': 'msvs_settings':
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment