Skip to content

Commit 73153ac

Browse files
authored
[tools] fix the issue of cc detection failure in Windows (#8914)
1 parent 0871140 commit 73153ac

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

tools/building.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
195195
os.environ['RTT_CC_PREFIX'] = exec_prefix
196196

197197
# auto change the 'RTT_EXEC_PATH' when 'rtconfig.EXEC_PATH' get failed
198-
if not os.path.exists(os.path.join(rtconfig.EXEC_PATH, rtconfig.CC)):
198+
if not utils.CmdExists(os.path.join(rtconfig.EXEC_PATH, rtconfig.CC)):
199199
if 'RTT_EXEC_PATH' in os.environ:
200200
# del the 'RTT_EXEC_PATH' and using the 'EXEC_PATH' setting on rtconfig.py
201201
del os.environ['RTT_EXEC_PATH']

tools/utils.py

+20
Original file line numberDiff line numberDiff line change
@@ -309,3 +309,23 @@ def VerTuple(version_str):
309309
ver = tuple(int(part) for part in ver_parts)
310310

311311
return ver
312+
313+
def CmdExists(cmd):
314+
import platform
315+
316+
cmd_list = cmd.split(' ')
317+
cmd = cmd_list[0]
318+
if os.path.isfile(cmd):
319+
return True
320+
else:
321+
# check cmd(.exe|.bat|.ps1) under Windows
322+
if platform.system() == 'Windows':
323+
if cmd.find('exe') != -1 or cmd.find('bat') != -1 or cmd.find('ps1') != -1:
324+
return False
325+
326+
# add .exe then check whether the cmd exists
327+
cmd = cmd + '.exe'
328+
if os.path.isfile(cmd):
329+
return True
330+
331+
return False

0 commit comments

Comments
 (0)