Skip to content
Open
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
6 changes: 3 additions & 3 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
Checks: '-*,cppcoreguidelines-*'
# ,performance-*,cppcoreguidelines-*,bugprone-*,misc-*,modernize-*,readability-*,cert-*'
WarningsAsErrors: 'hicpp-*'
# do while is present in catch macro
Checks: 'hicpp-*,cppcoreguidelines-*,-cppcoreguidelines-avoid-do-while'
WarningsAsErrors: 'hicpp-*,cppcoreguidelines-*,-cppcoreguidelines-avoid-do-while'
HeaderFilterRegex: ''
FormatStyle: file
InheritParentConfig: true
26 changes: 12 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,25 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: lukka/get-cmake@latest
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libfftw3-dev libpoco-dev
- name: cmake
run: cmake -B cmake-build -S . -GNinja && cmake --build cmake-build
- name: install meson
run: python3 -m pip install https://github.com/mesonbuild/meson/releases/download/1.0.0/meson-1.0.0.tar.gz && which meson
sonarcloud:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: Run tests
run: ctest --test-dir cmake-build --output-on-failure
- name: Generate coverage report
run: |
python3 -m pip install gcovr
gcovr -r cmake-build --xml-pretty -o coverage.xml
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Run build-wrapper
run: |
cmake -S . -B build
which build-wrapper-linux-x86_64 || echo "failed while looking for wrapper command"
which ninja || echo "ninja not found"
build-wrapper-linux-x86-64 --out-dir cmake-build-sonarcube-wrap cmake --build build || echo "failed to run wrapper command"
build-wrapper-linux-x86-64 --out-dir cmake-build-sonarcube-wrap cmake --build cmake-build
- name: run tox
run: python3 -m pip install tox && tox -e py
run: python3 -m pip install tox && tox -e py
- name: install meson
run: python3 -m pip install https://github.com/mesonbuild/meson/releases/download/1.0.0/meson-1.0.0.tar.gz && which meson
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Testing/
#vim
*.swp
build

#reports
coverage.xml
Expand Down Expand Up @@ -45,3 +46,4 @@ coverage.xml
cmake-build*
.aider*
.idea
coverage_report*
12 changes: 11 additions & 1 deletion .idea/cpp-examples.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

90 changes: 90 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Build and Development Commands

### Building the project
```bash
# Initial build setup with Ninja generator
cmake -B build -S . -G Ninja

# Build all targets
cmake --build build

# Alternative: Use the provided test script (includes build + test + coverage)
./test.sh
```

### Running tests
```bash
# Run all tests
ctest --test-dir build --output-on-failure

# Run specific test
ctest --test-dir build -R <test_name>
```

### Coverage and Analysis
```bash
# Generate coverage report (requires build with coverage enabled)
gcovr --fail-under-line 10 --exclude build/_deps build

# Run static analysis (clang-tidy)
clang-tidy -p build `find middleware -name *.cpp`

# Run Python tests (via tox)
tox -e py39
```

## Project Architecture

This is a C++ examples repository with the following key structure:

### Main Components
- **Root level**: Contains basic RAII examples and main CMakeLists.txt
- **cjunk/**: Collection of experimental C++ code and examples
- **trivialJson/**: Custom JSON library implementation with SmallMemoryModel and standard versions
- **practice/**: Various C++ learning examples (async, networking, algorithms, etc.)
- **swradio/**: Software-defined radio examples
- **glFrontEnd/**: OpenGL frontend examples
- **pocoJunk/**: Poco library experiments
- **middleware/**: FFT and signal processing utilities
- **example_streambuffer/**: Stream buffer examples
- **serialization/**: Serialization examples including FlatBuffers

### Key Libraries and Dependencies
- **Testing**: Catch2 (v3.5.4) for unit testing
- **Formatting**: fmt library for string formatting
- **Boost**: Header-only Boost libraries (v1.81.0)
- **Build**: CMake with Ninja generator preferred
- **Coverage**: gcovr for coverage reporting
- **Static Analysis**: clang-tidy integration

### Build Configuration
- C++17 standard
- Strict compiler warnings (-Werror on all warnings)
- Stack protection and security features enabled
- Coverage builds enabled by default
- Both shared and static analysis builds supported

### Testing Strategy
- Catch2-based unit tests in relevant subdirectories
- CTest integration for test discovery and execution
- Python tests via tox for any Python components
- Coverage reporting with minimum 10% line coverage requirement

## Development Notes

### CMake Structure
The project uses a modular CMake setup:
- Dependencies fetched via FetchContent from `cmake/dependencies.cmake`
- Each major component has its own CMakeLists.txt
- Libraries are built as separate targets (trivialJson, smallTrivialJson, etc.)
- commit after changes when all test pass.
- all commits should have exactly one author.

### CI/CD
- GitHub Actions workflow builds with Ubuntu + Ninja
- SonarCloud integration for code quality analysis
- Automatic dependency management via CMake FetchContent
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if (STATIC_ANALYSIS)
endif ()
include(cmake/dependencies.cmake)
declare_dependencies()
FetchContent_MakeAvailable(Boost Catch2 fmt)
FetchContent_MakeAvailable(Boost Catch2 fmt GoogleTest)
# boost 1.81 has a warning on gcc 13
target_compile_options(test_main PRIVATE -Wno-dangling-reference)
target_compile_options(json PRIVATE -Wno-dangling-reference)
Expand Down Expand Up @@ -89,6 +89,10 @@ set(libraries_to_link
)

add_executable(raii raii.cc)
target_link_libraries(raii PRIVATE Catch2::Catch2WithMain)
add_test(NAME raii COMMAND $<TARGET_FILE:raii>)
target_link_libraries(raii PRIVATE Catch2::Catch2WithMain)
add_subdirectory(cjunk)
add_subdirectory(example_streambuffer)
add_subdirectory(middleware)


71 changes: 71 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
.PHONY: all build test coverage clean help configure lint ci tox

BUILD_DIR = build

# Default target
all: build test coverage

# Configure cmake
configure:
@echo "=== Configuring project ==="
@cmake -B $(BUILD_DIR) -S . -G Ninja

# Build the project
build:
@echo "=== Building project ==="
@test -f $(BUILD_DIR)/build.ninja || $(MAKE) configure
@cmake --build $(BUILD_DIR)

# Run tests
test: build
@echo "=== Running tests ==="
@ctest --test-dir $(BUILD_DIR) --output-on-failure

# Generate coverage report
coverage: test
@echo "=== Generating coverage report ==="
@gcovr --fail-under-line 10 --exclude $(BUILD_DIR)/_deps $(BUILD_DIR)

# Run static analysis
lint: build
@echo "=== Running static analysis ==="
@files=$$(find middleware cjunk/trivialJson -name "*.cpp" -o -name "*.cc" 2>/dev/null); \
if [ -n "$$files" ]; then \
clang-tidy -p $(BUILD_DIR) $$files; \
else \
echo "No C++ files found for static analysis"; \
fi

# Run Python tests via tox
tox:
@echo "=== Running Python tests via tox ==="
@tox -e py39

# Full CI pipeline
ci: all lint tox
@echo "=== All CI checks passed! ==="

# Clean build directory
clean:
@echo "=== Cleaning build directory ==="
@rm -rf $(BUILD_DIR)

# Clean everything including Python cache
clean-all: clean
@echo "=== Cleaning all build artifacts ==="
@rm -rf .tox __pycache__ **/__pycache__ *.egg-info .pytest_cache .coverage

# Show help
help:
@echo "Available targets:"
@echo " all - Build, test, and generate coverage (default)"
@echo " configure - Configure cmake build"
@echo " build - Build the project"
@echo " test - Run tests"
@echo " coverage - Generate coverage report"
@echo " lint - Run static analysis"
@echo " tox - Run Python tests via tox"
@echo " ci - Full CI pipeline (build + test + coverage + lint + tox)"
@echo " clean - Clean build directory"
@echo " clean-all - Clean all build artifacts"
@echo " help - Show this help message"
4 changes: 2 additions & 2 deletions cjunk/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
project(cjunk)


add_subdirectory(trivialJson)
add_subdirectory(practice)
#add_subdirectory(swradio)
3 changes: 0 additions & 3 deletions cjunk/glFrontEnd/CMakeLists.txt

This file was deleted.

12 changes: 0 additions & 12 deletions cjunk/glFrontEnd/Window.cpp

This file was deleted.

14 changes: 0 additions & 14 deletions cjunk/glFrontEnd/Window.h

This file was deleted.

Loading
Loading