Skip to content

Commit 70142af

Browse files
committed
GitHub actions: Switch build
1 parent 1b10bc9 commit 70142af

File tree

10 files changed

+88
-16
lines changed

10 files changed

+88
-16
lines changed

.github/workflows/build.yml

Lines changed: 35 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/ccache-action@v1.2
386-
386+
387387
- name: Compile ffmpeg
388388
run: |
389389
cd ffmpeg && ./linux_x86-64.sh
@@ -399,3 +399,36 @@ 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+
-DUSE_LIBNX:BOOL=TRUE \
419+
-DUSE_FFMPEG:BOOL=FALSE \
420+
-DUSE_DISCORD:BOOL=FALSE \
421+
-DUSE_MINIUPNPC:BOOL=FALSE \
422+
-DUSE_ARMIPS:BOOL=FALSE \
423+
-DCMAKE_COLOR_DIAGNOSTICS:BOOL=TRUE \
424+
..
425+
ninja
426+
427+
- name: Upload artifacts
428+
if: success()
429+
uses: actions/upload-artifact@v4
430+
with:
431+
name: ppsspp-switch-build
432+
path: |
433+
build-switch/ppsspp.elf
434+
build-switch/ppsspp.nro

CMakeLists.txt

Lines changed: 16 additions & 3 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+
set(GLEW_NO_GLU ON)
232+
add_definitions(-DLUA_32BITS)
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)
@@ -1468,7 +1477,11 @@ 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+
endif()
14721485
elseif(SDL2_ttf_PKGCONFIG_FOUND)
14731486
set(nativeExtraLibs ${nativeExtraLibs} PkgConfig::SDL2_ttf_PKGCONFIG)
14741487
endif()

CMakePresets.json

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": 2,
2+
"version": 8,
33
"configurePresets": [
44
{
55
"name": "gcc-debug",
@@ -18,6 +18,23 @@
1818
"CMAKE_BUILD_TYPE": "Debug",
1919
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
2020
}
21+
},
22+
{
23+
"name": "libnx-debug",
24+
"hidden": false,
25+
"generator": "Ninja",
26+
"binaryDir": "build-libnx-debug",
27+
"cacheVariables": {
28+
"CMAKE_BUILD_TYPE": "Debug",
29+
"CMAKE_TOOLCHAIN_FILE": "$env{DEVKITPRO}/cmake/Switch.cmake",
30+
"USE_LIBNX": true,
31+
"USE_FFMPEG": false,
32+
"USE_DISCORD": false,
33+
"USE_MINIUPNPC": false,
34+
"USE_ARMIPS": false,
35+
"CMAKE_EXPORT_COMPILE_COMMANDS": "YES",
36+
"CMAKE_COLOR_DIAGNOSTICS": "YES"
37+
}
2138
}
2239
]
2340
}

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/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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
#include <sys/ioctl.h>
1414
#include <sys/socket.h>
1515
#include <sys/select.h>
16+
#if !PPSSPP_PLATFORM(SWITCH)
1617
#include <sys/mman.h>
18+
#endif
1719
#include <net/if.h>
1820
#include <netinet/in.h>
1921
#include <netinet/tcp.h>

Common/StringUtils.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,19 @@
1515
// Official SVN repository and contact information can be found at
1616
// http://code.google.com/p/dolphin-emu/
1717

18-
#include <cstring>
19-
2018
#include "ppsspp_config.h"
2119

20+
#if PPSSPP_PLATFORM(SWITCH)
21+
#define _GNU_SOURCE
22+
#endif
23+
2224
#ifdef _WIN32
2325
#include "Common/CommonWindows.h"
2426
#endif
2527

26-
#if PPSSPP_PLATFORM(SWITCH)
27-
#define _GNU_SOURCE
2828
#include <cstdio>
29-
#endif
30-
3129
#include <cstdarg>
30+
#include <cstring>
3231

3332
#include <string>
3433
#include <sstream>

Common/Thread/ThreadUtil.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ void RegisterAttachDetach(AttachDetachFunc attach, AttachDetachFunc detach) {
5757
#include <pthread.h>
5858
#include <sys/types.h>
5959
#include <unistd.h>
60+
#if !PPSSPP_PLATFORM(SWITCH)
6061
#include <sys/syscall.h>
6162
#endif
63+
#endif
6264

6365
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
6466
#include <pthread_np.h>

0 commit comments

Comments
 (0)