diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a74f60b..bf80ebc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,4 +29,10 @@ jobs: with: name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }} path: | - bin/ + bin/DLL/ + + - uses: actions/upload-artifact@v3 + with: + name: PDB + path: | + bin/PDB/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 015da94..d01ad80 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,7 @@ jobs: uses: actions/checkout@v2 with: submodules: recursive - + - uses: actions/checkout@v4 - uses: xmake-io/github-action-setup-xmake@v1 @@ -29,7 +29,13 @@ jobs: with: name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }} path: | - bin/ + bin/DLL/ + + - uses: actions/upload-artifact@v3 + with: + name: PDB + path: | + bin/PDB/ upload-to-release: needs: @@ -38,24 +44,35 @@ jobs: contents: write runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 - - uses: actions/download-artifact@v3 + - name: Download Plugin + uses: actions/download-artifact@v3 with: name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }} - path: release/ + path: release/Plugin/ - - run: | - cp LICENSE README.md release/ + - name: Download PDB + uses: actions/download-artifact@v3 + with: + name: PDB + path: release/PDB/ + + - name: Copy additional files + run: | + cp LICENSE README.md release/Plugin/ - name: Archive release run: | - cd release + cd release/Plugin zip -r ../${{ github.event.repository.name }}-windows-x64.zip * cd .. - - uses: softprops/action-gh-release@v1 + - name: Create GitHub Release + id: create_release + uses: softprops/action-gh-release@v1 with: - append_body: true files: | - ${{ github.event.repository.name }}-windows-x64.zip + release/${{ github.event.repository.name }}-windows-x64.zip + release/PDB/${{ github.event.repository.name }}.pdb diff --git a/manifest.json b/manifest.json index 873cf5a..2dea787 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "${pluginName}", "entry": "${pluginFile}", - "version": "0.9.3", + "version": "0.9.4", "type": "native", "dependencies": [ { diff --git a/scripts/after_build.lua b/scripts/after_build.lua index 3c1f6d1..d3fc616 100644 --- a/scripts/after_build.lua +++ b/scripts/after_build.lua @@ -88,10 +88,11 @@ function pack_plugin(target,plugin_define) local manifest_path = find_file("manifest.json", os.projectdir()) if manifest_path then local manifest = io.readfile(manifest_path) - local bindir = path.join(os.projectdir(), "bin") + local bindir = path.join(os.projectdir(), "bin/DLL") + local pdbdir = path.join(os.projectdir(), "bin/PDB") local outputdir = path.join(bindir, plugin_define.pluginName) local targetfile = path.join(outputdir, plugin_define.pluginFile) - local pdbfile = path.join(outputdir, path.basename(plugin_define.pluginFile) .. ".pdb") + local pdbfile = path.join(pdbdir, path.basename(plugin_define.pluginFile) .. ".pdb") local libfile = path.join(os.projectdir(), "lib") local manifestfile = path.join(outputdir, "manifest.json") local oritargetfile = target:targetfile() diff --git a/src/Entry.cpp b/src/Entry.cpp index 5db0e49..cac3698 100644 --- a/src/Entry.cpp +++ b/src/Entry.cpp @@ -5,17 +5,12 @@ ll::Logger logger(PLUGIN_NAME); namespace GMLIB_LegacyRemoteCallApi { -namespace { +std::unique_ptr& LRCA::getInstance() { + static std::unique_ptr instance; + return instance; +} -std::unique_ptr> - selfPluginInstance; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) - -auto disable(ll::plugin::NativePlugin& /*self*/) -> bool { return true; } - -auto enable(ll::plugin::NativePlugin& /*self*/) -> bool { return true; } - -auto load(ll::plugin::NativePlugin& self) -> bool { - selfPluginInstance = std::make_unique>(self); +bool LRCA::load() { Export_Legacy_GMLib_ModAPI(); Export_Legacy_GMLib_ServerAPI(); Export_Compatibility_API(); @@ -28,31 +23,10 @@ auto load(ll::plugin::NativePlugin& self) -> bool { return true; } -auto unload(ll::plugin::NativePlugin& self) -> bool { return false; } +bool LRCA::enable() { return true; } -} // namespace - -auto getSelfPluginInstance() -> ll::plugin::NativePlugin& { - if (!selfPluginInstance) { - throw std::runtime_error("selfPluginInstance is null"); - } - - return *selfPluginInstance; -} +bool LRCA::disable() { return true; } } // namespace GMLIB_LegacyRemoteCallApi -extern "C" { -_declspec(dllexport) auto ll_plugin_disable(ll::plugin::NativePlugin& self) -> bool { - return GMLIB_LegacyRemoteCallApi::disable(self); -} -_declspec(dllexport) auto ll_plugin_enable(ll::plugin::NativePlugin& self) -> bool { - return GMLIB_LegacyRemoteCallApi::enable(self); -} -_declspec(dllexport) auto ll_plugin_load(ll::plugin::NativePlugin& self) -> bool { - return GMLIB_LegacyRemoteCallApi::load(self); -} -_declspec(dllexport) auto ll_plugin_unload(ll::plugin::NativePlugin& self) -> bool { - return GMLIB_LegacyRemoteCallApi::unload(self); -} -} +LL_REGISTER_PLUGIN(GMLIB_LegacyRemoteCallApi::LRCA, GMLIB_LegacyRemoteCallApi::LRCA::getInstance()); diff --git a/src/Entry.h b/src/Entry.h index 3bd0e52..6b8d129 100644 --- a/src/Entry.h +++ b/src/Entry.h @@ -1,9 +1,33 @@ #pragma once - #include +#include namespace GMLIB_LegacyRemoteCallApi { -[[nodiscard]] auto getSelfPluginInstance() -> ll::plugin::NativePlugin&; +class LRCA { + +public: + static std::unique_ptr& getInstance(); + + LRCA(ll::plugin::NativePlugin& self) : mSelf(self) {} + + [[nodiscard]] ll::plugin::NativePlugin& getSelf() const { return mSelf; } + + /// @return True if the plugin is loaded successfully. + bool load(); + + /// @return True if the plugin is enabled successfully. + bool enable(); + + /// @return True if the plugin is disabled successfully. + bool disable(); + + // TODO: Implement this method if you need to unload the plugin. + // /// @return True if the plugin is unloaded successfully. + // bool unload(); + +private: + ll::plugin::NativePlugin& mSelf; +}; } // namespace GMLIB_LegacyRemoteCallApi diff --git a/src/Global.h b/src/Global.h index 2938e1c..5bee402 100644 --- a/src/Global.h +++ b/src/Global.h @@ -4,7 +4,7 @@ #include #define PLUGIN_NAME "GMLIB-LRCA" -#define LIB_VERSION SemVersion(0, 9, 1, "", "") +#define LIB_VERSION SemVersion(0, 9, 4, "", "") extern ll::Logger logger; diff --git a/tooth.json b/tooth.json index e688327..735ca71 100644 --- a/tooth.json +++ b/tooth.json @@ -1,7 +1,7 @@ { "format_version": 2, "tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi", - "version": "0.9.3", + "version": "0.9.4", "info": { "name": "GMLIB-LegacyRemoteCallApi", "description": "Legacy RemoteCall API for GMLIB", @@ -14,7 +14,7 @@ "library" ] }, - "asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.9.3/GMLIB-LegacyRemoteCallApi-windows-x64.zip", + "asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.9.4/GMLIB-LegacyRemoteCallApi-windows-x64.zip", "dependencies": { "github.com/GroupMountain/GMLIB": ">=0.9.6" }, diff --git a/xmake.lua b/xmake.lua index 547f3e8..b60986c 100644 --- a/xmake.lua +++ b/xmake.lua @@ -1,4 +1,4 @@ -add_rules("mode.debug", "mode.release", "mode.releasedbg") +add_rules("mode.debug", "mode.release") add_repositories("liteldev-repo https://github.com/LiteLDev/xmake-repo.git") @@ -47,7 +47,8 @@ target("GMLIB-LegacyRemoteCallApi") -- Change this to your plugin name. "/utf-8" ) add_defines( - "_HAS_CXX23=1" -- To enable C++23 features + "NOMINMAX", + "UNICODE" ) add_files( "src/**.cpp" @@ -68,7 +69,8 @@ target("GMLIB-LegacyRemoteCallApi") -- Change this to your plugin name. ) set_exceptions("none") -- To avoid conflicts with /EHa set_kind("shared") - set_languages("cxx23") + set_languages("c++23") + set_symbols("debug") after_build(function (target) local plugin_packer = import("scripts.after_build")