Skip to content
This repository was archived by the owner on Apr 6, 2022. It is now read-only.

Commit 32a3e07

Browse files
ulfalizergalak
authored andcommitted
check_compliance.py: Clean up get_defined_syms() a bit
Can do a single regex scan on the 'git grep' output and use --perl-regexp instead of --extended-regexp to get non-capturing groups. Also shortens things a bit. Signed-off-by: Ulf Magnusson <[email protected]>
1 parent 76356d4 commit 32a3e07

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

scripts/check_compliance.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -462,19 +462,18 @@ def get_defined_syms(kconf):
462462
# definitions. Doing it "properly" with Kconfiglib is still useful for the
463463
# main tree, because some symbols are defined using preprocessor macros.
464464

465-
# Warning: Needs to work with both --extended-regexp and the 're' module
466-
regex = r"^\s*(menu)?config\s*([A-Z0-9_]+)\s*(#|$)"
465+
# Warning: Needs to work with both --perl-regexp and the 're' module.
466+
# (?:...) is a non-capturing group.
467+
regex = r"^\s*(?:menu)?config\s*([A-Z0-9_]+)\s*(?:#|$)"
467468

468469
# Grep samples/ and tests/ for symbol definitions
469-
grep_stdout = git("grep", "-I", "-h", "--extended-regexp", regex, "--",
470+
grep_stdout = git("grep", "-I", "-h", "--perl-regexp", regex, "--",
470471
":samples", ":tests", cwd=ZEPHYR_BASE)
471472

472-
# Start with the symbols from the main Kconfig tree in 'res'
473-
res = set(sym.name for sym in kconf.unique_defined_syms)
474-
# Add the grepped definitions from samples and tests
475-
for def_line in grep_stdout.splitlines():
476-
res.add(re.match(regex, def_line).group(2))
477-
return res
473+
# Symbols from the main Kconfig tree + grepped definitions from samples and
474+
# tests
475+
return set([sym.name for sym in kconf.unique_defined_syms]
476+
+ re.findall(regex, grep_stdout, re.MULTILINE))
478477

479478

480479
# Many of these are symbols used as examples. Note that the list is sorted

0 commit comments

Comments
 (0)