From ce5c92754f471192f977824948f406e79635b345 Mon Sep 17 00:00:00 2001 From: scribblemaniac Date: Fri, 27 Sep 2019 23:42:25 -0600 Subject: [PATCH 1/4] Create Astyle options file from the agreed upon formmating guidelines --- .astylerc | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .astylerc diff --git a/.astylerc b/.astylerc new file mode 100644 index 0000000000..38a29bd014 --- /dev/null +++ b/.astylerc @@ -0,0 +1,42 @@ +## Formatting options for +## Astyle - Source code indenter, formatter, and beautifier for C, C++, and Java Source Code +## http://astyle.sourceforge.net/ + +# Indent as C/C++ +mode=c +# Use LF line end style +lineend=linux + +# Allman style formatting/indenting uses broken brackets +style=allman + +# Grant an exception to the Allman style bracketing for `extern "c"` statements. +attach-extern-c +# Attach while statement to closing bracket of a do {} while statment +attach-closing-while + +# Indent using 4 spaces per indent +indent=spaces=4 +convert-tabs +# Indent labels so they match the current indentation rather than being flush to the left +indent-labels +# Make sure all comments are indented with the code +indent-col1-comments +# No min indents for a header is built of multiple lines. This assures they are always aligned. +min-conditional-indent=0 +# Don't restrict the max contiunation indent as much as possible. Still, it shouldn't be close to 120 ever. +max-continuation-indent=120 + +# Insert space padding around operators and after commas +pad-oper +# Remove unnecessary padding around parentheses +unpad-paren +# Attach pointers and references to the variable name +align-pointer=name +# Insert space padding after paren headers only (e.g. 'if', 'for', 'while'...) +pad-header + +# Add braces to one-line conditional statements +add-braces +# Leave one-line blocks as-is. This should only be used with single statements. +keep-one-line-blocks From 3b03259ed5ff8329d893b92abc62d1135a1d4598 Mon Sep 17 00:00:00 2001 From: scribblemaniac Date: Sat, 28 Sep 2019 00:01:10 -0600 Subject: [PATCH 2/4] Add Astyle check to the Travis builds --- .travis.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index cf7315e122..b4a5849370 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,6 +47,7 @@ addons: - graphviz - python3 - python3-pip + - astyle before_install: - | @@ -57,7 +58,7 @@ before_install: if [ "$ver" -le "27" ]; then brew upgrade python; fi - brew install p7zip qt gpg; + brew install p7zip qt gpg astyle; brew link qt --force; fi @@ -70,10 +71,14 @@ install: - pip3 -V before_script: - - echo "are changes related to source code?" + - 'echo "Checking style guidelines"; + astyle -rn --project "./*.cpp" "./*.h"; + git diff; + git checkout -- .;' + - echo "Are changes related to source code?" - 'if [ "$TRAVIS_BRANCH" != "release" ]; then - bash $TRAVIS_BUILD_DIR/util/checkchanges.sh; - fi' + bash $TRAVIS_BUILD_DIR/util/checkchanges.sh; + fi' - 'if [ "$TRAVIS_OS_NAME" == "linux" ]; then . /opt/qt59/bin/qt59-env.sh; export DISPLAY=:99.0; From 65ae259f370fb6a06693de417d5919b83ffc9875 Mon Sep 17 00:00:00 2001 From: scribblemaniac Date: Sat, 28 Sep 2019 00:04:58 -0600 Subject: [PATCH 3/4] Add a code style profile for the Qt Creator Not as comprehensive as the Astyle guidelines, but contains some minor variations over the default Qt style. --- util/qt_creator_code_style.xml | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 util/qt_creator_code_style.xml diff --git a/util/qt_creator_code_style.xml b/util/qt_creator_code_style.xml new file mode 100644 index 0000000000..2f8d3f3f6f --- /dev/null +++ b/util/qt_creator_code_style.xml @@ -0,0 +1,40 @@ + + + + + + CodeStyleData + + true + false + true + false + false + false + false + false + true + false + false + false + true + true + false + true + false + false + false + 4 + true + false + 2 + false + true + 4 + + + + DisplayName + Pencil2D + + From 85432d9b14e23a3f03382a46a41a043448afc1e5 Mon Sep 17 00:00:00 2001 From: scribblemaniac Date: Tue, 1 Oct 2019 11:50:57 -0600 Subject: [PATCH 4/4] Exclude miniz library from astyle --- .astylerc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.astylerc b/.astylerc index 38a29bd014..5de8f3527d 100644 --- a/.astylerc +++ b/.astylerc @@ -40,3 +40,7 @@ pad-header add-braces # Leave one-line blocks as-is. This should only be used with single statements. keep-one-line-blocks + +# Exclude third-party libraries +exclude=miniz.cpp +exclude=miniz.h