Only do logging when building with make DEBUG=1

This commit is contained in:
Maschell 2021-12-28 21:00:01 +01:00
parent 86f124baaa
commit 6cbe000c49
3 changed files with 17 additions and 0 deletions

View File

@ -38,6 +38,11 @@ CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__
CXXFLAGS := $(CFLAGS) -std=c++20
ifeq ($(DEBUG),1)
CXXFLAGS += -DDEBUG -g
CCFLAGS += -DDEBUG -g
endif
ASFLAGS := -g $(ARCH)
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map)

View File

@ -55,10 +55,12 @@ extern "C" uint32_t textStart();
std::string EnvironmentSelectionScreen(const std::map<std::string, std::string> &payloads);
int main(int argc, char **argv) {
#ifdef DEBUG
if (!WHBLogModuleInit()) {
WHBLogCafeInit();
WHBLogUdpInit();
}
#endif // DEBUG
DEBUG_FUNCTION_LINE("Hello from EnvironmentLoader!");

View File

@ -7,6 +7,8 @@
extern "C" {
#endif
#ifdef DEBUG
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
@ -18,6 +20,14 @@ extern "C" {
WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
} while (0)
#else
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) while (0)
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) while (0)
#endif
#ifdef __cplusplus
}
#endif