Only do logging when building with make DEBUG=1

This commit is contained in:
Maschell 2021-12-29 17:15:40 +01:00
parent fb5cf55dd6
commit b985de6b7a
3 changed files with 22 additions and 4 deletions

View File

@ -38,6 +38,11 @@ LDFLAGS = -g $(ARCH) $(RPXSPECS) --entry=_start -Wl,-Map,$(notdir $*.map)
LIBS := -lfreetype -lpng -lbz2 -lwut -lz 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 # list of directories containing libraries, this must be the top level
# containing include and lib # containing include and lib

View File

@ -1,23 +1,34 @@
#pragma once #pragma once
#include <whb/log.h>
#include <string.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include <cstring> #ifdef DEBUG
#include <whb/log.h>
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__) #define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__) #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \ #define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \ WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
} while (0); } while (0)
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \ #define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \
WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \ 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 #ifdef __cplusplus
} }
#endif #endif

View File

@ -353,10 +353,12 @@ int32_t handleMenuScreen(int32_t autobootOptionInput) {
int32_t main(int32_t argc, char **argv) { int32_t main(int32_t argc, char **argv) {
#ifdef DEBUG
if (!WHBLogModuleInit()) { if (!WHBLogModuleInit()) {
WHBLogCafeInit(); WHBLogCafeInit();
WHBLogUdpInit(); WHBLogUdpInit();
} }
#endif // DEBUG
DEBUG_FUNCTION_LINE("Hello from Autoboot"); DEBUG_FUNCTION_LINE("Hello from Autoboot");
initExternalStorage(); initExternalStorage();