Skip to content

Commit

Permalink
General cleanup of old stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-johansson committed Jul 14, 2023
1 parent 4d23950 commit 83acd70
Show file tree
Hide file tree
Showing 12 changed files with 125 additions and 1,047 deletions.
209 changes: 22 additions & 187 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ jobs:
brew install cmake
brew install ninja
brew install glfw
brew install sdl2
brew install sdl2_image
brew install sdl2_mixer
brew install sdl2_ttf
- name: Restore Vcpkg artifacts
id: restore-vcpkg-artifacts
Expand Down Expand Up @@ -54,35 +50,20 @@ jobs:
cmake .. -GNinja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_STANDARD=${{matrix.CPP_VERSION}} \
-DBUILD_TESTS=ON \
-DBUILD_EXAMPLES=ON \
-DTREAT_WARNINGS_AS_ERRORS=ON
-DCEN_USE_SYSTEM_DEPS=OFF \
-DCEN_USE_SDL_IMAGE=OFF \
-DCEN_USE_SDL_MIXER=OFF \
-DCEN_USE_SDL_TTF=OFF \
-DCEN_BUILD_TESTS=OFF \
-DCEN_BUILD_EXAMPLES=OFF \
-DCEN_TREAT_WARNINGS_AS_ERRORS=ON
- name: Compile
run: ninja -C build

- name: Run unit tests
working-directory: ./build/test/unit-tests
run: ./centurion-tests

- name: Run mock tests
working-directory: ./build/test/mocked-tests
run: ./centurion-mocks

ubuntu:
runs-on: ubuntu-latest
if: contains(github.event.head_commit.message, '[skip-ci]') == false
strategy:
fail-fast: false
matrix:
SDL_VERSION: [ 2.0.20, 2.0.22, 2.24.0, 2.26.0 ]
TTF_VERSION: [ 2.20.2 ]
IMG_VERSION: [ 2.6.3 ]
MIX_VERSION: [ 2.6.3 ]
CPP_VERSION: [ 20 ]
include:
- { SDL_VERSION: 2.26.0, TTF_VERSION: 2.20.2, IMG_VERSION: 2.6.3, MIX_VERSION: 2.6.3, CPP_VERSION: 17 }
- { SDL_VERSION: 2.26.0, TTF_VERSION: 2.20.2, IMG_VERSION: 2.6.3, MIX_VERSION: 2.6.3, CPP_VERSION: 23 }
env:
VCPKG_ROOT: ${{github.workspace}}/vcpkg
VCPKG_DEFAULT_BINARY_CACHE: ${{github.workspace}}/vcpkg/bincache
Expand Down Expand Up @@ -149,95 +130,6 @@ jobs:
sudo ./vcpkg/vcpkg integrate install
mkdir ${{env.VCPKG_DEFAULT_BINARY_CACHE}}
- name: Restore SDL2
id: restore-sdl2
uses: actions/cache@v3
with:
path: SDL2-${{matrix.SDL_VERSION}}
key: SDL2-${{matrix.SDL_VERSION}}

- name: Build SDL2
if: steps.restore-sdl2.outputs.cache-hit != 'true'
run: |
wget https://www.libsdl.org/release/SDL2-${{matrix.SDL_VERSION}}.tar.gz
tar -xf SDL2-${{matrix.SDL_VERSION}}.tar.gz
rm -rf SDL2-${{matrix.SDL_VERSION}}.tar.gz
cd SDL2-${{matrix.SDL_VERSION}}
./configure
make -j $(nproc)
- name: Install SDL2
run: |
cd SDL2-${{matrix.SDL_VERSION}}
sudo make install
- name: Restore SDL2_image
id: restore-sdl2-image
uses: actions/cache@v3
with:
path: SDL_image-release-${{ matrix.IMG_VERSION }}
key: SDL_image-${{ matrix.IMG_VERSION }}

