summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.clang-format40
-rw-r--r--.editorconfig5
-rw-r--r--.yamlfmt.yml41
-rw-r--r--Makefile10
4 files changed, 93 insertions, 3 deletions
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..d0c759b
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,40 @@
+---
+# .clang-format - How to format C files in sbc-harness
+#
+# Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
+# SPDX-Licence-Identifier: AGPL-3.0-or-later
+
+Language: Cpp
+
+LineEnding: LF
+
+# Indentation
+UseTab: ForContinuationAndIndentation
+TabWidth: 8
+IndentWidth: 8
+ContinuationIndentWidth: 8
+ColumnLimit: 80
+IndentCaseLabels: false
+
+# Brace style
+AllowShortIfStatementsOnASingleLine: false
+BreakBeforeBraces: Attach
+
+# Alignment
+AlignConsecutiveAssignments:
+ Enabled: true
+ AcrossEmptyLines: false
+ AcrossComments: false
+AlignConsecutiveDeclarations:
+ Enabled: true
+ AcrossEmptyLines: false
+ AcrossComments: false
+
+# Preprocessor
+SortIncludes: CaseSensitive
+PPIndentWidth: -1 # inherit from IndentWidth
+AlignConsecutiveMacros:
+ Enabled: true
+ AcrossEmptyLines: true
+ AcrossComments: false
+AlignEscapedNewlines: Left
diff --git a/.editorconfig b/.editorconfig
index 2aa13e7..362e1bb 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -39,6 +39,11 @@ _mode = bash
[{lib9p/idl.gen,lib9p/include/lib9p/linux-errno.h.gen}]
_mode = python3
+[{*.yml,.clang-format}]
+_mode = yaml
+indent_style = space
+indent_size = 4
+
[{.editorconfig,.gitmodules}]
_mode = ini
diff --git a/.yamlfmt.yml b/.yamlfmt.yml
new file mode 100644
index 0000000..67a341d
--- /dev/null
+++ b/.yamlfmt.yml
@@ -0,0 +1,41 @@
+---
+# .yamlfmt.yml - How to format YAML files in sbc-harness
+#
+# Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
+# SPDX-Licence-Identifier: AGPL-3.0-or-later
+
+# Format options
+formatter:
+ type: basic
+ # Newlines
+ line_ending: lf
+ eof_newline: true
+ retain_line_breaks: false
+ retain_line_breaks_single: true
+ scan_folded_as_literal: false
+ # Indentation
+ indent: 4
+ indentless_arrays: false
+ # Other whitespace
+ pad_line_comments: 1
+ trim_trailing_whitespace: true
+ # Other
+ include_document_start: true
+ disallow_anchors: true
+ drop_merge_tag: false
+ max_line_length: 70
+
+# Program operation
+continue_on_error: false
+output_format: default
+
+# Which files to process
+doublestar: false
+exclude: []
+include: []
+gitignore_excludes: false
+gitignore_path: .gitignore
+regex_exclude: []
+extensions:
+ - yaml
+ - yml
diff --git a/Makefile b/Makefile
index d0c5c78..b4931b0 100644
--- a/Makefile
+++ b/Makefile
@@ -76,7 +76,9 @@ lint/python3: lint/%:
black --check $(sources_$*)
isort --check $(sources_$*)
lint/c: lint/%:
- @: TODO
+ clang-format --dry-run -Werror -- $(sources_$*)
+lint/yaml: lint/%:
+ yamlfmt -lint $(sources_$*)
lint/make lint/cmake lint/gitignore lint/ini lint/9p lint/markdown: lint/%:
@:
lint/unknown: lint/%:
@@ -89,7 +91,7 @@ lint/all: lint/%:
if ! grep -q 'Copyright (C) 2024 Luke T. Shumaker' $$filename; then \
echo "$$filename is missing a copyright statement"; r=1; continue; \
fi; \
- dscname=$$(sed -n '1,3{ /^#!/d; /^<!--$$/d; /-\*- .* -\*-/d; s,[/*# ]*,,; s/ - .*//;p; q; }' $$filename); \
+ dscname=$$(sed -En '1,3{ /^#!|^<!--$$|-\*- .* -\*-|^---$$/d; s,[/*# ]*,,; s/ - .*//;p; q; }' $$filename); \
filename_alt1=$$(echo "$$filename" | sed \
-e 's,^cmd/,,' \
-e 's,.*/include/,,' \
@@ -112,7 +114,9 @@ format/python3: format/%:
format/sh format/bash: format/%
@:
format/c: format/%:
- @: TODO
+ clang-format -i -- $(sources_$*)
+format/yaml: format/%:
+ yamlfmt $(sources_$*)
format/make format/cmake format/gitignore format/ini format/9p format/markdown: format/%:
@:
format/unknown: format/%: