Compare commits

..

9 Commits

14 changed files with 181 additions and 77 deletions

View File

@ -16,18 +16,20 @@ concurrency:
cancel-in-progress: true
env:
PREMAKE_VERSION: "5.0.0-beta2"
PREMAKE_VERSION: "5.0.0-beta6"
jobs:
build-win:
build-windows:
name: Build Windows
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
configuration:
- debug
- release
compiler:
- msvc
- clang
arch:
- x86
- x64
@ -45,7 +47,6 @@ jobs:
with:
submodules: true
fetch-depth: 0
# NOTE - If LFS ever starts getting used during builds, switch this to true!
lfs: false
- name: Add msbuild to PATH
@ -56,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/alterware-master.sln
- name: Build ${{matrix.arch}} ${{matrix.configuration}} ${{matrix.compiler}} binaries
run: msbuild /m /p:Configuration=${{matrix.configuration}} /p:Platform=${{matrix.platform}} build/alterware-master.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}}/alterware-master.exe
build/bin/${{matrix.arch}}/${{matrix.configuration}}/alterware-master.pdb
@ -76,36 +82,38 @@ jobs:
build-linux:
name: Build Linux
runs-on: ubuntu-latest
container: ubuntu:noble
strategy:
fail-fast: false
matrix:
configuration:
- debug
- release
arch:
- x86
- x64
- amd64
steps:
- name: Install g++ and multilib
run: |
apt-get update
apt-get install -y wget tar git make gcc-13 g++-13 gcc-13-multilib g++-13-multilib
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 13
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 13
update-alternatives --set gcc /usr/bin/gcc-13
update-alternatives --set g++ /usr/bin/g++-13
- name: Check out files
uses: actions/checkout@main
with:
submodules: true
fetch-depth: 0
# NOTE - If LFS ever starts getting used during builds, switch this to true!
lfs: false
- name: Install dependencies (arm64)
if: matrix.arch == 'arm64'
run: |
sudo apt-get update
sudo apt-get -y install crossbuild-essential-arm64
- name: Install dependencies (x86)
if: matrix.arch == 'x86'
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get -y install gcc-multilib g++-multilib
dpkg --add-architecture i386
apt-get update
apt-get install -y gcc-13-multilib g++-13-multilib
- name: Install Premake5
uses: diamante0018/setup-premake@master
@ -116,25 +124,89 @@ jobs:
uses: rui314/setup-mold@staging
- name: Generate project files
run: premake5 gmake2
working-directory: ${{ github.workspace }}
run: premake5 gmake
- name: Set up problem matching
uses: ammaraskar/gcc-problem-matcher@master
- name: Set up CC environment variable
if: matrix.arch == 'arm64'
- name: Build ${{matrix.arch}} ${{matrix.configuration}} binaries
working-directory: ${{ github.workspace }}
run: |
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
make -C build config=${{matrix.configuration}}_${{matrix.arch}} -j$(nproc)
- name: Set up CXX environment variable
if: matrix.arch == 'arm64'
run: |
echo "CXX=aarch64-linux-gnu-g++" >> $GITHUB_ENV
- name: Upload ${{matrix.arch}} ${{matrix.configuration}} binaries
uses: actions/upload-artifact@main
with:
name: linux-${{matrix.arch}}-${{matrix.configuration}}
path: |
build/bin/${{matrix.arch}}/${{matrix.configuration}}/alterware-master
prebuild-linux-arm64:
name: Prebuild Linux
runs-on: ubuntu-latest
steps:
- name: Check out files
uses: actions/checkout@main
with:
submodules: true
fetch-depth: 0
lfs: false
- name: Install Premake5
uses: diamante0018/setup-premake@master
with:
version: ${{ env.PREMAKE_VERSION }}
- name: Generate project files
run: premake5 --cc=clang gmake
- name: Upload project files
uses: actions/upload-artifact@main
with:
name: linux-project-files
path: |
build/
build-linux-arm64:
name: Build Linux
runs-on: ${{ matrix.os }}
needs: prebuild-linux-arm64
strategy:
fail-fast: false
matrix:
configuration:
- release
arch:
- arm64
include:
- arch: arm64
os: ubuntu-24.04-arm
steps:
- name: Check out files
uses: actions/checkout@main
with:
submodules: true
fetch-depth: 0
lfs: false
- name: Create the build directory
run: mkdir -p build
- name: Download project files
uses: actions/download-artifact@main
with:
name: linux-project-files
path: build/
- name: Build ${{matrix.arch}} ${{matrix.configuration}} binaries
working-directory: ${{ github.workspace }}
run: |
pushd build
make config=${{matrix.configuration}}_${{matrix.arch}} -j$(nproc)
env:
CC: clang
CXX: clang++
- name: Upload ${{matrix.arch}} ${{matrix.configuration}} binaries
uses: actions/upload-artifact@main
@ -150,9 +222,9 @@ jobs:
fail-fast: false
matrix:
configuration:
- debug
- release
arch:
- amd64
- arm64
steps:
- name: Check out files
@ -160,7 +232,6 @@ jobs:
with:
submodules: true
fetch-depth: 0
# NOTE - If LFS ever starts getting used during builds, switch this to true!
lfs: false
- name: Install Premake5
@ -169,7 +240,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
@ -188,7 +259,7 @@ jobs:
deploy:
name: Deploy artifacts
needs: [build-win, build-linux, build-macos]
needs: [build-windows, build-linux, build-linux-arm64, build-macos]
runs-on: ubuntu-latest
if: github.ref_type == 'tag'
steps:
@ -198,7 +269,7 @@ jobs:
- name: Download Release binaries
uses: actions/download-artifact@main
with:
name: linux-x64-release
name: linux-amd64-release
- name: Install SSH key
uses: shimataro/ssh-key-action@v2.7.0
@ -217,7 +288,7 @@ jobs:
docker:
name: Create Docker Image
needs: [build-win, build-linux, build-macos]
needs: [build-windows, build-linux, build-linux-arm64, build-macos]
runs-on: ubuntu-latest
if: github.ref_type == 'tag'
steps:
@ -243,17 +314,20 @@ jobs:
done
shell: bash
- name: Setup QEMU
uses: docker/setup-qemu-action@v3.6.0
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3.6.1
uses: docker/setup-buildx-action@v3.10.0
- name: Login to DockerHub
uses: docker/login-action@v3.3.0
uses: docker/login-action@v3.4.0
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- id: meta
uses: docker/metadata-action@v5.5.1
uses: docker/metadata-action@v5.7.0
with:
images: |
alterware/master-server
@ -263,10 +337,10 @@ jobs:
- name: Build and Push Docker Image
id: build-and-push
uses: docker/build-push-action@v6.7.0
uses: docker/build-push-action@v6.15.0
with:
context: .
platforms: linux/amd64
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

