Skip to content

Commit

Permalink
build: Build linux in an SLR container
Browse files Browse the repository at this point in the history
https://gitlab.steamos.cloud/steamrt/sniper/sdk/-/blob/steamrt/sniper/README.md

https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/blob/main/docs/slr-for-game-developers.md

- Revert to clang-11
- Don't install system libs that won't be provided to users in the SLR
- Use system libs where possible
- Update Dockerfile to match CI pipeline
- [temp] Manually find Ogg/Vorbis when using system libs
- revert once resolved: ValveSoftware/steam-runtime#735
- fix rpath for build
- issue using sdl from steam-runtime: ValveSoftware/steam-runtime#736
- set fpic for all targets
- Don't use system ogg/vorbis ValveSoftware/steam-runtime#735

Signed-off-by: Michael Pollind <[email protected]>
Co-authored-by: Gelmo <[email protected]>
  • Loading branch information
Michael Pollind and Gelmo committed Jan 11, 2025
1 parent b347590 commit 6ab4d7b
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 59 deletions.
76 changes: 48 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,21 @@ jobs:
max-parallel: 1
matrix:
config:
- { name: "Linux-x86_64-Release", type: "release", cmake_args: "-DBUILD_STEAMLIB=1 -DUSE_GRAPHICS_NRI=1" }
- { name: "Linux-x86_64-Debug", type: "debug", cmake_args: "-DBUILD_STEAMLIB=1 -DUSE_GRAPHICS_NRI=1"}
- {
name: "Linux-x86_64-Release",
type: "release",
cmake_args: "-DBUILD_STEAMLIB=1 -DUSE_GRAPHICS_NRI=1 -DUSE_SYSTEM_ZLIB=1 -DUSE_SYSTEM_OPENAL=1 -DUSE_SYSTEM_CURL=1 -DUSE_SYSTEM_FREETYPE=1",
}
- {
name: "Linux-x86_64-Debug",
type: "debug",
cmake_args: "-DBUILD_STEAMLIB=1 -DUSE_GRAPHICS_NRI=1 -DUSE_SYSTEM_ZLIB=1 -DUSE_SYSTEM_OPENAL=1 -DUSE_SYSTEM_CURL=1 -DUSE_SYSTEM_FREETYPE=1",
}
name: ${{ matrix.config.name }}
runs-on: ubuntu-20.04
container:
image: ubuntu:20.04
env:
DEBIAN_FRONTEND: noninteractive
DEBCONF_NONINTERACTIVE_SEEN: true
image: registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest
steps:
- name: Add CMake APT repo - glslang requires newer Cmake than provided by 20.04
uses: gerlero/add-apt-repository@v1
with:
uri: https://apt.kitware.com/ubuntu/
key: https://apt.kitware.com/keys/kitware-archive-latest.asc

- name: Install deps
uses: gerlero/apt-install@v1
with:
packages: kitware-archive-keyring git curl clang-18 cmake build-essential git zip unzip python3 autoconf libtool meson automake libtool pkg-config python3-jinja2 python3-setuptools libx11-dev libwayland-dev libxkbcommon-dev libegl1-mesa-dev libibus-1.0-dev libxft-dev libxext-dev

- name: Checkout repo
uses: actions/checkout@v4
with:
Expand All @@ -45,7 +39,7 @@ jobs:
if: matrix.config.type == 'release'
working-directory: ./source
run: |
export CC=clang-18 CXX=clang++-18
export CC=clang-11 CXX=clang++-11
cmake -B ./build ${{matrix.config.cmake_args}} -DBUILD_UNIT_TEST=1 -DCMAKE_BUILD_TYPE=Release
cd build
make -j8
Expand All @@ -54,7 +48,7 @@ jobs:
if: matrix.config.type == 'debug'
working-directory: ./source
run: |
export CC=clang-18 CXX=clang++-18
export CC=clang-11 CXX=clang++-11
cmake -B ./build ${{matrix.config.cmake_args}} -DBUILD_UNIT_TEST=1 -DCMAKE_BUILD_TYPE=Debug
cd build
make -j8
Expand All @@ -76,19 +70,32 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: ${{matrix.config.name}}
path: source/${{matrix.config.name}}.tar.gz
path: source/build/${{matrix.config.name}}.tar.gz

