summaryrefslogtreecommitdiff
path: root/lib/python/qmk
diff options
context:
space:
mode:
authorskullydazed <skullydazed@users.noreply.github.com>2020-03-08 09:21:45 -0700
committerFlorian Didron <fdidron@users.noreply.github.com>2020-06-12 17:00:27 +0900
commit928cb8ef92671806582f0f5ff8f9a83a17cb1796 (patch)
treef87b5b649470b3f34308d5725d6c5e16618d9ce8 /lib/python/qmk
parentcd1ba27a7b5d2021b8b906ebffd99a269d4b2688 (diff)
Add gcc version detection to qmk doctor (#8338)
Diffstat (limited to 'lib/python/qmk')
-rwxr-xr-xlib/python/qmk/cli/doctor.py52
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()