Skip to content

Commit 6d4160f

Browse files
committed
Merge branch 'release-creation'
2 parents 829cff4 + f7067ff commit 6d4160f

22 files changed

+359
-115
lines changed

.clang-format

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,5 @@ AllowShortLambdasOnASingleLine: Empty
102102

103103
# We do not want clang-format to put all arguments on a new line
104104
AllowAllArgumentsOnNextLine: false
105+
106+
InsertNewlineAtEOF: true

.github/data/release_body.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Libdbc release
2+
3+
### Developer Notes
4+
5+
**TODO: Update this!**
6+
7+
## Breaking Changes
8+
9+
* <Insert-Change>
10+
11+
## Features
12+
13+
* <Insert-Change>
14+
15+
## Bugs
16+
17+
* <Insert-Change>
18+
19+

.github/workflows/pipeline.yml

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Libdbc Pipeline
22

3-
on: [push]
3+
on: [push, workflow_call]
44

55
env:
66
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
@@ -42,27 +42,28 @@ jobs:
4242
4343
sudo locale-gen de_DE.UTF-8
4444
45+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
46+
source "$HOME/.cargo/env"
47+
4548
- name: Configure build
46-
working-directory: ${{runner.workspace}}
4749
env:
4850
CC: ${{matrix.cc}}
4951
CXX: ${{matrix.cxx}}
5052
run: |
51-
cmake -Bbuild -H$GITHUB_WORKSPACE \
53+
cmake -Bbuild -H$GITHUB_WORKSPACE \
5254
-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
55+
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
56+
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
57+
-DCMAKE_CXX_EXTENSIONS=ON \
58+
-DDBC_TEST_LOCALE_INDEPENDENCE=ON \
59+
-DDBC_GENERATE_SINGLE_HEADER=ON
5760
5861
- name: Build tests + lib
59-
working-directory: ${{runner.workspace}}
6062
run: cmake --build build --parallel `nproc`
6163

6264
- name: Run tests
6365
env:
6466
CTEST_OUTPUT_ON_FAILURE: 1
65-
working-directory: ${{runner.workspace}}
6667
run: ctest --output-on-failure --test-dir build -j `nproc`
6768

6869
windows-build:
@@ -129,11 +130,11 @@ jobs:
129130
CC: ${{matrix.cc}}
130131
CXX: ${{matrix.cxx}}
131132
run: |
132-
cmake -Bbuild -H$GITHUB_WORKSPACE \
133+
cmake -Bbuild -H$GITHUB_WORKSPACE \
133134
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
134-
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
135-
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
136-
-DCMAKE_CXX_EXTENSIONS=ON \
135+
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
136+
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
137+
-DCMAKE_CXX_EXTENSIONS=ON \
137138
-DDBC_TEST_LOCALE_INDEPENDENCE=ON
138139
139140
- name: Build tests + lib
@@ -150,7 +151,18 @@ jobs:
150151
runs-on: ubuntu-latest
151152

152153
steps:
153-
- uses: actions/checkout@v3
154+
- uses: actions/checkout@v4
155+
156+
- name: Install clang-format version
157+
run: |
158+
wget https://apt.llvm.org/llvm.sh
159+
chmod +x llvm.sh
160+
sudo ./llvm.sh 16
161+
162+
sudo apt update && sudo apt install -y clang-format-16
163+
sudo ln -sf $(which clang-format-16) $(which clang-format)
164+
165+
test "$(clang-format --version)" == "$(clang-format-16 --version)"
154166
155167
- name: Test format with clang format
156168
run: ./scripts/fmt.sh

.github/workflows/release.yml

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,82 @@ on:
55
inputs:
66
major:
77
required: true
8-
type: string
8+
description: "The major version"
9+
type: number
910
minor:
1011
required: true
11-
type: string
12+
description: "The minor version"
13+
type: number
1214
patch:
1315
required: true
14-
type: string
16+
description: "The patch version"
17+
type: number
18+
19+
release_type:
20+
type: choice
21+
description: "The type of release you are making. Controls branch naming / creation"
22+
options:
23+
- patch
24+
- minor
25+
- major
1526

