diff options
author | Damien Martin-Guillerez <dmarting@google.com> | 2016-07-01 13:33:48 +0000 |
---|---|---|
committer | Damien Martin-Guillerez <dmarting@google.com> | 2016-07-01 13:36:48 +0000 |
commit | 7d265e07e7a1e37f04d53342710e4f21d9ee8083 (patch) | |
tree | d84b71d801ab8065f9f4f5b94972643c4c26b580 /compile.sh | |
parent | fdb5a8c06985d78c55981a981a72bd4f0766ddb8 (diff) |
Add all the sources to //:srcs filegroup and add a check to detect
missing file to it.
We need to activate this check on presubmits
--
Change-Id: Ia95e92d3816ce92bb69bc0e2cf56e9c60b68d970
Reviewed-on: https://bazel-review.googlesource.com/#/c/3949/
MOS_MIGRATED_REVID=126404792
Diffstat (limited to 'compile.sh')
-rwxr-xr-x | compile.sh | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/compile.sh b/compile.sh index 59ec71c72e..eceefa5c38 100755 --- a/compile.sh +++ b/compile.sh @@ -39,21 +39,24 @@ function usage() { echo " Commands for developers:" >&2 echo " all = compile,determinism,test" >&2 echo " determinism = test for stability of Bazel builds" >&2 + echo " srcs = test that //:srcs contains all the sources" >&2 echo " test = run the full test suite of Bazel" >&2 exit 1 } function parse_options() { - local keywords="(compile|all|determinism|bootstrap|test)" + local keywords="(compile|all|determinism|bootstrap|srcs|test)" COMMANDS="${1:-compile}" [[ "${COMMANDS}" =~ ^$keywords(,$keywords)*$ ]] || usage "$@" DO_COMPILE= DO_CHECKSUM= DO_FULL_CHECKSUM=1 DO_TESTS= + DO_SRCS_TEST= [[ "${COMMANDS}" =~ (compile|all) ]] && DO_COMPILE=1 [[ "${COMMANDS}" =~ (bootstrap|determinism|all) ]] && DO_CHECKSUM=1 [[ "${COMMANDS}" =~ (bootstrap) ]] && DO_FULL_CHECKSUM= + [[ "${COMMANDS}" =~ (srcs|all) ]] && DO_SRCS_TEST=1 [[ "${COMMANDS}" =~ (test|all) ]] && DO_TESTS=1 BAZEL_BIN=${2:-"bazel-bin/src/bazel"} @@ -128,6 +131,35 @@ if [ $DO_CHECKSUM ]; then fi # +# Test that //:srcs contains all the sources +# +if [ $DO_SRCS_TEST ]; then + new_step "Checking that //:srcs contains all the sources" + log "Querying //:srcs" + ${BAZEL} query 'kind("source file", deps(//:srcs))' 2>/dev/null \ + | grep -v '^@' \ + | sed -e 's|^//||' | sed 's|^:||' | sed 's|:|/|' \ + | sort -u >"${OUTPUT_DIR}/srcs-query" + + log "Finding all files" + # See file BUILD for the list of grep -v exceptions. + # tools/defaults package is hidden by Bazel so cannot be put in the srcs. + find . -type f | sed 's|./||' \ + | grep -v '^bazel-' | grep -v '^WORKSPACE.user.bzl' \ + | grep -v '^\.' | grep -v '^out/' | grep -v '^output/' \ + | grep -v '^tools/defaults/BUILD' \ + | sort -u >"${OUTPUT_DIR}/srcs-find" + + log "Diffing" + res="$(diff -U 0 "${OUTPUT_DIR}/srcs-find" "${OUTPUT_DIR}/srcs-query" | sed 's|^-||' | grep -Ev '^(@@|\+\+|--)' || true)" + + if [ -n "${res}" ]; then + fail "//:srcs filegroup do not contains all the sources, missing: +${res}" + fi +fi + +# # Tests # if [ $DO_TESTS ]; then |