Merge remote-tracking branch 'upstream/develop' into xap

This commit is contained in:
Nick Brassel 2022-02-03 03:15:01 +11:00
commit dcf4bf6d29
8302 changed files with 152923 additions and 60301 deletions

View file

@ -11,7 +11,7 @@ from milc.questions import yesno
from qmk import submodules
from qmk.constants import QMK_FIRMWARE, QMK_FIRMWARE_UPSTREAM
from .check import CheckStatus, check_binaries, check_binary_versions, check_submodules
from qmk.commands import git_check_repo, git_get_branch, git_is_dirty, git_get_remotes, git_check_deviation, in_virtualenv
from qmk.commands import git_check_repo, git_get_branch, git_get_tag, git_is_dirty, git_get_remotes, git_check_deviation, in_virtualenv
def os_tests():
@ -47,6 +47,11 @@ def git_tests():
git_branch = git_get_branch()
if git_branch:
cli.log.info('Git branch: %s', git_branch)
repo_version = git_get_tag()
if repo_version:
cli.log.info('Repo version: %s', repo_version)
git_dirty = git_is_dirty()
if git_dirty:
cli.log.warning('{fg_yellow}Git has unstashed/uncommitted changes.')

View file

@ -1,6 +1,5 @@
"""Format C code according to QMK's style.
"""
from os import path
from shutil import which
from subprocess import CalledProcessError, DEVNULL, Popen, PIPE
@ -15,6 +14,12 @@ core_dirs = ('drivers', 'quantum', 'tests', 'tmk_core', 'platforms')
ignored = ('tmk_core/protocol/usb_hid', 'platforms/chibios/boards')
def is_relative_to(file, other):
"""Provide similar behavior to PurePath.is_relative_to in Python > 3.9
"""
return str(normpath(file).resolve()).startswith(str(normpath(other).resolve()))
def find_clang_format():
"""Returns the path to clang-format.
"""
@ -68,18 +73,18 @@ def cformat_run(files):
def filter_files(files, core_only=False):
"""Yield only files to be formatted and skip the rest
"""
if core_only:
# Filter non-core files
for index, file in enumerate(files):
files = list(map(normpath, filter(None, files)))
for file in files:
if core_only:
# The following statement checks each file to see if the file path is
# - in the core directories
# - not in the ignored directories
if not any(i in str(file) for i in core_dirs) or any(i in str(file) for i in ignored):
files[index] = None
if not any(is_relative_to(file, i) for i in core_dirs) or any(is_relative_to(file, i) for i in ignored):
cli.log.debug("Skipping non-core file %s, as '--core-only' is used.", file)
continue
for file in files:
if file and file.name.split('.')[-1] in c_file_suffixes:
if file.suffix[1:] in c_file_suffixes:
yield file
else:
cli.log.debug('Skipping file %s', file)
@ -118,12 +123,8 @@ def format_c(cli):
print(git_diff.stderr)
return git_diff.returncode
files = []
for file in git_diff.stdout.strip().split('\n'):
if not any([file.startswith(ignore) for ignore in ignored]):
if path.exists(file) and file.split('.')[-1] in c_file_suffixes:
files.append(file)
changed_files = git_diff.stdout.strip().split('\n')
files = list(filter_files(changed_files, True))
# Sanity check
if not files:

View file

@ -25,8 +25,9 @@ def yapf_run(files):
def filter_files(files):
"""Yield only files to be formatted and skip the rest
"""
files = list(map(normpath, filter(None, files)))
for file in files:
if file and normpath(file).name.split('.')[-1] in py_file_suffixes:
if file.suffix[1:] in py_file_suffixes:
yield file
else:
cli.log.debug('Skipping file %s', file)

View file

@ -26,7 +26,8 @@ def system_libs(binary: str) -> List[Path]:
# Actually query xxxxxx-gcc to find its include paths.
if binary.endswith("gcc") or binary.endswith("g++"):
result = cli.run([binary, '-E', '-Wp,-v', '-'], capture_output=True, check=True, input='\n')
# (TODO): Remove 'stdin' once 'input' no longer causes issues under MSYS
result = cli.run([binary, '-E', '-Wp,-v', '-'], capture_output=True, check=True, stdin=None, input='\n')
paths = []
for line in result.stderr.splitlines():
if line.startswith(" "):

View file

