[libc][tools] fix compile error on python2 env

This commit is contained in:
idings 2024-01-25 15:20:14 +08:00 committed by Meco Man
parent 3d3761f3e2
commit 0e409a6eb1
1 changed files with 9 additions and 3 deletions

View File

@ -72,14 +72,20 @@ def GetGccDefaultSearchDirs(rtconfig):
gcc_cmd = os.path.join(rtconfig.EXEC_PATH, rtconfig.CC)
device_flags = rtconfig.DEVICE.split()
args = [gcc_cmd] + device_flags + ['-xc', '-E', '-v', os.devnull]
command = [gcc_cmd] + device_flags + ['-xc', '-E', '-v', os.devnull]
# if gcc_cmd can not access , return empty list
if not os.access(gcc_cmd, os.X_OK):
return []
proc = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
lines = proc.stdout.splitlines()
if(platform.system() == 'Windows'):
child = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
else:
child = subprocess.Popen(' '.join(command), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
stdout = child.communicate()
stdout_string = (b''.join(stdout)).decode()
lines = stdout_string.splitlines()
start_it = match_pattern(start_pattern, lines)
if start_it == None: