## ---------------------------------------------------------------------
#
-# 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,
# 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,
# 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."
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'"
# 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')
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}"
}
# 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"