summaryrefslogtreecommitdiff
path: root/lib/python/qmk/c_parse.py
diff options
context:
space:
mode:
authorErovia <Erovia@users.noreply.github.com>2022-03-27 21:28:36 +0100
committerGitHub <noreply@github.com>2022-03-27 21:28:36 +0100
commit8c0198334c5a76b93530d6edd9b11ea99ea40018 (patch)
treef6c1f8a7be6dc5fbf1973f4d869b8b7d50a8d432 /lib/python/qmk/c_parse.py
parent5fae1ec9c3aa105848da8fa7aa249918917b9fd6 (diff)
CLI: Lint non-data driven macros in info.json (#16739)
* CLI: Lint non-data driven macros in info.json Macros in info.json should either have the "matrix" key with the matrix data or should should be also present in <keyboard>.h * Add verification of matrix data * Use generic '<keyboard>.h' in output * Add keyboard name to output * Make C layout macro finding more robust The old code missed C macros if they had whitespace between '#' and 'define' or had whitespace before '#'.
Diffstat (limited to 'lib/python/qmk/c_parse.py')
-rw-r--r--lib/python/qmk/c_parse.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/python/qmk/c_parse.py b/lib/python/qmk/c_parse.py
index e7d44a514f..72be690019 100644
--- a/lib/python/qmk/c_parse.py
+++ b/lib/python/qmk/c_parse.py
@@ -10,6 +10,7 @@ from qmk.comment_remover import comment_remover
10default_key_entry = {'x': -1, 'y': 0, 'w': 1} 10default_key_entry = {'x': -1, 'y': 0, 'w': 1}
11single_comment_regex = re.compile(r'\s+/[/*].*$') 11single_comment_regex = re.compile(r'\s+/[/*].*$')
12multi_comment_regex = re.compile(r'/\*(.|\n)*?\*/', re.MULTILINE) 12multi_comment_regex = re.compile(r'/\*(.|\n)*?\*/', re.MULTILINE)
13layout_macro_define_regex = re.compile(r'^#\s*define')
13 14
14 15
15def strip_line_comment(string): 16def strip_line_comment(string):
@@ -51,7 +52,7 @@ def find_layouts(file):
51 file_contents = file_contents.replace('\\\n', '') 52 file_contents = file_contents.replace('\\\n', '')
52 53
53 for line in file_contents.split('\n'): 54 for line in file_contents.split('\n'):
54 if line.startswith('#define') and '(' in line and 'LAYOUT' in line: 55 if layout_macro_define_regex.match(line.lstrip()) and '(' in line and 'LAYOUT' in line:
55 # We've found a LAYOUT macro 56 # We've found a LAYOUT macro
56 macro_name, layout, matrix = _parse_layout_macro(line.strip()) 57 macro_name, layout, matrix = _parse_layout_macro(line.strip())
57 58