summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2024-04-07 23:14:18 +0200
committerJohannes Stoelp <johannes.stoelp@gmail.com>2024-04-07 23:14:18 +0200
commit2b13efa7b78ab2bb08cba52e09b1f12af1701fd9 (patch)
treed2a2c51dcfe2e2db5fd25db3a77b96829141564b
parentdc8c474ec4460d07e42c97e5fc24af99ec5bf3e4 (diff)
downloadcpp-templates-2b13efa7b78ab2bb08cba52e09b1f12af1701fd9.tar.gz
cpp-templates-2b13efa7b78ab2bb08cba52e09b1f12af1701fd9.zip
make: add make file and clang-{tidy,format} configs
-rw-r--r--.clang-format16
-rw-r--r--.clang-tidy33
-rw-r--r--Makefile26
3 files changed, 75 insertions, 0 deletions
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..0a1656e
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,16 @@
+# dotfiles -- clang-format
+# author: johannst
+# doc : https://clang.llvm.org/docs/ClangFormatStyleOptions.html
+---
+
+Language: Cpp
+BasedOnStyle: Chromium
+
+AllowShortFunctionsOnASingleLine: None
+#AllowShortFunctionsOnASingleLine: Empty
+
+AccessModifierOffset: -2
+IndentWidth: 2
+
+AlignConsecutiveMacros: true
+AlignConsecutiveAssignments: true
diff --git a/.clang-tidy b/.clang-tidy
new file mode 100644
index 0000000..fa33f96
--- /dev/null
+++ b/.clang-tidy
@@ -0,0 +1,33 @@
+HeaderFilterRegex: '.*'
+WarningsAsErrors: '*'
+
+# Available checks:
+# https://clang.llvm.org/extra/clang-tidy/index.html#using-clang-tidy
+# https://clang.llvm.org/extra/clang-tidy/checks/list.html
+#
+# List all checks:
+# clang-tidy --checks="*" --list-checks
+#
+# Excuse all lints for a line inside the source code:
+# some code; // NOLINT
+#
+# // NOLINTNEXTLINE
+# some code;
+#
+# Excuse a single lint for a line inside the source code:
+# some code; // NOLINT(bugprone-macro-parentheses)
+#
+# // NOLINTNEXTLINE(bugprone-macro-parentheses)
+# some code;
+Checks: >
+ -*,
+ readability-*,
+
+# readability-identifier-naming.* options:
+# https://clang.llvm.org/extra/clang-tidy/checks/readability/identifier-naming.html
+CheckOptions:
+ - { key: readability-identifier-naming.ClassCase, value: lower_case }
+ - { key: readability-identifier-naming.MemberCase, value: lower_case }
+ - { key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }
+ - { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase }
+ - { key: readability-identifier-naming.TypeAliasCase, value: lower_case }
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..16d98bb
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,26 @@
+SRC = $(shell git ls-files '*.cc')
+
+check: $(SRC:.cc=.x)
+lint : $(SRC:.cc=.l)
+fmt : $(SRC:.cc=.f)
+
+%.x: %.cc
+ bash $^
+
+%.l: %.cc
+ clang-format -n --Werror $^
+ clang-tidy $^
+
+%.f: %.cc
+ clang-format -i $^
+
+help:
+ @echo "Targets that apply to all .cc files under scm:"
+ @echo "* check execute build commands in each file"
+ @echo " lint clang-format & clang-tidy lint"
+ @echo " fmt re-format each file"
+ @echo ""
+ @echo "Targets that apply to a single .cc file (where <name> is the file name w/o .cc suffix):"
+ @echo " <name>.x only execute <name>.cc"
+ @echo " <name>.l only lint <name>.cc"
+ @echo " <name>.f only re-format <name>.cc"