- name: Build SDL2_image
if: steps.restore-sdl2-image.outputs.cache-hit != 'true'
run: |
wget https://github.com/libsdl-org/SDL_image/archive/refs/tags/release-${{ matrix.IMG_VERSION }}.tar.gz
tar -xf release-${{ matrix.IMG_VERSION }}.tar.gz
rm -rf release-${{ matrix.IMG_VERSION }}.tar.gz
cd SDL_image-release-${{ matrix.IMG_VERSION }}
./configure
make -j $(nproc)
- name: Install SDL2_image
run: |
cd SDL_image-release-${{ matrix.IMG_VERSION }}
sudo make install
- name: Restore SDL2_mixer
id: restore-sdl2-mixer
uses: actions/cache@v3
with:
path: SDL_mixer-release-${{ matrix.MIX_VERSION }}
key: SDL2_mixer-${{ matrix.MIX_VERSION }}

- name: Build SDL2_mixer
if: steps.restore-sdl2-mixer.outputs.cache-hit != 'true'
run: |
wget https://github.com/libsdl-org/SDL_mixer/archive/refs/tags/release-${{ matrix.MIX_VERSION }}.tar.gz
tar -xf release-${{ matrix.MIX_VERSION }}.tar.gz
rm -rf release-${{ matrix.MIX_VERSION }}.tar.gz
cd SDL_mixer-release-${{ matrix.MIX_VERSION }}
./configure
make -j $(nproc)
- name: Install SDL2_mixer
run: |
cd SDL_mixer-release-${{ matrix.MIX_VERSION }}
sudo make install
- name: Restore SDL2_ttf
id: restore-sdl2-ttf
uses: actions/cache@v3
with:
path: SDL_ttf-release-${{ matrix.TTF_VERSION }}
key: SDL2_ttf-${{ matrix.TTF_VERSION }}

- name: Build SDL2_ttf
if: steps.restore-sdl2-ttf.outputs.cache-hit != 'true'
run: |
wget https://github.com/libsdl-org/SDL_ttf/archive/refs/tags/release-${{ matrix.TTF_VERSION }}.tar.gz
tar -xf release-${{ matrix.TTF_VERSION }}.tar.gz
rm -rf release-${{ matrix.TTF_VERSION }}.tar.gz
cd SDL_ttf-release-${{ matrix.TTF_VERSION }}
./autogen.sh
./configure --disable-harfbuzz-builtin --disable-freetype-builtin --without-x
make -j $(nproc)
- name: Install SDL2_ttf
run: |
cd SDL_ttf-release-${{ matrix.TTF_VERSION }}
sudo make install
- name: Emulate video device
run: |
/sbin/start-stop-daemon --start \
Expand All @@ -253,43 +145,20 @@ jobs:
cmake .. -GNinja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_STANDARD=${{matrix.CPP_VERSION}} \
-DBUILD_TESTS=ON \
-DBUILD_EXAMPLES=ON \
-DINCLUDE_AUDIO_TESTS=OFF \
-DTREAT_WARNINGS_AS_ERRORS=ON
-DCEN_USE_SYSTEM_DEPS=OFF \
-DCEN_USE_SDL_IMAGE=OFF \
-DCEN_USE_SDL_MIXER=OFF \
-DCEN_USE_SDL_TTF=OFF \
-DCEN_BUILD_TESTS=OFF \
-DCEN_BUILD_EXAMPLES=OFF \
-DCEN_TREAT_WARNINGS_AS_ERRORS=ON
- name: Compile
run: ninja -C build

- name: Run mocked tests
working-directory: ./build/test/mocked-tests
run: ./centurion-mocks

- name: Run unit tests
working-directory: ./build/test/unit-tests
run: ./centurion-tests

