diff options
Diffstat (limited to 'lib/python/qmk')
-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 577588492d..98f96f1de2 100755 --- a/lib/python/qmk/cli/doctor.py +++ b/lib/python/qmk/cli/doctor.py @@ -11,7 +11,14 @@ from milc import cli from qmk import submodules from qmk.questions import yesno -ESSENTIAL_BINARIES = ['dfu-programmer', 'avrdude', 'dfu-util', 'avr-gcc', 'arm-none-eabi-gcc', 'bin/qmk'] +ESSENTIAL_BINARIES = { + 'dfu-programmer': {}, + 'avrdude': {}, + 'dfu-util': {}, + 'avr-gcc': {}, + 'arm-none-eabi-gcc': {}, + 'bin/qmk': {}, +} ESSENTIAL_SUBMODULES = ['lib/chibios', 'lib/lufa'] @@ -24,12 +31,42 @@ def _udev_rule(vid, pid=None): return 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="%s", MODE:="0666"' % vid +def check_arm_gcc_version(): + """Returns True if the arm-none-eabi-gcc version is not known to cause problems. + """ + if 'output' in ESSENTIAL_BINARIES['arm-none-eabi-gcc']: + first_line = ESSENTIAL_BINARIES['arm-none-eabi-gcc']['output'].split('\n')[0] + second_half = first_line.split(')', 1)[1].strip() + version_number = second_half.split()[0] + cli.log.info('Found arm-none-eabi-gcc version %s', version_number) + + return True # Right now all known arm versions are ok + + +def check_avr_gcc_version(): + """Returns True if the avr-gcc version is not known to cause problems. + """ + if 'output' in ESSENTIAL_BINARIES['avr-gcc']: + first_line = ESSENTIAL_BINARIES['avr-gcc']['output'].split('\n')[0] + version_number = first_line.split()[2] + + major, minor, rest = version_number.split('.', 2) + if int(major) > 8: + cli.log.error('We do not recommend avr-gcc newer than 8. Downgrading to 8.x is recommended.') + return False + + cli.log.info('Found avr-gcc version %s', version_number) + return True + + return False + + def check_binaries(): """Iterates through ESSENTIAL_BINARIES and tests them. """ ok = True - for binary in ESSENTIAL_BINARIES: + for binary in sorted(ESSENTIAL_BINARIES): if not is_executable(binary): ok = False @@ -116,7 +153,9 @@ def is_executable(command): return False # Make sure the command can be executed - check = subprocess.run([command, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=5) + check = subprocess.run([command, '--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=5, universal_newlines=True) + ESSENTIAL_BINARIES[command]['output'] = check.stdout + if check.returncode in [0, 1]: # Older versions of dfu-programmer exit 1 cli.log.debug('Found {fg_cyan}%s', command) return True @@ -196,6 +235,13 @@ def doctor(cli): else: ok = False + # Make sure the tools are at the correct version + if not check_arm_gcc_version(): + ok = False + + if not check_avr_gcc_version(): + ok = False + # Check out the QMK submodules sub_ok = check_submodules() |