aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJakub Sujak <jakub.sujak@arm.com>2023-08-23 14:42:26 +0100
committerGunes Bayir <gunes.bayir@arm.com>2023-09-28 16:24:00 +0000
commit6e56bf3b58719772111236d3b0030fbb5e8d2e16 (patch)
tree84fb0ef0c03f1bba83285f7cd184131b158df68d /scripts
parent2ad0a6be5b9d14fa30e92f548fa6a97fd9061aa1 (diff)
downloadComputeLibrary-6e56bf3b58719772111236d3b0030fbb5e8d2e16.tar.gz
Revise clang-format configuration
Clang-format options now match those in clang-format version 14. Remove Astyle checks as the same code style checks are provided by clang-format. Resolves: COMPMID-6576 Change-Id: Iefa9bb719826242a3276e9ca058d0c84624f7302 Signed-off-by: Felix Thomasmathibalan <felixjohnny.thomasmathibalan@arm.com> Signed-off-by: Jakub Sujak <jakub.sujak@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/10399 Benchmark: Arm Jenkins <bsgcomp@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Gunes Bayir <gunes.bayir@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/format_code.py45
-rw-r--r--scripts/include_functions_kernels.py6
2 files changed, 5 insertions, 46 deletions
diff --git a/scripts/format_code.py b/scripts/format_code.py
index 94c49fdb59..f1ee7a731c 100755
--- a/scripts/format_code.py
+++ b/scripts/format_code.py
@@ -36,23 +36,7 @@ from modules.Shell import Shell
logger = logging.getLogger("format_code")
-ASTYLE_PARAMETERS ="--style=ansi \
- --indent=spaces \
- --indent-switches \
- --indent-col1-comments \
- --min-conditional-indent=0 \
- --max-instatement-indent=120 \
- --pad-oper \
- --align-pointer=name \
- --align-reference=name \
- --break-closing-brackets \
- --keep-one-line-statements \
- --max-code-length=200 \
- --mode=c \
- --lineend=linux \
- --indent-preprocessor \
- "
-
+# List of directories to exclude
exceptions = [
"src/core/NEON/kernels/assembly/gemm",
"src/core/NEON/kernels/assembly/arm",
@@ -60,7 +44,6 @@ exceptions = [
"/convolution/",
"/arm_gemm/",
"/arm_conv/",
- "compute_kernel_writer/",
"SConscript",
"SConstruct"
]
@@ -241,7 +224,7 @@ class FormatCodeRun:
skip_copyright = True
grep_folder = "grep -e \"^\\(arm_compute\\|src\\|examples\\|tests\\|utils\\|support\\)/\""
- grep_extension = "grep -e \"\\.\\(cpp\\|h\\|inl\\|cl\\|cs\\|hpp\\)$\""
+ grep_extension = "grep -e \"\\.\\(cpp\\|h\\|hh\\|inl\\|cl\\|cs\\|hpp\\)$\""
list_files = shell.run_single_to_str(cmd+" | { "+ grep_folder+" | "+grep_extension + " || true; }")
to_check = [ f for f in list_files.split("\n") if len(f) > 0]
@@ -277,16 +260,7 @@ class FormatCodeRun:
try:
self.shell.cd(self.folder)
self.shell.prepend_env("PATH","%s/../bin" % this_dir)
- clang_format = "clang-format -i -style=file "
- astyle = "astyle -n -q %s " % (ASTYLE_PARAMETERS)
-
- if sys.platform == 'darwin':
- # this platform explicitly needs an extension for the temporary file
- sed = "sed -i '.log' 's/\\t/ /g' "
- else:
- sed = "sed -i 's/\\t/ /g' "
- single_eol = "%s/ensure_single_eol.py " % this_dir
for f in self.files:
skip_this_file = False
for e in exceptions:
@@ -300,21 +274,6 @@ class FormatCodeRun:
logger.info("Formatting %s" % f)
if not self.skip_copyright:
check_copyright(f)
- cmds = [
- sed + f,
- clang_format + f,
- astyle + f,
- single_eol + f
- ]
-
- if sys.platform == 'darwin':
- # the temporary file creted by 'sed' will be removed here
- cmds.append(f"rm {f}.log")
-
- for cmd in cmds:
- output = self.shell.run_single_to_str(cmd)
- if len(output) > 0:
- logger.info(output)
check_license("LICENSE")
diff --git a/scripts/include_functions_kernels.py b/scripts/include_functions_kernels.py
index 82b40f0e36..49c12867e6 100644
--- a/scripts/include_functions_kernels.py
+++ b/scripts/include_functions_kernels.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (c) 2017-2018, 2020-2021 Arm Limited.
+# Copyright (c) 2017-2018, 2020-2021, 2023 Arm Limited.
#
# SPDX-License-Identifier: MIT
#
@@ -74,7 +74,7 @@ def create_include_list(folder):
files_path = folder + "/*.h"
files = glob.glob(files_path)
updated_files = [include_str + folder + "/" + x.rsplit('/',1)[1] + "\"\n" for x in files]
- updated_files.sort()
+ updated_files.sort(key=lambda x: x.lower())
return updated_files
@@ -86,7 +86,7 @@ def include_components(target, path, header_prefix, folder, subfolders=None):
include_list = create_include_list(target_path + folder)
for s in subfolders or []:
include_list += create_include_list( target_path + folder + "/" + s)
- include_list.sort()
+ include_list.sort(key=lambda x: x.lower())
lines = read_file(components_file)
lines, first_pos = remove_existing_includes(lines)
lines = add_updated_includes(lines, first_pos, include_list)