forked from espressif/esp-idf
ci(check): update check_soc_struct_headers script
This commit is contained in:
@ -72,7 +72,7 @@ check_chip_support_components:
|
|||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
script:
|
script:
|
||||||
- python tools/ci/check_soc_headers_leak.py
|
- python tools/ci/check_soc_headers_leak.py
|
||||||
- find ${IDF_PATH}/components/soc/**/include/soc/ -name "*_struct.h" -print0 | xargs -0 -n1 ./tools/ci/check_soc_struct_headers.py
|
- 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
|
||||||
- tools/ci/check_esp_memory_utils_headers.sh
|
- tools/ci/check_esp_memory_utils_headers.sh
|
||||||
|
|
||||||
check_esp_err_to_name:
|
check_esp_err_to_name:
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
# SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
# A check script that just works at the time of writing...
|
# A check script that just works at the time of writing...
|
||||||
#
|
#
|
||||||
# also builds a structure tree for further reference
|
# also builds a structure tree for further reference
|
||||||
#
|
#
|
||||||
# Input file format must be similiar to those headers generated by regtool, or this script makes no sense at all
|
# Input file format must be similar to those headers generated by regtool, or this script makes no sense at all
|
||||||
#
|
#
|
||||||
# Known limitation:
|
# Known limitation:
|
||||||
# 1. won't accept /* ... */ /* ... */': badly behavior with multiline comment
|
# 1. won't accept /* ... */ /* ... */': badly behavior with multiline comment
|
||||||
@ -21,18 +20,18 @@
|
|||||||
# 5. typedef volatile struct xxx{}: xxx must exists
|
# 5. typedef volatile struct xxx{}: xxx must exists
|
||||||
#
|
#
|
||||||
# Otherwise won't fail but warning
|
# Otherwise won't fail but warning
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
class MemberField:
|
class MemberField:
|
||||||
member_type = ''
|
member_type = ''
|
||||||
bitfield = None
|
bitfield = None
|
||||||
|
|
||||||
def __init__(self, m_type: str, m_bits: int=None) -> None:
|
def __init__(self, m_type: str, m_bits: Optional[int]=None) -> None:
|
||||||
self.member_type = m_type
|
self.member_type = m_type
|
||||||
self.bitfield = m_bits
|
self.bitfield = m_bits
|
||||||
|
|
||||||
@ -74,7 +73,7 @@ class SoCStructureHeaderChecker:
|
|||||||
# named typedef, or named struct/union. referd but will not delete
|
# named typedef, or named struct/union. referd but will not delete
|
||||||
__temp_ref_types = dict() # type: dict
|
__temp_ref_types = dict() # type: dict
|
||||||
|
|
||||||
def __expand_type(self, member_type: str, bitfield: int=None) -> Any:
|
def __expand_type(self, member_type: str, bitfield: Optional[int]=None) -> Any:
|
||||||
if member_type == 'uint32_t':
|
if member_type == 'uint32_t':
|
||||||
return MemberField(member_type, bitfield)
|
return MemberField(member_type, bitfield)
|
||||||
if bitfield is not None:
|
if bitfield is not None:
|
||||||
@ -121,7 +120,7 @@ class SoCStructureHeaderChecker:
|
|||||||
# skip empty line
|
# skip empty line
|
||||||
return self.__getline()
|
return self.__getline()
|
||||||
if rawline.count(';') > 1:
|
if rawline.count(';') > 1:
|
||||||
print('\033[0;34mINFO\033[0m: line: {}: possibily multiple expression within same line'.format(self.__linecount))
|
print('\033[0;34mINFO\033[0m: line: {}: possibly multiple expression within same line'.format(self.__linecount))
|
||||||
print(rawline)
|
print(rawline)
|
||||||
return rawline
|
return rawline
|
||||||
|
|
||||||
@ -129,7 +128,7 @@ class SoCStructureHeaderChecker:
|
|||||||
ret_val = 0
|
ret_val = 0
|
||||||
# first check for anonymous register structs
|
# first check for anonymous register structs
|
||||||
if is_typedef and is_volatile and name is None:
|
if is_typedef and is_volatile and name is None:
|
||||||
print('\033[0;31mERROR\033[0m: line {}: annoymous struct'.format(self.__linecount))
|
print('\033[0;31mERROR\033[0m: line {}: anonymous struct'.format(self.__linecount))
|
||||||
ret_val = -1
|
ret_val = -1
|
||||||
node_tree = dict()
|
node_tree = dict()
|
||||||
bitcount = 0
|
bitcount = 0
|
||||||
@ -252,7 +251,7 @@ class SoCStructureHeaderChecker:
|
|||||||
ret_val = 0
|
ret_val = 0
|
||||||
# first check for anonymous register structs
|
# first check for anonymous register structs
|
||||||
if is_typedef and is_volatile and name is None:
|
if is_typedef and is_volatile and name is None:
|
||||||
print('\033[0;31mERROR\033[0m: line {}: annoymous union'.format(self.__linecount))
|
print('\033[0;31mERROR\033[0m: line {}: anonymous union'.format(self.__linecount))
|
||||||
ret_val = -1
|
ret_val = -1
|
||||||
node_tree = dict() # type: Any
|
node_tree = dict() # type: Any
|
||||||
has_struct_count = 0
|
has_struct_count = 0
|
||||||
@ -334,7 +333,7 @@ class SoCStructureHeaderChecker:
|
|||||||
node_tree[match_obj.groups()[1]] = member_node
|
node_tree[match_obj.groups()[1]] = member_node
|
||||||
else:
|
else:
|
||||||
if '*' not in match_obj.groups()[0]:
|
if '*' not in match_obj.groups()[0]:
|
||||||
print('\033[0;31mERROR\033[0m: line {}: unknown type {}'.format(self.__linecount, match_obj.groups()[0]))
|
print('\033[0;31mWARN\033[0m: line {}: unknown type {}'.format(self.__linecount, match_obj.groups()[0]))
|
||||||
else:
|
else:
|
||||||
print('\033[0;33mWARN\033[0m: line {}: pointer type {}'.format(self.__linecount, match_obj.groups()[0]))
|
print('\033[0;33mWARN\033[0m: line {}: pointer type {}'.format(self.__linecount, match_obj.groups()[0]))
|
||||||
continue
|
continue
|
||||||
|
Reference in New Issue
Block a user