From 064bd2fbfae73fccf50d3b6ff05b27996d1c5fce Mon Sep 17 00:00:00 2001 From: Ecrin Date: Tue, 21 Jan 2025 18:37:09 +0300 Subject: [PATCH 1/9] Create c-cpp.yml --- .github/workflows/c-cpp.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/c-cpp.yml diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml new file mode 100644 index 0000000..6a9c312 --- /dev/null +++ b/.github/workflows/c-cpp.yml @@ -0,0 +1,23 @@ +name: C/C++ CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: configure + run: ./configure + - name: make + run: make + - name: make check + run: make check + - name: make distcheck + run: make distcheck From 4fa6b700c1afd1c37f397a7b398cd43ff9ceef11 Mon Sep 17 00:00:00 2001 From: ecrinyildiz Date: Fri, 24 Jan 2025 12:15:59 +0300 Subject: [PATCH 2/9] [~] Enhance CI workflow: Add dependencies and caching mechanism - Add SDL2 dependencies installation and caching, update CMake minimum version, and improve README with local testing instructions - Add `sudo` superuser privelege --- .github/workflows/c-cpp.yml | 71 ++++++++++++++++++++++++++++++------- CMakeLists.txt | 2 +- README.md | 10 ++++++ 3 files changed, 70 insertions(+), 13 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 6a9c312..edeff46 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -2,22 +2,69 @@ name: C/C++ CI on: push: - branches: [ "main" ] + branches: + - main pull_request: - branches: [ "main" ] + branches: + - main jobs: build: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: configure - run: ./configure - - name: make - run: make - - name: make check - run: make check - - name: make distcheck - run: make distcheck + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Restore SDL2 Cache + uses: actions/cache@v3 + with: + path: dependencies + key: sdl2-${{ runner.os }}-${{ hashFiles('**/CMakeLists.txt') }} + restore-keys: | + sdl2-${{ runner.os }}- + + - name: Install Base Dependencies + run: | + sudo apt-get update + sudo apt-get install -y software-properties-common build-essential cmake make wget + + - name: Install SDL2 Mixer (If Not Cached) + if: steps.cache.outputs.cache-hit != 'true' + run: | + mkdir -p dependencies + cd dependencies + wget https://github.com/libsdl-org/SDL_mixer/releases/download/release-2.8.0/SDL2_mixer-2.8.0.tar.gz + tar -xzf SDL2_mixer-2.8.0.tar.gz + cd SDL2_mixer-2.8.0 + mkdir build && cd build + cmake .. && make && sudo make install + + - name: Install SDL2 TTF (If Not Cached) + if: steps.cache.outputs.cache-hit != 'true' + run: | + mkdir -p dependencies + cd dependencies + wget https://github.com/libsdl-org/SDL_ttf/releases/download/release-2.24.0/SDL2_ttf-2.24.0.tar.gz + tar -xzf SDL2_ttf-2.24.0.tar.gz + cd SDL2_ttf-2.24.0 + mkdir build && cd build + cmake .. && make && sudo make install + + - name: Save SDL2 Cache + if: steps.cache.outputs.cache-hit != 'true' + uses: actions/cache@v3 + with: + path: dependencies + key: sdl2-${{ runner.os }}-${{ hashFiles('**/CMakeLists.txt') }} + + - name: Build Project + run: | + mkdir build + cd build + cmake .. + make + + - name: Run Project + run: | + ./build/project_name diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d50161..2d35ba6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) # Set the project name and version project(engine VERSION 1.0 LANGUAGES CXX) diff --git a/README.md b/README.md index 3acd7ac..c82f924 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,13 @@ You have to install LLVM for formatting your code. Refer to [this](https://llvm. - (**PROBABLY ONLY FOR WSL USERS**)When SDL library tries to popup a textbox or etc. via using xServer over windows, it fails and gets a core dump fail. To fix this, you need to install the correct GUI package for your wsl. It is most probably gets fixed with ```sudo apt install zenity ``` but it may depend on the linux version and distribution you are currently using. For further questions, go and search it on Google, Stackoverflow or ask ChatGPT. Don't bother me. - In systems other than Ubuntu 22.04LTS, some building problems might occur (for example, i could not build Logger class because i had to include each C++ standard library by hand, such as **`#include `** **`#include `**). If you know how to fix it, please feel free to contribute to this file. + + +### ** Test `Action` on local +In order to test the project on local computer before you push, you can use [`act`](https://github.com/nektos/act) module. This module uses the Docker API to either pull or build the necessary images, as defined in your workflow files and finally determines the execution path baseed on the dependencies that were defined. +Please look at the [act user guide](https://nektosact.com/) for more documentation. + +```bash +curl -s https://raw.githubusercontent.com/nektos/act/master/install.sh | bash +act .github/workflows/c-cpp.yml +``` From 66c6b68a6070f86c8a97bc448b7b5954901c073a Mon Sep 17 00:00:00 2001 From: ecrinyildiz Date: Fri, 24 Jan 2025 12:26:26 +0300 Subject: [PATCH 3/9] [~] Update ci cd: **Remarks:** No idea what im doing right now. im just trying my best to pass --- .github/workflows/c-cpp.yml | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index edeff46..d94ca99 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -16,21 +16,13 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 - - name: Restore SDL2 Cache - uses: actions/cache@v3 - with: - path: dependencies - key: sdl2-${{ runner.os }}-${{ hashFiles('**/CMakeLists.txt') }} - restore-keys: | - sdl2-${{ runner.os }}- - - name: Install Base Dependencies run: | sudo apt-get update - sudo apt-get install -y software-properties-common build-essential cmake make wget + sudo apt-get install -y software-properties-common build-essential cmake make wget \ + libsdl2-dev - - name: Install SDL2 Mixer (If Not Cached) - if: steps.cache.outputs.cache-hit != 'true' + - name: Install SDL2 Mixer run: | mkdir -p dependencies cd dependencies @@ -38,10 +30,9 @@ jobs: tar -xzf SDL2_mixer-2.8.0.tar.gz cd SDL2_mixer-2.8.0 mkdir build && cd build - cmake .. && make && sudo make install + cmake -DSDL2_DIR=/usr/lib/x86_64-linux-gnu/cmake/SDL2 .. && make && sudo make install - - name: Install SDL2 TTF (If Not Cached) - if: steps.cache.outputs.cache-hit != 'true' + - name: Install SDL2 TTF run: | mkdir -p dependencies cd dependencies @@ -49,14 +40,7 @@ jobs: tar -xzf SDL2_ttf-2.24.0.tar.gz cd SDL2_ttf-2.24.0 mkdir build && cd build - cmake .. && make && sudo make install - - - name: Save SDL2 Cache - if: steps.cache.outputs.cache-hit != 'true' - uses: actions/cache@v3 - with: - path: dependencies - key: sdl2-${{ runner.os }}-${{ hashFiles('**/CMakeLists.txt') }} + cmake -DSDL2_DIR=/usr/lib/x86_64-linux-gnu/cmake/SDL2 .. && make && sudo make install - name: Build Project run: | From 49d070761fa76fc8e9274525606095d77543b932 Mon Sep 17 00:00:00 2001 From: ecrinyildiz Date: Fri, 24 Jan 2025 12:40:59 +0300 Subject: [PATCH 4/9] Update CI workflow: Upgrade to Ubuntu 22.04 and enhance dependency installation --- .github/workflows/c-cpp.yml | 48 +++++++++++++------------------------ 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index d94ca99..277e898 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -10,45 +10,31 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Checkout Code uses: actions/checkout@v4 - - name: Install Base Dependencies + - name: Install GCC 11.4.0 and Base Dependencies run: | sudo apt-get update - sudo apt-get install -y software-properties-common build-essential cmake make wget \ - libsdl2-dev - - - name: Install SDL2 Mixer - run: | - mkdir -p dependencies - cd dependencies - wget https://github.com/libsdl-org/SDL_mixer/releases/download/release-2.8.0/SDL2_mixer-2.8.0.tar.gz - tar -xzf SDL2_mixer-2.8.0.tar.gz - cd SDL2_mixer-2.8.0 - mkdir build && cd build - cmake -DSDL2_DIR=/usr/lib/x86_64-linux-gnu/cmake/SDL2 .. && make && sudo make install - - - name: Install SDL2 TTF - run: | - mkdir -p dependencies - cd dependencies - wget https://github.com/libsdl-org/SDL_ttf/releases/download/release-2.24.0/SDL2_ttf-2.24.0.tar.gz - tar -xzf SDL2_ttf-2.24.0.tar.gz - cd SDL2_ttf-2.24.0 - mkdir build && cd build - cmake -DSDL2_DIR=/usr/lib/x86_64-linux-gnu/cmake/SDL2 .. && make && sudo make install + sudo apt-get install -y software-properties-common wget \ + build-essential cmake make libopusfile-dev + sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test + sudo apt-get update + sudo apt-get install -y gcc-11 g++-11 + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 11 + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 11 + gcc --version - - name: Build Project + - name: Install **`SDL`** Dependency run: | - mkdir build - cd build - cmake .. - make + sudo apt-get update && sudo apt-get upgrade -y + sudo apt-cache search libsdl2 && sudo apt-get install libsdl2-dev -y - - name: Run Project + - name: Install **`SDL Mixer`** Dependency run: | - ./build/project_name + sudo apt-get update && sudo apt-get upgrade -y + sudo apt install libopusfile-dev && sudo apt install libxmp-dev && sudo apt install fluidsynth libfluidsynth-dev && sudo apt install wavpack libwavpack-dev + sudo apt-cache search libsdl2-mixer && sudo apt-get install libsdl2-mixer-dev -y From dd7e387eb47fdafc10c3083f87c5981d8f44c5a8 Mon Sep 17 00:00:00 2001 From: ecrinyildiz Date: Fri, 24 Jan 2025 12:47:36 +0300 Subject: [PATCH 5/9] Enhance CI workflow: Add SDL, SDL Mixer, and SDL2 TTF dependencies installation --- .github/workflows/c-cpp.yml | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 277e898..bd5207f 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -28,13 +28,33 @@ jobs: sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 11 gcc --version - - name: Install **`SDL`** Dependency + - name: Install SDL Dependency run: | sudo apt-get update && sudo apt-get upgrade -y sudo apt-cache search libsdl2 && sudo apt-get install libsdl2-dev -y - - name: Install **`SDL Mixer`** Dependency + - name: Install SDL Mixer Dependency run: | sudo apt-get update && sudo apt-get upgrade -y - sudo apt install libopusfile-dev && sudo apt install libxmp-dev && sudo apt install fluidsynth libfluidsynth-dev && sudo apt install wavpack libwavpack-dev - sudo apt-cache search libsdl2-mixer && sudo apt-get install libsdl2-mixer-dev -y + # Install dependencies required for SDL2 Mixer + sudo apt-get install -y libopusfile-dev libxmp-dev fluidsynth libfluidsynth-dev wavpack libwavpack-dev + # Install SDL2 Mixer library + sudo apt-cache search libsdl2-mixer + sudo apt-get install -y libsdl2-mixer-dev + + - name: Install SDL2 TTF Dependency + run: | + # Update and install base dependencies + sudo apt-get update && sudo apt-get upgrade -y + sudo apt-get install -y libfreetype6-dev + + # Download and build SDL2 TTF version 2.24.0 + mkdir -p dependencies + cd dependencies + wget https://github.com/libsdl-org/SDL_ttf/releases/download/release-2.24.0/SDL2_ttf-2.24.0.tar.gz + tar -xzf SDL2_ttf-2.24.0.tar.gz + cd SDL2_ttf-2.24.0 + mkdir build && cd build + cmake .. + make + sudo make install From 552eb46af560d84a8750fc9331f3a7b7314e0c9e Mon Sep 17 00:00:00 2001 From: ecrinyildiz Date: Fri, 24 Jan 2025 13:14:41 +0300 Subject: [PATCH 6/9] Enhance CI workflow: Add build and test steps to the c-cpp.yml --- .github/workflows/c-cpp.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index bd5207f..36b7ba5 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -58,3 +58,12 @@ jobs: cmake .. make sudo make install + + - name: Build Project + run: | + mkdir -p build + ./scripts/clean_build.sh + + - name: Run Tests + run: | + # ./scripts/run_tests.sh From a41dcfc192a7ce6304eac994519707c690dde55b Mon Sep 17 00:00:00 2001 From: ecrinyildiz Date: Fri, 24 Jan 2025 13:19:17 +0300 Subject: [PATCH 7/9] Enhance CI workflow: Refactor installation steps and improve dependency management in c-cpp.yml --- .github/workflows/c-cpp.yml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 36b7ba5..0c93105 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -13,14 +13,16 @@ jobs: runs-on: ubuntu-22.04 steps: + # Step 1: Checkout Code - name: Checkout Code uses: actions/checkout@v4 + # Step 2: Install GCC 11.4.0 and Base Dependencies - name: Install GCC 11.4.0 and Base Dependencies run: | sudo apt-get update sudo apt-get install -y software-properties-common wget \ - build-essential cmake make libopusfile-dev + build-essential cmake make sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install -y gcc-11 g++-11 @@ -28,27 +30,23 @@ jobs: sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 11 gcc --version - - name: Install SDL Dependency + # Step 3: Install SDL2 + - name: Install SDL2 Dependency run: | - sudo apt-get update && sudo apt-get upgrade -y - sudo apt-cache search libsdl2 && sudo apt-get install libsdl2-dev -y + sudo apt-get update && sudo apt-get install -y libsdl2-dev + # Step 4: Install SDL2 Mixer - name: Install SDL Mixer Dependency run: | - sudo apt-get update && sudo apt-get upgrade -y - # Install dependencies required for SDL2 Mixer - sudo apt-get install -y libopusfile-dev libxmp-dev fluidsynth libfluidsynth-dev wavpack libwavpack-dev - # Install SDL2 Mixer library - sudo apt-cache search libsdl2-mixer - sudo apt-get install -y libsdl2-mixer-dev + sudo apt-get update + sudo apt-get install -y libopusfile-dev libxmp-dev fluidsynth libfluidsynth-dev \ + wavpack libwavpack-dev libsdl2-mixer-dev + # Step 5: Install SDL2 TTF - name: Install SDL2 TTF Dependency run: | - # Update and install base dependencies - sudo apt-get update && sudo apt-get upgrade -y + sudo apt-get update sudo apt-get install -y libfreetype6-dev - - # Download and build SDL2 TTF version 2.24.0 mkdir -p dependencies cd dependencies wget https://github.com/libsdl-org/SDL_ttf/releases/download/release-2.24.0/SDL2_ttf-2.24.0.tar.gz @@ -59,11 +57,13 @@ jobs: make sudo make install + # Step 6: Build Project - name: Build Project run: | mkdir -p build ./scripts/clean_build.sh - - name: Run Tests - run: | - # ./scripts/run_tests.sh + # # Step 7: Run Tests + # - name: Run Tests + # run: | + # ./scripts/run_tests.sh From 9abfbe615d144181b325ec10429dfdcb025f1e21 Mon Sep 17 00:00:00 2001 From: ecrinyildiz Date: Fri, 24 Jan 2025 13:21:36 +0300 Subject: [PATCH 8/9] Enhance CI workflow: Update build steps to use CMake and make in c-cpp.yml --- .github/workflows/c-cpp.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 0c93105..8e2d0c5 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -61,7 +61,9 @@ jobs: - name: Build Project run: | mkdir -p build - ./scripts/clean_build.sh + cd build + cmake -DSDL2_mixer_DIR=/usr/lib/x86_64-linux-gnu/cmake/SDL2_mixer .. + make # # Step 7: Run Tests # - name: Run Tests From a492324e9f5dbdcebcc6db3c8c89ce4a11d83464 Mon Sep 17 00:00:00 2001 From: Erinc Yildiz Date: Sun, 15 Mar 2026 16:10:18 +0300 Subject: [PATCH 9/9] [+] Includes: Update necessary includes to make the program compile with different compiler flags. --- include/CollisionManager.hpp | 2 ++ include/Logger.hpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/CollisionManager.hpp b/include/CollisionManager.hpp index 032b111..5e7de9c 100644 --- a/include/CollisionManager.hpp +++ b/include/CollisionManager.hpp @@ -6,6 +6,8 @@ #include #include #include +#include + namespace game::engine { class CollisionManager diff --git a/include/Logger.hpp b/include/Logger.hpp index ac70266..7c015a6 100644 --- a/include/Logger.hpp +++ b/include/Logger.hpp @@ -1,8 +1,10 @@ #pragma once +#include #include #include #include #include +#include namespace utils { class Logger