Skip to content

Commit ad499b1

Browse files
committed
Add support of Conan and others
- Create dot files for clang-tidy clang-format and cmake-format - Create Dockerfile for the env
1 parent 58dc4c0 commit ad499b1

17 files changed

Lines changed: 378 additions & 1 deletion

.clang-format

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
Language: Cpp
3+
ConstructorInitializerIndentWidth: 4
4+
AlignEscapedNewlinesLeft: true
5+
AlignTrailingComments: true
6+
AllowAllParametersOfDeclarationOnNextLine: false
7+
AllowShortIfStatementsOnASingleLine: false
8+
AllowShortLoopsOnASingleLine: false
9+
AllowShortFunctionsOnASingleLine: true
10+
AlwaysBreakTemplateDeclarations: true
11+
BreakBeforeBinaryOperators: false
12+
BreakBeforeTernaryOperators: true
13+
BreakConstructorInitializersBeforeComma: true
14+
BinPackArguments: false
15+
BinPackParameters: false
16+
ColumnLimit: 120
17+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
18+
DerivePointerBinding: false
19+
ExperimentalAutoDetectBinPacking: false
20+
IndentCaseLabels: true
21+
MaxEmptyLinesToKeep: 1
22+
NamespaceIndentation: All
23+
ObjCSpaceAfterProperty: false
24+
ObjCSpaceBeforeProtocolList: false
25+
PenaltyBreakBeforeFirstCallParameter: 1
26+
PenaltyBreakComment: 300
27+
PenaltyBreakString: 1000
28+
PenaltyBreakFirstLessLess: 120
29+
PenaltyExcessCharacter: 1000000
30+
PenaltyReturnTypeOnItsOwnLine: 200
31+
PointerBindsToType: true
32+
SpacesBeforeTrailingComments: 1
33+
Cpp11BracedListStyle: false
34+
Standard: 'Latest'
35+
IndentWidth: 4
36+
TabWidth: 4
37+
UseTab: Never
38+
BreakBeforeBraces: Allman
39+
IndentFunctionDeclarationAfterType: true
40+
SpacesInParentheses: false
41+
SpacesInAngles: false
42+
SpaceInEmptyParentheses: false
43+
SpacesInCStyleCastParentheses: false
44+
SpacesInContainerLiterals: true
45+
SpaceBeforeAssignmentOperators: true
46+
ContinuationIndentWidth: 4
47+
CommentPragmas: '^ IWYU pragma:'
48+
SpaceBeforeParens: ControlStatements
49+
...

.clang-tidy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# vi: ft=yaml
2+
Checks: '-*'
3+
FormatStyle: 'file'
4+
HeaderFilterRegex: '.*'

.clangd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Diagnostics:
2+
UnusedIncludes: Strict
3+
MissingIncludes: Strict
4+
AnalyzeAngledIncludes: Yes
5+
CompileFlags:
6+
Remove: [-DNDEBUG]