windows:
runs-on: windows-latest
if: contains(github.event.head_commit.message, '[skip-ci]') == false
strategy:
fail-fast: false
matrix:
SDL_VERSION: [ 2.24.0, 2.26.0 ]
TTF_VERSION: [ 2.0.18, 2.20.1 ]
IMG_VERSION: [ 2.0.5, 2.6.2 ]
MIX_VERSION: [ 2.6.3 ]
CPP_VERSION: [ 20 ]
include:
- { SDL_VERSION: 2.0.10, TTF_VERSION: 2.0.18, IMG_VERSION: 2.0.5, MIX_VERSION: 2.6.3, CPP_VERSION: 17 }
- { SDL_VERSION: 2.0.12, TTF_VERSION: 2.0.18, IMG_VERSION: 2.0.5, MIX_VERSION: 2.6.3, CPP_VERSION: 17 }
- { SDL_VERSION: 2.0.14, TTF_VERSION: 2.0.18, IMG_VERSION: 2.0.5, MIX_VERSION: 2.6.3, CPP_VERSION: 17 }
- { SDL_VERSION: 2.0.16, TTF_VERSION: 2.0.18, IMG_VERSION: 2.0.5, MIX_VERSION: 2.6.3, CPP_VERSION: 17 }
- { SDL_VERSION: 2.0.18, TTF_VERSION: 2.0.18, IMG_VERSION: 2.0.5, MIX_VERSION: 2.6.3, CPP_VERSION: 17 }
- { SDL_VERSION: 2.0.20, TTF_VERSION: 2.0.18, IMG_VERSION: 2.0.5, MIX_VERSION: 2.6.3, CPP_VERSION: 17 }
- { SDL_VERSION: 2.0.22, TTF_VERSION: 2.0.18, IMG_VERSION: 2.0.5, MIX_VERSION: 2.6.3, CPP_VERSION: 17 }
- { SDL_VERSION: 2.24.0, TTF_VERSION: 2.0.18, IMG_VERSION: 2.0.5, MIX_VERSION: 2.6.3, CPP_VERSION: 20 }
- { SDL_VERSION: 2.26.0, TTF_VERSION: 2.20.1, IMG_VERSION: 2.6.2, MIX_VERSION: 2.6.3, CPP_VERSION: 23 }
env:
VCPKG_ROOT: ${{github.workspace}}/vcpkg
steps:
Expand Down Expand Up @@ -327,54 +196,20 @@ jobs:
.\vcpkg\bootstrap-vcpkg.bat -disableMetrics
.\vcpkg\vcpkg integrate install
- name: Download SDL2
uses: albin-johansson/download-sdl2@latest
with:
version: ${{matrix.SDL_VERSION}}
sources_destination: .
binaries_destination: bin

- name: Download SDL2_image
uses: albin-johansson/download-sdl2-image@latest
with:
version: ${{matrix.IMG_VERSION}}
sources_destination: .
binaries_destination: bin

- name: Download SDL2_ttf
uses: albin-johansson/download-sdl2-ttf@latest
with:
version: ${{matrix.TTF_VERSION}}
sources_destination: .
binaries_destination: bin

- name: Download SDL2_mixer
uses: albin-johansson/download-sdl2-mixer@latest
with:
version: ${{matrix.MIX_VERSION}}
sources_destination: .
binaries_destination: bin

