From 425bb838d57fc5f9c04a5dd1cc6769bafd7d089d Mon Sep 17 00:00:00 2001 From: spicyjpeg Date: Tue, 9 Jan 2024 20:06:15 +0100 Subject: [PATCH] Fix CI and toolchain build scripts --- .github/scripts/build_toolchain.sh | 8 +++---- .github/workflows/build.yml | 34 +++++++++++++------------- CMakePresets.json | 1 - template/CMakePresets.json | 38 +++++++++++++++++++++++++----- 4 files changed, 52 insertions(+), 29 deletions(-) diff --git a/.github/scripts/build_toolchain.sh b/.github/scripts/build_toolchain.sh index 9c30c10b..9d6c121d 100755 --- a/.github/scripts/build_toolchain.sh +++ b/.github/scripts/build_toolchain.sh @@ -6,12 +6,12 @@ GCC_VERSION="13.2.0" NUM_JOBS="4" if [ $# -eq 2 ]; then - TARGET_NAME="$1" - PACKAGE_NAME="$2" + PACKAGE_NAME="$1" + TARGET_NAME="$2" BUILD_OPTIONS="" elif [ $# -eq 3 ]; then - TARGET_NAME="$1" - PACKAGE_NAME="$2" + PACKAGE_NAME="$1" + TARGET_NAME="$2" BUILD_OPTIONS="--build=x86_64-linux-gnu --host=$3" else echo "Usage: $0 [host triplet]" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ff927f56..c81d0280 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,8 +17,8 @@ jobs: uses: actions/cache@v3.3.2 with: enableCrossOsArchive: true - key: gcc - path: gcc + key: toolchain + path: gcc-mipsel-none-elf-* - name: Install prerequisites if: ${{ steps.cache.outputs.cache-hit != 'true' }} @@ -35,15 +35,13 @@ jobs: - name: Build toolchain for Linux if: ${{ steps.cache.outputs.cache-hit != 'true' }} run: | - cd gcc - ../psn00bsdk/.github/scripts/build_toolchain.sh gcc-mipsel-none-elf-linux mipsel-none-elf - echo "${{ github.workspace }}/gcc/gcc-mipsel-none-elf-linux/bin" >>$GITHUB_PATH + psn00bsdk/.github/scripts/build_toolchain.sh gcc-mipsel-none-elf-linux mipsel-none-elf + echo "${{ github.workspace }}/gcc-mipsel-none-elf-linux/bin" >>$GITHUB_PATH - name: Build toolchain for Windows if: ${{ steps.cache.outputs.cache-hit != 'true' }} run: | - cd gcc - ../psn00bsdk/.github/scripts/build_toolchain.sh gcc-mipsel-none-elf-windows mipsel-none-elf x86_64-w64-mingw32 + psn00bsdk/.github/scripts/build_toolchain.sh gcc-mipsel-none-elf-windows mipsel-none-elf x86_64-w64-mingw32 build-psn00bsdk-windows: name: Build PSn00bSDK on Windows @@ -60,12 +58,12 @@ jobs: uses: actions/cache@v3.3.2 with: enableCrossOsArchive: true - key: gcc - path: gcc + key: toolchain + path: gcc-mipsel-none-elf-* - name: Install prerequisites run: | - pacman -S --noconfirm mingw-w64-x86_64-ninja + pacman -S --noconfirm zip mingw-w64-x86_64-ninja - name: Fetch repo contents uses: actions/checkout@v4 @@ -75,7 +73,7 @@ jobs: - name: Build and package PSn00bSDK run: | - cmake --preset ci -S psn00bsdk -G "Visual Studio 17 2022" -DPSN00BSDK_TC=${{ github.workspace }}\gcc\gcc-mipsel-none-elf-windows + cmake --preset ci -S psn00bsdk -G "Visual Studio 17 2022" -DPSN00BSDK_TC=${{ github.workspace }}\gcc-mipsel-none-elf-windows cmake --build build cmake --install build cd dist @@ -97,13 +95,13 @@ jobs: uses: actions/cache@v3.3.2 with: enableCrossOsArchive: true - key: gcc - path: gcc + key: toolchain + path: gcc-mipsel-none-elf-* - name: Install prerequisites run: | sudo apt-get update -y - sudo apt-get install -y --no-install-recommends ninja-build + sudo apt-get install -y --no-install-recommends zip ninja-build - name: Fetch repo contents uses: actions/checkout@v4 @@ -113,7 +111,7 @@ jobs: - name: Build and package PSn00bSDK run: | - cmake --preset ci -S psn00bsdk -G "Ninja" -DPSN00BSDK_TC=${{ github.workspace }}/gcc/gcc-mipsel-none-elf-linux + cmake --preset ci -S psn00bsdk -G "Ninja" -DPSN00BSDK_TC=${{ github.workspace }}/gcc-mipsel-none-elf-linux cmake --build build cmake --install build cd dist @@ -138,8 +136,8 @@ jobs: uses: actions/cache@v3.3.2 with: enableCrossOsArchive: true - key: gcc - path: gcc + key: toolchain + path: gcc-mipsel-none-elf-* - name: Fetch repo contents if: ${{ github.ref_type == 'tag' }} @@ -165,6 +163,6 @@ jobs: #fail_on_unmatched_files: true body_path: release.md files: | - gcc/*.zip + gcc-mipsel-none-elf-*.zip psn00bsdk-windows/*.zip psn00bsdk-linux/*.zip diff --git a/CMakePresets.json b/CMakePresets.json index b576afbc..01c213fe 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -36,7 +36,6 @@ "cacheVariables": { "CMAKE_BUILD_TYPE": "Release", "LIBPSN00B_GENERATOR": "Ninja", - "PSN00BSDK_TARGET": "$env{GCC_TARGET}", "PSN00BSDK_GIT_TAG": "$env{GITHUB_REF_NAME}", "PSN00BSDK_GIT_COMMIT": "$env{GITHUB_SHA}" } diff --git a/template/CMakePresets.json b/template/CMakePresets.json index 97d84282..6fa719c4 100644 --- a/template/CMakePresets.json +++ b/template/CMakePresets.json @@ -7,16 +7,42 @@ }, "configurePresets": [ { - "name": "default", - "displayName": "Default configuration", - "description": "Use this preset to build the project using PSn00bSDK.", + "name": "debug", + "displayName": "Debug build", + "description": "Build the project with no optimization and assertions enabled.", "generator": "Ninja", "toolchainFile": "$env{PSN00BSDK_LIBS}/cmake/sdk.cmake", "binaryDir": "${sourceDir}/build", "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug", - "PSN00BSDK_TC": "", - "PSN00BSDK_TARGET": "mipsel-none-elf" + "CMAKE_BUILD_TYPE": "Debug" + }, + "warnings": { + "dev": false + } + }, + { + "name": "release", + "displayName": "Release build", + "description": "Build the project with performance optimization and assertions stripped.", + "generator": "Ninja", + "toolchainFile": "$env{PSN00BSDK_LIBS}/cmake/sdk.cmake", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + }, + "warnings": { + "dev": false + } + }, + { + "name": "min-size-release", + "displayName": "Minimum size release build", + "description": "Build the project with size optimization and assertions stripped.", + "generator": "Ninja", + "toolchainFile": "$env{PSN00BSDK_LIBS}/cmake/sdk.cmake", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "MinSizeRel" }, "warnings": { "dev": false