Skip to content

Commit 23712e6

Browse files
committed
GitHub actions: Switch build
1 parent f573b0c commit 23712e6

File tree

17 files changed

+152
-67
lines changed

17 files changed

+152
-67
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"image": "devkitpro/devkita64"
3+
}

.github/workflows/build.yml

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ jobs:
365365

366366
build_test_headless_alpine:
367367
runs-on: ubuntu-latest
368-
container:
368+
container:
369369
image: alpine:latest
370370
options: --shm-size=8g
371371
steps:
@@ -383,7 +383,7 @@ jobs:
383383
384384
- name: Setup ccache
385385
uses: hendrikmuhs/[email protected]
386-
386+
387387
- name: Compile ffmpeg
388388
run: |
389389
cd ffmpeg && ./linux_x86-64.sh
@@ -399,3 +399,40 @@ jobs:
399399
- name: Execute headless tests
400400
run: |
401401
python test.py -g --graphics=software
402+
403+
build_switch:
404+
runs-on: ubuntu-latest
405+
container:
406+
image: 'devkitpro/devkita64'
407+
steps:
408+
- name: Checkout
409+
uses: actions/checkout@v4
410+
with:
411+
submodules: recursive
412+
413+
- name: Build
414+
run: |
415+
mkdir -p build-switch
416+
cd build-switch
417+
cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/cmake/Switch.cmake \
418+
-DCMAKE_BUILD_TYPE=${{ env.BUILD_CONFIGURATION }} \
419+
-DUSE_LIBNX:BOOL=TRUE \
420+
-DUSING_GLES2:BOOL=TRUE \
421+
-DUSING_EGL:BOOL=FALSE \
422+
-DUSE_FFMPEG:BOOL=FALSE \
423+
-DUSE_DISCORD:BOOL=FALSE \
424+
-DUSE_MINIUPNPC:BOOL=FALSE \
425+
-DUSE_ARMIPS:BOOL=FALSE \
426+
-DUSE_SYSTEM_LIBPNG:BOOL=FALSE \
427+
-DCMAKE_COLOR_DIAGNOSTICS:BOOL=TRUE \
428+
..
429+
ninja
430+
431+
- name: Upload artifacts
432+
if: success()
433+
uses: actions/upload-artifact@v4
434+
with:
435+
name: ppsspp-switch-build
436+
path: |
437+
build-switch/PPSSPP.elf
438+
build-switch/PPSSPP.nro

CMakeLists.txt

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ option(UNITTEST "Set to ON to generate the unittest target" ${UNITTEST})
173173
option(SIMULATOR "Set to ON when targeting an x86 simulator of an ARM platform" ${SIMULATOR})
174174
option(LIBRETRO "Set to ON to generate the libretro target" OFF)
175175
# :: Options
176-
option(USE_LIBNX "Set to ON to build for Switch(libnx)" OFF)
176+
option(USE_LIBNX "Set to ON to build for Switch (libnx)" OFF)
177177
option(USE_FFMPEG "Build with FFMPEG support" ON)
178178
option(USE_DISCORD "Build with Discord support" ON)
179179
option(USE_MINIUPNPC "Build with miniUPnPc support" ON)
@@ -221,12 +221,21 @@ endif()
221221

222222
if(LIBRETRO)
223223
add_definitions(-D__LIBRETRO__)
224-
add_definitions(-DGLEW_NO_GLU)
224+
set(GLEW_NO_GLU ON)
225225
if(NOT MSVC)
226226
add_compile_options(-fPIC)
227227
endif()
228228
endif()
229229

230+
if (USE_LIBNX)
231+
add_definitions(-DHAVE_LIBNX)
232+
set(GLEW_NO_GLU ON)
233+
endif()
234+
235+
if (GLEW_NO_GLU)
236+
add_definitions(-DGLEW_NO_GLU)
237+
endif()
238+
230239
if(ANDROID)
231240
set(MOBILE_DEVICE ON)
232241
set(USING_GLES2 ON)
@@ -946,7 +955,7 @@ if(ARM64)
946955
endif()
947956
endif()
948957

949-
if(USING_GLES2 OR (USING_EGL AND NOT USING_FBDEV))
958+
if((USING_GLES2 OR (USING_EGL AND NOT USING_FBDEV)) AND NOT USE_LIBNX)
950959
find_package(X11)
951960
endif()
952961

