Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
225 changes: 225 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
name: build

# Every push to master builds Windows and Linux and refreshes the rolling
# "latest" release. Pull requests build too, but publish nothing.
on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:

permissions:
contents: read

env:
PHYSX_TAG: "4.1.2"

jobs:
# ---------------------------------------------------------------------------
# Windows -- PhysX ships prebuilt in external/physx-4.1, so nothing to fetch.
# ---------------------------------------------------------------------------
windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v7

# Same flow as the README: setup.bat locates VS via vswhere and loads the
# MSVC x64 environment, then the repo's own Ninja presets do the work.
#
# The *_RELEASE overrides only add debug info: CMAKE_BUILD_TYPE=Release
# emits no PDBs on its own, and we ship them. /Z7 rather than /Zi because
# Ninja compiles in parallel and /Zi would have every cl.exe contending
# for one vc.pdb. /DEBUG implies /OPT:NOREF, so REF|ICF are restored.
- name: Build
shell: cmd
run: |
call .\setup.bat
if errorlevel 1 exit /b 1
where ninja >nul 2>&1 || set "PATH=%VSINSTALLDIR%Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja;%PATH%"
cmake --preset release ^
-DCMAKE_C_FLAGS_RELEASE="/O2 /Ob2 /DNDEBUG /Z7" ^
-DCMAKE_CXX_FLAGS_RELEASE="/O2 /Ob2 /DNDEBUG /Z7" ^
-DCMAKE_EXE_LINKER_FLAGS_RELEASE="/INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF" ^
-DCMAKE_SHARED_LINKER_FLAGS_RELEASE="/INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF"
if errorlevel 1 exit /b 1
cmake --build --preset release
if errorlevel 1 exit /b 1

# All binaries land in build/ (only intermediates go to build/release).
# build/gamedata is deliberately excluded: game data comes from the
# client, not from us.
- name: Stage package
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$stage = 'stage/win64'
New-Item -ItemType Directory -Force -Path $stage, "$stage/third-party-licenses" | Out-Null

foreach ($srv in 'login_srv', 'hub_srv', 'mm_srv', 'game_srv') {
Copy-Item "build/$srv.exe" $stage
Copy-Item "build/$srv.pdb" $stage
}
Copy-Item 'build/PhysX*.dll' $stage
Copy-Item 'external/physx-4.1/LICENSE.md' "$stage/third-party-licenses/PhysX-4.1-LICENSE.md"
Copy-Item 'LICENSE.md' $stage

- uses: actions/upload-artifact@v4
with:
name: win64
path: stage/win64/
if-no-files-found: error

# ---------------------------------------------------------------------------
# Linux -- PhysX has no prebuilt Linux binaries, so it is built from source
# and cached. First run is slow; later runs restore in seconds.
# ---------------------------------------------------------------------------
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- name: Install build tools
run: |
sudo apt-get update
sudo apt-get install -y ninja-build clang

- name: Cache PhysX
id: physx-cache
uses: actions/cache@v4
with:
path: ~/physx-libs
key: physx-${{ env.PHYSX_TAG }}-${{ runner.os }}-clang-v1

# PhysX 4.1 predates these compilers and builds with -Werror alongside
# clang's -Weverything, so every warning added to clang since 2021 breaks
# it. Dropping -Werror is the only change needed.
- name: Build PhysX
if: steps.physx-cache.outputs.cache-hit != 'true'
run: |
set -e
git clone --depth 1 --branch 4.1 https://github.com/NVIDIAGameWorks/PhysX.git /tmp/physx-src
cd /tmp/physx-src
sed -i 's/ -Werror//g' physx/source/compiler/cmake/linux/CMakeLists.txt
sed -e 's/PX_BUILDSNIPPETS" value="True"/PX_BUILDSNIPPETS" value="False"/' \
-e 's/PX_BUILDPUBLICSAMPLES" value="True"/PX_BUILDPUBLICSAMPLES" value="False"/' \
-e 's/name="linux"/name="linux-headless"/' \
physx/buildtools/presets/public/linux.xml \
> physx/buildtools/presets/public/linux-headless.xml
cd physx
export PHYSX_ROOT_DIR="$PWD"
export PM_PxShared_PATH="$PHYSX_ROOT_DIR/../pxshared"

Check warning on line 111 in .github/workflows/build.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Environment variable 'PM_PxShared_PATH' should use ALL_CAPS naming convention.

See more on https://sonarcloud.io/project/issues?id=MXM-Engineers_GameServer&issues=AaHKmwkSmRk1AZTK9nYv&open=AaHKmwkSmRk1AZTK9nYv&pullRequest=47
export PM_CMakeModules_PATH="$PHYSX_ROOT_DIR/../externals/cmakemodules"

Check warning on line 112 in .github/workflows/build.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Environment variable 'PM_CMakeModules_PATH' should use ALL_CAPS naming convention.

