From daaca848379628caebe09f97fafaf9522ab09b0a Mon Sep 17 00:00:00 2001 From: MrRealistic-Mods Date: Sun, 21 Jun 2026 23:14:02 +0530 Subject: [PATCH 01/10] Add optional CMake cross-build support for Clang/MinGW on Linux. Keeps existing MSVC/Premake workflow unchanged. Adds toolchain files and portable source fixes needed for Clang builds. --- .gitignore | 1 + CMakeLists.txt | 250 ++++++++++++++++++ injector/assembly.hpp | 2 +- injector/injector.hpp | 2 +- modutils/Trampoline.h | 1 + plugin_II/game_II/CSprite.cpp | 2 +- .../game_III/CControllerConfigManager.h | 3 + plugin_III/game_III/CModelInfo.cpp | 6 +- plugin_III/game_III/meta/meta.CModelInfo.h | 2 +- plugin_IV/game_IV/CCam.h | 4 + plugin_IV/game_IV/CCamScriptInstruction.h | 3 + plugin_sa/game_sa/rw/rtanim.h | 2 +- plugin_sa_unreal/game_sa_unreal/rw/rtanim.h | 2 +- plugin_vc/game_vc/rw/rtanim.h | 2 +- plugin_vc_unreal/game_vc_unreal/rw/rtanim.h | 2 +- shared/DynAddress.cpp | 2 +- shared/Other.cpp | 2 +- shared/plugin.rc | Bin 4652 -> 2226 bytes toolchain-clang32.cmake | 24 ++ toolchain-clang64.cmake | 24 ++ 20 files changed, 323 insertions(+), 13 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 toolchain-clang32.cmake create mode 100644 toolchain-clang64.cmake diff --git a/.gitignore b/.gitignore index 238b2d224..15156ec6c 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ generated/ .metadata bin/ +build64/ tmp/ *.tmp *.bak diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..3bab35bc2 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,250 @@ +cmake_minimum_required(VERSION 3.15) +project(plugin-sdk LANGUAGES C CXX RC) + +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE) +endif() + +# C++23 standard +set(CMAKE_CXX_STANDARD 23) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS ON) + +option(BUILD_CLASSIC "Build classic 32-bit targets" ON) +option(BUILD_UNREAL "Build Unreal 64-bit targets" ON) + +# Suppress warnings that are expected in this MSVC game modding SDK +add_compile_options( + -Wno-invalid-offsetof # offsetof on non-standard-layout types (game structures) + -Wno-pragma-pack # MSVC-style #pragma pack usage + -Wno-microsoft-cast # MSVC-specific casts + -Wno-reinterpret-base-class # common in game hook code + -Wno-unused-private-field # padding fields in game structures + -Wno-unused-variable + -Wno-missing-field-initializers + -Wno-ignored-pragma-intrinsic # MSVC #pragma intrinsic +) + +# Common include directories +set(COMMON_INCLUDES + ${CMAKE_CURRENT_SOURCE_DIR}/shared + ${CMAKE_CURRENT_SOURCE_DIR}/shared/game + ${CMAKE_CURRENT_SOURCE_DIR}/shared/dxsdk + ${CMAKE_CURRENT_SOURCE_DIR}/safetyhook + ${CMAKE_CURRENT_SOURCE_DIR}/injector + ${CMAKE_CURRENT_SOURCE_DIR}/hooking +) + +# Common source files +file(GLOB_RECURSE COMMON_SOURCES + "shared/*.cpp" + "shared/*.c" + "shared/*.rc" + "hooking/*.cpp" + "safetyhook/*.cpp" + "safetyhook/*.c" +) + +if(BUILD_CLASSIC) +# --- Plugin_SA (GTA San Andreas) --- +file(GLOB_RECURSE SA_SOURCES + "plugin_sa/*.cpp" +) +add_library(Plugin_SA STATIC ${COMMON_SOURCES} ${SA_SOURCES}) +target_include_directories(Plugin_SA PUBLIC + ${COMMON_INCLUDES} + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_sa + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_sa/game_sa + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_sa/game_sa/enums + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_sa/game_sa/rw +) +target_compile_definitions(Plugin_SA PUBLIC + GTASA + PLUGIN_SGV_10US + RW + _DX9_SDK_INSTALLED +) + +# --- Plugin_VC (GTA Vice City) --- +file(GLOB_RECURSE VC_SOURCES + "plugin_vc/*.cpp" +) +add_library(Plugin_VC STATIC ${COMMON_SOURCES} ${VC_SOURCES}) +target_include_directories(Plugin_VC PUBLIC + ${COMMON_INCLUDES} + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_vc + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_vc/game_vc + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_vc/game_vc/enums + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_vc/game_vc/rw +) +target_compile_definitions(Plugin_VC PUBLIC + GTAVC + PLUGIN_SGV_10EN + RW + _DX9_SDK_INSTALLED +) + +# --- Plugin_III (GTA III) --- +file(GLOB_RECURSE III_SOURCES + "plugin_III/*.cpp" +) +add_library(Plugin_III STATIC ${COMMON_SOURCES} ${III_SOURCES}) +target_include_directories(Plugin_III PUBLIC + ${COMMON_INCLUDES} + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_III + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_III/game_III + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_III/game_III/enums + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_III/game_III/rw +) +target_compile_definitions(Plugin_III PUBLIC + GTA3 + PLUGIN_SGV_10EN + RW + _DX9_SDK_INSTALLED +) + +# --- Plugin_II (GTA II) --- +file(GLOB_RECURSE II_SOURCES + "plugin_II/*.cpp" +) +add_library(Plugin_II STATIC ${COMMON_SOURCES} ${II_SOURCES}) +target_include_directories(Plugin_II PUBLIC + ${COMMON_INCLUDES} + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_II + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_II/game_II +) +target_compile_definitions(Plugin_II PUBLIC + GTA2 + PLUGIN_SGV_96EN + GBH + _DX9_SDK_INSTALLED +) + +# --- Plugin_IV (GTA IV) --- +file(GLOB_RECURSE IV_SOURCES + "plugin_IV/*.cpp" +) +add_library(Plugin_IV STATIC ${COMMON_SOURCES} ${IV_SOURCES}) +target_include_directories(Plugin_IV PUBLIC + ${COMMON_INCLUDES} + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_IV + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_IV/game_IV +) +target_compile_definitions(Plugin_IV PUBLIC + GTAIV + PLUGIN_SGV_CE + RAGE + _DX9_SDK_INSTALLED +) +endif() + +if(BUILD_UNREAL) +# --- Plugin_III_Unreal (GTA III Unreal) --- +file(GLOB_RECURSE III_UNREAL_SOURCES + "plugin_iii_unreal/*.cpp" +) +add_library(Plugin_III_Unreal STATIC ${COMMON_SOURCES} ${III_UNREAL_SOURCES}) +target_include_directories(Plugin_III_Unreal PUBLIC + ${COMMON_INCLUDES} + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_iii_unreal + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_iii_unreal/game_iii_unreal + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_iii_unreal/game_iii_unreal/rw +) +target_compile_definitions(Plugin_III_Unreal PUBLIC + _WIN64 + GTA3_UNREAL + PLUGIN_UNREAL + UNREAL + NOASM + RWINT32FROMFLOAT + _CRT_NON_CONFORMING_SWPRINTFS + _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING + _DX9_SDK_INSTALLED +) + +# --- Plugin_SA_Unreal (GTA San Andreas Unreal) --- +file(GLOB_RECURSE SA_UNREAL_SOURCES + "plugin_sa_unreal/*.cpp" +) +add_library(Plugin_SA_Unreal STATIC ${COMMON_SOURCES} ${SA_UNREAL_SOURCES}) +target_include_directories(Plugin_SA_Unreal PUBLIC + ${COMMON_INCLUDES} + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_sa_unreal + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_sa_unreal/game_sa_unreal + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_sa_unreal/game_sa_unreal/rw +) +target_compile_definitions(Plugin_SA_Unreal PUBLIC + _WIN64 + GTASA_UNREAL + PLUGIN_UNREAL + UNREAL + NOASM + RWINT32FROMFLOAT + _CRT_NON_CONFORMING_SWPRINTFS + _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING + _DX9_SDK_INSTALLED +) + +# --- Plugin_VC_Unreal (GTA Vice City Unreal) --- +file(GLOB_RECURSE VC_UNREAL_SOURCES + "plugin_vc_unreal/*.cpp" +) +add_library(Plugin_VC_Unreal STATIC ${COMMON_SOURCES} ${VC_UNREAL_SOURCES}) +target_include_directories(Plugin_VC_Unreal PUBLIC + ${COMMON_INCLUDES} + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_vc_unreal + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_vc_unreal/game_vc_unreal + ${CMAKE_CURRENT_SOURCE_DIR}/plugin_vc_unreal/game_vc_unreal/rw +) +target_compile_definitions(Plugin_VC_Unreal PUBLIC + _WIN64 + GTAVC_UNREAL + PLUGIN_UNREAL + UNREAL + NOASM + RWINT32FROMFLOAT + _CRT_NON_CONFORMING_SWPRINTFS + _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING + _DX9_SDK_INSTALLED +) +endif() + +# --- Unified Target Output Properties (Match original MSVC naming in MinGW format) --- +set(ALL_TARGETS) +if(BUILD_CLASSIC) + list(APPEND ALL_TARGETS + Plugin_II + Plugin_III + Plugin_IV + Plugin_SA + Plugin_VC + ) +endif() +if(BUILD_UNREAL) + list(APPEND ALL_TARGETS + Plugin_III_Unreal + Plugin_SA_Unreal + Plugin_VC_Unreal + ) +endif() + +foreach(tgt ${ALL_TARGETS}) + if(TARGET ${tgt}) + set_target_properties(${tgt} PROPERTIES + PREFIX "lib" + SUFFIX ".a" + ) + endif() +endforeach() + +# Match original MSVC output names (Plugin.lib / Plugin_Unreal.lib) +if(TARGET Plugin_SA) + set_target_properties(Plugin_SA PROPERTIES + OUTPUT_NAME "Plugin" + ) +endif() +if(TARGET Plugin_SA_Unreal) + set_target_properties(Plugin_SA_Unreal PROPERTIES + OUTPUT_NAME "Plugin_Unreal" + ) +endif() diff --git a/injector/assembly.hpp b/injector/assembly.hpp index 53aa7700e..a88881394 100644 --- a/injector/assembly.hpp +++ b/injector/assembly.hpp @@ -3,7 +3,7 @@ // Original assembly.hpp functions moved to SafetyHook */ #include "injector.hpp" -#include "..\safetyhook\safetyhook.hpp" +#include "../safetyhook/safetyhook.hpp" namespace injector { diff --git a/injector/injector.hpp b/injector/injector.hpp index 96345ae83..d16f6e9c6 100644 --- a/injector/injector.hpp +++ b/injector/injector.hpp @@ -31,7 +31,7 @@ #include #include #include "gvm/gvm.hpp" -#include "..\shared\DynAddress.h" +#include "../shared/DynAddress.h" /* The following macros (#define) are relevant on this header: diff --git a/modutils/Trampoline.h b/modutils/Trampoline.h index 075be66a3..3032564c6 100644 --- a/modutils/Trampoline.h +++ b/modutils/Trampoline.h @@ -7,6 +7,7 @@ #include #include #include +#include // Trampoline class for big (>2GB) jumps // Never needed in 32-bit processes so in those cases this does nothing but forwards to Memory functions diff --git a/plugin_II/game_II/CSprite.cpp b/plugin_II/game_II/CSprite.cpp index b5685ee01..7a3bc7821 100644 --- a/plugin_II/game_II/CSprite.cpp +++ b/plugin_II/game_II/CSprite.cpp @@ -8,7 +8,7 @@ #include "CSprite.h" #include "CGame.h" #include "CPlayerPed.h" -#include "..\shared\extensions\Screen.h" +#include "../shared/extensions/Screen.h" #include "GBH.h" #include "CRect.h" diff --git a/plugin_III/game_III/CControllerConfigManager.h b/plugin_III/game_III/CControllerConfigManager.h index f87d82c18..533e03e42 100644 --- a/plugin_III/game_III/CControllerConfigManager.h +++ b/plugin_III/game_III/CControllerConfigManager.h @@ -6,6 +6,9 @@ */ #pragma once #include "PluginBase.h" +#include "CMouseControllerState.h" +#include "CControllerState.h" +#include "rw/skeleton.h" #define DIRECTINPUT_VERSION 0x0800 #include "dinput.h" diff --git a/plugin_III/game_III/CModelInfo.cpp b/plugin_III/game_III/CModelInfo.cpp index 96934be23..8a69fac5c 100644 --- a/plugin_III/game_III/CModelInfo.cpp +++ b/plugin_III/game_III/CModelInfo.cpp @@ -104,10 +104,10 @@ CBaseModelInfo* CModelInfo::GetModelInfo(int modelId) { return modelId < ms_modelInfoCount ? ms_modelInfoPtrs[modelId] : nullptr; } -int addrof_o(CModelInfo::GetModelInfo, CBaseModelInfo* (char const*, int*)) = ADDRESS_BY_VERSION(0x50B860, 0x50B950, 0x50B8E0); -int gaddrof_o(CModelInfo::GetModelInfo, CBaseModelInfo* (char const*, int*)) = GLOBAL_ADDRESS_BY_VERSION(0x50B860, 0x50B950, 0x50B8E0); +int addrof_o(CModelInfo::GetModelInfo, CBaseModelInfo*(*)(char const*, int*)) = ADDRESS_BY_VERSION(0x50B860, 0x50B950, 0x50B8E0); +int gaddrof_o(CModelInfo::GetModelInfo, CBaseModelInfo*(*)(char const*, int*)) = GLOBAL_ADDRESS_BY_VERSION(0x50B860, 0x50B950, 0x50B8E0); CBaseModelInfo *CModelInfo::GetModelInfo(char const* name, int* modelId) { - return plugin::CallAndReturnDynGlobal(gaddrof_o(CModelInfo::GetModelInfo, CBaseModelInfo * (char const*, int*)), name, modelId); + return plugin::CallAndReturnDynGlobal(gaddrof_o(CModelInfo::GetModelInfo, CBaseModelInfo*(*)(char const*, int*)), name, modelId); } int CModelInfo::FindNextModel(eModelInfoType type, int startModelId, bool searchForward, bool warpAround) { diff --git a/plugin_III/game_III/meta/meta.CModelInfo.h b/plugin_III/game_III/meta/meta.CModelInfo.h index 427bcd67a..ffab6e705 100644 --- a/plugin_III/game_III/meta/meta.CModelInfo.h +++ b/plugin_III/game_III/meta/meta.CModelInfo.h @@ -54,7 +54,7 @@ using calling_convention_t = CallingConventions::Cdecl; using args_t = ArgPick>; META_END -META_BEGIN_OVERLOADED(CModelInfo::GetModelInfo, CBaseModelInfo*(char const*, int*)) +META_BEGIN_OVERLOADED(CModelInfo::GetModelInfo, CBaseModelInfo*(*)(char const*, int*)) static int address; static int global_address; static const int id = 0x50B860; diff --git a/plugin_IV/game_IV/CCam.h b/plugin_IV/game_IV/CCam.h index c05620943..4414d8049 100644 --- a/plugin_IV/game_IV/CCam.h +++ b/plugin_IV/game_IV/CCam.h @@ -124,7 +124,11 @@ class CCam { uint32_t field_338; uint32_t field_342; uint32_t field_448; +#ifdef _MSC_VER uint8_t field_500[810]; +#else + uint8_t field_500[812]; // +2 to fill tail padding (Itanium ABI compatibility) +#endif public: static bool& bBlockCam; diff --git a/plugin_IV/game_IV/CCamScriptInstruction.h b/plugin_IV/game_IV/CCamScriptInstruction.h index af0a60b36..b2a044598 100644 --- a/plugin_IV/game_IV/CCamScriptInstruction.h +++ b/plugin_IV/game_IV/CCamScriptInstruction.h @@ -12,6 +12,9 @@ class CCamScriptInstruction { public: uint8_t field_1; +#ifndef _MSC_VER + uint8_t _pad_abi[3]; // Fill tail padding (Itanium ABI compatibility) +#endif public: CCamScriptInstruction() { diff --git a/plugin_sa/game_sa/rw/rtanim.h b/plugin_sa/game_sa/rw/rtanim.h index 2aad0e39b..62b5dbf13 100644 --- a/plugin_sa/game_sa/rw/rtanim.h +++ b/plugin_sa/game_sa/rw/rtanim.h @@ -1,7 +1,7 @@ #ifndef RTANIM_H #define RTANIM_H -#include /* automatically generated header file */ +#include /* automatically generated header file */ #define rtANIMSTREAMCURRENTVERSION 0x100 diff --git a/plugin_sa_unreal/game_sa_unreal/rw/rtanim.h b/plugin_sa_unreal/game_sa_unreal/rw/rtanim.h index 2aad0e39b..62b5dbf13 100644 --- a/plugin_sa_unreal/game_sa_unreal/rw/rtanim.h +++ b/plugin_sa_unreal/game_sa_unreal/rw/rtanim.h @@ -1,7 +1,7 @@ #ifndef RTANIM_H #define RTANIM_H -#include /* automatically generated header file */ +#include /* automatically generated header file */ #define rtANIMSTREAMCURRENTVERSION 0x100 diff --git a/plugin_vc/game_vc/rw/rtanim.h b/plugin_vc/game_vc/rw/rtanim.h index 2aad0e39b..62b5dbf13 100644 --- a/plugin_vc/game_vc/rw/rtanim.h +++ b/plugin_vc/game_vc/rw/rtanim.h @@ -1,7 +1,7 @@ #ifndef RTANIM_H #define RTANIM_H -#include /* automatically generated header file */ +#include /* automatically generated header file */ #define rtANIMSTREAMCURRENTVERSION 0x100 diff --git a/plugin_vc_unreal/game_vc_unreal/rw/rtanim.h b/plugin_vc_unreal/game_vc_unreal/rw/rtanim.h index 2aad0e39b..62b5dbf13 100644 --- a/plugin_vc_unreal/game_vc_unreal/rw/rtanim.h +++ b/plugin_vc_unreal/game_vc_unreal/rw/rtanim.h @@ -1,7 +1,7 @@ #ifndef RTANIM_H #define RTANIM_H -#include /* automatically generated header file */ +#include /* automatically generated header file */ #define rtANIMSTREAMCURRENTVERSION 0x100 diff --git a/shared/DynAddress.cpp b/shared/DynAddress.cpp index e6a0b8e4d..ab15a8e5c 100644 --- a/shared/DynAddress.cpp +++ b/shared/DynAddress.cpp @@ -11,7 +11,7 @@ #include #include "Base.h" #if !(defined (_M_IX86) || defined (_X86_)) -#include "..\modutils\Trampoline.h" +#include "../modutils/Trampoline.h" #endif uintptr_t _NOINLINE_ plugin::GetBaseAddress() { diff --git a/shared/Other.cpp b/shared/Other.cpp index df1cc72ac..ba87e7e88 100644 --- a/shared/Other.cpp +++ b/shared/Other.cpp @@ -11,7 +11,7 @@ #include #define STB_IMAGE_IMPLEMENTATION -#include "..\stb\stb_image.h" +#include "../stb/stb_image.h" #include "Image.h" diff --git a/shared/plugin.rc b/shared/plugin.rc index 81e29f86fe73335e84ed62908847edca1b5673e0..b8be53e37ee54904566102d83adfd0c377442a83 100644 GIT binary patch literal 2226 zcmcIl-*1~R5PtVxaicG-nk9rpo%%??VJH-$7*H!!LM(9-Ys5r`Y^&5iel`%2Y-ziP z%sd#M&-df|&gWha9@t#uMZPQ{X2mYez`DJK73EZ(ts!)^pi9Onm{Sr)wi_ffY}$eEJtgGnVH9{op1t5uk@R}tw4p9VzJYR0 zA;gcN>swxAV=&qb{s{di<1+dx@Cyc|(AjYb#5*Wl90tIAm9b(C*AZumG*U|Likmj| zLXyLl@Tn$faczztB{?LBW)@Ct&%1%wS2*4b&6$&6Ke|Dl={u3>U{F6&gqeI>++Hc zo@V>dw^c0NjD0(+?$K46S^4%wu+_R$*4qVKTQ^|n#^CJ1KptSyk4m36Fn!=_D)Pl{ zUhX5SQTj~m$yo=D_Pcqj>#V5Q&kfOWD&8xHhT~AAyvWkBCQTLKeFyr6E~~#WS#^t( q%lmPsz3gLxs4` z@u6n3J2Pj_IdkrF_Ser1+px%vt!tMyw7!jaZ)^;#1#Dy!JGWa_`}Tq-vW{I_k9P=s z%ym%~Hon11efy05 zW2_@PG|>7z-$S(CM^D+K1iZjI>ybbE;H$H*r%T#@^(+=7^3gHDR*Iw>^j z)f$6z5#H^Qf46vQL<~gs9G~}Cg*>b?^I18v^^7PO#d50a?DZ^>TUT)0wF9Ec=Tx2i zX_8(0oZKe5Dm>!*gD09x*?`9>G2Djg1p0M%Y6a*C&?aNq#c6dG=_WL5l}rRz=3&Zt{wM6|E{Qz_?3w7sN6i=MOQ>hTqsrW)fP z)rhQmla99Fqt&V^acLx>)?w7$uN!`Z#(n$|;6alX+1CcAM4s2(9el!Cnjes7qK@wb zxTqsA4$14%3{FG@zb5lH?_ZByP;K$9t37_cb$#6;961e^uBjmX&34NHE6d>drcNsf%XU_^OAj{h5r+<`yy|$yJ(c z+FPg51>arV>kRUpq7(W!cOhT>m3g(%P}9#@amt;RWh{5l~j z$0^Ijqv{n=q9|TOizN5Qcz$~Khb&1$l9}GZQp0<@EmJv?`Q3nIm3BJQ{`|ZA-*ngUdv&$u(mwwB+wY-&r*to~S{lWrk!D(l@v(o= gs=yEbMF(5PrC6=GB%B}bJ?fC|ru08^+VA4@8*^VKHvj+t diff --git a/toolchain-clang32.cmake b/toolchain-clang32.cmake new file mode 100644 index 000000000..3f0c958fd --- /dev/null +++ b/toolchain-clang32.cmake @@ -0,0 +1,24 @@ +set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_SYSTEM_PROCESSOR i686) + +set(triple i686-w64-windows-gnu) + +# Specify the cross compilers using Clang +set(CMAKE_C_COMPILER clang) +set(CMAKE_C_COMPILER_TARGET ${triple}) +set(CMAKE_CXX_COMPILER clang++) +set(CMAKE_CXX_COMPILER_TARGET ${triple}) + +# Specify target linker flags to use absolute path of MinGW linker +set(CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=/usr/bin/i686-w64-mingw32-ld") +set(CMAKE_SHARED_LINKER_FLAGS_INIT "-fuse-ld=/usr/bin/i686-w64-mingw32-ld") +set(CMAKE_MODULE_LINKER_FLAGS_INIT "-fuse-ld=/usr/bin/i686-w64-mingw32-ld") + +# Specify resource compiler +set(CMAKE_RC_COMPILER i686-w64-mingw32-windres) + +# Adjust search paths for the target environment +set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/toolchain-clang64.cmake b/toolchain-clang64.cmake new file mode 100644 index 000000000..06485b068 --- /dev/null +++ b/toolchain-clang64.cmake @@ -0,0 +1,24 @@ +set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_SYSTEM_PROCESSOR x86_64) + +set(triple x86_64-w64-windows-gnu) + +# Specify the cross compilers using Clang +set(CMAKE_C_COMPILER clang) +set(CMAKE_C_COMPILER_TARGET ${triple}) +set(CMAKE_CXX_COMPILER clang++) +set(CMAKE_CXX_COMPILER_TARGET ${triple}) + +# Specify target linker flags to use absolute path of MinGW linker +set(CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=/usr/bin/x86_64-w64-mingw32-ld") +set(CMAKE_SHARED_LINKER_FLAGS_INIT "-fuse-ld=/usr/bin/x86_64-w64-mingw32-ld") +set(CMAKE_MODULE_LINKER_FLAGS_INIT "-fuse-ld=/usr/bin/x86_64-w64-mingw32-ld") + +# Specify resource compiler +set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) + +# Adjust search paths for the target environment +set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) From ae11885d3954e11dc29d1b8a47506e2a5d4aff7d Mon Sep 17 00:00:00 2001 From: MrRealistic-Mods Date: Thu, 25 Jun 2026 01:43:22 +0530 Subject: [PATCH 02/10] Changed to premake --- CMakeLists.txt | 250 ----------------- plugin_IV/game_IV/CCam.h | 6 +- toolchain-clang32.cmake | 24 -- toolchain-clang64.cmake | 24 -- tools/premake/build_all_clang.sh | 38 +++ .../premake/linux-clang-example/premake5.lua | 116 ++++---- tools/premake/premake5.lua | 251 ++++++++++++------ 7 files changed, 273 insertions(+), 436 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 toolchain-clang32.cmake delete mode 100644 toolchain-clang64.cmake create mode 100644 tools/premake/build_all_clang.sh diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 3bab35bc2..000000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,250 +0,0 @@ -cmake_minimum_required(VERSION 3.15) -project(plugin-sdk LANGUAGES C CXX RC) - -if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE) -endif() - -# C++23 standard -set(CMAKE_CXX_STANDARD 23) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS ON) - -option(BUILD_CLASSIC "Build classic 32-bit targets" ON) -option(BUILD_UNREAL "Build Unreal 64-bit targets" ON) - -# Suppress warnings that are expected in this MSVC game modding SDK -add_compile_options( - -Wno-invalid-offsetof # offsetof on non-standard-layout types (game structures) - -Wno-pragma-pack # MSVC-style #pragma pack usage - -Wno-microsoft-cast # MSVC-specific casts - -Wno-reinterpret-base-class # common in game hook code - -Wno-unused-private-field # padding fields in game structures - -Wno-unused-variable - -Wno-missing-field-initializers - -Wno-ignored-pragma-intrinsic # MSVC #pragma intrinsic -) - -# Common include directories -set(COMMON_INCLUDES - ${CMAKE_CURRENT_SOURCE_DIR}/shared - ${CMAKE_CURRENT_SOURCE_DIR}/shared/game - ${CMAKE_CURRENT_SOURCE_DIR}/shared/dxsdk - ${CMAKE_CURRENT_SOURCE_DIR}/safetyhook - ${CMAKE_CURRENT_SOURCE_DIR}/injector - ${CMAKE_CURRENT_SOURCE_DIR}/hooking -) - -# Common source files -file(GLOB_RECURSE COMMON_SOURCES - "shared/*.cpp" - "shared/*.c" - "shared/*.rc" - "hooking/*.cpp" - "safetyhook/*.cpp" - "safetyhook/*.c" -) - -if(BUILD_CLASSIC) -# --- Plugin_SA (GTA San Andreas) --- -file(GLOB_RECURSE SA_SOURCES - "plugin_sa/*.cpp" -) -add_library(Plugin_SA STATIC ${COMMON_SOURCES} ${SA_SOURCES}) -target_include_directories(Plugin_SA PUBLIC - ${COMMON_INCLUDES} - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_sa - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_sa/game_sa - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_sa/game_sa/enums - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_sa/game_sa/rw -) -target_compile_definitions(Plugin_SA PUBLIC - GTASA - PLUGIN_SGV_10US - RW - _DX9_SDK_INSTALLED -) - -# --- Plugin_VC (GTA Vice City) --- -file(GLOB_RECURSE VC_SOURCES - "plugin_vc/*.cpp" -) -add_library(Plugin_VC STATIC ${COMMON_SOURCES} ${VC_SOURCES}) -target_include_directories(Plugin_VC PUBLIC - ${COMMON_INCLUDES} - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_vc - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_vc/game_vc - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_vc/game_vc/enums - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_vc/game_vc/rw -) -target_compile_definitions(Plugin_VC PUBLIC - GTAVC - PLUGIN_SGV_10EN - RW - _DX9_SDK_INSTALLED -) - -# --- Plugin_III (GTA III) --- -file(GLOB_RECURSE III_SOURCES - "plugin_III/*.cpp" -) -add_library(Plugin_III STATIC ${COMMON_SOURCES} ${III_SOURCES}) -target_include_directories(Plugin_III PUBLIC - ${COMMON_INCLUDES} - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_III - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_III/game_III - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_III/game_III/enums - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_III/game_III/rw -) -target_compile_definitions(Plugin_III PUBLIC - GTA3 - PLUGIN_SGV_10EN - RW - _DX9_SDK_INSTALLED -) - -# --- Plugin_II (GTA II) --- -file(GLOB_RECURSE II_SOURCES - "plugin_II/*.cpp" -) -add_library(Plugin_II STATIC ${COMMON_SOURCES} ${II_SOURCES}) -target_include_directories(Plugin_II PUBLIC - ${COMMON_INCLUDES} - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_II - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_II/game_II -) -target_compile_definitions(Plugin_II PUBLIC - GTA2 - PLUGIN_SGV_96EN - GBH - _DX9_SDK_INSTALLED -) - -# --- Plugin_IV (GTA IV) --- -file(GLOB_RECURSE IV_SOURCES - "plugin_IV/*.cpp" -) -add_library(Plugin_IV STATIC ${COMMON_SOURCES} ${IV_SOURCES}) -target_include_directories(Plugin_IV PUBLIC - ${COMMON_INCLUDES} - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_IV - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_IV/game_IV -) -target_compile_definitions(Plugin_IV PUBLIC - GTAIV - PLUGIN_SGV_CE - RAGE - _DX9_SDK_INSTALLED -) -endif() - -if(BUILD_UNREAL) -# --- Plugin_III_Unreal (GTA III Unreal) --- -file(GLOB_RECURSE III_UNREAL_SOURCES - "plugin_iii_unreal/*.cpp" -) -add_library(Plugin_III_Unreal STATIC ${COMMON_SOURCES} ${III_UNREAL_SOURCES}) -target_include_directories(Plugin_III_Unreal PUBLIC - ${COMMON_INCLUDES} - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_iii_unreal - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_iii_unreal/game_iii_unreal - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_iii_unreal/game_iii_unreal/rw -) -target_compile_definitions(Plugin_III_Unreal PUBLIC - _WIN64 - GTA3_UNREAL - PLUGIN_UNREAL - UNREAL - NOASM - RWINT32FROMFLOAT - _CRT_NON_CONFORMING_SWPRINTFS - _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING - _DX9_SDK_INSTALLED -) - -# --- Plugin_SA_Unreal (GTA San Andreas Unreal) --- -file(GLOB_RECURSE SA_UNREAL_SOURCES - "plugin_sa_unreal/*.cpp" -) -add_library(Plugin_SA_Unreal STATIC ${COMMON_SOURCES} ${SA_UNREAL_SOURCES}) -target_include_directories(Plugin_SA_Unreal PUBLIC - ${COMMON_INCLUDES} - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_sa_unreal - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_sa_unreal/game_sa_unreal - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_sa_unreal/game_sa_unreal/rw -) -target_compile_definitions(Plugin_SA_Unreal PUBLIC - _WIN64 - GTASA_UNREAL - PLUGIN_UNREAL - UNREAL - NOASM - RWINT32FROMFLOAT - _CRT_NON_CONFORMING_SWPRINTFS - _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING - _DX9_SDK_INSTALLED -) - -# --- Plugin_VC_Unreal (GTA Vice City Unreal) --- -file(GLOB_RECURSE VC_UNREAL_SOURCES - "plugin_vc_unreal/*.cpp" -) -add_library(Plugin_VC_Unreal STATIC ${COMMON_SOURCES} ${VC_UNREAL_SOURCES}) -target_include_directories(Plugin_VC_Unreal PUBLIC - ${COMMON_INCLUDES} - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_vc_unreal - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_vc_unreal/game_vc_unreal - ${CMAKE_CURRENT_SOURCE_DIR}/plugin_vc_unreal/game_vc_unreal/rw -) -target_compile_definitions(Plugin_VC_Unreal PUBLIC - _WIN64 - GTAVC_UNREAL - PLUGIN_UNREAL - UNREAL - NOASM - RWINT32FROMFLOAT - _CRT_NON_CONFORMING_SWPRINTFS - _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING - _DX9_SDK_INSTALLED -) -endif() - -# --- Unified Target Output Properties (Match original MSVC naming in MinGW format) --- -set(ALL_TARGETS) -if(BUILD_CLASSIC) - list(APPEND ALL_TARGETS - Plugin_II - Plugin_III - Plugin_IV - Plugin_SA - Plugin_VC - ) -endif() -if(BUILD_UNREAL) - list(APPEND ALL_TARGETS - Plugin_III_Unreal - Plugin_SA_Unreal - Plugin_VC_Unreal - ) -endif() - -foreach(tgt ${ALL_TARGETS}) - if(TARGET ${tgt}) - set_target_properties(${tgt} PROPERTIES - PREFIX "lib" - SUFFIX ".a" - ) - endif() -endforeach() - -# Match original MSVC output names (Plugin.lib / Plugin_Unreal.lib) -if(TARGET Plugin_SA) - set_target_properties(Plugin_SA PROPERTIES - OUTPUT_NAME "Plugin" - ) -endif() -if(TARGET Plugin_SA_Unreal) - set_target_properties(Plugin_SA_Unreal PROPERTIES - OUTPUT_NAME "Plugin_Unreal" - ) -endif() diff --git a/plugin_IV/game_IV/CCam.h b/plugin_IV/game_IV/CCam.h index 4414d8049..38e70ead6 100644 --- a/plugin_IV/game_IV/CCam.h +++ b/plugin_IV/game_IV/CCam.h @@ -124,11 +124,7 @@ class CCam { uint32_t field_338; uint32_t field_342; uint32_t field_448; -#ifdef _MSC_VER - uint8_t field_500[810]; -#else - uint8_t field_500[812]; // +2 to fill tail padding (Itanium ABI compatibility) -#endif + uint8_t field_500[812]; // Sized to 812 to fill tail padding on all platforms (sizeof(CCam) remains 0x500 due to alignment) public: static bool& bBlockCam; diff --git a/toolchain-clang32.cmake b/toolchain-clang32.cmake deleted file mode 100644 index 3f0c958fd..000000000 --- a/toolchain-clang32.cmake +++ /dev/null @@ -1,24 +0,0 @@ -set(CMAKE_SYSTEM_NAME Windows) -set(CMAKE_SYSTEM_PROCESSOR i686) - -set(triple i686-w64-windows-gnu) - -# Specify the cross compilers using Clang -set(CMAKE_C_COMPILER clang) -set(CMAKE_C_COMPILER_TARGET ${triple}) -set(CMAKE_CXX_COMPILER clang++) -set(CMAKE_CXX_COMPILER_TARGET ${triple}) - -# Specify target linker flags to use absolute path of MinGW linker -set(CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=/usr/bin/i686-w64-mingw32-ld") -set(CMAKE_SHARED_LINKER_FLAGS_INIT "-fuse-ld=/usr/bin/i686-w64-mingw32-ld") -set(CMAKE_MODULE_LINKER_FLAGS_INIT "-fuse-ld=/usr/bin/i686-w64-mingw32-ld") - -# Specify resource compiler -set(CMAKE_RC_COMPILER i686-w64-mingw32-windres) - -# Adjust search paths for the target environment -set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32) -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/toolchain-clang64.cmake b/toolchain-clang64.cmake deleted file mode 100644 index 06485b068..000000000 --- a/toolchain-clang64.cmake +++ /dev/null @@ -1,24 +0,0 @@ -set(CMAKE_SYSTEM_NAME Windows) -set(CMAKE_SYSTEM_PROCESSOR x86_64) - -set(triple x86_64-w64-windows-gnu) - -# Specify the cross compilers using Clang -set(CMAKE_C_COMPILER clang) -set(CMAKE_C_COMPILER_TARGET ${triple}) -set(CMAKE_CXX_COMPILER clang++) -set(CMAKE_CXX_COMPILER_TARGET ${triple}) - -# Specify target linker flags to use absolute path of MinGW linker -set(CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=/usr/bin/x86_64-w64-mingw32-ld") -set(CMAKE_SHARED_LINKER_FLAGS_INIT "-fuse-ld=/usr/bin/x86_64-w64-mingw32-ld") -set(CMAKE_MODULE_LINKER_FLAGS_INIT "-fuse-ld=/usr/bin/x86_64-w64-mingw32-ld") - -# Specify resource compiler -set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) - -# Adjust search paths for the target environment -set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32) -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/tools/premake/build_all_clang.sh b/tools/premake/build_all_clang.sh new file mode 100644 index 000000000..6d173d1d5 --- /dev/null +++ b/tools/premake/build_all_clang.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Exit on any error +set -e + +# Resolve the project root directory relative to this script's directory +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +export PLUGIN_SDK_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" + +echo "=== Generating GNU Makefiles using Premake ===" +"$SCRIPT_DIR/linux-clang-example/premake5" gmake --file="$SCRIPT_DIR/premake5.lua" + +echo "=== Cleaning previous target output directory ===" +mkdir -p "$PLUGIN_SDK_DIR/output/lib" +rm -f "$PLUGIN_SDK_DIR/output/lib"/* + +# Target lists +targets_32=("plugin_II" "plugin_III" "plugin_vc" "plugin_sa" "plugin_IV") +targets_64=("plugin_iii_unreal" "plugin_vc_unreal" "plugin_sa_unreal") + +echo "=== Compiling 32-bit Classic Targets (Release & Debug) ===" +for target in "${targets_32[@]}"; do + echo " -> Building $target [Release]..." + make config=release RESCOMP=i686-w64-mingw32-windres AR=ar -C "$PLUGIN_SDK_DIR/$target" -j$(nproc) + echo " -> Building $target [Debug]..." + make config=zdebug RESCOMP=i686-w64-mingw32-windres AR=ar -C "$PLUGIN_SDK_DIR/$target" -j$(nproc) +done + +echo "=== Compiling 64-bit Unreal Targets (Release & Debug) ===" +for target in "${targets_64[@]}"; do + echo " -> Building $target [Release]..." + make config=release RESCOMP=x86_64-w64-mingw32-windres AR=ar -C "$PLUGIN_SDK_DIR/$target" -j$(nproc) + echo " -> Building $target [Debug]..." + make config=zdebug RESCOMP=x86_64-w64-mingw32-windres AR=ar -C "$PLUGIN_SDK_DIR/$target" -j$(nproc) +done + +echo "=== Build Complete! ===" +echo "All static libraries have been compiled and placed inside: $PLUGIN_SDK_DIR/output/lib" +ls -la "$PLUGIN_SDK_DIR/output/lib" diff --git a/tools/premake/linux-clang-example/premake5.lua b/tools/premake/linux-clang-example/premake5.lua index f10365c84..7c47c893f 100644 --- a/tools/premake/linux-clang-example/premake5.lua +++ b/tools/premake/linux-clang-example/premake5.lua @@ -1,71 +1,85 @@ -local sdkdir = os.getenv("PLUGIN_SDK_DIR") +-- This is an example Premake5 script for generating a project that compiles +-- a custom GTA SA/VC/III ASI/CLEO plugin using Clang/MinGW on Linux. +-- To use this template, set the PLUGIN_SDK_DIR environment variable to the +-- path of your compiled Plugin-SDK repository. -if not sdkdir then - error("WARNING: PLUGIN_SDK_DIR env var not found. Defaulting to current directory.") +local sdkdir = os.getenv("PLUGIN_SDK_DIR") +if not sdkdir or sdkdir == "" then + error("ERROR: PLUGIN_SDK_DIR environment variable is not set!") end - sdkdir = path.translate(sdkdir, "/") -workspace "plugin" - configurations { "Release", "zDebug" } - location (sdkdir .. "\\output") - targetdir (sdkdir .. "\\output\\lib") +workspace "MyCustomPlugin" + configurations { "Release", "Debug" } + location "build" -project "plugin_sa" - kind "StaticLib" +project "MyCustomPlugin" + kind "SharedLib" language "C++" - architecture "x32" - staticruntime "On" - - defines { - "RW", - "PLUGIN_SGV_10US", - "GTASA" - } + targetextension ".asi" -- .asi, .cleo, or .dll + + -- Target 32-bit (x86) for classic GTA games, 64-bit (x86_64) for Unreal DE games + architecture "x86" - filter "action:gmake or action:gmake2 or action:codeblocks" + -- Target Clang cross-compilation toolchain on Linux/MinGW + filter "action:gmake or action:gmake2" toolset "clang" - buildoptions { - "--target=i686-w64-mingw32", + buildoptions { "-fpermissive", "-fcommon", "-fms-extensions", "-Wno-invalid-offsetof", - "-Wno-microsoft-include" , + "-Wno-microsoft-include", "-static", } - - filter "files:**.cpp" - buildoptions { "-std=c++2b" } -- C++23 - - - filter "configurations:Release" - defines { "NDEBUG" } - optimize "On" - symbols "Off" - targetname "plugin" - - filter "configurations:zDebug" - defines { "DEBUG", "_DEBUG" } - symbols "On" - optimize "Debug" - targetname "plugin_d" + + filter { "action:gmake or action:gmake2", "architecture:x86" } + buildoptions { "--target=i686-w64-mingw32" } + linkoptions { "--target=i686-w64-mingw32", "-static-libgcc", "-static-libstdc++" } + + filter { "action:gmake or action:gmake2", "architecture:x86_64" } + buildoptions { "--target=x86_64-w64-mingw32" } + linkoptions { "--target=x86_64-w64-mingw32", "-static-libgcc", "-static-libstdc++" } + filter {} + -- C++23 standard + filter "files:**.cpp" + buildoptions { "-std=c++2b" } filter {} - includedirs { - sdkdir, - sdkdir .. "/shared", - sdkdir .. "/shared/game", - sdkdir .. "/plugin_sa", + -- Include directories for the SDK + includedirs { + "source", -- Your plugin source folder + sdkdir .. "/shared", + sdkdir .. "/shared/game", + sdkdir .. "/shared/dxsdk", + sdkdir .. "/safetyhook", + -- Game-specific includes (change as needed for III, VC, SA, etc.): + sdkdir .. "/plugin_sa", sdkdir .. "/plugin_sa/game_sa", sdkdir .. "/plugin_sa/game_sa/enums", - sdkdir .. "/plugin_sa/game_sa/rw", - sdkdir .. "/safetyhook" + sdkdir .. "/plugin_sa/game_sa/rw", } - - files { - sdkdir .. "/shared/**.cpp", - sdkdir .. "/plugin_sa/**.cpp", - sdkdir .. "/safetyhook/**" - } \ No newline at end of file + + -- SDK static library search directory + libdirs { + sdkdir .. "/output/lib" + } + + -- Source files for your plugin + files { + "source/**.h", + "source/**.cpp", + } + + -- Define game macros (e.g. GTASA, GTAVC, GTA3) and link against correct SDK library + filter "configurations:Release" + defines { "GTASA", "NDEBUG" } + links { "Plugin" } -- Links libPlugin.a + targetdir "output/Release" + + filter "configurations:Debug" + defines { "GTASA", "DEBUG", "_DEBUG" } + links { "Plugin_d" } -- Links libPlugin_d.a + targetdir "output/Debug" + filter {} \ No newline at end of file diff --git a/tools/premake/premake5.lua b/tools/premake/premake5.lua index 190b0147f..767e284cc 100644 --- a/tools/premake/premake5.lua +++ b/tools/premake/premake5.lua @@ -25,7 +25,7 @@ if _ACTION then _ACTION = string.lower(_ACTION) end -mingw = _ACTION == "codeblocks" +mingw = _ACTION == "codeblocks" or _ACTION == "gmake" or _ACTION == "gmake2" msbuild = not mingw sdkdir = _OPTIONS["pluginsdkdir"] @@ -49,22 +49,32 @@ end function deleteAllFoldersWithName(pathToDir, folderName) - os.execute("for /d /r \"" .. pathToDir .. "\" %d in (" .. folderName .. ") do @if exist \"%d\" rd /s/q \"%d\" >nul 2>&1") + pathToDir = path.translate(pathToDir, "/") + if os.host() == "windows" then + os.execute("for /d /r \"" .. pathToDir .. "\" %d in (" .. folderName .. ") do @if exist \"%d\" rd /s/q \"%d\" >nul 2>&1") + else + os.execute("find \"" .. pathToDir .. "\" -type d -name \"" .. folderName .. "\" -exec rm -rf {} + >/dev/null 2>&1") + end end function cleanProjectsDirectory(pathToDir) - os.execute("del /s \"" .. pathToDir .. "\\*.sln\" >nul 2>&1") - os.execute("del /s \"" .. pathToDir .. "\\*.suo\" >nul 2>&1") - os.execute("del /s \"" .. pathToDir .. "\\*.sdf\" >nul 2>&1") - os.execute("del /s \"" .. pathToDir .. "\\*.opensdf\" >nul 2>&1") - os.execute("del /s \"" .. pathToDir .. "\\*.vcxproj\" >nul 2>&1") - os.execute("del /s \"" .. pathToDir .. "\\*.vcxproj.filters\" >nul 2>&1") - os.execute("del /s \"" .. pathToDir .. "\\*.vcxproj.user\" >nul 2>&1") - os.execute("del /s \"" .. pathToDir .. "\\*.workspace\" >nul 2>&1") - os.execute("del /s \"" .. pathToDir .. "\\*.cbp\" >nul 2>&1") - os.execute("del /s \"" .. pathToDir .. "\\*.project\" >nul 2>&1") - os.execute("del /s \"" .. pathToDir .. "\\*.depend\" >nul 2>&1") - os.execute("del /s \"" .. pathToDir .. "\\*.layout\" >nul 2>&1") + pathToDir = path.translate(pathToDir, "/") + if os.host() == "windows" then + os.execute("del /s \"" .. pathToDir .. "\\*.sln\" >nul 2>&1") + os.execute("del /s \"" .. pathToDir .. "\\*.suo\" >nul 2>&1") + os.execute("del /s \"" .. pathToDir .. "\\*.sdf\" >nul 2>&1") + os.execute("del /s \"" .. pathToDir .. "\\*.opensdf\" >nul 2>&1") + os.execute("del /s \"" .. pathToDir .. "\\*.vcxproj\" >nul 2>&1") + os.execute("del /s \"" .. pathToDir .. "\\*.vcxproj.filters\" >nul 2>&1") + os.execute("del /s \"" .. pathToDir .. "\\*.vcxproj.user\" >nul 2>&1") + os.execute("del /s \"" .. pathToDir .. "\\*.workspace\" >nul 2>&1") + os.execute("del /s \"" .. pathToDir .. "\\*.cbp\" >nul 2>&1") + os.execute("del /s \"" .. pathToDir .. "\\*.project\" >nul 2>&1") + os.execute("del /s \"" .. pathToDir .. "\\*.depend\" >nul 2>&1") + os.execute("del /s \"" .. pathToDir .. "\\*.layout\" >nul 2>&1") + else + os.execute("find \"" .. pathToDir .. "\" -type f \\( -name \"*.sln\" -o -name \"*.suo\" -o -name \"*.sdf\" -o -name \"*.opensdf\" -o -name \"*.vcxproj\" -o -name \"*.vcxproj.filters\" -o -name \"*.vcxproj.user\" -o -name \"*.workspace\" -o -name \"*.cbp\" -o -name \"*.project\" -o -name \"*.depend\" -o -name \"*.layout\" \\) -delete >/dev/null 2>&1") + end deleteAllFoldersWithName(pathToDir, "obj") end @@ -73,7 +83,7 @@ function projectFile(projectPath, fileName) end function gameFile(projectPath, gameName, fileName) - return (projectPath .. "\\" .. gameName .. "\\" .. fileName) + return (projectPath .. "/" .. gameName .. "/" .. fileName) end function gameFileTaskAtoZ(projectPath, gameName, fileName) @@ -81,11 +91,42 @@ function gameFileTaskAtoZ(projectPath, gameName, fileName) local strary = {} for i = 1, #alphabet do local c = alphabet:sub(i,i) - strary[i] = (projectPath .. "\\" .. gameName .. "\\" .. fileName .. c .. "*.*") + strary[i] = (projectPath .. "/" .. gameName .. "/" .. fileName .. c .. "*.*") end return strary end +function getCorrectFolderNames(projName, gameName) + local projFolder = projName + local gameFolder = gameName + + local projLower = string.lower(projName) + if projLower == "plugin_ii" then projFolder = "plugin_II" + elseif projLower == "plugin_iii" then projFolder = "plugin_III" + elseif projLower == "plugin_vc" then projFolder = "plugin_vc" + elseif projLower == "plugin_sa" then projFolder = "plugin_sa" + elseif projLower == "plugin_iv" then projFolder = "plugin_IV" + elseif projLower == "plugin_iii_unreal" then projFolder = "plugin_iii_unreal" + elseif projLower == "plugin_vc_unreal" then projFolder = "plugin_vc_unreal" + elseif projLower == "plugin_sa_unreal" then projFolder = "plugin_sa_unreal" + end + + if gameName then + local gameLower = string.lower(gameName) + if gameLower == "game_ii" then gameFolder = "game_II" + elseif gameLower == "game_iii" then gameFolder = "game_III" + elseif gameLower == "game_vc" then gameFolder = "game_vc" + elseif gameLower == "game_sa" then gameFolder = "game_sa" + elseif gameLower == "game_iv" then gameFolder = "game_IV" + elseif gameLower == "game_iii_unreal" then gameFolder = "game_iii_unreal" + elseif gameLower == "game_vc_unreal" then gameFolder = "game_vc_unreal" + elseif gameLower == "game_sa_unreal" then gameFolder = "game_sa_unreal" + end + end + + return projFolder, gameFolder +end + function projectDefinition(name, value) if mingw then return (name .. "=\"\\\"" .. value .. "\\\"\"") @@ -117,9 +158,11 @@ function splitStringAndPasteToArray(line, sep, params, arindex) end function setToolset() - if _ACTION == "codeblocks" then - toolset "gcc" - buildoptions "-std=gnu++17" + if _ACTION == "codeblocks" or _ACTION == "gmake" or _ACTION == "gmake2" then + toolset "clang" + filter "files:**.cpp" + buildoptions "-std=c++2b" + filter {} else systemversion "latest" buildoptions "/std:c++latest" @@ -129,9 +172,16 @@ end function pluginSdkStaticLibProject(projectName, sdkdir, outName, isPluginProject, gameName) print("Generating project \"" .. projectName .. "\"...") - projNameLower = string.lower(projectName) + local folderName, gameFolder = getCorrectFolderNames(projectName, gameName) + local projectPath = path.translate(sdkdir .. "/" .. folderName, "/") - project (projectName) + local origProjectName = projectName + projectName = folderName + gameName = gameFolder + + projNameLower = string.lower(origProjectName) + + project (origProjectName) language "C++" if projNameLower:sub(-#"_unreal") == "_unreal" then @@ -143,8 +193,6 @@ function pluginSdkStaticLibProject(projectName, sdkdir, outName, isPluginProject characterset "MBCS" staticruntime "On" - local projectPath = (sdkdir .. "\\" .. projectName) - if msbuild then cppdialect "C++latest" defines { "_CRT_NON_CONFORMING_SWPRINTFS", "_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING" } @@ -155,6 +203,22 @@ function pluginSdkStaticLibProject(projectName, sdkdir, outName, isPluginProject end if mingw then buildoptions "-fpermissive" + filter "action:gmake or action:gmake2 or action:codeblocks" + toolset "clang" + buildoptions { + "-fcommon", + "-fms-extensions", + "-Wno-invalid-offsetof", + "-Wno-microsoft-include", + "-static", + } + filter { "action:gmake or action:gmake2 or action:codeblocks", "architecture:x32" } + buildoptions { "--target=i686-w64-mingw32" } + linkoptions { "--target=i686-w64-mingw32" } + filter { "action:gmake or action:gmake2 or action:codeblocks", "architecture:x64" } + buildoptions { "--target=x86_64-w64-mingw32" } + linkoptions { "--target=x86_64-w64-mingw32" } + filter {} end if isPluginProject then @@ -197,22 +261,22 @@ function pluginSdkStaticLibProject(projectName, sdkdir, outName, isPluginProject filter {} if mingw then - targetdir "$(PLUGIN_SDK_DIR)\\output\\mingw\\lib" + targetdir "$(PLUGIN_SDK_DIR)/output/lib" filter "Release" - objdir "!$(PLUGIN_SDK_DIR)\\output\\mingw\\obj\\$(ProjectName)\\Release" - targetname ("lib" .. outName) + objdir "!$(PLUGIN_SDK_DIR)/output/mingw/obj/%{prj.name}/Release" + targetname (outName) filter "zDebug" - objdir "!$(PLUGIN_SDK_DIR)\\output\\mingw\\obj\\$(ProjectName)\\Debug" - targetname ("lib" .. outName .. "_d") + objdir "!$(PLUGIN_SDK_DIR)/output/mingw/obj/%{prj.name}/Debug" + targetname (outName .. "_d") filter {} targetextension ".a" else targetdir "$(PLUGIN_SDK_DIR)/output/lib" filter "Release" - objdir "!$(PLUGIN_SDK_DIR)\\output\\obj\\$(ProjectName)\\Release" + objdir "!$(PLUGIN_SDK_DIR)/output/obj/%{prj.name}/Release" targetname (outName) filter "zDebug" - objdir "!$(PLUGIN_SDK_DIR)\\output\\obj\\$(ProjectName)\\Debug" + objdir "!$(PLUGIN_SDK_DIR)/output/obj/%{prj.name}/Debug" targetname (outName .. "_d") filter {} targetextension ".lib" @@ -225,37 +289,37 @@ function pluginSdkStaticLibProject(projectName, sdkdir, outName, isPluginProject filter {} if isPluginProject then - os.execute('if not exist "' .. projectPath .. '" (mkdir "' .. projectPath .. '")') + os.mkdir(projectPath) location (projectPath) includedirs { - ("$(PLUGIN_SDK_DIR)\\" .. projectName), - ("$(PLUGIN_SDK_DIR)\\" .. projectName .. "\\" .. gameName), - ("$(PLUGIN_SDK_DIR)\\" .. projectName .. "\\" .. gameName .. "\\enums"), - ("$(PLUGIN_SDK_DIR)\\" .. projectName .. "\\" .. gameName .. "\\rw"), - "$(PLUGIN_SDK_DIR)\\safetyhook", - "$(PLUGIN_SDK_DIR)\\shared", - "$(PLUGIN_SDK_DIR)\\shared\\game" + ("$(PLUGIN_SDK_DIR)/" .. projectName), + ("$(PLUGIN_SDK_DIR)/" .. projectName .. "/" .. gameName), + ("$(PLUGIN_SDK_DIR)/" .. projectName .. "/" .. gameName .. "/enums"), + ("$(PLUGIN_SDK_DIR)/" .. projectName .. "/" .. gameName .. "/rw"), + "$(PLUGIN_SDK_DIR)/safetyhook", + "$(PLUGIN_SDK_DIR)/shared", + "$(PLUGIN_SDK_DIR)/shared/game" } -- shared files files { - (projectPath .. "\\**.h"), - (projectPath .. "\\**.cpp"), - (sdkdir .. "\\shared\\**.h"), - (sdkdir .. "\\shared\\**.cpp"), - (sdkdir .. "\\shared\\**.rc"), - (sdkdir .. "\\hooking\\**.cpp"), - (sdkdir .. "\\hooking\\**.h"), - (sdkdir .. "\\injector\\**.hpp"), - (sdkdir .. "\\safetyhook\\**.cpp"), - (sdkdir .. "\\safetyhook\\**.hpp"), - (sdkdir .. "\\safetyhook\\**.c"), + (projectPath .. "/**.h"), + (projectPath .. "/**.cpp"), + (sdkdir .. "/shared/**.h"), + (sdkdir .. "/shared/**.cpp"), + (sdkdir .. "/shared/**.rc"), + (sdkdir .. "/hooking/**.cpp"), + (sdkdir .. "/hooking/**.h"), + (sdkdir .. "/injector/**.hpp"), + (sdkdir .. "/safetyhook/**.cpp"), + (sdkdir .. "/safetyhook/**.hpp"), + (sdkdir .. "/safetyhook/**.c"), } -- game files vpaths { - ["shared/*"] = (projectFile(sdkdir, "shared\\**.*")), + ["shared/*"] = (projectFile(sdkdir, "shared/**.*")), [(gameName .. "/Animation")] = { (gameFile(projectPath, gameName, "Anim*.*")), (gameFile(projectPath, gameName, "CAnim*.*")) }, @@ -486,36 +550,37 @@ function getExamplePluginDefines(projName, game, projectType, d3dSupport, additi end function getExamplePluginIncludeFolders(pluginDir, gameDir, projectType, cleoDir, usesD3d9, usesRwD3d9, additionalDirs) + local pluginDir, gameDir = getCorrectFolderNames(pluginDir, gameDir) local counter = 1 local aryDirs = {} - aryDirs[counter] = ("$(PLUGIN_SDK_DIR)\\" .. pluginDir) - aryDirs[counter + 1] = ("$(PLUGIN_SDK_DIR)\\" .. pluginDir .. "\\" .. gameDir) - aryDirs[counter + 2] = ("$(PLUGIN_SDK_DIR)\\" .. pluginDir .. "\\" .. gameDir .. "\\enums") - aryDirs[counter + 3] = ("$(PLUGIN_SDK_DIR)\\" .. pluginDir .. "\\" .. gameDir .. "\\rw") - aryDirs[counter + 4] = "$(PLUGIN_SDK_DIR)\\shared" - aryDirs[counter + 5] = "$(PLUGIN_SDK_DIR)\\shared\\game" + aryDirs[counter] = ("$(PLUGIN_SDK_DIR)/" .. pluginDir) + aryDirs[counter + 1] = ("$(PLUGIN_SDK_DIR)/" .. pluginDir .. "/" .. gameDir) + aryDirs[counter + 2] = ("$(PLUGIN_SDK_DIR)/" .. pluginDir .. "/" .. gameDir .. "/enums") + aryDirs[counter + 3] = ("$(PLUGIN_SDK_DIR)/" .. pluginDir .. "/" .. gameDir .. "/rw") + aryDirs[counter + 4] = "$(PLUGIN_SDK_DIR)/shared" + aryDirs[counter + 5] = "$(PLUGIN_SDK_DIR)/shared/game" counter = counter + 6 if projectType == "CLEO" and cleoDir ~= "" then aryDirs[counter] = cleoDir counter = counter + 1 elseif projectType == "MOON" then - aryDirs[counter] = "$(MOONLOADER_SDK_SA_DIR)\\src" - aryDirs[counter + 1] = "$(MOONLOADER_SDK_SA_DIR)\\src\\libs\\lua" - aryDirs[counter + 2] = "$(MOONLOADER_SDK_SA_DIR)\\src\\libs\\sol2" + aryDirs[counter] = "$(MOONLOADER_SDK_SA_DIR)/src" + aryDirs[counter + 1] = "$(MOONLOADER_SDK_SA_DIR)/src/libs/lua" + aryDirs[counter + 2] = "$(MOONLOADER_SDK_SA_DIR)/src/libs/sol2" counter = counter + 3 end if usesD3d9 then if mingw then - aryDirs[counter] = "$(PLUGIN_SDK_DIR)\\shared\\dxsdk"; + aryDirs[counter] = "$(PLUGIN_SDK_DIR)/shared/dxsdk"; counter = counter + 1 end end if usesRwD3d9 then - aryDirs[counter] = "$(PLUGIN_SDK_DIR)\\shared\\rwd3d9" + aryDirs[counter] = "$(PLUGIN_SDK_DIR)/shared/rwd3d9" counter = counter + 1 end @@ -529,9 +594,9 @@ function getExamplePluginLibraryFolders(projectType, cleoDir, usesD3d9, usesRwD3 local aryDirs = {} if mingw then - aryDirs[counter] = "$(PLUGIN_SDK_DIR)\\output\\mingw\\lib" + aryDirs[counter] = "$(PLUGIN_SDK_DIR)/output/lib" else - aryDirs[counter] = "$(PLUGIN_SDK_DIR)\\output\\lib" + aryDirs[counter] = "$(PLUGIN_SDK_DIR)/output/lib" end counter = counter + 1 @@ -539,7 +604,7 @@ function getExamplePluginLibraryFolders(projectType, cleoDir, usesD3d9, usesRwD3 aryDirs[counter] = cleoDir counter = counter + 1 elseif projectType == "MOON" then - aryDirs[counter] = "$(MOONLOADER_SDK_SA_DIR)\\src\\libs\\lua" + aryDirs[counter] = "$(MOONLOADER_SDK_SA_DIR)/src/libs/lua" counter = counter + 1 end @@ -608,7 +673,7 @@ function setupDebugger(projectType, gameDirVar, gameExePath, gameExeName) fullTrgPath = os.getenv(gameDirVar) if fullTrgPath ~= nil and fullTrgPath ~= "" then fullTrgPath = fullTrgPath .. trgPath - os.execute('if not exist "' .. fullTrgPath .. '" (mkdir "' .. fullTrgPath .. '")') + os.mkdir(fullTrgPath) end postbuildcommands { "\ @@ -622,6 +687,7 @@ xcopy /Y \"$(TargetPath)\" \"$(" .. gameDirVar .. ")" .. trgPath .. "\" \r\n\ end function generatePrecompiledHeader(directory, create) + directory = path.translate(directory, "/") local headerFilename = path.join(directory, "stdafx.h") local sourceFilename = path.join(directory, "stdafx.cpp") @@ -638,20 +704,25 @@ function generatePrecompiledHeader(directory, create) -- generate stdafx.h local header = "// This file was generated by Premake\n"; - local templateFile = io.open("stdafx_template.h", "r") + local script_dir = path.getdirectory(_SCRIPT) + local templateFile = io.open(path.join(script_dir, "stdafx_template.h"), "r") + if not templateFile then + error("Could not find stdafx_template.h in " .. script_dir) + end header = header .. templateFile:read("*all") templateFile:close() -- gather include files local fileList = {} function collect(dir, excludes) - local f = os.matchfiles(sdkdir .. "\\" .. dir .. "\\**.h*") + local f = os.matchfiles(path.translate(sdkdir .. "/" .. dir .. "/**.h*")) for i=1, #f do - local p = path.getrelative(directory, f[i]):gsub("/", "\\") + local p = path.getrelative(directory, f[i]):gsub("\\", "/") local excluded = false for j=1, #excludes do - if string.find(p, excludes[j]) then + local excl = excludes[j]:gsub("\\", "/") + if string.find(p, excl) then excluded = true break end @@ -663,10 +734,10 @@ function generatePrecompiledHeader(directory, create) end end collect("hooking", {}) - collect("injector", {"\\gvm\\"}) + collect("injector", {"/gvm/"}) collect("modutils", {}) collect("safetyhook", {}) - collect("shared", {"dxsdk\\","rwd3d9.h"}) + collect("shared", {"dxsdk/","rwd3d9.h"}) collect("stb", {}) table.sort(fileList) @@ -749,6 +820,22 @@ function pluginSdkExampleProject(projectDir, projectName, projectType, game2, ga if mingw then buildoptions "-fpermissive" linkoptions { "-static-libgcc", "-static-libstdc++" } + filter "action:gmake or action:gmake2 or action:codeblocks" + toolset "clang" + buildoptions { + "-fcommon", + "-fms-extensions", + "-Wno-invalid-offsetof", + "-Wno-microsoft-include", + "-static", + } + filter { "action:gmake or action:gmake2 or action:codeblocks", "architecture:x32" } + buildoptions { "--target=i686-w64-mingw32" } + linkoptions { "--target=i686-w64-mingw32" } + filter { "action:gmake or action:gmake2 or action:codeblocks", "architecture:x64" } + buildoptions { "--target=x86_64-w64-mingw32" } + linkoptions { "--target=x86_64-w64-mingw32" } + filter {} end local ext = ".asi" @@ -985,7 +1072,7 @@ function generateNewPluginSource(projectDir, projectName, projectType, game2, ga local projectDir = path.normalize(projectDir) local sourceDir = path.join(projectDir, "source") - os.execute('if not exist "' .. sourceDir .. '" (mkdir "' .. sourceDir .. '")') + os.mkdir(sourceDir) -- generate Main.cpp local main = io.open(path.join(sourceDir, "Main.cpp"), 'w') @@ -1110,21 +1197,21 @@ else -- plugin sdk solution cleanProjectsDirectory(sdkdir .. "\\Plugin_II") cleanProjectsDirectory(sdkdir .. "\\Plugin_IV") - cleanProjectsDirectory(sdkdir .. "\\Plugin_SA_Unreal") - cleanProjectsDirectory(sdkdir .. "\\Plugin_VC_Unreal") - cleanProjectsDirectory(sdkdir .. "\\Plugin_III_Unreal") + cleanProjectsDirectory(sdkdir .. "/Plugin_SA_Unreal") + cleanProjectsDirectory(sdkdir .. "/Plugin_VC_Unreal") + cleanProjectsDirectory(sdkdir .. "/Plugin_III_Unreal") - os.remove(sdkdir .. "\\plugin.sln") - os.remove(sdkdir .. "\\plugin.suo") - os.remove(sdkdir .. "\\plugin.sdf") - os.remove(sdkdir .. "\\plugin.workspace") - os.remove(sdkdir .. "\\plugin.workspace.layout") + os.remove(path.translate(sdkdir .. "/plugin.sln")) + os.remove(path.translate(sdkdir .. "/plugin.suo")) + os.remove(path.translate(sdkdir .. "/plugin.sdf")) + os.remove(path.translate(sdkdir .. "/plugin.workspace")) + os.remove(path.translate(sdkdir .. "/plugin.workspace.layout")) deleteAllFoldersWithName(sdkdir, ".vs") - generatePrecompiledHeader(sdkdir .. "\\shared", false) + generatePrecompiledHeader(sdkdir .. "/shared", false) if _ACTION ~= "clean" then print("\nGenerating Plugin-SDK solution:") - generatePrecompiledHeader(sdkdir .. "\\shared", true) + generatePrecompiledHeader(sdkdir .. "/shared", true) workspace "plugin" location (sdkdir) From 8aef08543b3b7077a7860a7ac8386b0482f934c5 Mon Sep 17 00:00:00 2001 From: MrRealistic-Mods Date: Thu, 25 Jun 2026 01:54:45 +0530 Subject: [PATCH 03/10] removed test file --- tools/premake/build_all_clang.sh | 38 -------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 tools/premake/build_all_clang.sh diff --git a/tools/premake/build_all_clang.sh b/tools/premake/build_all_clang.sh deleted file mode 100644 index 6d173d1d5..000000000 --- a/tools/premake/build_all_clang.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -# Exit on any error -set -e - -# Resolve the project root directory relative to this script's directory -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -export PLUGIN_SDK_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" - -echo "=== Generating GNU Makefiles using Premake ===" -"$SCRIPT_DIR/linux-clang-example/premake5" gmake --file="$SCRIPT_DIR/premake5.lua" - -echo "=== Cleaning previous target output directory ===" -mkdir -p "$PLUGIN_SDK_DIR/output/lib" -rm -f "$PLUGIN_SDK_DIR/output/lib"/* - -# Target lists -targets_32=("plugin_II" "plugin_III" "plugin_vc" "plugin_sa" "plugin_IV") -targets_64=("plugin_iii_unreal" "plugin_vc_unreal" "plugin_sa_unreal") - -echo "=== Compiling 32-bit Classic Targets (Release & Debug) ===" -for target in "${targets_32[@]}"; do - echo " -> Building $target [Release]..." - make config=release RESCOMP=i686-w64-mingw32-windres AR=ar -C "$PLUGIN_SDK_DIR/$target" -j$(nproc) - echo " -> Building $target [Debug]..." - make config=zdebug RESCOMP=i686-w64-mingw32-windres AR=ar -C "$PLUGIN_SDK_DIR/$target" -j$(nproc) -done - -echo "=== Compiling 64-bit Unreal Targets (Release & Debug) ===" -for target in "${targets_64[@]}"; do - echo " -> Building $target [Release]..." - make config=release RESCOMP=x86_64-w64-mingw32-windres AR=ar -C "$PLUGIN_SDK_DIR/$target" -j$(nproc) - echo " -> Building $target [Debug]..." - make config=zdebug RESCOMP=x86_64-w64-mingw32-windres AR=ar -C "$PLUGIN_SDK_DIR/$target" -j$(nproc) -done - -echo "=== Build Complete! ===" -echo "All static libraries have been compiled and placed inside: $PLUGIN_SDK_DIR/output/lib" -ls -la "$PLUGIN_SDK_DIR/output/lib" From 2d83f8037b681235acd2fa5b625b1d9f9be18820 Mon Sep 17 00:00:00 2001 From: MrRealistic-Mods Date: Thu, 25 Jun 2026 21:30:26 +0530 Subject: [PATCH 04/10] added workflows, removed old clang files --- .../workflows/Build_Plugin_GTA_2_clang.yml | 80 +++++++++++++++ .../workflows/Build_Plugin_GTA_3_clang.yml | 80 +++++++++++++++ .../workflows/Build_Plugin_GTA_4_clang.yml | 80 +++++++++++++++ .../workflows/Build_Plugin_GTA_SA_clang.yml | 52 +++------- .../workflows/Build_Plugin_GTA_VC_clang.yml | 80 +++++++++++++++ shared/plugin.rc | 99 ------------------- shared/resource.h | 15 --- tools/premake/premake5.lua | 19 ++-- 8 files changed, 341 insertions(+), 164 deletions(-) create mode 100644 .github/workflows/Build_Plugin_GTA_2_clang.yml create mode 100644 .github/workflows/Build_Plugin_GTA_3_clang.yml create mode 100644 .github/workflows/Build_Plugin_GTA_4_clang.yml create mode 100644 .github/workflows/Build_Plugin_GTA_VC_clang.yml delete mode 100644 shared/plugin.rc delete mode 100644 shared/resource.h diff --git a/.github/workflows/Build_Plugin_GTA_2_clang.yml b/.github/workflows/Build_Plugin_GTA_2_clang.yml new file mode 100644 index 000000000..b3bd1f021 --- /dev/null +++ b/.github/workflows/Build_Plugin_GTA_2_clang.yml @@ -0,0 +1,80 @@ +name: Plugin GTA 2 (Clang) + +on: + workflow_dispatch: + + push: + paths: + - "!**.dll" + - "!**.md" + - "!**.txt" + - "tools/premake/**" + - "hooking/**" + - "injector/**" + - "modutils/**" + - "safetyhook/**" + - "shared/**" + - "plugin_II/**" + + pull_request: + paths: + - "!**.dll" + - "!**.md" + - "!**.txt" + - "tools/premake/**" + - "hooking/**" + - "injector/**" + - "modutils/**" + - "safetyhook/**" + - "shared/**" + - "plugin_II/**" + +jobs: + build: + name: Build + + # skip on pull request inside forks + if: github.event_name != 'pull_request' || github.repository == 'DK22Pac/plugin-sdk' + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + submodules: "recursive" + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y wget gnupg software-properties-common lsb-release g++-mingw-w64-i686 + + # Download LLVM installer script + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + + # Install Clang 23 + sudo ./llvm.sh 23 + + - name: Verify Clang + run: | + clang-23 --version + clang++-23 --version + + - name: Install premake5 + uses: Jarod42/install-premake5@v7 + + - name: Premake gmake project + run: | + export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE + premake5 gmake --file=tools/premake/premake5.lua + + - name: Build SDK + run: | + export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE + make config=release -C plugin_II -j$(nproc) + + - name: Build test plugin + run: | + export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE + make config=release_gta2 -C examples/Test -j$(nproc) diff --git a/.github/workflows/Build_Plugin_GTA_3_clang.yml b/.github/workflows/Build_Plugin_GTA_3_clang.yml new file mode 100644 index 000000000..c61204ecf --- /dev/null +++ b/.github/workflows/Build_Plugin_GTA_3_clang.yml @@ -0,0 +1,80 @@ +name: Plugin GTA 3 (Clang) + +on: + workflow_dispatch: + + push: + paths: + - "!**.dll" + - "!**.md" + - "!**.txt" + - "tools/premake/**" + - "hooking/**" + - "injector/**" + - "modutils/**" + - "safetyhook/**" + - "shared/**" + - "plugin_III/**" + + pull_request: + paths: + - "!**.dll" + - "!**.md" + - "!**.txt" + - "tools/premake/**" + - "hooking/**" + - "injector/**" + - "modutils/**" + - "safetyhook/**" + - "shared/**" + - "plugin_III/**" + +jobs: + build: + name: Build + + # skip on pull request inside forks + if: github.event_name != 'pull_request' || github.repository == 'DK22Pac/plugin-sdk' + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + submodules: "recursive" + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y wget gnupg software-properties-common lsb-release g++-mingw-w64-i686 + + # Download LLVM installer script + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + + # Install Clang 23 + sudo ./llvm.sh 23 + + - name: Verify Clang + run: | + clang-23 --version + clang++-23 --version + + - name: Install premake5 + uses: Jarod42/install-premake5@v7 + + - name: Premake gmake project + run: | + export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE + premake5 gmake --file=tools/premake/premake5.lua + + - name: Build SDK + run: | + export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE + make config=release -C plugin_III -j$(nproc) + + - name: Build test plugin + run: | + export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE + make config=release_gta3 -C examples/Test -j$(nproc) diff --git a/.github/workflows/Build_Plugin_GTA_4_clang.yml b/.github/workflows/Build_Plugin_GTA_4_clang.yml new file mode 100644 index 000000000..fb76df2be --- /dev/null +++ b/.github/workflows/Build_Plugin_GTA_4_clang.yml @@ -0,0 +1,80 @@ +name: Plugin GTA IV (Clang) + +on: + workflow_dispatch: + + push: + paths: + - "!**.dll" + - "!**.md" + - "!**.txt" + - "tools/premake/**" + - "hooking/**" + - "injector/**" + - "modutils/**" + - "safetyhook/**" + - "shared/**" + - "plugin_IV/**" + + pull_request: + paths: + - "!**.dll" + - "!**.md" + - "!**.txt" + - "tools/premake/**" + - "hooking/**" + - "injector/**" + - "modutils/**" + - "safetyhook/**" + - "shared/**" + - "plugin_IV/**" + +jobs: + build: + name: Build + + # skip on pull request inside forks + if: github.event_name != 'pull_request' || github.repository == 'DK22Pac/plugin-sdk' + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + submodules: "recursive" + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y wget gnupg software-properties-common lsb-release g++-mingw-w64-i686 + + # Download LLVM installer script + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + + # Install Clang 23 + sudo ./llvm.sh 23 + + - name: Verify Clang + run: | + clang-23 --version + clang++-23 --version + + - name: Install premake5 + uses: Jarod42/install-premake5@v7 + + - name: Premake gmake project + run: | + export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE + premake5 gmake --file=tools/premake/premake5.lua + + - name: Build SDK + run: | + export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE + make config=release -C plugin_IV -j$(nproc) + + - name: Build test plugin + run: | + export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE + make config=release_gta4 -C examples/Test -j$(nproc) diff --git a/.github/workflows/Build_Plugin_GTA_SA_clang.yml b/.github/workflows/Build_Plugin_GTA_SA_clang.yml index 49f7e8f3b..a9ef20e91 100644 --- a/.github/workflows/Build_Plugin_GTA_SA_clang.yml +++ b/.github/workflows/Build_Plugin_GTA_SA_clang.yml @@ -61,48 +61,20 @@ jobs: clang-23 --version clang++-23 --version - - name: Build SDK - run: | - echo "::group::Setup directories" - mkdir -p output/lib - for dir in shared plugin_sa safetyhook; do - find "$dir" -type d -exec mkdir -p "obj/{}" \; - done - echo "::groupEnd::" - - FLAGS="-I. -Ishared -Ishared/game -Iplugin_sa -Iplugin_sa/game_sa -Iplugin_sa/game_sa/enums -Iplugin_sa/game_sa/rw -Isafetyhook -DGTASA -DPLUGIN_SGV_10US -DRW" - CLANG_FLAGS="--target=i686-w64-mingw32 -fpermissive -fcommon -fms-extensions -Wno-microsoft-include -Wno-invalid-offsetof -Wno-builtin-macro-redefined -O2 -D__cpp_concepts=202202L" - - echo "::group::Compile C++ files" - find shared plugin_sa safetyhook -name '*.cpp' -print0 | \ - xargs -0 -P$(nproc) -I{} clang++-23 $CLANG_FLAGS -std=c++2b $FLAGS -c {} -o obj/{}.o - echo "::groupEnd::" + - name: Install premake5 + uses: Jarod42/install-premake5@v7 - echo "::group::Compile C files" - find safetyhook -name '*.c' -print0 | \ - xargs -0 -P$(nproc) -I{} clang-23 $CLANG_FLAGS $FLAGS -c {} -o obj/{}.o - echo "::groupEnd::" + - name: Premake gmake project + run: | + export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE + premake5 gmake --file=tools/premake/premake5.lua - echo "::group::Archive SDK" - find obj -name '*.o' | xargs i686-w64-mingw32-ar rcs output/lib/libplugin.a - echo "::groupEnd::" + - name: Build SDK + run: | + export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE + make config=release -C plugin_sa -j$(nproc) - name: Build test plugin run: | - echo "::group::Build test plugin" - - # Setup object directories for the test plugin - find examples/Test -type d -exec mkdir -p "obj/{}" \; - mkdir -p output/examples - - TEST_FLAGS="-I. -Ishared -Ishared/game -Iplugin_sa -Iplugin_sa/game_sa -Iplugin_sa/game_sa/enums -Iplugin_sa/game_sa/rw -Isafetyhook -DGTASA -DPLUGIN_SGV_10US -DRW" - TEST_CLANG_FLAGS="--target=i686-w64-mingw32 -fpermissive -fcommon -fms-extensions -Wno-microsoft-include -Wno-invalid-offsetof -Wno-builtin-macro-redefined -O2 -D__cpp_concepts=202202L" - - # Compile - find examples/Test -name '*.cpp' -print0 | \ - xargs -0 -P$(nproc) -I{} clang++-23 $TEST_CLANG_FLAGS -std=c++2b $TEST_FLAGS -c {} -o obj/{}.o - - # Link into ASI - clang++-23 --target=i686-w64-mingw32 -shared -o output/examples/Test.asi $(find obj/examples/Test -name '*.o') -Loutput/lib -lplugin -static-libgcc -static-libstdc++ -Wl,--enable-stdcall-fixup - - echo "::groupEnd::" \ No newline at end of file + export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE + make config=release_gta-sa -C examples/Test -j$(nproc) \ No newline at end of file diff --git a/.github/workflows/Build_Plugin_GTA_VC_clang.yml b/.github/workflows/Build_Plugin_GTA_VC_clang.yml new file mode 100644 index 000000000..730299464 --- /dev/null +++ b/.github/workflows/Build_Plugin_GTA_VC_clang.yml @@ -0,0 +1,80 @@ +name: Plugin GTA VC (Clang) + +on: + workflow_dispatch: + + push: + paths: + - "!**.dll" + - "!**.md" + - "!**.txt" + - "tools/premake/**" + - "hooking/**" + - "injector/**" + - "modutils/**" + - "safetyhook/**" + - "shared/**" + - "plugin_vc/**" + + pull_request: + paths: + - "!**.dll" + - "!**.md" + - "!**.txt" + - "tools/premake/**" + - "hooking/**" + - "injector/**" + - "modutils/**" + - "safetyhook/**" + - "shared/**" + - "plugin_vc/**" + +jobs: + build: + name: Build + + # skip on pull request inside forks + if: github.event_name != 'pull_request' || github.repository == 'DK22Pac/plugin-sdk' + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + submodules: "recursive" + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y wget gnupg software-properties-common lsb-release g++-mingw-w64-i686 + + # Download LLVM installer script + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + + # Install Clang 23 + sudo ./llvm.sh 23 + + - name: Verify Clang + run: | + clang-23 --version + clang++-23 --version + + - name: Install premake5 + uses: Jarod42/install-premake5@v7 + + - name: Premake gmake project + run: | + export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE + premake5 gmake --file=tools/premake/premake5.lua + + - name: Build SDK + run: | + export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE + make config=release -C plugin_vc -j$(nproc) + + - name: Build test plugin + run: | + export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE + make config=release_gta-vc -C examples/Test -j$(nproc) diff --git a/shared/plugin.rc b/shared/plugin.rc deleted file mode 100644 index b8be53e37..000000000 --- a/shared/plugin.rc +++ /dev/null @@ -1,99 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "winres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""winres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 16,0,0,0 - PRODUCTVERSION 16,0,0,0 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x7L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", "DK22Pac" - VALUE "FileDescription", "Plugin development kit for GTA SA, GTA VC, GTA 3 and GTA 2." - VALUE "FileVersion", "16.0.0.0" - VALUE "InternalName", "plugin.lib" - VALUE "LegalCopyright", "Copyright (C) 2023" - VALUE "OriginalFilename", "plugin.lib" - VALUE "ProductName", "Plugin-SDK" - VALUE "ProductVersion", "16.0.0.0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // English (United States) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/shared/resource.h b/shared/resource.h deleted file mode 100644 index 402c90313..000000000 --- a/shared/resource.h +++ /dev/null @@ -1,15 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by plugin.rc -// - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/tools/premake/premake5.lua b/tools/premake/premake5.lua index 767e284cc..908cba37d 100644 --- a/tools/premake/premake5.lua +++ b/tools/premake/premake5.lua @@ -308,7 +308,6 @@ function pluginSdkStaticLibProject(projectName, sdkdir, outName, isPluginProject (projectPath .. "/**.cpp"), (sdkdir .. "/shared/**.h"), (sdkdir .. "/shared/**.cpp"), - (sdkdir .. "/shared/**.rc"), (sdkdir .. "/hooking/**.cpp"), (sdkdir .. "/hooking/**.h"), (sdkdir .. "/injector/**.hpp"), @@ -905,7 +904,7 @@ function pluginSdkExampleProject(projectDir, projectName, projectType, game2, ga defines (getExamplePluginDefines(projectName, "GTAVC", projectType, d3dSupport, additionalDefinitions, "Vice City", "VC", "vc", "Tommy", "Vice City")) setupDebugger(projectType, "GTA_VC_DIR", "", "gta-vc.exe") filter { "Release", "platforms:GTA-VC" } - links (getExamplePluginLibraries("plugin_vc", projectType, "VC.CLEO", d3dSupport, d3dSupport, additionalLibraries, false)) + links (getExamplePluginLibraries("Plugin_VC", projectType, "VC.CLEO", d3dSupport, d3dSupport, additionalLibraries, false)) targetname (projectName .. ".VC") filter { "Debug", "platforms:GTA-VC" } links (getExamplePluginLibraries("Plugin_VC", projectType, "VC.CLEO", d3dSupport, d3dSupport, additionalLibraries, true)) @@ -921,10 +920,10 @@ function pluginSdkExampleProject(projectDir, projectName, projectType, game2, ga defines (getExamplePluginDefines(projectName, "GTASA", projectType, d3dSupport, additionalDefinitions, "San Andreas", "SA", "sa", "CJ", "San Andreas")) setupDebugger(projectType, "GTA_SA_DIR", "", "gta_sa.exe") filter { "Release", "platforms:GTA-SA" } - links (getExamplePluginLibraries("plugin", projectType, "cleo", d3dSupport, false, additionalLibraries, false)) + links (getExamplePluginLibraries("Plugin", projectType, "cleo", d3dSupport, false, additionalLibraries, false)) targetname (projectName .. ".SA") filter { "Debug", "platforms:GTA-SA" } - links (getExamplePluginLibraries("plugin", projectType, "cleo", d3dSupport, false, additionalLibraries, true)) + links (getExamplePluginLibraries("Plugin", projectType, "cleo", d3dSupport, false, additionalLibraries, true)) targetname (projectName .. ".SA") filter {} end @@ -953,7 +952,7 @@ function pluginSdkExampleProject(projectDir, projectName, projectType, game2, ga defines (getExamplePluginDefines(projectName, "GTA3_UNREAL", projectType, d3dSupport, additionalDefinitions, "3", "3", "3", "Claude", "Liberty City")) setupDebugger(projectType, "GTA_III_UNREAL_DIR", "Gameface\\Binaries\\Win64\\", "LibertyCity.exe") filter { "Release", "platforms:GTA3_Unreal" } - links (getExamplePluginLibraries("plugin_iii_unreal", projectType, "", d3dSupport, false, additionalLibraries, false)) + links (getExamplePluginLibraries("Plugin_III_Unreal", projectType, "", d3dSupport, false, additionalLibraries, false)) targetname (projectName .. ".III-DE") filter { "Debug", "platforms:GTA3_Unreal" } links (getExamplePluginLibraries("Plugin_III_Unreal", projectType, "", d3dSupport, false, additionalLibraries, true)) @@ -969,7 +968,7 @@ function pluginSdkExampleProject(projectDir, projectName, projectType, game2, ga defines (getExamplePluginDefines(projectName, "GTAVC_UNREAL", projectType, d3dSupport, additionalDefinitions, "Vice City", "VC", "vc", "Tommy", "Vice City")) setupDebugger(projectType, "GTA_VC_UNREAL_DIR", "Gameface\\Binaries\\Win64\\", "ViceCity.exe") filter { "Release", "platforms:GTA-VC_Unreal" } - links (getExamplePluginLibraries("plugin_vc_unreal", projectType, "", d3dSupport, d3dSupport, additionalLibraries, false)) + links (getExamplePluginLibraries("Plugin_VC_Unreal", projectType, "", d3dSupport, d3dSupport, additionalLibraries, false)) targetname (projectName .. ".VC-DE") filter { "Debug", "platforms:GTA-VC_Unreal" } links (getExamplePluginLibraries("Plugin_VC_Unreal", projectType, "", d3dSupport, d3dSupport, additionalLibraries, true)) @@ -985,7 +984,7 @@ function pluginSdkExampleProject(projectDir, projectName, projectType, game2, ga defines (getExamplePluginDefines(projectName, "GTASA_UNREAL", projectType, d3dSupport, additionalDefinitions, "San Andreas", "SA", "sa", "CJ", "San Andreas")) setupDebugger(projectType, "GTA_SA_UNREAL_DIR", "Gameface\\Binaries\\Win64\\", "SanAndreas.exe") filter { "Release", "platforms:GTA-SA_Unreal" } - links (getExamplePluginLibraries("plugin_unreal", projectType, "", d3dSupport, false, additionalLibraries, false)) + links (getExamplePluginLibraries("Plugin_Unreal", projectType, "", d3dSupport, false, additionalLibraries, false)) targetname (projectName .. ".SA-DE") filter { "Debug", "platforms:GTA-SA_Unreal" } links (getExamplePluginLibraries("Plugin_Unreal", projectType, "", d3dSupport, false, additionalLibraries, true)) @@ -1228,11 +1227,11 @@ else -- plugin sdk solution pluginSdkStaticLibProject("Plugin_SA_Unreal", sdkdir, "Plugin_Unreal", true, "Game_SA_Unreal") print("\nGenerating example projects:") - local f = io.open(sdkdir .. "\\examples\\examples.csv", "rb") + local f = io.open(sdkdir .. "/examples/examples.csv", "rb") if f then f:close() local firstLine = true - for line in io.lines(sdkdir .. "\\examples\\examples.csv") do + for line in io.lines(sdkdir .. "/examples/examples.csv") do if firstLine then -- skip the header row firstLine = false @@ -1247,7 +1246,7 @@ else -- plugin sdk solution params[i] = params[i]:gsub("%s+", "") end - local projDir = (sdkdir .. "\\examples\\" .. params[1]) + local projDir = (sdkdir .. "/examples/" .. params[1]) pluginSdkExampleProject(projDir, params[1], -- name params[2], -- project type From d8d6d8f3e72720b5d29426a776d479c7cef23337 Mon Sep 17 00:00:00 2001 From: MrRealistic-Mods Date: Thu, 25 Jun 2026 21:34:41 +0530 Subject: [PATCH 05/10] fixes --- .github/workflows/Build_Plugin_GTA_2_clang.yml | 4 ++-- .github/workflows/Build_Plugin_GTA_3_clang.yml | 4 ++-- .github/workflows/Build_Plugin_GTA_4_clang.yml | 4 ++-- .github/workflows/Build_Plugin_GTA_SA_clang.yml | 4 ++-- .github/workflows/Build_Plugin_GTA_VC_clang.yml | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/Build_Plugin_GTA_2_clang.yml b/.github/workflows/Build_Plugin_GTA_2_clang.yml index b3bd1f021..b53209b56 100644 --- a/.github/workflows/Build_Plugin_GTA_2_clang.yml +++ b/.github/workflows/Build_Plugin_GTA_2_clang.yml @@ -72,9 +72,9 @@ jobs: - name: Build SDK run: | export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE - make config=release -C plugin_II -j$(nproc) + make config=release CXX=clang++-23 CC=clang-23 -C plugin_II -j$(nproc) - name: Build test plugin run: | export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE - make config=release_gta2 -C examples/Test -j$(nproc) + make config=release_gta2 CXX=clang++-23 CC=clang-23 -C examples/Test -j$(nproc) diff --git a/.github/workflows/Build_Plugin_GTA_3_clang.yml b/.github/workflows/Build_Plugin_GTA_3_clang.yml index c61204ecf..1bff05122 100644 --- a/.github/workflows/Build_Plugin_GTA_3_clang.yml +++ b/.github/workflows/Build_Plugin_GTA_3_clang.yml @@ -72,9 +72,9 @@ jobs: - name: Build SDK run: | export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE - make config=release -C plugin_III -j$(nproc) + make config=release CXX=clang++-23 CC=clang-23 -C plugin_III -j$(nproc) - name: Build test plugin run: | export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE - make config=release_gta3 -C examples/Test -j$(nproc) + make config=release_gta3 CXX=clang++-23 CC=clang-23 -C examples/Test -j$(nproc) diff --git a/.github/workflows/Build_Plugin_GTA_4_clang.yml b/.github/workflows/Build_Plugin_GTA_4_clang.yml index fb76df2be..41687fad8 100644 --- a/.github/workflows/Build_Plugin_GTA_4_clang.yml +++ b/.github/workflows/Build_Plugin_GTA_4_clang.yml @@ -72,9 +72,9 @@ jobs: - name: Build SDK run: | export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE - make config=release -C plugin_IV -j$(nproc) + make config=release CXX=clang++-23 CC=clang-23 -C plugin_IV -j$(nproc) - name: Build test plugin run: | export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE - make config=release_gta4 -C examples/Test -j$(nproc) + make config=release_gta4 CXX=clang++-23 CC=clang-23 -C examples/Test -j$(nproc) diff --git a/.github/workflows/Build_Plugin_GTA_SA_clang.yml b/.github/workflows/Build_Plugin_GTA_SA_clang.yml index a9ef20e91..775f56d30 100644 --- a/.github/workflows/Build_Plugin_GTA_SA_clang.yml +++ b/.github/workflows/Build_Plugin_GTA_SA_clang.yml @@ -72,9 +72,9 @@ jobs: - name: Build SDK run: | export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE - make config=release -C plugin_sa -j$(nproc) + make config=release CXX=clang++-23 CC=clang-23 -C plugin_sa -j$(nproc) - name: Build test plugin run: | export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE - make config=release_gta-sa -C examples/Test -j$(nproc) \ No newline at end of file + make config=release_gta-sa CXX=clang++-23 CC=clang-23 -C examples/Test -j$(nproc) \ No newline at end of file diff --git a/.github/workflows/Build_Plugin_GTA_VC_clang.yml b/.github/workflows/Build_Plugin_GTA_VC_clang.yml index 730299464..788f18d3d 100644 --- a/.github/workflows/Build_Plugin_GTA_VC_clang.yml +++ b/.github/workflows/Build_Plugin_GTA_VC_clang.yml @@ -72,9 +72,9 @@ jobs: - name: Build SDK run: | export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE - make config=release -C plugin_vc -j$(nproc) + make config=release CXX=clang++-23 CC=clang-23 -C plugin_vc -j$(nproc) - name: Build test plugin run: | export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE - make config=release_gta-vc -C examples/Test -j$(nproc) + make config=release_gta-vc CXX=clang++-23 CC=clang-23 -C examples/Test -j$(nproc) From f84c1d5cfb72a100a6414a355f66e17877586742 Mon Sep 17 00:00:00 2001 From: MrRealistic-Mods Date: Thu, 25 Jun 2026 21:36:48 +0530 Subject: [PATCH 06/10] fixes --- tools/premake/premake5.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/premake/premake5.lua b/tools/premake/premake5.lua index 908cba37d..64537bcf9 100644 --- a/tools/premake/premake5.lua +++ b/tools/premake/premake5.lua @@ -211,6 +211,7 @@ function pluginSdkStaticLibProject(projectName, sdkdir, outName, isPluginProject "-Wno-invalid-offsetof", "-Wno-microsoft-include", "-static", + "-D__cpp_concepts=202202L", } filter { "action:gmake or action:gmake2 or action:codeblocks", "architecture:x32" } buildoptions { "--target=i686-w64-mingw32" } @@ -827,6 +828,7 @@ function pluginSdkExampleProject(projectDir, projectName, projectType, game2, ga "-Wno-invalid-offsetof", "-Wno-microsoft-include", "-static", + "-D__cpp_concepts=202202L", } filter { "action:gmake or action:gmake2 or action:codeblocks", "architecture:x32" } buildoptions { "--target=i686-w64-mingw32" } From 3f837bc9fa8858b09a8dc14fb8f4df8a581fe5bb Mon Sep 17 00:00:00 2001 From: MrRealistic-Mods Date: Thu, 25 Jun 2026 21:49:45 +0530 Subject: [PATCH 07/10] fixed build --- .github/workflows/Build_Plugin_GTA_2_clang.yml | 4 ++-- .github/workflows/Build_Plugin_GTA_3_clang.yml | 4 ++-- .github/workflows/Build_Plugin_GTA_4_clang.yml | 4 ++-- .github/workflows/Build_Plugin_GTA_SA_clang.yml | 4 ++-- .github/workflows/Build_Plugin_GTA_VC_clang.yml | 4 ++-- tools/premake/premake5.lua | 2 ++ 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/Build_Plugin_GTA_2_clang.yml b/.github/workflows/Build_Plugin_GTA_2_clang.yml index b53209b56..58fd94110 100644 --- a/.github/workflows/Build_Plugin_GTA_2_clang.yml +++ b/.github/workflows/Build_Plugin_GTA_2_clang.yml @@ -72,9 +72,9 @@ jobs: - name: Build SDK run: | export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE - make config=release CXX=clang++-23 CC=clang-23 -C plugin_II -j$(nproc) + make config=release CXX=clang++-23 CC=clang-23 AR=ar -C plugin_II -j$(nproc) - name: Build test plugin run: | export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE - make config=release_gta2 CXX=clang++-23 CC=clang-23 -C examples/Test -j$(nproc) + make config=release_gta2 CXX=clang++-23 CC=clang-23 AR=ar -C examples/Test -j$(nproc) diff --git a/.github/workflows/Build_Plugin_GTA_3_clang.yml b/.github/workflows/Build_Plugin_GTA_3_clang.yml index 1bff05122..2a396b732 100644 --- a/.github/workflows/Build_Plugin_GTA_3_clang.yml +++ b/.github/workflows/Build_Plugin_GTA_3_clang.yml @@ -72,9 +72,9 @@ jobs: - name: Build SDK run: | export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE - make config=release CXX=clang++-23 CC=clang-23 -C plugin_III -j$(nproc) + make config=release CXX=clang++-23 CC=clang-23 AR=ar -C plugin_III -j$(nproc) - name: Build test plugin run: | export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE - make config=release_gta3 CXX=clang++-23 CC=clang-23 -C examples/Test -j$(nproc) + make config=release_gta3 CXX=clang++-23 CC=clang-23 AR=ar -C examples/Test -j$(nproc) diff --git a/.github/workflows/Build_Plugin_GTA_4_clang.yml b/.github/workflows/Build_Plugin_GTA_4_clang.yml index 41687fad8..ce7fbb6dc 100644 --- a/.github/workflows/Build_Plugin_GTA_4_clang.yml +++ b/.github/workflows/Build_Plugin_GTA_4_clang.yml @@ -72,9 +72,9 @@ jobs: - name: Build SDK run: | export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE - make config=release CXX=clang++-23 CC=clang-23 -C plugin_IV -j$(nproc) + make config=release CXX=clang++-23 CC=clang-23 AR=ar -C plugin_IV -j$(nproc) - name: Build test plugin run: | export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE - make config=release_gta4 CXX=clang++-23 CC=clang-23 -C examples/Test -j$(nproc) + make config=release_gta4 CXX=clang++-23 CC=clang-23 AR=ar -C examples/Test -j$(nproc) diff --git a/.github/workflows/Build_Plugin_GTA_SA_clang.yml b/.github/workflows/Build_Plugin_GTA_SA_clang.yml index 775f56d30..d54357c4b 100644 --- a/.github/workflows/Build_Plugin_GTA_SA_clang.yml +++ b/.github/workflows/Build_Plugin_GTA_SA_clang.yml @@ -72,9 +72,9 @@ jobs: - name: Build SDK run: | export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE - make config=release CXX=clang++-23 CC=clang-23 -C plugin_sa -j$(nproc) + make config=release CXX=clang++-23 CC=clang-23 AR=ar -C plugin_sa -j$(nproc) - name: Build test plugin run: | export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE - make config=release_gta-sa CXX=clang++-23 CC=clang-23 -C examples/Test -j$(nproc) \ No newline at end of file + make config=release_gta-sa CXX=clang++-23 CC=clang-23 AR=ar -C examples/Test -j$(nproc) \ No newline at end of file diff --git a/.github/workflows/Build_Plugin_GTA_VC_clang.yml b/.github/workflows/Build_Plugin_GTA_VC_clang.yml index 788f18d3d..8956d1548 100644 --- a/.github/workflows/Build_Plugin_GTA_VC_clang.yml +++ b/.github/workflows/Build_Plugin_GTA_VC_clang.yml @@ -72,9 +72,9 @@ jobs: - name: Build SDK run: | export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE - make config=release CXX=clang++-23 CC=clang-23 -C plugin_vc -j$(nproc) + make config=release CXX=clang++-23 CC=clang-23 AR=ar -C plugin_vc -j$(nproc) - name: Build test plugin run: | export PLUGIN_SDK_DIR=$GITHUB_WORKSPACE - make config=release_gta-vc CXX=clang++-23 CC=clang-23 -C examples/Test -j$(nproc) + make config=release_gta-vc CXX=clang++-23 CC=clang-23 AR=ar -C examples/Test -j$(nproc) diff --git a/tools/premake/premake5.lua b/tools/premake/premake5.lua index 64537bcf9..bfabdfafa 100644 --- a/tools/premake/premake5.lua +++ b/tools/premake/premake5.lua @@ -210,6 +210,7 @@ function pluginSdkStaticLibProject(projectName, sdkdir, outName, isPluginProject "-fms-extensions", "-Wno-invalid-offsetof", "-Wno-microsoft-include", + "-Wno-builtin-macro-redefined", "-static", "-D__cpp_concepts=202202L", } @@ -827,6 +828,7 @@ function pluginSdkExampleProject(projectDir, projectName, projectType, game2, ga "-fms-extensions", "-Wno-invalid-offsetof", "-Wno-microsoft-include", + "-Wno-builtin-macro-redefined", "-static", "-D__cpp_concepts=202202L", } From b89d4fe44e4dea3be41c95c883bbb71b6ce954bb Mon Sep 17 00:00:00 2001 From: MrRealistic-Mods Date: Thu, 25 Jun 2026 21:55:32 +0530 Subject: [PATCH 08/10] fixed linktimeoptimization --- tools/premake/premake5.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/premake/premake5.lua b/tools/premake/premake5.lua index bfabdfafa..f62ad0c3c 100644 --- a/tools/premake/premake5.lua +++ b/tools/premake/premake5.lua @@ -255,8 +255,10 @@ function pluginSdkStaticLibProject(projectName, sdkdir, outName, isPluginProject filter "Release" optimize "On" - linktimeoptimization "On" + if linktimeoptimization then linktimeoptimization "On" end symbols "Off" + filter { "Release", "action:gmake or action:gmake2 or action:codeblocks" } + if linktimeoptimization then linktimeoptimization "Off" end filter "zDebug" symbols "On" defines "DEBUG" @@ -852,7 +854,9 @@ function pluginSdkExampleProject(projectDir, projectName, projectType, game2, ga filter "Release" optimize "On" symbols "Off" - linktimeoptimization "On" + if linktimeoptimization then linktimeoptimization "On" end + filter { "Release", "action:gmake or action:gmake2 or action:codeblocks" } + if linktimeoptimization then linktimeoptimization "Off" end filter "Debug" symbols "On" defines "DEBUG" From 8070b2bd18343aeacae3d7640e8bb6fcf1f445ed Mon Sep 17 00:00:00 2001 From: MrRealistic-Mods Date: Thu, 25 Jun 2026 22:03:19 +0530 Subject: [PATCH 09/10] fixed test plugin build issue --- tools/premake/premake5.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/premake/premake5.lua b/tools/premake/premake5.lua index f62ad0c3c..ae8968793 100644 --- a/tools/premake/premake5.lua +++ b/tools/premake/premake5.lua @@ -679,11 +679,13 @@ function setupDebugger(projectType, gameDirVar, gameExePath, gameExeName) os.mkdir(fullTrgPath) end - postbuildcommands { "\ + if os.host() == "windows" then + postbuildcommands { "\ if defined " .. gameDirVar .. " ( \r\n\ taskkill /IM " .. gameExeName .. " /F /FI \"STATUS eq RUNNING\" \r\n\ xcopy /Y \"$(TargetPath)\" \"$(" .. gameDirVar .. ")" .. trgPath .. "\" \r\n\ )" } + end debugcommand ("$(" .. gameDirVar .. ")\\" .. gameExePath .. gameExeName) debugdir ("$(" .. gameDirVar .. ")") From f76309d020a53e5ef0bcb5ac65105565460a5ae1 Mon Sep 17 00:00:00 2001 From: MrRealistic-Mods Date: Fri, 26 Jun 2026 19:20:05 +0530 Subject: [PATCH 10/10] sdkdir translation fix --- tools/premake/premake5.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/premake/premake5.lua b/tools/premake/premake5.lua index ae8968793..3c1a5fa0d 100644 --- a/tools/premake/premake5.lua +++ b/tools/premake/premake5.lua @@ -36,6 +36,7 @@ if sdkdir == nil or sdkdir == "" then print("ERROR!\nCan't locate Plugin-SDK directory\n") os.exit(1) end +sdkdir = path.translate(sdkdir) projectType = _OPTIONS["type"] if projectType == nil then @@ -720,7 +721,7 @@ function generatePrecompiledHeader(directory, create) -- gather include files local fileList = {} function collect(dir, excludes) - local f = os.matchfiles(path.translate(sdkdir .. "/" .. dir .. "/**.h*")) + local f = os.matchfiles(sdkdir .. "/" .. dir .. "/**.h*") for i=1, #f do local p = path.getrelative(directory, f[i]):gsub("\\", "/") @@ -1210,11 +1211,11 @@ else -- plugin sdk solution cleanProjectsDirectory(sdkdir .. "/Plugin_VC_Unreal") cleanProjectsDirectory(sdkdir .. "/Plugin_III_Unreal") - os.remove(path.translate(sdkdir .. "/plugin.sln")) - os.remove(path.translate(sdkdir .. "/plugin.suo")) - os.remove(path.translate(sdkdir .. "/plugin.sdf")) - os.remove(path.translate(sdkdir .. "/plugin.workspace")) - os.remove(path.translate(sdkdir .. "/plugin.workspace.layout")) + os.remove(sdkdir .. "/plugin.sln") + os.remove(sdkdir .. "/plugin.suo") + os.remove(sdkdir .. "/plugin.sdf") + os.remove(sdkdir .. "/plugin.workspace") + os.remove(sdkdir .. "/plugin.workspace.layout") deleteAllFoldersWithName(sdkdir, ".vs") generatePrecompiledHeader(sdkdir .. "/shared", false)