Skip to content
Open
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
46 changes: 45 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,54 @@ jobs:
with:
name: ${{ runner.os }}-${{ matrix.arch }}
path: build/*.tar.gz
psvita:
name: PS Vita
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Install dependencies
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libatomic1 libgcc-s1 \
libstdc++6 gcc-multilib g++-multilib cmake \
ninja-build libfontconfig-dev
sudo apt-get install cmake=3.28.3-1build7
sudo ln -sf /usr/bin/cmake /usr/local/bin/cmake
- name: Setup VitaSDK
run: |
chmod +x scripts/setup_psvita_sdk.sh
scripts/setup_psvita_sdk.sh
echo "VITASDK=/usr/local/vitasdk" >> $GITHUB_ENV
echo "$VITASDK/bin" >> $GITHUB_PATH
- name: Configure project
run: cmake --preset "psvita-debug"
- name: Build
run: cmake --build .
working-directory: build
- name: Write configuration files
run: |
pushd build
chmod +x ${{ github.workspace }}/scripts/write_psvita_configs.sh
${{ github.workspace }}/scripts/write_psvita_configs.sh
popd
- name: Package
run: cpack --config CPackConfig.cmake
working-directory: build
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: PSVita
path: build/*.zip
release:
name: Release
runs-on: ubuntu-latest
needs: [android, windows, linux]
needs: [android, windows, linux, psvita]
steps:
- name: Fetch artifacts
uses: actions/download-artifact@v4
Expand Down
33 changes: 28 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ else()
add_definitions(-D_CRT_SILENCE_NONCONFORMING_TGMATH_H -D_CRT_SECURE_NO_WARNINGS)
endif()

if(VITA)
message(STATUS "Building for PS Vita")
add_compile_options(-fno-use-cxa-atexit)
endif()

if(BUILD_CLIENT)
add_subdirectory(cl_dll)
endif()
Expand All @@ -104,12 +109,18 @@ if(BUILD_MENU)
add_subdirectory(3rdparty/mainui_cpp)
endif()

if(ANDROID OR CMAKE_SIZEOF_VOID_P EQUAL 8)
set(VGUI_STATIC ON CACHE BOOL "" FORCE)
add_subdirectory(3rdparty/vgui_dll)
# check for platforms that aren't natively supported by VGUI
if(ANDROID OR CMAKE_SIZEOF_VOID_P EQUAL 8 OR VITA)
set(VGUI_STATIC ON CACHE BOOL "" FORCE)
add_subdirectory(3rdparty/vgui_dll)

set(XASH_SDK ${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(3rdparty/vgui_support)

set(XASH_SDK ${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(3rdparty/vgui_support)
if(VITA)
target_compile_options(vgui PRIVATE -fPIC)
target_compile_options(vgui_support PRIVATE -fPIC)
endif()
elseif(BUILD_VGUI)
add_subdirectory(3rdparty/vgui_dll)
endif()
Expand Down Expand Up @@ -146,9 +157,21 @@ if(NOT ANDROID)
)
endif()

# copy pre-generated config files to psvita bundle
if(VITA)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/config.cfg"
"${CMAKE_CURRENT_BINARY_DIR}/video.cfg"
"${CMAKE_CURRENT_BINARY_DIR}/opengl.cfg"
DESTINATION "${GAME_DIR}/")
endif()

if(WIN32)
set(CPACK_GENERATOR "ZIP")
set(CPACK_PACKAGE_FILE_NAME "TF15Client-${CMAKE_SYSTEM_NAME}-${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}")
elseif(VITA)
set(CPACK_GENERATOR "ZIP")
set(CPACK_PACKAGE_FILE_NAME "TF15Client-PSVita")
else()
set(CPACK_GENERATOR "TGZ")
set(CPACK_PACKAGE_FILE_NAME "TF15Client-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
Expand Down
26 changes: 26 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,32 @@
},
"binaryDir": "${sourceDir}/build",
"toolchainFile": "${sourceDir}/toolchains/i386-linux-gnu.cmake"
},
{
"name": "psvita-debug",
"displayName": "PS Vita Debug",
"generator": "Unix Makefiles",
"toolchainFile": "$env{VITASDK}/share/vita.toolchain.cmake",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BUILD_SERVER": "OFF",
"MAINUI_USE_STB": "ON",
"CMAKE_PROJECT_tf15-client_INCLUDE": "$env{VITASDK}/share/vrtld_shim.cmake"
},
"binaryDir": "${sourceDir}/build"
},
{
"name": "psvita-release",
"displayName": "PS Vita Release",
"generator": "Unix Makefiles",
"toolchainFile": "$env{VITASDK}/share/vita.toolchain.cmake",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BUILD_SERVER": "OFF",
"MAINUI_USE_STB": "ON",
"CMAKE_PROJECT_tf15-client_INCLUDE": "$env{VITASDK}/share/vrtld_shim.cmake"
},
"binaryDir": "${sourceDir}/build"
}
]
}
10 changes: 7 additions & 3 deletions cl_dll/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ set(CLDLL_SOURCES

include_directories(. hl/ ../dlls ../dlls/tfc ../common ../engine ../pm_shared ../game_shared ../public)

if(ANDROID OR CMAKE_SIZEOF_VOID_P EQUAL 8)
if(ANDROID OR CMAKE_SIZEOF_VOID_P EQUAL 8 OR VITA)
include_directories(../3rdparty/vgui_dll/include)
elseif(NOT BUILD_VGUI)
SET(CMAKE_SKIP_RPATH TRUE)
Expand All @@ -164,9 +164,13 @@ if(WIN32)
target_link_libraries(${CLDLL_LIBRARY} user32.lib winmm.lib ws2_32.lib)
endif()

if(ANDROID OR CMAKE_SIZEOF_VOID_P EQUAL 8)
if(ANDROID OR CMAKE_SIZEOF_VOID_P EQUAL 8 OR VITA)
target_link_libraries(${CLDLL_LIBRARY} vgui_support)
target_link_libraries(${CLDLL_LIBRARY} vgui)
if(VITA)
target_link_libraries(${CLDLL_LIBRARY} -Wl,--whole-archive vgui -Wl,--no-whole-archive)
else()
target_link_libraries(${CLDLL_LIBRARY} vgui)
endif()
elseif(NOT BUILD_VGUI)
if (WIN32)
add_library(vgui SHARED IMPORTED)
Expand Down
5 changes: 4 additions & 1 deletion cl_dll/cdll_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
#include "windows.h"
#undef HSPRITE
#else
#define MAX_PATH PATH_MAX
#include <limits.h>
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
#define MAX_PATH PATH_MAX
#endif

#include "hud.h"
Expand Down
4 changes: 3 additions & 1 deletion cl_dll/hud_benchtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
// Functions for spawning a thread to get a hopcount to a particular ip address and returning the result in a specified
// variable

#include "build.h"

#ifdef _WIN32
#define HSPRITE HSPRITE_win32
#include <windows.h>
#undef HSPRITE
#else
#elif XASH_LINUX == 1
#include <dlfcn.h>
#endif

Expand Down
10 changes: 10 additions & 0 deletions common/mathlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,27 @@
#pragma once
#ifndef MATHLIB_H
#define MATHLIB_H

#include "build.h"

#ifndef __cplusplus
#include <math.h>
#ifdef HAVE_TGMATH_H

#if XASH_PSVITA != 1
#include <tgmath.h>
#endif

#endif // HAVE_TGMATH_H

#else // __cplusplus

#if HAVE_CMATH
#include <cmath>
#else
#include <math.h>
#endif

#endif // __cplusplus

typedef float vec_t;
Expand Down
2 changes: 1 addition & 1 deletion dlls/extdll.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@
typedef unsigned int ULONG;
typedef unsigned char BYTE;
typedef int BOOL;
#define MAX_PATH PATH_MAX
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
#define MAX_PATH PATH_MAX
#endif //_WIN32

// Misc C-runtime library headers
Expand Down
6 changes: 2 additions & 4 deletions pm_shared/pm_math.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
*
****/
// pm_math.c -- math primitives
#include <math.h>

