7 Commits
0.0.7 ... 0.0.9

Author SHA1 Message Date
75d6440776 feat: arm64 Linux Docker image 2025-04-13 13:46:57 +02:00
b927f4aa01 fix Docker 2025-04-12 20:10:44 +02:00
b5ab843ae1 chore: update deps (#117) 2025-04-12 18:55:56 +02:00
ba269b6a63 build: add back x64 macos build 2025-02-08 18:27:35 +01:00
6ed6d552ec build: downgrade ubuntu 2025-02-06 12:05:46 +01:00
da27f374ef chore: remove _s functions 2025-02-06 11:48:54 +01:00
32a000195f chore: update deps 2025-01-17 14:37:17 +01:00
14 changed files with 187 additions and 73 deletions

View File

@ -16,10 +16,10 @@ 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:
@ -28,6 +28,9 @@ jobs:
configuration:
- debug
- release
compiler:
- msvc
- clang
arch:
- x86
- x64
@ -45,7 +48,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 +58,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,6 +83,7 @@ jobs:
build-linux:
name: Build Linux
runs-on: ubuntu-latest
container: ubuntu:noble
strategy:
fail-fast: false
matrix:
@ -84,28 +92,30 @@ jobs:
- 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 +126,96 @@ 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'
- 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:
- debug
- 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: Compress the build directory
run: mkdir -p build
- name: Download project files
uses: actions/download-artifact@main
with:
name: linux-project-files
path: build/
- name: Install LLVM
run: |
echo "CXX=aarch64-linux-gnu-g++" >> $GITHUB_ENV
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 18
- 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-18
CXX: clang++-18
- name: Upload ${{matrix.arch}} ${{matrix.configuration}} binaries
uses: actions/upload-artifact@main
@ -153,6 +234,7 @@ jobs:
- debug
- release
arch:
- amd64
- arm64
steps:
- name: Check out files
@ -160,7 +242,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 +250,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 +269,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 +279,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 +298,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 +324,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 +347,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

Submodule deps/GSL updated: f1a494cfd2...3325bbd33d

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

2
deps/zlib vendored

Submodule deps/zlib updated: d476828316...5a82f71ed1

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