Work with PSA constants: Python port of 03091d1114
Signed-off-by: Yuto Takano <yuto.takano@arm.com>
This commit is contained in:
parent
ed91cf003a
commit
bb7dca495f
1 changed files with 7 additions and 7 deletions
|
@ -31,7 +31,7 @@ import subprocess
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
# Naming patterns to check against
|
# Naming patterns to check against
|
||||||
MACRO_PATTERN = r"^MBEDTLS_[0-9A-Z_]*[0-9A-Z]$"
|
MACRO_PATTERN = r"^(MBEDTLS|PSA)_[0-9A-Z_]*[0-9A-Z]$"
|
||||||
IDENTIFIER_PATTERN = r"^(mbedtls|psa)_[0-9a-z_]*[0-9a-z]$"
|
IDENTIFIER_PATTERN = r"^(mbedtls|psa)_[0-9a-z_]*[0-9a-z]$"
|
||||||
|
|
||||||
class Match(object):
|
class Match(object):
|
||||||
|
@ -159,20 +159,19 @@ class NameCheck(object):
|
||||||
|
|
||||||
return macros
|
return macros
|
||||||
|
|
||||||
def parse_MBED_names(self, header_files, library_files):
|
def parse_MBED_names(self, files):
|
||||||
"""
|
"""
|
||||||
Parse all words in the file that begin with MBED. Includes macros.
|
Parse all words in the file that begin with MBED. Includes macros.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
header_files: A list of filepaths to look through.
|
files: A list of filepaths to look through.
|
||||||
library_files: A list of filepaths to look through.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
A list of Match objects for words beginning with MBED.
|
A list of Match objects for words beginning with MBED.
|
||||||
"""
|
"""
|
||||||
MBED_names = []
|
MBED_names = []
|
||||||
|
|
||||||
for filename in header_files + library_files:
|
for filename in files:
|
||||||
with open(filename, "r") as fp:
|
with open(filename, "r") as fp:
|
||||||
for line in fp:
|
for line in fp:
|
||||||
for name in re.finditer(r"\bMBED.+?_[A-Z0-9_]*", line):
|
for name in re.finditer(r"\bMBED.+?_[A-Z0-9_]*", line):
|
||||||
|
@ -380,11 +379,12 @@ class NameCheck(object):
|
||||||
p_headers = self.get_files(os.path.join("include", "psa"))
|
p_headers = self.get_files(os.path.join("include", "psa"))
|
||||||
libraries = self.get_files("library")
|
libraries = self.get_files("library")
|
||||||
|
|
||||||
all_macros = self.parse_macros(m_headers + ["configs/config-default.h"])
|
all_macros = self.parse_macros(
|
||||||
|
m_headers + p_headers)
|
||||||
enum_consts = self.parse_enum_consts(m_headers)
|
enum_consts = self.parse_enum_consts(m_headers)
|
||||||
identifiers = self.parse_identifiers(m_headers + p_headers)
|
identifiers = self.parse_identifiers(m_headers + p_headers)
|
||||||
symbols = self.parse_symbols()
|
symbols = self.parse_symbols()
|
||||||
mbed_names = self.parse_MBED_names(m_headers, libraries)
|
mbed_names = self.parse_MBED_names(m_headers + p_headers + libraries)
|
||||||
|
|
||||||
# Remove identifier macros like mbedtls_printf or mbedtls_calloc
|
# Remove identifier macros like mbedtls_printf or mbedtls_calloc
|
||||||
macros = list(set(all_macros) - set(identifiers))
|
macros = list(set(all_macros) - set(identifiers))
|
||||||
|
|
Loading…
Reference in a new issue