1627
jobs:
28+
check_version:
29+
runs-on: ubuntu-latest
30+
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: "Validate version in cmake before continuing"
35+
run: ./scripts/check_version.py --version "v${{ inputs.major }}.${{ inputs.minor }}.${{ inputs.patch }}"
36+
37+
pipeline:
38+
needs: [check_version]
39+
uses: ./.github/workflows/pipeline.yml
40+
1741
create_release:
1842
runs-on: ubuntu-latest
43+
needs: [pipeline]
44+
45+
env:
46+
header_file_path: build/single_header/libdbc/libdbc.hpp
47+
1948
steps:
20-
- name: "Checkout the code"
21-
uses: actions/checkout@v3
49+
- uses: actions/checkout@v4
50+
51+
- name: "Setup Cargo"
52+
run: |
53+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
54+
source "$HOME/.cargo/env"
55+
56+
- name: Configure build
57+
run: cmake -Bbuild -H$GITHUB_WORKSPACE -DDBC_GENERATE_SINGLE_HEADER=ON
58+
59+
- name: Generate the header file
60+
run: cmake --build build --parallel `nproc` --target single_header
61+
62+
- uses: actions/upload-artifact@v4
63+
with:
64+
if-no-files-found: error
65+
name: header-only
66+
path: ${{ env.header_file_path }}
67+
68+
- name: "Create a branch if we are making a major / minor release"
69+
uses: peterjgrainger/[email protected]
70+
if: ${{ inputs.release_type }} == "minor" || ${{ inputs.release_type }} == "major"
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
with:
74+
branch: 'release/v${{ inputs.major }}.${{ inputs.minor }}'
75+
sha: '${{ github.sha }}'
2276

23-
- name: "Run tests as a pre check"
24-
uses: .github/workflows/tests.yml
77+
- uses: ncipollo/release-action@v1
78+
with:
79+
artifacts: "${{ env.header_file_path }}"
80+
draft: true
81+
bodyFile: ".github/data/release_body.md"
82+
tag: v${{ inputs.major }}.${{ inputs.minor }}.${{ inputs.patch }}
83+
commit: release/v${{ inputs.major }}.${{ inputs.minor }}
2584

2685

2786

CMakeLists.txt

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
cmake_minimum_required(VERSION 3.16)
22

3-
project(dbc
4-
VERSION 0.2.0
5-
DESCRIPTION "C++ DBC Parser"
6-
)
3+
# Keep this on one line for release checking
4+
project(dbc VERSION 0.2.0 DESCRIPTION "C++ DBC Parser")
75

86
# -- PROJECT OPTIONS -- #
97
option(DBC_ENABLE_TESTS "Enable Unittests" ON)
108
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)
119
option(DBC_GENERATE_DOCS "Use doxygen if installed to generated documentation files" OFF)
10+
option(DBC_GENERATE_SINGLE_HEADER "This will run the generator for the single header file version. Default is OFF since we make a static build. Requires cargo installed." OFF)
1211
# ---------------------- #
1312

1413
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
@@ -27,20 +26,18 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
2726

2827
find_package(FastFloat QUIET)
2928
if (NOT ${FastFloat_FOUND})
30-
include(FetchContent)
31-
FetchContent_Declare(
32-
FastFloat
33-
GIT_REPOSITORY https://github.com/fastfloat/fast_float.git
34-
GIT_TAG 1ea4f27b2aeee2859a1354a3c24cff52a116cad1
35-
)
36-
# FetchContent_MakeAvailable(FastFloat)
37-
FetchContent_Populate(FastFloat)
38-
add_subdirectory(${fastfloat_SOURCE_DIR} ${fastfloat_BINARY_DIR} EXCLUDE_FROM_ALL)
29+
include(FetchContent)
30+
FetchContent_Declare(
31+
FastFloat
32+
GIT_REPOSITORY https://github.com/fastfloat/fast_float.git
33+
GIT_TAG 1ea4f27b2aeee2859a1354a3c24cff52a116cad1
34+
)
35+
FetchContent_MakeAvailable(FastFloat)
3936
endif()
4037

