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

This commit is contained in:
Nick Brassel 2025-04-02 13:13:41 +11:00
commit 601a58b4cc
441 changed files with 7947 additions and 2318 deletions

View file

@ -66,7 +66,6 @@ subcommands = [
'qmk.cli.generate.keyboard_c',
'qmk.cli.generate.keyboard_h',
'qmk.cli.generate.keycodes',
'qmk.cli.generate.keycodes_tests',
'qmk.cli.generate.keymap_h',
'qmk.cli.generate.make_dependencies',
'qmk.cli.generate.rgb_breathe_table',
@ -223,7 +222,7 @@ if sys.version_info[0] != 3 or sys.version_info[1] < 9:
milc_version = __VERSION__.split('.')
if int(milc_version[0]) < 2 and int(milc_version[1]) < 4:
if int(milc_version[0]) < 2 and int(milc_version[1]) < 9:
requirements = Path('requirements.txt').resolve()
_eprint(f'Your MILC library is too old! Please upgrade: python3 -m pip install -U -r {str(requirements)}')

View file

@ -1,39 +0,0 @@
"""Used by the make system to generate a keycode lookup table from keycodes_{version}.json
"""
from milc import cli
from qmk.constants import GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE
from qmk.commands import dump_lines
from qmk.path import normpath
from qmk.keycodes import load_spec
def _generate_defines(lines, keycodes):
lines.append('')
lines.append('std::map<uint16_t, std::string> KEYCODE_ID_TABLE = {')
for key, value in keycodes["keycodes"].items():
lines.append(f' {{{value.get("key")}, "{value.get("key")}"}},')
lines.append('};')
@cli.argument('-v', '--version', arg_only=True, required=True, help='Version of keycodes to generate.')
@cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to')
@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages")
@cli.subcommand('Used by the make system to generate a keycode lookup table from keycodes_{version}.json', hidden=True)
def generate_keycodes_tests(cli):
"""Generates a keycode to identifier lookup table for unit test output.
"""
# Build the keycodes.h file.
keycodes_h_lines = [GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE, '// clang-format off']
keycodes_h_lines.append('extern "C" {\n#include <keycode.h>\n}')
keycodes_h_lines.append('#include <map>')
keycodes_h_lines.append('#include <string>')
keycodes_h_lines.append('#include <cstdint>')
keycodes = load_spec(cli.args.version)
_generate_defines(keycodes_h_lines, keycodes)
# Show the results
dump_lines(cli.args.output, keycodes_h_lines, cli.args.quiet)

View file

@ -10,7 +10,7 @@ from qmk.info import info_json, get_modules
from qmk.json_schema import json_load
from qmk.keyboard import keyboard_completer, keyboard_folder
from qmk.commands import dump_lines, parse_configurator_json
from qmk.path import normpath, FileType
from qmk.path import normpath, unix_style_path, FileType
from qmk.constants import GPL2_HEADER_SH_LIKE, GENERATED_HEADER_SH_LIKE
from qmk.community_modules import find_module_path, load_module_jsons
@ -63,7 +63,7 @@ def generate_modules_rules(keyboard, filename):
lines.append('')
lines.append('OPT_DEFS += -DCOMMUNITY_MODULES_ENABLE=TRUE')
for module in modules:
module_path = find_module_path(module)
module_path = unix_style_path(find_module_path(module))
if not module_path:
raise FileNotFoundError(f"Module '{module}' not found.")
lines.append('')
@ -72,6 +72,8 @@ def generate_modules_rules(keyboard, filename):
lines.append(f'COMMUNITY_MODULE_PATHS += {module_path}')
lines.append(f'VPATH += {module_path}')
lines.append(f'SRC += $(wildcard {module_path}/{module_path.name}.c)')
lines.append(f'MODULE_NAME_{module_path.name.upper()} := {module_path.name}')
lines.append(f'MODULE_PATH_{module_path.name.upper()} := {module_path}')
lines.append(f'-include {module_path}/rules.mk')
module_jsons = load_module_jsons(modules)

View file

@ -250,12 +250,14 @@ class CommunityModuleJSONEncoder(QMKJSONEncoder):
return '00module_name'
if key == 'maintainer':
return '01maintainer'
if key == 'license':
return '02license'
if key == 'url':
return '02url'
return '03url'
if key == 'features':
return '03features'
return '04features'
if key == 'keycodes':
return '04keycodes'
return '05keycodes'
elif self.indentation_level == 3: # keycodes
if key == 'key':
return '00key'

View file

@ -3,7 +3,7 @@
import logging
import os
import argparse
from pathlib import Path
from pathlib import Path, PureWindowsPath, PurePosixPath
from qmk.constants import MAX_KEYBOARD_SUBFOLDERS, QMK_FIRMWARE, QMK_USERSPACE, HAS_QMK_USERSPACE
from qmk.errors import NoSuchKeyboardError
@ -146,6 +146,28 @@ def normpath(path):
return Path(os.environ['ORIG_CWD']) / path
def unix_style_path(path):
"""Converts a Windows-style path with drive letter to a Unix path.
Path().as_posix() normally returns the path with drive letter and forward slashes, so is inappropriate for `Makefile` paths.
Passes through unadulterated if the path is not a Windows-style path.
Args:
path
The path to convert.
Returns:
The input path converted to Unix format.
"""
if isinstance(path, PureWindowsPath):
p = list(path.parts)
p[0] = f'/{p[0][0].lower()}' # convert from `X:/` to `/x`
path = PurePosixPath(*p)
return path
class FileType(argparse.FileType):
def __init__(self, *args, **kwargs):
# Use UTF8 by default for stdin