summaryrefslogtreecommitdiffstats
path: root/comm/taskcluster/scripts/source-test-clang-format.sh
blob: 90f449a03be28b3131a743b7f1ff691b83e370ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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