From 92ed0c9146cbd7eda7c7e60c889b1eda494b6445 Mon Sep 17 00:00:00 2001 From: James Zern Date: Wed, 27 Jul 2016 22:16:51 -0700 Subject: [PATCH 1/2] README: add a note about clang-format Change-Id: I835401e3befffcbc68e7d2bdd2fd556a19948e91 (cherry picked from commit 15f29ef0922c6584dea69ac75367edb2f6934bb3) --- README | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README b/README index 460ad7390..0f95a8f45 100644 --- a/README +++ b/README @@ -127,6 +127,21 @@ VP8/VP9 TEST VECTORS: $ ./configure --enable-unit-tests $ LIBVPX_TEST_DATA_PATH=../libvpx-test-data make testdata +CODE STYLE: + The coding style used by this project is enforced with clang-format using the + configuration contained in the .clang-format file in the root of the + repository. + + Before pushing changes for review you can format your code with: + # Apply clang-format to modified .c, .h and .cc files + $ clang-format -i --style=file \ + $(git diff --name-only --diff-filter=ACMR '*.[hc]' '*.cc') + + Check the .clang-format file for the version used to generate it if there is + any difference between your local formatting and the review system. + + See also: http://clang.llvm.org/docs/ClangFormat.html + SUPPORT This library is an open source project supported by its community. Please please email webm-discuss@webmproject.org for help. From 7dcd4993bb6adfe9ff27218dc05da993c8669905 Mon Sep 17 00:00:00 2001 From: James Zern Date: Thu, 4 Aug 2016 20:17:09 -0700 Subject: [PATCH 2/2] remove tools/vpx-style.sh update ftfy.sh to use clang-format Change-Id: I8ac740c5b3842beed2b8878fbe506f381f4c57e4 (cherry picked from commit 958ae5af9c892e5328ec0363d1a69afbfe0e0907) --- tools/ftfy.sh | 7 +++---- tools/vpx-astyle.sh | 27 --------------------------- 2 files changed, 3 insertions(+), 31 deletions(-) delete mode 100755 tools/vpx-astyle.sh diff --git a/tools/ftfy.sh b/tools/ftfy.sh index 29ae95e9b..c005918fe 100755 --- a/tools/ftfy.sh +++ b/tools/ftfy.sh @@ -32,7 +32,7 @@ vpx_style() { for f; do case "$f" in *.h|*.c|*.cc) - "${dirname_self}"/vpx-astyle.sh "$f" + clang-format -i --style=file "$f" ;; esac done @@ -102,9 +102,8 @@ CLEAN_FILES="${CLEAN_FILES} ${ORIG_COMMIT_MSG} ${NEW_COMMIT_MSG}" # Preconditions [ $# -lt 2 ] || usage -# Check that astyle supports pad-header and align-pointer=name -if ! astyle --pad-header --align-pointer=name < /dev/null; then - log "Install astyle v1.24 or newer" +if ! clang-format -version >/dev/null 2>&1; then + log "clang-format not found" exit 1 fi diff --git a/tools/vpx-astyle.sh b/tools/vpx-astyle.sh deleted file mode 100755 index 6340426bd..000000000 --- a/tools/vpx-astyle.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -set -e -astyle --style=java --indent=spaces=2 --indent-switches\ - --min-conditional-indent=0 \ - --pad-oper --pad-header --unpad-paren \ - --align-pointer=name \ - --indent-preprocessor --convert-tabs --indent-labels \ - --suffix=none --quiet --max-instatement-indent=80 "$@" -# Disabled, too greedy? -#sed -i 's;[[:space:]]\{1,\}\[;[;g' "$@" - -sed_i() { - # Incompatible sed parameter parsing. - if sed -i 2>&1 | grep -q 'requires an argument'; then - sed -i '' "$@" - else - sed -i "$@" - fi -} - -sed_i -e 's/[[:space:]]\{1,\}\([,;]\)/\1/g' \ - -e 's/[[:space:]]\{1,\}\([+-]\{2\};\)/\1/g' \ - -e 's/,[[:space:]]*}/}/g' \ - -e 's;//\([^/[:space:]].*$\);// \1;g' \ - -e 's/^\(public\|private\|protected\):$/ \1:/g' \ - -e 's/[[:space:]]\{1,\}$//g' \ - "$@"