34de7ca224d613e1ae19a45860e27c15d40254dd

Author
Joel Challis <git@zvecr.com>
Committer
GitHub <noreply@github.com>
Date

Message

Move print/debug files to quantum (#12069)

* move print/debug files to quantum

* Update comments

Diff

  1diff --git a/build_test.mk b/build_test.mk
  2index 4c09bf0278e960453940b53fa5de2644e1bf5448..b6b8782174d36ac99ff406fa0257f8292d76e2b7 100644
  3--- a/build_test.mk
  4+++ b/build_test.mk
  5@@ -63,7 +63,7 @@ endif
  6 $(TEST)_SRC += \
  7 	tests/test_common/main.c \
  8 	$(LIB_PATH)/printf/printf.c \
  9-	$(COMMON_DIR)/printf.c
 10+	$(QUANTUM_PATH)/logging/print.c
 11 
 12 $(TEST_OBJ)/$(TEST)_SRC := $($(TEST)_SRC)
 13 $(TEST_OBJ)/$(TEST)_INC := $($(TEST)_INC) $(VPATH) $(GTEST_INC)
 14diff --git a/common_features.mk b/common_features.mk
 15index 75a9e1f2eba6dd11a4cc6c6f4d3dc09b2736b21d..15b7b464fd43b9569ec33e41d2bb09191060a3eb 100644
 16--- a/common_features.mk
 17+++ b/common_features.mk
 18@@ -21,7 +21,15 @@ QUANTUM_SRC += \
 19     $(QUANTUM_DIR)/bitwise.c \
 20     $(QUANTUM_DIR)/led.c \
 21     $(QUANTUM_DIR)/keymap_common.c \
 22-    $(QUANTUM_DIR)/keycode_config.c
 23+    $(QUANTUM_DIR)/keycode_config.c \
 24+    $(QUANTUM_DIR)/logging/debug.c \
 25+    $(QUANTUM_DIR)/logging/sendchar.c \
 26+
 27+VPATH += $(QUANTUM_DIR)/logging
 28+# Fall back to lib/printf if there is no platform provided print
 29+ifeq ("$(wildcard $(TMK_PATH)/common/$(PLATFORM_KEY)/printf.mk)","")
 30+    include $(QUANTUM_PATH)/logging/print.mk
 31+endif
 32 
 33 ifeq ($(strip $(DEBUG_MATRIX_SCAN_RATE_ENABLE)), yes)
 34     OPT_DEFS += -DDEBUG_MATRIX_SCAN_RATE
 35diff --git a/tmk_core/common/debug.c b/quantum/logging/debug.c
 36rename from tmk_core/common/debug.c
 37rename to quantum/logging/debug.c
 38diff --git a/tmk_core/common/debug.h b/quantum/logging/debug.h
 39rename from tmk_core/common/debug.h
 40rename to quantum/logging/debug.h
 41index 3d2e2315effcc5a5c1f4b05e5c837255a3aab802..841531035691541a1e262f367b2e2d2c5b1fd39e 100644
 42--- a/tmk_core/common/debug.h
 43+++ b/quantum/logging/debug.h
 44@@ -67,7 +67,7 @@ extern debug_config_t debug_config;
 45         do {                                               \
 46             if (debug_enable) xprintf(fmt, ##__VA_ARGS__); \
 47         } while (0)
 48-#    define dmsg(s) dprintf("%s at %s: %S\n", __FILE__, __LINE__, PSTR(s))
 49+#    define dmsg(s) dprintf("%s at %d: %s\n", __FILE__, __LINE__, s)
 50 
 51 /* Deprecated. DO NOT USE these anymore, use dprintf instead. */
 52 #    define debug(s)                    \
 53diff --git a/tmk_core/common/nodebug.h b/quantum/logging/nodebug.h
 54rename from tmk_core/common/nodebug.h
 55rename to quantum/logging/nodebug.h
 56diff --git a/tmk_core/common/printf.c b/quantum/logging/print.c
 57rename from tmk_core/common/printf.c
 58rename to quantum/logging/print.c
 59diff --git a/tmk_core/common/print.h b/quantum/logging/print.h
 60rename from tmk_core/common/print.h
 61rename to quantum/logging/print.h
 62diff --git a/quantum/logging/print.mk b/quantum/logging/print.mk
 63new file mode 100644
 64index 0000000000000000000000000000000000000000..67c004192d899d5c43589daa9d45cb82e3112e91
 65--- /dev/null
 66+++ b/quantum/logging/print.mk
 67@@ -0,0 +1,9 @@
 68+PRINTF_PATH = $(LIB_PATH)/printf
 69+
 70+VPATH += $(PRINTF_PATH)
 71+SRC += $(PRINTF_PATH)/printf.c
 72+QUANTUM_SRC +=$(QUANTUM_DIR)/logging/print.c
 73+OPT_DEFS += -DPRINTF_DISABLE_SUPPORT_FLOAT
 74+OPT_DEFS += -DPRINTF_DISABLE_SUPPORT_EXPONENTIAL
 75+OPT_DEFS += -DPRINTF_DISABLE_SUPPORT_LONG_LONG
 76+OPT_DEFS += -DPRINTF_DISABLE_SUPPORT_PTRDIFF_T
 77diff --git a/tmk_core/common/sendchar_null.c b/quantum/logging/sendchar.c
 78rename from tmk_core/common/sendchar_null.c
 79rename to quantum/logging/sendchar.c
 80index fb67f70866adb408f40cd47cf375ac6165db57cc..9422382f6f9f53afd075518d255881e8749ac913 100644
 81--- a/tmk_core/common/sendchar_null.c
 82+++ b/quantum/logging/sendchar.c
 83@@ -16,4 +16,5 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 84 */
 85 #include "sendchar.h"
 86 
 87+/* default noop "null" implementation */
 88 __attribute__((weak)) int8_t sendchar(uint8_t c) { return 0; }
 89diff --git a/tmk_core/common/sendchar.h b/quantum/logging/sendchar.h
 90rename from tmk_core/common/sendchar.h
 91rename to quantum/logging/sendchar.h
 92diff --git a/tmk_core/common.mk b/tmk_core/common.mk
 93index 2f8f81126ab6f765049aba5ce9464367a87d0896..bd4142364c54a5a8333f5cd52116e773a0443690 100644
 94--- a/tmk_core/common.mk
 95+++ b/tmk_core/common.mk
 96@@ -8,22 +8,16 @@ TMK_COMMON_SRC +=	$(COMMON_DIR)/host.c \
 97 	$(COMMON_DIR)/action_macro.c \
 98 	$(COMMON_DIR)/action_layer.c \
 99 	$(COMMON_DIR)/action_util.c \
100-	$(COMMON_DIR)/debug.c \
101-	$(COMMON_DIR)/sendchar_null.c \
102 	$(COMMON_DIR)/eeconfig.c \
103 	$(COMMON_DIR)/report.c \
104+	$(COMMON_DIR)/sync_timer.c \
105 	$(COMMON_DIR)/usb_util.c \
106 	$(PLATFORM_COMMON_DIR)/suspend.c \
107 	$(PLATFORM_COMMON_DIR)/timer.c \
108-	$(COMMON_DIR)/sync_timer.c \
109 	$(PLATFORM_COMMON_DIR)/bootloader.c \
110 
111-# Use platform provided print - fall back to lib/printf
112-ifneq ("$(wildcard $(TMK_PATH)/$(PLATFORM_COMMON_DIR)/printf.mk)","")
113-    include $(TMK_PATH)/$(PLATFORM_COMMON_DIR)/printf.mk
114-else
115-    include $(TMK_PATH)/$(COMMON_DIR)/lib_printf.mk
116-endif
117+# Use platform provided print if it exists
118+-include $(TMK_PATH)/$(PLATFORM_COMMON_DIR)/printf.mk
119 
120 SHARED_EP_ENABLE = no
121 MOUSE_SHARED_EP ?= yes
122@@ -55,6 +49,7 @@ endif
123 ifeq ($(strip $(CONSOLE_ENABLE)), yes)
124     TMK_COMMON_DEFS += -DCONSOLE_ENABLE
125 else
126+    # TODO: decouple this so other print backends can exist
127     TMK_COMMON_DEFS += -DNO_PRINT
128     TMK_COMMON_DEFS += -DNO_DEBUG
129 endif
130diff --git a/tmk_core/common/lib_printf.mk b/tmk_core/common/lib_printf.mk
131deleted file mode 100644
132index 10d2d8468d959e832ef42aca6eccb994d2049c15..0000000000000000000000000000000000000000
133--- a/tmk_core/common/lib_printf.mk
134+++ /dev/null
135@@ -1,9 +0,0 @@
136-PRINTF_PATH = $(LIB_PATH)/printf
137-
138-TMK_COMMON_SRC += $(PRINTF_PATH)/printf.c
139-TMK_COMMON_SRC += $(COMMON_DIR)/printf.c
140-TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_FLOAT
141-TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_EXPONENTIAL
142-TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_LONG_LONG
143-TMK_COMMON_DEFS += -DPRINTF_DISABLE_SUPPORT_PTRDIFF_T
144-VPATH += $(PRINTF_PATH)
145diff --git a/tmk_core/common/sendchar_uart.c b/tmk_core/common/sendchar_uart.c
146deleted file mode 100644
147index 2fc48bafffbc3f5427f4c296ffd661f25c335b31..0000000000000000000000000000000000000000
148--- a/tmk_core/common/sendchar_uart.c
149+++ /dev/null
150@@ -1,23 +0,0 @@
151-/*
152-Copyright 2011 Jun Wako <wakojun@gmail.com>
153-
154-This program is free software: you can redistribute it and/or modify
155-it under the terms of the GNU General Public License as published by
156-the Free Software Foundation, either version 2 of the License, or
157-(at your option) any later version.
158-
159-This program is distributed in the hope that it will be useful,
160-but WITHOUT ANY WARRANTY; without even the implied warranty of
161-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
162-GNU General Public License for more details.
163-
164-You should have received a copy of the GNU General Public License
165-along with this program.  If not, see <http://www.gnu.org/licenses/>.
166-*/
167-#include "uart.h"
168-#include "sendchar.h"
169-
170-int8_t sendchar(uint8_t c) {
171-    uart_putchar(c);
172-    return 0;
173-}