Implement github CI for the project
This commit is contained in:
76
.github/workflows/ci.yml
vendored
Normal file
76
.github/workflows/ci.yml
vendored
Normal 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
|
||||||
@@ -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_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0")
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
|
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
|
# Platform-specific settings
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
||||||
@@ -19,7 +24,7 @@ elseif(UNIX)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Find SDL2
|
# Find SDL2
|
||||||
if(WIN32)
|
if(WIN32 AND NOT DEFINED ENV{VCPKG_ROOT})
|
||||||
# Windows things
|
# Windows things
|
||||||
set(SDL2_DIR "C:/SDL2" CACHE PATH "/path/to/sdl2") # Do this later when I have access to a Windows machine
|
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)
|
find_package(SDL2 REQUIRED CONFIG)
|
||||||
@@ -41,11 +46,14 @@ elseif(APPLE)
|
|||||||
find_package(SDL2 REQUIRED CONFIG)
|
find_package(SDL2 REQUIRED CONFIG)
|
||||||
|
|
||||||
message(STATUS "Found SDL2 at: ${SDL2_DIR}")
|
message(STATUS "Found SDL2 at: ${SDL2_DIR}")
|
||||||
else()
|
elseif(UNIX)
|
||||||
find_package(PkgConfig REQUIRED)
|
if(NOT SDL2_FOUND)
|
||||||
pkg_check_modules(SDL2 REQUIRED sdl2)
|
find_package(PkgConfig REQUIRED)
|
||||||
|
pkg_check_modules(SDL2 REQUIRED sdl2)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
add_executable(breadedSNES
|
add_executable(breadedSNES
|
||||||
src/main.cpp
|
src/main.cpp
|
||||||
src/cpu.cpp
|
src/cpu.cpp
|
||||||
@@ -60,6 +68,10 @@ add_executable(breadedSNES
|
|||||||
src/ppu.h
|
src/ppu.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(SDL2_FOUND)
|
||||||
|
include_directories(${SDL2_INCLUDE_DIRS})
|
||||||
|
endif()
|
||||||
|
|
||||||
target_include_directories(breadedSNES PRIVATE
|
target_include_directories(breadedSNES PRIVATE
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
${SDL2_INCLUDE_DIRS}
|
${SDL2_INCLUDE_DIRS}
|
||||||
|
|||||||
Reference in New Issue
Block a user