Fix building with make DEBUG=1

This commit is contained in:
Maschell 2022-01-30 20:38:48 +01:00
parent e84fcd6861
commit ca32972134
4 changed files with 68 additions and 65 deletions

View File

@ -31,7 +31,7 @@ INCLUDES := src
#-------------------------------------------------------------------------------
# options for code generation
#-------------------------------------------------------------------------------
CFLAGS := -g -Wall -O2 -ffunction-sections \
CFLAGS := -Wall -O2 -ffunction-sections \
$(MACHDEP)
CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ -D__WUPS__
@ -41,6 +41,11 @@ CXXFLAGS := $(CFLAGS)
ASFLAGS := -g $(ARCH)
LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) -T$(WUMS_ROOT)/share/librpxloader.ld $(WUPSSPECS)
ifeq ($(DEBUG),1)
CXXFLAGS += -DDEBUG -g
CFLAGS += -DDEBUG -g
endif
LIBS := -lwups -lwut -lrpxloader
#-------------------------------------------------------------------------------

View File

@ -12,9 +12,6 @@
#include "utils/StringTools.h"
#include <fs/DirList.h>
#include "fileinfos.h"
#include <whb/log_module.h>
#include <whb/log_udp.h>
#include <whb/log_cafe.h>
#include <rpxloader.h>
#include "fs/FSUtils.h"
#include "filelist.h"
@ -60,10 +57,7 @@ INITIALIZE_PLUGIN() {
}
ON_APPLICATION_START() {
if(!WHBLogModuleInit()){
WHBLogCafeInit();
WHBLogUdpInit();
}
initLogging();
if (OSGetTitleID() == 0x0005001010040000L || // Wii U Menu JPN
OSGetTitleID() == 0x0005001010040100L || // Wii U Menu USA
@ -78,50 +72,8 @@ ON_APPLICATION_START() {
doReboot = false;
}
DECL_FUNCTION(void, GX2SwapScanBuffers, void) {
real_GX2SwapScanBuffers();
if (OSGetTitleID() != 0x0005001010040000L && // Wii U Menu JPN
OSGetTitleID() != 0x0005001010040100L && // Wii U Menu USA
OSGetTitleID() != 0x0005001010040200L) { // Wii U Menu ERU
return;
}
if (doReboot) {
return;
}
if (++sd_check_cooldown < 120) {
return;
}
sd_check_cooldown = 0;
DIR *dir;
dir = opendir("fs:/vol/external01/");
if (dir == nullptr) {
if (!lastResult) {
FSCmdBlock cmd;
FSMountSource mountSource;
FSStatus result;
FSInitCmdBlock(&cmd);
result = FSGetMountSource(__wut_devoptab_fs_client, &cmd, FS_MOUNT_SOURCE_SD, &mountSource, FS_ERROR_FLAG_ALL);
if (result >= 0) {
DEBUG_FUNCTION_LINE("SD mount successful");
_SYSLaunchTitleWithStdArgsInNoSplash(OSGetTitleID(), 0);
doReboot = true;
}
return;
} else {
lastResult = false;
DEBUG_FUNCTION_LINE("SD was ejected");
_SYSLaunchTitleWithStdArgsInNoSplash(OSGetTitleID(), 0);
doReboot = true;
return;
}
}
// DEBUG_FUNCTION_LINE("SD is mounted");
closedir(dir);
lastResult = true;
ON_APPLICATION_ENDS() {
deinitLogging();
}
void fillXmlForTitleID(uint32_t titleid_upper, uint32_t titleid_lower, ACPMetaXml *out_buf) {
@ -274,7 +226,7 @@ void readCustomTitlesFromSD() {
} while (offset < sizeof(ini_buffer));
if (ini_parse_string(ini_buffer, handler, &gFileInfos[j]) < 0) {
DEBUG_FUNCTION_LINE("Failed to parse ini")
DEBUG_FUNCTION_LINE("Failed to parse ini");
}
RL_FileClose(file_handle);
@ -610,6 +562,4 @@ WUPS_MUST_REPLACE(FSReadFile, WUPS_LOADER_LIBRARY_COREINIT, FSReadFile);
WUPS_MUST_REPLACE(FSOpenFile, WUPS_LOADER_LIBRARY_COREINIT, FSOpenFile);
WUPS_MUST_REPLACE(FSCloseFile, WUPS_LOADER_LIBRARY_COREINIT, FSCloseFile);
WUPS_MUST_REPLACE(GX2SwapScanBuffers, WUPS_LOADER_LIBRARY_GX2, GX2SwapScanBuffers);
WUPS_MUST_REPLACE_PHYSICAL(MCPGetTitleInternal, (0x3001C400 + 0x0205a590), (0x0205a590 - 0xFE3C00));

36
src/utils/logger.c Normal file
View File

@ -0,0 +1,36 @@
#ifdef DEBUG
#include <stdint.h>
#include <whb/log_udp.h>
#include <whb/log_cafe.h>
#include <whb/log_module.h>
uint32_t moduleLogInit = false;
uint32_t cafeLogInit = false;
uint32_t udpLogInit = false;
#endif // DEBUG
void initLogging() {
#ifdef DEBUG
if (!(moduleLogInit = WHBLogModuleInit())) {
cafeLogInit = WHBLogCafeInit();
udpLogInit = WHBLogUdpInit();
}
#endif // DEBUG
}
void deinitLogging() {
#ifdef DEBUG
if (moduleLogInit) {
WHBLogModuleDeinit();
moduleLogInit = false;
}
if (cafeLogInit) {
WHBLogCafeDeinit();
cafeLogInit = false;
}
if (udpLogInit) {
WHBLogUdpDeinit();
udpLogInit = false;
}
#endif // DEBUG
}

View File

@ -1,30 +1,42 @@
#ifndef __LOGGER_H_
#define __LOGGER_H_
#pragma once
#include <whb/log.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <string.h>
#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 OSFATAL_FUNCTION_LINE(FMT, ARGS...)do { \
OSFatal_printf("[%s]%s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
} while (0)
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
#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_VERBOSE(FMT, ARGS...) while (0)
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) while (0)
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) while (0)
#endif
void initLogging();
void deinitLogging();
#ifdef __cplusplus
}
#endif
#endif