Skip to content

Commit 5d15713

Browse files
committed
Added support for PS Vita platform
1 parent ffae509 commit 5d15713

15 files changed

Lines changed: 203 additions & 17 deletions

File tree

.github/workflows/build.yml

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
branches:
55
- master
66
- new-mod-api
7+
- psvita-port
8+
79

810
jobs:
911
android:
@@ -104,10 +106,54 @@ jobs:
104106
with:
105107
name: ${{ runner.os }}-${{ matrix.arch }}
106108
path: build/*.tar.gz
109+
psvita:
110+
name: PS Vita
111+
runs-on: ubuntu-latest
112+
continue-on-error: true
113+
steps:
114+
- name: Checkout sources
115+
uses: actions/checkout@v4
116+
with:
117+
fetch-depth: 0
118+
submodules: recursive
119+
- name: Install dependencies
120+
run: |
121+
sudo dpkg --add-architecture i386
122+
sudo apt-get update
123+
sudo apt-get install libatomic1 libgcc-s1 \
124+
libstdc++6 gcc-multilib g++-multilib cmake \
125+
ninja-build libfontconfig-dev
126+
sudo apt-get install cmake=3.28.3-1build7
127+
sudo ln -sf /usr/bin/cmake /usr/local/bin/cmake
128+
- name: Setup VitaSDK
129+
run: |
130+
chmod +x scripts/setup_psvita_sdk.sh
131+
scripts/setup_psvita_sdk.sh
132+
echo "VITASDK=/usr/local/vitasdk" >> $GITHUB_ENV
133+
echo "$VITASDK/bin" >> $GITHUB_PATH
134+
- name: Configure project
135+
run: cmake --preset "psvita-debug"
136+
- name: Build
137+
run: cmake --build .
138+
working-directory: build
139+
- name: Write configuration files
140+
run: |
141+
pushd build
142+
chmod +x ${{ github.workspace }}/scripts/write_psvita_configs.sh
143+
${{ github.workspace }}/scripts/write_psvita_configs.sh
144+
popd
145+
- name: Package
146+
run: cpack --config CPackConfig.cmake
147+
working-directory: build
148+
- name: Upload artifacts
149+
uses: actions/upload-artifact@v4
150+
with:
151+
name: PSVita
152+
path: build/*.zip
107153
release:
108154
name: Release
109155
runs-on: ubuntu-latest
110-
needs: [android, windows, linux]
156+
needs: [android, windows, linux, psvita]
111157
steps:
112158
- name: Fetch artifacts
113159
uses: actions/download-artifact@v4

CMakeLists.txt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ else()
9292
add_definitions(-D_CRT_SILENCE_NONCONFORMING_TGMATH_H -D_CRT_SECURE_NO_WARNINGS)
9393
endif()
9494

95+
if(VITA)
96+
message(STATUS "Building for PS Vita")
97+
add_compile_options(-fno-use-cxa-atexit)
98+
endif()
99+
95100
if(BUILD_CLIENT)
96101
add_subdirectory(cl_dll)
97102
endif()
@@ -104,12 +109,18 @@ if(BUILD_MENU)
104109
add_subdirectory(3rdparty/mainui_cpp)
105110
endif()
106111

107-
if(ANDROID OR CMAKE_SIZEOF_VOID_P EQUAL 8)
108-
set(VGUI_STATIC ON CACHE BOOL "" FORCE)
109-
add_subdirectory(3rdparty/vgui_dll)
112+
# check for platforms that aren't natively supported by VGUI
113+
if(ANDROID OR CMAKE_SIZEOF_VOID_P EQUAL 8 OR VITA)
114+
set(VGUI_STATIC ON CACHE BOOL "" FORCE)
115+
add_subdirectory(3rdparty/vgui_dll)
110116

111117
set(XASH_SDK ${CMAKE_CURRENT_SOURCE_DIR})
112118
add_subdirectory(3rdparty/vgui_support)
119+
120+
if(VITA)
121+
target_compile_options(vgui PRIVATE -fPIC)
122+
target_compile_options(vgui_support PRIVATE -fPIC)
123+
endif()
113124
elseif(BUILD_VGUI)
114125
add_subdirectory(3rdparty/vgui_dll)
115126
endif()
@@ -147,6 +158,9 @@ install(
147158
if(WIN32)
148159
set(CPACK_GENERATOR "ZIP")
149160
set(CPACK_PACKAGE_FILE_NAME "TF15Client-${CMAKE_SYSTEM_NAME}-${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}")
161+
elseif(VITA)
162+
set(CPACK_GENERATOR "ZIP")
163+
set(CPACK_PACKAGE_FILE_NAME "TF15Client-PSVita")
150164
else()
151165
set(CPACK_GENERATOR "TGZ")
152166
set(CPACK_PACKAGE_FILE_NAME "TF15Client-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")

CMakePresets.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,32 @@
7979
},
8080
"binaryDir": "${sourceDir}/build",
8181
"toolchainFile": "${sourceDir}/toolchains/i386-linux-gnu.cmake"
82+
},
83+
{
84+
"name": "psvita-debug",
85+
"displayName": "PS Vita Debug",
86+
"generator": "Unix Makefiles",
87+
"toolchainFile": "$env{VITASDK}/share/vita.toolchain.cmake",
88+
"cacheVariables": {
89+
"CMAKE_BUILD_TYPE": "Debug",
90+
"BUILD_SERVER": "OFF",
91+
"MAINUI_USE_STB": "ON",
92+
"CMAKE_PROJECT_tf15-client_INCLUDE": "$env{VITASDK}/share/vrtld_shim.cmake"
93+
},
94+
"binaryDir": "${sourceDir}/build"
95+
},
96+
{
97+
"name": "psvita-release",
98+
"displayName": "PS Vita Release",
99+
"generator": "Unix Makefiles",
100+
"toolchainFile": "$env{VITASDK}/share/vita.toolchain.cmake",
101+
"cacheVariables": {
102+
"CMAKE_BUILD_TYPE": "Release",
103+
"BUILD_SERVER": "OFF",
104+
"MAINUI_USE_STB": "ON",
105+
"CMAKE_PROJECT_tf15-client_INCLUDE": "$env{VITASDK}/share/vrtld_shim.cmake"
106+
},
107+
"binaryDir": "${sourceDir}/build"
82108
}
83109
]
84110
}

cl_dll/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ set(CLDLL_SOURCES
146146

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

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

167-
if(ANDROID OR CMAKE_SIZEOF_VOID_P EQUAL 8)
167+
if(ANDROID OR CMAKE_SIZEOF_VOID_P EQUAL 8 OR VITA)
168168
target_link_libraries(${CLDLL_LIBRARY} vgui_support)
169-
target_link_libraries(${CLDLL_LIBRARY} vgui)
169+
if(VITA)
170+
target_link_libraries(${CLDLL_LIBRARY} -Wl,--whole-archive vgui -Wl,--no-whole-archive)
171+
else()
172+
target_link_libraries(${CLDLL_LIBRARY} vgui)
173+
endif()
170174
elseif(NOT BUILD_VGUI)
171175
if (WIN32)
172176
add_library(vgui SHARED IMPORTED)

cl_dll/cdll_int.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@
2323
#include "windows.h"
2424
#undef HSPRITE
2525
#else
26-
#define MAX_PATH PATH_MAX
2726
#include <limits.h>
27+
#ifndef PATH_MAX
28+
#define PATH_MAX 4096
29+
#endif
30+
#define MAX_PATH PATH_MAX
2831
#endif
2932

3033
#include "hud.h"

cl_dll/hud_benchtrace.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
// Functions for spawning a thread to get a hopcount to a particular ip address and returning the result in a specified
33
// variable
44

5+
#include "build.h"
6+
57
#ifdef _WIN32
68
#define HSPRITE HSPRITE_win32
79
#include <windows.h>
810
#undef HSPRITE
9-
#else
11+
#elif XASH_LINUX == 1
1012
#include <dlfcn.h>
1113
#endif
1214

cmake/GenerateExtras.cmake

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# ugly and not performant but cmake is what it is
2+
if(NOT ANDROID)
3+
add_custom_command(OUTPUT ${EXTRAS_DIR}
4+
COMMAND ${CMAKE_COMMAND} -E make_directory "${EXTRAS_DIR}")
5+
6+
add_custom_target(pack_extras ALL
7+
COMMAND ${CMAKE_COMMAND} -E copy_directory
8+
"${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/tf15client-extras" "${EXTRAS_DIR}"
9+
COMMAND ${CMAKE_COMMAND} -E tar cf "${EXTRAS_DIR}.pk3" --format=zip .
10+
WORKING_DIRECTORY "${EXTRAS_DIR}"
11+
DEPENDS "${EXTRAS_DIR}")
12+
13+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/extras.pk3" DESTINATION "${GAME_DIR}/")
14+
15+
# copy pre-generated config files to psvita bundle
16+
if(VITA)
17+
install(FILES
18+
"${CMAKE_CURRENT_BINARY_DIR}/config.cfg"
19+
"${CMAKE_CURRENT_BINARY_DIR}/video.cfg"
20+
"${CMAKE_CURRENT_BINARY_DIR}/opengl.cfg"
21+
DESTINATION "${GAME_DIR}/")
22+
endif()
23+
endif()

common/mathlib.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,27 @@
1616
#pragma once
1717
#ifndef MATHLIB_H
1818
#define MATHLIB_H
19+
20+
#include "build.h"
21+
1922
#ifndef __cplusplus
2023
#include <math.h>
2124
#ifdef HAVE_TGMATH_H
25+
26+
#if XASH_PSVITA != 1
2227
#include <tgmath.h>
28+
#endif
29+
2330
#endif // HAVE_TGMATH_H
31+
2432
#else // __cplusplus
33+
2534
#if HAVE_CMATH
2635
#include <cmath>
2736
#else
2837
#include <math.h>
2938
#endif
39+
3040
#endif // __cplusplus
3141

3242
typedef float vec_t;

dlls/extdll.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@
5656
typedef unsigned int ULONG;
5757
typedef unsigned char BYTE;
5858
typedef int BOOL;
59-
#define MAX_PATH PATH_MAX
6059
#ifndef PATH_MAX
6160
#define PATH_MAX 4096
6261
#endif
62+
#define MAX_PATH PATH_MAX
6363
#endif //_WIN32
6464

6565
// Misc C-runtime library headers

pm_shared/pm_math.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313
*
1414
****/
1515
// pm_math.c -- math primitives
16-
#include <math.h>
16+
1717
#include "mathlib.h"
18-
#ifdef HAVE_TGMATH_H
19-
#include <tgmath.h>
20-
#endif
18+
#include "build.h"
2119
#include "const.h"
2220

2321
// up / down

0 commit comments

Comments
 (0)