]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Choose the clang-format version 6824/head
authorDaniel Garcia-Sanchez <daniel.garcia-sanchez@insp.upmc.fr>
Sat, 23 Jun 2018 11:00:01 +0000 (13:00 +0200)
committerDaniel Garcia-Sanchez <daniel.garcia-sanchez@insp.upmc.fr>
Sat, 23 Jun 2018 11:00:01 +0000 (13:00 +0200)
contrib/utilities/indent
contrib/utilities/indent-all
contrib/utilities/indent_common.sh

index 9cd6790c8a1974fa81cbbd9ff7d916082065f691..ca889f7fcd367c38f07f1ac47859cd727fb8d890 100755 (executable)
@@ -15,7 +15,7 @@
 ## ---------------------------------------------------------------------
 
 #
-# This script does the same thing as contrib/utilities/indent but only
+# This script does the same thing as contrib/utilities/indent-all but only
 # reformats files which have changed (or have been added but neither
 # staged/commited) since the last merge commit to the master branch.
 #
 #   make indent
 # from a build directory.
 #
+# The script can be invoked with DEAL_II_CLANG_FORMAT to change
+# the default version of clang-format. For example:
+#   DEAL_II_CLANG_FORMAT=clang-format-6.0 ./contrib/utilities/indent
+# or,
+#   make DEAL_II_CLANG_FORMAT="clang-format-6.0" indent
+#
 # Note: If the script is invoked with REPORT_ONLY=true set,
 #   REPORT_ONLY=true ./contrib/utilities/indent
 # or,
index f8dfeca48dbefc56537b53406fff57ba9593a350..8682646ac6b02f4cf094d3485cc8d6ee548f82e8 100755 (executable)
 #   make indent-all
 # from a build directory.
 #
+# The script can be invoked with DEAL_II_CLANG_FORMAT to change
+# the default version of clang-format. For example:
+#   DEAL_II_CLANG_FORMAT=clang-format-6.0 ./contrib/utilities/indent
+# or,
+#   make DEAL_II_CLANG_FORMAT="clang-format-6.0" indent
+#
 # Note: If the script is invoked with REPORT_ONLY=true set,
 #   REPORT_ONLY=true ./contrib/utilities/indent-all
 # or,
index df786bc42a187a59a02699b4804ecc18b8ad92c4..81cf5370f15194d60697e4c221cbad3f1f87a54d 100644 (file)
 # to ensure that the rest of the indentation pipeline makes sense.
 #
 
+#
+# DEAL_II_CLANG_FORMAT can be used to change the default version of
+# clang-format
+#
+
+export DEAL_II_CLANG_FORMAT="${DEAL_II_CLANG_FORMAT:-clang-format}"
+
 checks() {
   if test ! -d source -o ! -d include -o ! -d examples ; then
     echo "*** This script must be run from the top-level directory of deal.II."
@@ -35,7 +42,7 @@ checks() {
   CLANG_FORMAT_PATH="$(cd "$(dirname "$0")" && pwd)/programs/clang-6/bin"
   export PATH="${CLANG_FORMAT_PATH}:${PATH}"
 
-  if ! [ -x "$(command -v clang-format)" ]; then
+  if ! [ -x "$(command -v ${DEAL_II_CLANG_FORMAT})" ]; then
     echo "***   No clang-format program found."
     echo "***"
     echo "***   You can run the './contrib/utilities/download_clang_format'"
@@ -46,7 +53,7 @@ checks() {
 
   # Make sure to have the right version. We know that clang-6.0.0
   # and clang-6.0.1 work. Hence, test for clang-6.0.
-  CLANG_FORMAT_VERSION="$(clang-format --version)"
+  CLANG_FORMAT_VERSION="$(${DEAL_II_CLANG_FORMAT} --version)"
   CLANG_FORMAT_MAJOR_VERSION=$(echo "${CLANG_FORMAT_VERSION}" | sed 's/^[^0-9]*\([0-9]*\).*$/\1/g')
   CLANG_FORMAT_MINOR_VERSION=$(echo "${CLANG_FORMAT_VERSION}" | sed 's/^[^0-9]*[0-9]*\.\([0-9]*\).*$/\1/g')
 
@@ -103,7 +110,7 @@ format_file()
   file="${1}"
   tmpfile="$(mktemp "${TMPDIR}/$(basename "$1").tmp.XXXXXXXX")"
 
-  clang-format "${file}" > "${tmpfile}"
+  "${DEAL_II_CLANG_FORMAT}" "${file}" > "${tmpfile}"
   fix_or_report "${file}" "${tmpfile}" "file indented incorrectly"
   rm -f "${tmpfile}"
 }
@@ -131,7 +138,7 @@ format_inst()
   # picks up and uses the .clang-format style-sheet in the current
   # directory.
   #
-  clang-format < "${tmpfile}" > "${tmpfile}new"
+  "${DEAL_II_CLANG_FORMAT}" < "${tmpfile}" > "${tmpfile}new"
 
   sed -i -e 's#{ // namespace#\\{#g' "${tmpfile}new"
   sed -i -e 's#}[ ]*// namespace.*#\\}#g' "${tmpfile}new"

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.