Skip to content

Commit

Permalink
Draft: [infra] Remove .FORMATDENY file
Browse files Browse the repository at this point in the history
This commit removes .FORMATDENY file.
It uses .yapfignore file to ignore yapf formatting and DisableFormat option  for clang-format formatting.

ONE-DCO-1.0-Signed-off-by: Hyeongseok Oh <[email protected]>
  • Loading branch information
hseok-oh committed Jan 16, 2025
1 parent 55ebd1b commit bd45a2f
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 44 deletions.
3 changes: 3 additions & 0 deletions .yapfignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
runtime/3rdparty/**/*
tests/nnapi/nnapi_test_generator/**/*
tests/nnapi/specs/**/*
Empty file.
1 change: 1 addition & 0 deletions compiler/ann-api/include/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DisableFormat: true
Empty file removed compiler/ann-ref/.FORMATDENY
Empty file.
1 change: 1 addition & 0 deletions compiler/ann-ref/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DisableFormat: true
17 changes: 0 additions & 17 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))$'`
# 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 @@ -166,11 +158,6 @@ function check_python_files() {
# Exceptional case: fm-equalize doesn't have '.py' extension.
FILES_TO_CHECK_PYTHON+=(`echo "$FILES_TO_CHECK" | tr ' ' '\n' | egrep '^compiler/fm-equalize/fm-equalize$'`)

for s in ${DIRECTORIES_NOT_TO_BE_TESTED[@]}; do
skip=${s#'.'/}/
FILES_TO_CHECK_PYTHON=(${FILES_TO_CHECK_PYTHON[*]/$skip*/})
done

if [[ ${#FILES_TO_CHECK_PYTHON} -ne 0 ]]; then
yapf -i ${FILES_TO_CHECK_PYTHON[@]}
EXIT_CODE=$?
Expand Down Expand Up @@ -215,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
42 changes: 15 additions & 27 deletions infra/nnfw/command/copyright-check
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,22 @@

INVALID_EXIT=0

# Files to check copyright headers
# TODO Check python files as well
FILE_PATTERNS=(*.h *.hpp *.cpp *.cc *.c *.cl)

# Manually ignore checking - 3rd party, generated files
# Pattern should start with ':!' to exclude pattern
FILE_EXCLUDE_PATTERN=(
:!compiler/ann-api
:!onert-micro/externals
:!runtime/3rdparty
:!tests/nnapi
)

check_copyright() {
DIRECTORIES_NOT_TO_BE_TESTED=$1
CORRECT_COPYRIGHT="Copyright \(c\) [0-9\-]+ Samsung Electronics Co\., Ltd\. All Rights Reserved"

FILES_TO_CHECK=$(git ls-files -c --exclude-standard)
FILES_TO_CHECK_COPYRIGHTS=()
for f in ${FILES_TO_CHECK[@]}; do
# Manually ignore checking
if [[ ${f} == +(*/NeuralNetworks.h|*/NeuralNetworksExtensions.h) ]]; then
continue
fi

# File extension to check
if [[ ${f} == +(*.h|*.hpp|*.cpp|*.cc|*.c|*.cl) ]]; then
FILES_TO_CHECK_COPYRIGHTS+=("${f}")
fi
done

for s in ${DIRECTORIES_NOT_TO_BE_TESTED[@]}; do
FILES_TO_CHECK_COPYRIGHTS=(${FILES_TO_CHECK_COPYRIGHTS[*]/$s*/})
done
FILES_TO_CHECK_COPYRIGHTS=$(git ls-files -c --exclude-standard -- ${FILE_PATTERNS[@]} ${FILE_EXCLUDE_PATTERN[@]})

if [[ ${#FILES_TO_CHECK_COPYRIGHTS} -ne 0 ]]; then
for f in ${FILES_TO_CHECK_COPYRIGHTS[@]}; do
Expand All @@ -36,14 +31,7 @@ check_copyright() {
fi
}

DIRECTORIES_NOT_TO_BE_TESTED=()

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

check_copyright $DIRECTORIES_NOT_TO_BE_TESTED
check_copyright

if [[ $INVALID_EXIT -ne 0 ]]; then
echo "[FAILED] Invalid copyright check exit."
Expand Down
Empty file removed onert-micro/externals/.FORMATDENY
Empty file.
1 change: 1 addition & 0 deletions onert-micro/externals/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DisableFormat: true
Empty file removed runtime/3rdparty/.FORMATDENY
Empty file.
1 change: 1 addition & 0 deletions runtime/3rdparty/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DisableFormat: true
1 change: 1 addition & 0 deletions tests/nnapi/bridge/include/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DisableFormat: true
Empty file removed tests/nnapi/src/.FORMATDENY
Empty file.
1 change: 1 addition & 0 deletions tests/nnapi/src/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DisableFormat: true

0 comments on commit bd45a2f

Please sign in to comment.