-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
21 changed files
with
756 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,11 @@ on: | |
push: | ||
branches: | ||
- "master" | ||
- "develop" | ||
pull_request: | ||
branches: | ||
- "master" | ||
- "develop" | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
@@ -27,47 +29,47 @@ jobs: | |
# | ||
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. | ||
matrix: | ||
os: [ ubuntu-latest, windows-latest ] | ||
os: [ ubuntu-24.04, windows-latest ] | ||
build_type: [ Release ] | ||
c_compiler: [ gcc, clang, cl ] | ||
include: | ||
- os: windows-latest | ||
c_compiler: cl | ||
cpp_compiler: cl | ||
- os: ubuntu-latest | ||
- os: ubuntu-24.04 | ||
c_compiler: gcc | ||
cpp_compiler: g++ | ||
- os: ubuntu-latest | ||
- os: ubuntu-24.04 | ||
c_compiler: clang | ||
cpp_compiler: clang++ | ||
exclude: | ||
- os: windows-latest | ||
c_compiler: gcc | ||
- os: windows-latest | ||
c_compiler: clang | ||
- os: ubuntu-latest | ||
- os: ubuntu-24.04 | ||
c_compiler: cl | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
|
||
- name: 🔧 Install GCC | ||
uses: egor-tensin/[email protected] | ||
if: matrix.os == 'ubuntu-latest' && matrix.c_compiler == 'gcc' | ||
if: matrix.os == 'ubuntu-24.04' && matrix.c_compiler == 'gcc' | ||
with: | ||
version: 13 | ||
|
||
- name: 🔧 Install Clang | ||
uses: egor-tensin/[email protected] | ||
if: matrix.os == 'ubuntu-latest' && matrix.c_compiler == 'clang' | ||
if: matrix.os == 'ubuntu-24.04' && matrix.c_compiler == 'clang' | ||
with: | ||
version: 16 | ||
|
||
- name: 🔧 Setup python | ||
uses: actions/setup-python@v4 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
cache: pip | ||
python-version: '3.13' | ||
cache: 'pip' | ||
|
||
- name: ☁️ Install required python packages | ||
run: pip install -r requirements.txt | ||
|
@@ -76,27 +78,25 @@ jobs: | |
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. | ||
id: strings | ||
shell: bash | ||
run: echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | ||
run: | | ||
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | ||
if [ "${{ matrix.os }}" == "windows-latest" ]; then | ||
echo "preset-name=conan-default" >> "$GITHUB_OUTPUT" | ||
else | ||
echo "preset-name=conan-release" >> "$GITHUB_OUTPUT" | ||
fi | ||
- name: 🐸 Create default Conan profile | ||
run: conan profile detect | ||
|
||
- name: ☁️ Get dependencies | ||
run: conan install ${{ github.workspace }} --build=missing --output-folder=build --settings compiler.cppstd=20 | ||
run: conan install ${{ github.workspace }} --build=missing -s compiler.cppstd=20 -o testing=True | ||
|
||
- name: 🛠️ Configure CMake | ||
run: > | ||
cmake -B ${{ steps.strings.outputs.build-output-dir }} | ||
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} | ||
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} | ||
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} | ||
-DBUILD_TESTING=ON | ||
--toolchain=conan_toolchain.cmake | ||
-S ${{ github.workspace }} | ||
run: cmake --preset ${{ steps.strings.outputs.preset-name }} | ||
|
||
- name: 🔨 Build project | ||
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --parallel | ||
run: cmake --build --preset conan-release --parallel | ||
|
||
- name: 🏃 Run test suite | ||
working-directory: build | ||
run: ctest --build-config ${{ matrix.build_type }} | ||
run: ctest --preset conan-release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Coverage | ||
|
||
on: | ||
# Triggers the workflow on push or pull request events but only for the "master" branch | ||
push: | ||
branches: | ||
- "master" | ||
- "develop" | ||
pull_request: | ||
branches: | ||
- "master" | ||
- "develop" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: 🔧 Install GCC | ||
uses: egor-tensin/[email protected] | ||
with: | ||
version: 13 | ||
|
||
- name: 🔧 Setup python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
cache: pip | ||
|
||
- name: ☁️ Install required packages | ||
run: | | ||
sudo apt-get install -y lcov | ||
pip install -r requirements.txt | ||
- name: 🐸 Create default Conan profile | ||
run: conan profile detect | ||
|
||
- name: ☁️ Get dependencies | ||
run: conan install ${{ github.workspace }} --build=missing -s compiler.cppstd=20 -o testing=True -o coverage=True | ||
|
||
- name: 🛠️ Configure CMake | ||
run: cmake --preset conan-release | ||
|
||
- name: 🔨 Build project | ||
run: cmake --build --preset conan-release --parallel | ||
|
||
- name: 🏃 Run test suite | ||
run: ctest --preset conan-release | ||
|
||
- name: 📊 Generate coverage reports with lcov | ||
run: | | ||
lcov --directory . --capture --output-file coverage.info --gcov-tool gcov-13 | ||
lcov --remove coverage.info '/usr/*' --remove coverage.info '**/.conan*' --remove coverage.info '**/test*' --remove coverage.info '**/test_package*' --output-file coverage.info | ||
lcov --list coverage.info | ||
- name: ☂️ Upload coverage reports to Codecov | ||
uses: codecov/codecov-action@v3 | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,6 @@ | |
/*build* | ||
/doc | ||
/include/cppIni/cppini_export.h | ||
test_package/build | ||
python | ||
CMakeUserPresets.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
cmake_minimum_required(VERSION 3.24) | ||
|
||
# Code coverage configuration | ||
add_library(coverage_config INTERFACE) | ||
if(CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU") | ||
message("Enabling code coverage") | ||
target_compile_options(coverage_config INTERFACE | ||
-O0 # no optimization | ||
-g # generate debug info | ||
--coverage # sets all required flags | ||
) | ||
target_link_options(coverage_config INTERFACE --coverage) | ||
endif() | ||
install(TARGETS coverage_config EXPORT ${PROJECT_NAME}-targets) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# cppIni - A C++20 library for reading and writing INI files | ||
# Copyright (C) 2023-2024 Nils Hofmann <[email protected]> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
from conan import ConanFile | ||
from conan.tools.build import check_min_cppstd | ||
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps | ||
|
||
|
||
class cppiniRecipe(ConanFile): | ||
name = "cppini" | ||
version = "0.2.0" | ||
package_type = "library" | ||
|
||
# Optional metadata | ||
license = "GPL-3.0-or-later" | ||
author = "Nils Hofmann <[email protected]>" | ||
url = "https://github.com/Master92/cppIni" | ||
description = "A C++20 library for reading and writing INI files" | ||
topics = ("c++20", "configuration", "ini") | ||
|
||
# Binary configuration | ||
settings = "os", "compiler", "build_type", "arch" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
"testing": [True, False], | ||
"coverage": [True, False] | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
"testing": True, | ||
"coverage": False | ||
} | ||
|
||
# Sources are located in the same place as this recipe, copy them to the recipe | ||
exports_sources = "CMakeLists.txt", "src/*", "include/*", "cmake/*", "tests/*" | ||
|
||
def build_requirements(self): | ||
self.build_requires("cmake/[>=3.24]") | ||
if self.options.testing: | ||
self.test_requires("doctest/[>=2.4]") | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
self.options.rm_safe("fPIC") | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
self.options.rm_safe("fPIC") | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def validate(self): | ||
if self.settings.compiler.cppstd: | ||
check_min_cppstd(self, "20") | ||
|
||
def generate(self): | ||
deps = CMakeDeps(self) | ||
deps.generate() | ||
tc = CMakeToolchain(self) | ||
tc.variables["BUILD_SHARED_LIBS"] = self.options.shared | ||
tc.variables["BUILD_TESTING"] = self.options.testing | ||
tc.variables["CODE_COVERAGE"] = self.options.coverage | ||
tc.generate() | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
cmake.test() | ||
|
||
def package(self): | ||
cmake = CMake(self) | ||
cmake.install() | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["cppini"] |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.