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..58fd94110 --- /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 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 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 new file mode 100644 index 000000000..2a396b732 --- /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 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 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 new file mode 100644 index 000000000..ce7fbb6dc --- /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 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 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 49f7e8f3b..d54357c4b 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 CXX=clang++-23 CC=clang-23 AR=ar -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 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 new file mode 100644 index 000000000..8956d1548 --- /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 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 AR=ar -C examples/Test -j$(nproc) 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/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..38e70ead6 100644 --- a/plugin_IV/game_IV/CCam.h +++ b/plugin_IV/game_IV/CCam.h @@ -124,7 +124,7 @@ class CCam { uint32_t field_338; uint32_t field_342; uint32_t field_448; - uint8_t field_500[810]; + 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/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 deleted file mode 100644 index 81e29f86f..000000000 Binary files a/shared/plugin.rc and /dev/null differ 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/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..3c1a5fa0d 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"] @@ -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 @@ -49,22 +50,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 +84,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 +92,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 +159,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 +173,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 +194,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 +204,24 @@ 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", + "-Wno-builtin-macro-redefined", + "-static", + "-D__cpp_concepts=202202L", + } + 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 @@ -189,30 +256,32 @@ 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" 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 +294,36 @@ 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 .. "/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 +554,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 +598,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 +608,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,20 +677,23 @@ 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 { "\ + 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 .. ")") 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 +710,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(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 +740,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 +826,24 @@ 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", + "-Wno-builtin-macro-redefined", + "-static", + "-D__cpp_concepts=202202L", + } + 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" @@ -762,7 +857,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" @@ -818,7 +915,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)) @@ -834,10 +931,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 @@ -866,7 +963,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)) @@ -882,7 +979,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)) @@ -898,7 +995,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)) @@ -985,7 +1082,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 +1207,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(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) + 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) @@ -1141,11 +1238,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 @@ -1160,7 +1257,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