diff --git a/.github/workflows/linux-compile.yml b/.github/workflows/linux-compile.yml index fb5019d94..7f0fe1a5f 100644 --- a/.github/workflows/linux-compile.yml +++ b/.github/workflows/linux-compile.yml @@ -7,6 +7,9 @@ on: jobs: build: runs-on: ubuntu-latest + strategy: + matrix: + config: [Release, Debug] steps: - uses: actions/checkout@v4 with: @@ -39,15 +42,15 @@ jobs: sudo make install - name: Build run: | - cmake -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE=Release - cmake --build build-cmake -j + cmake -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.config }} + cmake --build build-cmake -j --config ${{ matrix.config }} - name: Create Package run: | - mkdir spaghetti-release - mv build-cmake/Spaghettify spaghetti-release/ + mkdir spaghetti-${{ matrix.config }} + mv build-cmake/Spaghettify spaghetti-${{ matrix.config }}/ - name: Publish packaged artifacts uses: actions/upload-artifact@v4 with: - name: spaghetti-linux-x64 - path: spaghetti-release + name: spaghetti-linux-x64-${{ matrix.config }} + path: spaghetti-${{ matrix.config }} retention-days: 1 diff --git a/.github/workflows/macos-compile.yml b/.github/workflows/macos-compile.yml index 870579d6a..ec72d0b57 100644 --- a/.github/workflows/macos-compile.yml +++ b/.github/workflows/macos-compile.yml @@ -7,6 +7,9 @@ on: jobs: build: runs-on: macOS-latest + strategy: + matrix: + config: [Release, Debug] steps: - uses: actions/checkout@v4 with: @@ -21,15 +24,15 @@ jobs: vcpkgDirectory: '${{ github.workspace }}/vcpkg' - name: Build run: | - cmake -H. -Bbuild-cmake -GNinja -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake - cmake --build build-cmake -j + cmake -H. -Bbuild-cmake -GNinja -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake + cmake --build build-cmake -j --config ${{ matrix.config }} - name: Create Package run: | - mkdir spaghetti-release - mv build-cmake/Spaghettify spaghetti-release/ + mkdir spaghetti-${{ matrix.config }} + mv build-cmake/Spaghettify spaghetti-${{ matrix.config }}/ - name: Publish packaged artifacts uses: actions/upload-artifact@v4 with: - name: spaghetti-mac-universal - path: spaghetti-release + name: spaghetti-mac-universal-${{ matrix.config }} + path: spaghetti-${{ matrix.config }} retention-days: 1 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d99628b39..beaf692d3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -47,6 +47,9 @@ jobs: build-windows: needs: generate-port-o2r runs-on: windows-2022 + strategy: + matrix: + config: [Release, Debug] steps: - uses: actions/checkout@v4 with: @@ -55,30 +58,34 @@ jobs: submodules: recursive - name: Build run: | - cmake -S . -B "build/x64" -G "Visual Studio 17 2022" -T v143 -A x64 -DCMAKE_BUILD_TYPE=Release - cmake --build ./build/x64 --config Release --parallel 10 + cmake -S . -B "build/x64" -G "Visual Studio 17 2022" -T v143 -A x64 -DCMAKE_BUILD_TYPE=${{ matrix.config }} + cmake --build ./build/x64 --config ${{ matrix.config }} --parallel 10 - name: Download spaghetti.o2r uses: actions/download-artifact@v4 with: name: spaghetti.o2r - path: ./build/x64/Release + path: ./build/x64/${{ matrix.config }} - name: Create Package run: | - mkdir spaghetti-release - mv build/x64/Release/Spaghettify.exe spaghetti-release/ - mv build/x64/Release/spaghetti.o2r spaghetti-release/ - mv config.yml spaghetti-release/ - mv yamls spaghetti-release/ - Invoke-WebRequest -Uri "https://raw.githubusercontent.com/mdqinc/SDL_GameControllerDB/master/gamecontrollerdb.txt" -OutFile "spaghetti-release/gamecontrollerdb.txt" + mkdir spaghetti-${{ matrix.config }} + mv build/x64/${{ matrix.config }}/Spaghettify.exe spaghetti-${{ matrix.config }}/ + mv build/x64/${{ matrix.config }}/spaghetti.o2r spaghetti-${{ matrix.config }}/ + mv config.yml spaghetti-${{ matrix.config }}/ + mv yamls spaghetti-${{ matrix.config }}/ + Invoke-WebRequest -Uri "https://raw.githubusercontent.com/mdqinc/SDL_GameControllerDB/master/gamecontrollerdb.txt" -OutFile "spaghetti-${{ matrix.config }}/gamecontrollerdb.txt" - name: Upload build + if: matrix.config == 'Release' uses: actions/upload-artifact@v4 with: name: spaghetti-windows - path: spaghetti-release + path: spaghetti-${{ matrix.config }} build-macos: needs: generate-port-o2r runs-on: macOS-latest + strategy: + matrix: + config: [Release, Debug] steps: - uses: actions/checkout@v4 with: @@ -93,8 +100,8 @@ jobs: vcpkgDirectory: '${{ github.workspace }}/vcpkg' - name: Build run: | - cmake -H. -Bbuild-cmake -GNinja -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake - cmake --build build-cmake --config Release -j3 + cmake -H. -Bbuild-cmake -GNinja -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake + cmake --build build-cmake --config ${{ matrix.config }} -j3 - name: Download spaghetti.o2r uses: actions/download-artifact@v4 with: @@ -102,21 +109,25 @@ jobs: path: ./build-cmake - name: Create Package run: | - mkdir spaghetti-release - mv build-cmake/Spaghettify spaghetti-release/ - mv build-cmake/spaghetti.o2r spaghetti-release/ - mv config.yml spaghetti-release/ - mv yamls spaghetti-release/ - wget -O spaghetti-release/gamecontrollerdb.txt https://raw.githubusercontent.com/mdqinc/SDL_GameControllerDB/master/gamecontrollerdb.txt + mkdir spaghetti-${{ matrix.config }} + mv build-cmake/Spaghettify spaghetti-${{ matrix.config }}/ + mv build-cmake/spaghetti.o2r spaghetti-${{ matrix.config }}/ + mv config.yml spaghetti-${{ matrix.config }}/ + mv yamls spaghetti-${{ matrix.config }}/ + wget -O spaghetti-${{ matrix.config }}/gamecontrollerdb.txt https://raw.githubusercontent.com/mdqinc/SDL_GameControllerDB/master/gamecontrollerdb.txt - name: Publish packaged artifacts + if: matrix.config == 'Release' uses: actions/upload-artifact@v4 with: name: spaghetti-mac-x64 - path: spaghetti-release + path: spaghetti-${{ matrix.config }} build-linux: needs: generate-port-o2r runs-on: ubuntu-latest + strategy: + matrix: + config: [Release, Debug] steps: - uses: actions/checkout@v4 with: @@ -189,25 +200,19 @@ jobs: path: ./build-cmake - name: Build run: | - cmake -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE=Release - cmake --build build-cmake --config Release -j3 + cmake -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.config }} + cmake --build build-cmake --config ${{ matrix.config }} -j3 (cd build-cmake && cpack -G External) wget -O gamecontrollerdb.txt https://raw.githubusercontent.com/mdqinc/SDL_GameControllerDB/master/gamecontrollerdb.txt mv README.md readme.txt mv build-cmake/*.appimage spaghetti.appimage - # - name: Upload build - # uses: actions/upload-artifact@v4 - # with: - # name: Spaghettify-linux - # path: | - # spaghetti.appimage - # config.yml - # yamls - # gamecontrollerdb.txt build-linux-old: needs: generate-port-o2r runs-on: ubuntu-22.04 + strategy: + matrix: + config: [Release, Debug] steps: - uses: actions/checkout@v4 with: @@ -292,16 +297,17 @@ jobs: path: ./build-cmake - name: Build run: | - cmake -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE=Release - cmake --build build-cmake --config Release -j3 + cmake -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.config }} + cmake --build build-cmake --config ${{ matrix.config }} -j3 (cd build-cmake && cpack -G External) wget -O gamecontrollerdb.txt https://raw.githubusercontent.com/mdqinc/SDL_GameControllerDB/master/gamecontrollerdb.txt mv README.md readme.txt mv build-cmake/*.appimage spaghetti.appimage - name: Upload build + if: matrix.config == 'Release' uses: actions/upload-artifact@v4 with: - name: Spaghettify-linux + name: spaghetti-linux-x64 path: | spaghetti.appimage config.yml @@ -311,6 +317,9 @@ jobs: build-linux-docker: needs: generate-port-o2r runs-on: ubuntu-22.04 + strategy: + matrix: + config: [Release, Debug] steps: - uses: actions/checkout@v4 with: @@ -327,13 +336,16 @@ jobs: if: steps.cache.outputs.cache-hit != 'true' run: docker build . -t spaghetti - name: Confiure - run: docker run --rm -v ${PWD}:/project spaghetti cmake -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE=Release + run: docker run --rm -v ${PWD}:/project spaghetti cmake -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.config }} - name: Build spaghetti - run: docker run --rm -v ${PWD}:/project spaghetti cmake --build build-cmake --config Release -j$(nproc) + run: docker run --rm -v ${PWD}:/project spaghetti cmake --build build-cmake --config ${{ matrix.config }} -j$(nproc) build-switch: needs: generate-port-o2r runs-on: ubuntu-latest + strategy: + matrix: + config: [Release, Debug] container: image: devkitpro/devkita64:20241023 steps: @@ -361,12 +373,13 @@ jobs: make sudo make install cd ../.. - cmake -H. -Bbuild-switch -GNinja -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Switch.cmake - cmake --build build-switch --config Release -j3 + # cmake -H. -Bbuild-switch -GNinja -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Switch.cmake -DCMAKE_BUILD_TYPE=${{ matrix.config }} + cmake --build build-switch --config ${{ matrix.config }} -j3 wget -O gamecontrollerdb.txt https://raw.githubusercontent.com/mdqinc/SDL_GameControllerDB/master/gamecontrollerdb.txt mv README.md readme.txt mv build-switch/*.nro Spaghettify.nro - name: Upload build + if: matrix.config == 'Release' uses: actions/upload-artifact@v4 with: name: Spaghettify-switch diff --git a/.github/workflows/windows-compile.yml b/.github/workflows/windows-compile.yml index bbaee328b..42258ec9c 100644 --- a/.github/workflows/windows-compile.yml +++ b/.github/workflows/windows-compile.yml @@ -7,6 +7,9 @@ on: jobs: build: runs-on: windows-2022 + strategy: + matrix: + config: [Release, Debug] steps: - uses: actions/checkout@v4 with: @@ -15,11 +18,11 @@ jobs: submodules: recursive - name: Build run: | - cmake -S . -B "build/x64" -G "Visual Studio 17 2022" -T v143 -A x64 -DCMAKE_BUILD_TYPE=Release - cmake --build ./build/x64 + cmake -S . -B "build/x64" -G "Visual Studio 17 2022" -T v143 -A x64 -DCMAKE_BUILD_TYPE=${{ matrix.config }} + cmake --build ./build/x64 --config ${{ matrix.config }} --parallel 10 - name: Upload build uses: actions/upload-artifact@v4 with: - name: spaghetti-windows - path: ./build/x64/Debug + name: spaghetti-windows-${{ matrix.config }} + path: ./build/x64/${{ matrix.config }} retention-days: 1 diff --git a/CMakeLists.txt b/CMakeLists.txt index 00221a581..88b475807 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,19 +121,42 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows") endif() endif() +################################################################################ +# Compiler specific configuration types +################################################################################ +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|AppleClang") + set(COMMON_FLAGS "-Wall -Wextra -Wno-error \ + -Wno-return-type \ + -Wno-unused-parameter \ + -Wno-unused-function \ + -Wno-unused-variable \ + -Wno-missing-field-initializers \ + -Wno-parentheses \ + -Wno-narrowing \ + -Wno-missing-braces \ + -ffast-math \ + -flto=auto \ + -pipe" + ) + + set(COMMON_C_FLAGS "${COMMON_FLAGS} -Wno-int-conversion -Werror-implicit-function-declaration -Wno-incompatible-pointer-types") + set(COMMON_CXX_FLAGS "${COMMON_FLAGS} -Wno-c++11-narrowing -Wno-deprecated-enum-enum-conversion -fpermissive -fomit-frame-pointer") +elseif (MSVC) + set(COMMON_FLAGS "/fp:fast") + set(COMMON_C_FLAGS "${COMMON_FLAGS}") + set(COMMON_CXX_FLAGS "${COMMON_FLAGS}") +else() + set(COMMON_C_FLAGS "") + set(COMMON_CXX_FLAGS "") +endif() + ################################################################################ # Global configuration types ################################################################################ -if (CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch") -set(CMAKE_C_FLAGS_DEBUG "-g -ffast-math -DDEBUG") -set(CMAKE_CXX_FLAGS_DEBUG "-g -ffast-math -DDEBUG") -set(CMAKE_C_FLAGS_RELEASE "-O3 -ffast-math -DNDEBUG") -set(CMAKE_CXX_FLAGS_RELEASE "-O3 -ffast-math -DNDEBUG") -else() -set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG") -set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") -set(CMAKE_OBJCXX_FLAGS_RELEASE "-O2 -DNDEBUG") -endif() +set(CMAKE_C_FLAGS_DEBUG "-g -DNDEBUG ${COMMON_C_FLAGS}") +set(CMAKE_CXX_FLAGS_DEBUG "-g -DNDEBUG ${COMMON_CXX_FLAGS}") +set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG ${COMMON_C_FLAGS}") +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG ${COMMON_CXX_FLAGS}") # Set game compilation version set(VERSION us) @@ -583,26 +606,6 @@ endif() if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS") target_compile_options(${PROJECT_NAME} PRIVATE - -Wall -Wextra -Wno-error - -Wno-return-type - -Wno-unused-parameter - -Wno-unused-function - -Wno-unused-variable - -Wno-missing-field-initializers - -Wno-parentheses - -Wno-narrowing - -Wno-missing-braces - -Wno-int-conversion - $<$: - -Werror-implicit-function-declaration - -Wno-incompatible-pointer-types - -fpermissive - > - $<$:-fpermissive> - $<$: - -Wno-c++11-narrowing - -Wno-deprecated-enum-enum-conversion - > -pthread ) @@ -611,76 +614,20 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") ) elseif (CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch") target_compile_options(${PROJECT_NAME} PRIVATE - -Wall -Wextra -Wno-error - -Wno-return-type - -Wno-unused-parameter - -Wno-unused-function - -Wno-unused-variable - -Wno-missing-field-initializers - -Wno-parentheses - -Wno-narrowing - -Wno-missing-braces - -Wno-int-conversion - $<$: - -Werror-implicit-function-declaration - -Wno-incompatible-pointer-types - -fpermissive - > - $<$:-fpermissive> - $<$: - -Wno-c++11-narrowing - -Wno-deprecated-enum-enum-conversion - > -pthread ) target_link_options(${PROJECT_NAME} PRIVATE -pthread ) - elseif (CMAKE_SYSTEM_NAME STREQUAL "CafeOS") - target_compile_options(${PROJECT_NAME} PRIVATE - -O2 - - # disable some warnings to not clutter output - -Wno-multichar - -Wno-return-type - -Wno-narrowing - -Wno-switch-outside-range - $<$: - -Werror-implicit-function-declaration - -Wno-incompatible-pointer-types - -Wno-discarded-array-qualifiers - -Wno-discarded-qualifiers - -Wno-int-conversion - -Wno-builtin-declaration-mismatch - -Wno-switch-unreachable - -Wno-stringop-overflow - > - ) - else() + elseif (NOT CMAKE_SYSTEM_NAME STREQUAL "CafeOS") if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") - set(CPU_OPTION -msse2 -mfpmath=sse) + set(CPU_OPTION -msse2 -mfpmath=sse) endif() target_compile_options(${PROJECT_NAME} PRIVATE - -Wall -Wextra -Wno-error - -Wno-unused-parameter - -Wno-unused-function - -Wno-unused-variable - -Wno-missing-field-initializers - -Wno-parentheses - -Wno-narrowing - -Wno-missing-braces - -Wno-int-conversion - $<$: - -Werror-implicit-function-declaration - -Wno-incompatible-pointer-types - -fpermissive - > - $<$:-fpermissive> - $<$:-Wno-deprecated-enum-enum-conversion> -pthread - ${CPU_OPTION} + ${CPU_OPTION} ) target_link_options(${PROJECT_NAME} PRIVATE diff --git a/README.md b/README.md index 067d1b8e7..7d0addec5 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ If you want to manually compile SpaghettiKart, please consult the [building inst If you want to playtest a continuous integration build, you can find them at the links below. Keep in mind that these are for playtesting only, and you will likely encounter bugs and possibly crashes. * [Windows](https://nightly.link/HarbourMasters/SpaghettiKart/workflows/main/main/spaghetti-windows.zip?status=completed) -* [Linux](https://nightly.link/HarbourMasters/SpaghettiKart/workflows/main/main/Spaghettify-linux.zip?status=completed) +* [Linux](https://nightly.link/HarbourMasters/SpaghettiKart/workflows/main/main/spaghetti-linux-x64.zip?status=completed) * [macOS](https://nightly.link/HarbourMasters/SpaghettiKart/workflows/main/main/spaghetti-mac-x64.zip?status=completed) * [Switch](https://nightly.link/HarbourMasters/SpaghettiKart/workflows/main/main/Spaghettify-switch.zip?status=completed)