From d6bfcc4800bb8b3c3e9edd46f381a08d6c1c1c88 Mon Sep 17 00:00:00 2001 From: Rigs Date: Thu, 13 Aug 2026 00:53:34 -0400 Subject: [PATCH 1/3] Add support for VCPKG on Switch builds: - Create custom port overlays to use precompiled pkgs when necessary Co-authored-by: Dextinfire <> --- .github/workflows/impacto.yml | 40 +++++--- CMakeLists.txt | 92 ++++++------------- CMakePresets.json | 22 +++++ HorizonNX.toolchain | 8 +- README.md | 2 + doc/switch_build.md | 55 +++++++++++ portfiles-switch/README.md | 50 ++++++++++ portfiles-switch/ffmpeg/FFMPEGConfig.cmake | 13 +++ portfiles-switch/ffmpeg/portfile.cmake | 4 + portfiles-switch/ffmpeg/vcpkg.json | 14 +++ portfiles-switch/libass/portfile.cmake | 1 + portfiles-switch/libass/vcpkg.json | 5 + portfiles-switch/libogg/OggConfig.cmake | 7 ++ portfiles-switch/libogg/portfile.cmake | 4 + portfiles-switch/libogg/vcpkg.json | 5 + portfiles-switch/libvorbis/VorbisConfig.cmake | 13 +++ portfiles-switch/libvorbis/portfile.cmake | 4 + portfiles-switch/libvorbis/vcpkg.json | 8 ++ portfiles-switch/libwebp/WebPConfig.cmake | 27 ++++++ portfiles-switch/libwebp/portfile.cmake | 4 + portfiles-switch/libwebp/vcpkg.json | 5 + portfiles-switch/openal-soft/portfile.cmake | 1 + portfiles-switch/openal-soft/vcpkg.json | 5 + portfiles-switch/sdl2/portfile.cmake | 1 + portfiles-switch/sdl2/vcpkg.json | 10 ++ portfiles-switch/vulkan/portfile.cmake | 1 + portfiles-switch/vulkan/vcpkg.json | 5 + portfiles-switch/zlib/portfile.cmake | 1 + portfiles-switch/zlib/vcpkg.json | 5 + triplets/arm64-switch.cmake | 9 ++ 30 files changed, 341 insertions(+), 80 deletions(-) create mode 100644 doc/switch_build.md create mode 100644 portfiles-switch/README.md create mode 100644 portfiles-switch/ffmpeg/FFMPEGConfig.cmake create mode 100644 portfiles-switch/ffmpeg/portfile.cmake create mode 100644 portfiles-switch/ffmpeg/vcpkg.json create mode 100644 portfiles-switch/libass/portfile.cmake create mode 100644 portfiles-switch/libass/vcpkg.json create mode 100644 portfiles-switch/libogg/OggConfig.cmake create mode 100644 portfiles-switch/libogg/portfile.cmake create mode 100644 portfiles-switch/libogg/vcpkg.json create mode 100644 portfiles-switch/libvorbis/VorbisConfig.cmake create mode 100644 portfiles-switch/libvorbis/portfile.cmake create mode 100644 portfiles-switch/libvorbis/vcpkg.json create mode 100644 portfiles-switch/libwebp/WebPConfig.cmake create mode 100644 portfiles-switch/libwebp/portfile.cmake create mode 100644 portfiles-switch/libwebp/vcpkg.json create mode 100644 portfiles-switch/openal-soft/portfile.cmake create mode 100644 portfiles-switch/openal-soft/vcpkg.json create mode 100644 portfiles-switch/sdl2/portfile.cmake create mode 100644 portfiles-switch/sdl2/vcpkg.json create mode 100644 portfiles-switch/vulkan/portfile.cmake create mode 100644 portfiles-switch/vulkan/vcpkg.json create mode 100644 portfiles-switch/zlib/portfile.cmake create mode 100644 portfiles-switch/zlib/vcpkg.json create mode 100644 triplets/arm64-switch.cmake diff --git a/.github/workflows/impacto.yml b/.github/workflows/impacto.yml index a220df0ec..47c68da2d 100644 --- a/.github/workflows/impacto.yml +++ b/.github/workflows/impacto.yml @@ -228,29 +228,43 @@ jobs: image: ghcr.io/committeeofzero/impacto-switch:latest env: VERSION: ${{ needs.get-version.outputs.VERSION }} + PresetName: ci-release-switch + vcpkgCommitId: '62159a45e18f3a9ac0548628dcaf74fcb60c6ff9' steps: - uses: actions/checkout@v6 with: ref: ${{ needs.lint.outputs.commitid }} - - name: Run build - run: |- - cmake . -DCMAKE_TOOLCHAIN_FILE=HorizonNX.toolchain - make -j2 - elf2nro impacto impacto.nro - mkdir -p "release/ci-release" - cp impacto.nro "release/ci-release" - cp -r profiles "release/ci-release" - cp -r resources "release/ci-release" - - name: Copy Shaders - run: cp -r src/shaders "release/ci-release" + + - uses: lukka/get-cmake@latest + + - name: Setup vcpkg + uses: lukka/run-vcpkg@v11 + id: runvcpkg + with: + vcpkgDirectory: '${{ runner.workspace }}/build/vcpkg' + vcpkgGitCommitId: '${{ env.vcpkgCommitId }}' + vcpkgJsonGlob: '**/vcpkg.json' + + - name: Run CMake with vcpkg.json manifest + uses: lukka/run-cmake@v10 + with: + cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt' + configurePreset: ${{ env.PresetName }} + buildPreset: ${{ env.PresetName }} + + - name: Package NRO + run: | + elf2nro "release/${{ env.PresetName }}/impacto" "release/${{ env.PresetName }}/impacto.nro" shell: bash + - name: Copy docs run: | - cp THIRDPARTY.md README.md LICENSE "release/ci-release" + cp THIRDPARTY.md README.md LICENSE "release/${{ env.PresetName }}" shell: bash + - name: Archive Artifacts run: | - mv ./release/ci-release ./release/impacto + mv ./release/${{ env.PresetName }} ./release/impacto 7z a -tzip -mm=Deflate -mx=9 impacto-switch-${{ env.VERSION }}${{ github.run_number }}-${{ github.sha }}.zip ./release/impacto - name: Upload Artifact uses: actions/upload-artifact@v7 diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f5890eed..1e29779e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -833,6 +833,10 @@ endif() if(NX) add_compile_definitions(__SWITCH__) + + if (VCPKG_TOOLCHAIN) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH) + endif() endif() # dependencies @@ -1127,40 +1131,29 @@ else () "$" "$,SDL2::SDL2,SDL2::SDL2-static>" ) + find_package(Ogg CONFIG REQUIRED) + find_package(Vorbis CONFIG REQUIRED) + find_package(WebP CONFIG REQUIRED) + + list(APPEND Impacto_Libs + ${SDL2_LIBRARIES} + ZLIB::ZLIB + WebP::webp WebP::webpdecoder WebP::webpdemux + Ogg::ogg + Vorbis::vorbis + Vorbis::vorbisfile + ) + if (NX) - pkg_check_modules(ogg REQUIRED IMPORTED_TARGET ogg) - pkg_check_modules(vorbis REQUIRED IMPORTED_TARGET vorbis) - pkg_check_modules(vorbisfile REQUIRED IMPORTED_TARGET vorbisfile) - pkg_check_modules(libwebp REQUIRED IMPORTED_TARGET libwebp) list(APPEND Impacto_Libs - ${SDL2_LIBRARIES} - ZLIB::ZLIB - PkgConfig::vorbisfile - PkgConfig::vorbis - PkgConfig::ogg - PkgConfig::libwebp EGL glapi drm_nouveau nx ) - add_definitions(-DIMPACTO_OPENAL_HAVE_ALEXT) - else () - find_package(Ogg CONFIG REQUIRED) - find_package(Vorbis CONFIG REQUIRED) - find_package(WebP CONFIG REQUIRED) - - list(APPEND Impacto_Libs - ${SDL2_LIBRARIES} - ZLIB::ZLIB - WebP::webp WebP::webpdecoder WebP::webpdemux - Ogg::ogg - Vorbis::vorbis - Vorbis::vorbisfile - ) - - add_definitions(-DIMPACTO_OPENAL_HAVE_ALEXT) endif () + + add_definitions(-DIMPACTO_OPENAL_HAVE_ALEXT) endif () list(APPEND Impacto_Include_Dirs ${SDL2_INCLUDE_DIRS}) @@ -1295,48 +1288,17 @@ if (NOT DEFINED IMPACTO_DISABLE_FFMPEG) src/subtitle/ffmpegsubtitlehelper.h ) - if (NOT VCPKG_TOOLCHAIN) - if(NOT BUILD_SHARED_LIBS) - set(AV_ENABLE_SHARED OFF CACHE BOOL "Enable shared library build (Off)" FORCE) - endif() - set(AV_DISABLE_AVDEVICE ON CACHE INTERNAL "Disable FFMPEG AVDevice") - set(AV_DISABLE_AVFILTER ON CACHE INTERNAL "Disable FFMPEG AVFilter") - set(AV_BUILD_EXAMPLES OFF CACHE INTERNAL "Build AVCPP Examples") - FetchContent_Declare( - avcpp - GIT_REPOSITORY "https://github.com/h4tr3d/avcpp" - GIT_TAG "6bf8c76b120cf2cc448d706ea22f112017803605" - SYSTEM - GIT_SUBMODULES "" - PATCH_COMMAND ${AVCPP_PATCH} - UPDATE_DISCONNECTED 1 - ) - - FetchContent_MakeAvailable(avcpp) - pkg_check_modules(FFmpeg REQUIRED IMPORTED_TARGET - libavcodec - libavutil - libswscale - libswresample - libavformat - ) - list(APPEND Impacto_Libs - avcpp - PkgConfig::FFmpeg - ) - else () - find_package(FFMPEG REQUIRED) - list(APPEND Impacto_Include_Dirs ${FFMPEG_INCLUDE_DIRS}) - list(APPEND Impacto_Libs ${FFMPEG_LIBRARIES}) + find_package(FFMPEG REQUIRED) + list(APPEND Impacto_Include_Dirs ${FFMPEG_INCLUDE_DIRS}) + list(APPEND Impacto_Libs ${FFMPEG_LIBRARIES}) - find_package(avcpp CONFIG REQUIRED) - list(APPEND Impacto_Libs - avcpp::avcpp - avcpp::FFmpeg - ) + find_package(avcpp CONFIG REQUIRED) + list(APPEND Impacto_Libs + avcpp::avcpp + avcpp::FFmpeg + ) - endif () list(APPEND Impacto_Include_Dirs ${FFMPEG_INCLUDE_DIRS}) list(APPEND Impacto_Libs ${FFMPEG_LIBRARIES}) pkg_check_modules(dav1d REQUIRED IMPORTED_TARGET dav1d) diff --git a/CMakePresets.json b/CMakePresets.json index 3671b1fe2..c3c3d833d 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -75,6 +75,20 @@ "ANDROID_ABI": "arm64-v8a", "ANDROID_STL": "c++_static" } + }, + { + "name": "ci-release-switch", + "description": "Nintendo Switch (Horizon/devkitPro) Release build for CI, via vcpkg", + "hidden": false, + "inherits": [ + "ci-release" + ], + "cacheVariables": { + "VCPKG_TARGET_TRIPLET": "arm64-switch", + "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/HorizonNX.toolchain", + "VCPKG_OVERLAY_PORTS": "${sourceDir}/portfiles-switch;${sourceDir}/portfiles", + "IMPACTO_WARNINGS": "OFF" + } } ], "buildPresets": [ @@ -94,6 +108,14 @@ "install" ] }, + { + "name": "ci-release-switch", + "description": "Nintendo Switch Release", + "configurePreset": "ci-release-switch", + "targets": [ + "install" + ] + }, { "name": "x64-Release", "description": "x64 Release with Debug Symbols", diff --git a/HorizonNX.toolchain b/HorizonNX.toolchain index a5be9c1ca..5b5f79e1c 100644 --- a/HorizonNX.toolchain +++ b/HorizonNX.toolchain @@ -28,13 +28,17 @@ else() endif() set(PKG_CONFIG_EXECUTABLE "${DEVKITPRO}/portlibs/switch/bin/aarch64-none-elf-pkg-config" CACHE STRING "") +set(ENV{PKG_CONFIG_PATH} "") +set(ENV{PKG_CONFIG_LIBDIR} "${DEVKITPRO}/portlibs/switch/lib/pkgconfig") +set(ENV{PKG_CONFIG_SYSROOT_DIR} "${DEVKITPRO}/portlibs/switch") + set(CMAKE_C_FLAGS "${CPPFLAGS} -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIC -ffunction-sections" CACHE STRING "C flags") set(CMAKE_CXX_FLAGS "${CPPFLAGS} ${CMAKE_C_FLAGS}" CACHE STRING "C++ flags") if(WITH_PORTLIBS) - set(CMAKE_FIND_ROOT_PATH ${DEVKITPRO}/devkitA64 ${DEVKITPRO} ${DEVKITPRO}/libnx ${DEVKITPRO}/portlibs/switch) + list(APPEND CMAKE_FIND_ROOT_PATH ${DEVKITPRO}/devkitA64 ${DEVKITPRO} ${DEVKITPRO}/libnx ${DEVKITPRO}/portlibs/switch) else() - set(CMAKE_FIND_ROOT_PATH ${DEVKITPRO}/devkitA64 ${DEVKITPRO}/libnx ${DEVKITPRO}) + list(APPEND CMAKE_FIND_ROOT_PATH ${DEVKITPRO}/devkitA64 ${DEVKITPRO}/libnx ${DEVKITPRO}) endif() set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) diff --git a/README.md b/README.md index 3dae3d4ca..e43d9f88b 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ For building on Windows with Visual Studio 2019 or newer, please refer to the [b For building on Linux, see the [instructions for Ubuntu Desktop](doc/ubuntu_build.md) and adapt to your distribution if necessary. +For building for the Nintendo Switch (Horizon / devkitPro), see the [Switch build instructions](doc/switch_build.md). + More platforms and toolchains are known to work. ## Contributing diff --git a/doc/switch_build.md b/doc/switch_build.md new file mode 100644 index 000000000..b8deae3a1 --- /dev/null +++ b/doc/switch_build.md @@ -0,0 +1,55 @@ +# Building for Nintendo Switch (Horizon / devkitPro) + +The Switch build is driven by **vcpkg**, like every other platform. Dependencies that +vcpkg builds from source on the desktop platforms (today: `fmt`) are built the same +way here, cross-compiled with the devkitPro toolchain. Dependencies that the +**devkitPro portlibs** already provide as system packages (SDL2, zlib, libogg, +libvorbis, libwebp, libass, ffmpeg, OpenAL) are instead shipped as *overlay ports* +under [`../portfiles-switch/`](../portfiles-switch): vcpkg builds no library binaries +for them and CMake resolves the copy already provided by devkitPro. For libraries +devkitPro ships without a CMake config (libogg, libvorbis, libwebp) the overlay +installs a tiny `*Config.cmake` wrapper around the devkitPro pkg-config, so impacto +uses the same `find_package(... CONFIG)` interface and imported targets on every +platform. `avcpp` sits on top of the system ffmpeg, so it stays on impacto's +`FetchContent` + pkg-config path and is overlaid empty as well. See the +[overlay README](../portfiles-switch/README.md) and + +for the technique. + +## Prerequisites + +* **devkitPro** with the devkitA64 toolchain, `libnx`, and the Switch portlibs + (`switch-dev` group plus `switch-sdl2`, `switch-zlib`, `switch-libogg`, + `switch-libvorbis`, `switch-libwebp`, `switch-ffmpeg`, `switch-dav1d`, + `switch-libass`, and OpenAL). Install with `dkp-pacman`. +* The `DEVKITPRO` environment variable pointing at your devkitPro install + (e.g. `/opt/devkitpro`). +* A **vcpkg** checkout, with the `VCPKG_ROOT` environment variable pointing at it. +* **CMake** ≥ 3.28 and **Ninja**. + +## Building + +From the repository root: + +```bash +cmake --preset ci-release-switch +cmake --build --preset ci-release-switch +``` + +This configures with the vcpkg toolchain, the `arm64-switch` triplet (which +chainloads `HorizonNX.toolchain`), and the Switch overlay ports, then builds and +runs the `install` step. The staged build — the `impacto` ELF plus `shaders`, +`profiles`, `games`, and the `*.lua` config files — lands in +`release/ci-release-switch/`. + +## Producing an NRO + +Wrap the installed ELF for distribution: + +```bash +elf2nro release/ci-release-switch/impacto release/ci-release-switch/impacto.nro +``` + +The `switch` job in [`../.github/workflows/impacto.yml`](../.github/workflows/impacto.yml) +runs exactly these steps inside the `ghcr.io/committeeofzero/impacto-switch` +container. diff --git a/portfiles-switch/README.md b/portfiles-switch/README.md new file mode 100644 index 000000000..bfc943c83 --- /dev/null +++ b/portfiles-switch/README.md @@ -0,0 +1,50 @@ +# Switch (Horizon / devkitPro) overlay ports + +These overlay ports are used only by the `arm64-switch` triplet (via the +`ci-release-switch` CMake preset, which prepends this directory to +`VCPKG_OVERLAY_PORTS`). They shadow the upstream ports only for the Switch build, so +desktop/mobile builds keep using the real upstream ports. + +Their job is to satisfy impacto's `vcpkg.json` dependency graph *without* vcpkg +rebuilding libraries that devkitPro already provides — the technique from +. +Non-system dependencies (e.g. `fmt`) are **not** overlaid; vcpkg builds those from +source for the Switch triplet just like on desktop. + +The overlays come in two flavours. + +## 1. Pass-through overlays + +`portfile.cmake` is just `set(VCPKG_POLICY_EMPTY_PACKAGE enabled)` — vcpkg installs +nothing and CMake's existing lookup already finds the devkitPro copy: + +| Port | Resolved by | +|---------------|---------------------------------------------------------| +| `sdl2` | `find_package(SDL2 CONFIG)` → devkitPro `SDL2Config.cmake` | +| `zlib` | `find_package(ZLIB)` (CMake module) → devkitPro | +| `openal-soft` | `find_package(OpenAL)` (CMake module) → devkitPro | +| `libass` | `pkg_check_modules(libass)` in impacto's CMakeLists | +| `ffmpeg` | `pkg_check_modules(libav*)` in impacto's ffmpeg branch (dav1d likewise, from devkitPro `switch-dav1d`) | +| `avcpp` | impacto's `FetchContent` (it rides on the system ffmpeg) | +| `vulkan` | unused on Switch (`IMPACTO_DISABLE_VULKAN`) | + +## 2. Config-emitting overlays + +devkitPro ships these libraries with `.pc` files but **no CMake package config**, so a +pass-through overlay would force impacto to keep a Switch-specific `pkg_check_modules` +branch. Instead, each `portfile.cmake` installs a small `*Config.cmake` wrapper (still +`VCPKG_POLICY_EMPTY_PACKAGE`, no binaries) that locates the devkitPro library via +pkg-config and re-exports it as the **same imported targets the other platforms use**: + +| Port | Config installed | Targets provided | +|-------------|-------------------|----------------------------------------------------| +| `libogg` | `share/ogg/OggConfig.cmake` | `Ogg::ogg` | +| `libvorbis` | `share/vorbis/VorbisConfig.cmake` | `Vorbis::vorbis`, `Vorbis::vorbisfile` | +| `libwebp` | `share/webp/WebPConfig.cmake` | `WebP::webp`, `WebP::webpdecoder`, `WebP::webpdemux` | + +This is what lets impacto's `CMakeLists.txt` call `find_package(Ogg CONFIG)` / +`find_package(Vorbis CONFIG)` / `find_package(WebP CONFIG)` and link `Ogg::ogg`, +`Vorbis::vorbis`, etc. on **every** platform, with no `if(NX)` dependency branch. The +only Switch-specific link libraries left in the CMakeLists are the libnx windowing / +GPU driver libs (`EGL`, `glapi`, `drm_nouveau`, `nx`), which are not vcpkg-managed +dependencies. diff --git a/portfiles-switch/ffmpeg/FFMPEGConfig.cmake b/portfiles-switch/ffmpeg/FFMPEGConfig.cmake new file mode 100644 index 000000000..6021589e2 --- /dev/null +++ b/portfiles-switch/ffmpeg/FFMPEGConfig.cmake @@ -0,0 +1,13 @@ +find_package(PkgConfig REQUIRED) + +if(NOT TARGET FFMPEG) + pkg_check_modules(_switch_ffmpeg REQUIRED IMPORTED_TARGET + libavcodec + libavutil + libswscale + libswresample + libavformat + ) + add_library(FFMPEG INTERFACE IMPORTED) + set_property(TARGET FFMPEG PROPERTY INTERFACE_LINK_LIBRARIES PkgConfig::_switch_ffmpeg) +endif() \ No newline at end of file diff --git a/portfiles-switch/ffmpeg/portfile.cmake b/portfiles-switch/ffmpeg/portfile.cmake new file mode 100644 index 000000000..3d863b1ba --- /dev/null +++ b/portfiles-switch/ffmpeg/portfile.cmake @@ -0,0 +1,4 @@ +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/FFMPEGConfig.cmake" + DESTINATION "${CURRENT_PACKAGES_DIR}/share/ffmpeg") + +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/portfiles-switch/ffmpeg/vcpkg.json b/portfiles-switch/ffmpeg/vcpkg.json new file mode 100644 index 000000000..816b3c959 --- /dev/null +++ b/portfiles-switch/ffmpeg/vcpkg.json @@ -0,0 +1,14 @@ +{ + "name": "ffmpeg", + "version": "7.1.2", + "description": "Empty overlay for the Switch build: FFmpeg is provided by the devkitPro switch-ffmpeg portlib (libav* resolved via pkg-config).", + "features": { + "avcodec": { "description": "No-op overlay feature; provided by devkitPro switch-ffmpeg." }, + "avformat": { "description": "No-op overlay feature; provided by devkitPro switch-ffmpeg." }, + "swresample": { "description": "No-op overlay feature; provided by devkitPro switch-ffmpeg." }, + "swscale": { "description": "No-op overlay feature; provided by devkitPro switch-ffmpeg." }, + "dav1d": { "description": "No-op overlay feature; dav1d is provided by the devkitPro switch-dav1d portlib." }, + "zlib": { "description": "No-op overlay feature; provided by devkitPro switch-ffmpeg." }, + "vaapi": { "description": "No-op overlay feature (Linux-only in the manifest; never selected on Switch)." } + } +} diff --git a/portfiles-switch/libass/portfile.cmake b/portfiles-switch/libass/portfile.cmake new file mode 100644 index 000000000..065116c27 --- /dev/null +++ b/portfiles-switch/libass/portfile.cmake @@ -0,0 +1 @@ +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/portfiles-switch/libass/vcpkg.json b/portfiles-switch/libass/vcpkg.json new file mode 100644 index 000000000..69881fd92 --- /dev/null +++ b/portfiles-switch/libass/vcpkg.json @@ -0,0 +1,5 @@ +{ + "name": "libass", + "version": "0.17.3", + "description": "Empty overlay for the Switch build: libass is provided by the devkitPro switch-libass portlib." +} diff --git a/portfiles-switch/libogg/OggConfig.cmake b/portfiles-switch/libogg/OggConfig.cmake new file mode 100644 index 000000000..31776342a --- /dev/null +++ b/portfiles-switch/libogg/OggConfig.cmake @@ -0,0 +1,7 @@ +if(NOT TARGET Ogg::ogg) + find_package(PkgConfig REQUIRED) + pkg_check_modules(_switch_ogg REQUIRED IMPORTED_TARGET ogg) + + add_library(Ogg::ogg INTERFACE IMPORTED) + set_property(TARGET Ogg::ogg PROPERTY INTERFACE_LINK_LIBRARIES PkgConfig::_switch_ogg) +endif() diff --git a/portfiles-switch/libogg/portfile.cmake b/portfiles-switch/libogg/portfile.cmake new file mode 100644 index 000000000..01d5984d3 --- /dev/null +++ b/portfiles-switch/libogg/portfile.cmake @@ -0,0 +1,4 @@ +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/OggConfig.cmake" + DESTINATION "${CURRENT_PACKAGES_DIR}/share/ogg") + +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/portfiles-switch/libogg/vcpkg.json b/portfiles-switch/libogg/vcpkg.json new file mode 100644 index 000000000..af91ee277 --- /dev/null +++ b/portfiles-switch/libogg/vcpkg.json @@ -0,0 +1,5 @@ +{ + "name": "libogg", + "version": "1.3.5", + "description": "Empty overlay for the Switch build: libogg is provided by the devkitPro switch-libogg portlib." +} diff --git a/portfiles-switch/libvorbis/VorbisConfig.cmake b/portfiles-switch/libvorbis/VorbisConfig.cmake new file mode 100644 index 000000000..428a7049a --- /dev/null +++ b/portfiles-switch/libvorbis/VorbisConfig.cmake @@ -0,0 +1,13 @@ +find_package(PkgConfig REQUIRED) + +if(NOT TARGET Vorbis::vorbis) + pkg_check_modules(_switch_vorbis REQUIRED IMPORTED_TARGET vorbis) + add_library(Vorbis::vorbis INTERFACE IMPORTED) + set_property(TARGET Vorbis::vorbis PROPERTY INTERFACE_LINK_LIBRARIES PkgConfig::_switch_vorbis) +endif() + +if(NOT TARGET Vorbis::vorbisfile) + pkg_check_modules(_switch_vorbisfile REQUIRED IMPORTED_TARGET vorbisfile) + add_library(Vorbis::vorbisfile INTERFACE IMPORTED) + set_property(TARGET Vorbis::vorbisfile PROPERTY INTERFACE_LINK_LIBRARIES PkgConfig::_switch_vorbisfile) +endif() diff --git a/portfiles-switch/libvorbis/portfile.cmake b/portfiles-switch/libvorbis/portfile.cmake new file mode 100644 index 000000000..383394736 --- /dev/null +++ b/portfiles-switch/libvorbis/portfile.cmake @@ -0,0 +1,4 @@ +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/VorbisConfig.cmake" + DESTINATION "${CURRENT_PACKAGES_DIR}/share/vorbis") + +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/portfiles-switch/libvorbis/vcpkg.json b/portfiles-switch/libvorbis/vcpkg.json new file mode 100644 index 000000000..8ef89c7da --- /dev/null +++ b/portfiles-switch/libvorbis/vcpkg.json @@ -0,0 +1,8 @@ +{ + "name": "libvorbis", + "version": "1.3.7", + "description": "Empty overlay for the Switch build: libvorbis is provided by the devkitPro switch-libvorbis portlib.", + "dependencies": [ + "libogg" + ] +} diff --git a/portfiles-switch/libwebp/WebPConfig.cmake b/portfiles-switch/libwebp/WebPConfig.cmake new file mode 100644 index 000000000..2496a7642 --- /dev/null +++ b/portfiles-switch/libwebp/WebPConfig.cmake @@ -0,0 +1,27 @@ +find_package(PkgConfig REQUIRED) + +if(NOT TARGET WebP::webp) + pkg_check_modules(_switch_webp REQUIRED IMPORTED_TARGET libwebp) + add_library(WebP::webp INTERFACE IMPORTED) + set_property(TARGET WebP::webp PROPERTY INTERFACE_LINK_LIBRARIES PkgConfig::_switch_webp) +endif() + +if(NOT TARGET WebP::webpdecoder) + pkg_check_modules(_switch_webpdecoder QUIET IMPORTED_TARGET libwebpdecoder) + add_library(WebP::webpdecoder INTERFACE IMPORTED) + if(TARGET PkgConfig::_switch_webpdecoder) + set_property(TARGET WebP::webpdecoder PROPERTY INTERFACE_LINK_LIBRARIES PkgConfig::_switch_webpdecoder) + else() + set_property(TARGET WebP::webpdecoder PROPERTY INTERFACE_LINK_LIBRARIES WebP::webp) + endif() +endif() + +if(NOT TARGET WebP::webpdemux) + pkg_check_modules(_switch_webpdemux QUIET IMPORTED_TARGET libwebpdemux) + add_library(WebP::webpdemux INTERFACE IMPORTED) + if(TARGET PkgConfig::_switch_webpdemux) + set_property(TARGET WebP::webpdemux PROPERTY INTERFACE_LINK_LIBRARIES PkgConfig::_switch_webpdemux) + else() + set_property(TARGET WebP::webpdemux PROPERTY INTERFACE_LINK_LIBRARIES WebP::webp) + endif() +endif() diff --git a/portfiles-switch/libwebp/portfile.cmake b/portfiles-switch/libwebp/portfile.cmake new file mode 100644 index 000000000..3fe354166 --- /dev/null +++ b/portfiles-switch/libwebp/portfile.cmake @@ -0,0 +1,4 @@ +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/WebPConfig.cmake" + DESTINATION "${CURRENT_PACKAGES_DIR}/share/webp") + +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/portfiles-switch/libwebp/vcpkg.json b/portfiles-switch/libwebp/vcpkg.json new file mode 100644 index 000000000..0bbee2e1d --- /dev/null +++ b/portfiles-switch/libwebp/vcpkg.json @@ -0,0 +1,5 @@ +{ + "name": "libwebp", + "version": "1.4.0", + "description": "Empty overlay for the Switch build: libwebp is provided by the devkitPro switch-libwebp portlib." +} diff --git a/portfiles-switch/openal-soft/portfile.cmake b/portfiles-switch/openal-soft/portfile.cmake new file mode 100644 index 000000000..065116c27 --- /dev/null +++ b/portfiles-switch/openal-soft/portfile.cmake @@ -0,0 +1 @@ +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/portfiles-switch/openal-soft/vcpkg.json b/portfiles-switch/openal-soft/vcpkg.json new file mode 100644 index 000000000..525ffb14b --- /dev/null +++ b/portfiles-switch/openal-soft/vcpkg.json @@ -0,0 +1,5 @@ +{ + "name": "openal-soft", + "version": "1.23.1", + "description": "Empty overlay for the Switch build: OpenAL Soft is provided by devkitPro and resolved via find_package(OpenAL)." +} diff --git a/portfiles-switch/sdl2/portfile.cmake b/portfiles-switch/sdl2/portfile.cmake new file mode 100644 index 000000000..065116c27 --- /dev/null +++ b/portfiles-switch/sdl2/portfile.cmake @@ -0,0 +1 @@ +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/portfiles-switch/sdl2/vcpkg.json b/portfiles-switch/sdl2/vcpkg.json new file mode 100644 index 000000000..c76f2f020 --- /dev/null +++ b/portfiles-switch/sdl2/vcpkg.json @@ -0,0 +1,10 @@ +{ + "name": "sdl2", + "version": "2.32.10", + "description": "Empty overlay for the Switch build: SDL2 is provided by the devkitPro switch-sdl2 portlib.", + "features": { + "vulkan": { + "description": "No-op on Switch (Vulkan is disabled); the devkitPro SDL2 build already provides whatever backends it supports." + } + } +} diff --git a/portfiles-switch/vulkan/portfile.cmake b/portfiles-switch/vulkan/portfile.cmake new file mode 100644 index 000000000..065116c27 --- /dev/null +++ b/portfiles-switch/vulkan/portfile.cmake @@ -0,0 +1 @@ +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/portfiles-switch/vulkan/vcpkg.json b/portfiles-switch/vulkan/vcpkg.json new file mode 100644 index 000000000..0ea2df429 --- /dev/null +++ b/portfiles-switch/vulkan/vcpkg.json @@ -0,0 +1,5 @@ +{ + "name": "vulkan", + "version": "1.1.0", + "description": "Empty overlay for the Switch build: Vulkan is disabled on Switch (IMPACTO_DISABLE_VULKAN), so no Vulkan SDK is needed." +} diff --git a/portfiles-switch/zlib/portfile.cmake b/portfiles-switch/zlib/portfile.cmake new file mode 100644 index 000000000..065116c27 --- /dev/null +++ b/portfiles-switch/zlib/portfile.cmake @@ -0,0 +1 @@ +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/portfiles-switch/zlib/vcpkg.json b/portfiles-switch/zlib/vcpkg.json new file mode 100644 index 000000000..8cb80c65d --- /dev/null +++ b/portfiles-switch/zlib/vcpkg.json @@ -0,0 +1,5 @@ +{ + "name": "zlib", + "version": "1.3.1", + "description": "Empty overlay for the Switch build: zlib is provided by the devkitPro switch-zlib portlib." +} diff --git a/triplets/arm64-switch.cmake b/triplets/arm64-switch.cmake new file mode 100644 index 000000000..a0c24f16f --- /dev/null +++ b/triplets/arm64-switch.cmake @@ -0,0 +1,9 @@ +set(VCPKG_TARGET_ARCHITECTURE arm64) +set(VCPKG_CRT_LINKAGE static) +set(VCPKG_LIBRARY_LINKAGE static) + +set(VCPKG_CMAKE_SYSTEM_NAME Generic) + +set(VCPKG_BUILD_TYPE release) + +set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../HorizonNX.toolchain") From 115d74dc2d35886d59331ab5bad080f192fb5c2b Mon Sep 17 00:00:00 2001 From: Dextinfire <> Date: Thu, 13 Aug 2026 04:01:06 -0700 Subject: [PATCH 2/3] Convert FetchContent to vcpkg --- CMakeLists.txt | 171 +++------------------------------------ THIRDPARTY.md | 1 - src/profile/charset.cpp | 2 +- src/text/text.cpp | 2 +- src/video/ffmpegstream.h | 2 +- src/workqueue.cpp | 2 +- vcpkg.json | 9 ++- 7 files changed, 24 insertions(+), 165 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e29779e8..3936ed5bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -833,21 +833,8 @@ endif() if(NX) add_compile_definitions(__SWITCH__) - - if (VCPKG_TOOLCHAIN) - set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH) - endif() endif() -# dependencies -FetchContent_Declare( - glm - GIT_REPOSITORY https://github.com/g-truc/glm.git - GIT_TAG "1.0.1" - SYSTEM - EXCLUDE_FROM_ALL -) - FetchContent_Declare( libatrac9 GIT_TAG "master" @@ -856,55 +843,6 @@ FetchContent_Declare( SYSTEM EXCLUDE_FROM_ALL ) -if (NOT VCPKG_TOOLCHAIN) - FetchContent_Declare( - fmt - GIT_REPOSITORY "https://github.com/fmtlib/fmt.git" - GIT_TAG "11.1.4" - SYSTEM - EXCLUDE_FROM_ALL - ) -endif () - -FetchContent_Declare( - pugixml - GIT_REPOSITORY "https://github.com/zeux/pugixml.git" - GIT_TAG "v1.14" - SYSTEM - EXCLUDE_FROM_ALL -) - -FetchContent_Declare( - utf8cpp - GIT_REPOSITORY "https://github.com/nemtrif/utfcpp" - GIT_TAG "v4.0.5" - SYSTEM - EXCLUDE_FROM_ALL -) - -FetchContent_Declare( - concurrentqueue - GIT_REPOSITORY "https://github.com/cameron314/concurrentqueue" - GIT_TAG "v1.0.4" - SYSTEM - EXCLUDE_FROM_ALL -) - -FetchContent_Declare( - readerwriterqueue - GIT_REPOSITORY "https://github.com/cameron314/readerwriterqueue" - GIT_TAG "16b48ae1148284e7b40abf72167206a4390a4592" - SYSTEM - EXCLUDE_FROM_ALL -) - -FetchContent_Declare( - unordered_dense - GIT_REPOSITORY "https://github.com/martinus/unordered_dense" - GIT_TAG "v4.5.0" - SYSTEM - EXCLUDE_FROM_ALL -) FetchContent_Declare( magic_enum @@ -914,99 +852,9 @@ FetchContent_Declare( EXCLUDE_FROM_ALL ) -FetchContent_Declare( - boost_core - GIT_TAG "boost-1.91.0" - GIT_REPOSITORY "https://github.com/boostorg/core.git" - SYSTEM - EXCLUDE_FROM_ALL -) - -FetchContent_Declare( - boost_config - GIT_TAG "boost-1.91.0" - GIT_REPOSITORY "https://github.com/boostorg/config.git" - SYSTEM - EXCLUDE_FROM_ALL -) - -FetchContent_Declare( - boost_throwexception - GIT_TAG "boost-1.91.0" - GIT_REPOSITORY "https://github.com/boostorg/throw_exception.git" - SYSTEM - EXCLUDE_FROM_ALL -) - -FetchContent_Declare( - boost_assert - GIT_TAG "boost-1.91.0" - GIT_REPOSITORY "https://github.com/boostorg/assert.git" - SYSTEM - EXCLUDE_FROM_ALL -) - -FetchContent_Declare( - boost_preprocessor - GIT_TAG "boost-1.91.0" - GIT_REPOSITORY "https://github.com/boostorg/preprocessor.git" - SYSTEM - EXCLUDE_FROM_ALL -) - -FetchContent_Declare( - boost_move - GIT_TAG "boost-1.91.0" - GIT_REPOSITORY "https://github.com/boostorg/move.git" - SYSTEM - EXCLUDE_FROM_ALL -) - -FetchContent_Declare( - boost_typetraits - GIT_TAG "boost-1.91.0" - GIT_REPOSITORY "https://github.com/boostorg/type_traits.git" - SYSTEM - EXCLUDE_FROM_ALL -) - -FetchContent_Declare( - boost_conceptcheck - GIT_TAG "boost-1.91.0" - GIT_REPOSITORY "https://github.com/boostorg/concept_check.git" - SYSTEM - EXCLUDE_FROM_ALL -) - -FetchContent_Declare( - boost_circularbuffer - GIT_TAG "boost-1.91.0" - GIT_REPOSITORY "https://github.com/boostorg/circular_buffer.git" - SYSTEM - EXCLUDE_FROM_ALL -) - -if (NOT VCPKG_TOOLCHAIN) - FetchContent_MakeAvailable(fmt) -endif () -FetchContent_MakeAvailable(glm) -FetchContent_MakeAvailable(pugixml) -FetchContent_MakeAvailable(utf8cpp) FetchContent_MakeAvailable(libatrac9) -FetchContent_MakeAvailable(concurrentqueue) -FetchContent_MakeAvailable(readerwriterqueue) -FetchContent_MakeAvailable(unordered_dense) FetchContent_MakeAvailable(magic_enum) -FetchContent_MakeAvailable(boost_core) -FetchContent_MakeAvailable(boost_config) -FetchContent_MakeAvailable(boost_throwexception) -FetchContent_MakeAvailable(boost_assert) -FetchContent_MakeAvailable(boost_preprocessor) -FetchContent_MakeAvailable(boost_move) -FetchContent_MakeAvailable(boost_typetraits) -FetchContent_MakeAvailable(boost_conceptcheck) -FetchContent_MakeAvailable(boost_circularbuffer) if (NOT DEFINED IMPACTO_DISABLE_MMAP) list(APPEND Impacto_Src @@ -1159,20 +1007,25 @@ endif () list(APPEND Impacto_Include_Dirs ${SDL2_INCLUDE_DIRS}) list(APPEND Impacto_Include_Dirs ${WebP_INCLUDE_DIRS}) -if (VCPKG_TOOLCHAIN) - find_package(fmt CONFIG REQUIRED) -endif () -list(APPEND Impacto_Libs fmt::fmt) +find_package(fmt CONFIG REQUIRED) +find_package(glm CONFIG REQUIRED) +find_package(Boost REQUIRED COMPONENTS circular_buffer) +find_package(pugixml CONFIG REQUIRED) +find_package(unordered_dense CONFIG REQUIRED) +find_package(readerwriterqueue CONFIG REQUIRED) +find_package(concurrentqueue CONFIG REQUIRED) +find_package(utf8cpp CONFIG REQUIRED) list(APPEND Impacto_Libs + fmt::fmt pugixml::pugixml atrac9 unordered_dense::unordered_dense magic_enum glm::glm - utf8cpp - concurrentqueue - readerwriterqueue + utf8cpp::utf8cpp + concurrentqueue::concurrentqueue + readerwriterqueue::readerwriterqueue Boost::circular_buffer ) diff --git a/THIRDPARTY.md b/THIRDPARTY.md index a8fdbe924..582b0bd00 100644 --- a/THIRDPARTY.md +++ b/THIRDPARTY.md @@ -17,7 +17,6 @@ * `vendor/imgui`: [Dear ImGui](https://github.com/ocornut/imgui) * `vendor/pcg`: [PCG Random Number Generation, Minimal C Edition](https://github.com/imneme/pcg-c-basic) * `vendor/squish`: [Squish](http://sjbrown.co.uk/?code=squish) -* `vendor/utf8-cpp`: [UTF8-CPP](https://github.com/nemtrif/utfcpp) * `vendor/mspack`: [libmspack](https://www.cabextract.org.uk/libmspack/), only includes LZX decompressor to reduce code size * `vendor/mio`: [mio](https://github.com/vimpunk/mio), except for platforms without mmap support diff --git a/src/profile/charset.cpp b/src/profile/charset.cpp index 368b4c47b..e25d0f4dc 100644 --- a/src/profile/charset.cpp +++ b/src/profile/charset.cpp @@ -2,7 +2,7 @@ #include "profile_internal.h" #include "../text/text.h" -#include +#include namespace Impacto { namespace Profile { diff --git a/src/text/text.cpp b/src/text/text.cpp index e9b77cec1..fe5f2c409 100644 --- a/src/text/text.cpp +++ b/src/text/text.cpp @@ -2,7 +2,7 @@ #include -#include +#include #include "../log.h" #include "../animation.h" diff --git a/src/video/ffmpegstream.h b/src/video/ffmpegstream.h index fbd35a60c..d4460b97b 100644 --- a/src/video/ffmpegstream.h +++ b/src/video/ffmpegstream.h @@ -15,7 +15,7 @@ #if __SWITCH__ #define __unix__ #endif -#include +#include #if __SWITCH__ #undef __unix__ #endif diff --git a/src/workqueue.cpp b/src/workqueue.cpp index a3121103e..00f56fcf8 100644 --- a/src/workqueue.cpp +++ b/src/workqueue.cpp @@ -10,7 +10,7 @@ #if __SWITCH__ #define __unix__ #endif -#include +#include #if __SWITCH__ #undef __unix__ #endif diff --git a/vcpkg.json b/vcpkg.json index b154f3227..42b1bfb48 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -41,7 +41,14 @@ }, "libwebp", "fmt", - "libass" + "libass", + "glm", + "pugixml", + "utfcpp", + "concurrentqueue", + "readerwriterqueue", + "unordered-dense", + "boost-circular-buffer" ], "overrides": [ { From cda46b561807f52206f29a5327a8f660f0eb196b Mon Sep 17 00:00:00 2001 From: Dextinfire <> Date: Thu, 13 Aug 2026 04:25:16 -0700 Subject: [PATCH 3/3] Vcpkg caching for switch --- .github/workflows/impacto.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.github/workflows/impacto.yml b/.github/workflows/impacto.yml index 47c68da2d..6a28962df 100644 --- a/.github/workflows/impacto.yml +++ b/.github/workflows/impacto.yml @@ -224,12 +224,19 @@ jobs: - get-version permissions: contents: read + packages: write container: image: ghcr.io/committeeofzero/impacto-switch:latest env: VERSION: ${{ needs.get-version.outputs.VERSION }} PresetName: ci-release-switch vcpkgCommitId: '62159a45e18f3a9ac0548628dcaf74fcb60c6ff9' + VCPKG_FORCE_DOWNLOADED_BINARIES: 1 + VCPKG_BINARY_SOURCES: >- + ${{ github.event_name == 'pull_request_target' && + (github.event.pull_request.head.repo.full_name != github.repository) + && 'clear;nuget,https://nuget.pkg.github.com/committeeofzero/index.json,read' + || 'clear;nuget,https://nuget.pkg.github.com/committeeofzero/index.json,readwrite' }} steps: - uses: actions/checkout@v6 with: @@ -245,6 +252,29 @@ jobs: vcpkgGitCommitId: '${{ env.vcpkgCommitId }}' vcpkgJsonGlob: '**/vcpkg.json' + - name: Configure NuGet feed via vcpkg + shell: bash + env: + FEED_URL: 'https://nuget.pkg.github.com/committeeofzero/index.json' + run: | + NUGET_PATH=$(vcpkg fetch nuget | tail -n 1) + + if [[ "$NUGET_PATH" == *.exe && "$RUNNER_OS" != "Windows" ]]; then + EXEC=(mono "$NUGET_PATH") + else + EXEC=("$NUGET_PATH") + fi + + "${EXEC[@]}" sources add \ + -Source "${{ env.FEED_URL }}" \ + -StorePasswordInClearText \ + -Name GitHubPackages \ + -UserName "GithubCI" \ + -Password "${{ github.token }}" + + "${EXEC[@]}" setapikey "${{ github.token }}" \ + -Source "${{ env.FEED_URL }}" + - name: Run CMake with vcpkg.json manifest uses: lukka/run-cmake@v10 with: