Skip to content

Commit 7ae6459

Browse files
authored
Restore support for the Nokia N-Gage (#12148)
1 parent 26f9940 commit 7ae6459

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+4183
-43
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: 'Setup Nonka N-Gage SDK'
2+
description: 'Download and setup Nokia N-Gage SDK'
3+
inputs:
4+
path:
5+
description: 'Installation path'
6+
default: 'default'
7+
runs:
8+
using: 'composite'
9+
steps:
10+
- uses: actions/setup-python@v5
11+
with:
12+
python-version: '3.x'
13+
- name: 'Verify platform'
14+
id: calc
15+
shell: sh
16+
run: |
17+
case "${{ runner.os }}-${{ runner.arch }}" in
18+
"Windows-X86" | "Windows-X64")
19+
echo "ok!"
20+
echo "cache-key=ngage-sdk-windows" >> ${GITHUB_OUTPUT}
21+
default_install_path="C:/ngagesdk"
22+
;;
23+
*)
24+
echo "Unsupported ${{ runner.os }}-${{ runner.arch }}"
25+
exit 1;
26+
;;
27+
esac
28+
install_path="${{ inputs.path }}"
29+
if [ "x$install_path" = "xdefault" ]; then
30+
install_path="$default_install_path"
31+
fi
32+
echo "install-path=$install_path" >> ${GITHUB_OUTPUT}
33+
34+
toolchain_repo="https://github.com/ngagesdk/ngage-toolchain"
35+
toolchain_branch="main"
36+
echo "toolchain-repo=${toolchain_repo}" >> ${GITHUB_OUTPUT}
37+
echo "toolchain-branch=${toolchain_branch}" >> ${GITHUB_OUTPUT}
38+
39+
sdk_repo="https://github.com/ngagesdk/sdk"
40+
sdk_branch="main"
41+
echo "sdk-repo=${sdk_repo}" >> ${GITHUB_OUTPUT}
42+
echo "sdk-branch=${sdk_branch}" >> ${GITHUB_OUTPUT}
43+
44+
tools_repo="https://github.com/ngagesdk/tools"
45+
tools_branch="main"
46+
echo "tools-repo=${tools_repo}" >> ${GITHUB_OUTPUT}
47+
echo "tools-branch=${tools_branch}" >> ${GITHUB_OUTPUT}
48+
49+
extras_repo="https://github.com/ngagesdk/extras"
50+
extras_branch="main"
51+
echo "extras-repo=${extras_repo}" >> ${GITHUB_OUTPUT}
52+
echo "extras-branch=${extras_branch}" >> ${GITHUB_OUTPUT}
53+
# - name: 'Restore cached ${{ steps.calc.outputs.archive }}'
54+
# id: cache-restore
55+
# uses: actions/cache/restore@v4
56+
# with:
57+
# path: '${{ runner.temp }}'
58+
# key: ${{ steps.calc.outputs.cache-key }}
59+
- name: 'Download N-Gage SDK'
60+
# if: ${{ !steps.cache-restore.outputs.cache-hit || steps.cache-restore.outputs.cache-hit == 'false' }}
61+
shell: pwsh
62+
run: |
63+
64+
Invoke-WebRequest "${{ steps.calc.outputs.toolchain-repo }}/archive/refs/heads/${{ steps.calc.outputs.toolchain-branch }}.zip" -OutFile "${{ runner.temp }}/ngage-toolchain.zip"
65+
Invoke-WebRequest "${{ steps.calc.outputs.sdk-repo }}/archive/refs/heads/${{ steps.calc.outputs.sdk-branch }}.zip" -OutFile "${{ runner.temp }}/sdk.zip"
66+
Invoke-WebRequest "${{ steps.calc.outputs.tools-repo }}/archive/refs/heads/${{ steps.calc.outputs.tools-branch }}.zip" -OutFile "${{ runner.temp }}/tools.zip"
67+
Invoke-WebRequest "${{ steps.calc.outputs.extras-repo }}/archive/refs/heads/${{ steps.calc.outputs.extras-branch }}.zip" -OutFile "${{ runner.temp }}/extras.zip"
68+
69+
# - name: 'Cache ${{ steps.calc.outputs.archive }}'
70+
# if: ${{ !steps.cache-restore.outputs.cache-hit || steps.cache-restore.outputs.cache-hit == 'false' }}
71+
# uses: actions/cache/save@v4
72+
# with:
73+
# path: |
74+
# ${{ runner.temp }}/apps.zip
75+
# ${{ runner.temp }}/sdk.zip
76+
# ${{ runner.temp }}/tools.zip
77+
# key: ${{ steps.calc.outputs.cache-key }}
78+
- name: 'Extract N-Gage SDK'
79+
shell: pwsh
80+
run: |
81+
New-Item -ItemType Directory -Path "${{ steps.calc.outputs.install-path }}" -Force
82+
83+
New-Item -ItemType Directory -Path "${{ runner.temp }}/ngage-toolchain-temp" -Force
84+
7z "-o${{ runner.temp }}/ngage-toolchain-temp" x "${{ runner.temp }}/ngage-toolchain.zip"
85+
Move-Item -Path "${{ runner.temp }}/ngage-toolchain-temp/ngage-toolchain-${{ steps.calc.outputs.toolchain-branch }}/*" -Destination "${{ steps.calc.outputs.install-path }}"
86+
87+
7z "-o${{ steps.calc.outputs.install-path }}/sdk" x "${{ runner.temp }}/sdk.zip"
88+
Move-Item -Path "${{ steps.calc.outputs.install-path }}/sdk/sdk-${{ steps.calc.outputs.sdk-branch }}" -Destination "${{ steps.calc.outputs.install-path }}/sdk/sdk"
89+
90+
7z "-o${{ steps.calc.outputs.install-path }}/sdk" x "${{ runner.temp }}/tools.zip"
91+
Move-Item -Path "${{ steps.calc.outputs.install-path }}/sdk/tools-${{ steps.calc.outputs.tools-branch }}" -Destination "${{ steps.calc.outputs.install-path }}/sdk/tools"
92+
93+
7z "-o${{ steps.calc.outputs.install-path }}/sdk" x "${{ runner.temp }}/extras.zip"
94+
Move-Item -Path "${{ steps.calc.outputs.install-path }}/sdk/extras-${{ steps.calc.outputs.extras-branch }}" -Destination "${{ steps.calc.outputs.install-path }}/sdk/extras"
95+
- name: 'Set output variables'
96+
id: final
97+
shell: sh
98+
run: |
99+
echo "${{ steps.calc.outputs.install-path }}/sdk/sdk/6.1/Shared/EPOC32/gcc/bin" >> $GITHUB_PATH
100+
echo "${{ steps.calc.outputs.install-path }}/sdk/sdk/6.1/Shared/EPOC32/ngagesdk/bin" >> $GITHUB_PATH
101+
echo "NGAGESDK=${{ steps.calc.outputs.install-path }}" >> $GITHUB_ENV
102+
echo "CMAKE_TOOLCHAIN_FILE=${{ steps.calc.outputs.install-path }}/cmake/ngage-toolchain.cmake" >> $GITHUB_ENV

