ci(static-checks): improve checks for thirdparty headers
current include order check doesn't consider how third-party headers
should be included.
With - https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/19825
We are proposing a approach for TF-A to use this include order
for any third-party headers.
Order proposed is:
[..]
/* system header files */
#include <stddef.h>
/* Thirdparty headers - mbedtls header files */
#include <mbedtls/version.h>
/* project header files */
#include <drivers/auth/auth_mod.h>
#include <drivers/auth/tbbr_cot_common.h>
/* platform header files */
#include <platform_def.h>
[..]
Use this same order for CI static checks for include order tests.
Change-Id: I4637e1ed839dafbbfa8039972ccca79059ca8897
Signed-off-by: Govindraj Raja <govindraj.raja@arm.com>
diff --git a/script/static-checks/check-include-order.py b/script/static-checks/check-include-order.py
index 0953507..4961c05 100755
--- a/script/static-checks/check-include-order.py
+++ b/script/static-checks/check-include-order.py
@@ -26,8 +26,6 @@
IGNORED_FOLDERS = (
"include/lib/stdlib",
"include/lib/libc",
- "include/lib/libfdt",
- "lib/libfdt",
"lib/libc",
"lib/stdlib",
)
@@ -89,6 +87,13 @@
plat_incs.difference_update(plat_common_incs)
libc_incs = dir_include_paths("include/lib/libc")
proj_incs = dir_include_paths("include/")
+ third_party_incs = []
+ third_party_incs.append(dir_include_paths("mbedtls"))
+ third_party_incs.append(dir_include_paths("include/lib/libfdt"))
+ third_party_incs.append(dir_include_paths("lib/compiler-rt"))
+ third_party_incs.append(dir_include_paths("lib/libfdt"))
+ third_party_incs.append(dir_include_paths("lib/zlib"))
+
indices = []
for inc in inc_list:
@@ -96,10 +101,12 @@
inc_group_index = int(inc_path not in libc_incs)
if inc_group_index:
- if inc_path in proj_incs:
+ if inc_path in third_party_incs:
inc_group_index = 1
- elif inc_path in plat_incs:
+ elif inc_path in proj_incs:
inc_group_index = 2
+ elif inc_path in plat_incs:
+ inc_group_index = 3
incs[inc_group_index].append(inc_path)
indices.append((inc_group_index, inc))