Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
BasedOnStyle: LLVM
BreakBeforeBraces: Custom
BraceWrapping:
AfterFunction: true
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 1
BreakConstructorInitializers: BeforeComma
ColumnLimit: 100
IndentWidth: 4
AlwaysBreakTemplateDeclarations: Yes

9 changes: 9 additions & 0 deletions .cmake-format.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"line_width": 100,
"tab_size": 4,
"max_pargs_hwrap": 4,
"max_subargs_per_line": 4,
"separate_ctrl_name_with_space": false,
"separate_fn_name_with_space": false,
"dangle_parens": false
}
25 changes: 25 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{c,cc,cpp,cxx,h,hh,hpp,hxx,ipp,tpp}]
indent_style = space
indent_size = 4
tab_width = 4
max_line_length = 100

[CMakeLists.txt]
indent_style = tab
tab_width = 4

[*.cmake]
indent_style = tab
tab_width = 4

[*.{json,jsonc}]
indent_style = space
indent_size = 2
41 changes: 41 additions & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: ci-build

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v7

- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install --yes \
clang-format \
libgtest-dev \
ninja-build \
pipx
pipx install cmakelang
pipx install cmakelint
echo "$HOME/.local/bin" >> "$GITHUB_PATH"

- name: Check C++ formatting
run: ./scripts/lint.sh cpp-format

- name: Check CMake formatting
run: ./scripts/lint.sh cmake-format

- name: Lint CMake files
run: ./scripts/lint.sh cmake-lint

- name: Configure, build, and test
working-directory: ctprintf
run: cmake --workflow --preset debug-workflow
15 changes: 15 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/ctprintf/include"
],
"cppStandard": "c++20",
"intelliSenseMode": "linux-gcc-x64",
"compilerPath": "/usr/bin/c++",
"cStandard": "gnu17"
}
],
"version": 4
}
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"ms-vscode.cpptools",
"ms-vscode.cmake-tools",
"cheshirekow.cmake-format",
"sonarsource.sonarlint-vscode"
]
}
28 changes: 28 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"cmake.useCMakePresets": "always",
"cmake.options.statusBarVisibility": "compact",
"cmake.options.advanced": {
"ctest": {
"statusBarVisibility": "hidden"
},
"testPreset": {
"statusBarVisibility": "hidden"
}
},
"cmake.sourceDirectory": "${workspaceFolder}/ctprintf",
"cmake.configureOnOpen": false,
"cmake.configureOnEdit": false,
"cmake.loadCompileCommands": false,
"cmake.skipConfigureIfCachePresent": true,
"cmake.parallelJobs": 0,
"cmake.copyCompileCommands": "${workspaceFolder}/ctprintf/build/debug/compile_commands.json",
"sonarlint.pathToCompileCommands": "${workspaceFolder}/ctprintf/build/debug/compile_commands.json",
"[cmake]": {
"editor.defaultFormatter": "cheshirekow.cmake-format",
"editor.formatOnSave": true,
"editor.tabSize": 4,
"editor.insertSpaces": true
},
"cmake-format.configFile": "${workspaceFolder}/.cmake-format.json",
"cmake-format.executable": "cmake-format"
}
84 changes: 84 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "configure",
"type": "cmake",
"command": "configure",
"preset": "${input:buildType}",
"problemMatcher": []
},
{
"label": "build",
"type": "cmake",
"command": "build",
"targets": [
"all"
],
"preset": "${input:buildType}",
"group": "build",
"problemMatcher": "$gcc",
"dependsOn": [
"configure"
]
},
{
"label": "clean",
"type": "cmake",
"command": "clean",
"preset": "${input:buildType}",
"problemMatcher": []
},
{
"label": "Run CMake workflow",
"type": "shell",
"command": "cmake",
"args": [
"--workflow",
"--fresh",
"--preset",
"${input:buildType}-workflow"
],
"options": {
"cwd": "${workspaceFolder}/ctprintf"
},
"problemMatcher": [],
"group": "test",
"presentation": {
"reveal": "always",
"echo": true,
"focus": true,
"panel": "dedicated",
"clear": true
}
},
{
"label": "Lint",
"type": "shell",
"command": "./scripts/lint.sh",
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [],
"presentation": {
"reveal": "always",
"echo": true,
"focus": true,
"panel": "dedicated",
"clear": true
}
}
],
"inputs": [
{
"id": "buildType",
"type": "pickString",
"description": "Select the CMake workflow preset",
"options": [
"debug",
"release"
],
"default": "debug"
},
]
}
26 changes: 26 additions & 0 deletions ctprintf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 3.25)
project(ctprintf LANGUAGES CXX)

option(ENABLE_TESTING "Build and enable tests" OFF)

add_library(ctprintf INTERFACE)

add_library(ctprintf::ctprintf ALIAS ctprintf)

target_sources(
ctprintf
INTERFACE include/ctprintf/format.hpp
include/ctprintf/output.hpp
include/ctprintf/types.hpp
include/ctprintf/detail/formatter.hpp
include/ctprintf/detail/parser.hpp)

target_include_directories(ctprintf INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)

target_compile_features(ctprintf INTERFACE cxx_std_20)

if(ENABLE_TESTING)
include(CTest)
enable_testing()
add_subdirectory(tests)
endif() # ENABLE_TESTING
96 changes: 96 additions & 0 deletions ctprintf/CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 25,
"patch": 0
},
"configurePresets": [
{
"name": "debug",
"displayName": "Debug",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"ENABLE_TESTING": "ON",
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
}
},
{
"name": "release",
"displayName": "Release",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"ENABLE_TESTING": "ON",
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
}
}
],
"buildPresets": [
{
"name": "debug",
"configurePreset": "debug"
},
{
"name": "release",
"configurePreset": "release"
}
],
"testPresets": [
{
"name": "debug",
"configurePreset": "debug",
"output": {
"outputOnFailure": true
}
},
{
"name": "release",
"configurePreset": "release",
"output": {
"outputOnFailure": true
}
}
],
"workflowPresets": [
{
"name": "debug-workflow",
"displayName": "Debug: configure, build, and test",
"steps": [
{
"type": "configure",
"name": "debug"
},
{
"type": "build",
"name": "debug"
},
{
"type": "test",
"name": "debug"
}
]
},
{
"name": "release-workflow",
"displayName": "Release: configure, build, and test",
"steps": [
{
"type": "configure",
"name": "release"
},
{
"type": "build",
"name": "release"
},
{
"type": "test",
"name": "release"
}
]
}
]
}
Loading
Loading