@@ -1468,7 +1477,17 @@ else()
14681477
message(WARNING "Found SDL2_ttf <2.0.18 - this is too old, falling back to atlas")
14691478
endif()
14701479
if(SDL2_ttf_FOUND)
1471-
set(nativeExtraLibs ${nativeExtraLibs} SDL2_ttf::SDL2_ttf)
1480+
if(TARGET SDL2_ttf::SDL2_ttf)
1481+
set(nativeExtraLibs ${nativeExtraLibs} SDL2_ttf::SDL2_ttf)
1482+
else()
1483+
set(nativeExtraLibs ${nativeExtraLibs} SDL2_ttf::SDL2_ttf-static)
1484+
if (USE_LIBNX)
1485+
# devkitpro switch portlibs SDL2_ttf is pulling -lpng16. Remove it to use libpng17
1486+
get_target_property(SDL2_ttf_extra_libs SDL2_ttf::SDL2_ttf-static INTERFACE_LINK_LIBRARIES)
1487+
string(REPLACE "png16" "" SDL2_ttf_extra_libs_fixed "${SDL2_ttf_extra_libs}")
1488+
set_target_properties(SDL2_ttf::SDL2_ttf-static PROPERTIES INTERFACE_LINK_LIBRARIES "${SDL2_ttf_extra_libs_fixed}")
1489+
endif()
1490+
endif()
14721491
elseif(SDL2_ttf_PKGCONFIG_FOUND)
14731492
set(nativeExtraLibs ${nativeExtraLibs} PkgConfig::SDL2_ttf_PKGCONFIG)
14741493
endif()
@@ -2492,7 +2511,7 @@ endif()
24922511
include_directories(ext/libchdr/include)
24932512

24942513
target_link_libraries(${CoreLibName} Common native chdr kirk cityhash sfmt19937 xbrz xxhash rcheevos minimp3 at3_standalone lua ${GlslangLibs}
2495-
${CoreExtraLibs} ${OPENGL_LIBRARIES} ${X11_LIBRARIES} ${CMAKE_DL_LIBS})
2514+
${CoreExtraLibs} ${OPENGL_LIBRARIES} ${X11_LIBRARIES} $<$<NOT:$<BOOL:${USE_LIBNX}>>:${CMAKE_DL_LIBS}>)
24962515

24972516
# Winsock
24982517
if(WIN32)

CMakePresets.json

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,43 @@
1-
{
2-
"version": 2,
3-
"configurePresets": [
4-
{
5-
"name": "gcc-debug",
6-
"binaryDir": "build-gcc-debug",
7-
"generator": "Ninja",
8-
"cacheVariables": {
9-
"CMAKE_BUILD_TYPE": "Debug",
10-
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
11-
}
12-
},
13-
{
14-
"name": "clang-debug",
15-
"binaryDir": "build-clang-debug",
16-
"generator": "Ninja",
17-
"cacheVariables": {
18-
"CMAKE_BUILD_TYPE": "Debug",
19-
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
20-
}
21-
}
22-
]
23-
}
1+
{
2+
"version": 8,
3+
"configurePresets": [
4+
{
5+
"name": "gcc-debug",
6+
"binaryDir": "build-gcc-debug",
7+
"generator": "Ninja",
8+
"cacheVariables": {
9+
"CMAKE_BUILD_TYPE": "Debug",
10+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
11+
}
12+
},
13+
{
14+
"name": "clang-debug",
15+
"binaryDir": "build-clang-debug",
16+
"generator": "Ninja",
17+
"cacheVariables": {
18+
"CMAKE_BUILD_TYPE": "Debug",
19+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
20+
}
21+
},
22+
{
23+
"name": "switch-debug",
24+
"hidden": false,
25+
"generator": "Ninja",
26+
"binaryDir": "build-switch-debug",
27+
"cacheVariables": {
28+
"CMAKE_BUILD_TYPE": "Debug",
29+
"CMAKE_TOOLCHAIN_FILE": "$env{DEVKITPRO}/cmake/Switch.cmake",
30+
"USE_LIBNX": true,
31+
"USING_GLES2": true,
32+
"USING_EGL": false,
33+
"USE_FFMPEG": false,
34+
"USE_DISCORD": false,
35+
"USE_MINIUPNPC": false,
36+
"USE_ARMIPS": false,
37+
"USE_SYSTEM_LIBPNG": false,
38+
"CMAKE_EXPORT_COMPILE_COMMANDS": "YES",
39+
"CMAKE_COLOR_DIAGNOSTICS": "YES"
40+
}
41+
}
42+
]
43+
}

