From 5e2d5d81193e49c445463bb61ed3f814ef3d2572 Mon Sep 17 00:00:00 2001 From: Dextinfire <> Date: Thu, 26 Dec 2024 01:41:58 -0800 Subject: [PATCH] switch with dockerfile --- .github/workflows/docker-switch.yml | 33 ++++++++++++ .github/workflows/pipeline.yml | 84 +++++++++++++++-------------- CMakeLists.txt | 25 +++++---- docker/impacto-switch/Dockerfile | 14 +++++ vcpkg.json | 1 - 5 files changed, 104 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/docker-switch.yml create mode 100644 docker/impacto-switch/Dockerfile diff --git a/.github/workflows/docker-switch.yml b/.github/workflows/docker-switch.yml new file mode 100644 index 00000000..7b0e2a23 --- /dev/null +++ b/.github/workflows/docker-switch.yml @@ -0,0 +1,33 @@ +name: Docker Image CI for GHCR +on: + push: + paths: + - docker/impacto-switch/* + + +jobs: +build_and_publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ghcr.io/committeeofzero/impacto-switch + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + push: true + context: docker/impacto-switch + file: docker/impacto-switch/Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 20f529d1..6a17520f 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -72,10 +72,6 @@ jobs: os_name: macos-x64 triplet: x64-osx-ci host_triplet: x64-osx-ci - - os: ubuntu-latest - os_name: switch - triplet: none - host_triplet: none - os: ubuntu-latest os_name: android triplet: arm64-android-ci @@ -109,19 +105,8 @@ jobs: distribution: "temurin" cache: 'gradle' - - name: Download Switch deps - if: matrix.os_name == 'switch' - uses: blauqs/actions-download-asset@master - with: - repo: MrRevo3D/impacto - version: buildtag - file: devkitpro.tgz - out: /opt - token: ${{ secrets.SWITCH_BUILD_TOKEN }} - - uses: lukka/get-cmake@latest - name: Setup vcpkg - if: matrix.os_name != 'switch' uses: lukka/run-vcpkg@v11 id: runvcpkg with: @@ -136,7 +121,6 @@ jobs: run: brew install nasm if: contains(matrix.os_name, 'macos') - name: Run CMake with vcpkg.json manifest - if: matrix.os_name != 'switch' uses: lukka/run-cmake@v10 with: cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt' @@ -147,27 +131,6 @@ jobs: '-DVCPKG_HOST_TRIPLET=${{ matrix.host_triplet }}', ] buildPreset: ${{ env.PresetName }} - - name: Run Switch build - if: matrix.os_name == 'switch' - run: |- - tar -xzf /opt/devkitpro.tgz -C /opt - export DEVKITPRO=/opt/devkitpro - export DEVKITARM=/opt/devkitpro/devkitARM - export PATH="/opt/devkitpro/tools/bin:$PATH" - cmake -B switch-build -DCMAKE_TOOLCHAIN_FILE=HorizonNX.toolchain - pushd switch-build - make -j2 - elf2nro impacto impacto.nro - mkdir -p "${{ github.workspace }}/release/${{ env.PresetName }}" - cp impacto.nro "${{ github.workspace }}/release/${{ env.PresetName }}" - popd - cp -r profiles "${{ github.workspace }}/release/${{ env.PresetName }}" - cp -r games "${{ github.workspace }}/release/${{ env.PresetName }}" - - name: "switch debug" - if: always() && contains(matrix.os_name, 'switch') - run: |- - nm switch-build/_deps/libatrac9-build/libatrac9.a - tree - name: Copy Shaders run: cp -r src/shaders "${{ github.workspace }}/release/${{ env.PresetName }}" shell: bash @@ -201,7 +164,49 @@ jobs: path: impacto-${{ matrix.os_name }}-${{ vars.VERSION }}${{ github.run_number }}-${{ github.sha }}.zip name: release-${{ matrix.os_name }} - + switch: + runs-on: + timeout-minutes: 120 + needs: lint + permissions: + contents: read + packages: read + container: + image: ghcr.io/committeeofzero/impacto-switch:latest + credentials: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ needs.lint.outputs.commitid }} + - name: Run build + run: |- + cmake -B switch-build -DCMAKE_TOOLCHAIN_FILE=HorizonNX.toolchain + pushd switch-build + make -j2 + elf2nro impacto impacto.nro + mkdir -p "${{ github.workspace }}/release/ci-release" + cp impacto.nro "${{ github.workspace }}/release/ci-release" + popd + cp -r profiles "${{ github.workspace }}/release/ci-release" + cp -r games "${{ github.workspace }}/release/ci-release" + - name: Copy Shaders + run: cp -r src/shaders "${{ github.workspace }}/release/${{ env.PresetName }}" + shell: bash + - name: Copy docs + run: | + cp THIRDPARTY.md README.md LICENSE "${{ github.workspace }}/release/${{ env.PresetName }}" + shell: bash + - name: Archive Artifacts + run: | + 7z u impacto-switch-${{ vars.VERSION }}${{ github.run_number }}-${{ github.sha }}.zip release/ci-release/* + - name: Upload Artifact + uses: actions/upload-artifact@v4.1.0 + with: + path: impacto-switch-${{ vars.VERSION }}${{ github.run_number }}-${{ github.sha }}.zip + name: release-switch + publish_artifacts: name: Publish Artifacts runs-on: ubuntu-22.04 @@ -209,7 +214,8 @@ jobs: contents: write needs: - job-matrix - if: needs.job-matrix.result == 'success' && github.event_name != 'pull_request_target' && ((startsWith(github.ref, 'refs/tags') || github.ref_name == 'master')) + - switch + if: needs.job-matrix.result == 'success' && needs.switch.result == 'success' && github.event_name != 'pull_request_target' && ((startsWith(github.ref, 'refs/tags') || github.ref_name == 'master')) steps: - uses: actions/download-artifact@v4 with: diff --git a/CMakeLists.txt b/CMakeLists.txt index 41ad9c26..70d50150 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -691,6 +691,15 @@ if(ANDROID OR NX) endif() # dependencies +FetchContent_Declare( + glm + GIT_REPOSITORY https://github.com/g-truc/glm.git + GIT_TAG "1.0.1" + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vendor/glm + SYSTEM + EXCLUDE_FROM_ALL +) + FetchContent_Declare( libatrac9 GIT_TAG "master" @@ -729,6 +738,7 @@ FetchContent_Declare( ) FetchContent_MakeAvailable(fmt) +FetchContent_MakeAvailable(glm) FetchContent_MakeAvailable(pugixml) FetchContent_MakeAvailable(utf8cpp) FetchContent_MakeAvailable(libatrac9) @@ -762,8 +772,6 @@ if (WIN32) set(SDL2_LIBRARIES SDL2::SDL2 SDL2::SDL2main) endif () -find_package(glm REQUIRED) - if (NOT NX) # avoid CMAKE_DL_LIBS for NX set(Impacto_Libs ${CMAKE_DL_LIBS} @@ -853,7 +861,7 @@ else () if (NX) list(APPEND Impacto_Libs ${SDL2_LIBRARIES} - glm + glm::glm ZLIB::ZLIB vorbisfile vorbis @@ -880,18 +888,9 @@ else () ZLIB::ZLIB ${OGGVORBIS_LIBRARIES} ${WebP_LIBRARIES} + glm::glm ) - if (VCPKG_TOOLCHAIN) - list(APPEND Impacto_Libs - glm::glm - ) - elseif (NOT APPLE) # If we don't do this it decides to link glm as a library on macOS for some reason - list(APPEND Impacto_Libs - glm - ) - endif () - add_definitions(-DIMPACTO_OPENAL_HAVE_ALEXT) endif () endif () diff --git a/docker/impacto-switch/Dockerfile b/docker/impacto-switch/Dockerfile new file mode 100644 index 00000000..2c2eee22 --- /dev/null +++ b/docker/impacto-switch/Dockerfile @@ -0,0 +1,14 @@ +FROM devkitpro/toolchain-base + +LABEL org.committeeofzero.impacto-switch https://github.com/committeeofzero/impacto + +RUN dkp-pacman -Syyu --noconfirm && \ + dkp-pacman -S --needed --noconfirm switch-dev && \ + dkp-pacman -S --needed --noconfirm switch-portlibs && \ + dkp-pacman -S --needed --noconfirm switch-openal-soft && \ + dkp-pacman -S --needed --noconfirm switch-webp && \ + dkp-pacman -S --needed --noconfirm switch-sdl2 && \ + dkp-pacman -S --needed --noconfirm switch-mesa && \ + dkp-pacman -S --needed --noconfirm switch-ffmpeg && \ + dkp-pacman -S --needed --noconfirm switch-libvorbis && \ + yes | dkp-pacman -Scc \ No newline at end of file diff --git a/vcpkg.json b/vcpkg.json index b7a46ac4..9732711a 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -15,7 +15,6 @@ "libogg", "libvorbis", "zlib", - "glm", "avcpp", "libwebp" ]