about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--.clang-format33
-rw-r--r--CONTRIBUTING.md5
-rw-r--r--Makefile.am10
3 files changed, 48 insertions, 0 deletions
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 00000000..c2f306e2
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,33 @@
+Language: Cpp
+BasedOnStyle: GNU
+SpaceAfterCStyleCast: false
+SpaceAfterLogicalNot: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeSquareBrackets: false
+SpaceInEmptyBlock: false
+SpaceInEmptyParentheses: false
+SpacesInCStyleCastParentheses: false
+SpacesInConditionalStatement: false
+SpacesInContainerLiterals: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+SpaceBeforeParens: ControlStatements
+ColumnLimit: 0
+PointerAlignment: Left
+AlignAfterOpenBracket: Align
+AlignConsecutiveMacros: true
+AlignEscapedNewlines: Left
+AlignOperands: true
+AlignTrailingComments: true
+AllowAllArgumentsOnNextLine: true
+AllowShortBlocksOnASingleLine: true
+IndentWidth: 4
+BreakBeforeBraces: Custom
+BraceWrapping:
+  AfterCaseLabel: true
+  AfterControlStatement: Never
+  AfterFunction: true
+  BeforeElse: false
+  #BeforeWhile: false
+  AfterStruct: true
+#BreakStringLiterals: true
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 188c13f7..fbedb57c 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -3,6 +3,11 @@
 ## Coding style
 Follow the style already present ;-)
 
+To make this easier for you we created a `.clang-format` file.
+You'll need to have `clang-format` installed.
+
+Then just run `make format` before you do any commit.
+
 ## Pull Requests
 Before submitting a Pull Request please run valgrind and the clang static code analyzer.
 
diff --git a/Makefile.am b/Makefile.am
index 95175c0f..a7fdea7a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -237,6 +237,13 @@ core_sources += $(omemo_sources)
 unittest_sources += $(omemo_unittest_sources)
 endif
 
+all_c_sources = $(core_sources) $(unittest_sources) \
+				$(pgp_sources) $(pgp_unittest_sources) \
+				$(otr3_sources) $(otr4_sources) $(otr_unittest_sources) \
+				$(omemo_sources) $(omemo_unittest_sources) \
+				$(c_sources) $(python_sources) \
+				$(main_source)
+
 AM_CFLAGS = @AM_CFLAGS@ -I$(srcdir)/src
 
 bin_PROGRAMS = profanity
@@ -324,3 +331,6 @@ endif
 
 check-unit: tests/unittests/unittests
 	tests/unittests/unittests
+
+format: $(all_c_sources)
+	clang-format -i $(all_c_sources)