@ -108,6 +108,12 @@ def generate_config_items(kb_info_json, config_h_lines):
config_h_lines.append(f'#ifndef {key}')
config_h_lines.append(f'# define {key} {value}')
config_h_lines.append(f'#endif // {key}')
elif key_type == 'bcd_version':
(major, minor, revision) = config_value.split('.')
config_h_lines.append('')
config_h_lines.append(f'#ifndef {config_key}')
config_h_lines.append(f'# define {config_key} 0x{major.zfill(2)}{minor}{revision}')
config_h_lines.append(f'#endif // {config_key}')
else:
config_h_lines.append('')
config_h_lines.append(f'#ifndef {config_key}')

View file

@ -97,7 +97,7 @@ def generate_develop_pr_list(cli):
match = git_expr.search(line)
if match:
pr_info = _get_pr_info(cache, gh, match.group("pr"))
commit_info = {'hash': match.group("hash"), 'title': match.group("title"), 'pr_num': int(match.group("pr")), 'pr_labels': [label.name for label in pr_info.labels.items]}
commit_info = {'hash': match.group("hash"), 'title': pr_info['title'], 'pr_num': int(match.group("pr")), 'pr_labels': [label.name for label in pr_info.labels.items]}
_categorise_commit(commit_info)
def _dump_commit_list(name, collection):

View file

