Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6d7dd85
add linux base
Katze719 Jul 5, 2025
978cdcd
add windoof
Katze719 Jul 5, 2025
b80d8cc
make cross compile work
Katze719 Jul 5, 2025
1f0f4c5
flang-tidy fixes
Katze719 Jul 5, 2025
6378ec9
add ci build job
Katze719 Jul 5, 2025
df3a992
fix ifdef
Katze719 Jul 5, 2025
340877f
Update serial examples and add buffer occupancy functions for Windows
Katze719 Jul 5, 2025
520d9ac
Add serialIsReady function to check modem status readiness
Katze719 Jul 5, 2025
1324197
Add serialOnError function and error handling callback; remove serial…
Katze719 Jul 5, 2025
ce06c9d
Enhance serial port handling with detailed error reporting and callba…
Katze719 Jul 5, 2025
0ad4c44
Refactor serial port information retrieval: rename serialGetPortsInfo…
Katze719 Jul 5, 2025
2bfc6fe
Fix com_name assignment in serialGetPortsInfo to correctly extract po…
Katze719 Jul 5, 2025
4e8d394
Fix com_name assignment in serialGetPortsInfo to correctly extract po…
Katze719 Jul 5, 2025
1a4168f
Refactor serial port functions: rename handle parameters for clarity,…
Katze719 Jul 5, 2025
659a15a
Refactor parameter names in serial port functions for consistency and…
Katze719 Jul 5, 2025
004924d
Rename callback function pointers for consistency: change error_callb…
Katze719 Jul 5, 2025
1f43c0a
Refactor serial port statistics: rename rx_total to in_total and tx_t…
Katze719 Jul 5, 2025
ab38c9f
Bump version to 1.0.0 in CMakeLists.txt
Katze719 Jul 5, 2025
1df345d
Refactor versioning: replace version_config.cpp with version_config.h…
Katze719 Jul 5, 2025
f0f2c12
Update getVersion function signature to accept Version by value inste…
Katze719 Jul 5, 2025
7fcd5c1
Refactor getVersion function: change signature to return Version dire…
Katze719 Jul 5, 2025
c22d0c2
Update getVersion function to use output parameter for version retrie…
Katze719 Jul 5, 2025
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
17 changes: 17 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
BasedOnStyle: LLVM
IndentWidth: 4
ColumnLimit: 140
TabWidth: 4
UseTab: Never
BreakBeforeBraces: Allman
AllowShortFunctionsOnASingleLine: Empty
PointerAlignment: Left
DerivePointerAlignment: false
SpaceBeforeParens: ControlStatements
SortIncludes: true
IncludeBlocks: Regroup
ReflowComments: true
ContinuationIndentWidth: 4
BinPackParameters: false
BinPackArguments: false

30 changes: 30 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Checks: >
-*,
readability-* ,
modernize-* ,
-modernize-use-trailing-return-type,
-readability-magic-numbers,

WarningsAsErrors: >
bugprone-* ,
performance-* ,
clang-analyzer-*

HeaderFilterRegex: 'src/.*'
FormatStyle: file

CheckOptions:
- key: modernize-use-auto.MinTypeNameLength
value: '5'
- key: modernize-use-auto.RemoveStars
value: 'false'
- key: readability-identifier-naming.VariableCase
value: lower_case
- key: readability-identifier-naming.MemberCase
value: lower_case
- key: readability-identifier-naming.PrivateMemberPrefix
value: '_'
- key: readability-function-size.ParameterThreshold
value: '12'
- key: readability-braces-around-statements.ShortStatementLines
value: '0'
15 changes: 15 additions & 0 deletions .devcontainer/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM fedora:42

RUN dnf install -y \
clang \
clang-tools-extra \
clangd \
clang-format \
clang-tidy \
clang-analyzer \
cmake \
git \
ninja-build \
mingw64-headers \
mingw64-crt mingw64-winpthreads mingw64-gcc mingw64-gcc-c++ \
&& dnf clean all
28 changes: 28 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"build": {
"dockerfile": "./Dockerfile.dev"
},
"customizations": {
"vscode": {
"extensions": [
"mhutchie.git-graph",
"ms-azuretools.vscode-docker",
"vivaxy.vscode-conventional-commits",
"github.vscode-github-actions",
"llvm-vs-code-extensions.vscode-clangd",
"ms-vscode.cmake-tools"
]
}
},
"runArgs": [
"--network",
"host",
"--privileged",
"--device",
"/dev/bus/usb:/dev/bus/usb",
"--device-cgroup-rule=c 188:* rwm",
"--device-cgroup-rule=c 166:* rwm",
"--group-add=dialout",
"--volume=/dev/serial/by-id:/dev/serial/by-id:ro"
]
}
30 changes: 0 additions & 30 deletions .github/workflows/build.yml

This file was deleted.

47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build & Release cpp_windows_bindings

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "**" ]
release:
types: [ created ]

