Skip to content

Commit 2f5bff0

Browse files
committed
Finish v0.2.0
This release adds an interface for plain C and several quality of life features for the repository such as a code coverage report for pull requests and a conan recipe that allows us to create a conan package. On top of that, a code of conduct and contributing guidelines were added.
2 parents ce308be + caf96a0 commit 2f5bff0

21 files changed

Lines changed: 756 additions & 34 deletions

.github/workflows/build.yaml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ on:
55
push:
66
branches:
77
- "master"
8+
- "develop"
89
pull_request:
910
branches:
1011
- "master"
12+
- "develop"
1113

1214
# Allows you to run this workflow manually from the Actions tab
1315
workflow_dispatch:
@@ -27,47 +29,47 @@ jobs:
2729
#
2830
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
2931
matrix:
30-
os: [ ubuntu-latest, windows-latest ]
32+
os: [ ubuntu-24.04, windows-latest ]
3133
build_type: [ Release ]
3234
c_compiler: [ gcc, clang, cl ]
3335
include:
3436
- os: windows-latest
3537
c_compiler: cl
3638
cpp_compiler: cl
37-
- os: ubuntu-latest
39+
- os: ubuntu-24.04
3840
c_compiler: gcc
3941
cpp_compiler: g++
40-
- os: ubuntu-latest
42+
- os: ubuntu-24.04
4143
c_compiler: clang
4244
cpp_compiler: clang++
4345
exclude:
4446
- os: windows-latest
4547
c_compiler: gcc
4648
- os: windows-latest
4749
c_compiler: clang
48-
- os: ubuntu-latest
50+
- os: ubuntu-24.04
4951
c_compiler: cl
5052

5153
steps:
52-
- uses: actions/checkout@v3
54+
- uses: actions/checkout@v4
5355

5456
- name: 🔧 Install GCC
5557
uses: egor-tensin/setup-gcc@v1.3
56-
if: matrix.os == 'ubuntu-latest' && matrix.c_compiler == 'gcc'
58+
if: matrix.os == 'ubuntu-24.04' && matrix.c_compiler == 'gcc'
5759
with:
5860
version: 13
5961

6062
- name: 🔧 Install Clang
6163
uses: egor-tensin/setup-clang@v1.4
62-
if: matrix.os == 'ubuntu-latest' && matrix.c_compiler == 'clang'
64+
if: matrix.os == 'ubuntu-24.04' && matrix.c_compiler == 'clang'
6365
with:
6466
version: 16
6567

6668
- name: 🔧 Setup python
67-
uses: actions/setup-python@v4
69+
uses: actions/setup-python@v5
6870
with:
69-
python-version: '3.10'
70-
cache: pip
71+
python-version: '3.13'
72+
cache: 'pip'
7173

7274
- name: ☁️ Install required python packages
7375
run: pip install -r requirements.txt
@@ -76,27 +78,25 @@ jobs:
7678
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
7779
id: strings
7880
shell: bash
79-
run: echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
81+
run: |
82+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
83+
if [ "${{ matrix.os }}" == "windows-latest" ]; then
84+
echo "preset-name=conan-default" >> "$GITHUB_OUTPUT"
85+
else
86+
echo "preset-name=conan-release" >> "$GITHUB_OUTPUT"
87+
fi
8088
8189
- name: 🐸 Create default Conan profile
8290
run: conan profile detect
8391

8492
- name: ☁️ Get dependencies
85-
run: conan install ${{ github.workspace }} --build=missing --output-folder=build --settings compiler.cppstd=20
93+
run: conan install ${{ github.workspace }} --build=missing -s compiler.cppstd=20 -o testing=True
8694

8795
- name: 🛠️ Configure CMake
88-
run: >
89-
cmake -B ${{ steps.strings.outputs.build-output-dir }}
90-
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
91-
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
92-
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
93-
-DBUILD_TESTING=ON
94-
--toolchain=conan_toolchain.cmake
95-
-S ${{ github.workspace }}
96+
run: cmake --preset ${{ steps.strings.outputs.preset-name }}
9697

9798
- name: 🔨 Build project
98-
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --parallel
99+
run: cmake --build --preset conan-release --parallel
99100