See more on https://sonarcloud.io/project/issues?id=MXM-Engineers_GameServer&issues=AaHKmwkSmRk1AZTK9nYw&open=AaHKmwkSmRk1AZTK9nYw&pullRequest=47
export PM_PATHS="$PM_CMakeModules_PATH"
python3 ./buildtools/cmake_generate_projects.py linux-headless
cmake --build compiler/linux-headless-release -j "$(nproc)"
mkdir -p ~/physx-libs
cp bin/linux.clang/release/*.a ~/physx-libs/
ls -la ~/physx-libs

# -g plus a split of the debug info into .debug files, so the shipped
# binaries stay small while crashes remain symbolicatable -- the Linux
# equivalent of the PDBs the Windows job ships.
- name: Build
run: |
cmake --preset release \
-DPHYSX_LINUX_LIB_DIR="$HOME/physx-libs" \
-DCMAKE_C_FLAGS_RELEASE="-O3 -DNDEBUG -g" \
-DCMAKE_CXX_FLAGS_RELEASE="-O3 -DNDEBUG -g"
cmake --build --preset release

- name: Stage package
run: |
set -e
stage=stage/linux64
mkdir -p "$stage/third-party-licenses"
for srv in login_srv hub_srv mm_srv game_srv; do
cp "build/$srv" "$stage/"
objcopy --only-keep-debug "$stage/$srv" "$stage/$srv.debug"
objcopy --strip-debug "$stage/$srv"
objcopy --add-gnu-debuglink="$stage/$srv.debug" "$stage/$srv"
chmod +x "$stage/$srv"
done
cp external/physx-4.1/LICENSE.md "$stage/third-party-licenses/PhysX-4.1-LICENSE.md"
cp LICENSE.md "$stage/"
ls -la "$stage"

- uses: actions/upload-artifact@v4
with:
name: linux64
path: stage/linux64/
if-no-files-found: error

# ---------------------------------------------------------------------------
# Rolling release: one "latest" tag, replaced on every push to master.
# ---------------------------------------------------------------------------
release:
needs: [windows, linux]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
path: artifacts

- name: Package
run: |
set -e
built=$(date -u '+%Y-%m-%d %H:%M:%S UTC')
for plat in win64 linux64; do
cat > "artifacts/$plat/BUILDINFO.txt" <<EOF
MXM GameServer - $plat (Release)

commit: ${{ github.sha }}
branch: ${{ github.ref_name }}
built: $built
run: ${{ github.run_number }}

Extract somewhere and run the servers with that folder as the working
directory. gamedata/ and the .cfg files are resolved from the CWD;
missing .cfg files fall back to compiled defaults, but gamedata/ is
required and is NOT included here -- it is extracted from the game
client.

Start order: mm_srv, then hub_srv and game_srv, then login_srv.
EOF
done
# zip for Windows; tar.gz for Linux, because zip does not preserve
# the executable bit.
(cd artifacts/win64 && zip -qr ../../MXM-GameServer-win64.zip .)
chmod +x artifacts/linux64/*_srv
tar -czf MXM-GameServer-linux64.tar.gz -C artifacts/linux64 .
ls -la MXM-GameServer-*

- name: Publish rolling "latest" release
env:
GH_TOKEN: ${{ github.token }}
run: |
# Drop the previous release and its tag. Fails harmlessly on the very
# first run, when there is nothing to delete.
gh release delete latest --yes --cleanup-tag --repo "$GITHUB_REPOSITORY" || true

short="${GITHUB_SHA:0:7}"
cat > notes.md <<EOF
Automated build of \`master\` @ [\`$short\`](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }})

Built by [run #${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).

| download | contents |
|---|---|
| \`MXM-GameServer-win64.zip\` | \`login_srv\`, \`hub_srv\`, \`mm_srv\`, \`game_srv\` + PDBs, and the NVIDIA PhysX 4.1 runtime DLLs |
| \`MXM-GameServer-linux64.tar.gz\` | the same four servers (PhysX linked statically) + separate \`.debug\` symbol files |

Game data is **not** included -- it is extracted from the game client.
EOF

gh release create latest \
--title "Latest master build (#${{ github.run_number }})" \
--notes-file notes.md \
--prerelease \
--target "$GITHUB_SHA" \
--repo "$GITHUB_REPOSITORY" \
MXM-GameServer-win64.zip \
MXM-GameServer-linux64.tar.gz
19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ endfunction()
set(PHYSX_DIR ${EXTERNAL_DIR}/physx-4.1)
set(PHYSX_DLLS PhysXCommon_64.dll PhysXCooking_64.dll PhysXFoundation_64.dll PhysX_64.dll)
function(copy_physx_dlls target)
if(NOT WIN32)
return()
endif()
foreach(dll IN LISTS PHYSX_DLLS)
add_custom_command(TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
Expand Down Expand Up @@ -103,6 +106,22 @@ if(CMAKE_CONFIGURATION_TYPES)
endforeach()
endif()

# PhysX ships prebuilt win64 libs; on Linux they have to be built from source
# (see .github/workflows/build.yml). Without them game_srv and col are skipped
# so the rest of the tree still builds.
if(WIN32)
set(MXM_HAVE_PHYSX ON)
else()
set(PHYSX_LINUX_LIB_DIR "${PHYSX_DIR}/lib/linux-release" CACHE PATH
"Directory holding the PhysX 4.1 Linux static libraries")
if(EXISTS "${PHYSX_LINUX_LIB_DIR}/libPhysX_static_64.a")
set(MXM_HAVE_PHYSX ON)
else()
set(MXM_HAVE_PHYSX OFF)
message(STATUS "PhysX Linux libraries not found in ${PHYSX_LINUX_LIB_DIR} -- skipping game_srv and col")
endif()
endif()

add_subdirectory(external)
add_subdirectory(src)
add_subdirectory(tools)
55 changes: 41 additions & 14 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ add_library(zlib STATIC ${ZLIB_SOURCES})
target_include_directories(zlib PUBLIC ${EXTERNAL_DIR}/zlib-1.2.11)
if(MSVC)
target_compile_options(zlib PRIVATE /W0)
else()
# zlib only includes <unistd.h> when its configure script says so; without
# it gz*.c implicitly declares read/write/lseek/close, an error from GCC 14 on.
target_compile_definitions(zlib PRIVATE Z_HAVE_UNISTD_H)
endif()

# ---- EA foundation libraries ----
Expand Down Expand Up @@ -49,6 +53,11 @@ target_compile_definitions(eastl PRIVATE
EASTL_OPENSOURCE=1)
target_link_libraries(eastl PUBLIC eastdc)

if(NOT WIN32)
# the lea tool is a shared library, so everything it pulls in must be PIC
set_target_properties(eaassert eathread eastdc eastl PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()

# ---- tinyxml2 (compiled into the server targets, as genie did) ----
add_library(tinyxml2 INTERFACE)
target_include_directories(tinyxml2 INTERFACE ${EXTERNAL_DIR}/tinyxml2-8.0.0)
Expand All @@ -62,23 +71,41 @@ file(GLOB IMGUI_SOURCES CONFIGURE_DEPENDS ${EXTERNAL_DIR}/imgui-1.81/*.cpp)
add_library(imgui STATIC ${IMGUI_SOURCES})
target_include_directories(imgui PUBLIC ${EXTERNAL_DIR}/imgui-1.81)

# ---- PhysX (prebuilt win64 libs) ----
# ---- PhysX ----
if(MXM_HAVE_PHYSX)
add_library(physx INTERFACE)
target_include_directories(physx INTERFACE
${PHYSX_DIR}/include/physx
${PHYSX_DIR}/include/pxshared)
target_link_directories(physx INTERFACE
"$<$<CONFIG:Debug>:${PHYSX_DIR}/lib/debug>"
"$<$<CONFIG:Debug>:${PHYSX_DIR}/lib/checked>"
"$<$<NOT:$<CONFIG:Debug>>:${PHYSX_DIR}/lib/release>"
)
target_link_libraries(physx INTERFACE
PhysXExtensions_static_64
PhysX_64
PhysXPvdSDK_static_64
PhysXCommon_64
PhysXFoundation_64
PhysXCooking_64
PhysXCharacterKinematic_static_64)
if(WIN32)
target_link_directories(physx INTERFACE
"$<$<CONFIG:Debug>:${PHYSX_DIR}/lib/debug>"
"$<$<CONFIG:Debug>:${PHYSX_DIR}/lib/checked>"
"$<$<NOT:$<CONFIG:Debug>>:${PHYSX_DIR}/lib/release>"
)
target_link_libraries(physx INTERFACE
PhysXExtensions_static_64
PhysX_64
PhysXPvdSDK_static_64
PhysXCommon_64
PhysXFoundation_64
PhysXCooking_64
PhysXCharacterKinematic_static_64)
else()
# PhysX 4.1 builds every module static on Linux and they reference each
# other, so they have to be resolved as a single link group.
target_link_directories(physx INTERFACE ${PHYSX_LINUX_LIB_DIR})
target_link_libraries(physx INTERFACE
-Wl,--start-group
PhysXExtensions_static_64
PhysX_static_64
PhysXPvdSDK_static_64
PhysXCommon_static_64
PhysXFoundation_static_64
PhysXCooking_static_64
PhysXCharacterKinematic_static_64
-Wl,--end-group)
endif()
endif()

# copy_physx_dlls() is defined in the root CMakeLists.txt
Loading
Loading