Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[infra/cmd] Update format command #14601

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions infra/command/format
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
INVALID_EXIT=0
FILES_TO_CHECK=()
DIRECTORIES_TO_BE_TESTED=()
DIRECTORIES_NOT_TO_BE_TESTED=()
DEFAULT_CLANG_VERSION="16"
CLANG_FORMAT_CANDIDATE=clang-format-$DEFAULT_CLANG_VERSION
PATCH_FILE=format.patch
Expand Down Expand Up @@ -124,16 +123,9 @@ function check_cpp_files() {

# Check c++ files: replace ' ' with newline, check with grep
FILES_TO_CHECK_CPP=`echo "$FILES_TO_CHECK" | tr ' ' '\n' | egrep '((\.c[cl]?)|(\.cpp)|(\.h(pp)?))$'`
# Manually ignore style checking
FILES_TO_CHECK_CPP=`echo "$FILES_TO_CHECK_CPP" | egrep -v '((/NeuralNetworks\.h)|(/NeuralNetworksExtensions\.h))$'`
Comment on lines -127 to -128
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q) are these related with .FORMATDENY ? or another format update ? (I assume we don't need to check these NeuralNetworks files)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are ignored by compiler/ann-api/include/.clang-format and tests/nnapi/bridge/include/.clang-format. I'll update commit comment.

# Transform to array
FILES_TO_CHECK_CPP=($FILES_TO_CHECK_CPP)

# Skip by '.FORMATDENY' file
for s in ${DIRECTORIES_NOT_TO_BE_TESTED[@]}; do
FILES_TO_CHECK_CPP=(${FILES_TO_CHECK_CPP[*]/$s*/})
done

if [[ ${#FILES_TO_CHECK_CPP} -ne 0 ]]; then
${CLANG_FORMAT} -i ${FILES_TO_CHECK_CPP[@]}
EXIT_CODE=$?
Expand Down Expand Up @@ -210,10 +202,6 @@ if [[ "${CHECK_DIFF_ONLY}" = "1" ]]; then
fi
fi

for DIR_NOT_TO_BE_TESTED in $(git ls-files -co --exclude-standard '*/.FORMATDENY'); do
DIRECTORIES_NOT_TO_BE_TESTED+=($(dirname "${DIR_NOT_TO_BE_TESTED}"))
done

check_newline
check_permission
check_cpp_files
Expand Down