mirror of
https://github.com/Mbed-TLS/mbedtls-framework.git
synced 2026-09-12 21:29:55 +00:00
Pacify check_names.py
Signed-off-by: Gilles Peskine <[email protected]>
This commit is contained in:
@@ -10,6 +10,7 @@ See framework/docs/architecture/config-check-framework.md for information.
|
|||||||
import argparse
|
import argparse
|
||||||
import enum
|
import enum
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
import typing
|
import typing
|
||||||
@@ -74,8 +75,6 @@ class Checker:
|
|||||||
|
|
||||||
def user(self, _prefix: str) -> str:
|
def user(self, _prefix: str) -> str:
|
||||||
"""C code to inject immediately after including the user config."""
|
"""C code to inject immediately after including the user config."""
|
||||||
#pylint: disable=no-self-use
|
|
||||||
# Derived classes will add content where needed.
|
|
||||||
return f'''
|
return f'''
|
||||||
#if defined({self.name})
|
#if defined({self.name})
|
||||||
# error {self._quoted_message()}
|
# error {self._quoted_message()}
|
||||||
@@ -121,6 +120,13 @@ class Removed(Checker):
|
|||||||
"""
|
"""
|
||||||
return f'{self.name} was removed in {self.version}.'
|
return f'{self.name} was removed in {self.version}.'
|
||||||
|
|
||||||
|
def user(self, prefix: str) -> str:
|
||||||
|
"""C code to inject immediately after including the user config."""
|
||||||
|
code = super().user(prefix)
|
||||||
|
return re.sub(rf'^ *# *\w+.*\b{self.name}\b.*$',
|
||||||
|
lambda m: m.group(0) + ' //no-check-names',
|
||||||
|
code, flags=re.M)
|
||||||
|
|
||||||
|
|
||||||
class BranchData(typing.NamedTuple):
|
class BranchData(typing.NamedTuple):
|
||||||
"""The relevant aspects of the configuration on a branch."""
|
"""The relevant aspects of the configuration on a branch."""
|
||||||
@@ -172,7 +178,7 @@ class HeaderGenerator:
|
|||||||
/* {basename} (generated part of {self.branch_data.header_prefix}config.c). */
|
/* {basename} (generated part of {self.branch_data.header_prefix}config.c). */
|
||||||
/* Automatically generated by {os.path.basename(sys.argv[0])}. Do not edit! */
|
/* Automatically generated by {os.path.basename(sys.argv[0])}. Do not edit! */
|
||||||
|
|
||||||
#if !defined({self.bypass_checks})
|
#if !defined({self.bypass_checks}) //no-check-names
|
||||||
|
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
''')
|
''')
|
||||||
@@ -180,7 +186,7 @@ class HeaderGenerator:
|
|||||||
out.write(f'''
|
out.write(f'''
|
||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
#endif /* !defined({self.bypass_checks}) */
|
#endif /* !defined({self.bypass_checks}) */ //no-check-names
|
||||||
|
|
||||||
/* End of automatically generated {basename} */
|
/* End of automatically generated {basename} */
|
||||||
''')
|
''')
|
||||||
|
|||||||
Reference in New Issue
Block a user