diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..5b9f6fd5 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,130 @@ +name: Build Horizon OC Zeus + +on: + push: + branches: [ develop, main, master ] + pull_request: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + # Minimal devkitA64 container, apparently dkp-toolchain isn't needed? + container: + image: devkitpro/devkita64:latest + + steps: + - name: Checkout repository and submodules # why are we doing this? I don't think we use submodules but memory doesn't serve so let's keep it + uses: actions/checkout@v4 + with: + submodules: recursive + + + # ------------------------------------------------- + # Fix PATH for devkitA64 and devkitARM + # ------------------------------------------------- + - name: Set devkitPro PATH + run: | + export DEVKITPRO=/opt/devkitpro + export DEVKITA64=$DEVKITPRO/devkitA64 + export DEVKITARM=$DEVKITPRO/devkitARM + export PATH=$DEVKITA64/bin:$DEVKITARM/bin:$PATH + aarch64-none-elf-gcc --version + arm-none-eabi-gcc --version + shell: bash + + - name: + run: apt install ccache -y + shell: bash + + # ------------------------------------------------- + # Get short commit SHA + # ------------------------------------------------- + - name: Set commit SHA + id: vars + run: echo "SHORT_SHA=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV + + # ------------------------------------------------- + # Clone Atmosphère + # ------------------------------------------------- + - name: Clone Atmosphere + run: git clone https://github.com/Atmosphere-NX/Atmosphere.git atmosphere + + # ------------------------------------------------- + # Clone Horizon OC (develop branch) kinda suspicious for now, shouldn't it just already be cloned on the actions runner? + # ------------------------------------------------- + #- name: Clone Horizon OC + # run: git clone -b develop --single-branch https://github.com/Horizon-OC/Horizon-OC.git horizon-oc + + # ------------------------------------------------- + # Prepare build folder + # ------------------------------------------------- + - name: Prepare build folder + run: | + mkdir -p build + cp -r atmosphere/ build/ + + # ------------------------------------------------- + # Override loader source + # ------------------------------------------------- + - name: Override ldr_process_creation.cpp + run: | + cp -f Source/Atmosphere/stratosphere/loader/source/ldr_process_creation.cpp \ + build/stratosphere/loader/source/ldr_process_creation.cpp + + # ------------------------------------------------- + # Build Horizon OC Zeus (trying ccache, directly invoking make instead, hacky) + # ------------------------------------------------- + #- name: Build Horizon OC Zeus + # working-directory: horizon-oc + # run: | + # chmod +x build.sh + # ./build.sh + - name: Cache ccache + uses: actions/cache@v4 + with: + path: /root/.cache/ccache + key: ccache-${{ runner.os }}-devkitpro-${{ hashFiles('**/Makefile', '**/*.mk') }} + restore-keys: | + ccache-${{ runner.os }}-devkitpro- + + - name: Configure ccache + run: | + export CCACHE_DIR=/root/.cache/ccache + echo "CCACHE_DIR=/root/.cache/ccache" >> $GITHUB_ENV + ccache --set-config=max_size=10G + ccache --set-config=compiler_check=content + ccache --zero-stats + + - name: Build (try) + working-directory: build/stratosphere/loader + run: | # I forgot what dkp uses + export CC="ccache aarch64-none-elf-gcc" + export CXX="ccache aarch64-none-elf-g++" + ccache make -j$(($(nproc) * 2)) CXX="ccache aarch64-none-elf-g++" CC="ccache aarch64-none-elf-gcc + hactool -t kip1 out/nintendo_nx_arm64_armv8a/release/loader.kip --uncompress=hoc.kip + cp build/stratosphere/loader/hoc.kip dist/atmosphere/kips/hoc.kip + + - name: ccache stats + run: ccache --show-stats + + + # ------------------------------------------------- + # Package dist folder as ZIP with commit SHA + # ------------------------------------------------- + - name: Package dist + # working-directory: horizon-oc + run: | + ZIP_NAME="horizon-oc-zeus-dist-${SHORT_SHA}.zip" + zip -r "$ZIP_NAME" dist + echo "ZIP_NAME=$ZIP_NAME" >> $GITHUB_ENV + + # ------------------------------------------------- + # Upload ZIP artifact + # ------------------------------------------------- + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: horizon-oc-zeus-dist + path: horizon-oc/${{ env.ZIP_NAME }}