From 34de7ca224d613e1ae19a45860e27c15d40254dd Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Tue, 3 Aug 2021 18:49:33 +0100 Subject: [PATCH] Move print/debug files to quantum (#12069) * move print/debug files to quantum * Update comments --- build_test.mk | 2 +- common_features.mk | 10 +++++++- {tmk_core/common => quantum/logging}/debug.c | 0 {tmk_core/common => quantum/logging}/debug.h | 2 +- .../common => quantum/logging}/nodebug.h | 0 .../printf.c => quantum/logging/print.c | 0 {tmk_core/common => quantum/logging}/print.h | 0 quantum/logging/print.mk | 9 ++++++++ .../logging/sendchar.c | 1 + .../common => quantum/logging}/sendchar.h | 0 tmk_core/common.mk | 13 ++++------- tmk_core/common/lib_printf.mk | 9 -------- tmk_core/common/sendchar_uart.c | 23 ------------------- 13 files changed, 25 insertions(+), 44 deletions(-) rename {tmk_core/common => quantum/logging}/debug.c (100%) rename {tmk_core/common => quantum/logging}/debug.h (98%) rename {tmk_core/common => quantum/logging}/nodebug.h (100%) rename tmk_core/common/printf.c => quantum/logging/print.c (100%) rename {tmk_core/common => quantum/logging}/print.h (100%) create mode 100644 quantum/logging/print.mk rename tmk_core/common/sendchar_null.c => quantum/logging/sendchar.c (94%) rename {tmk_core/common => quantum/logging}/sendchar.h (100%) delete mode 100644 tmk_core/common/lib_printf.mk delete mode 100644 tmk_core/common/sendchar_uart.c diff --git a/build_test.mk b/build_test.mk index 4c09bf0278..b6b8782174 100644 --- a/build_test.mk +++ b/build_test.mk @@ -63,7 +63,7 @@ endif $(TEST)_SRC += \ tests/test_common/main.c \ $(LIB_PATH)/printf/printf.c \ - $(COMMON_DIR)/printf.c + $(QUANTUM_PATH)/logging/print.c $(TEST_OBJ)/$(TEST)_SRC := $($(TEST)_SRC) $(TEST_OBJ)/$(TEST)_INC := $($(TEST)_INC) $(VPATH) $(GTEST_INC) diff --git a/common_features.mk b/common_features.mk index 75a9e1f2eb..15b7b464fd 100644 --- a/common_features.mk +++ b/common_features.mk @@ -21,7 +21,15 @@ QUANTUM_SRC += \ $(QUANTUM_DIR)/bitwise.c \ $(QUANTUM_DIR)/led.c \ $(QUANTUM_DIR)/keymap_common.c \ - $(QUANTUM_DIR)/keycode_config.c + $(QUANTUM_DIR)/keycode_config.c \ + $(QUANTUM_DIR)/logging/debug.c \ + $(QUANTUM_DIR)/logging/sendchar.c \ + +VPATH += $(QUANTUM_DIR)/logging +# Fall back to lib/printf if there is no platform provided print +ifeq ("$(wildcard $(TMK_PATH)/common/$(PLATFORM_KEY)/printf.mk)","") + include $(QUANTUM_PATH)/logging/print.mk +endif ifeq ($(strip $(DEBUG_MATRIX_SCAN_RATE_ENABLE)), yes) OPT_DEFS += -DDEBUG_MATRIX_SCAN_RATE diff --git a/tmk_core/common/debug.c b/quantum/logging/debug.c similarity index 100% rename from tmk_core/common/debug.c rename to quantum/logging/debug.c diff --git a/tmk_core/common/debug.h b/quantum/logging/debug.h similarity index 98% rename from tmk_core/common/debug.h rename to quantum/logging/debug.h index 3d2e2315ef..8415310356 100644 --- a/tmk_core/common/debug.h +++ b/quantum/logging/debug.h @@ -67,7 +67,7 @@ extern debug_config_t debug_config; do { \ if (debug_enable) xprintf(fmt, ##__VA_ARGS__); \ } while (0) -# define dmsg(s) dprintf("%s at %s: %S\n", __FILE__, __LINE__, PSTR(s)) +# define dmsg(s) dprintf("%s at %d: %s\n", __FILE__, __LINE__, s) /* Deprecated. DO NOT USE these anymore, use dprintf instead. */ # define debug(s) \ diff --git a/tmk_core/common/nodebug.h b/quantum/logging/nodebug.h similarity index 100% rename from tmk_core/common/nodebug.h rename to quantum/logging/nodebug.h diff --git a/tmk_core/common/printf.c b/quantum/logging/print.c similarity index 100% rename from tmk_core/common/printf.c rename to quantum/logging/print.c diff --git a/tmk_core/common/print.h b/quantum/logging/print.h similarity index 100% rename from tmk_core/common/print.h rename to quantum/logging/print.h diff --git a/quantum/logging/print.mk b/quantum/logging/print.mk new file mode 100644 index 0000000000..67c004192d --- /dev/null +++ b/quantum/logging/print.mk @@ -0,0 +1,9 @@ +PRINTF_PATH = $(LIB_PATH)/printf + +VPATH += $(PRINTF_PATH) +SRC += $(PRINTF_PATH)/printf.c +QUANTUM_SRC +=$(QUANTUM_DIR)/logging/print.c +OPT_DEFS += -DPRINTF_DISABLE_SUPPORT_FLOAT +OPT_DEFS += -DPRINTF_DISABLE_SUPPORT_EXPONENTIAL +OPT_DEFS += -DPRINTF_DISABLE_SUPPORT_LONG_LONG +OPT_DEFS += -DPRINTF_DISABLE_SUPPORT_PTRDIFF_T diff --git a/tmk_core/common/sendchar_null.c b/quantum/logging/sendchar.c similarity index 94% rename from tmk_core/common/sendchar_null.c rename to quantum/logging/sendchar.c index fb67f70866..9422382f6f 100644 --- a/tmk_core/common/sendchar_null.c +++ b/quantum/logging/sendchar.c @@ -16,4 +16,5 @@ along with this program. If not, see . */ #include "sendchar.h" +/* default noop "null" implementation */ __attribute__((weak)) int8_t sendchar(uint8_t c) { return 0; } diff --git a/tmk_core/common/sendchar.h b/quantum/logging/sendchar.h similarity index 100% rename from tmk_core/common/sendchar.h rename to quantum/logging/sendchar.h diff --git a/tmk_core/common.mk b/tmk_core/common.mk index 2f8f81126a..bd4142364c 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk @@ -8,22 +8,16 @@ TMK_COMMON_SRC += $(COMMON_DIR)/host.c \ $(COMMON_DIR)/action_macro.c \ $(COMMON_DIR)/action_layer.c \ $(COMMON_DIR)/action_util.c \ - $(COMMON_DIR)/debug.c \ - $(COMMON_DIR)/sendchar_null.c \ $(COMMON_DIR)/eeconfig.c \ $(COMMON_DIR)/report.c \ + $(COMMON_DIR)/sync_timer.c \ $(COMMON_DIR)/usb_util.c \ $(PLATFORM_COMMON_DIR)/suspend.c \ $(PLATFORM_COMMON_DIR)/timer.c \ - $(COMMON_DIR)/sync_timer.c \ $(PLATFORM_COMMON_DIR)/bootloader.c \ -# Use platform provided print - fall back to lib/printf -ifneq ("$(wildcard $(TMK_PATH)/$(PLATFORM_COMMON_DIR)/printf.mk)","") - include $(TMK_PATH)/$(PLATFORM_COMMON_DIR)/printf.mk -else - include $(TMK_PATH)/$(COMMON_DIR)/lib_printf.mk -endif +# Use platform provided print if it exists +-include $(TMK_PATH)/$(PLATFORM_COMMON_DIR)/printf.mk SHARED_EP_ENABLE = no MOUSE_SHARED_EP ?= yes @@ -55,6 +49,7 @@ endif ifeq ($(strip $(CONSOLE_ENABLE)), yes) TMK_COMMON_DEFS += -DCONSOLE_ENABLE else + # TODO: decouple this so other print backends can exist TMK_COMMON_DEFS += -DNO_PRINT TMK_COMMON_DEFS += -DNO_DEBUG endif diff --git a/tmk_core/common/lib_printf.mk b/tmk_core/common/lib_printf.mk deleted file mode 100644 index 10d2d8468d..0000000000 --- a/tmk_core/common/lib_printf.mk +++ /dev/null @@ -1,9 +0,0 @@ -PRINTF_PATH = $(LIB_PATH)/printf - -TMK_COMMON_SRC += $(PRINTF_PATH)/printf.c -TMK_COMMON_SRC += $(COMMON_DIR)/printf.c -TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_FLOAT -TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_EXPONENTIAL -TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_LONG_LONG -TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_PTRDIFF_T -VPATH += $(PRINTF_PATH) diff --git a/tmk_core/common/sendchar_uart.c b/tmk_core/common/sendchar_uart.c deleted file mode 100644 index 2fc48bafff..0000000000 --- a/tmk_core/common/sendchar_uart.c +++ /dev/null @@ -1,23 +0,0 @@ -/* -Copyright 2011 Jun Wako - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -#include "uart.h" -#include "sendchar.h" - -int8_t sendchar(uint8_t c) { - uart_putchar(c); - return 0; -}