From: Matthias Maier Date: Wed, 16 May 2018 22:58:04 +0000 (-0500) Subject: Contrib: Add a script to compile clang-format X-Git-Tag: v9.1.0-rc1~1126^2~6 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04404338c093cdeba446a184007d91db43a3b094;p=dealii.git Contrib: Add a script to compile clang-format --- diff --git a/contrib/utilities/compile_clang_format b/contrib/utilities/compile_clang_format new file mode 100755 index 0000000000..c538d11e91 --- /dev/null +++ b/contrib/utilities/compile_clang_format @@ -0,0 +1,81 @@ +#!/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, compiles and installs the clang-format binary. The +# destination directory is +# [contrib/utilities]/programs/clang-/bin. +# +# Compiling clang-format and all necessary parts of LLVM/CLANG might +# require a significant amount of resources. Alternatively, you can use +# download_clang_format to install a statically-linked binary. +# + +set -e +set -u + +PRG="$(cd "$(dirname "$0")" && pwd)/programs" + +CLANG_PATH="${PRG}/clang-6" + +RELEASE_DATE="2018-04-06" +RELEASE_BRANCH="release_60" +LLVM_REPOSITORY="https://github.com/llvm-mirror/llvm" +CLANG_REPOSITORY="https://github.com/llvm-mirror/clang" +LLVM_COMMIT="1a0dddf879aadfcfea409b3c0a9aa3c9da306945" +CLANG_COMMIT="d5f48a217f404c3462537527f4169bb45eed3904" + +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 compiling clang-format-6." +mkdir -p "${CLANG_PATH}/bin" + +tmpdir="${TMPDIR:-/tmp}/dealiiclang${RANDOM}${RANDOM}" +mkdir -p "${tmpdir}" +cd "${tmpdir}" + +git init +git remote add origin "${LLVM_REPOSITORY}" +git fetch --shallow-since="${RELEASE_DATE}" origin "${RELEASE_BRANCH}" +git reset --hard "${LLVM_COMMIT}" + +git init tools/clang +cd tools/clang +git remote add origin "${CLANG_REPOSITORY}" +git fetch --shallow-since="${RELEASE_DATE}" origin "${RELEASE_BRANCH}" +git reset --hard "${CLANG_COMMIT}" + +cd ../../ +mkdir build +cd build +cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DLLVM_BUILD_STATIC=true .. +make -j4 clang-format +cp bin/clang-format "${CLANG_PATH}"/bin +cp ../{CODE_OWNERS,CREDITS,LICENSE}.TXT "${CLANG_PATH}" +rm -rf "${tmpdir}" + +echo "All done. clang-format succesfully installed into" +echo " ${CLANG_PATH}/clang-6/bin"