#include "mathlib.h"
#ifdef HAVE_TGMATH_H
#include <tgmath.h>
#endif
#include "build.h"
#include "const.h"

// up / down
Expand Down
1 change: 1 addition & 0 deletions public/build.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Then you can use another oneliner to query all variables:
#undef XASH_IRIX
#undef XASH_JS
#undef XASH_LINUX
#undef XASH_LINUX_UNKNOWN
#undef XASH_LITTLE_ENDIAN
#undef XASH_MIPS
#undef XASH_MOBILE_PLATFORM
Expand Down
6 changes: 6 additions & 0 deletions public/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
#include <stdio.h>
#include "interface.h"

#if XASH_PSVITA == 1
#include <unistd.h>
#define VRTLD_LIBDL_COMPAT
#include <vrtld.h>
#endif

#if !defined( _WIN32 )
// Linux doesn't have this function so this emulates its functionality
//
Expand Down
7 changes: 4 additions & 3 deletions public/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@
#ifndef __INTERFACE_H__
#define __INTERFACE_H__

#if !defined( _WIN32 )
#include "build.h"

#if XASH_LINUX == 1
#include <dlfcn.h> // dlopen,dlclose, et al
#include <unistd.h>
#endif

#if !defined( _WIN32 )
#define HMODULE void *
#define GetProcAddress dlsym

