Created
June 22, 2018 09:19
-
-
Save bbannier/312fb769362811ccc9bedc078ef02e4b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
set -o pipefail | |
readonly MESOS_DIR="$(git rev-parse --show-toplevel)" | |
# shellcheck source=atexit.sh | |
. "$MESOS_DIR"/support/atexit.sh | |
SOURCE_DIRS="$MESOS_DIR/src $MESOS_DIR/3rdparty" | |
# Get a list of all source files in the tree. | |
# | |
# We rely on the fact that in Mesos source files end in `.cpp`. | |
readonly FILES=$(mktemp) | |
atexit "rm $FILES" | |
for file in $(cd "$MESOS_DIR" && git ls-files "$MESOS_DIR" | grep '.*\.cpp'); do | |
realpath "$MESOS_DIR/$file" | |
done | sort > "$FILES" | |
# Get a list of all source files in the cmake build. | |
# | |
# Since Mesos add source files to the cmake build conditionally, even | |
# cmake does not know the full list of all possible source files. As a | |
# heuristic we search the cmake build for likely source file names. | |
readonly CMAKE_FILES=$(mktemp) | |
atexit "rm $CMAKE_FILES" | |
# shellcheck disable=SC2086 | |
# shellcheck disable=SC2044 | |
for cm in $(find $SOURCE_DIRS -name CMakeLists.txt); do | |
base="$(dirname "$cm")" | |
# shellcheck disable=SC2013 | |
for file in $(grep -o '\(\S\)*\w\+\.cpp' "$cm"); do | |
# We ignore weird filename-like patterns which do | |
# not correspond to a path. | |
realpath "$base/$file" || true | |
done | |
done | sort > "$CMAKE_FILES" | |
if ! diff -a "$FILES" "$CMAKE_FILES" > /dev/null; then | |
printf "%s\\n" "The following files do not appear in any CMakeLists.txt:" | |
comm -23 "$FILES" "$CMAKE_FILES" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment