Static Checks: Update Include Order Check Rules
The including statement group order in TF-M:
Public Headers
Private Headers
<> indicates public headers.
"" indicates private headers.
Logs of include order check are printed to console.
Change-Id: I265e58fe8f09bff9cbc54dd26341939db16693c1
Signed-off-by: Xinyu Zhang <xinyu.zhang@arm.com>
diff --git a/script/static-checks/check-include-order.py b/script/static-checks/check-include-order.py
index 7c32d65..e6dbec1 100755
--- a/script/static-checks/check-include-order.py
+++ b/script/static-checks/check-include-order.py
@@ -71,25 +71,16 @@
libc_incs = []
# First, check if all includes are in the appropriate group.
- inc_group = "System"
+ inc_group = "Public"
incs = collections.defaultdict(list)
error_msgs = []
for inc in inc_list:
- if inc[1:-1] in libc_incs:
- if inc_group != "System":
- error_msgs.append(inc[1:-1] + " should be in system group, at the top")
- elif (
- "plat/" in inc
- or "platform" in inc
- or (inc.startswith('"') and "plat" in path)
- ):
- inc_group = "Platform"
- elif inc_group in ("Project", "System"):
- inc_group = "Project"
- else:
+ if inc.startswith('"'):
+ inc_group = "Private"
+ elif inc_group == "Private":
error_msgs.append(
- inc[1:-1] + " should be in project group, after system group"
+ inc[1:-1] + " should be in public group, before private group"
)
incs[inc_group].append(inc[1:-1])
diff --git a/script/static-checks/static-checks-include-order.sh b/script/static-checks/static-checks-include-order.sh
index 0f2b46c..67089b5 100755
--- a/script/static-checks/static-checks-include-order.sh
+++ b/script/static-checks/static-checks-include-order.sh
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Copyright (c) 2019, Arm Limited. All rights reserved.
+# Copyright (c) 2019-2021, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -14,12 +14,12 @@
TEST_CASE="Order of includes on the last patch(es)"
"$CI_ROOT/script/static-checks/check-include-order.py" --tree "$1" \
--patch --from-ref origin/master \
- &> "$LOG_FILE"
+ | tee "$LOG_FILE"
else
echo "# Check order of includes of the entire source tree"
TEST_CASE="Order of includes of the entire source tree"
"$CI_ROOT/script/static-checks/check-include-order.py" --tree "$1" \
- &> "$LOG_FILE"
+ | tee "$LOG_FILE"
fi
EXIT_VALUE=$?