From 7e4bdd22f91b8dec700bd2a30f31f37fb2434755 Mon Sep 17 00:00:00 2001 From: Wouter Wijsman Date: Sun, 16 Jun 2024 12:47:30 +0200 Subject: [PATCH 1/5] Add build script and update build.txt --- .github/workflows/compilation.yml | 6 +---- .github/workflows/docker.yml | 7 +---- Dockerfile | 22 ++-------------- build-and-install.sh | 44 +++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 31 deletions(-) create mode 100755 build-and-install.sh diff --git a/.github/workflows/compilation.yml b/.github/workflows/compilation.yml index 3ef4d2bb..243ec4c0 100644 --- a/.github/workflows/compilation.yml +++ b/.github/workflows/compilation.yml @@ -19,11 +19,7 @@ jobs: - name: Compile PSPSDK run: | - ./bootstrap - ./configure - make clean - make -j $(getconf _NPROCESSORS_ONLN) - make install + ./build-and-install.sh - name: Get short SHA id: slug diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a8a96b3f..8ff2a087 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -15,12 +15,6 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Login to Github registry uses: docker/login-action@v3 with: @@ -30,6 +24,7 @@ jobs: - uses: docker/build-push-action@v5 with: + context: . push: true tags: ghcr.io/${{ github.repository }}:latest build-args: | diff --git a/Dockerfile b/Dockerfile index 147b38df..e1f7d6e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,26 +5,8 @@ FROM $BASE_DOCKER_IMAGE COPY . /src -RUN apk add build-base autoconf automake zlib-dev -RUN cd /src && \ - ./bootstrap && \ - ./configure && \ - make -j $(getconf _NPROCESSORS_ONLN) clean && \ - make -j $(getconf _NPROCESSORS_ONLN) && \ - make -j $(getconf _NPROCESSORS_ONLN) install - -## gcc needs to include libcglue libpthreadglue libpsputility libpsprtc libpspnet_inet libpspnet_resolver libpspsdk libpspmodinfo libpspuser libpspkernel -## from pspsdk to be able to build executables, because they are part of the standard libraries -RUN ln -sf "$PSPDEV/psp/sdk/lib/libcglue.a" "$PSPDEV/psp/lib/libcglue.a" || { exit 1; } -RUN ln -sf "$PSPDEV/psp/sdk/lib/libpthreadglue.a" "$PSPDEV/psp/lib/libpthreadglue.a" || { exit 1; } -RUN ln -sf "$PSPDEV/psp/sdk/lib/libpsputility.a" "$PSPDEV/psp/lib/libpsputility.a" || { exit 1; } -RUN ln -sf "$PSPDEV/psp/sdk/lib/libpsprtc.a" "$PSPDEV/psp/lib/libpsprtc.a" || { exit 1; } -RUN ln -sf "$PSPDEV/psp/sdk/lib/libpspnet_inet.a" "$PSPDEV/psp/lib/libpspnet_inet.a" || { exit 1; } -RUN ln -sf "$PSPDEV/psp/sdk/lib/libpspnet_resolver.a" "$PSPDEV/psp/lib/libpspnet_resolver.a" || { exit 1; } -RUN ln -sf "$PSPDEV/psp/sdk/lib/libpspsdk.a" "$PSPDEV/psp/lib/libpspsdk.a" || { exit 1; } -RUN ln -sf "$PSPDEV/psp/sdk/lib/libpspmodinfo.a" "$PSPDEV/psp/lib/libpspmodinfo.a" || { exit 1; } -RUN ln -sf "$PSPDEV/psp/sdk/lib/libpspuser.a" "$PSPDEV/psp/lib/libpspuser.a" || { exit 1; } -RUN ln -sf "$PSPDEV/psp/sdk/lib/libpspkernel.a" "$PSPDEV/psp/lib/libpspkernel.a" || { exit 1; } +RUN apk add build-base autoconf automake zlib-dev bash git && \ + /src/build-and-install.sh # Second stage FROM alpine:latest diff --git a/build-and-install.sh b/build-and-install.sh new file mode 100755 index 00000000..575c3b46 --- /dev/null +++ b/build-and-install.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +## Fail script if an error happens +set -e + +## Enter the pspsdk directory. +cd "$(dirname "$0")" || { echo "ERROR: Could not enter the pspsdk directory."; exit 1; } + +## Make sure PSPDEV is set +if [ -z "${PSPDEV}" ]; then + echo "The PSPDEV environment variable has not been set" + exit 1 +fi + +## Build pspsdk +./bootstrap +./configure +make clean +make -j $(getconf _NPROCESSORS_ONLN) + +## Install pspsdk +make install + +## gcc needs to include libcglue libpthreadglue libpsputility libpsprtc libpspnet_inet libpspnet_resolver libpspsdk libpspmodinfo libpspuser libpspkernel +## from pspsdk to be able to build executables, because they are part of the standard libraries +cd "$PSPDEV/psp/lib" +ln -sf "../sdk/lib/libcglue.a" "libcglue.a" || { exit 1; } +ln -sf "../sdk/lib/libpthreadglue.a" "libpthreadglue.a" || { exit 1; } +ln -sf "../sdk/lib/libpsputility.a" "libpsputility.a" || { exit 1; } +ln -sf "../sdk/lib/libpsprtc.a" "libpsprtc.a" || { exit 1; } +ln -sf "../sdk/lib/libpspnet_inet.a" "libpspnet_inet.a" || { exit 1; } +ln -sf "../sdk/lib/libpspnet_resolver.a" "libpspnet_resolver.a" || { exit 1; } +ln -sf "../sdk/lib/libpspsdk.a" "libpspsdk.a" || { exit 1; } +ln -sf "../sdk/lib/libpspmodinfo.a" "libpspmodinfo.a" || { exit 1; } +ln -sf "../sdk/lib/libpspuser.a" "libpspuser.a" || { exit 1; } +ln -sf "../sdk/lib/libpspkernel.a" "libpspkernel.a" || { exit 1; } +cd - + +## Store build information +BUILD_FILE="${PSPDEV}/build.txt" +if [[ -f "${BUILD_FILE}" ]]; then + sed -i='' '/^pspsdk /d' "${BUILD_FILE}" +fi +git log -1 --format="pspsdk %H %cs %s" >> "${BUILD_FILE}" From 20a03ef15b9f7815a59ce4b458bdb0037d6d87d2 Mon Sep 17 00:00:00 2001 From: Wouter Wijsman Date: Sun, 16 Jun 2024 12:53:36 +0200 Subject: [PATCH 2/5] Make sure bash is installed --- .github/workflows/compilation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compilation.yml b/.github/workflows/compilation.yml index 243ec4c0..10fa2878 100644 --- a/.github/workflows/compilation.yml +++ b/.github/workflows/compilation.yml @@ -15,7 +15,7 @@ jobs: - name: Install dependencies run: | - apk add build-base autoconf automake zlib-dev + apk add build-base autoconf automake zlib-dev bash git - name: Compile PSPSDK run: | From 352a65af7ebd914486f1a2a05cecada85f659766 Mon Sep 17 00:00:00 2001 From: Wouter Wijsman Date: Sun, 16 Jun 2024 12:54:57 +0200 Subject: [PATCH 3/5] Execute git checkout after installing git --- .github/workflows/compilation.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/compilation.yml b/.github/workflows/compilation.yml index 10fa2878..8c2cd699 100644 --- a/.github/workflows/compilation.yml +++ b/.github/workflows/compilation.yml @@ -11,12 +11,13 @@ jobs: runs-on: ubuntu-latest container: ghcr.io/pspdev/psptoolchain:latest steps: - - uses: actions/checkout@v4 - name: Install dependencies run: | apk add build-base autoconf automake zlib-dev bash git + - uses: actions/checkout@v4 + - name: Compile PSPSDK run: | ./build-and-install.sh From 5ec9a1b35a7fdc0b94d69e26816898c671864c8a Mon Sep 17 00:00:00 2001 From: Wouter Wijsman Date: Sun, 16 Jun 2024 12:56:45 +0200 Subject: [PATCH 4/5] Make sure ownership is set for git repo --- .github/workflows/compilation.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/compilation.yml b/.github/workflows/compilation.yml index 8c2cd699..af1f0a32 100644 --- a/.github/workflows/compilation.yml +++ b/.github/workflows/compilation.yml @@ -20,6 +20,9 @@ jobs: - name: Compile PSPSDK run: | + chown -R $(id -nu):$(id -ng) . + export PSPDEV=$PWD/pspdev + export PATH=$PATH:$PSPDEV/bin ./build-and-install.sh - name: Get short SHA From 227a0f4d8450780901fa28060b9129d663d2aed4 Mon Sep 17 00:00:00 2001 From: Wouter Wijsman Date: Sun, 16 Jun 2024 12:58:27 +0200 Subject: [PATCH 5/5] Use correct path for pspdev --- .github/workflows/compilation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compilation.yml b/.github/workflows/compilation.yml index af1f0a32..da18a92d 100644 --- a/.github/workflows/compilation.yml +++ b/.github/workflows/compilation.yml @@ -21,7 +21,7 @@ jobs: - name: Compile PSPSDK run: | chown -R $(id -nu):$(id -ng) . - export PSPDEV=$PWD/pspdev + export PSPDEV=/usr/local/pspdev export PATH=$PATH:$PSPDEV/bin ./build-and-install.sh