Implement github CI for the project

This commit is contained in:
2025-07-22 08:44:39 -04:00
parent 605b3b7c82
commit 86ee748396
2 changed files with 92 additions and 4 deletions

76
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,76 @@
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
name: Build ${{ matrix.os }} - ${{ matrix.build_type }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
build_type: [Debug, Release]
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Set up cache
uses: actions/cache@v4
with:
path: |
build/_deps
~/.cache
~/AppData/Local/vcpkg/archives
key: ${{ runner.os }}-cmake-${{ matrix.build_type }}-${{ hashFiles('**/CMakeLists.txt') }}
restore-keys: |
${{ runner.os }}-cmake-${{ matrix.build_type }}
- name: Install dependencies (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt update
sudo apt install -y cmake build-essential libsdl2-dev
- name: Install dependencies (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install cmake sdl2
- name: Install dependencies (Windows)
if: matrix.os == 'windows-latest'
run: |
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' --yes
vcpkg install sdl2
shell: bash
- name: Configure CMake
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
env:
CMAKE_TOOLCHAIN_FILE: ${{ matrix.os == 'windows-latest' && 'C:/vcpkg/scripts/buildsystems/vcpkg.cmake' || '' }}
- name: Build
run: cmake --build build --config ${{ matrix.build_type }}
- name: Package
run: |
cd build
cpack
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: breadedSNES-${{ matrix.os }}-${{ matrix.build_type }}
path: |
build/*.zip
build/*.dmg
build/*.tar.gz
build/*.tgz
build/*.exe
build/*.7z

View File

@@ -7,6 +7,11 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "")
endif()
# Platform-specific settings
if(WIN32)
add_definitions(-DWIN32_LEAN_AND_MEAN)
@@ -19,7 +24,7 @@ elseif(UNIX)
endif()
# Find SDL2
if(WIN32)
if(WIN32 AND NOT DEFINED ENV{VCPKG_ROOT})
# Windows things
set(SDL2_DIR "C:/SDL2" CACHE PATH "/path/to/sdl2") # Do this later when I have access to a Windows machine
find_package(SDL2 REQUIRED CONFIG)
@@ -41,11 +46,14 @@ elseif(APPLE)
find_package(SDL2 REQUIRED CONFIG)
message(STATUS "Found SDL2 at: ${SDL2_DIR}")
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(SDL2 REQUIRED sdl2)
elseif(UNIX)
if(NOT SDL2_FOUND)
find_package(PkgConfig REQUIRED)
pkg_check_modules(SDL2 REQUIRED sdl2)
endif()
endif()
add_executable(breadedSNES
src/main.cpp
src/cpu.cpp
@@ -60,6 +68,10 @@ add_executable(breadedSNES
src/ppu.h
)
if(SDL2_FOUND)
include_directories(${SDL2_INCLUDE_DIRS})
endif()
target_include_directories(breadedSNES PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${SDL2_INCLUDE_DIRS}