From f1baadb4deb1e7c48b62a8c430082cffc693e15a Mon Sep 17 00:00:00 2001 From: louib Date: Thu, 26 Dec 2019 13:47:12 -0500 Subject: [PATCH] Setup code formatting with make. --- .clang-format | 16 ++++++++-------- .github/workflows/ci.yml | 11 +++++++---- .github/workflows/ci_ubuntu-16.04.yml | 11 +++++++---- Makefile.am | 7 +++++++ 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/.clang-format b/.clang-format index eddf6db..933ee34 100644 --- a/.clang-format +++ b/.clang-format @@ -1,11 +1,11 @@ --- Language: Cpp AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: true -AlignConsecutiveDeclarations: true +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false AlignEscapedNewlinesLeft: false -AlignOperands: true -AlignTrailingComments: true +AlignOperands: false +AlignTrailingComments: false AllowAllParametersOfDeclarationOnNextLine: false AllowShortBlocksOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false @@ -22,7 +22,7 @@ BraceWrapping: AfterClass: true AfterFunction: true AfterControlStatement: true - AfterEnum: true + AfterEnum: false AfterNamespace: true AfterStruct: true AfterUnion: true @@ -47,7 +47,7 @@ IncludeCategories: - Regex: '.*' Priority: 1 IndentCaseLabels: true -IndentWidth: 8 +IndentWidth: 4 IndentWrappedFunctionNames: false KeepEmptyLinesAtTheStartOfBlocks: true MacroBlockBegin: '' @@ -74,7 +74,7 @@ SpacesInCStyleCastParentheses: false SpacesInParentheses: true SpacesInSquareBrackets: false Standard: Cpp11 -TabWidth: 8 -UseTab: Always +TabWidth: 4 +UseTab: Never ... diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a40409..28a1d1b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,13 +9,16 @@ jobs: steps: - uses: actions/checkout@v1 - - name: update repo + - name: updating available system dependencies run: sudo apt-get update - name: installing system dependencies - run: sudo apt-get install -y build-essential pkg-config automake libncurses5-dev autotools-dev libparted-dev dmidecode + run: sudo apt-get install -y build-essential pkg-config automake libncurses5-dev autotools-dev libparted-dev dmidecode clang-format-5.0 - name: creating autoconf files run: ./init.sh - - name: configure + - name: configuring run: ./configure CFLAGS='-O0 -g -Wall -Wextra' - - name: make + - name: compiling run: make + # Changing the path should no longer be necessary when clang-format6 is installed. + # - name: verifying code style + # run: export PATH=$PATH:/usr/lib/llvm-5.0/bin && make check-format diff --git a/.github/workflows/ci_ubuntu-16.04.yml b/.github/workflows/ci_ubuntu-16.04.yml index 5e1f0cf..a8870a6 100644 --- a/.github/workflows/ci_ubuntu-16.04.yml +++ b/.github/workflows/ci_ubuntu-16.04.yml @@ -9,13 +9,16 @@ jobs: steps: - uses: actions/checkout@v1 - - name: update repo + - name: updating available system dependencies run: sudo apt-get update - name: installing system dependencies - run: sudo apt-get install -y build-essential pkg-config automake libncurses5-dev autotools-dev libparted-dev dmidecode + run: sudo apt-get install -y build-essential pkg-config automake libncurses5-dev autotools-dev libparted-dev dmidecode clang-format-5.0 - name: creating autoconf files run: ./init.sh - - name: configure + - name: configuring run: ./configure CFLAGS='-O0 -g -Wall -Wextra' - - name: make + - name: compiling run: make + # Changing the path should no longer be necessary when clang-format6 is installed. + # - name: verifying code style + # run: export PATH=$PATH:/usr/lib/llvm-5.0/bin && make check-format diff --git a/Makefile.am b/Makefile.am index 45a33d3..f1896c0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,2 +1,9 @@ AUTOMAKE_OPTIONS = foreign SUBDIRS = src man +nwipe_SOURCES = src/*.c src/*.h + +format: + clang-format -i -style=file $(nwipe_SOURCES) + +check-format: + clang-format -i -style=file $(nwipe_SOURCES) && git diff-index --quiet HEAD