jobs:

build:
name: Build Windows shared library (g++/MinGW)
runs-on: windows-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup MSYS2 with MinGW-w64 & build tools
run: echo "Using pre-installed Git for Windows g++ in PATH"

- name: Configure CMake (g++ / Ninja)
run: |
cmake -S . -B build -G "Ninja" -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release

- name: Compile
run: cmake --build build


- name: Upload Windows artifacts
uses: actions/upload-artifact@v4
with:
name: libcpp_windows_bindings
path: |
build/**/*.dll
build/**/*.a
retention-days: 14

- name: Attach Windows artifacts to release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
files: |
build/**/*.dll
build/**/*.a
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.vscode/
build/
src/version_config.h
.cache/
compile_commands.json
103 changes: 103 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
cmake_minimum_required(VERSION 3.30)

set(VERSION_MAJOR 1)
set(VERSION_MINOR 0)
set(VERSION_PATCH 0)

set(PROJECT_N cpp_windows_bindings)
project(${PROJECT_N} VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})

# Generate compile_commands.json for clang-based tooling (clangd / clang-tidy)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

include(cmake/CPM.cmake)

CPMAddPackage(
NAME "googletest"
GITHUB_REPOSITORY "google/googletest"
GIT_TAG "v1.17.0"
GIT_SHALLOW TRUE
OPTIONS "GTEST_BUILD_TESTS OFF"
OPTIONS "GTEST_BUILD_EXAMPLES OFF"
OPTIONS "GTEST_BUILD_DOCS OFF"
)

# Ensure clang tooling can pick up compile_commands.json from project root
if(CMAKE_EXPORT_COMPILE_COMMANDS)
add_custom_target(copy-compile-commands ALL
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_BINARY_DIR}/compile_commands.json
${PROJECT_SOURCE_DIR}/compile_commands.json
COMMENT "Copy compile_commands.json to project root"
VERBATIM)
endif()

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED True)

file(GLOB_RECURSE SRCS ${PROJECT_SOURCE_DIR}/src/**.cpp)

set(LIB true)

configure_file(versioning/version_config.h.in ${PROJECT_SOURCE_DIR}/src/version_config.h)

# a macro that gets all of the header containing directories.
MACRO(header_directories return_list includes_base_folder extention )
FILE(GLOB_RECURSE new_list ${includes_base_folder}/*.${extention})
SET(dir_list "")
FOREACH(file_path ${new_list})
GET_FILENAME_COMPONENT(dir_path ${file_path} PATH)
SET(dir_list ${dir_list} ${dir_path})
ENDFOREACH()
LIST(REMOVE_DUPLICATES dir_list)
SET(${return_list} ${dir_list})
ENDMACRO()

# using said macro.
header_directories(INCLUDES ${PROJECT_SOURCE_DIR}/src/ hpp)

message("src files:")
foreach(file ${SRCS})
message(STATUS ${file})
endforeach()

message("include directories:")
foreach(dir ${INCLUDES})
message(STATUS ${dir})
endforeach()

if(LIB)
add_library(${PROJECT_N} SHARED ${SRCS})
else()
add_executable(${PROJECT_N} ${SRCS})
endif(LIB)

set_target_properties(${PROJECT_N} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR})

target_include_directories(${PROJECT_N} PUBLIC ${PROJECT_SOURCE_DIR}/src)

add_executable(tests
tests/serial_test.cpp
tests/serial_unit_tests.cpp)

target_link_libraries(tests PRIVATE ${PROJECT_N} gtest)

target_include_directories(tests PRIVATE ${PROJECT_SOURCE_DIR}/src)

add_custom_command(TARGET tests POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:${PROJECT_N}>
$<TARGET_FILE_DIR:tests>
COMMENT "Copy shared library next to aggregated test binary")

enable_testing()
add_test(NAME AllTests COMMAND tests COM3)

if(MINGW)
# Statisch gegen stdc++, gcc linken und pthread als statisches Archiv
target_link_options(${PROJECT_N} PRIVATE -static -static-libstdc++ -static-libgcc -pthread)
# Windows SetupAPI for serial port enumeration
target_link_libraries(${PROJECT_N} PRIVATE setupapi)
endif()
28 changes: 28 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"version": 3,
"configurePresets": [
{
"name": "windows-mingw-gcc",
"displayName": "x86_64 Windows (MinGW-w64 GCC)",
"description": "Cross-compile for 64-bit Windows using MinGW-w64 GCC toolchain",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build",
"toolchainFile": "${sourceDir}/cmake/toolchains/mingw64.cmake",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
}
],
"buildPresets": [
{
"name": "windows-mingw-gcc",
"configurePreset": "windows-mingw-gcc"
}
],
"testPresets": [
{
"name": "windows-mingw-gcc",
"configurePreset": "windows-mingw-gcc"
}
]
}
Loading