diff options
| author | skullydazed <skullydazed@users.noreply.github.com> | 2020-03-08 09:21:45 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-08 09:21:45 -0700 |
| commit | cf40c33c907c44753bb145b9f2d5107447422fbc (patch) | |
| tree | a50ae8593c05fbd4ab545da5ed1ad03591ef6e35 /lib/python/qmk/cli | |
| parent | 4b7a3b2265d476dc3105511c74e25adc13ab8a8a (diff) | |
| download | qmk_firmware-cf40c33c907c44753bb145b9f2d5107447422fbc.tar.gz qmk_firmware-cf40c33c907c44753bb145b9f2d5107447422fbc.zip | |
Add gcc version detection to qmk doctor (#8338)
Diffstat (limited to 'lib/python/qmk/cli')
| -rwxr-xr-x | lib/python/qmk/cli/doctor.py | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/lib/python/qmk/cli/doctor.py b/lib/python/qmk/cli/doctor.py index 41db41184..9b81c8508 100755 --- a/lib/python/qmk/cli/doctor.py +++ b/lib/python/qmk/cli/doctor.py | |||
| @@ -11,7 +11,14 @@ from milc import cli | |||
| 11 | from qmk import submodules | 11 | from qmk import submodules |
| 12 | from qmk.questions import yesno | 12 | from qmk.questions import yesno |
| 13 | 13 | ||
| 14 | ESSENTIAL_BINARIES = ['dfu-programmer', 'avrdude', 'dfu-util', 'avr-gcc', 'arm-none-eabi-gcc', 'bin/qmk'] | 14 | ESSENTIAL_BINARIES = { |
| 15 | 'dfu-programmer': {}, | ||
| 16 | 'avrdude': {}, | ||
| 17 | 'dfu-util': {}, | ||
| 18 | 'avr-gcc': {}, | ||
| 19 | 'arm-none-eabi-gcc': {}, | ||
| 20 | 'bin/qmk': {}, | ||
| 21 | } | ||
| 15 | ESSENTIAL_SUBMODULES = ['lib/chibios', 'lib/lufa'] | 22 | ESSENTIAL_SUBMODULES = ['lib/chibios', 'lib/lufa'] |
| 16 | 23 | ||
| 17 | 24 | ||
| @@ -24,12 +31,42 @@ def _udev_rule(vid, pid=None): | |||
| 24 | return 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="%s", MODE:="0666"' % vid | 31 | return 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="%s", MODE:="0666"' % vid |
| 25 | 32 | ||
| 26 | 33 | ||
| 34 | def check_arm_gcc_version(): | ||
| 35 | """Returns True if the arm-none-eabi-gcc version is not known to cause problems. | ||
| 36 | """ | ||
| 37 | if 'output' in ESSENTIAL_BINARIES['arm-none-eabi-gcc']: | ||
| 38 | first_line = ESSENTIAL_BINARIES['arm-none-eabi-gcc']['output'].split('\n')[0] | ||
| 39 | second_half = first_line.split(')', 1)[1].strip() | ||
| 40 | version_number = second_half.split()[0] | ||
| 41 | cli.log.info('Found arm-none-eabi-gcc version %s', version_number) | ||
| 42 | |||
| 43 | return True # Right now all known arm versions are ok | ||
| 44 | |||
| 45 | |||
| 46 | def check_avr_gcc_version(): | ||
| 47 | """Returns True if the avr-gcc version is not known to cause problems. | ||
| 48 | """ | ||
| 49 | if 'output' in ESSENTIAL_BINARIES['avr-gcc']: | ||
| 50 | first_line = ESSENTIAL_BINARIES['avr-gcc']['output'].split('\n')[0] | ||
| 51 | version_number = first_line.split()[2] | ||
| 52 | |||
| 53 | major, minor, rest = version_number.split('.', 2) | ||
| 54 | if int(major) > 8: | ||
| 55 | cli.log.error('We do not recommend avr-gcc newer than 8. Downgrading to 8.x is recommended.') | ||
| 56 | return False | ||
| 57 | |||
| 58 | cli.log.info('Found avr-gcc version %s', version_number) | ||
| 59 | return True | ||
| 60 | |||
| 61 | return False | ||
| 62 | |||
| 63 | |||
| 27 | def check_binaries(): | 64 | def check_binaries(): |
| 28 | """Iterates through ESSENTIAL_BINARIES and tests them. | 65 | """Iterates through ESSENTIAL_BINARIES and tests them. |
| 29 | """ | 66 | """ |
| 30 | ok = True | 67 | ok = True |
| 31 | 68 | ||
| 32 | for binary in ESSENTIAL_BINARIES: | 69 | for binary in sorted(ESSENTIAL_BINARIES): |
| 33 | if not is_executable(binary): | 70 | if not is_executable(binary): |
| 34 | ok = False | 71 | ok = False |
| 35 | 72 | ||
| @@ -116,7 +153,9 @@ def is_executable(command): | |||
| 116 | return False | 153 | return False |
| 117 | 154 | ||
| 118 | # Make sure the command can be executed | 155 | # Make sure the command can be executed |
| 119 | check = subprocess.run([command, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=5) | 156 | check = subprocess.run([command, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=5, universal_newlines=True) |
| 157 | ESSENTIAL_BINARIES[command]['output'] = check.stdout | ||
| 158 | |||
| 120 | if check.returncode in [0, 1]: # Older versions of dfu-programmer exit 1 | 159 | if check.returncode in [0, 1]: # Older versions of dfu-programmer exit 1 |
| 121 | cli.log.debug('Found {fg_cyan}%s', command) | 160 | cli.log.debug('Found {fg_cyan}%s', command) |
| 122 | return True | 161 | return True |
| @@ -196,6 +235,13 @@ def doctor(cli): | |||
| 196 | else: | 235 | else: |
| 197 | ok = False | 236 | ok = False |
| 198 | 237 | ||
| 238 | # Make sure the tools are at the correct version | ||
| 239 | if not check_arm_gcc_version(): | ||
| 240 | ok = False | ||
| 241 | |||
| 242 | if not check_avr_gcc_version(): | ||
| 243 | ok = False | ||
| 244 | |||
| 199 | # Check out the QMK submodules | 245 | # Check out the QMK submodules |
| 200 | sub_ok = check_submodules() | 246 | sub_ok = check_submodules() |
| 201 | 247 | ||
