diff options
Diffstat (limited to 'comm/taskcluster/scripts/source-test-clang-format.sh')
-rwxr-xr-x | comm/taskcluster/scripts/source-test-clang-format.sh | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/comm/taskcluster/scripts/source-test-clang-format.sh b/comm/taskcluster/scripts/source-test-clang-format.sh new file mode 100755 index 0000000000..90f449a03b --- /dev/null +++ b/comm/taskcluster/scripts/source-test-clang-format.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -e + +# Run the Firefox setup script +source "$HOME/checkouts/gecko/taskcluster/scripts/misc/source-test-clang-setup.sh" + +# Append comm/.clang-format-ignore contents to $topsrcdir/.clang-format-ignore +sed -e 's%^\([a-z]\)%comm/\1%' comm/.clang-format-ignore >> .clang-format-ignore + +# Update mozconfig file with Thunderbird build options +cat <<EOT >> "$MOZCONFIG" +ac_add_options --enable-project=comm/mail +EOT + +# Run mach clang-format +# shellcheck disable=SC2068 +./mach --log-no-times clang-format --output "$HOME/clang-format.json" --format json -p $@ +# shellcheck disable=SC2068 +./mach --log-no-times clang-format --output "$HOME/clang-format.diff" --format diff -p $@ + +# Exit with an error code if clang-format.diff contains a proper diff. +# Needed because mach clang-format will exit 0 regardless of outcome. +# If no formatting is needed, clang-format.diff will have a single \n, +# so check for a file size > 1 byte. +DIFF_SIZE=$(stat -c %s "$HOME/clang-format.diff") +if [[ "$DIFF_SIZE" -gt 1 ]]; then + echo "Exiting with error status. DIFF_SIZE is $DIFF_SIZE." + exit 1 +else + exit 0 +fi |