Skip to content

Commit

Permalink
Only run iwyu on compilation units actually changed in PR
Browse files Browse the repository at this point in the history
  • Loading branch information
dagardner-nv committed Aug 2, 2023
1 parent 6a26e4f commit cccef95
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions ci/scripts/cpp_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,22 @@ if [[ -n "${MRC_MODIFIED_FILES}" ]]; then

# Include What You Use
if [[ "${SKIP_IWYU}" == "" ]]; then
IWYU_DIRS="cpp python"
# Remove .h, .hpp, and .cu files from the modified list
shopt -s extglob
IWYU_MODIFIED_FILES=( "${MRC_MODIFIED_FILES[@]/*.@(h|hpp|cu)/}" )

# Get the list of compiled files relative to this directory
WORKING_PREFIX="${PWD}/"
COMPILED_FILES=( $(jq -r .[].file ${BUILD_DIR}/compile_commands.json | sort -u ) )
COMPILED_FILES=( "${COMPILED_FILES[@]/#$WORKING_PREFIX/}" )
COMBINED_FILES=("${COMPILED_FILES[@]}")
COMBINED_FILES+=("${IWYU_MODIFIED_FILES[@]}")

# Find the intersection between compiled files and modified files
IWYU_MODIFIED_FILES=( $(printf '%s\0' "${COMBINED_FILES[@]}" | sort -z | uniq -d -z | xargs -0n1) )

NUM_PROC=$(get_num_proc)
IWYU_OUTPUT=`${IWYU_TOOL} -p ${BUILD_DIR} -j ${NUM_PROC} ${IWYU_DIRS} 2>&1`
IWYU_OUTPUT=`${IWYU_TOOL} -p ${BUILD_DIR} -j ${NUM_PROC} ${IWYU_MODIFIED_FILES[@]} 2>&1`
IWYU_RETVAL=$?
fi
else
Expand Down

0 comments on commit cccef95

Please sign in to comment.