blob: 876ab292bd9dedd972a6fb64d322cc6aa39afe27 [file] [log] [blame]
#!/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
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
set -o pipefail
# Prepare sources
git clone --depth 1 file:///SRC "${SRCDIR}"
# Populate the `.clang-tidy` at the top-level.
cp "${SRCDIR}"/support/clang-tidy "${SRCDIR}"/.clang-tidy
# Configure sources
cmake -DCMAKE_BUILD_TYPE=Release \
# Set up CMake to run as many parallel build process as we have cores instead
# of relying on the default parallelism of the particular build tool.
# Build the external dependencies.
# TODO(mpark): Use an external dependencies target once MESOS-6924 is resolved.
cmake --build 3rdparty --parallel --target boost-1.65.0
cmake --build 3rdparty --parallel --target elfio-3.2
cmake --build 3rdparty --parallel --target glog-0.4.0
cmake --build 3rdparty --parallel --target googletest-1.8.0
cmake --build 3rdparty --parallel --target grpc-1.10.0
cmake --build 3rdparty --parallel --target http_parser-2.6.2
# TODO(mpark): The `|| true` is a hack to try both `libev` and `libevent` and
# use whichever one happens to be configured. This would also go
# away with MESOS-6924.
cmake --build 3rdparty --parallel --target libev-4.22 || true
cmake --build 3rdparty --parallel --target libevent-2.1.5-beta || true
cmake --build 3rdparty --parallel --target leveldb-1.19
cmake --build 3rdparty --parallel --target nvml-352.79
cmake --build 3rdparty --parallel --target picojson-1.3.0
cmake --build 3rdparty --parallel --target protobuf-3.5.0
cmake --build 3rdparty --parallel --target zookeeper-3.4.8
# Generate the protobuf definitions.
# TODO(mpark): Use a protobuf generation target once MESOS-6925 is resolved.
cmake --build . --parallel --target mesos-protobufs
# For protobuf definitions in stout (`protobuf-test.pb.h`) or
# libprocess (`grpc_tests.pb.h`, `grpc_tests.grpc.pb.h` and `benchmarks.pb.h`)
# no explict targets exists; we instead build the executable targets to produce
# them as a side-effect. This is pretty hacky for what we want to do, but it's
# okay for now.
cmake --build 3rdparty/stout/tests --parallel --target stout-tests
cmake --build 3rdparty/libprocess/src/tests --parallel --target libprocess-tests
cmake --build 3rdparty/libprocess/src/tests --parallel --target benchmarks
# TODO(bbannier): Use a less restrictive `grep` pattern and `header-filter`
# once MESOS-6115 is fixed.
cat compile_commands.json \
| jq '.[].file' \
| sed 's/"//g' \
| sed 's/^\ //g' \
| grep "^${SRCDIR}/.*\.cpp$" \
| parallel -j $(nproc) clang-tidy -p "${PWD}" \
-extra-arg=-Wno-unknown-warning-option \
-extra-arg=-Wno-unused-command-line-argument \
-header-filter="^${SRCDIR}/.*\.hpp$" -checks="${CHECKS}" \
1> clang-tidy.log 2> /dev/null
# Propagate any errors.
if test -s clang-tidy.log; then
cat clang-tidy.log
exit 1
echo "No mesos-tidy violations found."