diff --git a/.github/workflows/Build_Plugin_GTA_SA_clang.yml b/.github/workflows/Build_Plugin_GTA_SA_clang.yml new file mode 100644 index 00000000..4d511c6c --- /dev/null +++ b/.github/workflows/Build_Plugin_GTA_SA_clang.yml @@ -0,0 +1,104 @@ +name: Plugin GTA SA (Clang) + +on: + workflow_dispatch: + + push: + paths: + - "!**.dll" + - "!**.md" + - "!**.txt" + - "tools/premake/**" + - "hooking/**" + - "injector/**" + - "modutils/**" + - "safetyhook/**" + - "shared/**" + - "plugin_sa/**" + + pull_request: + paths: + - "!**.dll" + - "!**.md" + - "!**.txt" + - "tools/premake/**" + - "hooking/**" + - "injector/**" + - "modutils/**" + - "safetyhook/**" + - "shared/**" + - "plugin_sa/**" + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + 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: 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/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::" + + 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::" + + echo "::group::Archive SDK" + find obj -name '*.o' | xargs i686-w64-mingw32-ar rcs output/lib/libplugin.a + echo "::groupEnd::" + + - 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/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 diff --git a/examples/Test/Main.cpp b/examples/Test/Main.cpp index 59677b49..1f1a312c 100644 --- a/examples/Test/Main.cpp +++ b/examples/Test/Main.cpp @@ -13,7 +13,7 @@ struct Main Main() { // register event callbacks - Events::gameProcessEvent += []{ gInstance.OnGameProcess(); }; + Events::gameProcessEvent += [this]{ OnGameProcess(); }; } void OnGameProcess() diff --git a/injector/injector.hpp b/injector/injector.hpp index de4a8b47..96345ae8 100644 --- a/injector/injector.hpp +++ b/injector/injector.hpp @@ -642,7 +642,7 @@ namespace injector template static T *get() { - return get().get(); + return get().template get(); } private: diff --git a/plugin_sa/game_sa/CAEPedSpeechAudioEntity.h b/plugin_sa/game_sa/CAEPedSpeechAudioEntity.h index c2ae70d5..6059ccf1 100644 --- a/plugin_sa/game_sa/CAEPedSpeechAudioEntity.h +++ b/plugin_sa/game_sa/CAEPedSpeechAudioEntity.h @@ -19,6 +19,7 @@ enum eAudioPedType { PED_TYPE_SPC = 5 }; +class CPed; class CAEPedSpeechAudioEntity : public CAEAudioEntity { public: diff --git a/plugin_sa/game_sa/CBike.h b/plugin_sa/game_sa/CBike.h index fd6692ae..d0e527ee 100644 --- a/plugin_sa/game_sa/CBike.h +++ b/plugin_sa/game_sa/CBike.h @@ -7,9 +7,9 @@ #pragma once #include "PluginBase.h" #include "CVehicle.h" +#include "eSkidmarkType.h" #include "tBikeHandlingData.h" - enum eBikeNodes { BIKE_NODE_NONE = 0, BIKE_CHASSIS = 1, diff --git a/plugin_sa/game_sa/CPostEffects.h b/plugin_sa/game_sa/CPostEffects.h index 24cd4a0a..034d1acb 100644 --- a/plugin_sa/game_sa/CPostEffects.h +++ b/plugin_sa/game_sa/CPostEffects.h @@ -9,6 +9,8 @@ #include "RenderWare.h" #include "CRGBA.h" +class CPed; + class CPostEffects { public: static void Initialise(); diff --git a/plugin_sa/game_sa/CTaskSimpleHoldEntity.h b/plugin_sa/game_sa/CTaskSimpleHoldEntity.h index 48b47165..bb96a63e 100644 --- a/plugin_sa/game_sa/CTaskSimpleHoldEntity.h +++ b/plugin_sa/game_sa/CTaskSimpleHoldEntity.h @@ -7,8 +7,19 @@ #pragma once #include "PluginBase.h" -#include "CTaskSimple.h" +#include "CAEAudioEntity.h" #include "CAnimBlock.h" +#include "CTaskSimple.h" +#include "CVector.h" +#include "eAnimations.h" + +class CEntity; +class CAnimBlendAssociation; +class CAnimBlendHierarchy; + +#ifndef _MSC_VER +class CVector; +#endif class PLUGIN_API CTaskSimpleHoldEntity : public CTaskSimple { protected: diff --git a/tools/premake/linux-clang-example/premake5 b/tools/premake/linux-clang-example/premake5 new file mode 100755 index 00000000..b5354b58 Binary files /dev/null and b/tools/premake/linux-clang-example/premake5 differ diff --git a/tools/premake/linux-clang-example/premake5.lua b/tools/premake/linux-clang-example/premake5.lua index 1624c3f2..3b3b6b7c 100644 --- a/tools/premake/linux-clang-example/premake5.lua +++ b/tools/premake/linux-clang-example/premake5.lua @@ -30,6 +30,7 @@ project "plugin_sa" "-fpermissive", "-fcommon", "-fms-extensions", + "-Wno-invalid-offsetof", "-Wno-microsoft-include" , "-static", }