From 7cdcf34a9ac151d77f9d7d83e5b1dc680f94bc36 Mon Sep 17 00:00:00 2001 From: Teddi Date: Sun, 28 Jun 2020 21:24:15 +0100 Subject: [PATCH] Major overhaul adding linux / 64 bit support + ci - Now supports 64 bit version of win32 binary - Supports linux 32/64 - Minor improvements to code - Adds github action CI support --- .github/workflows/build-master.yml | 171 +++++++++++++++++++++++++++++ premake5.lua | 96 +++++++++------- src/fwens.cpp | 12 +- src/main.cpp | 8 +- 4 files changed, 237 insertions(+), 50 deletions(-) create mode 100644 .github/workflows/build-master.yml diff --git a/.github/workflows/build-master.yml b/.github/workflows/build-master.yml new file mode 100644 index 0000000..baa00d7 --- /dev/null +++ b/.github/workflows/build-master.yml @@ -0,0 +1,171 @@ +name: Build gFwens (push to master) + +on: + push: + branches: [ master ] + + paths-ignore: + - "README.md" + - 'examples/**' + - ".gitignore" + - ".github/workflows/build-master.yml" + +env: + STEAMWORKS_LIB_BASEDIR: "./deps" + +jobs: + + fetch-dependencies: + runs-on: ubuntu-18.04 + env: + STEAMWORKS_URL: ${{ secrets.STEAMWORKS_SDK_URL }} + steps: + - run: | + wget https://github.com/premake/premake-core/releases/download/v5.0.0-alpha15/premake-5.0.0-alpha15-windows.zip -qO- | busybox unzip - + wget $STEAMWORKS_URL -qO- | busybox unzip - + wget https://github.com/premake/premake-core/releases/download/v5.0.0-alpha15/premake-5.0.0-alpha15-linux.tar.gz -qO- | tar zxf - + + - uses: actions/upload-artifact@v2 + with: + name: premake-persistence + path: ./premake* + + - uses: actions/upload-artifact@v2 + with: + name: sdk-persistence + path: ./sdk* + +### + + build-win: + runs-on: windows-2019 + needs: fetch-dependencies + steps: + + - uses: actions/checkout@v2 + with: + repository: facepunch/gmod-module-base + ref: refs/heads/development + path: gmodheaders + + - uses: actions/checkout@v2 + with: + path: gfwens + + - uses: actions/download-artifact@v2 + with: + name: premake-persistence + path: gfwens + + - uses: actions/download-artifact@v2 + with: + name: sdk-persistence + path: gfwens/deps + + - uses: microsoft/setup-msbuild@v1.0.0 + + - run: | + cd gfwens + ./premake5.exe vs2019 + MSBuild.exe /p:Configuration=Release + MSBuild.exe /p:Configuration=Release /property:Platform=x64 + + - uses: actions/upload-artifact@v2 + with: + name: gmsv_fwens_win32.dll + path: gfwens\bin\release\gmsv_fwens_win32.dll + + - uses: actions/upload-artifact@v2 + with: + name: gmsv_fwens_win64.dll + path: gfwens\bin\release\gmsv_fwens_win64.dll + +### + + build-linux: + runs-on: ubuntu-18.04 + needs: fetch-dependencies + steps: + + - uses: actions/checkout@v2 + with: + repository: facepunch/gmod-module-base + ref: refs/heads/development + path: gmodheaders + + - uses: actions/checkout@v2 + with: + path: gfwens + + - uses: actions/download-artifact@v2 + with: + name: premake-persistence + path: gfwens + + - uses: actions/download-artifact@v2 + with: + name: sdk-persistence + path: gfwens/deps + + # We need multilib otherwise we'll get the wrong arch for *nix + - run: | + sudo apt install gcc-multilib g++-multilib -y + cd gfwens + chmod +x ./premake5 + ./premake5 gmake2 + make config=release_x32 + make config=release_x64 + + - uses: actions/upload-artifact@v2 + with: + name: gmsv_fwens_linux.dll + path: gfwens/bin/release/gmsv_fwens_linux.dll + + - uses: actions/upload-artifact@v2 + with: + name: gmsv_fwens_linux64.dll + path: gfwens/bin/release/gmsv_fwens_linux64.dll + + release: + runs-on: ubuntu-18.04 + needs: [build-win, build-linux] + + steps: + + - name: Get short hash + id: gensha + run: echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)" + + - uses: actions/download-artifact@v2 + with: + name: gmsv_fwens_linux.dll + + - uses: actions/download-artifact@v2 + with: + name: gmsv_fwens_linux64.dll + + - uses: actions/download-artifact@v2 + with: + name: gmsv_fwens_win32.dll + + - uses: actions/download-artifact@v2 + with: + name: gmsv_fwens_win64.dll + + - uses: ncipollo/release-action@v1 + with: + artifacts: "*.dll" + token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ steps.gensha.outputs.sha8 }} + omitBody: true + + - uses: geekyeggo/delete-artifact@v1 + with: + name: | + gmsv_fwens_win32.dll + gmsv_fwens_win64.dll + gmsv_fwens_linux.dll + gmsv_fwens_linux64.dll + premake-persistence + sdk-persistence + \ No newline at end of file diff --git a/premake5.lua b/premake5.lua index 584bb37..8f730fc 100644 --- a/premake5.lua +++ b/premake5.lua @@ -1,61 +1,75 @@ --- x64 is experimental and not guaranteed to work. Pending on gmod actually getting 64 bit support. --- win32 suffix doesn't change currently as we don't know what the plan will be for this. Similar to how -- linux / osx still get the .dll extension even though yknow, those are the wrong binary suffixes for those OS's -platformAlias = { - ["windows"] = "win32", - ["linux"] = "linux", - ["macosx"] = "osx" -} - -workspace "gfwens" +workspace "gmsv_gfwens" configurations {"Debug", "Release"} platforms {"x32", "x64"} project "gmsv_gfwens" kind "SharedLib" language "C++" - files { "src/*.cpp", "src/*.h" } - includedirs { "../gmodheaders/include", "../steamworks" } - targetname ("gmsv_fwens_" .. platformAlias[os.target()]) + local gmodBaseDir = os.getenv("GMODHEADERS") or "" + local steamworksBaseDir = os.getenv("STEAMWORKS_LIB_BASEDIR") or "" + + includedirs { "../gmodheaders/include", "../steamworks", gmodBaseDir, steamworksBaseDir} + targetname ("gmsv_fwens") targetprefix "" targetextension ".dll" - -- Debug | x32 / x64 - filter { "configurations:Debug", "platforms:x32" } + filter "configurations:Debug" defines { "DEBUG", "_CRT_SECURE_NO_WARNINGS" } - links { "../steamworks/sdk/redistributable_bin/steam_api.lib"} symbols "On" - targetdir "bin/x32/debug/" - objdir "bin/x32/debug/" - architecture "x32" + targetdir "bin/debug/" + objdir "bin/debug/" - filter { "configurations:Debug","platforms:x64" } - defines { "DEBUG", "_CRT_SECURE_NO_WARNINGS" } - links { "../steamworks/sdk/redistributable_bin/win64/steam_api64.lib"} - symbols "On" - targetdir "bin/x64/debug/" - objdir "bin/x64/debug/" - architecture "x64" - - -- Release | x32 / x64 - filter { "configurations:Release","platforms:x32" } + filter "configurations:Release" defines { "NDEBUG", "_CRT_SECURE_NO_WARNINGS" } - links { "../steamworks/sdk/redistributable_bin/steam_api.lib"} optimize "On" - targetdir "bin/x32/release/" - objdir "bin/x32/release/" symbols "off" - architecture "x32" + targetdir "bin/release/" + objdir "bin/release/" - filter { "configurations:Release", "platforms:x64" } - defines { "NDEBUG", "_CRT_SECURE_NO_WARNINGS" } - links { "../steamworks/sdk/redistributable_bin/win64/steam_api64.lib"} - optimize "On" - targetdir "bin/x64/release/" - objdir "bin/x64/release/" - symbols "off" - architecture "x64" - \ No newline at end of file + filter {"platforms:*32" } + architecture "x86" + + filter {"platforms:*64" } + architecture "x86_64" + + filter({"system:windows", "platforms:*32"}) + targetsuffix("_win32") + if steamworksBaseDir ~= "" then + links {steamworksBaseDir .. "/sdk/redistributable_bin/steam_api.lib"} + else + links { "../steamworks/sdk/redistributable_bin/steam_api.lib"} + end + + filter({"system:windows", "platforms:*64"}) + targetsuffix("_win64") + + if steamworksBaseDir ~= "" then + links {steamworksBaseDir .."/sdk/redistributable_bin/win64/steam_api64.lib"} + else + links { "../steamworks/sdk/redistributable_bin/win64/steam_api64.lib"} + end + + filter({"system:linux", "platforms:*32"}) + targetsuffix("_linux") + if steamworksBaseDir ~= "" then + libdirs {steamworksBaseDir .. "/sdk/redistributable_bin/linux32/"} + else + libdirs {"../steamworks/sdk/redistributable_bin/linux32/"} + end + links {"steam_api"} + + filter({"system:linux", "platforms:*64"}) + targetsuffix("_linux64") + + if steamworksBaseDir ~= "" then + libdirs {steamworksBaseDir .. "/sdk/redistributable_bin/linux64/"} + else + libdirs {"../steamworks/sdk/redistributable_bin/linux64/"} + end + links {"steam_api"} + + filter {} diff --git a/src/fwens.cpp b/src/fwens.cpp index fbee64e..4d161f3 100644 --- a/src/fwens.cpp +++ b/src/fwens.cpp @@ -92,10 +92,12 @@ void Fwens::RequestUserGroupStatus(CSteamID player, CSteamID groupID) void Fwens::Steam_HandleGroupRequest(GSClientGroupStatus_t* pCallback) { - // CSteamID.Render() no longer appears to function, we'll cast these manually in a bit. - char userBuffer[64]; - char groupBuffer[64]; + // CSteamID.Render() no longer appears to function, we'll cast these manually. + char userBuffer[18]; + char groupBuffer[19]; + snprintf(userBuffer, sizeof(userBuffer), "%llu", pCallback->m_SteamIDUser.ConvertToUint64()); + snprintf(groupBuffer, sizeof(groupBuffer), "%llu", pCallback->m_SteamIDGroup.ConvertToUint64()); this->LUA->PushSpecial(GarrysMod::Lua::SPECIAL_GLOB); this->LUA->GetField(-1, "hook"); @@ -109,10 +111,10 @@ void Fwens::Steam_HandleGroupRequest(GSClientGroupStatus_t* pCallback) this->LUA->PushBool(pCallback->m_bOfficer); this->LUA->SetField(-2, "isOfficer"); - this->LUA->PushString(_i64toa(pCallback->m_SteamIDUser.ConvertToUint64(), userBuffer, 10)); + this->LUA->PushString(userBuffer); this->LUA->SetField(-2, "steamID64"); - this->LUA->PushString(_i64toa(pCallback->m_SteamIDGroup.ConvertToUint64(), groupBuffer, 10)); + this->LUA->PushString(groupBuffer); this->LUA->SetField(-2, "groupID64"); //Fix error handling here! Otherwise forever breaking badly diff --git a/src/main.cpp b/src/main.cpp index 991e000..20afced 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,13 +7,13 @@ using namespace GarrysMod::Lua; LUA_FUNCTION(GetInSteamGroup) { - if (!LUA->IsType(1, Type::STRING)) + if (!LUA->IsType(1, Type::String)) { LUA->ArgError(1, "expected string"); return 0; } - if (!LUA->IsType(2, Type::STRING)) + if (!LUA->IsType(2, Type::String)) { LUA->ArgError(2, "expected string"); return 0; @@ -22,8 +22,8 @@ LUA_FUNCTION(GetInSteamGroup) const char* strSteamuser = LUA->GetString(1); const char* strSteamGroup = LUA->GetString(2); - uint64 steamID64 = _atoi64(strSteamuser); - uint64 groupID64 = _atoi64(strSteamGroup); + uint64 steamID64 = strtoull(strSteamuser, NULL, 10); + uint64 groupID64 = strtoull(strSteamGroup, NULL, 10); CSteamID player = CSteamID(steamID64); if (!player.IsValid())