|
3 | 3 |
|
4 | 4 | def check_installed(tool, version="") -> int: |
5 | 5 | if version: |
6 | | - command = [f'{tool}-{version} ', '--version'] |
| 6 | + check_version_cmd = [f'{tool}-{version} ', '--version'] |
| 7 | + # clang-tools exist because install_requires=['clang-tools'] in setup.py |
| 8 | + install_tool_cmd = ['clang-tools', '-i', version] |
7 | 9 | else: |
8 | | - command = [tool, '--version'] |
| 10 | + check_version_cmd = [tool, '--version'] |
| 11 | + # install verison 13 by default if clang-tools not exist. |
| 12 | + install_tool_cmd = ['clang-tools', '-i', '13'] |
9 | 13 | try: |
10 | | - subprocess.run(command, stdout=subprocess.PIPE) |
11 | | - retval = 0 |
| 14 | + retval = subprocess.run(check_version_cmd, stdout=subprocess.PIPE).returncode |
12 | 15 | except FileNotFoundError: |
13 | | - # clang-tools exist because install_requires=['clang-tools'] in setup.py |
14 | | - # install verison 13 by default if clang-tools not exist. |
15 | | - if version: |
16 | | - retval = subprocess.run(['clang-tools', '-i', version], stdout=subprocess.PIPE).returncode |
17 | | - else: |
18 | | - retval = subprocess.run(['clang-tools', '-i', '13'], stdout=subprocess.PIPE).returncode |
| 16 | + retval = subprocess.run(install_tool_cmd, stdout=subprocess.PIPE).returncode |
19 | 17 | return retval |
20 | 18 |
|
21 | 19 |
|
|
0 commit comments