From 54d85f487cfadeb72a0cd19734f5a1a97b749df3 Mon Sep 17 00:00:00 2001 From: dbalatoni13 <40299962+dbalatoni13@users.noreply.github.com> Date: Tue, 8 Apr 2025 17:12:51 +0200 Subject: [PATCH] Split off the DOL to improve the build process --- CMakeLists.txt | 32 +++++++++++++++++++++----------- dol.def | 1 + include/version.h | 2 +- src/game/frand.c | 2 +- src/game/main.c | 2 +- src/port/portmain.c | 7 +++++++ 6 files changed, 32 insertions(+), 14 deletions(-) create mode 100644 src/port/portmain.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 59e13d23..ec1cc87c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,8 @@ endif () set(CMAKE_C_STANDARD 11) set(CMAKE_CXX_STANDARD 20) +set(VERSION 0) + # Set build type to Debug if not specified if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) @@ -106,20 +108,28 @@ set_source_files_properties(${file} PROPERTIES COMPILE_FLAGS "-std=c89 -Dinline= endforeach() endif () -# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic") -add_executable(marioparty4 ${DOLPHIN_FILES} ${GAME_FILES} ${PORT_FILES}) -set_property(TARGET marioparty4 PROPERTY ENABLE_EXPORTS ON) -target_compile_definitions(marioparty4 PRIVATE TARGET_PC VERSION=0 TARGET_MAIN) -target_compile_definitions(musyx PRIVATE MUSY_VERSION_MAJOR=1 MUSY_VERSION_MINOR=5 MUSY_VERSION_PATCH=4) -target_include_directories(marioparty4 PRIVATE include build/GMPE01_00/include) +add_library(dol SHARED ${DOLPHIN_FILES} ${GAME_FILES} ${PORT_FILES}) +target_compile_definitions(dol PRIVATE TARGET_PC TARGET_DOL VERSION=${VERSION} MUSY_VERSION_MAJOR=1 MUSY_VERSION_MINOR=5 MUSY_VERSION_PATCH=4) +target_include_directories(dol PRIVATE include build/GMPE01_00/include) +target_link_libraries(dol PRIVATE aurora::core aurora::gx aurora::vi musyx) if (MSVC) -target_link_options(marioparty4 PRIVATE "/DEF:${CMAKE_SOURCE_DIR}/dol.def") -endif () -target_link_libraries(marioparty4 PRIVATE aurora::core aurora::gx aurora::vi aurora::main musyx) +target_link_options(dol PRIVATE "/DEF:${CMAKE_SOURCE_DIR}/dol.def") +else () +target_compile_options(dol PRIVATE "-fvisibility=default") +endif() add_library(bootDll SHARED src/REL/bootDll/main.c src/REL/bootDll/language.c) -target_compile_definitions(bootDll PRIVATE TARGET_PC VERSION=0 TARGET_REL) +target_compile_definitions(bootDll PRIVATE TARGET_PC VERSION=${VERSION}) target_include_directories(bootDll PRIVATE include build/GMPE01_00/include) +if (MSVC) set_target_properties(bootDll PROPERTIES LINK_FLAGS "/EXPORT:ObjectSetup") -target_link_libraries(bootDll PRIVATE musyx marioparty4) +else () +endif() +set(CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS OFF) +target_link_libraries(bootDll PRIVATE dol musyx) + +add_executable(marioparty4 src/port/portmain.c) +target_compile_definitions(marioparty4 PRIVATE TARGET_PC VERSION=${VERSION}) +target_include_directories(marioparty4 PRIVATE include) +target_link_libraries(marioparty4 PRIVATE dol aurora::main) diff --git a/dol.def b/dol.def index 65325067..941749d0 100644 --- a/dol.def +++ b/dol.def @@ -1,4 +1,5 @@ EXPORTS + game_main byteswap_u32 byteswap_s32 OSReport diff --git a/include/version.h b/include/version.h index de3a0e84..8a25ab40 100644 --- a/include/version.h +++ b/include/version.h @@ -22,7 +22,7 @@ #endif #if _WIN32 -#ifdef TARGET_MAIN +#ifdef TARGET_DOL #define SHARED_SYM __declspec(dllexport) #else #define SHARED_SYM __declspec(dllimport) diff --git a/src/game/frand.c b/src/game/frand.c index d997320f..5d1407f9 100644 --- a/src/game/frand.c +++ b/src/game/frand.c @@ -2,7 +2,7 @@ static u32 frand_seed; - extern s32 rand8(void); +extern s32 rand8(void); static inline u32 frandom(u32 param) { diff --git a/src/game/main.c b/src/game/main.c index 03394e18..b25ef144 100644 --- a/src/game/main.c +++ b/src/game/main.c @@ -87,7 +87,7 @@ void aurora_log_callback(AuroraLogLevel level, const char* module, const char *m #endif #ifdef TARGET_PC -int main(int argc, char *argv[]) +int game_main(int argc, char *argv[]) #else void main(void) #endif diff --git a/src/port/portmain.c b/src/port/portmain.c new file mode 100644 index 00000000..c024bd18 --- /dev/null +++ b/src/port/portmain.c @@ -0,0 +1,7 @@ +int game_main(int argc, char *argv[]); + + +int main(int argc, char *argv[]) +{ + game_main(argc, argv); +}