From 58c67fbb16425e90909f833fd57746f18271a846 Mon Sep 17 00:00:00 2001 From: Carsten Teibes Date: Sat, 28 Oct 2023 01:00:52 +0200 Subject: [PATCH] CMake: Add build presets and use them for CI --- .github/workflows/ci.yml | 24 +-- .gitignore | 1 + CMakePresets.json | 363 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 371 insertions(+), 17 deletions(-) create mode 100644 CMakePresets.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 916ee4d8..6f4263f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,6 @@ jobs: - name: Prepare Environment run: | echo "SHORT_SHA=${GITHUB_SHA:0:10}" >> $GITHUB_ENV - echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV - name: Checkout uses: actions/checkout@v4 @@ -95,19 +94,17 @@ jobs: - name: Prepare Environment run: | echo "SHORT_SHA=${GITHUB_SHA:0:10}" >> $GITHUB_ENV - echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV - name: Checkout uses: actions/checkout@v4 - name: Build OpenJazz run: | - cmake -G Ninja -B build . -DCMAKE_BUILD_TYPE=Release - cmake --build build + cmake --workflow --preset release - name: Prepare artifact run: | - cmake --install build --prefix $PWD + cmake --install build-release --prefix $PWD cp /mingw64/bin/SDL2.dll dist/ asciidoctor -o OpenJazzManual.html -a oj_version=${SHORT_SHA} res/unix/OpenJazz.6.adoc w3m -dump -cols 2147483647 -s OpenJazzManual.html > dist/Manual.txt @@ -136,15 +133,13 @@ jobs: - name: Prepare Environment run: | echo "SHORT_SHA=${GITHUB_SHA:0:10}" >> $GITHUB_ENV - echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV - name: Checkout uses: actions/checkout@v4 - name: Build OpenJazz run: | - export CXXFLAGS="-Wall -g -O2" - $DEVKITPRO/portlibs/wii/bin/powerpc-eabi-cmake -G Ninja -B build . -DCMAKE_BUILD_TYPE=Release + $DEVKITPRO/portlibs/wii/bin/powerpc-eabi-cmake -G Ninja -B build . -DCMAKE_BUILD_TYPE=RelWithDebInfo cmake --build build - name: Prepare artifact @@ -177,15 +172,13 @@ jobs: - name: Prepare Environment run: | echo "SHORT_SHA=${GITHUB_SHA:0:10}" >> $GITHUB_ENV - echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV - name: Checkout uses: actions/checkout@v4 - name: Build OpenJazz run: | - export CXXFLAGS="-Wall -g -O2" - $DEVKITPRO/portlibs/3ds/bin/arm-none-eabi-cmake -G Ninja -B build . -DCMAKE_BUILD_TYPE=Release + $DEVKITPRO/portlibs/3ds/bin/arm-none-eabi-cmake -G Ninja -B build . -DCMAKE_BUILD_TYPE=RelWithDebInfo cmake --build build - name: Prepare artifact @@ -218,7 +211,6 @@ jobs: - name: Prepare Environment run: | echo "SHORT_SHA=${GITHUB_SHA:0:10}" >> $GITHUB_ENV - echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV - name: Prepare GCCSDK autobuilder and build SDL run: | @@ -263,20 +255,18 @@ jobs: - name: Prepare Environment run: | echo "SHORT_SHA=${GITHUB_SHA:0:10}" >> $GITHUB_ENV - echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV - name: Checkout uses: actions/checkout@v4 - name: Build OpenJazz run: | - export CXXFLAGS="-Wall -g -O2" - psp-cmake -G Ninja -B build . -DCMAKE_BUILD_TYPE=Release -DNETWORK=OFF - cmake --build build + cmake --preset=psp-release -DNETWORK=OFF + cmake --build --preset=psp-release - name: Prepare artifact run: | - cmake --install build --prefix $PWD + cmake --install build-psp-release --prefix $PWD asciidoctor -o OpenJazzManual.html -a oj_version=${SHORT_SHA} res/unix/OpenJazz.6.adoc w3m -dump -cols 2147483647 -s OpenJazzManual.html > OpenJazz/Manual.txt cp README.md OpenJazz/README.txt diff --git a/.gitignore b/.gitignore index 4954bb84..b94fc272 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ CMakeFiles/ !/builds/cmake/*.cmake ext/Makefile build.ninja +CMakeUserPresets.json # homebrew *.elf diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 00000000..fc41e068 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,363 @@ +{ + "version": 6, + "configurePresets": [ + { + "name": "base", + "displayName": "Comment: base preset, all inherit from it", + "hidden": true, + "generator": "Ninja", + "binaryDir": "${sourceDir}/build-${presetName}", + "cacheVariables": { + "WANT_CCACHE": "ON" + } + }, + { + "name": "type-debug", + "displayName": "Comment: build type debug preset", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "type-release", + "displayName": "Comment: build type release preset", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "ReleaseWithDebInfo" + } + }, + { + "name": "parent", + "inherits": "base", + "displayName": "Comment: platform/special preset", + "description": "Default build using Ninja generator", + "hidden": true + }, + { + "name": "debug", + "displayName": "Native (Debug)", + "inherits": [ + "parent", + "type-debug" + ] + }, + { + "name": "release", + "displayName": "Native (Release)", + "inherits": [ + "parent", + "type-release" + ] + }, + { + "name": "asan-parent", + "inherits": "base", + "displayName": "Comment: platform/special preset", + "description": "ASAN build using Ninja generator", + "cacheVariables": { + "WANT_ASAN": "ON" + }, + "hidden": true + }, + { + "name": "asan-debug", + "displayName": "ASAN (Debug)", + "inherits": [ + "asan-parent", + "type-debug" + ] + }, + { + "name": "3ds-parent", + "inherits": "base", + "displayName": "Comment: platform/special preset", + "description": "Homebrew build using Ninja generator", + "toolchainFile": "$env{DEVKITPRO}/cmake/3DS.cmake", + "hidden": true + }, + { + "name": "3ds-debug", + "displayName": "Nintendo 3DS (Debug)", + "inherits": [ + "3ds-parent", + "type-debug" + ] + }, + { + "name": "3ds-release", + "displayName": "Nintendo 3DS (Release)", + "inherits": [ + "3ds-parent", + "type-release" + ] + }, + { + "name": "wii-parent", + "inherits": "base", + "displayName": "Comment: platform/special preset", + "description": "Homebrew build using Ninja generator", + "toolchainFile": "$env{DEVKITPRO}/cmake/Wii.cmake", + "hidden": true + }, + { + "name": "wii-debug", + "displayName": "Nintendo Wii (Debug)", + "inherits": [ + "wii-parent", + "type-debug" + ] + }, + { + "name": "wii-release", + "displayName": "Nintendo Wii (Release)", + "inherits": [ + "wii-parent", + "type-release" + ] + }, + { + "name": "psp-parent", + "inherits": "base", + "displayName": "Comment: platform/special preset", + "description": "Homebrew build using Ninja generator", + "toolchainFile": "$env{PSPDEV}/psp/share/pspdev.cmake", + "hidden": true + }, + { + "name": "psp-debug", + "displayName": "Sony PSP (Debug)", + "inherits": [ + "psp-parent", + "type-debug" + ] + }, + { + "name": "psp-release", + "displayName": "Sony PSP (Release)", + "inherits": [ + "psp-parent", + "type-release" + ] + } + ], + "buildPresets": [ + { + "name": "debug", + "configurePreset": "debug" + }, + { + "name": "release", + "configurePreset": "release" + }, + { + "name": "asan-debug", + "configurePreset": "asan-debug" + }, + { + "name": "3ds-debug", + "configurePreset": "3ds-debug" + }, + { + "name": "3ds-release", + "configurePreset": "3ds-release" + }, + { + "name": "wii-debug", + "configurePreset": "wii-debug" + }, + { + "name": "wii-release", + "configurePreset": "wii-release" + }, + { + "name": "psp-debug", + "configurePreset": "psp-debug" + }, + { + "name": "psp-release", + "configurePreset": "psp-release" + } + ], + "packagePresets": [ + { + "name": "debug", + "configurePreset": "debug" + }, + { + "name": "release", + "configurePreset": "release" + }, + { + "name": "asan-debug", + "configurePreset": "asan-debug" + }, + { + "name": "3ds-debug", + "configurePreset": "3ds-debug" + }, + { + "name": "3ds-release", + "configurePreset": "3ds-release" + }, + { + "name": "wii-debug", + "configurePreset": "wii-debug" + }, + { + "name": "wii-release", + "configurePreset": "wii-release" + }, + { + "name": "psp-debug", + "configurePreset": "psp-debug" + }, + { + "name": "psp-release", + "configurePreset": "psp-release" + } + ], + "workflowPresets": [ + { + "name": "debug", + "steps": [ + { + "type": "configure", + "name": "debug" + }, + { + "type": "build", + "name": "debug" + } + ] + }, + { + "name": "release", + "steps": [ + { + "type": "configure", + "name": "release" + }, + { + "type": "build", + "name": "release" + } + ] + }, + { + "name": "asan-debug", + "steps": [ + { + "type": "configure", + "name": "asan-debug" + }, + { + "type": "build", + "name": "asan-debug" + } + ] + }, + { + "name": "3ds-debug", + "steps": [ + { + "type": "configure", + "name": "3ds-debug" + }, + { + "type": "build", + "name": "3ds-debug" + }, + { + "type": "package", + "name": "3ds-debug" + } + ] + }, + { + "name": "3ds-release", + "steps": [ + { + "type": "configure", + "name": "3ds-release" + }, + { + "type": "build", + "name": "3ds-release" + }, + { + "type": "package", + "name": "3ds-release" + } + ] + }, + { + "name": "wii-debug", + "steps": [ + { + "type": "configure", + "name": "wii-debug" + }, + { + "type": "build", + "name": "wii-debug" + }, + { + "type": "package", + "name": "wii-debug" + } + ] + }, + { + "name": "wii-release", + "steps": [ + { + "type": "configure", + "name": "wii-release" + }, + { + "type": "build", + "name": "wii-release" + }, + { + "type": "package", + "name": "wii-release" + } + ] + }, + { + "name": "psp-debug", + "steps": [ + { + "type": "configure", + "name": "psp-debug" + }, + { + "type": "build", + "name": "psp-debug" + }, + { + "type": "package", + "name": "psp-debug" + } + ] + }, + { + "name": "psp-release", + "steps": [ + { + "type": "configure", + "name": "psp-release" + }, + { + "type": "build", + "name": "psp-release" + }, + { + "type": "package", + "name": "psp-release" + } + ] + } + ] +}