mirror of
https://github.com/qmk/qmk_firmware
synced 2024-11-17 17:35:30 +00:00
qmk generate-make-dependencies
improvements (#21001)
* Recommendations from @sigprof * Fix CI tests
This commit is contained in:
parent
449240f198
commit
420e35f922
1 changed files with 8 additions and 9 deletions
|
@ -6,7 +6,6 @@ from milc import cli
|
||||||
from argcomplete.completers import FilesCompleter
|
from argcomplete.completers import FilesCompleter
|
||||||
|
|
||||||
from qmk.commands import dump_lines
|
from qmk.commands import dump_lines
|
||||||
from qmk.constants import QMK_FIRMWARE
|
|
||||||
from qmk.keyboard import keyboard_completer, keyboard_folder
|
from qmk.keyboard import keyboard_completer, keyboard_folder
|
||||||
from qmk.keymap import keymap_completer, locate_keymap
|
from qmk.keymap import keymap_completer, locate_keymap
|
||||||
from qmk.path import normpath, FileType
|
from qmk.path import normpath, FileType
|
||||||
|
@ -23,34 +22,34 @@ def generate_make_dependencies(cli):
|
||||||
"""
|
"""
|
||||||
interesting_files = [
|
interesting_files = [
|
||||||
'info.json',
|
'info.json',
|
||||||
'keymap.json',
|
|
||||||
'rules.mk',
|
'rules.mk',
|
||||||
'post_rules.mk',
|
'post_rules.mk',
|
||||||
'config.h',
|
'config.h',
|
||||||
'post_config.h',
|
'post_config.h',
|
||||||
]
|
]
|
||||||
|
|
||||||
found_files = []
|
check_files = []
|
||||||
|
|
||||||
# Walk up the keyboard's directory tree looking for the files we're interested in
|
# Walk up the keyboard's directory tree looking for the files we're interested in
|
||||||
keyboards_root = Path('keyboards')
|
keyboards_root = Path('keyboards')
|
||||||
parent_path = Path('keyboards') / cli.args.keyboard
|
parent_path = Path('keyboards') / cli.args.keyboard
|
||||||
while parent_path != keyboards_root:
|
while parent_path != keyboards_root:
|
||||||
for file in interesting_files:
|
for file in interesting_files:
|
||||||
test_path = parent_path / file
|
check_files.append(parent_path / file)
|
||||||
if test_path.exists():
|
|
||||||
found_files.append(test_path)
|
|
||||||
parent_path = parent_path.parent
|
parent_path = parent_path.parent
|
||||||
|
|
||||||
# Find the keymap and include any of the interesting files
|
# Find the keymap and include any of the interesting files
|
||||||
if cli.args.keymap is not None:
|
if cli.args.keymap is not None:
|
||||||
km = locate_keymap(cli.args.keyboard, cli.args.keymap)
|
km = locate_keymap(cli.args.keyboard, cli.args.keymap)
|
||||||
if km is not None:
|
if km is not None:
|
||||||
|
# keymap.json is only valid for the keymap, so check this one separately
|
||||||
|
check_files.append(km.parent / 'keymap.json')
|
||||||
|
# Add all the interesting files
|
||||||
for file in interesting_files:
|
for file in interesting_files:
|
||||||
found_files.extend(km.parent.glob(f'**/{file}'))
|
check_files.append(km.parent / file)
|
||||||
|
|
||||||
# If we have a matching userspace, include those too
|
# If we have a matching userspace, include those too
|
||||||
for file in interesting_files:
|
for file in interesting_files:
|
||||||
found_files.extend((QMK_FIRMWARE / 'users' / cli.args.keymap).glob(f'**/{file}'))
|
check_files.append(Path('users') / cli.args.keymap / file)
|
||||||
|
|
||||||
dump_lines(cli.args.output, [f'generated-files: {found.resolve()}\n' for found in found_files])
|
dump_lines(cli.args.output, [f'generated-files: $(wildcard {found})\n' for found in check_files])
|
||||||
|
|
Loading…
Reference in a new issue