Commit a10370c4 authored by Daniel Bratell's avatar Daniel Bratell Committed by Commit Bot

Add --log-file arg to post_build_ninja_summary.py

Sometimes the log files are not named .ninja_log and then it's
good if you can give the script the actual name and path.

Change-Id: I59e9812c81a83ffac3ecdc8b29887e99bf71b60f
Reviewed-on: https://chromium-review.googlesource.com/1012112Reviewed-by: 's avatarDirk Pranke <dpranke@chromium.org>
Reviewed-by: 's avatarBruce Dawson <brucedawson@chromium.org>
Commit-Queue: Daniel Bratell <bratell@opera.com>
parent d21878d7
...@@ -56,6 +56,7 @@ will have a weighted time that is the same or similar to its elapsed time. A ...@@ -56,6 +56,7 @@ will have a weighted time that is the same or similar to its elapsed time. A
compile that runs in parallel with 999 other compiles will have a weighted time compile that runs in parallel with 999 other compiles will have a weighted time
that is tiny.""" that is tiny."""
import argparse
import errno import errno
import os import os
import sys import sys
...@@ -275,20 +276,27 @@ def SummarizeEntries(entries): ...@@ -275,20 +276,27 @@ def SummarizeEntries(entries):
len(entries), len(entries) / (length)) len(entries), len(entries) / (length))
def main(argv): def main():
log_file = '.ninja_log' log_file = '.ninja_log'
for pid, arg in enumerate(argv): parser = argparse.ArgumentParser()
if arg == '-C': parser.add_argument('-C', dest='build_directory',
log_file = os.path.join(argv[pid+1], log_file) help='Build directory.')
parser.add_argument('--log-file',
help="specific ninja log file to analyze.")
args, _extra_args = parser.parse_known_args()
if args.build_directory:
log_file = os.path.join(args.build_directory, log_file)
if args.log_file:
log_file = args.log_file
try: try:
with open(log_file, 'r') as log: with open(log_file, 'r') as log:
entries = ReadTargets(log, False) entries = ReadTargets(log, False)
SummarizeEntries(entries) SummarizeEntries(entries)
except IOError: except IOError:
print 'No log file found, no build summary created.' print 'Log file %r not found, no build summary created.' % log_file
return errno.ENOENT return errno.ENOENT
if __name__ == '__main__': if __name__ == '__main__':
sys.exit(main(sys.argv[1:])) sys.exit(main())
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