View File

@ -1,14 +1,20 @@
FROM alpine:latest
FROM ubuntu:noble
ARG TARGETARCH
RUN apk add --no-cache gcompat libstdc++
WORKDIR /master-server
COPY --chmod=755 ./linux-x64-release/alterware-master /usr/local/bin/
RUN groupadd alterware-master && useradd -r -g alterware-master alterware-master
RUN mkdir -p /master-server && \
chown alterware-master:alterware-master /master-server && \
chmod 775 /master-server
COPY --chown=alterware-master:alterware-master --chmod=755 ./linux-${TARGETARCH}-release/alterware-master /master-server
RUN addgroup -S alterware-master && adduser -S alterware-master -G alterware-master
USER alterware-master
EXPOSE 20810/udp
ENV AW_STATS_LOCATION=""
ENTRYPOINT ["/usr/local/bin/alterware-master"]
ENTRYPOINT ["/master-server/alterware-master"]

View File

@ -11,6 +11,29 @@ Run using [Docker][docker-link]
docker run -p 20810:20810/udp -e AW_STATS_LOCATION=<UTF-8 C-string> alterware/master-server:latest
```
or run as a systemd service
```
[Unit]
Description=AlterWare Master Server
After=network.target
[Service]
Type=simple
ExecStart=<working dir>/alterware-master
WorkingDirectory=<working dir>
Environment="AW_STATS_LOCATION=/var/www/<domain name>/html/stats.json"
StandardOutput=null
Restart=on-failure
RestartSec=10
KillMode=process
User=<username>
Group=<group name>
[Install]
WantedBy=multi-user.target
```
## Build
- Install [Premake5][premake5-link] and add it to your system PATH
- Clone this repository using [Git][git-link]
@ -23,10 +46,9 @@ Requirements for Unix systems:
- Dependencies: Ensure the LLVM C++ Standard library is installed
- Alternative compilers: If you opt for a different compiler such as GCC, use the [Mold][mold-link] linker
- Customization: Modifications to the Premake5.lua script may be required
- Platform support: Details regarding supported platforms are available in [build.yml][build-link]
- Platform support: Details regarding supported platforms are available in [build.yml](.github/workflows/build.yml). Linux ARM64 should be supported out of the box even if it's not present in the CI scripts
[docker-link]: https://www.docker.com
[premake5-link]: https://premake.github.io
[git-link]: https://git-scm.com
[mold-link]: https://github.com/rui314/mold
[build-link]: https://github.com/alterware/master-server/blob/master/.github/workflows/build.yml

2
deps/GSL vendored

@ -1 +1 @@
Subproject commit f1a494cfd2ce55fe88b5134eab985f5852667b8d
Subproject commit 3325bbd33d24d1f8f5a0f69e782c92ad5a39a68e

2
deps/libtomcrypt vendored

@ -1 +1 @@
Subproject commit fc6b42025b080a19a0a201a427bb8512f251bb7b
Subproject commit a6b9aff7aab857fe1b491710a5c5b9e2be49cb08

2
deps/libtommath vendored

@ -1 +1 @@
Subproject commit 5809141a3a6ec1bf3443c927c02b955e19224016
Subproject commit e823b0c34cea291bdb94d672731e1c1f08525557

View File

@ -47,6 +47,8 @@ function libtomcrypt.project()
"LTC_SOURCE",
"_LIB",
"USE_LTM",
"LTC_NO_TEST",
"LTC_NO_PROTOTYPES"
}
removedefines {
@ -54,15 +56,13 @@ function libtomcrypt.project()
"_USRDLL",
}
if os.istarget("darwin") then
filter "platforms:x64"
buildoptions "-march=native"
filter {}
filter { "system:macosx", "platforms:arm64" }
buildoptions "-mcpu=apple-m1"
filter {}
filter "platforms:arm64"
buildoptions "-mcpu=apple-m1"
filter {}
end
filter { "system:macosx", "platforms:amd64" }
buildoptions "-mcpu=x86-64"
filter {}
warnings "Off"
kind "StaticLib"

2
deps/rapidjson vendored

@ -1 +1 @@
Subproject commit 7c73dd7de7c4f14379b781418c6e947ad464c818
Subproject commit 24b5e7a8b27f42fa16b96fc70aade9106cf7102f

2
deps/zlib vendored

@ -1 +1 @@
Subproject commit d476828316d05d54c6fd6a068b121b30c147b5cd
Subproject commit 5a82f71ed1dfc0bec044d9702463dbdf84ea3b71

View File

@ -41,9 +41,11 @@ configurations {"debug", "release"}
language "C++"
cppdialect "C++20"
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
@ -55,6 +57,10 @@ filter "platforms:x64"
architecture "x86_64"
filter {}
filter "platforms:amd64"
architecture "x86_64"
filter {}
filter "platforms:arm64"
architecture "ARM64"
filter {}
@ -77,14 +83,16 @@ if os.istarget("linux") then
filter {}
filter { "toolset:clang*" }
buildoptions "-stdlib=libc++"
linkoptions "-stdlib=libc++"
-- 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"
@ -99,7 +107,7 @@ flags {"NoIncrementalLink", "NoMinimalRebuild", "MultiProcessorCompile", "No64Bi
filter "configurations:release"
optimize "Size"
defines "NDEBUG"
flags "FatalCompileWarnings"
fatalwarnings {"All"}
filter {}
filter "configurations:debug"

View File

@ -65,11 +65,7 @@ namespace console
{
static thread_local char buffer[0x1000];
#ifdef _WIN32
const int count = vsnprintf_s(buffer, _TRUNCATE, message, *ap);
#else
const int count = vsnprintf(buffer, sizeof(buffer), message, *ap);
#endif
if (count < 0) return {};
return {buffer, static_cast<size_t>(count)};

View File

@ -39,7 +39,7 @@ int main(const int argc, const char** argv)
}
catch (std::exception& e)
{
console::error("Fatal error: %s\n", e.what());
console::error("Fatal error: %s", e.what());
return -1;
}

View File

@ -41,10 +41,12 @@ namespace
const auto location = utils::env::get_value("AW_STATS_LOCATION");
if (location.empty())
{
console::error("The environment variable 'AW_STATS_LOCATION' is not set. Please set 'AW_STATS_LOCATION' to specify the save location for 'stats.json'\n");
console::error("The environment variable 'AW_STATS_LOCATION' is not set. Please set 'AW_STATS_LOCATION' to specify the save location for 'stats.json'");
return;
}
console::info("Writing stats to %s", location.c_str());
utils::io::write_file(location, root_data);
}
}

View File

@ -29,11 +29,7 @@ namespace utils::string
while (true)
{
#ifdef _WIN32
const auto res = vsnprintf_s(entry->buffer_, entry->size_, _TRUNCATE, format, ap);
#else
const auto res = vsnprintf(entry->buffer_, entry->size_, format, ap);
#endif
if (res > 0) break; // Success
if (res == 0) return nullptr; // Error