Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: tools/clang/scripts/run_tool.py

Issue 2448133006: Tool added to extract network traffic annotations. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/clang/scripts/run_tool.py
diff --git a/tools/clang/scripts/run_tool.py b/tools/clang/scripts/run_tool.py
index 68f12e980390a0139fb78512b27d3cc4e8423bfe..cc88dafee7700ccf68562b4d93b9ec35803831de 100755
--- a/tools/clang/scripts/run_tool.py
+++ b/tools/clang/scripts/run_tool.py
@@ -114,7 +114,7 @@ def _ExtractEditsFromStdout(build_directory, stdout):
return edits
-def _ExecuteTool(toolname, build_directory, filename):
+def _ExecuteTool(toolname, tool_params, build_directory, filename):
"""Executes the tool.
This is defined outside the class so it can be pickled for the multiprocessing
@@ -136,7 +136,8 @@ def _ExecuteTool(toolname, build_directory, filename):
keys "filename" and "stderr" respectively.
"""
command = subprocess.Popen(
- (toolname, '-p', build_directory, filename),
+ (toolname, '-p', build_directory, filename) if tool_params is None else
+ (toolname, '-p', build_directory, filename, tool_params),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = command.communicate()
@@ -150,7 +151,7 @@ def _ExecuteTool(toolname, build_directory, filename):
class _CompilerDispatcher(object):
"""Multiprocessing controller for running clang tools in parallel."""
- def __init__(self, toolname, build_directory, filenames):
+ def __init__(self, toolname, tool_params, build_directory, filenames):
"""Initializer method.
Args:
@@ -159,6 +160,7 @@ class _CompilerDispatcher(object):
filenames: The files to run the tool over.
"""
self.__toolname = toolname
+ self.__tool_params = tool_params
self.__build_directory = build_directory
self.__filenames = filenames
self.__success_count = 0
@@ -178,8 +180,9 @@ class _CompilerDispatcher(object):
"""Does the grunt work."""
pool = multiprocessing.Pool()
result_iterator = pool.imap_unordered(
- functools.partial(_ExecuteTool, self.__toolname,
- self.__build_directory), self.__filenames)
+ functools.partial(_ExecuteTool, self.__toolname, self.__tool_params,
+ self.__build_directory),
+ self.__filenames)
for result in result_iterator:
self.__ProcessResult(result)
sys.stdout.write('\n')
@@ -299,6 +302,9 @@ def main():
'path_filter',
nargs='*',
help='optional paths to filter what files the tool is run on')
+ parser.add_argument(
+ '--tool-params', type=str,
+ help='parameters passed to the tool')
battre 2016/10/26 14:29:18 please fix indentation
Ramin Halavati 2016/10/27 09:40:08 Done.
args = parser.parse_args()
os.environ['PATH'] = '%s%s%s' % (
@@ -321,7 +327,8 @@ def main():
source_filenames = [f
for f in filenames
if os.path.splitext(f)[1] in extensions]
- dispatcher = _CompilerDispatcher(args.tool, args.compile_database,
+ dispatcher = _CompilerDispatcher(args.tool, args.tool_params,
+ args.compile_database,
source_filenames)
dispatcher.Run()
# Filter out edits to files that aren't in the git repository, since it's not
@@ -334,4 +341,4 @@ def main():
if __name__ == '__main__':
- sys.exit(main())
+ sys.exit(main())

Powered by Google App Engine
This is Rietveld 408576698