Compare commits

...

3 Commits

9 changed files with 107 additions and 97 deletions

View File

@ -16,7 +16,7 @@ concurrency:
cancel-in-progress: true
env:
PREMAKE_VERSION: "5.0.0-beta2"
PREMAKE_VERSION: "5.0.0-beta6"
jobs:
build-windows:
@ -26,12 +26,17 @@ jobs:
fail-fast: false
matrix:
configuration:
- debug
- release
compiler:
- msvc
- clang
arch:
- x86
- x64
- arm64
include:
- arch: x86
platform: Win32
- arch: x64
platform: x64
- arch: arm64
@ -52,19 +57,24 @@ jobs:
with:
version: ${{ env.PREMAKE_VERSION }}
- name: Generate project files
- name: Generate project files (clang)
if: matrix.compiler == 'clang'
run: premake5 --cc=${{matrix.compiler}} vs2022
- name: Generate project files (msvc)
if: matrix.compiler == 'msvc'
run: premake5 vs2022
- name: Set up problem matching
uses: ammaraskar/msvc-problem-matcher@master
- name: Build ${{matrix.arch}} ${{matrix.configuration}} binaries
run: msbuild /m /v:minimal /p:Configuration=${{matrix.configuration}} /p:Platform=${{matrix.platform}} build/iw4-validator.sln
- name: Build ${{matrix.arch}} ${{matrix.configuration}} ${{matrix.compiler}} binaries
run: msbuild /m /p:Configuration=${{matrix.configuration}} /p:Platform=${{matrix.platform}} build/iw4-validator.sln
- name: Upload ${{matrix.arch}} ${{matrix.configuration}} binaries
- name: Upload ${{matrix.arch}} ${{matrix.configuration}} ${{matrix.compiler}} binaries
uses: actions/upload-artifact@main
with:
name: windows-${{matrix.arch}}-${{matrix.configuration}}
name: windows-${{matrix.arch}}-${{matrix.configuration}}-${{matrix.compiler}}
path: |
build/bin/${{matrix.arch}}/${{matrix.configuration}}/iw4-validator.exe
build/bin/${{matrix.arch}}/${{matrix.configuration}}/iw4-validator.pdb
@ -72,16 +82,22 @@ jobs:
build-linux:
name: Build Linux
runs-on: ubuntu-latest
container: ubuntu:noble
strategy:
fail-fast: false
matrix:
configuration:
- debug
- release
arch:
- x64
- x86
- amd64
- arm64
steps:
- name: Install g++ and multilib
run: |
apt-get update
apt-get install -y wget tar git make gcc g++ gcc-multilib g++-multilib
- name: Check out files
uses: actions/checkout@main
with:
@ -92,8 +108,15 @@ jobs:
- name: Install dependencies (arm64)
if: matrix.arch == 'arm64'
run: |
sudo apt-get update
sudo apt-get install crossbuild-essential-arm64 -y
apt-get update
apt-get install -y crossbuild-essential-arm64
- name: Install dependencies (x86)
if: matrix.arch == 'x86'
run: |
dpkg --add-architecture i386
apt-get update
apt-get -y install gcc-multilib g++-multilib
- name: Install Premake5
uses: diamante0018/setup-premake@master
@ -101,7 +124,7 @@ jobs:
version: ${{ env.PREMAKE_VERSION }}
- name: Generate project files
run: premake5 gmake2
run: premake5 gmake
- name: Set up problem matching
uses: ammaraskar/gcc-problem-matcher@master
@ -118,8 +141,7 @@ jobs:
- name: Build ${{matrix.arch}} ${{matrix.configuration}} binaries
run: |
pushd build
make config=${{matrix.configuration}}_${{matrix.arch}} -j$(nproc)
make -C build config=${{matrix.configuration}}_${{matrix.arch}} -j$(nproc)
- name: Upload ${{matrix.arch}} ${{matrix.configuration}} binaries
uses: actions/upload-artifact@main
@ -154,61 +176,3 @@ jobs:
- name: Upload iw4-validator binary
run: rsync -avz iw4-validator.exe ${{ secrets.ALTERWARE_MASTER_SSH_USER }}@${{ secrets.ALTERWARE_MASTER_SSH_ADDRESS }}:${{ env.ALTERWARE_MASTER_PATH }}/tools/
docker:
name: Create Docker Image
needs: [build-linux, build-windows]
runs-on: ubuntu-latest
if: github.ref_type == 'tag'
steps:
- name: Check out files
uses: actions/checkout@main
with:
sparse-checkout: |
Dockerfile
README.md
sparse-checkout-cone-mode: false
- name: Download Release binaries
uses: actions/download-artifact@main
- name: Compress Binaries
run: |
for dir in */; do
if [[ $dir == *"windows"* ]]; then
cd "$dir" && zip -r "../${dir%/}.zip" . && cd ..
else
tar -czvf "${dir%/}.tar.gz" -C "$dir" .
fi
done
shell: bash
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3.2.0
- name: Login to DockerHub
uses: docker/login-action@v3.1.0
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- id: meta
uses: docker/metadata-action@v5.5.1
with:
images: |
alterware/iw4-validator
tags: |
${{ github.ref_name }}
latest
- name: Build and Push Docker Image
id: build-and-push
uses: docker/build-push-action@v5.1.0
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