osx:
strategy:
max-parallel: 1
matrix:
config:
- { agent: "macos-13", name: "OSX-x86_64-Release", xcode-version: "15.0.1", type: "release", cmake_args: "-DBUILD_STEAMLIB=1 -DUSE_SYSTEM_CURL=1", build_folder: "Release" }
- { agent: "macos-13", name: "OSX-x86_64-Debug", xcode-version: "15.0.1", type: "debug", cmake_args: "-DBUILD_STEAMLIB=1 -DWF_BUILD_DSYM=ON -DUSE_SYSTEM_CURL=1", build_folder: "Debug" }
- {
agent: "macos-13",
name: "OSX-x86_64-Release",
xcode-version: "15.0.1",
type: "release",
cmake_args: "-DBUILD_STEAMLIB=1 -DUSE_SYSTEM_CURL=1",
build_folder: "Release",
}
- {
agent: "macos-13",
name: "OSX-x86_64-Debug",
xcode-version: "15.0.1",
type: "debug",
cmake_args: "-DBUILD_STEAMLIB=1 -DWF_BUILD_DSYM=ON -DUSE_SYSTEM_CURL=1",
build_folder: "Debug",
}
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.agent }}
steps:

- name: Replace problem-causing python installation - https://github.com/TeamForbiddenLLC/warfork-qfusion/pull/325 - Fixed in macos-14
shell: bash
run: |
Expand Down Expand Up @@ -146,20 +153,33 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: ${{matrix.config.name}}
path: source/${{matrix.config.name}}.tar.gz
path: source/build/${{matrix.config.name}}.tar.gz

windows:
strategy:
max-parallel: 1
matrix:
config:
- { agent: "windows-2019", name: "win-x86_64-Release", vs_version: "Visual Studio 16 2019", type: "release", cmake_args: "-DBUILD_STEAMLIB=1", build_folder: "Release" }
- { agent: "windows-2019", name: "win-x86_64-Debug", vs_version: "Visual Studio 16 2019", type: "debug", cmake_args: "-DBUILD_STEAMLIB=1 -DWF_BUILD_DSYM=ON", build_folder: "Debug" }
- {
agent: "windows-2019",
name: "win-x86_64-Release",
vs_version: "Visual Studio 16 2019",
type: "release",
cmake_args: "-DBUILD_STEAMLIB=1",
build_folder: "Release",
}
- {
agent: "windows-2019",
name: "win-x86_64-Debug",
vs_version: "Visual Studio 16 2019",
type: "debug",
cmake_args: "-DBUILD_STEAMLIB=1 -DWF_BUILD_DSYM=ON",
build_folder: "Debug",
}

name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.agent }}
steps:

- name: Checkout repo
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -205,4 +225,4 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: ${{matrix.config.name}}
path: source\${{matrix.config.name}}.zip
path: source\build\${{matrix.config.name}}.zip
21 changes: 9 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
# Run the following command and a build archive will be produced in the build/ directory:
# docker build --output build .
FROM ubuntu:20.04 AS build
ARG DEBIAN_FRONTEND=noninteractive
ARG DEBCONF_NONINTERACTIVE_SEEN=true
RUN apt update
RUN apt install -y curl clang cmake build-essential \
libsdl2-dev libopenal-dev libvorbis-dev libtheora-dev \
libfreetype6-dev libcurl4-gnutls-dev git zip unzip \
&& rm -rf /var/lib/apt/lists/*
FROM registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest AS build
RUN mkdir -p /root/warfork
WORKDIR /root/warfork
COPY .clang-format .
Expand All @@ -18,9 +11,13 @@ COPY .git .
COPY source source
RUN curl https://warfork.com/downloads/sdk/ --output third-party/steamworks/sdk.zip
RUN unzip third-party/steamworks/sdk.zip -d third-party/steamworks
RUN export CC=clang CXX=clang++
RUN cmake -DCMAKE_BUILD_TYPE=DEBUG -DBUILD_STEAMLIB=1 ./source
RUN export CC=clang-11 CXX=clang++-11
WORKDIR /root/warfork/source
RUN cmake -B ./build -DBUILD_STEAMLIB=1 -DUSE_GRAPHICS_NRI=1 -DUSE_SYSTEM_ZLIB=1 -DUSE_SYSTEM_OPENAL=1 -DUSE_SYSTEM_CURL=1 -DUSE_SYSTEM_FREETYPE=1 -DBUILD_UNIT_TEST=1 -DCMAKE_BUILD_TYPE=Debug
WORKDIR /root/warfork/source/build
RUN make -j8
RUN tar -czvf ./source/Linux-x86_64-Debug.tar.gz ./source/build/*
WORKDIR /root/warfork/source/build/warfork-qfusion
RUN set -e; for exc in ./test/*; do $exc; done
RUN tar --exclude='*.a' --exclude='base*/*.a' --exclude='libs/*.a' --exclude='test' -zcvf ../Linux-x86_64-Debug.tar.gz *
FROM scratch AS export
COPY --from=build /root/warfork/source/Linux-x86_64-Debug.tar.gz .
COPY --from=build /root/warfork/source/build/Linux-x86_64-Debug.tar.gz .
5 changes: 4 additions & 1 deletion source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ set(CMAKE_SKIP_BUILD_RPATH FALSE)
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH $ORIGIN/libs)

set(CMAKE_BUILD_RPATH $ORIGIN/libs:$ORIGIN)

# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(QFUSION_GAME Warfork)
if (QFUSION_GAME)
if (${QFUSION_GAME} MATCHES "Warfork")
Expand Down
22 changes: 5 additions & 17 deletions source/extern/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ if (NOT GAME_MODULES_ONLY)
endif()

if(USE_SYSTEM_ZLIB)
find_package(ZLIB REQUIRED)

add_library(ZLIB::ZLIB INTERFACE IMPORTED GLOBAL)
find_package(ZLIB REQUIRED GLOBAL)
add_library(zlib ALIAS ZLIB::ZLIB)
target_link_libraries(ZLIB::ZLIB INTERFACE ZLIB::ZLIB)
else()
option(ZLIB_BUILD_EXAMPLES "" OFF)
Expand All @@ -22,10 +21,7 @@ endif()

if (USE_SDL2)
if (USE_SYSTEM_SDL2)
find_package(SDL2 REQUIRED)

add_library(SDL2 INTERFACE IMPORTED GLOBAL)
target_link_libraries(SDL2 INTERFACE SDL2::SDL2)
find_package(SDL2 REQUIRED GLOBAL)
else()
option(SDL_RPATH "" OFF)
option(SDL_SHARED "" ON)
Expand All @@ -39,7 +35,6 @@ if (USE_SDL2)
endif()
endif()


if(USE_SYSTEM_OGG)
find_package(Ogg REQUIRED GLOBAL)
else()
Expand All @@ -49,18 +44,15 @@ endif()

if(USE_SYSTEM_FREETYPE)
find_package(Freetype REQUIRED GLOBAL)
target_link_libraries(Freetype::Freetype INTERFACE freetype)
else()
add_subdirectory(freetype)
add_library(Freetype::Freetype INTERFACE IMPORTED GLOBAL)
target_link_libraries(Freetype::Freetype INTERFACE freetype)
endif()


if(USE_SYSTEM_VORBIS)
find_package(Vorbis REQUIRED GLOBAL)

# add_library(Vorbis::Vorbis INTERFACE IMPORTED GLOBAL)
# target_link_libraries(Vorbis::Vorbis INTERFACE Vorbis::Vorbis)
find_package(Vorbis REQUIRED GLOBAL)
else()
if(NOT USE_SYSTEM_OGG)
set(OGG_LIBRARY ogg)
Expand All @@ -69,7 +61,6 @@ else()
add_subdirectory(vorbis)
endif()


if (USE_SYSTEM_OPENAL)
find_package(OpenAL REQUIRED GLOBAL)
else()
Expand All @@ -91,8 +82,6 @@ else()
target_compile_definitions(OpenAL PUBLIC AL_LIBTYPE_STATIC)
endif()



if(USE_SYSTEM_CURL)
find_package(CURL REQUIRED GLOBAL)
else()
Expand Down Expand Up @@ -120,4 +109,3 @@ endif()
endif()

set(STB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/stb PARENT_SCOPE)

2 changes: 1 addition & 1 deletion source/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ else()
"../null/sys_vfs_null.c"
)

set(SERVER_PLATFORM_LIBRARIES "-ldl")
set(SERVER_PLATFORM_LIBRARIES "-ldl" "pthread")
set(SERVER_BINARY_TYPE "")
endif()

Expand Down

0 comments on commit 6ab4d7b

Please sign in to comment.