.cmake-format

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
# -----------------------------
2+
# Options affecting formatting.
3+
# -----------------------------
4+
with section("format"):
5+
6+
# Disable formatting entirely, making cmake-format a no-op
7+
disable = True
8+
9+
# How wide to allow formatted cmake files
10+
line_width = 80
11+
12+
# How many spaces to tab for indent
13+
tab_size = 4
14+
15+
# If true, lines are indented using tab characters (utf-8 0x09) instead of
16+
# <tab_size> space characters (utf-8 0x20). In cases where the layout would
17+
# require a fractional tab character, the behavior of the fractional
18+
# indentation is governed by <fractional_tab_policy>
19+
use_tabchars = False
20+
21+
# If <use_tabchars> is True, then the value of this variable indicates how
22+
# fractional indentions are handled during whitespace replacement. If set to
23+
# 'use-space', fractional indentation is left as spaces (utf-8 0x20). If set
24+
# to `round-up` fractional indentation is replaced with a single tab character
25+
# (utf-8 0x09) effectively shifting the column to the next tabstop
26+
fractional_tab_policy = 'use-space'
27+
28+
# If an argument group contains more than this many sub-groups (parg or kwarg
29+
# groups) then force it to a vertical layout.
30+
max_subgroups_hwrap = 2
31+
32+
# If a positional argument group contains more than this many arguments, then
33+
# force it to a vertical layout.
34+
max_pargs_hwrap = 6
35+
36+
# If a cmdline positional group consumes more than this many lines without
37+
# nesting, then invalidate the layout (and nest)
38+
max_rows_cmdline = 2
39+
40+
# If true, separate flow control names from their parentheses with a space
41+
separate_ctrl_name_with_space = False
42+
43+
# If true, separate function names from parentheses with a space
44+
separate_fn_name_with_space = False
45+
46+
# If a statement is wrapped to more than one line, than dangle the closing
47+
# parenthesis on its own line.
48+
dangle_parens = False
49+
50+
# If the trailing parenthesis must be 'dangled' on its on line, then align it
51+
# to this reference: `prefix`: the start of the statement, `prefix-indent`:
52+
# the start of the statement, plus one indentation level, `child`: align to
53+
# the column of the arguments
54+
dangle_align = 'prefix'
55+
56+
# If the statement spelling length (including space and parenthesis) is
57+
# smaller than this amount, then force reject nested layouts.
58+
min_prefix_chars = 4
59+
60+
# If the statement spelling length (including space and parenthesis) is larger
61+
# than the tab width by more than this amount, then force reject un-nested
62+
# layouts.
63+
max_prefix_chars = 10
64+
65+
# If a candidate layout is wrapped horizontally but it exceeds this many
66+
# lines, then reject the layout.
67+
max_lines_hwrap = 2
68+
69+
# What style line endings to use in the output.
70+
line_ending = 'unix'
71+
72+
# Format command names consistently as 'lower' or 'upper' case
73+
command_case = 'canonical'
74+
75+
# Format keywords consistently as 'lower' or 'upper' case
76+
keyword_case = 'unchanged'
77+
78+
# A list of command names which should always be wrapped
79+
always_wrap = []
80+
81+
# If true, the argument lists which are known to be sortable will be sorted
82+
# lexicographicall
83+
enable_sort = True
84+
85+
# If true, the parsers may infer whether or not an argument list is sortable
86+
# (without annotation).
87+
autosort = False
88+
89+
# By default, if cmake-format cannot successfully fit everything into the
90+
# desired linewidth it will apply the last, most agressive attempt that it
91+
# made. If this flag is True, however, cmake-format will print error, exit
92+
# with non-zero status code, and write-out nothing
93+
require_valid_layout = False
94+
95+
# A dictionary mapping layout nodes to a list of wrap decisions. See the
96+
# documentation for more information.
97+
layout_passes = {}
98+
99+
# ------------------------------------------------
100+
# Options affecting comment reflow and formatting.
101+
# ------------------------------------------------
102+
with section("markup"):
103+
104+
# What character to use for bulleted lists
105+
bullet_char = '*'
106+
107+
# What character to use as punctuation after numerals in an enumerated list
108+
enum_char = '.'
109+
110+
# If comment markup is enabled, don't reflow the first comment block in each
111+
# listfile. Use this to preserve formatting of your copyright/license
112+
# statements.
113+
first_comment_is_literal = False
114+
115+
# If comment markup is enabled, don't reflow any comment block which matches
116+
# this (regex) pattern. Default is `None` (disabled).
117+
literal_comment_pattern = None
118+
119+
# Regular expression to match preformat fences in comments default=
120+
# ``r'^\s*([`~]{3}[`~]*)(.*)$'``
121+
fence_pattern = '^\\s*([`~]{3}[`~]*)(.*)$'
122+
123+
# Regular expression to match rulers in comments default=
124+
# ``r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'``
125+
ruler_pattern = '^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$'
126+
127+
# If a comment line matches starts with this pattern then it is explicitly a
128+
# trailing comment for the preceeding argument. Default is '#<'
129+
explicit_trailing_pattern = '#<'
130+
131+
# If a comment line starts with at least this many consecutive hash
132+
# characters, then don't lstrip() them off. This allows for lazy hash rulers
133+
# where the first hash char is not separated by space
134+
hashruler_min_length = 10
135+
136+
# If true, then insert a space between the first hash char and remaining hash
137+
# chars in a hash ruler, and normalize its length to fill the column
138+
canonicalize_hashrulers = True
139+
140+
# enable comment markup parsing and reflow
141+
enable_markup = True
142+
143+
# ----------------------------
144+
# Options affecting the linter
145+
# ----------------------------
146+
with section("lint"):
147+
148+
# a list of lint codes to disable
149+
disabled_codes = ['C0113']
150+
151+
# regular expression pattern describing valid function names
152+
function_pattern = '[0-9a-z_]+'
153+
154+
# regular expression pattern describing valid macro names
155+
macro_pattern = '[0-9A-Z_]+'
156+
157+
# regular expression pattern describing valid names for variables with global
158+
# (cache) scope
159+
global_var_pattern = '[A-Z][0-9A-Z_]+'
160+
161+
# regular expression pattern describing valid names for variables with global
162+
# scope (but internal semantic)
163+
internal_var_pattern = '_[A-Z][0-9A-Z_]+'
164+
165+
# regular expression pattern describing valid names for variables with local
166+
# scope
167+
local_var_pattern = '[a-z][a-z0-9_]+'
168+
169+
# regular expression pattern describing valid names for privatedirectory
170+
# variables
171+
private_var_pattern = '_[0-9a-z_]+'
172+
173+
# regular expression pattern describing valid names for public directory
174+
# variables
175+
public_var_pattern = '[A-Z][0-9A-Z_]+'
176+
177+
# regular expression pattern describing valid names for function/macro
178+
# arguments and loop variables.
179+
argument_var_pattern = '[a-z][a-z0-9_]+'
180+
181+
# regular expression pattern describing valid names for keywords used in
182+
# functions or macros
183+
keyword_pattern = '[A-Z][0-9A-Z_]+'
184+
185+
# In the heuristic for C0201, how many conditionals to match within a loop in
186+
# before considering the loop a parser.
187+
max_conditionals_custom_parser = 2
188+
189+
# Require at least this many newlines between statements
190+
min_statement_spacing = 1
191+
192+
# Require no more than this many newlines between statements
193+
max_statement_spacing = 2
194+
max_returns = 6
195+
max_branches = 12
196+
max_arguments = 5
197+
max_localvars = 15
198+
max_statements = 50
199+
200+
# -------------------------------
201+
# Options affecting file encoding
202+
# -------------------------------
203+
with section("encode"):
204+
205+
# If true, emit the unicode byte-order mark (BOM) at the start of the file
206+
emit_byteorder_mark = False
207+
208+
# Specify the encoding of the input file. Defaults to utf-8
209+
input_encoding = 'utf-8'
210+
211+
# Specify the encoding of the output file. Defaults to utf-8. Note that cmake
212+
# only claims to support utf-8 so be careful when using anything else
213+
output_encoding = 'utf-8'
214+
215+
# -------------------------------------
216+
# Miscellaneous configurations options.
217+
# -------------------------------------
218+
with section("misc"):
219+
220+
# A dictionary containing any per-command configuration overrides. Currently
221+
# only `command_case` is supported.
222+
per_command = {}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: centipede-environment
2+
3+
on:
4+
schedule:
5+
# trigger the workflow on the every sunday at 2 am UTC
6+
- cron: '0 2 * * 6'
7+
workflow_dispatch:
8+
9+
jobs:
10+
docker-build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
submodules: 'true'
18+
19+
- name: Login to Docker Hub
20+
uses: docker/login-action@v3
21+
with:
22+
username: yanzhaowang
23+
password: ${{ secrets.DOCKERHUB_TOKEN }}
24+
25+
- name: Build and push
26+
uses: docker/build-push-action@v6
27+
with:
28+
push: true
29+
context: util/container_env
30+
tags: yanzhaowang/centipede:env

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "util/conan"]
2+
path = util/conan
3+
url = https://github.com/conan-io/cmake-conan.git

CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
cmake_minimum_required(VERSION 3.28 FATAL_ERROR)
22

3-
project(centipede LANGUAGES CXX VERSION 0.0.1)
3+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
4+
5+
include(check_submodules)
6+
7+
project(centipede LANGUAGES CXX C VERSION 0.0.1)
8+
9+
include(load_dependencies)
410

511
add_subdirectory(source)
12+
add_subdirectory(doc)
13+
add_subdirectory(example)
14+
add_subdirectory(test)

CMakePresets.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"binaryDir": "${sourceDir}/build",
1414
"cacheVariables": {
1515
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
16+
"CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "util/conan/conan_provider.cmake",
1617
"CMAKE_CXX_STANDARD": "23",
1718
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
1819
"CMAKE_CXX_EXTENSIONS": "ON",

cmake/check_submodules.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/util/conan/conan_provider.cmake")
2+
message(
3+
FATAL_ERROR
4+
"\n\
5+
Conan configuration file \"conan_provider.cmake\" doesn't exist!\n\
6+
Did you forget to do:\n\
7+
git submodule update --init --recursive\n\
8+
"
9+
)
10+
else()
11+
message(STATUS "Git submodules has been loaded.")
12+
endif()

cmake/load_dependencies.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
find_package(spdlog REQUIRED CONFIG)
2+
find_package(magic_enum REQUIRED CONFIG)
3+
find_package(CLI11 REQUIRED CONFIG)

0 commit comments

Comments
 (0)