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
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

View File

@ -1,23 +1,34 @@
#pragma once
#include <whb/log.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <cstring>
#include <whb/log.h>
#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

View File

@ -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();