Common/Arm64Emitter.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
#ifdef FMIN
2121
#undef FMIN
2222
#endif
23+
#ifdef BIT
24+
#undef BIT
25+
#endif
2326

2427
namespace Arm64Gen
2528
{

Common/CommonTypes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ typedef signed __int64 s64;
4949
#define Framebuffer _Framebuffer
5050
#define Waitable _Waitable
5151
#define ThreadContext _ThreadContext
52+
#define BreakReason _BreakReason
5253
#include <switch.h>
5354
// Cleanup
5455
#undef KEY_UP
@@ -57,6 +58,7 @@ typedef signed __int64 s64;
5758
#undef Framebuffer
5859
#undef Waitable
5960
#undef ThreadContext
61+
#undef BreakReason
6062

6163
// Conflicting types with libnx
6264
#ifndef _u64

Common/GPU/OpenGL/gl3stub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "Common/GPU/OpenGL/GLCommon.h"
2020

2121
#if defined(USING_GLES2)
22-
#if !PPSSPP_PLATFORM(IOS)
22+
#if !PPSSPP_PLATFORM(IOS) && !PPSSPP_PLATFORM(SWITCH)
2323
#include "EGL/egl.h"
2424

2525
GLboolean gl3stubInit() {

Common/MemArenaHorizon.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ u8 *MemArena::Find4GBBase() {
6767
memorySrcBase = (uintptr_t)memalign(0x1000, 0x10000000);
6868

6969
if (!memoryBase)
70-
memoryBase = (uintptr_t)virtmemReserve(0x10000000);
70+
memoryBase = (uintptr_t)virtmemFindAslr(0x10000000, 0x1000);
7171

7272
if (!memoryCodeBase)
73-
memoryCodeBase = (uintptr_t)virtmemReserve(0x10000000);
73+
memoryCodeBase = (uintptr_t)virtmemFindAslr(0x10000000, 0x1000);
7474

7575
if (R_FAILED(svcMapProcessCodeMemory(envGetOwnProcessHandle(), (u64)memoryCodeBase, (u64)memorySrcBase, 0x10000000)))
7676
printf("Failed to map memory...\n");

Common/MemoryUtil.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
#ifndef __SWITCH__
2222
#include <sys/mman.h>
2323
#else
24-
#include <switch.h>
24+
//#include <switch.h>
2525
#endif // !__SWITCH__
2626
#endif
27-
#include <stdint.h>
27+
#include <cstdint>
28+
#include <cstddef>
2829

2930
// Returns true if we need to avoid setting both writable and executable at the same time (W^X)
3031
bool PlatformIsWXExclusive();

Common/Net/SocketCompat.h

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include "ppsspp_config.h"
44

5+
#include "Common/CommonTypes.h"
6+
57
#if PPSSPP_PLATFORM(WINDOWS)
68
#include "Common/CommonWindows.h"
79
#include <io.h>
@@ -13,7 +15,9 @@
1315
#include <sys/ioctl.h>
1416
#include <sys/socket.h>
1517
#include <sys/select.h>
18+
#if !PPSSPP_PLATFORM(SWITCH)
1619
#include <sys/mman.h>
20+
#endif
1721
#include <net/if.h>
1822
#include <netinet/in.h>
1923
#include <netinet/tcp.h>
@@ -27,21 +31,6 @@
2731
#include <fcntl.h>
2832
#include <errno.h>
2933

30-
#if defined(HAVE_LIBNX) || PPSSPP_PLATFORM(SWITCH)
31-
#undef __BSD_VISIBLE
32-
#define __BSD_VISIBLE 1
33-
#define TCP_MAXSEG 2
34-
#include <netdb.h>
35-
#include <switch.h>
36-
// Missing include, *shrugs*
37-
extern "C" struct hostent *gethostbyname(const char *name);
38-
#endif // defined(HAVE_LIBNX) || PPSSPP_PLATFORM(SWITCH)
39-
40-
#if PPSSPP_PLATFORM(SWITCH) && !defined(INADDR_NONE)
41-
// Missing toolchain define
42-
#define INADDR_NONE 0xFFFFFFFF
43-
#endif
44-
4534
// TODO: move this to some common set
4635
#if PPSSPP_PLATFORM(WINDOWS)
4736
#undef ESHUTDOWN

0 commit comments

Comments
 (0)