Skip to content

Commit 829cff4

Browse files
committed
Merge branch 'cleaning-up-repo'
2 parents 0f3b22b + 8630cf3 commit 829cff4

File tree

21 files changed

+539
-1071
lines changed

21 files changed

+539
-1071
lines changed

.github/workflows/pipeline.yml

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
name: Libdbc Pipeline
2+
3+
on: [push]
4+
5+
env:
6+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
7+
BUILD_TYPE: Release
8+
9+
jobs:
10+
linux-builds:
11+
name: linux ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}}
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
cxx:
17+
- g++-13
18+
- clang++-16
19+
build_type: [Debug, Release]
20+
std: [11]
21+
include:
22+
- cxx: g++-13
23+
cc: gcc-13
24+
- cxx: clang++-16
25+
cc: clang-16
26+
llvm_version: 16
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- name: Install clang
32+
if: ${{ matrix.llvm_version }}
33+
run: |
34+
wget https://apt.llvm.org/llvm.sh
35+
chmod +x llvm.sh
36+
sudo ./llvm.sh ${{ matrix.llvm_version }}
37+
38+
- name: Prepare environment
39+
run: |
40+
sudo apt-get update
41+
sudo apt-get install -y locales
42+
43+
sudo locale-gen de_DE.UTF-8
44+
45+
- name: Configure build
46+
working-directory: ${{runner.workspace}}
47+
env:
48+
CC: ${{matrix.cc}}
49+
CXX: ${{matrix.cxx}}
50+
run: |
51+
cmake -Bbuild -H$GITHUB_WORKSPACE \
52+
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
53+
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
54+
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
55+
-DCMAKE_CXX_EXTENSIONS=ON \
56+
-DDBC_TEST_LOCALE_INDEPENDENCE=ON
57+
58+
- name: Build tests + lib
59+
working-directory: ${{runner.workspace}}
60+
run: cmake --build build --parallel `nproc`
61+
62+
- name: Run tests
63+
env:
64+
CTEST_OUTPUT_ON_FAILURE: 1
65+
working-directory: ${{runner.workspace}}
66+
run: ctest --output-on-failure --test-dir build -j `nproc`
67+
68+
windows-build:
69+
name: ${{matrix.os}}, ${{matrix.std}}, ${{matrix.build_type}}, ${{matrix.platform}}
70+
runs-on: ${{matrix.os}}
71+
strategy:
72+
fail-fast: false
73+
matrix:
74+
os: [windows-2019, windows-2022]
75+
platform: [Win32, x64]
76+
build_type: [Debug, Release]
77+
std: [11]
78+
79+
steps:
80+
- uses: actions/checkout@v4
81+
82+
- name: Configure build
83+
working-directory: ${{runner.workspace}}
84+
run: |
85+
cmake -S $Env:GITHUB_WORKSPACE `
86+
-B ${{runner.workspace}}/build `
87+
-A ${{matrix.platform}} `
88+
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} `
89+
-DCMAKE_CXX_STANDARD=${{matrix.std}} `
90+
-DCMAKE_CXX_STANDARD_REQUIRED=ON `
91+
-DCMAKE_CXX_EXTENSIONS=ON `
92+
-DDBC_TEST_LOCALE_INDEPENDENCE=ON
93+
94+
- name: Build tests + lib
95+
working-directory: ${{runner.workspace}}
96+
run: cmake --build build --config ${{matrix.build_type}} --parallel %NUMBER_OF_PROCESSORS%
97+
shell: cmd
98+
99+
- name: Run tests
100+
env:
101+
CTEST_OUTPUT_ON_FAILURE: 1
102+
working-directory: ${{runner.workspace}}
103+
run: ctest --output-on-failure --test-dir build -j %NUMBER_OF_PROCESSORS%
104+
shell: cmd
105+
106+
macos-builds:
107+
name: macos ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}}
108+
runs-on: macos-latest
109+
strategy:
110+
fail-fast: false
111+
matrix:
112+
cxx:
113+
- g++
114+
- clang++
115+
build_type: [Debug, Release]
116+
std: [11]
117+
include:
118+
- cxx: g++
119+
cc: gcc
120+
- cxx: clang++
121+
cc: clang
122+
123+
steps:
124+
- uses: actions/checkout@v4
125+
126+
- name: Configure build
127+
working-directory: ${{runner.workspace}}
128+
env:
129+
CC: ${{matrix.cc}}
130+
CXX: ${{matrix.cxx}}
131+
run: |
132+
cmake -Bbuild -H$GITHUB_WORKSPACE \
133+
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
134+
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
135+
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
136+
-DCMAKE_CXX_EXTENSIONS=ON \
137+
-DDBC_TEST_LOCALE_INDEPENDENCE=ON
138+
139+
- name: Build tests + lib
140+
working-directory: ${{runner.workspace}}
141+
run: cmake --build build --parallel `sysctl -n hw.ncpu`
142+
143+
- name: Run tests
144+
env:
145+
CTEST_OUTPUT_ON_FAILURE: 1
146+
working-directory: ${{runner.workspace}}
147+
run: ctest --output-on-failure --test-dir build -j `sysctl -n hw.ncpu`
148+
149+
format-check:
150+
runs-on: ubuntu-latest
151+
152+
steps:
153+
- uses: actions/checkout@v3
154+
155+
- name: Test format with clang format
156+
run: ./scripts/fmt.sh
157+

.github/workflows/tests.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.gitignore

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
# Build folders
22
bin/
33
build/
4+
Testing/
45

56
# -- Git -- #
6-
*.bak
7+
*.bak
8+
9+
# -- Python -- #
10+
venv*/
11+
__pycache__/
12+
13+
# -- IDEs / Editors -- #
14+
.idea/
15+
.vscode/
16+
*.sublime-*
17+
18+
# -- Static Analyzers -- #
19+
.cache/
20+

CMakeLists.txt

Lines changed: 57 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
cmake_minimum_required(VERSION 3.16)
22

3-
project(dbc VERSION 0.1.1 DESCRIPTION "C++ DBC Parser")
3+
project(dbc
4+
VERSION 0.2.0
5+
DESCRIPTION "C++ DBC Parser"
6+
)
7+
8+
# -- PROJECT OPTIONS -- #
9+
option(DBC_ENABLE_TESTS "Enable Unittests" ON)
10+
option(DBC_TEST_LOCALE_INDEPENDENCE "Used to deterime if the libary is locale agnostic when it comes to converting floats. You need `de_DE.UTF-8` locale installed for this testing." OFF)
11+
option(DBC_GENERATE_DOCS "Use doxygen if installed to generated documentation files" OFF)
12+
# ---------------------- #
413

514
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
615

@@ -12,14 +21,6 @@ set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE)
1221
set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.md)
1322
include(CPack)
1423

15-
option(DEBUG "use debug flag" NO)
16-
option(ENABLE_TESTS "Enable Unittests" ON)
17-
# Turn OFF, if you are using FetchContent to include it to your project
18-
option(FETCH_CONTENT_INCLUSION "Include project with FetchContent_Declare in another project. In this case the headers and the cmake files are not needed, only the library" OFF)
19-
20-
# defines variables used in the dbc.pc.in
21-
include(GNUInstallDirs)
22-
2324
# specify the C++ standard
2425
set(CMAKE_CXX_STANDARD 11)
2526
set(CMAKE_CXX_STANDARD_REQUIRED True)
@@ -37,80 +38,78 @@ if (NOT ${FastFloat_FOUND})
3738
add_subdirectory(${fastfloat_SOURCE_DIR} ${fastfloat_BINARY_DIR} EXCLUDE_FROM_ALL)
3839
endif()
3940

40-
set(GCC_COMPILE_FLAGS "-Wextra -Wall -Wfloat-equal -Wundef -Wshadow \
41-
-Wpointer-arith -Wcast-align -Wstrict-prototypes -Wwrite-strings \
42-
-Waggregate-return -Wcast-qual -Wswitch-default -Wswitch-enum -Wconversion \
43-
-Wunreachable-code -Wformat=2 -Werror -Wuninitialized -Winit-self")
44-
45-
if(DEBUG)
46-
set(GCC_COMPILE_FLAGS ${GCC_COMPILE_FLAGS}" -g")
47-
else()
48-
set(GCC_COMPILE_FLAGS ${GCC_COMPILE_FLAGS}" -O2")
49-
endif()
50-
51-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
52-
5341
# add where to find the source files
54-
# file(GLOB_RECURSE SOURCE ${PROJECT_SOURCE_DIR}/src/ *.cpp)
55-
list(APPEND SOURCE ${PROJECT_SOURCE_DIR}/src/utils.cpp
56-
${PROJECT_SOURCE_DIR}/src/message.cpp
57-
${PROJECT_SOURCE_DIR}/src/signal.cpp
58-
${PROJECT_SOURCE_DIR}/src/dbc.cpp)
42+
list(APPEND SOURCE_FILES
43+
${PROJECT_SOURCE_DIR}/src/utils.cpp
44+
${PROJECT_SOURCE_DIR}/src/message.cpp
45+
${PROJECT_SOURCE_DIR}/src/signal.cpp
46+
${PROJECT_SOURCE_DIR}/src/dbc.cpp
47+
)
5948

60-
set(HEADER_FILES
49+
list(APPEND HEADER_FILES
6150
${PROJECT_SOURCE_DIR}/include/libdbc/dbc.hpp
6251
${PROJECT_SOURCE_DIR}/include/libdbc/message.hpp
6352
${PROJECT_SOURCE_DIR}/include/libdbc/signal.hpp
6453
${PROJECT_SOURCE_DIR}/include/libdbc/utils/utils.hpp
6554
${PROJECT_SOURCE_DIR}/include/libdbc/exceptions/error.hpp
6655
)
6756

68-
include_directories(src)
69-
include_directories(include)
70-
71-
if(ENABLE_TESTS)
57+
if(DBC_ENABLE_TESTS)
7258
include(CTest)
7359
add_subdirectory(test)
7460
endif()
7561

76-
add_subdirectory(doc)
62+
if(DBC_GENERATE_DOCS)
63+
add_subdirectory(doc)
64+
endif()
65+
66+
list(APPEND GCC_CLANG_COMPILE_FLAGS
67+
-Wall -Wextra -Wpedantic
68+
-Wconversion -Wint-in-bool-context
69+
-Wmissing-declarations -Wmissing-field-initializers
70+
-Werror
71+
)
7772

78-
add_library(${PROJECT_NAME} STATIC ${SOURCE})
79-
target_link_libraries(${PROJECT_NAME} FastFloat::fast_float)
8073

81-
if (${CMAKE_MINOR_VERSION} GREATER_EQUAL 23)
82-
target_sources(${PROJECT_NAME} INTERFACE FILE_SET HEADERS
83-
TYPE HEADERS
84-
BASE_DIRS ${PROJECT_SOURCE_DIR}/include/libdbc
85-
FILES ${HEADER_FILES})
74+
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
75+
add_compile_options(/W4 /WX)
76+
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
77+
# Clang shadow warnings aren't as sensitive as gcc
78+
add_compile_options(${GCC_CLANG_COMPILE_FLAGS} -Wshadow)
79+
else()
80+
add_compile_options(${GCC_CLANG_COMPILE_FLAGS})
8681
endif()
8782

83+
add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES})
84+
target_link_libraries(${PROJECT_NAME} FastFloat::fast_float)
85+
target_include_directories(${PROJECT_NAME} PUBLIC
86+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
87+
$<INSTALL_INTERFACE:include>
88+
)
89+
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
90+
91+
target_sources(${PROJECT_NAME} INTERFACE FILE_SET HEADERS
92+
TYPE HEADERS
93+
BASE_DIRS ${PROJECT_SOURCE_DIR}/include/libdbc
94+
FILES ${HEADER_FILES}
95+
)
96+
8897
add_custom_target(release
8998
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
9099
COMMAND ${CMAKE_SOURCE_DIR}/scripts/create_single_header.sh
91-
DEPENDS ${PROJECT_NAME})
100+
DEPENDS ${PROJECT_NAME}
101+
)
92102

93103
## Installation
94104
# install lib
95105
install(TARGETS ${PROJECT_NAME}
96106
DESTINATION ${CMAKE_INSTALL_LIBDIR})
97107

98108
# install headers
99-
if (${CMAKE_MINOR_VERSION} GREATER_EQUAL 23 AND NOT FETCH_CONTENT_INCLUSION)
100-
install(TARGETS ${PROJECT_NAME}
101-
FILE_SET HEADERS
102-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lib${PROJECT_NAME}
103-
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
104-
)
105-
elseif(NOT FETCH_CONTENT_INCLUSION)
106-
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/libdbc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
107-
endif()
108-
109+
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/libdbc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
109110

110-
if (NOT FETCH_CONTENT_INCLUSION)
111-
# Generate pkg-config file
112-
configure_file(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
113-
install(
114-
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
115-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
116-
endif()
111+
# Generate pkg-config file
112+
configure_file(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
113+
install(
114+
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
115+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

0 commit comments

Comments
 (0)