diff options
| author | idings <[email protected]> | 2024-01-25 15:20:14 +0800 |
|---|---|---|
| committer | Meco Man <[email protected]> | 2024-01-26 18:32:28 +0800 |
| commit | 0e409a6eb16287790cac9db38abe85b64ffd9f2e (patch) | |
| tree | 0bdc806704e63781e390da169b0c402e0539d462 /tools/gcc.py | |
| parent | 3d3761f3e2301d988e7b6e2c1804883a26a734ef (diff) | |
[libc][tools] fix compile error on python2 env
Diffstat (limited to 'tools/gcc.py')
| -rw-r--r-- | tools/gcc.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tools/gcc.py b/tools/gcc.py index 52aaaf1488..dfcb98c617 100644 --- a/tools/gcc.py +++ b/tools/gcc.py @@ -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: |
