diff options
| author | Bernard Xiong <[email protected]> | 2024-05-08 10:50:45 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-05-08 10:50:45 +0800 |
| commit | 73153ac06a07a574627b49c9a86ac2d57c298cd0 (patch) | |
| tree | f73f2b6a2b61ca5566ef9e1c2fbba0bfadd74f63 /tools/utils.py | |
| parent | 0871140759e272e16954aefd2f6f89b46ec71db2 (diff) | |
[tools] fix the issue of cc detection failure in Windows (#8914)
Diffstat (limited to 'tools/utils.py')
| -rw-r--r-- | tools/utils.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/utils.py b/tools/utils.py index d76720a850..761aa07b0c 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -309,3 +309,23 @@ def VerTuple(version_str): ver = tuple(int(part) for part in ver_parts) return ver + +def CmdExists(cmd): + import platform + + cmd_list = cmd.split(' ') + cmd = cmd_list[0] + if os.path.isfile(cmd): + return True + else: + # check cmd(.exe|.bat|.ps1) under Windows + if platform.system() == 'Windows': + if cmd.find('exe') != -1 or cmd.find('bat') != -1 or cmd.find('ps1') != -1: + return False + + # add .exe then check whether the cmd exists + cmd = cmd + '.exe' + if os.path.isfile(cmd): + return True + + return False |
