add support for in-tree keymap.json (wip)

This commit is contained in:
Zach White 2021-09-15 19:15:02 -07:00
parent 3f9e745b71
commit 0d9d1d0414
9 changed files with 35 additions and 24 deletions

View file

@ -7,11 +7,11 @@ from qmk.keyboard import keyboard_completer, keyboard_folder
from qmk.path import normpath
def would_populate_layout_h(keyboard):
def would_populate_layout_h(keyboard, keymap):
"""Detect if a given keyboard is doing data driven layouts
"""
# Build the info.json file
kb_info_json = info_json(keyboard, overrides=get_keyboard_overrides(keyboard))
kb_info_json = info_json(keyboard, overrides=get_keyboard_overrides(keyboard, keymap))
for layout_name in kb_info_json['layouts']:
if kb_info_json['layouts'][layout_name]['c_macro']:
@ -29,11 +29,12 @@ def would_populate_layout_h(keyboard):
@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.argument('-kb', '--keyboard', arg_only=True, type=keyboard_folder, completer=keyboard_completer, required=True, help='Keyboard to generate keyboard.h for.')
@cli.argument('-km', '--keymap', arg_only=True, help='Keymap name to check for overrides.')
@cli.subcommand('Used by the make system to generate keyboard.h from info.json', hidden=True)
def generate_keyboard_h(cli):
"""Generates the keyboard.h file.
"""
has_layout_h = would_populate_layout_h(cli.args.keyboard)
has_layout_h = would_populate_layout_h(cli.args.keyboard, cli.args.keymap)
# Build the layouts.h file.
keyboard_h_lines = ['/* This file was generated by `qmk generate-keyboard-h`. Do not edit or copy.' ' */', '', '#pragma once', '#include "quantum.h"']