Skip to content

Commit 0cfa866

Browse files
L-KAYAHarshal5
authored andcommitted
ci(check): update check_soc_struct_headers script
1 parent 5863b66 commit 0cfa866

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

.gitlab/ci/pre_check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ check_chip_support_components:
7272
expire_in: 1 week
7373
script:
7474
- python tools/ci/check_soc_headers_leak.py
75-
- find ${IDF_PATH}/components/soc/**/include/soc/ -name "*_struct.h" -print0 | xargs -0 -n1 ./tools/ci/check_soc_struct_headers.py
75+
- find ${IDF_PATH}/components/soc/**/include/soc/ ${IDF_PATH}/components/soc/**/register/soc/ -name "*_struct.h" -print0 | xargs -0 -n1 ./tools/ci/check_soc_struct_headers.py
7676
- tools/ci/check_esp_memory_utils_headers.sh
7777

7878
check_esp_err_to_name:

tools/ci/check_soc_struct_headers.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#!/usr/bin/env python
2-
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
2+
# SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
# SPDX-License-Identifier: Apache-2.0
4-
54
# A check script that just works at the time of writing...
65
#
76
# also builds a structure tree for further reference
87
#
9-
# Input file format must be similiar to those headers generated by regtool, or this script makes no sense at all
8+
# Input file format must be similar to those headers generated by regtool, or this script makes no sense at all
109
#
1110
# Known limitation:
1211
# 1. won't accept /* ... */ /* ... */': badly behavior with multiline comment
@@ -21,18 +20,18 @@
2120
# 5. typedef volatile struct xxx{}: xxx must exists
2221
#
2322
# Otherwise won't fail but warning
24-
2523
import os
2624
import re
2725
import sys
2826
from typing import Any
27+
from typing import Optional
2928

3029

3130
class MemberField:
3231
member_type = ''
3332
bitfield = None
3433

35-
def __init__(self, m_type: str, m_bits: int=None) -> None:
34+
def __init__(self, m_type: str, m_bits: Optional[int]=None) -> None:
3635
self.member_type = m_type
3736
self.bitfield = m_bits
3837

@@ -74,7 +73,7 @@ class SoCStructureHeaderChecker:
7473
# named typedef, or named struct/union. referd but will not delete
7574
__temp_ref_types = dict() # type: dict
7675

77-
def __expand_type(self, member_type: str, bitfield: int=None) -> Any:
76+
def __expand_type(self, member_type: str, bitfield: Optional[int]=None) -> Any:
7877
if member_type == 'uint32_t':
7978
return MemberField(member_type, bitfield)
8079
if bitfield is not None:
@@ -121,15 +120,15 @@ def __getline(self, incomment:bool=False) -> Any:
121120
# skip empty line
122121
return self.__getline()
123122
if rawline.count(';') > 1:
124-
print('\033[0;34mINFO\033[0m: line: {}: possibily multiple expression within same line'.format(self.__linecount))
123+
print('\033[0;34mINFO\033[0m: line: {}: possibly multiple expression within same line'.format(self.__linecount))
125124
print(rawline)
126125
return rawline
127126

128127
def __process_structure(self, name: str, is_typedef: bool, is_volatile: bool) -> Any:
129128
ret_val = 0
130129
# first check for anonymous register structs
131130
if is_typedef and is_volatile and name is None:
132-
print('\033[0;31mERROR\033[0m: line {}: annoymous struct'.format(self.__linecount))
131+
print('\033[0;31mERROR\033[0m: line {}: anonymous struct'.format(self.__linecount))
133132
ret_val = -1
134133
node_tree = dict()
135134
bitcount = 0
@@ -252,7 +251,7 @@ def __process_union(self, name: str, is_typedef: bool, is_volatile: bool) -> Any
252251
ret_val = 0
253252
# first check for anonymous register structs
254253
if is_typedef and is_volatile and name is None:
255-
print('\033[0;31mERROR\033[0m: line {}: annoymous union'.format(self.__linecount))
254+
print('\033[0;31mERROR\033[0m: line {}: anonymous union'.format(self.__linecount))
256255
ret_val = -1
257256
node_tree = dict() # type: Any
258257
has_struct_count = 0
@@ -334,7 +333,7 @@ def __process_union(self, name: str, is_typedef: bool, is_volatile: bool) -> Any
334333
node_tree[match_obj.groups()[1]] = member_node
335334
else:
336335
if '*' not in match_obj.groups()[0]:
337-
print('\033[0;31mERROR\033[0m: line {}: unknown type {}'.format(self.__linecount, match_obj.groups()[0]))
336+
print('\033[0;31mWARN\033[0m: line {}: unknown type {}'.format(self.__linecount, match_obj.groups()[0]))
338337
else:
339338
print('\033[0;33mWARN\033[0m: line {}: pointer type {}'.format(self.__linecount, match_obj.groups()[0]))
340339
continue

0 commit comments

Comments
 (0)