4138
# add where to find the source files
4239
list(APPEND SOURCE_FILES
43-
${PROJECT_SOURCE_DIR}/src/utils.cpp
40+
${PROJECT_SOURCE_DIR}/src/utils.cpp
4441
${PROJECT_SOURCE_DIR}/src/message.cpp
4542
${PROJECT_SOURCE_DIR}/src/signal.cpp
4643
${PROJECT_SOURCE_DIR}/src/dbc.cpp
@@ -55,50 +52,51 @@ list(APPEND HEADER_FILES
5552
)
5653

5754
if(DBC_ENABLE_TESTS)
58-
include(CTest)
59-
add_subdirectory(test)
55+
include(CTest)
56+
add_subdirectory(test)
6057
endif()
6158

6259
if(DBC_GENERATE_DOCS)
63-
add_subdirectory(doc)
60+
add_subdirectory(doc)
6461
endif()
6562

6663
list(APPEND GCC_CLANG_COMPILE_FLAGS
67-
-Wall -Wextra -Wpedantic
68-
-Wconversion -Wint-in-bool-context
69-
-Wmissing-declarations -Wmissing-field-initializers
70-
-Werror
64+
-Wall -Wextra -Wpedantic
65+
-Wconversion -Wint-in-bool-context
66+
-Wmissing-declarations -Wmissing-field-initializers
67+
-Werror
7168
)
7269

7370

7471
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
75-
add_compile_options(/W4 /WX)
72+
add_compile_options(/W4 /WX)
7673
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)
74+
# Clang shadow warnings aren't as sensitive as gcc
75+
add_compile_options(${GCC_CLANG_COMPILE_FLAGS} -Wshadow)
7976
else()
80-
add_compile_options(${GCC_CLANG_COMPILE_FLAGS})
77+
add_compile_options(${GCC_CLANG_COMPILE_FLAGS})
8178
endif()
8279

8380
add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES})
8481
target_link_libraries(${PROJECT_NAME} FastFloat::fast_float)
8582
target_include_directories(${PROJECT_NAME} PUBLIC
86-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
87-
$<INSTALL_INTERFACE:include>
83+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
84+
$<INSTALL_INTERFACE:include>
8885
)
8986
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
9087

9188
target_sources(${PROJECT_NAME} INTERFACE FILE_SET HEADERS
92-
TYPE HEADERS
93-
BASE_DIRS ${PROJECT_SOURCE_DIR}/include/libdbc
94-
FILES ${HEADER_FILES}
89+
TYPE HEADERS
90+
BASE_DIRS ${PROJECT_SOURCE_DIR}/include/libdbc
91+
FILES ${HEADER_FILES}
9592
)
9693

97-
add_custom_target(release
98-
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
99-
COMMAND ${CMAKE_SOURCE_DIR}/scripts/create_single_header.sh
100-
DEPENDS ${PROJECT_NAME}
101-
)
94+
if(DBC_GENERATE_SINGLE_HEADER)
95+
add_custom_target(single_header ALL
96+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
97+
COMMAND ${CMAKE_SOURCE_DIR}/scripts/create_single_header.sh
98+
)
99+
endif()
102100

103101
## Installation
104102
# install lib
@@ -111,5 +109,5 @@ install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/libdbc DESTINATION ${CMAKE_INSTA
111109
# Generate pkg-config file
112110
configure_file(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
113111
install(
114-
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
115-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
112+
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
113+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,21 @@ cmake -LH .. | grep -B1 "DBC_"
3636
cmake -LAH ..
3737
```
3838

39+
### Creating a Single Header File
40+
41+
It requires you have `cargo` installed from rust. See these instructions if you don't have that https://www.rust-lang.org/tools/install.
42+
It uses the https://github.com/Felerius/cpp-amalgamate crate to do the single header file creation.
43+
44+
The output will be generated in the `build/single_header/libdbc/` folder. You can run a cmake command to build this as well as other targets.
45+
46+
To just build the single header you can simply run the target:
47+
```shell
48+
cmake -Bbuild -H. -DDBC_GENERATE_SINGLE_HEADER=ON
49+
50+
cmake --build build --parallel `nproc` --target single_header
51+
```
52+
53+
3954
## Testing
4055

4156
I am trying to always make sure that this is very well tested code. I am using Catch2 to do this

include/libdbc/dbc.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#ifndef __DBC_HPP__
32
#define __DBC_HPP__
43

include/libdbc/exceptions/error.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ class validity_error : public exception {
2121

2222
} // libdbc
2323

24-
#endif // __ERROR_HPP__
24+
#endif // __ERROR_HPP__

script-requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)