From b985de6b7a6f53c2ce1291267fad026eddda912d Mon Sep 17 00:00:00 2001 From: Maschell Date: Wed, 29 Dec 2021 17:15:40 +0100 Subject: [PATCH] Only do logging when building with `make DEBUG=1` --- Makefile | 5 +++++ source/logger.h | 19 +++++++++++++++---- source/main.cpp | 2 ++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 3b21398..d6e6683 100644 --- a/Makefile +++ b/Makefile @@ -38,6 +38,11 @@ LDFLAGS = -g $(ARCH) $(RPXSPECS) --entry=_start -Wl,-Map,$(notdir $*.map) LIBS := -lfreetype -lpng -lbz2 -lwut -lz +ifeq ($(DEBUG),1) +CXXFLAGS += -DDEBUG -g +CCFLAGS += -DDEBUG -g +endif + #------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level # containing include and lib diff --git a/source/logger.h b/source/logger.h index c6fc916..7e11c21 100644 --- a/source/logger.h +++ b/source/logger.h @@ -1,23 +1,34 @@ #pragma once +#include +#include + #ifdef __cplusplus extern "C" { #endif -#include -#include +#ifdef DEBUG #define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__) #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__) #define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \ WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \ - } while (0); + } while (0) #define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \ WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \ - } while (0); + } while (0) + +#else + +#define DEBUG_FUNCTION_LINE(FMT, ARGS...) while (0) + +#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) while (0) + +#endif #ifdef __cplusplus } #endif + diff --git a/source/main.cpp b/source/main.cpp index 3313852..7dc3fca 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -353,10 +353,12 @@ int32_t handleMenuScreen(int32_t autobootOptionInput) { int32_t main(int32_t argc, char **argv) { +#ifdef DEBUG if (!WHBLogModuleInit()) { WHBLogCafeInit(); WHBLogUdpInit(); } +#endif // DEBUG DEBUG_FUNCTION_LINE("Hello from Autoboot"); initExternalStorage();