- name: Generate build files
env:
SDL2DIR: ${{github.workspace}}/SDL2-${{matrix.SDL_VERSION}}
SDL2IMAGEDIR: ${{github.workspace}}/SDL2_image-${{matrix.IMG_VERSION}}
SDL2MIXERDIR: ${{github.workspace}}/SDL2_mixer-${{matrix.MIX_VERSION}}
SDL2TTFDIR: ${{github.workspace}}/SDL2_ttf-${{matrix.TTF_VERSION}}
run: |
mkdir build
cd build
cmake .. -GNinja `
-DCMAKE_BUILD_TYPE=Debug `
-DCMAKE_CXX_STANDARD=${{matrix.CPP_VERSION}} `
-DBUILD_TESTS=ON `
-DBUILD_EXAMPLES=ON `
-DTREAT_WARNINGS_AS_ERRORS=ON
-DCEN_USE_SYSTEM_DEPS=OFF `
-DCEN_USE_SDL_IMAGE=OFF `
-DCEN_USE_SDL_MIXER=OFF `
-DCEN_USE_SDL_TTF=OFF `
-DCEN_BUILD_TESTS=OFF `
-DCEN_BUILD_EXAMPLES=OFF `
-DCEN_TREAT_WARNINGS_AS_ERRORS=ON
- name: Compile
run: ninja -C build

- name: Run mocked tests
shell: cmd
working-directory: ./build/test/mocked-tests
run: centurion-mocks
run: ninja -C build
102 changes: 68 additions & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,87 @@ if (DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
endif ()

project(centurion
VERSION 7.3.0
VERSION 8.0.0
HOMEPAGE_URL "https://github.com/albin-johansson/centurion"
LANGUAGES CXX)

if ("${CMAKE_CXX_STANDARD}" STREQUAL "")
set(CMAKE_CXX_STANDARD 17)
endif ()

set(CXX_STANDARD_REQUIRED ON)
set(CXX_EXTENSIONS OFF)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

# Build options
option(BUILD_TESTS "Build the test suite" OFF)
option(BUILD_EXAMPLES "Build the examples" OFF)
option(INCLUDE_AUDIO_TESTS "Test audio components" ON)
option(TREAT_WARNINGS_AS_ERRORS "Treat compiler warnings as errors" OFF)

include(cmake/centurion.cmake)
# Build configuration
option(CEN_USE_SYSTEM_DEPS "Use SDL libraries installed on system" ON)
option(CEN_USE_SDL_IMAGE "Enable APIs dependent on the SDL_image library" OFF)
option(CEN_USE_SDL_MIXER "Enable APIs dependent on the SDL_mixer library" OFF)
option(CEN_USE_SDL_TTF "Enable APIs dependent on the SDL_ttf library" OFF)
option(CEN_BUILD_EXAMPLES "Build the examples" OFF)
option(CEN_BUILD_TESTS "Build the test suite" OFF)
option(CEN_INCLUDE_AUDIO_TESTS "Test audio components" ON)
option(CEN_TREAT_WARNINGS_AS_ERRORS "Treat compiler warnings as errors" OFF)

# Directories
set(CEN_ROOT_DIR "${PROJECT_SOURCE_DIR}")
set(CEN_RESOURCES_DIR "${PROJECT_SOURCE_DIR}/test/resources")
set(CEN_SOURCE_DIR "${PROJECT_SOURCE_DIR}/src")
set(CEN_BINARIES_DIR "${PROJECT_SOURCE_DIR}/bin")
set(CEN_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/src")
set(CEN_EXTERNAL_DIR "${PROJECT_SOURCE_DIR}/external")

# Target names
set(CENTURION_LIB_TARGET libcenturion)
set(CENTURION_TEST_TARGET centurion-tests)
set(CENTURION_MOCK_TARGET centurion-mocks)
function(cen_prepare_target target)
set_target_properties(${target}
PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)

if (CEN_USE_SDL_IMAGE MATCHES OFF)
target_compile_definitions(${target} PRIVATE CENTURION_NO_SDL_IMAGE)
endif ()

if (CEN_USE_SDL_MIXER MATCHES OFF)
target_compile_definitions(${target} PRIVATE CENTURION_NO_SDL_MIXER)
endif ()

# System dependencies
find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
find_package(SDL2_mixer REQUIRED)
find_package(SDL2_ttf REQUIRED)
if (CEN_USE_SDL_TTF MATCHES OFF)
target_compile_definitions(${target} PRIVATE CENTURION_NO_SDL_TTF)
endif ()

if (BUILD_TESTS)
# Vcpkg test dependencies
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(${target}
PRIVATE
/EHsc
/MP
/W4
/Zc:preprocessor # Enable conforming preprocessor
/Zc:__cplusplus # Force MSVC to use __cplusplus macro with correct value
/wd4996 # Disable deprecation warnings
)

if (CEN_TREAT_WARNINGS_AS_ERRORS MATCHES ON)
target_compile_options(${target} PRIVATE /WX)
endif ()
else ()
target_compile_options(${target} PRIVATE
-Wall
-Wextra
-Wpedantic
-Wconversion
-Wno-deprecated
-Wno-deprecated-declarations
-Wno-format-security
)

if (CEN_TREAT_WARNINGS_AS_ERRORS MATCHES ON)
target_compile_options(${target} PRIVATE -Werror)
endif ()
endif ()
endfunction()

if (CEN_USE_SYSTEM_DEPS MATCHES ON)
# TODO
else ()
add_subdirectory(external/SDL)
endif ()

if (CEN_BUILD_TESTS MATCHES ON)
find_package(GTest CONFIG REQUIRED)
find_package(cereal CONFIG REQUIRED)
find_package(GLEW REQUIRED)

add_subdirectory(test)
# add_subdirectory(test)
endif ()

if (BUILD_EXAMPLES)
add_subdirectory(examples)
if (CEN_BUILD_EXAMPLES MATCHES ON)
endif ()
Loading

0 comments on commit 83acd70

Please sign in to comment.