#define _snprintf snprintf

#endif

void *Sys_GetProcAddress( void *pModuleHandle, const char *pName );
Expand Down
25 changes: 25 additions & 0 deletions scripts/setup_psvita_sdk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

cd $GITHUB_WORKSPACE

export VITASDK=/usr/local/vitasdk

echo "Downloading vitasdk..."
git clone https://github.com/vitasdk/vdpm.git --depth=1 || exit 1
pushd vdpm
./bootstrap-vitasdk.sh || exit 1
./vdpm taihen || exit 1
./vdpm kubridge || exit 1
./vdpm zlib || exit 1
./vdpm SceShaccCgExt || exit 1
./vdpm vitaShaRK || exit 1
./vdpm libmathneon || exit 1
popd

echo "Building vrtld..."
git clone https://github.com/fgsfdsfgs/vita-rtld.git --depth=1 || exit 1
pushd vita-rtld || die
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release || die_configure
cmake --build build -- -j$JOBS || die
cmake --install build || die
popd
27 changes: 27 additions & 0 deletions scripts/write_psvita_configs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

touch config.cfg
echo 'unbindall' >> config.cfg
echo 'bind A_BUTTON "+use"' >> config.cfg
echo 'bind B_BUTTON "+jump"' >> config.cfg
echo 'bind X_BUTTON "+reload"' >> config.cfg
echo 'bind Y_BUTTON "+duck"' >> config.cfg
echo 'bind L1_BUTTON "+attack2"' >> config.cfg
echo 'bind R1_BUTTON "+attack"' >> config.cfg
echo 'bind START "escape"' >> config.cfg
echo 'bind DPAD_UP "lastinv"' >> config.cfg
echo 'bind DPAD_DOWN "impulse 100"' >> config.cfg
echo 'bind DPAD_LEFT "invprev"' >> config.cfg
echo 'bind DPAD_RIGHT "invnext"' >> config.cfg
echo 'bind BACK "chooseteam"' >> config.cfg
echo 'gl_vsync "1"' >> config.cfg
echo 'sv_autosave "0"' >> config.cfg

touch video.cfg
echo 'fullscreen "1"' >> video.cfg
echo 'width "960"' >> video.cfg
echo 'height "544"' >> video.cfg
echo 'r_refdll "gl"' >> video.cfg

touch opengl.cfg
echo 'gl_nosort "1"' >> opengl.cfg