Skip to content

Commit 58361da

Browse files
committed
Initialize the Repo to working state (#1)
Initialize the repo to working state, including examples, tests, cross-platform CI pipelines, documentation, and more
0 parents  commit 58361da

39 files changed

Lines changed: 2822 additions & 0 deletions

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.github/workflows/ci-linux.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Linux
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build-and-test:
11+
name: ${{ matrix.name }}
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- name: "Linux GCC"
18+
compiler: gcc
19+
cmake-generator: 'Ninja'
20+
cmake-options: '-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++'
21+
22+
- name: "Linux Clang"
23+
compiler: clang
24+
cmake-generator: 'Ninja'
25+
cmake-options: '-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++'
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v3
30+
with:
31+
submodules: 'recursive'
32+
33+
- name: Install ninja-build
34+
run: |
35+
sudo apt-get update
36+
sudo apt-get install -y ninja-build
37+
shell: bash
38+
39+
- name: Configure CMake
40+
run: |
41+
cmake -B build -G "${{ matrix.cmake-generator }}" ${{ matrix.cmake-options }}
42+
shell: bash
43+
44+
- name: Build
45+
run: |
46+
cmake --build build --config Release
47+
shell: bash
48+
49+
- name: Run tests
50+
working-directory: build
51+
run: |
52+
./tests/testcoe_tests
53+
shell: bash

.github/workflows/ci-macos.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: macOS
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build-and-test:
11+
name: ${{ matrix.name }}
12+
runs-on: macos-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- name: "macOS Clang"
18+
compiler: clang
19+
cmake-generator: 'Ninja'
20+
cmake-options: ''
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v3
25+
with:
26+
submodules: 'recursive'
27+
28+
- name: Install ninja-build
29+
run: |
30+
brew install ninja
31+
shell: bash
32+
33+
- name: Configure CMake
34+
run: |
35+
cmake -B build -G "${{ matrix.cmake-generator }}" ${{ matrix.cmake-options }}
36+
shell: bash
37+
38+
- name: Build
39+
run: |
40+
cmake --build build --config Release
41+
shell: bash
42+
43+
- name: Run tests
44+
working-directory: build/tests
45+
run: |
46+
./testcoe_tests
47+
shell: bash

.github/workflows/ci-windows.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Windows
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build-and-test:
11+
name: ${{ matrix.name }}
12+
runs-on: windows-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- name: "Windows MSVC"
18+
compiler: msvc
19+
cmake-generator: 'Visual Studio 17 2022'
20+
cmake-options: ''
21+
22+
- name: "Windows MinGW"
23+
compiler: gcc
24+
cmake-generator: 'MinGW Makefiles'
25+
cmake-options: '-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++'
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v3
30+
with:
31+
submodules: 'recursive'
32+
33+
- name: Install Windows build tools
34+
if: matrix.compiler != 'msvc'
35+
run: |
36+
choco install mingw
37+
shell: bash
38+
39+
- name: Configure CMake
40+
run: |
41+
cmake -B build -G "${{ matrix.cmake-generator }}" ${{ matrix.cmake-options }}
42+
shell: bash
43+
44+
- name: Build
45+
run: |
46+
cmake --build build --config Release
47+
shell: bash
48+
49+
- name: Copy MinGW DLLs
50+
if: matrix.compiler == 'gcc'
51+
run: |
52+
# Find GCC directory
53+
GCC_DIR=$(dirname $(which gcc))
54+
echo "GCC directory: $GCC_DIR"
55+
56+
# Copy DLLs to test directory
57+
echo "Copying DLLs to tests directory"
58+
cp "$GCC_DIR"/libgcc*.dll build/tests/ 2>/dev/null || echo "No libgcc DLLs found"
59+
cp "$GCC_DIR"/libstdc*.dll build/tests/ 2>/dev/null || echo "No libstdc DLLs found"
60+
cp "$GCC_DIR"/libwinpthread*.dll build/tests/ 2>/dev/null || echo "No libwinpthread DLLs found"
61+
62+
# Copy DLLs to example directories
63+
echo "Copying DLLs to example directories"
64+
for dir in build/examples/basic build/examples/filter build/examples/crash; do
65+
echo "Copying to $dir"
66+
cp "$GCC_DIR"/libgcc*.dll "$dir/" 2>/dev/null || echo "No libgcc DLLs found"
67+
cp "$GCC_DIR"/libstdc*.dll "$dir/" 2>/dev/null || echo "No libstdc DLLs found"
68+
cp "$GCC_DIR"/libwinpthread*.dll "$dir/" 2>/dev/null || echo "No libwinpthread DLLs found"
69+
done
70+
71+
# List files to verify
72+
echo "Files in build/tests:"
73+
ls -la build/tests/*.dll || echo "No DLLs in tests"
74+
echo "Files in build/examples/basic:"
75+
ls -la build/examples/basic/*.dll || echo "No DLLs in basic"
76+
shell: bash
77+
78+
- name: Run tests
79+
working-directory: build
80+
run: |
81+
if [ "${{ matrix.compiler }}" == "gcc" ]; then
82+
./tests/testcoe_tests.exe
83+
else
84+
./tests/Release/testcoe_tests.exe
85+
fi
86+
shell: bash

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build/
2+
.vscode/

CMakeLists.txt

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(testcoe VERSION 0.1.0 LANGUAGES CXX)
3+
4+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
5+
set(CMAKE_CXX_STANDARD 17)
6+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7+
8+
if(MSVC)
9+
# Ensure debug symbols are generated and linked
10+
add_compile_options(/Zi)
11+
add_link_options(/DEBUG)
12+
# Keep debug info in release builds too for stack traces
13+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
14+
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
15+
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
16+
# Enhanced debug info for GCC/Clang
17+
add_compile_options(-g3 -fno-omit-frame-pointer)
18+
endif()
19+
20+
# googletest
21+
find_package(GTest QUIET)
22+
if(GTest_FOUND)
23+
message(STATUS "[testcoe] Using existing GoogleTest installation")
24+
else()
25+
message(STATUS "[testcoe] GoogleTest not found, fetching from source")
26+
include(FetchContent)
27+
FetchContent_Declare(
28+
googletest
29+
GIT_REPOSITORY https://github.com/google/googletest.git
30+
GIT_TAG v1.16.0
31+
)
32+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
33+
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
34+
FetchContent_MakeAvailable(googletest)
35+
endif()
36+
37+
# backward-cpp
38+
set(BACKWARD_HAS_BFD 0 CACHE BOOL "Disable BFD support" FORCE)
39+
set(BACKWARD_HAS_DW 0 CACHE BOOL "Disable libdw support" FORCE)
40+
set(BACKWARD_HAS_DWARF 0 CACHE BOOL "Disable libdwarf support" FORCE)
41+
set(BACKWARD_HAS_UNWIND 0 CACHE BOOL "Disable libunwind support" FORCE)
42+
set(STACK_WALKING_UNWIND TRUE CACHE BOOL "Use unwind for stack walking" FORCE)
43+
set(STACK_DETAILS_AUTO_DETECT FALSE CACHE BOOL "Auto detect backward details" FORCE)
44+
set(STACK_DETAILS_BACKTRACE_SYMBOL TRUE CACHE BOOL "Use backtrace symbols" FORCE)
45+
46+
# Windows-specific enhancements for better stack traces
47+
if(WIN32)
48+
set(BACKWARD_HAS_DBGHELP 1 CACHE BOOL "Enable Windows DbgHelp for better stack traces" FORCE)
49+
endif()
50+
51+
find_package(Backward QUIET)
52+
if(Backward_FOUND)
53+
message(STATUS "[testcoe] Using existing Backward-cpp installation")
54+
else()
55+
message(STATUS "[testcoe] Backward-cpp not found, fetching from source")
56+
include(FetchContent)
57+
FetchContent_Declare(
58+
backward
59+
GIT_REPOSITORY https://github.com/bombela/backward-cpp
60+
GIT_TAG v1.6
61+
)
62+
FetchContent_MakeAvailable(backward)
63+
endif()
64+
65+
# testcoe
66+
add_subdirectory(include)
67+
add_subdirectory(src)
68+
69+
option(BUILD_EXAMPLES "Build the examples" ON)
70+
71+
if(BUILD_EXAMPLES)
72+
add_subdirectory(examples)
73+
74+
option(BUILD_TESTS "Build the tests" ON)
75+
76+
if(BUILD_TESTS)
77+
add_subdirectory(tests)
78+
endif()
79+
endif()
80+

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Nir Cohen Hershkovitz
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)