100101
- name: 🏃 Run test suite
101-
working-directory: build
102-
run: ctest --build-config ${{ matrix.build_type }}
102+
run: ctest --preset conan-release

.github/workflows/coverage.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Coverage
2+
3+
on:
4+
# Triggers the workflow on push or pull request events but only for the "master" branch
5+
push:
6+
branches:
7+
- "master"
8+
- "develop"
9+
pull_request:
10+
branches:
11+
- "master"
12+
- "develop"
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v3
20+
21+
- name: 🔧 Install GCC
22+
uses: egor-tensin/setup-gcc@v1.3
23+
with:
24+
version: 13
25+
26+
- name: 🔧 Setup python
27+
uses: actions/setup-python@v4
28+
with:
29+
python-version: '3.10'
30+
cache: pip
31+
32+
- name: ☁️ Install required packages
33+
run: |
34+
sudo apt-get install -y lcov
35+
pip install -r requirements.txt
36+
37+
- name: 🐸 Create default Conan profile
38+
run: conan profile detect
39+
40+
- name: ☁️ Get dependencies
41+
run: conan install ${{ github.workspace }} --build=missing -s compiler.cppstd=20 -o testing=True -o coverage=True
42+
43+
- name: 🛠️ Configure CMake
44+
run: cmake --preset conan-release
45+
46+
- name: 🔨 Build project
47+
run: cmake --build --preset conan-release --parallel
48+
49+
- name: 🏃 Run test suite
50+
run: ctest --preset conan-release
51+
52+
- name: 📊 Generate coverage reports with lcov
53+
run: |
54+
lcov --directory . --capture --output-file coverage.info --gcov-tool gcov-13
55+
lcov --remove coverage.info '/usr/*' --remove coverage.info '**/.conan*' --remove coverage.info '**/test*' --remove coverage.info '**/test_package*' --output-file coverage.info
56+
lcov --list coverage.info
57+
58+
- name: ☂️ Upload coverage reports to Codecov
59+
uses: codecov/codecov-action@v3
60+
env:
61+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
/*build*
33
/doc
44
/include/cppIni/cppini_export.h
5+
test_package/build
6+
python
57
CMakeUserPresets.json

CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
cmake_minimum_required(VERSION 3.24)
2-
project(cppIni LANGUAGES CXX VERSION 0.1.0)
2+
project(cppIni LANGUAGES CXX VERSION 0.2.0)
33

44
set(CMAKE_CXX_STANDARD 20)
55
set(CMAKE_CXX_STANDARD_REQUIRED ON)
66

7-
option(BUILD_TESTING ON "Build test files")
8-
option(BUILD_SHARED_LIBS ON "Build shared library files")
7+
option(BUILD_TESTING "Build test files" OFF)
8+
option(BUILD_SHARED_LIBS "Build shared library files" ON)
9+
option(CODE_COVERAGE "Enable coverage reporting" OFF)
910

11+
include(cmake/CodeCoverage.cmake)
1012
add_subdirectory(src)
1113

1214
if(BUILD_TESTING)

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# cppIni - A C++20 library for reading and writing INI files
22

3+
Branch | Status | Coverage
4+
--- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------| ---
5+
`master` | [![Build](https://github.com/Master92/cppIni/actions/workflows/build.yaml/badge.svg?branch=master)](https://github.com/Master92/cppIni/actions/workflows/build.yaml) | [![codecov](https://codecov.io/gh/Master92/cppIni/branch/master/graph/badge.svg?token=V66BUECAMV)](https://codecov.io/gh/Master92/cppIni)
6+
`develop` | [![Build](https://github.com/Master92/cppIni/actions/workflows/build.yaml/badge.svg?branch=develop)](https://github.com/Master92/cppIni/actions/workflows/build.yaml) | [![codecov](https://codecov.io/gh/Master92/cppIni/branch/develop/graph/badge.svg?token=V66BUECAMV)](https://codecov.io/gh/Master92/cppIni/tree/develop)
7+
38
[![Release](https://img.shields.io/github/v/tag/Master92/cppIni?label=release)](https://github.com/Master92/cppIni/releases)
4-
[![Build](https://img.shields.io/github/actions/workflow/status/Master92/cppIni/build.yaml?logo=github)](https://github.com/Master92/cppIni/actions/workflows/build.yaml)
59
![License](https://img.shields.io/github/license/Master92/cppIni)
610
![GitHub stars](https://img.shields.io/github/stars/Master92/cppIni?label=%E2%AD%90%20Stars)
711

cmake/CodeCoverage.cmake

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
cmake_minimum_required(VERSION 3.24)
2+
3+
# Code coverage configuration
4+
add_library(coverage_config INTERFACE)
5+
if(CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU")
6+
message("Enabling code coverage")
7+
target_compile_options(coverage_config INTERFACE
8+
-O0 # no optimization
9+
-g # generate debug info
10+
--coverage # sets all required flags
11+
)
12+
target_link_options(coverage_config INTERFACE --coverage)
13+
endif()
14+
install(TARGETS coverage_config EXPORT ${PROJECT_NAME}-targets)

conanfile.py

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# cppIni - A C++20 library for reading and writing INI files
2+
# Copyright (C) 2023-2024 Nils Hofmann <nils.friedchen@googlemail.com>
3+
#
4+
# This program is free software: you can redistribute it and/or modify
5+
# it under the terms of the GNU General Public License as published by
6+
# the Free Software Foundation, either version 3 of the License, or
7+
# (at your option) any later version.
8+
#
9+
# This program is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
#
17+
# This program is free software: you can redistribute it and/or modify
18+
# it under the terms of the GNU General Public License as published by
19+
# the Free Software Foundation, either version 3 of the License, or
20+
# (at your option) any later version.
21+
#
22+
# This program is distributed in the hope that it will be useful,
23+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
24+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25+
# GNU General Public License for more details.
26+
#
27+
# You should have received a copy of the GNU General Public License
28+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
29+
30+
from conan import ConanFile
31+
from conan.tools.build import check_min_cppstd
32+
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
33+
34+
35+
class cppiniRecipe(ConanFile):
36+
name = "cppini"
37+
version = "0.2.0"
38+
package_type = "library"
39+
40+
# Optional metadata
41+
license = "GPL-3.0-or-later"
42+
author = "Nils Hofmann <nils.friedchen@gooelamil.com>"
43+
url = "https://github.com/Master92/cppIni"
44+
description = "A C++20 library for reading and writing INI files"
45+
topics = ("c++20", "configuration", "ini")
46+
47+
# Binary configuration
48+
settings = "os", "compiler", "build_type", "arch"
49+
options = {
50+
"shared": [True, False],
51+
"fPIC": [True, False],
52+
"testing": [True, False],
53+
"coverage": [True, False]
54+
}
55+
default_options = {
56+
"shared": False,
57+
"fPIC": True,
58+
"testing": True,
59+
"coverage": False
60+
}
61+
62+
# Sources are located in the same place as this recipe, copy them to the recipe
63+
exports_sources = "CMakeLists.txt", "src/*", "include/*", "cmake/*", "tests/*"
64+
65+
def build_requirements(self):
66+
self.build_requires("cmake/[>=3.24]")
67+
if self.options.testing:
68+
self.test_requires("doctest/[>=2.4]")
69+
70+
def config_options(self):
71+
if self.settings.os == "Windows":
72+
self.options.rm_safe("fPIC")
73+
74+
def configure(self):
75+
if self.options.shared:
76+
self.options.rm_safe("fPIC")
77+
78+
def layout(self):
79+
cmake_layout(self)
80+
81+
def validate(self):
82+
if self.settings.compiler.cppstd:
83+
check_min_cppstd(self, "20")
84+
85+
def generate(self):
86+
deps = CMakeDeps(self)
87+
deps.generate()
88+
tc = CMakeToolchain(self)
89+
tc.variables["BUILD_SHARED_LIBS"] = self.options.shared
90+
tc.variables["BUILD_TESTING"] = self.options.testing
91+
tc.variables["CODE_COVERAGE"] = self.options.coverage
92+
tc.generate()
93+
94+
def build(self):
95+
cmake = CMake(self)
96+
cmake.configure()
97+
cmake.build()
98+
cmake.test()
99+
100+
def package(self):
101+
cmake = CMake(self)
102+
cmake.install()
103+
104+
def package_info(self):
105+
self.cpp_info.libs = ["cppini"]

conanfile.txt

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

0 commit comments

Comments
 (0)