aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/lint.sh18
-rwxr-xr-xscripts/style.sh35
2 files changed, 43 insertions, 10 deletions
diff --git a/scripts/lint.sh b/scripts/lint.sh
index d474129..3d4f453 100755
--- a/scripts/lint.sh
+++ b/scripts/lint.sh
@@ -68,10 +68,21 @@ else
command=(git ls-files)
fi
+# POSIX xargs is required to run commands at least once, but cpplint.py fails
+# (with huge help text) if no files are supplied. Apple xargs avoids invocation
+# if there are no arguments. Use a temporary file to avoid depending on/testing
+# for this feature.
+TEMP=$(mktemp -t lint-files-$$.XXXXXXXXXX)
+trap "rm '$TEMP'" EXIT
+
# Straight C++ files get regular cpplint
"${command[@]}" "${git_options[@]}" \
-- 'Firestore/core/**/*.'{h,cc} \
- | xargs -0 python scripts/cpplint.py --quiet 2>&1
+ > "$TEMP"
+
+if [[ -s "$TEMP" ]]; then
+ xargs -0 python scripts/cpplint.py --quiet 2>&1 < "$TEMP"
+fi
CPP_STATUS=$?
# Objective-C++ files get a looser cpplint
@@ -79,7 +90,10 @@ CPP_STATUS=$?
-- 'Firestore/Source/**/*.'{h,m,mm} \
'Firestore/Example/Tests/**/*.'{h,m,mm} \
'Firestore/core/**/*.mm' \
- | xargs -0 python scripts/cpplint.py "${objc_lint_options[@]}" --quiet 2>&1
+ > "$TEMP"
+if [[ -s "$TEMP" ]]; then
+ xargs -0 python scripts/cpplint.py "${objc_lint_options[@]}" --quiet 2>&1 < "$TEMP"
+fi
OBJC_STATUS=$?
if [[ $CPP_STATUS != 0 || $OBJC_STATUS != 0 ]]; then
diff --git a/scripts/style.sh b/scripts/style.sh
index d8825f2..f82af77 100755
--- a/scripts/style.sh
+++ b/scripts/style.sh
@@ -21,18 +21,36 @@
# Commonly
# ./scripts/style.sh master
-system=$(uname -s)
-
+# Strip the clang-format version output down to the major version. Examples:
+# clang-format version 7.0.0 (tags/google/stable/2018-01-11)
+# clang-format version google3-trunk (trunk r333779)
version=$(clang-format --version)
+
+# Remove leading "clang-format version"
version="${version/*version /}"
+# Remove trailing parenthetical version details
+version="${version/ (*)/}"
+# Remove everything after the first dot (note this is a glob, not a regex)
version="${version/.*/}"
-if [[ "$version" != 6 && "$version" != 7 ]]; then
- # Allow an older clang-format to accommodate Travis version skew.
- echo "Please upgrade to clang-format version 7."
- echo "If it's installed via homebrew you can run: brew upgrade clang-format"
- exit 1
-fi
+case "$version" in
+ 6 | 7)
+ # Allow an older clang-format to accommodate Travis version skew.
+ ;;
+ google3-trunk)
+ echo "Please use a publicly released clang-format; a recent LLVM release"
+ echo "from http://releases.llvm.org/download.html will work."
+ echo "Prepend to PATH when running style.sh."
+ exit 1
+ ;;
+ *)
+ echo "Please upgrade to clang-format version 7."
+ echo "If it's installed via homebrew you can run: brew upgrade clang-format"
+ exit 1
+ ;;
+esac
+
+system=$(uname -s)
if [[ "$system" == "Darwin" ]]; then
version=$(swiftformat --version)
version="${version/*version /}"
@@ -122,6 +140,7 @@ s%^./%%
# Checked-in generated code
\%\.pb(objc|rpc)\.% d
\%\.pb\.% d
+\%\.nanopb\.% d
# Format C-ish sources only
\%\.(h|m|mm|cc|swift)$% p