|
18 | 18 |
|
19 | 19 | set -e |
20 | 20 |
|
21 | | -echo "Running 2 cpplints..." |
22 | | -python3 3rdparty/dmlc-core/scripts/lint.py --quiet tvm cpp \ |
23 | | - include src \ |
24 | | - examples/extension/src examples/graph_executor/src \ |
25 | | - tests/cpp tests/crt \ |
26 | | - --exclude_path "src/runtime/hexagon/rpc/hexagon_rpc.h" \ |
27 | | - "src/runtime/hexagon/rpc/hexagon_rpc_skel.c" \ |
28 | | - "src/runtime/hexagon/rpc/hexagon_rpc_stub.c" \ |
| 21 | +LINT_ALL_FILES=true |
| 22 | +REVISION= |
29 | 23 |
|
| 24 | +while (( $# )); do |
| 25 | + case "$1" in |
| 26 | + --rev) |
| 27 | + LINT_ALL_FILES=false |
| 28 | + REVISION=$2 |
| 29 | + shift 2 |
| 30 | + ;; |
| 31 | + *) |
| 32 | + echo "Usage: tests/lint/cpplint.sh [--rev <commit>]" |
| 33 | + exit 1 |
| 34 | + ;; |
| 35 | + esac |
| 36 | +done |
| 37 | + |
| 38 | +if [[ "$LINT_ALL_FILES" == "true" ]]; then |
| 39 | + echo "Running 2 cpplints..." |
| 40 | + python3 3rdparty/dmlc-core/scripts/lint.py --quiet tvm cpp \ |
| 41 | + include src \ |
| 42 | + examples/extension/src examples/graph_executor/src \ |
| 43 | + tests/cpp tests/crt \ |
| 44 | + --exclude_path "src/runtime/hexagon/rpc/hexagon_rpc.h" \ |
| 45 | + "src/runtime/hexagon/rpc/hexagon_rpc_skel.c" \ |
| 46 | + "src/runtime/hexagon/rpc/hexagon_rpc_stub.c" \ |
| 47 | + |
| 48 | +else |
| 49 | + echo "Running cpplint on changed files..." |
| 50 | + # Get changed files, filtering by the directories we care about |
| 51 | + # We use git diff to find changes. |
| 52 | + # We filter for the directories: include, src, examples/extension/src, examples/graph_executor/src, tests/cpp, tests/crt |
| 53 | + |
| 54 | + # grep pattern construction |
| 55 | + DIRS="include|src|examples/extension/src|examples/graph_executor/src|tests/cpp|tests/crt" |
| 56 | + |
| 57 | + # Read files into array |
| 58 | + IFS=$'\n' read -a FILES -d'\n' < <(git diff --name-only --diff-filter=ACMRTUX $REVISION | grep -E "^($DIRS)/" ) || true |
| 59 | + |
| 60 | + # Filter out excluded files |
| 61 | + FILTERED_FILES=() |
| 62 | + for f in "${FILES[@]}"; do |
| 63 | + if [[ "$f" == "src/runtime/hexagon/rpc/hexagon_rpc.h" ]] || \ |
| 64 | + [[ "$f" == "src/runtime/hexagon/rpc/hexagon_rpc_skel.c" ]] || \ |
| 65 | + [[ "$f" == "src/runtime/hexagon/rpc/hexagon_rpc_stub.c" ]]; then |
| 66 | + continue |
| 67 | + fi |
| 68 | + FILTERED_FILES+=("$f") |
| 69 | + done |
| 70 | + |
| 71 | + if [ ${#FILTERED_FILES[@]} -eq 0 ]; then |
| 72 | + echo "No changes in C++ files" |
| 73 | + else |
| 74 | + python3 3rdparty/dmlc-core/scripts/lint.py --quiet tvm cpp "${FILTERED_FILES[@]}" |
| 75 | + fi |
| 76 | +fi |
30 | 77 |
|
31 | 78 | if find src -name "*.cc" -exec grep -Hn '^#include <regex>$' {} +; then |
32 | 79 | echo "The <regex> header file may not be used in TVM," 1>&2 |
33 | 80 | echo "because it causes ABI incompatibility with most pytorch installations." 1>&2 |
34 | | - echo "Pytorch packages on PyPI currently set `-DUSE_CXX11_ABI=0`," 1>&2 |
| 81 | + echo "Pytorch packages on PyPI currently set \`-DUSE_CXX11_ABI=0\`," 1>&2 |
35 | 82 | echo "which causes ABI compatibility when calling <regex> functions." 1>&2 |
36 | 83 | echo "See https://github.com/pytorch/pytorch/issues/51039 for more details." 1>&2 |
37 | 84 | exit 1 |
|
0 commit comments