.github/workflows/create-test-plan.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class SdlPlatform(Enum):
5454
Riscos = "riscos"
5555
FreeBSD = "freebsd"
5656
NetBSD = "netbsd"
57+
NGage = "ngage"
5758

5859

5960
class Msys2Platform(Enum):
@@ -139,11 +140,12 @@ class JobSpec:
139140
"riscos": JobSpec(name="RISC OS", os=JobOs.UbuntuLatest, platform=SdlPlatform.Riscos, artifact="SDL-riscos", container="riscosdotinfo/riscos-gccsdk-4.7:latest", ),
140141
"netbsd": JobSpec(name="NetBSD", os=JobOs.UbuntuLatest, platform=SdlPlatform.NetBSD, artifact="SDL-netbsd-x64", ),
141142
"freebsd": JobSpec(name="FreeBSD", os=JobOs.UbuntuLatest, platform=SdlPlatform.FreeBSD, artifact="SDL-freebsd-x64", ),
143+
"ngage": JobSpec(name="N-Gage", os=JobOs.WindowsLatest, platform=SdlPlatform.NGage, artifact="SDL-ngage", ),
142144
}
143145

144146

145147
class StaticLibType(Enum):
146-
MSVC = "SDL3-static.lib"
148+
STATIC_LIB = "SDL3-static.lib"
147149
A = "libSDL3.a"
148150

149151

@@ -223,6 +225,7 @@ class JobDetails:
223225
check_sources: bool = False
224226
setup_python: bool = False
225227
pypi_packages: list[str] = dataclasses.field(default_factory=list)
228+
setup_gage_sdk_path: str = ""
226229

227230
def to_workflow(self, enable_artifacts: bool) -> dict[str, str|bool]:
228231
data = {
@@ -290,6 +293,7 @@ def to_workflow(self, enable_artifacts: bool) -> dict[str, str|bool]:
290293
"check-sources": self.check_sources,
291294
"setup-python": self.setup_python,
292295
"pypi-packages": my_shlex_join(self.pypi_packages),
296+
"setup-ngage-sdk-path": self.setup_gage_sdk_path,
293297
}
294298
return {k: v for k, v in data.items() if v != ""}
295299

@@ -365,7 +369,7 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
365369
job.msvc_project_flags.append("-p:TreatWarningsAsError=true")
366370
job.test_pkg_config = False
367371
job.shared_lib = SharedLibType.WIN32
368-
job.static_lib = StaticLibType.MSVC
372+
job.static_lib = StaticLibType.STATIC_LIB
369373
job.cmake_arguments.extend((
370374
"-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=ProgramDatabase",
371375
"-DCMAKE_EXE_LINKER_FLAGS=-DEBUG",
@@ -740,6 +744,19 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
740744
job.cpactions_arch = "x86-64"
741745
job.cpactions_setup_cmd = "export PATH=\"/usr/pkg/sbin:/usr/pkg/bin:/sbin:$PATH\"; export PKG_CONFIG_PATH=\"/usr/pkg/lib/pkgconfig\";export PKG_PATH=\"https://cdn.netBSD.org/pub/pkgsrc/packages/NetBSD/$(uname -p)/$(uname -r|cut -f \"1 2\" -d.)/All/\";echo \"PKG_PATH=$PKG_PATH\";echo \"uname -a -> \"$(uname -a)\"\";sudo -E sysctl -w security.pax.aslr.enabled=0;sudo -E sysctl -w security.pax.aslr.global=0;sudo -E pkgin clean;sudo -E pkgin update"
742746
job.cpactions_install_cmd = "sudo -E pkgin -y install cmake dbus pkgconf ninja-build pulseaudio libxkbcommon wayland wayland-protocols libinotify libusb1"
747+
case SdlPlatform.NGage:
748+
build_parallel = False
749+
job.cmake_build_type = "Release"
750+
job.setup_ninja = True
751+
job.static_lib = StaticLibType.STATIC_LIB
752+
job.shared_lib = None
753+
job.clang_tidy = False
754+
job.werror = False # FIXME: enable SDL_WERROR
755+
job.shared = False
756+
job.run_tests = False
757+
job.setup_gage_sdk_path = "C:/ngagesdk"
758+
job.cmake_toolchain_file = "C:/ngagesdk/cmake/ngage-toolchain.cmake"
759+
job.test_pkg_config = False
743760
case _:
744761
raise ValueError(f"Unsupported platform={spec.platform}")
745762

.github/workflows/generic.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ jobs:
9393
with:
9494
arch: ${{ matrix.platform.msvc-vcvars-arch }}
9595
sdk: ${{ matrix.platform.msvc-vcvars-sdk }}
96+
- name: 'Set up Nokia N-Gage SDK'
97+
uses: ./.github/actions/setup-ngage-sdk
98+
if: ${{ matrix.platform.setup-ngage-sdk-path != '' }}
99+
with:
100+
path: '${{ matrix.platform.setup-ngage-sdk-path }}'
96101
- name: 'Set up Windows GDK Desktop'
97102
uses: ./.github/actions/setup-gdk-desktop
98103
if: ${{ matrix.platform.setup-gdk-folder != '' }}

CMakeLists.txt

Lines changed: 98 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ include("${SDL3_SOURCE_DIR}/cmake/GetGitRevisionDescription.cmake")
7676
include("${SDL3_SOURCE_DIR}/cmake/3rdparty.cmake")
7777
include("${SDL3_SOURCE_DIR}/cmake/PreseedMSVCCache.cmake")
7878
include("${SDL3_SOURCE_DIR}/cmake/PreseedEmscriptenCache.cmake")
79+
include("${SDL3_SOURCE_DIR}/cmake/PreseedNokiaNGageCache.cmake")
7980

8081
SDL_DetectCompiler()
8182
SDL_DetectTargetCPUArchitectures(SDL_CPUS)
@@ -155,7 +156,7 @@ endif()
155156
# The hidraw support doesn't catch Xbox, PS4 and Nintendo controllers,
156157
# so we'll just use libusb when it's available. libusb does not support iOS,
157158
# so we default to yes on iOS.
158-
if(IOS OR TVOS OR VISIONOS OR WATCHOS OR ANDROID)
159+
if(IOS OR TVOS OR VISIONOS OR WATCHOS OR ANDROID OR NGAGE)
159160
set(SDL_HIDAPI_LIBUSB_AVAILABLE FALSE)
160161
else()
161162
set(SDL_HIDAPI_LIBUSB_AVAILABLE TRUE)
@@ -219,7 +220,7 @@ if(EMSCRIPTEN)
219220
set(SDL_SHARED_AVAILABLE OFF)
220221
endif()
221222

222-
if(VITA OR PSP OR PS2 OR N3DS OR RISCOS)
223+
if(VITA OR PSP OR PS2 OR N3DS OR RISCOS OR NGAGE)
223224
set(SDL_SHARED_AVAILABLE OFF)
224225
endif()
225226

@@ -414,6 +415,24 @@ if(VITA)
414415
set_option(VIDEO_VITA_PVR "Build with PSVita PVR gles/gles2 support" OFF)
415416
endif()
416417

418+
if (NGAGE)
419+
set(SDL_GPU OFF)
420+
set(SDL_CAMERA OFF)
421+
set(SDL_JOYSTICK OFF)
422+
set(SDL_HAPTIC OFF)
423+
set(SDL_HIDAPI OFF)
424+
set(SDL_POWER OFF)
425+
set(SDL_SENSOR OFF)
426+
set(SDL_DIALOG OFF)
427+
set(SDL_DISKAUDIO OFF)
428+
set(SDL_DUMMYAUDIO OFF)
429+
set(SDL_DUMMYCAMERA OFF)
430+
set(SDL_DUMMYVIDEO OFF)
431+
set(SDL_OFFSCREEN OFF)
432+
set(SDL_RENDER_GPU OFF)
433+
set(SDL_VIRTUAL_JOYSTICK OFF)
434+
endif()
435+
417436
if(NOT (SDL_SHARED OR SDL_STATIC))
418437
message(FATAL_ERROR "SDL_SHARED and SDL_STATIC cannot both be disabled")
419438
endif()
@@ -2931,6 +2950,81 @@ elseif(N3DS)
29312950
set(HAVE_SDL_LOCALE TRUE)
29322951

29332952
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/io/n3ds/*.c")
2953+
2954+
elseif(NGAGE)
2955+
2956+
enable_language(CXX)
2957+
2958+
set(SDL_MAIN_USE_CALLBACKS 1)
2959+
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/main/ngage/*.c")
2960+
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/main/ngage/*.cpp")
2961+
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/core/ngage/*.cpp")
2962+
set(HAVE_SDL_MAIN_CALLBACKS TRUE)
2963+
2964+
if(SDL_AUDIO)
2965+
set(SDL_AUDIO_DRIVER_NGAGE 1)
2966+
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/audio/ngage/*.c")
2967+
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/audio/ngage/*.cpp")
2968+
set(HAVE_SDL_AUDIO TRUE)
2969+
endif()
2970+
2971+
set(SDL_FILESYSTEM_NGAGE 1)
2972+
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/filesystem/ngage/*.c")
2973+
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/filesystem/ngage/*.cpp")
2974+
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/filesystem/posix/*.c")
2975+
set(HAVE_SDL_FILESYSTEM TRUE)
2976+
2977+
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/locale/ngage/*.cpp")
2978+
2979+
if(SDL_RENDER)
2980+
set(SDL_VIDEO_RENDER_NGAGE 1)
2981+
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/render/ngage/*.c")
2982+
endif()
2983+
2984+
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/time/ngage/*.cpp")
2985+
set(SDL_TIME_NGAGE 1)
2986+
2987+
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/render/ngage/*.cpp")
2988+
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/time/unix/*.c")
2989+
2990+
set(SDL_TIMER_NGAGE 1)
2991+
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/timer/ngage/*.cpp")
2992+
2993+
set(SDL_FSOPS_POSIX 1)
2994+
2995+
set(SDL_VIDEO_DRIVER_NGAGE 1)
2996+
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/video/ngage/*.c")
2997+
set(HAVE_SDL_TIMERS TRUE)
2998+
2999+
set_option(SDL_LEAN_AND_MEAN "Enable lean and mean" ON)
3000+
if(SDL_LEAN_AND_MEAN)
3001+
sdl_compile_definitions(
3002+
PRIVATE
3003+
SDL_LEAN_AND_MEAN
3004+
)
3005+
endif()
3006+
3007+
sdl_link_dependency(ngage
3008+
LINK_OPTIONS "SHELL:-s MAIN_COMPAT=0"
3009+
PKG_CONFIG_LINK_OPTIONS "-s;MAIN_COMPAT=0"
3010+
LIBS
3011+
NRenderer
3012+
3dtypes
3013+
cone
3014+
libgcc
3015+
libgcc_ngage
3016+
mediaclientaudiostream
3017+
charconv
3018+
bitgdi
3019+
euser
3020+
estlib
3021+
ws32
3022+
hal
3023+
fbscli
3024+
efsrv
3025+
scdv
3026+
gdi
3027+
)
29343028
endif()
29353029

29363030
sdl_sources(${SDL3_SOURCE_DIR}/src/dialog/SDL_dialog.c)
@@ -3111,8 +3205,8 @@ endif()
31113205

31123206
# We always need to have threads and timers around
31133207
if(NOT HAVE_SDL_THREADS)
3114-
# The emscripten platform has been carefully vetted to work without threads
3115-
if(EMSCRIPTEN)
3208+
# The Emscripten and N-Gage platform has been carefully vetted to work without threads
3209+
if(EMSCRIPTEN OR NGAGE)
31163210
set(SDL_THREADS_DISABLED 1)
31173211
sdl_glob_sources("${SDL3_SOURCE_DIR}/src/thread/generic/*.c")
31183212
else()

0 commit comments

Comments
 (0)