Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e4fb495b authored by Chih-hung Hsieh's avatar Chih-hung Hsieh Committed by Gerrit Code Review
Browse files

Merge "Separate parallel_classify_warnings out of parse_input_file."

parents 07b4a598 76d0065e
Loading
Loading
Loading
Loading
+11 −5
Original line number Original line Diff line number Diff line
@@ -84,6 +84,8 @@ import argparse
import multiprocessing
import multiprocessing
import os
import os
import re
import re
import signal
import sys


parser = argparse.ArgumentParser(description='Convert a build log into HTML')
parser = argparse.ArgumentParser(description='Convert a build log into HTML')
parser.add_argument('--gencsv',
parser.add_argument('--gencsv',
@@ -2090,11 +2092,16 @@ def classify_warnings(lines):
  results = []
  results = []
  for line in lines:
  for line in lines:
    classify_one_warning(line, results)
    classify_one_warning(line, results)
  # After the main work, ignore all other signals to a child process,
  # to avoid bad warning/error messages from the exit clean-up process.
  if args.processes > 1:
    signal.signal(signal.SIGTERM, lambda *args: sys.exit(-signal.SIGTERM))
  return results
  return results




def parallel_classify_warnings(warning_lines):
def parallel_classify_warnings(warning_lines):
  """Classify all warning lines with num_cpu parallel processes."""
  """Classify all warning lines with num_cpu parallel processes."""
  compile_patterns()
  num_cpu = args.processes
  num_cpu = args.processes
  if num_cpu > 1:
  if num_cpu > 1:
    groups = [[] for x in range(num_cpu)]
    groups = [[] for x in range(num_cpu)]
@@ -2177,17 +2184,15 @@ def normalize_warning_line(line):
    return line
    return line




def parse_input_file():
def parse_input_file(infile):
  """Parse input file, match warning lines."""
  """Parse input file, match warning lines."""
  global platform_version
  global platform_version
  global target_product
  global target_product
  global target_variant
  global target_variant
  infile = open(args.buildlog, 'r')
  line_counter = 0
  line_counter = 0


  # handle only warning messages with a file path
  # handle only warning messages with a file path
  warning_pattern = re.compile('^[^ ]*/[^ ]*: warning: .*')
  warning_pattern = re.compile('^[^ ]*/[^ ]*: warning: .*')
  compile_patterns()


  # Collect all warnings into the warning_lines set.
  # Collect all warnings into the warning_lines set.
  warning_lines = set()
  warning_lines = set()
@@ -2207,7 +2212,7 @@ def parse_input_file():
      m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
      m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
      if m is not None:
      if m is not None:
        target_variant = m.group(0)
        target_variant = m.group(0)
  parallel_classify_warnings(warning_lines)
  return warning_lines




# Return s with escaped backslash and quotation characters.
# Return s with escaped backslash and quotation characters.
@@ -2503,7 +2508,8 @@ def dump_csv():




def main():
def main():
  parse_input_file()
  warning_lines = parse_input_file(open(args.buildlog, 'r'))
  parallel_classify_warnings(warning_lines)
  if args.gencsv:
  if args.gencsv:
    dump_csv()
    dump_csv()
  else:
  else: