mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mp...@apache.org
Subject [mesos] branch master updated: Added supporting scripts for Mesos LLVM Tools.
Date Sun, 23 Sep 2018 01:24:04 GMT
This is an automated email from the ASF dual-hosted git repository.

mpark pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git


The following commit(s) were added to refs/heads/master by this push:
     new 270c4cb  Added supporting scripts for Mesos LLVM Tools.
270c4cb is described below

commit 270c4cb62f5680bcf952bfb7ec8dfc10843f21e0
Author: Michael Park <mpark@apache.org>
AuthorDate: Sat Sep 22 16:22:57 2018 -0700

    Added supporting scripts for Mesos LLVM Tools.
    
    Review: https://reviews.apache.org/r/66114/
---
 support/llvm/README.md  | 90 +++++++++++++++++++++++++++++++++++++++++++++++++
 support/llvm/install.sh | 84 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 174 insertions(+)

diff --git a/support/llvm/README.md b/support/llvm/README.md
new file mode 100644
index 0000000..1889302
--- /dev/null
+++ b/support/llvm/README.md
@@ -0,0 +1,90 @@
+# Mesos LLVM Tools
+
+This is an overview of the Mesos-flavored LLVM Tools we maintain.
+  - MesosFormat: [mesos/clang]
+  - MesosTidy: [mesos/clang-tools-extra]
+
+[mesos/clang]: https://github.com/mesos/clang
+[mesos/clang-tools-extra]: https://github.com/mesos/clang-tools-extra
+
+Statically-linked pre-built binaries are
+  - __hosted__ on [Bintray][bintray]
+  - __installed__ by [install.sh] in `<MESOS_DIR>/.git/llvm/<VERSION>`
+  - __built__ by scripts at [mesos/llvm]
+
+[bintray]: https://bintray.com/apache/mesos/llvm
+[install.sh]: install.sh
+[mesos/llvm]: https://github.com/mesos/llvm
+
+## MesosFormat
+
+[ClangFormat] is a Clang-based formatting tool. While the provided configuration
+is close to the Mesos C++ Style Guide, we are not yet at a point where we take
+the result produced by [ClangFormat] to be the final definitive answer.
+
+The current expected workflow is to integrate it into your favorite editor
+and format selected regions of code.
+
+### Configuration
+
+By default, [ClangFormat] uses the configuration defined in a `.clang-format`
+file located in the nearest parent directory of the input file.
+The `bootstrap` script creates a `.clang-format` symlink at `<MESOS_DIR>`
+which points to `support/clang-format` for [ClangFormat] to find.
+
+### Integration
+
+#### Vim
+
+Add the following to your `.vimrc`:
+
+```
+let g:clang_format_path = "<MESOS_DIR>/.git/llvm/active/bin/clang-format"
+
+map <C-K> :pyf <MESOS_DIR>/.git/llvm/active/share/clang/clang-format.py<CR>
+imap <C-K> <C-O>:pyf <MESOS_DIR>/.git/llvm/active/share/clang/clang-format.py<CR>
+```
+
+Refer to https://clang.llvm.org/docs/ClangFormat.html#vim-integration
+
+[ClangFormat]: https://clang.llvm.org/docs/ClangFormat.html
+
+## MesosTidy
+
+[ClangTidy] is a Clang-based linter tool.
+
+### Configuration
+
+By default, [ClangTidy] uses the configuration defined in a `.clang-tidy`
+file located in the nearest parent directory of the input file.
+The `bootstrap` script creates a `.clang-tidy` symlink at `<MESOS_DIR>`
+which points to `support/clang-tidy` for [ClangTidy] to find.
+
+### Invocation
+
+The script `support/mesos-tidy.py` is a slightly modified version of
+[`run-clang-tidy.py`][run-clang-tidy], a tool that runs `clang-tidy`
+over all files in a compilation database.
+
+[run-clang-tidy]: https://github.com/llvm-mirror/clang-tools-extra/blob/release_60/clang-tidy/tool/run-clang-tidy.py
+
+Run the checks with a temporary compilation database:
+
+```bash
+./support/mesos-tidy.py 1> clang-tidy.log
+```
+
+Run the checks with an existing compilation database:
+
+```bash
+./support/mesos-tidy.py -p build 1> clang-tidy.log
+```
+
+Run the checks with an existing compilation database,
+apply fix-its, and reformat the code after:
+
+```
+./support/mesos-tidy.py -p build -fix -format
+```
+
+[ClangTidy]: http://clang.llvm.org/extra/clang-tidy/
diff --git a/support/llvm/install.sh b/support/llvm/install.sh
new file mode 100755
index 0000000..98923bd
--- /dev/null
+++ b/support/llvm/install.sh
@@ -0,0 +1,84 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+
+#     http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e
+set -o pipefail
+
+: "${VERSION:="2018-03-08"}"
+
+LLVM_DIR="$(git rev-parse --git-common-dir)/llvm"
+INSTALL_DIR="${LLVM_DIR}/${VERSION}"
+
+mkdir -p "${LLVM_DIR}"
+
+function activate() {
+  ln -nsf "${VERSION}" "${LLVM_DIR}/active"
+  echo "'${LLVM_DIR}/active' now points at '${VERSION}'."
+}
+
+if [ -d "${INSTALL_DIR}" ]; then
+  echo "Mesos LLVM tools ${VERSION} are already installed at '${INSTALL_DIR}'."
+
+  activate
+  exit 1
+fi
+
+mkdir -p "${INSTALL_DIR}"
+
+OS="$(uname -s)"
+
+BINTRAY_URL="https://apache.bintray.com"
+
+case "${OS}" in
+  Linux)
+    EXT="linux.tar.gz"
+    ;;
+  Darwin)
+    VER="$(sw_vers -productVersion)"
+    case "${VER}" in
+      10.11.*)
+        EXT="el_capitan.bottle.tar.gz"
+        ;;
+      10.12.*)
+        EXT="sierra.bottle.tar.gz"
+        ;;
+      10.13.*)
+        EXT="high_sierra.bottle.tar.gz"
+        ;;
+      *)
+        echo "Mesos LLVM tools are currently not available for Mac OS X ${VER}."
+        exit 2
+        ;;
+    esac
+    ;;
+  *)
+    echo "Mesos LLVM tools are currently not available for ${OS}."
+    exit 2
+    ;;
+esac
+
+for TOOL in "mesos-format" "mesos-tidy"
+do
+  URL="${BINTRAY_URL}/mesos/${TOOL}-${VERSION}.${EXT}"
+  curl -sSL "${URL}" | tar -xz --strip-components=2 -C "${INSTALL_DIR}"
+  if [ $? -eq 0 ]; then
+    echo "Installed '${TOOL}' in '${INSTALL_DIR}'."
+  fi
+done
+
+activate


Mime
View raw message