Skip to content
Closed
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
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

1 change: 0 additions & 1 deletion diff_engine_core
Submodule diff_engine_core deleted from fa6548
45 changes: 45 additions & 0 deletions diff_engine_core/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# .clang-format for C project with Allman style braces
BasedOnStyle: LLVM

# Indentation
IndentWidth: 4
UseTab: Never
TabWidth: 4

# Line length
ColumnLimit: 85
BinPackParameters: true
BinPackArguments: true

# Braces style
BreakBeforeBraces: Allman # Allman style: brace on next line
BraceWrapping:
AfterFunction: true
AfterControlStatement: true
AfterStruct: true
AfterClass: true
AfterNamespace: false
IndentBraces: false

# Pointers
PointerAlignment: Right

# Spaces
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpacesInParentheses: false
SpacesInContainerLiterals: false
SpaceBeforeParens: ControlStatements

# Allow single-line short statements if simple
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowAllParametersOfDeclarationOnNextLine: true


# Other
ReflowComments: true
IndentCaseLabels: true
AlignOperands: true
InsertNewlineAtEOF: true
27 changes: 27 additions & 0 deletions diff_engine_core/.github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CMake Build and Test

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

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
build_type: [Release, Debug]

steps:
- uses: actions/checkout@v3

- name: Configure CMake
run: cmake -B build -S . -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_VERBOSE_MAKEFILE=ON

- name: Build
run: cmake --build build --config ${{ matrix.build_type }}

- name: Run tests
run: cd build && ctest -C ${{ matrix.build_type }} --verbose
38 changes: 38 additions & 0 deletions diff_engine_core/.github/workflows/formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Code Formatting

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

jobs:
format:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v5

# Install clang-format if needed
- name: Install clang-format (Linux)
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install -y clang-format

- name: Install clang-format (macOS)
if: matrix.os == 'macos-latest'
run: brew install clang-format || true

# Check formatting
- name: Check C/C++ formatting
run: |
misformatted=$(find . -name '*.c' -o -name '*.h' -print0 | xargs -0 clang-format -style=file -output-replacements-xml | grep "<replacement " || true)
if [ -n "$misformatted" ]; then
echo "ERROR: Some files are not properly formatted. Run clang-format -i."
exit 1
else
echo "All files are properly formatted."
exit 0
fi
39 changes: 39 additions & 0 deletions diff_engine_core/.github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
# Run tests before creating release
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v4

- name: Configure CMake
run: cmake -B build -S . -DCMAKE_BUILD_TYPE=Release

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

- name: Run tests
run: ./build/all_tests

# Create GitHub release after tests pass
release:
needs: test
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- name: Create Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
32 changes: 32 additions & 0 deletions diff_engine_core/.github/workflows/sanitizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: ASan+UBSan

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

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]

steps:
- uses: actions/checkout@v5

# Configure CMake with ASan + UBSan
- name: Configure with sanitizers
run: cmake -B build -S . \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer -g" \
-DCMAKE_CXX_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer -g"

# Build
- name: Build
run: cmake --build build --config Debug

# Run tests
- name: Run tests under ASan+UBSan
run: ./build/all_tests
27 changes: 27 additions & 0 deletions diff_engine_core/.github/workflows/valgrind.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Valgrind

on: [push, pull_request]

jobs:
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y valgrind

- name: Configure Debug build
run: cmake -B build -S . -DCMAKE_BUILD_TYPE=Debug

- name: Build
run: cmake --build build --config Debug

- name: Run tests under Valgrind
run: |
valgrind --leak-check=full --show-leak-kinds=all \
--track-origins=yes -s --show-reachable=yes \
--error-exitcode=1 build/all_tests

79 changes: 79 additions & 0 deletions diff_engine_core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Prerequisites
*.d

# Object files
*.o
*.ko
*.obj
*.elf

# Linker output
*.ilk
*.map
*.exp

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf

# CMake
CMakeCache.txt
CMakeFiles/
CMakeScripts/
Testing/
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
build/
Build/
out/

# IDEs
.vscode/
.idea/
*.swp
*.swo
*~
.DS_Store

.venv/
__pycache__/
uv.lock
94 changes: 94 additions & 0 deletions diff_engine_core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
cmake_minimum_required(VERSION 3.15)
project(DNLP_Diff_Engine C)
set(CMAKE_C_STANDARD 99)

set(DIFF_ENGINE_VERSION_MAJOR 0)
set(DIFF_ENGINE_VERSION_MINOR 1)
set(DIFF_ENGINE_VERSION_PATCH 1)
set(DIFF_ENGINE_VERSION "${DIFF_ENGINE_VERSION_MAJOR}.${DIFF_ENGINE_VERSION_MINOR}.${DIFF_ENGINE_VERSION_PATCH}")
add_compile_definitions(DIFF_ENGINE_VERSION="${DIFF_ENGINE_VERSION}")

message(STATUS "Configuring DNLP Differentiation Engine (version ${DIFF_ENGINE_VERSION})")


#Set default build type to Release if not specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
else()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
endif()

# Warning flags (compiler-specific)
if(MSVC)
add_compile_options(/W4 /WX)
else()
add_compile_options(
-Wall # Enable most warnings
-Wextra # Extra warnings
-Wpedantic # Strict ISO C compliance
-Wshadow # Warn about variable shadowing
-Wformat=2 # Extra format string checks
-Wcast-qual # Warn about cast that removes qualifiers
-Wcast-align # Warn about pointer cast alignment issues
-Wunused # Warn about unused variables/functions
-Wdouble-promotion # Warn about float to double promotion
-Wnull-dereference # Warn about null pointer dereference
)
endif()

# Include directories
include_directories(${PROJECT_SOURCE_DIR}/include)

# Source files - automatically gather all .c files from src/
file(GLOB_RECURSE SOURCES "src/*.c")


# Create core library
add_library(dnlp_diff ${SOURCES})

# Link math library (Unix/Linux only)
if(NOT MSVC)
target_link_libraries(dnlp_diff m)
endif()

# Config-specific compile options (compiler-specific)
if(MSVC)
target_compile_options(dnlp_diff PRIVATE
$<$<CONFIG:Debug>:/Od /Zi>
$<$<CONFIG:Release>:/O2 /DNDEBUG>
$<$<CONFIG:RelWithDebInfo>:/O2 /Zi /DNDEBUG>
$<$<CONFIG:MinSizeRel>:/Os /DNDEBUG>
)
else()
target_compile_options(dnlp_diff PRIVATE
$<$<CONFIG:Debug>:-g -O0>
$<$<CONFIG:Release>:-O3 -DNDEBUG>
$<$<CONFIG:RelWithDebInfo>:-O2 -g -DNDEBUG>
$<$<CONFIG:MinSizeRel>:-Os -DNDEBUG>
)
endif()

# This is needed for clock_gettime on Linux without compiler extensions
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
add_compile_definitions(_POSIX_C_SOURCE=200809L)
endif()

# Enable position-independent code for shared library compatibility
set_property(TARGET dnlp_diff PROPERTY POSITION_INDEPENDENT_CODE ON)

# =============================================================================
# C tests (only for standalone builds)
# =============================================================================
if(NOT SKBUILD)
include_directories(${PROJECT_SOURCE_DIR}/tests)
enable_testing()

add_executable(all_tests
tests/all_tests.c
tests/test_helpers.c
)
target_link_libraries(all_tests dnlp_diff)
add_test(NAME AllTests COMMAND all_tests)
endif()
Loading
Loading