Skip to content

Commit

Permalink
switch with dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Dextinfire committed Dec 26, 2024
1 parent 8625ab2 commit 5e2d5d8
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 53 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/docker-switch.yml
Original file line number Diff line number Diff line change
@@ -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 }}
84 changes: 45 additions & 39 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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'
Expand All @@ -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
Expand Down Expand Up @@ -201,15 +164,58 @@ 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/[email protected]
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
permissions:
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:
Expand Down
25 changes: 12 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -729,6 +738,7 @@ FetchContent_Declare(
)

FetchContent_MakeAvailable(fmt)
FetchContent_MakeAvailable(glm)
FetchContent_MakeAvailable(pugixml)
FetchContent_MakeAvailable(utf8cpp)
FetchContent_MakeAvailable(libatrac9)
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -853,7 +861,7 @@ else ()
if (NX)
list(APPEND Impacto_Libs
${SDL2_LIBRARIES}
glm
glm::glm
ZLIB::ZLIB
vorbisfile
vorbis
Expand All @@ -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 ()
Expand Down
14 changes: 14 additions & 0 deletions docker/impacto-switch/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"libogg",
"libvorbis",
"zlib",
"glm",
"avcpp",
"libwebp"
]
Expand Down

0 comments on commit 5e2d5d8

Please sign in to comment.