Skip to content
Merged
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
41 changes: 41 additions & 0 deletions .github/workflows/switch2kit-desktop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Switch2Kit desktop platforms
on:
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: switch2kit-desktop-${{ github.ref }}
cancel-in-progress: true
jobs:
source:
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
- run: git submodule update --init dependencies/Switch2Kit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
repository: libsdl-org/SDL
ref: f87239e71e42da91ca317a12eefb82cfbf3393eb
path: test-sdl
persist-credentials: false
- name: Archive the exact sources used by the controller integration
run: |
mkdir -p "$RUNNER_TEMP/switch2kit-source"
git archive HEAD -o "$RUNNER_TEMP/switch2kit-source/host.zip"
git -C dependencies/Switch2Kit archive HEAD -o "$RUNNER_TEMP/switch2kit-source/sdk.zip"
git -C test-sdl archive HEAD -o "$RUNNER_TEMP/switch2kit-source/sdl.zip"
{
git rev-parse HEAD
git submodule status dependencies/Switch2Kit
git -C test-sdl rev-parse HEAD
} > "$RUNNER_TEMP/switch2kit-source/revisions.txt"
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: Switch2Kit-desktop-source
path: ${{ runner.temp }}/switch2kit-source
retention-days: 7
if-no-files-found: error
77 changes: 77 additions & 0 deletions .github/workflows/switch2kit-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Switch2Kit Linux application
on:
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: switch2kit-linux-${{ github.ref }}
cancel-in-progress: false
jobs:
linux:
runs-on: ubuntu-24.04
container: swift:6.2.1-noble
timeout-minutes: 120
env:
DEBIAN_FRONTEND: noninteractive
VCPKG_MAX_CONCURRENCY: 3
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
submodules: recursive
- name: Install native dependencies
run: |
apt-get update
apt-get install -y --no-install-recommends build-essential cmake ninja-build python3 pkg-config curl zip unzip tar zstd nasm autoconf automake libtool libtool-bin gettext freeglut3-dev libgcrypt20-dev libglm-dev libgtk-3-dev libpulse-dev libsecret-1-dev libsystemd-dev libudev-dev libbluetooth-dev libgl1-mesa-dev libglu1-mesa-dev libx11-xcb-dev libwayland-dev wayland-protocols extra-cmake-modules dbus xvfb xauth openbox wmctrl x11-utils
git config --global --add safe.directory "$PWD"
mkdir -p "$HOME/.cache/vcpkg/archives"
echo "VCPKG_BINARY_SOURCES=clear;files,$HOME/.cache/vcpkg/archives,readwrite" >> "$GITHUB_ENV"
- uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809
with:
path: ~/.cache/vcpkg/archives
key: switch2kit-cemu-linux-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json', 'dependencies/vcpkg_overlay_ports*/**') }}
restore-keys: switch2kit-cemu-linux-
- name: Build and install the controller-enabled application
shell: bash
run: |
set -o pipefail
bash scripts/build-switch2kit.sh 2>&1 | tee linux-build.log
- name: Execute controller policies
shell: bash
run: |
set -o pipefail
python3 tests/switch2kit/run.py --sanitize 2>&1 | tee linux-policies.log
- name: Relocate, resolve native dependencies and launch the installed binary
shell: bash
run: |
set -euo pipefail
mv build-switch2kit/install "$RUNNER_TEMP/Cemu-Switch2Kit-linux-x86_64"
app="$RUNNER_TEMP/Cemu-Switch2Kit-linux-x86_64"
mv build-switch2kit "$RUNNER_TEMP/disabled-build-tree"
test -n "$(find "$app" -name libSwitch2KitC.so -print -quit)"
ldd "$app/bin/Cemu_release" | tee linux-dependencies.log
! grep -q 'not found' linux-dependencies.log
grep -F "$app" linux-dependencies.log | grep libSwitch2KitC
tar -C "$RUNNER_TEMP" -czf Cemu-Switch2Kit-linux-x86_64.tar.gz Cemu-Switch2Kit-linux-x86_64
mv "$app" "$RUNNER_TEMP/unavailable-staged-application"
dbus-run-session -- xvfb-run -a python3 dependencies/Switch2Kit/tests/emulator-launch/linux.py cemu \
"$PWD/Cemu-Switch2Kit-linux-x86_64.tar.gz" --report "$PWD/linux-launch.json" \
--forbidden-root "$PWD" --forbidden-root "$RUNNER_TEMP/disabled-build-tree" \
--forbidden-root "$RUNNER_TEMP/unavailable-staged-application"
- name: Controller-enabled development build
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: Cemu-Switch2Kit-linux-x86_64
path: Cemu-Switch2Kit-linux-x86_64.tar.gz
retention-days: 14
if-no-files-found: error
- name: Native diagnostics
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: Cemu-Switch2Kit-linux-diagnostics
path: |
linux-*.log
linux-launch.json
retention-days: 7
68 changes: 68 additions & 0 deletions .github/workflows/switch2kit-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Switch2Kit Windows application
on:
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: switch2kit-windows-${{ github.ref }}
cancel-in-progress: true
jobs:
windows:
runs-on: windows-2022
timeout-minutes: 120
env:
VCPKG_MAX_CONCURRENCY: 3
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
submodules: recursive
- uses: compnerd/gha-setup-swift@397094e75494a93fa8d81db0268dbc8f5d6cf7c6
with:
swift-version: swift-6.2.1-release
swift-build: 6.2.1-RELEASE
- name: Build the complete controller-enabled application
shell: pwsh
run: |
& ./scripts/build-switch2kit.ps1 2>&1 | Tee-Object windows-build.log
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
# The build helper initialized MSVC in this PowerShell process.
python tests/switch2kit/test_host_file.py 2>&1 | Tee-Object windows-host-file.log
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Stage and launch the application away from the build tree
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$stage = Join-Path $env:RUNNER_TEMP 'Cemu-Switch2Kit-windows-x86_64'
New-Item -ItemType Directory -Path $stage | Out-Null
# Robocopy follows directory junctions and copies linked resources.
robocopy 'bin' $stage /E /NFL /NDL /NJH /NJS
if ($LASTEXITCODE -ge 8) { throw 'Application staging failed.' }
$global:LASTEXITCODE = 0
# Never distribute a developer/test profile. The supervisor seeds only
# its private extracted copy, after the distributable archive is made.
foreach ($profile in @('User', 'user', 'portable', 'portable.txt', 'settings.xml')) {
if (Test-Path (Join-Path $stage $profile)) { throw "Unexpected profile in application staging: $profile" }
}
Move-Item build-switch2kit-windows "$env:RUNNER_TEMP/disabled-build-tree"
Compress-Archive -Path $stage -DestinationPath 'Cemu-Switch2Kit-windows-x86_64.zip'
Move-Item $stage "$env:RUNNER_TEMP/unavailable-staged-application"
& ./tests/switch2kit/windows-launch.ps1 -Archive 'Cemu-Switch2Kit-windows-x86_64.zip' -ForbiddenRoot "$PWD"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Controller-enabled development application
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: Cemu-Switch2Kit-windows-x86_64
path: Cemu-Switch2Kit-windows-x86_64.zip
retention-days: 14
if-no-files-found: error
- name: Native diagnostics
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: Cemu-Switch2Kit-windows-diagnostics
path: |
windows-*.log
windows-launch.json
retention-days: 7
20 changes: 15 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.21.1)

option(ENABLE_VCPKG "Enable the vcpkg package manager" ON)
option(ENABLE_SWITCH2KIT "Use in-process Switch2Kit controllers on macOS 15+" OFF)
option(ENABLE_SWITCH2KIT "Use in-process Switch2Kit controllers" OFF)
set(SWITCH2KIT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/Switch2Kit" CACHE PATH "Switch2Kit source checkout")
option(MACOS_BUNDLE "The executable when built on macOS will be created as an application bundle" OFF)
option(ALLOW_PORTABLE "Allow Cemu to be run in portable mode" ON)
Expand Down Expand Up @@ -173,11 +173,14 @@ if(ENABLE_SDL)
endif()

if(ENABLE_SWITCH2KIT)
if(NOT APPLE OR NOT ENABLE_SDL OR NOT MACOS_BUNDLE)
message(FATAL_ERROR "Switch2Kit requires macOS, ENABLE_SDL and MACOS_BUNDLE")
if(NOT (APPLE OR WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux"))
message(FATAL_ERROR "Switch2Kit requires a macOS, Windows or Linux desktop host")
endif()
if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 15.0)
message(FATAL_ERROR "Switch2Kit requires CMAKE_OSX_DEPLOYMENT_TARGET=15.0 or newer")
if(NOT ENABLE_SDL)
message(FATAL_ERROR "Switch2Kit requires ENABLE_SDL")
endif()
if(APPLE AND (NOT MACOS_BUNDLE OR CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 15.0))
message(FATAL_ERROR "Switch2Kit on macOS requires MACOS_BUNDLE and CMAKE_OSX_DEPLOYMENT_TARGET=15.0 or newer")
endif()
if(NOT EXISTS "${SWITCH2KIT_SOURCE_DIR}/Integrations/SDL3/CMakeLists.txt")
message(FATAL_ERROR "Switch2Kit is missing. Run git submodule update --init --recursive")
Expand Down Expand Up @@ -289,3 +292,10 @@ if (NOT ZArchive_FOUND)
endif()

add_subdirectory(src)

if(ENABLE_SWITCH2KIT AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
include(GNUInstallDirs)
switch2kit_install_linux(CemuBin)
install(TARGETS CemuBin RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(DIRECTORY bin/gameProfiles bin/resources DESTINATION "${CMAKE_INSTALL_DATADIR}/Cemu")
endif()
Loading
Loading