aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/style.sh
diff options
context:
space:
mode:
authorGravatar Gil <mcg@google.com>2018-06-06 12:31:37 -0700
committerGravatar GitHub <noreply@github.com>2018-06-06 12:31:37 -0700
commit7dbf5caa5f25551658aee614247aed10012166e2 (patch)
tree6696ec6fcd43ab55e0dd8fc927a48ecae7161d0e /scripts/style.sh
parent2b0f4627383574b09414117985b4d204312b9cc0 (diff)
Fix support scripts on Linux (#1385)
* Make it possible to run style.sh on Linux Needs clang-format in a nonstandard location, but can be made to work. * Fix lint.sh on Linux * Fix multiline comment error
Diffstat (limited to 'scripts/style.sh')
-rwxr-xr-xscripts/style.sh34
1 files changed, 26 insertions, 8 deletions
diff --git a/scripts/style.sh b/scripts/style.sh
index 8eff1e8..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 /}"