in tools/xctoolrunner/xctoolrunner.py [0:0]
def actool_filtering(tool_exit_status, raw_stdout, raw_stderr):
"""Filter the stdout messages from "actool".
Args:
tool_exit_status: The exit status of "xcrun actool".
raw_stdout: This is the unmodified stdout captured from "xcrun actool".
raw_stderr: This is the unmodified stderr captured from "xcrun actool".
Returns:
A tuple of the filtered stdout and strerr.
"""
section_header = re.compile("^/\\* ([^ ]+) \\*/$")
excluded_sections = ["com.apple.actool.compilation-results"]
spurious_patterns = [
re.compile(x) for x in [
r"\[\]\[ipad\]\[76x76\]\[\]\[\]\[1x\]\[\]\[\]: notice: \(null\)",
r"\[\]\[ipad\]\[76x76\]\[\]\[\]\[1x\]\[\]\[\]: notice: 76x76@1x app "
r"icons only apply to iPad apps targeting releases of iOS prior to "
r"10\.0\.",
]
]
def is_spurious_message(line):
for pattern in spurious_patterns:
match = pattern.search(line)
if match is not None:
return True
return False
output = []
current_section = None
data_in_section = False
for line in raw_stdout.splitlines():
header_match = section_header.search(line)
if header_match:
data_in_section = False
current_section = header_match.group(1)
continue
if not current_section:
output.append(line + "\n")
elif current_section not in excluded_sections:
if is_spurious_message(line):
continue
if not data_in_section:
data_in_section = True
output.append("/* %s */\n" % current_section)
output.append(line + "\n")
# Some of the time, in a successful run, actool reports on stderr some
# internal assertions and ask "Please file a bug report with Apple", but
# it isn't clear that there is really a problem. Since everything else
# (warnings about assets, etc.) is reported on stdout, just drop stderr
# on successful runs.
if tool_exit_status == 0:
raw_stderr = None
return ("".join(output), raw_stderr)