View File

@ -1,9 +0,0 @@
FROM alpine:latest
RUN apk add --no-cache gcompat libstdc++
COPY --chmod=755 ./linux-x64-release/iw4-validator /usr/local/bin/
RUN addgroup -S iw4 && adduser -S iw4 -G iw4
USER iw4
ENTRYPOINT ["/usr/local/bin/iw4-validator"]

View File

@ -8,7 +8,7 @@ You may use this tool to validate "client effects" GSC files for the IW4 engine
- Install [Premake5][premake5-link] and add it to your system PATH
- Clone this repository using [Git][git-link]
- Update the submodules using ``git submodule update --init --recursive``
- Run Premake with either of these two options ``premake5 vs2022`` (Windows) or ``premake5 gmake2`` (Linux/macOS)
- Run Premake with either of these two options ``premake5 vs2022`` (Windows) or ``premake5 gmake`` (Linux/macOS)
#### Command line arguments

View File

@ -6,9 +6,11 @@ targetdir "%{wks.location}/bin/%{cfg.platform}/%{cfg.buildcfg}"
configurations {"debug", "release"}
if os.istarget("darwin") then
platforms {"x64", "arm64"}
else
if os.istarget("linux") then
platforms {"x86", "amd64", "arm64"}
elseif os.istarget("macosx") then
platforms {"amd64", "arm64"}
else
platforms {"x86", "x64", "arm64"}
end
@ -20,6 +22,10 @@ filter "platforms:x64"
architecture "x86_64"
filter {}
filter "platforms:amd64"
architecture "x86_64"
filter {}
filter "platforms:arm64"
architecture "ARM64"
filter {}
@ -39,7 +45,25 @@ filter {"system:linux", "system:macosx"}
linkoptions "-pthread"
filter {}
filter {"system:macosx", "platforms:arm64"}
if os.istarget("linux") then
-- this supports cross-compilation for arm64
filter { "toolset:clang*", "platforms:arm64" }
buildoptions "--target=arm64-linux-gnu"
linkoptions "--target=arm64-linux-gnu"
filter {}
filter { "toolset:clang*" }
-- always try to use lld. LD or Gold will not work
linkoptions "-fuse-ld=lld"
filter {}
end
filter { "system:macosx", "platforms:amd64" }
buildoptions "-arch x86_64"
linkoptions "-arch x86_64"
filter {}
filter { "system:macosx", "platforms:arm64" }
buildoptions "-arch arm64"
linkoptions "-arch arm64"
filter {}
@ -53,7 +77,7 @@ flags {"NoIncrementalLink", "NoMinimalRebuild", "MultiProcessorCompile", "No64Bi
filter "configurations:release"
optimize "Speed"
defines "NDEBUG"
flags "FatalCompileWarnings"
fatalwarnings {"All"}
filter {}
filter "configurations:debug"

View File

@ -216,9 +216,9 @@ namespace console
lock _{};
#ifdef _WIN32
SetConsoleTitleA(title.data());
SetConsoleTitleA(title.c_str());
#else
printf("\033]0;%s\007", title.data());
printf("\033]0;%s\007", title.c_str());
fflush(stdout);
#endif
}

