From 4241ba9835121db8b731bc3fcd72315b5fc3220d Mon Sep 17 00:00:00 2001 From: Julian Uy Date: Sat, 25 Nov 2023 02:36:04 +0000 Subject: [PATCH 1/2] refactor: Improve buildsystem Cleaner error handling Store repository URL and reference in config file Comment cleanup --- config/ps2toolchain-config.sh | 12 ++++++++++++ scripts/001-dvp.sh | 36 ++++++++++++++++++++++++++--------- scripts/002-iop.sh | 36 ++++++++++++++++++++++++++--------- scripts/003-ee.sh | 36 ++++++++++++++++++++++++++--------- 4 files changed, 93 insertions(+), 27 deletions(-) create mode 100644 config/ps2toolchain-config.sh diff --git a/config/ps2toolchain-config.sh b/config/ps2toolchain-config.sh new file mode 100644 index 0000000..63a1ee4 --- /dev/null +++ b/config/ps2toolchain-config.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +PS2TOOLCHAIN_DVP_REPO_URL="https://github.com/ps2dev/ps2toolchain-dvp.git" +PS2TOOLCHAIN_DVP_DEFAULT_REPO_REF="main" +PS2TOOLCHAIN_IOP_REPO_URL="https://github.com/ps2dev/ps2toolchain-iop.git" +PS2TOOLCHAIN_IOP_DEFAULT_REPO_REF="main" +PS2TOOLCHAIN_EE_REPO_URL="https://github.com/ps2dev/ps2toolchain-ee.git" +PS2TOOLCHAIN_EE_DEFAULT_REPO_REF="main" + +if test -f "$PS2DEV_CONFIG_OVERRIDE"; then + source "$PS2DEV_CONFIG_OVERRIDE" +fi diff --git a/scripts/001-dvp.sh b/scripts/001-dvp.sh index 73382f0..a22d55a 100755 --- a/scripts/001-dvp.sh +++ b/scripts/001-dvp.sh @@ -1,18 +1,36 @@ #!/bin/bash -# 001-dvp.sh by Francisco Javier Trujillo Mata (fjtrujy@gmail.com) +# 001-dvp.sh by ps2dev developers + +## Exit with code 1 when any command executed returns a non-zero exit code. +onerr() +{ + exit 1; +} +trap onerr ERR + +## Read information from the configuration file. +source "$(dirname "$0")/../config/ps2toolchain-config.sh" ## Download the source code. -REPO_URL="https://github.com/ps2dev/ps2toolchain-dvp" -REPO_FOLDER="ps2toolchain-dvp" +REPO_URL="$PS2TOOLCHAIN_DVP_REPO_URL" +REPO_REF="$PS2TOOLCHAIN_DVP_DEFAULT_REPO_REF" +REPO_FOLDER="$(s="$REPO_URL"; s=${s##*/}; printf "%s" "${s%.*}")" -# Checking if a specific TAG has been selected, it is passed using parameter $1 -[ -z "$1" ] && REPO_REFERENCE="main" || REPO_REFERENCE=$1 -echo "Using repo reference $REPO_REFERENCE" +# Checking if a specific Git reference has been passed in parameter $1 +if test -n "$1"; then + REPO_REF="$1" + printf 'Using specified repo reference %s\n' "$REPO_REF" +fi if test ! -d "$REPO_FOLDER"; then - git clone $REPO_URL -b "${REPO_REFERENCE}" || exit 1 + git clone --depth 1 -b "$REPO_REF" "$REPO_URL" "$REPO_FOLDER" +else + git -C "$REPO_FOLDER" fetch origin + git -C "$REPO_FOLDER" reset --hard "origin/$REPO_REF" + git -C "$REPO_FOLDER" checkout "$REPO_REF" fi -cd "$REPO_FOLDER" && git fetch origin && git reset --hard "origin/${REPO_REFERENCE}" && git checkout "${REPO_REFERENCE}" || exit 1 + +cd "$REPO_FOLDER" ## Build and install. -./toolchain.sh || { exit 1; } +./toolchain.sh diff --git a/scripts/002-iop.sh b/scripts/002-iop.sh index 238b6eb..9537d96 100755 --- a/scripts/002-iop.sh +++ b/scripts/002-iop.sh @@ -1,18 +1,36 @@ #!/bin/bash -# 002-iop.sh by Francisco Javier Trujillo Mata (fjtrujy@gmail.com) +# 002-iop.sh by ps2dev developers + +## Exit with code 1 when any command executed returns a non-zero exit code. +onerr() +{ + exit 1; +} +trap onerr ERR + +## Read information from the configuration file. +source "$(dirname "$0")/../config/ps2toolchain-config.sh" ## Download the source code. -REPO_URL="https://github.com/ps2dev/ps2toolchain-iop" -REPO_FOLDER="ps2toolchain-iop" +REPO_URL="$PS2TOOLCHAIN_IOP_REPO_URL" +REPO_REF="$PS2TOOLCHAIN_IOP_DEFAULT_REPO_REF" +REPO_FOLDER="$(s="$REPO_URL"; s=${s##*/}; printf "%s" "${s%.*}")" -# Checking if a specific TAG has been selected, it is passed using parameter $1 -[ -z "$1" ] && REPO_REFERENCE="main" || REPO_REFERENCE=$1 -echo "Using repo reference $REPO_REFERENCE" +# Checking if a specific Git reference has been passed in parameter $1 +if test -n "$1"; then + REPO_REF="$1" + printf 'Using specified repo reference %s\n' "$REPO_REF" +fi if test ! -d "$REPO_FOLDER"; then - git clone $REPO_URL -b "${REPO_REFERENCE}" || exit 1 + git clone --depth 1 -b "$REPO_REF" "$REPO_URL" "$REPO_FOLDER" +else + git -C "$REPO_FOLDER" fetch origin + git -C "$REPO_FOLDER" reset --hard "origin/$REPO_REF" + git -C "$REPO_FOLDER" checkout "$REPO_REF" fi -cd "$REPO_FOLDER" && git fetch origin && git reset --hard "origin/${REPO_REFERENCE}" && git checkout "${REPO_REFERENCE}" || exit 1 + +cd "$REPO_FOLDER" ## Build and install. -./toolchain.sh || { exit 1; } +./toolchain.sh diff --git a/scripts/003-ee.sh b/scripts/003-ee.sh index a096bbb..06bea7f 100755 --- a/scripts/003-ee.sh +++ b/scripts/003-ee.sh @@ -1,18 +1,36 @@ #!/bin/bash -# 003-ee.sh by Francisco Javier Trujillo Mata (fjtrujy@gmail.com) +# 003-ee.sh by ps2dev developers + +## Exit with code 1 when any command executed returns a non-zero exit code. +onerr() +{ + exit 1; +} +trap onerr ERR + +## Read information from the configuration file. +source "$(dirname "$0")/../config/ps2toolchain-config.sh" ## Download the source code. -REPO_URL="https://github.com/ps2dev/ps2toolchain-ee" -REPO_FOLDER="ps2toolchain-ee" +REPO_URL="$PS2TOOLCHAIN_EE_REPO_URL" +REPO_REF="$PS2TOOLCHAIN_EE_DEFAULT_REPO_REF" +REPO_FOLDER="$(s="$REPO_URL"; s=${s##*/}; printf "%s" "${s%.*}")" -# Checking if a specific TAG has been selected, it is passed using parameter $1 -[ -z "$1" ] && REPO_REFERENCE="main" || REPO_REFERENCE=$1 -echo "Using repo reference $REPO_REFERENCE" +# Checking if a specific Git reference has been passed in parameter $1 +if test -n "$1"; then + REPO_REF="$1" + printf 'Using specified repo reference %s\n' "$REPO_REF" +fi if test ! -d "$REPO_FOLDER"; then - git clone $REPO_URL -b "${REPO_REFERENCE}" || exit 1 + git clone --depth 1 -b "$REPO_REF" "$REPO_URL" "$REPO_FOLDER" +else + git -C "$REPO_FOLDER" fetch origin + git -C "$REPO_FOLDER" reset --hard "origin/$REPO_REF" + git -C "$REPO_FOLDER" checkout "$REPO_REF" fi -cd "$REPO_FOLDER" && git fetch origin && git reset --hard "origin/${REPO_REFERENCE}" && git checkout "${REPO_REFERENCE}" || exit 1 + +cd "$REPO_FOLDER" ## Build and install. -./toolchain.sh || { exit 1; } +./toolchain.sh From 732769fe722bcf18a3e37ca83290cb0c86842fc4 Mon Sep 17 00:00:00 2001 From: Julian Uy Date: Sat, 25 Nov 2023 02:38:42 +0000 Subject: [PATCH 2/2] refactor: Improve CI Enable fail fast Normalize install package list Bump checkout action version Fix macOS capitalization Add workflow dispatch --- .github/workflows/compilation.yml | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/compilation.yml b/.github/workflows/compilation.yml index 9d2cd11..058ddf3 100644 --- a/.github/workflows/compilation.yml +++ b/.github/workflows/compilation.yml @@ -5,6 +5,7 @@ on: pull_request: repository_dispatch: types: [run_build] + workflow_dispatch: {} jobs: build: @@ -12,35 +13,43 @@ jobs: strategy: matrix: os: [[macos-latest, bash], [ubuntu-latest, bash], [windows-latest, msys2]] + fail-fast: false defaults: run: shell: ${{ matrix.os[1] }} {0} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + with: + fetch-depth: 0 - - name: Install Ubuntu texinfo bison flex + - name: Install Ubuntu packages if: matrix.os[0] == 'ubuntu-latest' run: | sudo apt-get update sudo apt-get -y install texinfo bison flex gettext libgmp3-dev libmpfr-dev libmpc-dev + echo "MSYSTEM=x64" >> $GITHUB_ENV - - name: Install Mac texinfo bison flex - if: matrix.os[0] == 'macOS-latest' + - name: Install macOS packages + if: matrix.os[0] == 'macos-latest' run: | brew update brew install texinfo bison flex gnu-sed gsl gmp mpfr libmpc + echo "MSYSTEM=x64" >> $GITHUB_ENV - - name: Install MSYS2 texinfo bison flex + - name: Install MSYS2 packages if: matrix.os[0] == 'windows-latest' uses: msys2/setup-msys2@v2 with: msystem: MINGW32 - install: base-devel git make texinfo flex bison patch binutils mingw-w64-i686-gcc mpc-devel + install: | + base-devel git make texinfo flex bison patch binutils mingw-w64-i686-gcc mpc-devel tar + mingw-w64-i686-cmake mingw-w64-i686-extra-cmake-modules mingw-w64-i686-make mingw-w64-i686-libogg update: true shell: msys2 {0} - name: Runs all the stages in the shell + continue-on-error: false run: | export PS2DEV=$PWD/ps2dev export PS2SDK=$PS2DEV/ps2sdk