Merge "scripts: update gcc-wrapper to python3"

This commit is contained in:
qctecmdr 2021-03-04 04:46:39 -08:00 • committed by Gerrit - the friendly Code Review server
commit ac1ea4edfd

View file

@ -1,4 +1,4 @@
#! /usr/bin/env python2
#! /usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0-only
# Copyright (c) 2011-2017, 2018 The Linux Foundation. All rights reserved.
@ -32,10 +32,10 @@ ofile = None
warning_re = re.compile(r'''(.*/|)([^/]+\.[a-z]+:\d+):(\d+:)? warning:''')
def interpret_warning(line):
"""Decode the message from gcc. The messages we care about have a filename, and a warning"""
line = line.rstrip('\n')
line = line.rstrip().decode()
m = warning_re.match(line)
if m and m.group(2) not in allowed_warnings:
print "error, forbidden warning:", m.group(2)
print("error, forbidden warning:", m.group(2))
# If there is a warning, remove any object if it exists.
if ofile:
@ -60,17 +60,17 @@ def run_gcc():
try:
proc = subprocess.Popen(args, stderr=subprocess.PIPE)
for line in proc.stderr:
print line,
print(line, end=' ')
interpret_warning(line)
result = proc.wait()
except OSError as e:
result = e.errno
if result == errno.ENOENT:
print args[0] + ':',e.strerror
print 'Is your PATH set correctly?'
print(args[0] + ':',e.strerror)
print('Is your PATH set correctly?')
else:
print ' '.join(args), str(e)
print(' '.join(args), str(e))
return result