@ -32,6 +32,7 @@ def _is_split(keyboard_name):
@cli.argument('-c', '--clean', arg_only=True, action='store_true', help="Remove object files before compiling.")
@cli.argument('-f', '--filter', arg_only=True, action='append', default=[], help="Filter the list of keyboards based on the supplied value in rules.mk. Supported format is 'SPLIT_KEYBOARD=yes'. May be passed multiple times.")
@cli.argument('-km', '--keymap', type=str, default='default', help="The keymap name to build. Default is 'default'.")
@cli.argument('-e', '--env', arg_only=True, action='append', default=[], help="Set a variable to be passed to make. May be passed multiple times.")
@cli.subcommand('Compile QMK Firmware for all keyboards.', hidden=False if cli.config.user.developer else True)
def multibuild(cli):
"""Compile QMK Firmware against all keyboards.
@ -68,7 +69,7 @@ def multibuild(cli):
all: {keyboard_safe}_binary
{keyboard_safe}_binary:
@rm -f "{QMK_FIRMWARE}/.build/failed.log.{keyboard_safe}" || true
+@$(MAKE) -C "{QMK_FIRMWARE}" -f "{QMK_FIRMWARE}/build_keyboard.mk" KEYBOARD="{keyboard_name}" KEYMAP="{cli.args.keymap}" REQUIRE_PLATFORM_KEY= COLOR=true SILENT=false \\
+@$(MAKE) -C "{QMK_FIRMWARE}" -f "{QMK_FIRMWARE}/build_keyboard.mk" KEYBOARD="{keyboard_name}" KEYMAP="{cli.args.keymap}" REQUIRE_PLATFORM_KEY= COLOR=true SILENT=false {' '.join(cli.args.env)} \\
>>"{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" 2>&1 \\
|| cp "{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" "{QMK_FIRMWARE}/.build/failed.log.{os.getpid()}.{keyboard_safe}"
@{{ grep '\[ERRORS\]' "{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}" >/dev/null 2>&1 && printf "Build %-64s \e[1;31m[ERRORS]\e[0m\\n" "{keyboard_name}:{cli.args.keymap}" ; }} \\

View file

@ -7,11 +7,12 @@ from subprocess import DEVNULL
from milc import cli
@cli.argument('-t', '--test', arg_only=True, action='append', default=[], help="Mapped to nose2 'testNames' positional argument - https://docs.nose2.io/en/latest/usage.html#specifying-tests-to-run")
@cli.subcommand('QMK Python Unit Tests', hidden=False if cli.config.user.developer else True)
def pytest(cli):
"""Run several linting/testing commands.
"""
nose2 = cli.run(['nose2', '-v'], capture_output=False, stdin=DEVNULL)
nose2 = cli.run(['nose2', '-v', '-t' 'lib/python', *cli.args.test], capture_output=False, stdin=DEVNULL)
flake8 = cli.run(['flake8', 'lib/python'], capture_output=False, stdin=DEVNULL)
return flake8.returncode | nose2.returncode

View file

@ -298,6 +298,14 @@ def git_get_branch():
return git_branch.stdout.strip()
def git_get_tag():
"""Returns the current tag for a repo, or None.
"""
git_tag = cli.run(['git', 'describe', '--abbrev=0', '--tags'])
if git_tag.returncode == 0:
return git_tag.stdout.strip()
def git_is_dirty():
"""Returns 1 if repo is dirty, or 0 if clean
"""

View file

@ -14,7 +14,7 @@ QMK_FIRMWARE_UPSTREAM = 'qmk/qmk_firmware'
MAX_KEYBOARD_SUBFOLDERS = 5
# Supported processor types
CHIBIOS_PROCESSORS = 'cortex-m0', 'cortex-m0plus', 'cortex-m3', 'cortex-m4', 'MKL26Z64', 'MK20DX128', 'MK20DX256', 'MK66FX1M0', 'STM32F042', 'STM32F072', 'STM32F103', 'STM32F303', 'STM32F401', 'STM32F407', 'STM32F411', 'STM32F446', 'STM32G431', 'STM32G474', 'STM32L412', 'STM32L422', 'STM32L433', 'STM32L443', 'GD32VF103', 'WB32F3G71'
CHIBIOS_PROCESSORS = 'cortex-m0', 'cortex-m0plus', 'cortex-m3', 'cortex-m4', 'MKL26Z64', 'MK20DX128', 'MK20DX256', 'MK66FX1M0', 'STM32F042', 'STM32F072', 'STM32F103', 'STM32F303', 'STM32F401', 'STM32F405', 'STM32F407', 'STM32F411', 'STM32F446', 'STM32G431', 'STM32G474', 'STM32L412', 'STM32L422', 'STM32L432', 'STM32L433', 'STM32L442', 'STM32L443', 'GD32VF103', 'WB32F3G71'
LUFA_PROCESSORS = 'at90usb162', 'atmega16u2', 'atmega32u2', 'atmega16u4', 'atmega32u4', 'at90usb646', 'at90usb647', 'at90usb1286', 'at90usb1287', None
VUSB_PROCESSORS = 'atmega32a', 'atmega328p', 'atmega328', 'attiny85'

View file

@ -387,6 +387,19 @@ def _extract_matrix_info(info_data, config_c):
return info_data
# TODO: kill off usb.device_ver in favor of usb.device_version
def _extract_device_version(info_data):
if info_data.get('usb'):
if info_data['usb'].get('device_version') and not info_data['usb'].get('device_ver'):
(major, minor, revision) = info_data['usb']['device_version'].split('.', 3)
info_data['usb']['device_ver'] = f'0x{major.zfill(2)}{minor}{revision}'
if not info_data['usb'].get('device_version') and info_data['usb'].get('device_ver'):
major = int(info_data['usb']['device_ver'][2:4])
minor = int(info_data['usb']['device_ver'][4])
revision = int(info_data['usb']['device_ver'][5])
info_data['usb']['device_version'] = f'{major}.{minor}.{revision}'
def _extract_config_h(info_data):
"""Pull some keyboard information from existing config.h files
"""
@ -430,6 +443,13 @@ def _extract_config_h(info_data):
elif key_type == 'int':
dotty_info[info_key] = int(config_c[config_key])
elif key_type == 'bcd_version':
major = int(config_c[config_key][2:4])
minor = int(config_c[config_key][4])
revision = int(config_c[config_key][5])
dotty_info[info_key] = f'{major}.{minor}.{revision}'
else:
dotty_info[info_key] = config_c[config_key]
@ -444,6 +464,7 @@ def _extract_config_h(info_data):
_extract_split_main(info_data, config_c)
_extract_split_transport(info_data, config_c)
_extract_split_right_pins(info_data, config_c)
_extract_device_version(info_data)
return info_data
@ -622,12 +643,7 @@ def arm_processor_rules(info_data, rules):
info_data['protocol'] = 'ChibiOS'
if 'bootloader' not in info_data:
if 'STM32' in info_data['processor']:
info_data['bootloader'] = 'stm32-dfu'
elif 'WB32' in info_data['processor']:
info_data['bootloader'] = 'wb32-dfu'
else:
info_data['bootloader'] = 'unknown'
info_data['bootloader'] = 'unknown'
if 'STM32' in info_data['processor']:
info_data['platform'] = 'STM32'

View file

@ -113,7 +113,7 @@ def test_list_keymaps_community():
def test_list_keymaps_kb_only():
result = check_subcommand('list-keymaps', '-kb', 'niu_mini')
result = check_subcommand('list-keymaps', '-kb', 'contra')
check_returncode(result)
assert 'default' and 'via' in result.stdout