From: Matthias Maier Date: Wed, 16 May 2018 23:12:58 +0000 (-0500) Subject: Contrib: Add a script to download a static clang-format X-Git-Tag: v9.1.0-rc1~1126^2~5 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb4a66e475b38b5c7176b25e719ab10237e678c8;p=dealii.git Contrib: Add a script to download a static clang-format --- diff --git a/contrib/utilities/download_clang_format b/contrib/utilities/download_clang_format new file mode 100755 index 0000000000..1c34fdb402 --- /dev/null +++ b/contrib/utilities/download_clang_format @@ -0,0 +1,73 @@ +#!/bin/bash +## --------------------------------------------------------------------- +## +## Copyright (C) 2018 by the deal.II authors +## +## This file is part of the deal.II library. +## +## The deal.II library is free software; you can use it, redistribute +## it, and/or modify it under the terms of the GNU Lesser General +## Public License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## The full text of the license can be found in the file LICENSE at +## the top level of the deal.II distribution. +## +## --------------------------------------------------------------------- + +# +# This script downloads and installs the clang-format binary. The +# destination directory is +# [contrib/utilities]/programs/clang-/bin. +# +# This script only works on Linux (amd64) and macOS. For other +# architectures it is necessary to compile the clang-format binary by hand. +# This can be done with the compile_clang_format script. +# + +PRG="$(cd "$(dirname "$0")" && pwd)/programs" +CLANG_PATH="${PRG}/clang-6" + +URL="https://github.com/dealii/dealii/releases/download/v9.0.0" + +# Find out which kind of OS we are running and set the appropriate settings +case "${OSTYPE}" in + linux*) + FILENAME="clang-format-6-linux.tar.gz" + CHECKSUM_CMD="sha256sum" + CHECKSUM="387b42b30db598d51bf26f020c5bef574cb6355210d2f5909691407a0fc81a26 $FILENAME" + ;; + *) + echo "unknown: ${OSTYPE}" + exit 1 + ;; +esac + +if [ ! -d "${PRG}" ] +then + echo "create folder ${PRG}" + mkdir "${PRG}" +fi + +if [ -d "${CLANG_PATH}" ] +then + echo "${CLANG_PATH} exists. Exiting." + exit 1 +fi + +echo "Downloading and installing clang-format-6." +mkdir "${CLANG_PATH}" + +tmpdir="${TMPDIR:-/tmp}/dealiiclang${RANDOM}${RANDOM}" +mkdir -p "${tmpdir}" +cd "${tmpdir}" +curl -s -L "${URL}/${FILENAME}" -O > /dev/null +if echo "${CHECKSUM}" | "${CHECKSUM_CMD}" -c; then + tar xfz "${FILENAME}" -C "${PRG}" > /dev/null +else + echo "*** The downloaded file has the wrong SHA256 checksum!" + exit 1 +fi +rm -r "${tmpdir}" + +echo "All done. clang-format succesfully installed into" +echo " ${CLANG_PATH}/clang-6/bin"