Build correctly when out of tree (#18775)
This commit is contained in:
parent
18dc851e37
commit
aa8e0a3e7a
3 changed files with 32 additions and 20 deletions
|
@ -162,7 +162,7 @@ ifneq ("$(wildcard $(KEYMAP_JSON))", "")
|
|||
-include $(KEYMAP_PATH)/rules.mk
|
||||
|
||||
# Load any rules.mk content from keymap.json
|
||||
INFO_RULES_MK = $(shell $(QMK_BIN) generate-rules-mk --quiet --escape --keyboard $(KEYBOARD) --keymap $(KEYMAP) --output $(KEYMAP_OUTPUT)/src/rules.mk)
|
||||
INFO_RULES_MK = $(shell $(QMK_BIN) generate-rules-mk --quiet --escape --output $(KEYMAP_OUTPUT)/src/rules.mk $(KEYMAP_JSON))
|
||||
include $(INFO_RULES_MK)
|
||||
|
||||
# Add rules to generate the keymap files - indentation here is important
|
||||
|
@ -173,7 +173,7 @@ $(KEYMAP_OUTPUT)/src/keymap.c: $(KEYMAP_JSON)
|
|||
|
||||
$(KEYMAP_OUTPUT)/src/config.h: $(KEYMAP_JSON)
|
||||
@$(SILENT) || printf "$(MSG_GENERATING) $@" | $(AWK_CMD)
|
||||
$(eval CMD=$(QMK_BIN) generate-config-h --quiet --keyboard $(KEYBOARD) --keymap $(KEYMAP) --output $(KEYMAP_H))
|
||||
$(eval CMD=$(QMK_BIN) generate-config-h --quiet --output $(KEYMAP_H) $(KEYMAP_JSON))
|
||||
@$(BUILD_CMD)
|
||||
|
||||
generated-files: $(KEYMAP_OUTPUT)/src/config.h $(KEYMAP_OUTPUT)/src/keymap.c
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
"""Used by the make system to generate info_config.h from info.json.
|
||||
"""
|
||||
from pathlib import Path
|
||||
|
||||
from dotty_dict import dotty
|
||||
|
||||
from argcomplete.completers import FilesCompleter
|
||||
from milc import cli
|
||||
|
||||
from qmk.info import info_json, keymap_json_config
|
||||
from qmk.info import info_json
|
||||
from qmk.json_schema import json_load
|
||||
from qmk.keyboard import keyboard_completer, keyboard_folder
|
||||
from qmk.commands import dump_lines
|
||||
from qmk.path import normpath
|
||||
from qmk.commands import dump_lines, parse_configurator_json
|
||||
from qmk.path import normpath, FileType
|
||||
from qmk.constants import GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE
|
||||
|
||||
|
||||
|
@ -162,19 +163,24 @@ def generate_led_animations_config(led_feature_json, config_h_lines, prefix):
|
|||
config_h_lines.append(generate_define(f'{prefix}{animation.upper()}'))
|
||||
|
||||
|
||||
@cli.argument('filename', nargs='?', arg_only=True, type=FileType('r'), completer=FilesCompleter('.json'), help='A configurator export JSON to be compiled and flashed or a pre-compiled binary firmware file (bin/hex) to be flashed.')
|
||||
@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 config.h for.')
|
||||
@cli.argument('-km', '--keymap', arg_only=True, help='Keymap to generate config.h for.')
|
||||
@cli.argument('-kb', '--keyboard', arg_only=True, type=keyboard_folder, completer=keyboard_completer, help='Keyboard to generate config.h for.')
|
||||
@cli.subcommand('Used by the make system to generate info_config.h from info.json', hidden=True)
|
||||
def generate_config_h(cli):
|
||||
"""Generates the info_config.h file.
|
||||
"""
|
||||
# Determine our keyboard/keymap
|
||||
if cli.args.keymap:
|
||||
kb_info_json = dotty(keymap_json_config(cli.args.keyboard, cli.args.keymap))
|
||||
else:
|
||||
if cli.args.filename:
|
||||
user_keymap = parse_configurator_json(cli.args.filename)
|
||||
kb_info_json = user_keymap.get('config', {})
|
||||
elif cli.args.keyboard:
|
||||
kb_info_json = dotty(info_json(cli.args.keyboard))
|
||||
else:
|
||||
cli.log.error('You must supply a configurator export or `--keyboard`.')
|
||||
cli.subcommands['generate-config-h'].print_help()
|
||||
return False
|
||||
|
||||
# Build the info_config.h file.
|
||||
config_h_lines = [GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE, '#pragma once']
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
"""Used by the make system to generate a rules.mk
|
||||
"""
|
||||
from pathlib import Path
|
||||
|
||||
from dotty_dict import dotty
|
||||
|
||||
from argcomplete.completers import FilesCompleter
|
||||
from milc import cli
|
||||
|
||||
from qmk.info import info_json, keymap_json_config
|
||||
from qmk.info import info_json
|
||||
from qmk.json_schema import json_load
|
||||
from qmk.keyboard import keyboard_completer, keyboard_folder
|
||||
from qmk.commands import dump_lines
|
||||
from qmk.path import normpath
|
||||
from qmk.commands import dump_lines, parse_configurator_json
|
||||
from qmk.path import normpath, FileType
|
||||
from qmk.constants import GPL2_HEADER_SH_LIKE, GENERATED_HEADER_SH_LIKE
|
||||
|
||||
|
||||
|
@ -39,20 +40,25 @@ def process_mapping_rule(kb_info_json, rules_key, info_dict):
|
|||
return f'{rules_key} ?= {rules_value}'
|
||||
|
||||
|
||||
@cli.argument('filename', nargs='?', arg_only=True, type=FileType('r'), completer=FilesCompleter('.json'), help='A configurator export JSON to be compiled and flashed or a pre-compiled binary firmware file (bin/hex) to be flashed.')
|
||||
@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('-e', '--escape', arg_only=True, action='store_true', help="Escape spaces in quiet mode")
|
||||
@cli.argument('-kb', '--keyboard', arg_only=True, type=keyboard_folder, completer=keyboard_completer, required=True, help='Keyboard to generate rules.mk for.')
|
||||
@cli.argument('-km', '--keymap', arg_only=True, help='Keymap to generate rules.mk for.')
|
||||
@cli.argument('-kb', '--keyboard', arg_only=True, type=keyboard_folder, completer=keyboard_completer, help='Keyboard to generate rules.mk for.')
|
||||
@cli.subcommand('Used by the make system to generate rules.mk from info.json', hidden=True)
|
||||
def generate_rules_mk(cli):
|
||||
"""Generates a rules.mk file from info.json.
|
||||
"""
|
||||
# Determine our keyboard/keymap
|
||||
if cli.args.keymap:
|
||||
kb_info_json = dotty(keymap_json_config(cli.args.keyboard, cli.args.keymap))
|
||||
else:
|
||||
if cli.args.filename:
|
||||
user_keymap = parse_configurator_json(cli.args.filename)
|
||||
kb_info_json = user_keymap.get('config', {})
|
||||
elif cli.args.keyboard:
|
||||
kb_info_json = dotty(info_json(cli.args.keyboard))
|
||||
else:
|
||||
cli.log.error('You must supply a configurator export or `--keyboard`.')
|
||||
cli.subcommands['generate-rules-mk'].print_help()
|
||||
return False
|
||||
|
||||
info_rules_map = json_load(Path('data/mappings/info_rules.json'))
|
||||
rules_mk_lines = [GPL2_HEADER_SH_LIKE, GENERATED_HEADER_SH_LIKE]
|
||||
|
|
Loading…
Reference in a new issue