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