View File

@ -2,6 +2,7 @@
#include <utils/string.hpp>
#include "console.hpp"
#include "map_rotation.hpp"
using namespace std::literals;
@ -10,6 +11,29 @@ namespace map_rotation
{
namespace
{
bool is_valid_game_type(const std::string& game_type)
{
static std::array<const char*, 14> game_types =
{
"arena",
"conf",
"ctf",
"dd",
"dm",
"dom",
"gtnw",
"gun",
"infect",
"koth",
"oneflag",
"sab",
"sd",
"war",
};
return std::ranges::find(game_types, game_type) != std::end(game_types);
}
bool is_valid_key(const std::string& key)
{
static std::array<const char*, 3> keys =
@ -69,10 +93,15 @@ namespace map_rotation
if (is_valid_key(key))
{
this->add_entry(key, value);
if (key == "gametype" && !is_valid_game_type(value))
{
console::warn("It appears you have an invalid game type in your map rotation (%s)", value.c_str());
}
}
else
{
throw map_rotation_parse_error(utils::string::va("Invalid key '%s'", key.data()));
throw map_rotation_parse_error(utils::string::va("Invalid key '%s'", key.c_str()));
}
}
}

View File

@ -2,7 +2,7 @@
namespace map_rotation
{
#define DEFAULT_ERROR_MSG "Map Rotation Parse Error"
constexpr auto* DEFAULT_ERROR_MSG = "Map Rotation Parse Error";
class map_rotation_parse_error : public std::runtime_error
{

View File

@ -21,12 +21,12 @@ namespace
std::string data;
if (!utils::io::read_file(filename, &data) || data.empty())
{
throw std::runtime_error(utils::string::va("'%s' is empty", filename.data()));
throw std::runtime_error(utils::string::va("'%s' is empty", filename.c_str()));
}
if (game::parse_client_effects(data.data()))
{
console::info("Successfully parsed '%s'\n", filename.data());
console::info("Successfully parsed '%s'\n", filename.c_str());
}
}
@ -41,9 +41,11 @@ namespace
std::string data;
if (!utils::io::read_file(filename, &data) || data.empty())
{
throw std::runtime_error(utils::string::va("'%s' is empty", filename.data()));
throw std::runtime_error(utils::string::va("'%s' is empty", filename.c_str()));
}
console::info("Please ensure that the map rotation is in all lowercase\n");
try
{
map_rotation::rotation_data rotation_data;
@ -53,7 +55,7 @@ namespace
}
catch (const std::exception& ex)
{
console::error(utils::string::va("%s. '%s' contains invalid data!\n", ex.what(), filename.data()));
console::error(utils::string::va("%s. '%s' contains invalid data!\n", ex.what(), filename.c_str()));
}
}

View File

@ -7,12 +7,12 @@ namespace utils
{
bool remove_file(const std::string& file)
{
return std::remove(file.data()) == 0;
return std::remove(file.c_str()) == 0;
}
bool move_file(const std::string& src, const std::string& target)
{
return std::rename(src.data(), target.data()) == 0;
return std::rename(src.c_str(), target.c_str()) == 0;
}
bool file_exists(const std::string& file)