summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2023-06-21 08:41:49 +1000
committerGitHub <noreply@github.com>2023-06-21 08:41:49 +1000
commitffdc70bf0a6fecff024ece2a5b7b4c0c88dd6ee3 (patch)
tree5b4f6b347fd5902c6db24019173e5706a84b9bba
parent45dc1ccffedd92c543997cc153efbaf058a46616 (diff)
Consolidate `KEYBOARD_OUTPUT`+`KEYMAP_OUTPUT`=>`INTERMEDIATE_OUTPUT` (#21272)
-rw-r--r--builddefs/build_keyboard.mk67
-rw-r--r--builddefs/common_rules.mk2
-rw-r--r--docs/data_driven_config.md4
-rw-r--r--docs/ja/data_driven_config.md4
-rwxr-xr-xlib/python/qmk/cli/mass_compile.py17
-rw-r--r--lib/python/qmk/commands.py26
-rw-r--r--lib/python/qmk/constants.py2
-rw-r--r--platforms/chibios/vendors/RP/pico_sdk_shims.c3
8 files changed, 59 insertions, 66 deletions
diff --git a/builddefs/build_keyboard.mk b/builddefs/build_keyboard.mk
index 0425d3fc9d..32e41e7d5b 100644
--- a/builddefs/build_keyboard.mk
+++ b/builddefs/build_keyboard.mk
@@ -27,7 +27,6 @@ QMK_BIN ?= qmk
# Set the filename for the final firmware binary
KEYBOARD_FILESAFE := $(subst /,_,$(KEYBOARD))
TARGET ?= $(KEYBOARD_FILESAFE)_$(KEYMAP)
-KEYBOARD_OUTPUT := $(BUILD_DIR)/obj_$(KEYBOARD_FILESAFE)
ifeq ($(strip $(DUMP_CI_METADATA)),yes)
$(info CI Metadata: KEYBOARD=$(KEYBOARD))
@@ -44,7 +43,7 @@ endif
# Object files and generated keymap directory
# To put object files in current directory, use a dot (.), do NOT make
# this an empty or blank macro!
-KEYMAP_OUTPUT := $(BUILD_DIR)/obj_$(TARGET)
+INTERMEDIATE_OUTPUT := $(BUILD_DIR)/obj_$(TARGET)
ifdef SKIP_VERSION
OPT_DEFS += -DSKIP_VERSION
@@ -60,7 +59,7 @@ VERSION_H_FLAGS += --skip-git
endif
# Generate the board's version.h file.
-$(shell $(QMK_BIN) generate-version-h $(VERSION_H_FLAGS) -q -o $(KEYMAP_OUTPUT)/src/version.h)
+$(shell $(QMK_BIN) generate-version-h $(VERSION_H_FLAGS) -q -o $(INTERMEDIATE_OUTPUT)/src/version.h)
# Determine which subfolders exist.
KEYBOARD_FOLDER_PATH_1 := $(KEYBOARD)
@@ -121,7 +120,7 @@ MAIN_KEYMAP_PATH_4 := $(KEYBOARD_PATH_4)/keymaps/$(KEYMAP)
MAIN_KEYMAP_PATH_5 := $(KEYBOARD_PATH_5)/keymaps/$(KEYMAP)
# Pull in rules from info.json
-INFO_RULES_MK = $(shell $(QMK_BIN) generate-rules-mk --quiet --escape --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/info_rules.mk)
+INFO_RULES_MK = $(shell $(QMK_BIN) generate-rules-mk --quiet --escape --keyboard $(KEYBOARD) --output $(INTERMEDIATE_OUTPUT)/src/info_rules.mk)
include $(INFO_RULES_MK)
# Check for keymap.json first, so we can regenerate keymap.c
@@ -161,28 +160,28 @@ endif
# Have we found a keymap.json?
ifneq ("$(wildcard $(KEYMAP_JSON))", "")
- KEYMAP_C := $(KEYMAP_OUTPUT)/src/keymap.c
- KEYMAP_H := $(KEYMAP_OUTPUT)/src/config.h
+ KEYMAP_C := $(INTERMEDIATE_OUTPUT)/src/keymap.c
+ KEYMAP_H := $(INTERMEDIATE_OUTPUT)/src/config.h
# Load the keymap-level rules.mk if exists
-include $(KEYMAP_PATH)/rules.mk
# Load any rules.mk content from keymap.json
- INFO_RULES_MK = $(shell $(QMK_BIN) generate-rules-mk --quiet --escape --output $(KEYMAP_OUTPUT)/src/rules.mk $(KEYMAP_JSON))
+ INFO_RULES_MK = $(shell $(QMK_BIN) generate-rules-mk --quiet --escape --output $(INTERMEDIATE_OUTPUT)/src/rules.mk $(KEYMAP_JSON))
include $(INFO_RULES_MK)
# Add rules to generate the keymap files - indentation here is important
-$(KEYMAP_OUTPUT)/src/keymap.c: $(KEYMAP_JSON)
+$(INTERMEDIATE_OUTPUT)/src/keymap.c: $(KEYMAP_JSON)
@$(SILENT) || printf "$(MSG_GENERATING) $@" | $(AWK_CMD)
$(eval CMD=$(QMK_BIN) json2c --quiet --output $(KEYMAP_C) $(KEYMAP_JSON))
@$(BUILD_CMD)
-$(KEYMAP_OUTPUT)/src/config.h: $(KEYMAP_JSON)
+$(INTERMEDIATE_OUTPUT)/src/config.h: $(KEYMAP_JSON)
@$(SILENT) || printf "$(MSG_GENERATING) $@" | $(AWK_CMD)
$(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
+generated-files: $(INTERMEDIATE_OUTPUT)/src/config.h $(INTERMEDIATE_OUTPUT)/src/keymap.c
endif
@@ -323,34 +322,34 @@ ifneq ("$(wildcard $(KEYBOARD_PATH_5)/info.json)","")
INFO_JSON_FILES += $(KEYBOARD_PATH_5)/info.json
endif
-CONFIG_H += $(KEYBOARD_OUTPUT)/src/info_config.h
-KEYBOARD_SRC += $(KEYBOARD_OUTPUT)/src/default_keyboard.c
+CONFIG_H += $(INTERMEDIATE_OUTPUT)/src/info_config.h
+KEYBOARD_SRC += $(INTERMEDIATE_OUTPUT)/src/default_keyboard.c
-$(KEYBOARD_OUTPUT)/src/info_config.h: $(INFO_JSON_FILES)
+$(INTERMEDIATE_OUTPUT)/src/info_config.h: $(INFO_JSON_FILES)
@$(SILENT) || printf "$(MSG_GENERATING) $@" | $(AWK_CMD)
- $(eval CMD=$(QMK_BIN) generate-config-h --quiet --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/info_config.h)
+ $(eval CMD=$(QMK_BIN) generate-config-h --quiet --keyboard $(KEYBOARD) --output $(INTERMEDIATE_OUTPUT)/src/info_config.h)
@$(BUILD_CMD)
-$(KEYBOARD_OUTPUT)/src/default_keyboard.c: $(INFO_JSON_FILES)
+$(INTERMEDIATE_OUTPUT)/src/default_keyboard.c: $(INFO_JSON_FILES)
@$(SILENT) || printf "$(MSG_GENERATING) $@" | $(AWK_CMD)
- $(eval CMD=$(QMK_BIN) generate-keyboard-c --quiet --keyboard $(KEYBOARD) --output $(KEYBOARD_OUTPUT)/src/default_keyboard.c)
+ $(eval CMD=$(QMK_BIN) generate-keyboard-c --quiet --keyboard $(KEYBOARD) --output $(INTERMEDIATE_OUTPUT)/src/default_keyboard.c)
@$(BUILD_CMD)
-$(KEYBOARD_OUTPUT)/src/default_keyboard.h: $(INFO_JSON_FILES)
+$(INTERMEDIATE_OUTPUT)/src/default_keyboard.h: $(INFO_JSON_FILES)
@$(SILENT) || printf "$(MSG_GENERATING) $@" | $(AWK_CMD)
- $(eval CMD=$(QMK_BIN) generate-keyboard-h --quiet --keyboard $(KEYBOARD) --include $(FOUND_KEYBOARD_H) --output $(KEYBOARD_OUTPUT)/src/default_keyboard.h)
+ $(eval CMD=$(QMK_BIN) generate-keyboard-h --quiet --keyboard $(KEYBOARD) --include $(FOUND_KEYBOARD_H) --output $(INTERMEDIATE_OUTPUT)/src/default_keyboard.h)
@$(BUILD_CMD)
-generated-files: $(KEYBOARD_OUTPUT)/src/info_config.h $(KEYBOARD_OUTPUT)/src/default_keyboard.c $(KEYBOARD_OUTPUT)/src/default_keyboard.h
+generated-files: $(INTERMEDIATE_OUTPUT)/src/info_config.h $(INTERMEDIATE_OUTPUT)/src/default_keyboard.c $(INTERMEDIATE_OUTPUT)/src/default_keyboard.h
-generated-files: $(KEYMAP_OUTPUT)/src/info_deps.d
+generated-files: $(INTERMEDIATE_OUTPUT)/src/info_deps.d
-$(KEYMAP_OUTPUT)/src/info_deps.d:
+$(INTERMEDIATE_OUTPUT)/src/info_deps.d:
@$(SILENT) || printf "$(MSG_GENERATING) $@" | $(AWK_CMD)
- $(eval CMD=$(QMK_BIN) generate-make-dependencies -kb $(KEYBOARD) -km $(KEYMAP) -o $(KEYMAP_OUTPUT)/src/info_deps.d)
+ $(eval CMD=$(QMK_BIN) generate-make-dependencies -kb $(KEYBOARD) -km $(KEYMAP) -o $(INTERMEDIATE_OUTPUT)/src/info_deps.d)
@$(BUILD_CMD)
--include $(KEYMAP_OUTPUT)/src/info_deps.d
+-include $(INTERMEDIATE_OUTPUT)/src/info_deps.d
.INTERMEDIATE : generated-files
@@ -423,8 +422,7 @@ VPATH += $(KEYMAP_PATH)
VPATH += $(USER_PATH)
VPATH += $(KEYBOARD_PATHS)
VPATH += $(COMMON_VPATH)
-VPATH += $(KEYBOARD_OUTPUT)/src
-VPATH += $(KEYMAP_OUTPUT)/src
+VPATH += $(INTERMEDIATE_OUTPUT)/src
include $(BUILDDEFS_PATH)/common_features.mk
include $(BUILDDEFS_PATH)/generic_features.mk
@@ -471,17 +469,14 @@ PROJECT_CONFIG := $(CONFIG_H)
CONFIG_H += $(POST_CONFIG_H)
ALL_CONFIGS := $(PROJECT_CONFIG) $(CONFIG_H)
-OUTPUTS := $(KEYMAP_OUTPUT) $(KEYBOARD_OUTPUT)
-$(KEYMAP_OUTPUT)_SRC := $(SRC)
-$(KEYMAP_OUTPUT)_DEFS := $(OPT_DEFS) \
--DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYBOARD_H=\"$(KEYBOARD_OUTPUT)/src/default_keyboard.h\" \
--DQMK_KEYMAP=\"$(KEYMAP)\" -DQMK_KEYMAP_H=\"$(KEYMAP).h\" -DQMK_KEYMAP_CONFIG_H=\"$(KEYMAP_PATH)/config.h\"
-$(KEYMAP_OUTPUT)_INC := $(VPATH) $(EXTRAINCDIRS)
-$(KEYMAP_OUTPUT)_CONFIG := $(CONFIG_H)
-$(KEYBOARD_OUTPUT)_SRC := $(PLATFORM_SRC)
-$(KEYBOARD_OUTPUT)_DEFS := $(PROJECT_DEFS)
-$(KEYBOARD_OUTPUT)_INC := $(PROJECT_INC)
-$(KEYBOARD_OUTPUT)_CONFIG := $(PROJECT_CONFIG)
+OUTPUTS := $(INTERMEDIATE_OUTPUT)
+$(INTERMEDIATE_OUTPUT)_SRC := $(SRC) $(PLATFORM_SRC)
+$(INTERMEDIATE_OUTPUT)_DEFS := $(OPT_DEFS) \
+ -DQMK_KEYBOARD=\"$(KEYBOARD)\" -DQMK_KEYBOARD_H=\"$(INTERMEDIATE_OUTPUT)/src/default_keyboard.h\" \
+ -DQMK_KEYMAP=\"$(KEYMAP)\" -DQMK_KEYMAP_H=\"$(KEYMAP).h\" -DQMK_KEYMAP_CONFIG_H=\"$(KEYMAP_PATH)/config.h\" \
+ $(PROJECT_DEFS)
+$(INTERMEDIATE_OUTPUT)_INC := $(VPATH) $(EXTRAINCDIRS) $(PROJECT_INC)
+$(INTERMEDIATE_OUTPUT)_CONFIG := $(CONFIG_H) $(PROJECT_CONFIG)
# Default target.
all: build check-size
diff --git a/builddefs/common_rules.mk b/builddefs/common_rules.mk
index 816eac49ae..5d635307ed 100644
--- a/builddefs/common_rules.mk
+++ b/builddefs/common_rules.mk
@@ -176,7 +176,7 @@ MOVE_DEP = mv -f $(patsubst %.o,%.td,$@) $(patsubst %.o,%.d,$@)
# For a ChibiOS build, ensure that the board files have the hook overrides injected
define BOARDSRC_INJECT_HOOKS
-$(KEYBOARD_OUTPUT)/$(patsubst %.c,%.o,$(patsubst ./%,%,$1)): INIT_HOOK_CFLAGS += -include $(TOP_DIR)/tmk_core/protocol/chibios/init_hooks.h
+$(INTERMEDIATE_OUTPUT)/$(patsubst %.c,%.o,$(patsubst ./%,%,$1)): INIT_HOOK_CFLAGS += -include $(TOP_DIR)/tmk_core/protocol/chibios/init_hooks.h
endef
$(foreach LOBJ, $(BOARDSRC), $(eval $(call BOARDSRC_INJECT_HOOKS,$(LOBJ))))
diff --git a/docs/data_driven_config.md b/docs/data_driven_config.md
index ba287f5688..b288f9901a 100644
--- a/docs/data_driven_config.md
+++ b/docs/data_driven_config.md
@@ -79,8 +79,8 @@ If you are not sure how to edit this file or are not comfortable with Python [op
The final piece of the puzzle is providing your new option to the build system. This is done by generating two files:
-* `.build/obj_<keyboard>/src/info_config.h`
-* `.build/obj_<keyboard>/src/rules.mk`
+* `.build/obj_<keyboard>_<keymap>/src/info_config.h`
+* `.build/obj_<keyboard>_<keymap>/src/rules.mk`
These two files are generated by the code here:
diff --git a/docs/ja/data_driven_config.md b/docs/ja/data_driven_config.md
index bc8f4d24a5..6296173b66 100644
--- a/docs/ja/data_driven_config.md
+++ b/docs/ja/data_driven_config.md
@@ -109,8 +109,8 @@ QMK が完全な `info.json` を生成するときはいつでも、`config.h`
パズルの最後のピースは、ビルドシステムに新しいオプションを提供することです。
これは、2つのファイルを生成することによって行われます。
-* `.build/obj_<keyboard>/src/info_config.h`
-* `.build/obj_<keyboard>/src/rules.mk`
+* `.build/obj_<keyboard>_<keymap>/src/info_config.h`
+* `.build/obj_<keyboard>_<keymap>/src/rules.mk`
この2つのファイルは、次のコードによって生成されます。
diff --git a/lib/python/qmk/cli/mass_compile.py b/lib/python/qmk/cli/mass_compile.py
index 52c1cae4c2..ddd946a32b 100755
--- a/lib/python/qmk/cli/mass_compile.py
+++ b/lib/python/qmk/cli/mass_compile.py
@@ -53,20 +53,22 @@ def mass_compile(cli):
keyboard_name = target[0]
keymap_name = target[1]
keyboard_safe = keyboard_name.replace('/', '_')
+ build_log = f"{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}.{keymap_name}"
+ failed_log = f"{QMK_FIRMWARE}/.build/failed.log.{os.getpid()}.{keyboard_safe}.{keymap_name}"
# yapf: disable
f.write(
f"""\
all: {keyboard_safe}_{keymap_name}_binary
{keyboard_safe}_{keymap_name}_binary:
- @rm -f "{QMK_FIRMWARE}/.build/failed.log.{keyboard_safe}.{keymap_name}" || true
- @echo "Compiling QMK Firmware for target: '{keyboard_name}:{keymap_name}'..." >>"{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}"
+ @rm -f "{build_log}" || true
+ @echo "Compiling QMK Firmware for target: '{keyboard_name}:{keymap_name}'..." >>"{build_log}"
+@$(MAKE) -C "{QMK_FIRMWARE}" -f "{QMK_FIRMWARE}/builddefs/build_keyboard.mk" KEYBOARD="{keyboard_name}" KEYMAP="{keymap_name}" COLOR=true SILENT=false {' '.join(cli.args.env)} \\
- >>"{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}.{keymap_name}" 2>&1 \\
- || cp "{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}.{keymap_name}" "{QMK_FIRMWARE}/.build/failed.log.{os.getpid()}.{keyboard_safe}.{keymap_name}"
- @{{ grep '\[ERRORS\]' "{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}.{keymap_name}" >/dev/null 2>&1 && printf "Build %-64s \e[1;31m[ERRORS]\e[0m\\n" "{keyboard_name}:{keymap_name}" ; }} \\
- || {{ grep '\[WARNINGS\]' "{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}.{keymap_name}" >/dev/null 2>&1 && printf "Build %-64s \e[1;33m[WARNINGS]\e[0m\\n" "{keyboard_name}:{keymap_name}" ; }} \\
+ >>"{build_log}" 2>&1 \\
+ || cp "{build_log}" "{failed_log}"
+ @{{ grep '\[ERRORS\]' "{build_log}" >/dev/null 2>&1 && printf "Build %-64s \e[1;31m[ERRORS]\e[0m\\n" "{keyboard_name}:{keymap_name}" ; }} \\
+ || {{ grep '\[WARNINGS\]' "{build_log}" >/dev/null 2>&1 && printf "Build %-64s \e[1;33m[WARNINGS]\e[0m\\n" "{keyboard_name}:{keymap_name}" ; }} \\
|| printf "Build %-64s \e[1;32m[OK]\e[0m\\n" "{keyboard_name}:{keymap_name}"
- @rm -f "{QMK_FIRMWARE}/.build/build.log.{os.getpid()}.{keyboard_safe}.{keymap_name}" || true
+ @rm -f "{build_log}" || true
"""# noqa
)
# yapf: enable
@@ -77,7 +79,6 @@ all: {keyboard_safe}_{keymap_name}_binary
f"""\
@rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{keymap_name}.elf" 2>/dev/null || true
@rm -rf "{QMK_FIRMWARE}/.build/{keyboard_safe}_{keymap_name}.map" 2>/dev/null || true
- @rm -rf "{QMK_FIRMWARE}/.build/obj_{keyboard_safe}" || true
@rm -rf "{QMK_FIRMWARE}/.build/obj_{keyboard_safe}_{keymap_name}" || true
"""# noqa
)
diff --git a/lib/python/qmk/commands.py b/lib/python/qmk/commands.py
index b1eac13957..ab8e323edf 100644
--- a/lib/python/qmk/commands.py
+++ b/lib/python/qmk/commands.py
@@ -9,7 +9,7 @@ from pathlib import Path
from milc import cli
import jsonschema
-from qmk.constants import KEYBOARD_OUTPUT_PREFIX
+from qmk.constants import INTERMEDIATE_OUTPUT_PREFIX
from qmk.json_schema import json_load, validate
@@ -134,16 +134,13 @@ def compile_configurator_json(user_keymap, bootloader=None, parallel=1, clean=Fa
keyboard_filesafe = user_keymap['keyboard'].replace('/', '_')
target = f'{keyboard_filesafe}_{user_keymap["keymap"]}'
- keyboard_output = Path(f'{KEYBOARD_OUTPUT_PREFIX}{keyboard_filesafe}')
- keymap_output = Path(f'{keyboard_output}_{user_keymap["keymap"]}')
- keymap_dir = keymap_output / 'src'
+ intermediate_output = Path(f'{INTERMEDIATE_OUTPUT_PREFIX}{keyboard_filesafe}_{user_keymap["keymap"]}')
+ keymap_dir = intermediate_output / 'src'
keymap_json = keymap_dir / 'keymap.json'
if clean:
- if keyboard_output.exists():
- shutil.rmtree(keyboard_output)
- if keymap_output.exists():
- shutil.rmtree(keymap_output)
+ if intermediate_output.exists():
+ shutil.rmtree(intermediate_output)
# begin with making the deepest folder in the tree
keymap_dir.mkdir(exist_ok=True, parents=True)
@@ -183,13 +180,12 @@ def compile_configurator_json(user_keymap, bootloader=None, parallel=1, clean=Fa
f'KEYMAP={user_keymap["keymap"]}',
f'KEYBOARD_FILESAFE={keyboard_filesafe}',
f'TARGET={target}',
- f'KEYBOARD_OUTPUT={keyboard_output}',
- f'KEYMAP_OUTPUT={keymap_output}',
- f'MAIN_KEYMAP_PATH_1={keymap_output}',
- f'MAIN_KEYMAP_PATH_2={keymap_output}',
- f'MAIN_KEYMAP_PATH_3={keymap_output}',
- f'MAIN_KEYMAP_PATH_4={keymap_output}',
- f'MAIN_KEYMAP_PATH_5={keymap_output}',
+ f'INTERMEDIATE_OUTPUT={intermediate_output}',
+ f'MAIN_KEYMAP_PATH_1={intermediate_output}',
+ f'MAIN_KEYMAP_PATH_2={intermediate_output}',
+ f'MAIN_KEYMAP_PATH_3={intermediate_output}',
+ f'MAIN_KEYMAP_PATH_4={intermediate_output}',
+ f'MAIN_KEYMAP_PATH_5={intermediate_output}',
f'KEYMAP_JSON={keymap_json}',
f'KEYMAP_PATH={keymap_dir}',
f'VERBOSE={verbose}',
diff --git a/lib/python/qmk/constants.py b/lib/python/qmk/constants.py
index 8a13029a8a..04ec4f6a16 100644
--- a/lib/python/qmk/constants.py
+++ b/lib/python/qmk/constants.py
@@ -123,7 +123,7 @@ ROW_LETTERS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnop'
# Constants that should match their counterparts in make
BUILD_DIR = environ.get('BUILD_DIR', '.build')
-KEYBOARD_OUTPUT_PREFIX = f'{BUILD_DIR}/obj_'
+INTERMEDIATE_OUTPUT_PREFIX = f'{BUILD_DIR}/obj_'
# Headers for generated files
GPL2_HEADER_C_LIKE = f'''\
diff --git a/platforms/chibios/vendors/RP/pico_sdk_shims.c b/platforms/chibios/vendors/RP/pico_sdk_shims.c
index 239155c086..caab400531 100644
--- a/platforms/chibios/vendors/RP/pico_sdk_shims.c
+++ b/platforms/chibios/vendors/RP/pico_sdk_shims.c
@@ -2,7 +2,8 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include <stdbool.h>
-#include <ch.h>
+
+extern void chSysHalt(const char *reason) __attribute__((noreturn));
void panic(const char *fmt, ...) {
chSysHalt(fmt);