Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Linux

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build-and-test:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
# Linux with GCC
- name: "Linux GCC"
compiler: gcc
cmake-generator: 'Ninja'
cmake-options: '-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++'

# Linux with Clang
- name: "Linux Clang"
compiler: clang
cmake-generator: 'Ninja'
cmake-options: '-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++'

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Install ninja-build
run: |
sudo apt-get update
sudo apt-get install -y ninja-build
shell: bash

- name: Configure CMake
run: |
cmake -B build -G "${{ matrix.cmake-generator }}" ${{ matrix.cmake-options }}

- name: Build
run: |
cmake --build build --config Release

- name: Run tests
working-directory: build
run: |
./tests/all_tests
shell: bash
46 changes: 46 additions & 0 deletions .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: macOS

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build-and-test:
name: ${{ matrix.name }}
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
include:
# macOS with Apple Clang
- name: "macOS Clang"
compiler: clang
cmake-generator: 'Ninja'
cmake-options: ''

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Install ninja-build
run: |
brew install ninja
shell: bash

- name: Configure CMake
run: |
cmake -B build -G "${{ matrix.cmake-generator }}" ${{ matrix.cmake-options }}

- name: Build
run: |
cmake --build build --config Release

- name: Run tests
working-directory: build
run: |
./tests/all_tests
shell: bash
71 changes: 71 additions & 0 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Windows

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build-and-test:
name: ${{ matrix.name }}
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include:
# Windows with MSVC
- name: "Windows MSVC"
compiler: msvc
cmake-generator: 'Visual Studio 17 2022'
cmake-options: ''

# Windows with MinGW (GCC)
- name: "Windows MinGW"
compiler: gcc
cmake-generator: 'MinGW Makefiles'
cmake-options: '-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++'

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Install Windows build tools
if: matrix.compiler != 'msvc'
run: |
if [ "${{ matrix.compiler }}" == "clang" ]; then
choco install ninja
elif [ "${{ matrix.compiler }}" == "gcc" ]; then
choco install mingw
fi
shell: bash

- name: Configure CMake
run: |
cmake -B build -G "${{ matrix.cmake-generator }}" ${{ matrix.cmake-options }}

- name: Build
run: |
cmake --build build --config Release

- name: Run tests
working-directory: build
run: |
if [ "${{ matrix.compiler }}" == "gcc" ]; then
# For MinGW - copy DLLs directly (no PATH manipulation)
GCC_DIR=$(dirname $(which gcc))
echo "GCC directory: $GCC_DIR"
echo "Copying DLLs from $GCC_DIR"
cp "$GCC_DIR"/libgcc*.dll tests/ 2>/dev/null || echo "No libgcc DLLs found"
cp "$GCC_DIR"/libstdc*.dll tests/ 2>/dev/null || echo "No libstdc DLLs found"
cp "$GCC_DIR"/libwinpthread*.dll tests/ 2>/dev/null || echo "No libwinpthread DLLs found"
echo "Running tests"
cd tests
./all_tests.exe
else # MSVC
echo "Running tests"
./tests/Release/all_tests.exe
fi
shell: bash
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/
.vscode/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "external/cryptopp-cmake"]
path = external/cryptopp-cmake
url = https://github.com/abdes/cryptopp-cmake.git
61 changes: 61 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
cmake_minimum_required(VERSION 3.14)
project(datacoe)

# Debug mode, feel free to modify to your desire
set(CMAKE_BUILD_TYPE Debug)
if(MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "/Zi /DEBUG")
set(CMAKE_C_FLAGS_DEBUG "/Zi /DEBUG")
else()
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_C_FLAGS_DEBUG "-g")
endif()

include(FetchContent)

# Currently fetching googletest v1.16.0,
# Feel free to upgrade and change the URL into the <commit hash>.zip file you would like to upgrade
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/6910c9d9165801d8827d628cb72eb7ea9dd538c5.zip
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
if(WIN32)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
endif()
FetchContent_MakeAvailable(googletest)

add_subdirectory(external/cryptopp-cmake)

# Currently fetching nlohmann/json v3.11.3,
# Feel free to upgrade to your desired version.
FetchContent_Declare(
json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.11.3
)
FetchContent_MakeAvailable(json)

add_subdirectory(tests)

add_library(${PROJECT_NAME}
src/game_data.cpp
src/data_reader_writer.cpp
src/data_manager.cpp
)

target_link_libraries(${PROJECT_NAME} PRIVATE cryptopp)

target_include_directories(${PROJECT_NAME} PUBLIC
${CMAKE_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/cryptopp-cmake
${json_SOURCE_DIR}/single_include/nlohmann)

set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17)

# "Treat warnings as errors" behavior, Feel free to remove/modify it.
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Werror)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(${PROJECT_NAME} PRIVATE /W3 /WX)
endif()
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2025 Nir Cohen Hershkovitz
Copyright (c) 2025 Nir Cohen Hershkovitz (@nircoe)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading
Loading