Make base compile on linux
Related Issue
TODO
Implementation
This PR fixes a number of issues with compiling TC2 on linux. It currently runs, and can load maps. It uses parts of #616, #486, #603.
Build Instructions
podman run -v $PWD:/src -it registry.gitlab.steamos.cloud/steamrt/sniper/sdk
# this enters a container shell
cd /src
./src/build.sh
# exit the container
./game_clean/link.sh
./game/start_tf2.sh
Screenshots
Checklist
- [x] No other PRs implement this idea.
- [x] This PR does not introduce any regressions.
- [X] I certify that this PR is my own entirely original work, or I have permission from and have attributed the relevant authors.
- [x] I have agreed to and signed this project's Contributor License Agreement.
- [x] This PR only contains changes to the engine and/or core game framework
- [x] This PR targets the
communitybranch. (???)
- [ ] This change has been filed as an issue.
- [x] No other PRs address this.
- [x] This PR is as minimal as possible.
- [x] This PR has been built and locally tested on at least one platform.
- [ ] This PR has been tested on all platforms, on both a dedicated server and on a listen server.
Testing Checklist
| Client | Server | Version | |
|---|---|---|---|
| Windows | |||
| Linux | Built, Tested | 6.1.7-xanmod1 #1-NixOS SMP PREEMPT_DYNAMIC Tue Jan 1 00:00:00 UTC 1980 | |
| Mac OS |
This was built under the steam "scout" and "sniper" runtime.
Caveats
- ~While the game does run, there is a bug that will cause a crash whenever a weapon is inspected.~ fixed!
Alternatives
- Don't support linux builds at all
- Rewrite the build system to use something like cmake
Mind adding the following to commits which add build.sh & other scripts?
Co-authored-by: melvyn2 <[email protected]>
Co-authored-by: HurricanePootis <[email protected]>
Co-authored-by: interrupt <[email protected]>
Mind adding the following to commits which add build.sh & other scripts?
Done, I've also added credits (or cherry-picked) to a couple of other commits
What's with this freetype2 change?
TF2 already uses the system freetype libraries, and the headers that were in common don't actually build, so I just elected to use the system headers.
Reposting from the #tf2-patches channel on discord:
If anyone wants to write a "proper" (if that even exists) fix for the target id panel crashes, feel free. I'm tired of trying to figure out what it is, and https://github.com/ReplayCoding/tf2-patches/commit/e05bc50c596b402a22f8e15e790059e03d244688 works fine.
also why was empty ccache added?
Just github being funny, it's a perms change to make it executable.
Does this only build with some specific gcc version?
$ gcc --version
gcc (Gentoo 12.2.1_p20230121-r1 p10) 12.2.1 20230121
In file included from src/libc_override_glibc.h:64,
from src/libc_override.h:78,
from src/tcmalloc.cc:157,
from src/debugallocation.cc:79:
src/libc_override_gcc_and_weak.h:56:33: error: ISO C++17 does not allow dynamic exception specifications
56 | void* operator new(size_t size) throw (std::bad_alloc)
| ^~~~~
src/libc_override_gcc_and_weak.h:60:35: error: ISO C++17 does not allow dynamic exception specifications
60 | void* operator new[](size_t size) throw (std::bad_alloc)
| ^~~~~
cc1plus: note: unrecognized command-line option '-Wno-reserved-user-defined-literal' may have been intended to silence earlier diagnostics
make: *** [Makefile:4083: libtcmalloc_debug_la-debugallocation.lo] Error 1
make: *** Waiting for unfinished jobs....
It's only been tested on the steam runtimes, which go up to GCC 10.3.0 on the sniper runtime.
It's only been tested on the steam runtimes, which go up to GCC 10.3.0 on the sniper runtime.
gcc 12 defaults to C++17, thus this will require setting -std=gnu++14 explicitly (which is what gcc 10 defaults to)
Also, you should update create_clean.sh to also support linux, here's a start I made on one:
#!/bin/bash
#
# Run script within the directory
BIN_DIR=$(dirname "$(readlink -fn "$0")")
cd "${BIN_DIR}" || exit 2
set -e
DEV_DIR=../game
CLEAN_DIR=../game_dist
CLEAN_DEBUG_DIR=${CLEAN_DIR}_debug
rm -rf ${CLEAN_DIR}
rm -rf ${CLEAN_DEBUG_DIR}
mkdir -p ${CLEAN_DIR}/{bin,tf/bin}
mkdir -p ${CLEAN_DEBUG_DIR}/{bin,tf/bin}
cp -rf copy/* ${CLEAN_DIR}
cp -rf copy/* ${DEV_DIR}
EXE_EXT=
DLL_EXT=.so
PDB_EXT=.dbg
declare -a FILES=(
{hl2_linux,hl2.sh}
)
declare -a DLLS_CI=(
bin/engine
bin/replay
bin/launcher
bin/inputsystem
bin/{material,soundemitter}system
bin/{shaderapi,stdshader_}dx9
bin/vgui{matsurface,2}
bin/{data,scenefile}cache
bin/sourcevr
bin/studiorender
bin/bsppack
bin/filesystem_stdio
bin/libvstdlib
bin/libtier0
tf/bin/{client,server}
)
declare -a DLLS=(
bin/GameUI
bin/ServerBrowser
)
for F in "${FILES[@]}"; do
cp -f ${DEV_DIR}/${F} ${CLEAN_DIR}/${F}
done
for F in "${DLLS_CI[@]}"; do
cp -f ${DEV_DIR}/${F}$DLL_EXT ${CLEAN_DIR}/${F}$DLL_EXT
# cp -f ${DEV_DIR}/${F,,}.pdb ${CLEAN_DEBUG_DIR}/${F,,}.pdb
done
for F in "${DLLS[@]}"; do
cp -f ${DEV_DIR}/${F}$DLL_EXT ${CLEAN_DIR}/${F}$DLL_EXT
# cp -f ${DEV_DIR}/${F}.pdb ${CLEAN_DEBUG_DIR}/${F}.pdb
done
declare -a FILES=(
../LICENSE_SDK
../.github/README.md
../thirdpartylegalnotices.txt
)
for F in "${FILES[@]}"; do
ORIG=$(basename ${F})
cp -f ${F} ${CLEAN_DIR}/${ORIG}
done
I've added a create_clean_linux.sh script, and updated link.sh to work from game_dist. game_dist should now be entirely self-contained.