From 7969d84257a78dc9ca09e40acf36d1201d8322a4 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sat, 16 Nov 2024 15:01:36 +0100 Subject: [PATCH] ci: nswitch: add autobuilds --- .github/workflows/c-cpp.yml | 35 ++++++++++++++++++++++++++++ tools/buildscripts/nswitch_docker.sh | 32 +++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 tools/buildscripts/nswitch_docker.sh diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index c4a7aa1a1..fc0be5336 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -151,6 +151,41 @@ jobs: path: bin/ retention-days: 0 + build-arm64-switch: + runs-on: ubuntu-latest + steps: + - name: Install host dependencies + run: | + sudo apt-get update + sudo apt-get install git make cmake curl + - name: Install devkitA64 docker image + run: sudo docker pull devkitpro/devkita64:latest + - name: Checkout repository + uses: actions/checkout@v4 + - name: Build pd.arm64.nro + run: sudo docker run --name pd --rm -v `pwd`:`pwd` -w `pwd` devkitpro/devkita64:latest bash ./tools/buildscripts/nswitch_docker.sh build + - name: Build pd.pal.arm64.nro + run: sudo docker run --name pd --rm -v `pwd`:`pwd` -w `pwd` devkitpro/devkita64:latest bash ./tools/buildscripts/nswitch_docker.sh build_pal -DROMID=pal-final + - name: Build pd.jpn.arm64.nro + run: sudo docker run --name pd --rm -v `pwd`:`pwd` -w `pwd` devkitpro/devkita64:latest bash ./tools/buildscripts/nswitch_docker.sh build_jpn -DROMID=jpn-final + - name: Prepare artifact for packaging + run: | + mkdir -p bin/perfectdark/data + mkdir -p bin/perfectdark_pal/data + mkdir -p bin/perfectdark_jpn/data + cp build/pd.arm64.nro bin/ + cp build_pal/pd.pal.arm64.nro bin/ + cp build_jpn/pd.jpn.arm64.nro bin/ + touch bin/perfectdark/data/put_your_rom_here.txt + touch bin/perfectdark_pal/data/put_your_rom_here.txt + touch bin/perfectdark_jpn/data/put_your_rom_here.txt + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: pd-arm64-nswitch + path: bin/ + retention-days: 0 + build-flatpak-bundle: name: "Build flatpak bundle" runs-on: ubuntu-latest diff --git a/tools/buildscripts/nswitch_docker.sh b/tools/buildscripts/nswitch_docker.sh new file mode 100644 index 000000000..ebaeca518 --- /dev/null +++ b/tools/buildscripts/nswitch_docker.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +git config --global --add safe.directory '*' + +echo "Setting up environment..." + +# we can't actually download dkp-toolchain-vars even from here, so +export PORTLIBS_ROOT=${DEVKITPRO}/portlibs +export PATH=${DEVKITPRO}/tools/bin:${DEVKITPRO}/devkitA64/bin:$PATH +export TOOL_PREFIX=aarch64-none-elf- +export CC=${TOOL_PREFIX}gcc +export CXX=${TOOL_PREFIX}g++ +export AR=${TOOL_PREFIX}gcc-ar +export RANLIB=${TOOL_PREFIX}gcc-ranlib +export PORTLIBS_PREFIX=${DEVKITPRO}/portlibs/switch +export PATH=$PORTLIBS_PREFIX/bin:$PATH +export ARCH="-march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIC -ftls-model=local-exec" +export CFLAGS="${ARCH} -O2 -ffunction-sections -fdata-sections" +export CXXFLAGS="${CFLAGS}" +export CPPFLAGS="-D__SWITCH__ -I${PORTLIBS_PREFIX}/include -isystem ${DEVKITPRO}/libnx/include" +export LDFLAGS="${ARCH} -L${PORTLIBS_PREFIX}/lib -L${DEVKITPRO}/libnx/lib" +export LIBS="-lnx" + +echo "Configuring..." + +aarch64-none-elf-cmake -G"Unix Makefiles" -B$1 $2 $3 $4 $5 . || exit 1 + +echo "Building..." + +pushd $1 || exit 1 +make -j4 || exit 1 +popd || exit 1