diff options
| author | Ryan <fauxpark@gmail.com> | 2020-06-19 04:37:47 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-18 19:37:47 +0100 |
| commit | db80209e697770cca0ba44e437efa548247b387f (patch) | |
| tree | c24f46b26d83f23aeaff302968e84b07c25519e2 | |
| parent | 716924de3e07eb4a6f39a9c8da9ba0fc64c7f796 (diff) | |
| download | qmk_firmware-db80209e697770cca0ba44e437efa548247b387f.tar.gz qmk_firmware-db80209e697770cca0ba44e437efa548247b387f.zip | |
Parse version better in `qmk doctor` GCC version checks (#9324)
| -rwxr-xr-x | lib/python/qmk/cli/doctor.py | 15 | ||||
| -rw-r--r-- | lib/python/qmk/tests/test_cli_commands.py | 8 |
2 files changed, 17 insertions, 6 deletions
diff --git a/lib/python/qmk/cli/doctor.py b/lib/python/qmk/cli/doctor.py index 011c3dd3c..4d7ba5218 100755 --- a/lib/python/qmk/cli/doctor.py +++ b/lib/python/qmk/cli/doctor.py | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | Check out the user's QMK environment and make sure it's ready to compile. | 3 | Check out the user's QMK environment and make sure it's ready to compile. |
| 4 | """ | 4 | """ |
| 5 | import platform | 5 | import platform |
| 6 | import re | ||
| 6 | import shutil | 7 | import shutil |
| 7 | import subprocess | 8 | import subprocess |
| 8 | from pathlib import Path | 9 | from pathlib import Path |
| @@ -50,6 +51,16 @@ def _deprecated_udev_rule(vid, pid=None): | |||
| 50 | return 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="%s", MODE:="0666"' % vid | 51 | return 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="%s", MODE:="0666"' % vid |
| 51 | 52 | ||
| 52 | 53 | ||
| 54 | def parse_gcc_version(version): | ||
| 55 | m = re.match(r"(\d+)(?:\.(\d+))?(?:\.(\d+))?", version) | ||
| 56 | |||
| 57 | return { | ||
| 58 | 'major': int(m.group(1)), | ||
| 59 | 'minor': int(m.group(2)) if m.group(2) else 0, | ||
| 60 | 'patch': int(m.group(3)) if m.group(3) else 0 | ||
| 61 | } | ||
| 62 | |||
| 63 | |||
| 53 | def check_arm_gcc_version(): | 64 | def check_arm_gcc_version(): |
| 54 | """Returns True if the arm-none-eabi-gcc version is not known to cause problems. | 65 | """Returns True if the arm-none-eabi-gcc version is not known to cause problems. |
| 55 | """ | 66 | """ |
| @@ -66,8 +77,8 @@ def check_avr_gcc_version(): | |||
| 66 | if 'output' in ESSENTIAL_BINARIES['avr-gcc']: | 77 | if 'output' in ESSENTIAL_BINARIES['avr-gcc']: |
| 67 | version_number = ESSENTIAL_BINARIES['avr-gcc']['output'].strip() | 78 | version_number = ESSENTIAL_BINARIES['avr-gcc']['output'].strip() |
| 68 | 79 | ||
| 69 | major, minor, rest = version_number.split('.', 2) | 80 | parsed_version = parse_gcc_version(version_number) |
| 70 | if int(major) > 8: | 81 | if parsed_version['major'] > 8: |
| 71 | cli.log.error('We do not recommend avr-gcc newer than 8. Downgrading to 8.x is recommended.') | 82 | cli.log.error('We do not recommend avr-gcc newer than 8. Downgrading to 8.x is recommended.') |
| 72 | return False | 83 | return False |
| 73 | 84 | ||
diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py index dce270de8..68f8ed604 100644 --- a/lib/python/qmk/tests/test_cli_commands.py +++ b/lib/python/qmk/tests/test_cli_commands.py | |||
| @@ -115,7 +115,7 @@ def test_list_keymaps_no_keyboard_found(): | |||
| 115 | def test_json2c(): | 115 | def test_json2c(): |
| 116 | result = check_subcommand('json2c', 'keyboards/handwired/onekey/keymaps/default_json/keymap.json') | 116 | result = check_subcommand('json2c', 'keyboards/handwired/onekey/keymaps/default_json/keymap.json') |
| 117 | check_returncode(result, 0) | 117 | check_returncode(result, 0) |
| 118 | assert result.stdout == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {\t[0] = LAYOUT(KC_A)};\n\n' | 118 | assert result.stdout == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {\t[0] = LAYOUT_ortho_1x1(KC_A)};\n\n' |
| 119 | 119 | ||
| 120 | 120 | ||
| 121 | def test_info(): | 121 | def test_info(): |
| @@ -132,7 +132,7 @@ def test_info_keyboard_render(): | |||
| 132 | check_returncode(result) | 132 | check_returncode(result) |
| 133 | assert 'Keyboard Name: handwired/onekey/pytest' in result.stdout | 133 | assert 'Keyboard Name: handwired/onekey/pytest' in result.stdout |
| 134 | assert 'Processor: STM32F303' in result.stdout | 134 | assert 'Processor: STM32F303' in result.stdout |
| 135 | assert 'Layout:' in result.stdout | 135 | assert 'Layouts:' in result.stdout |
| 136 | assert 'k0' in result.stdout | 136 | assert 'k0' in result.stdout |
| 137 | 137 | ||
| 138 | 138 | ||
| @@ -149,6 +149,6 @@ def test_info_matrix_render(): | |||
| 149 | check_returncode(result) | 149 | check_returncode(result) |
| 150 | assert 'Keyboard Name: handwired/onekey/pytest' in result.stdout | 150 | assert 'Keyboard Name: handwired/onekey/pytest' in result.stdout |
| 151 | assert 'Processor: STM32F303' in result.stdout | 151 | assert 'Processor: STM32F303' in result.stdout |
| 152 | assert 'LAYOUT' in result.stdout | 152 | assert 'LAYOUT_ortho_1x1' in result.stdout |
| 153 | assert '│0A│' in result.stdout | 153 | assert '│0A│' in result.stdout |
| 154 | assert 'Matrix for "LAYOUT"' in result.stdout | 154 | assert 'Matrix for "LAYOUT_ortho_1x1"' in result.stdout |
