Skip to content

Commit

Permalink
scripts: ci: check_compliance: Update to detect concatenation
Browse files Browse the repository at this point in the history
Check was complaining when Kconfig flag was build using concatenation
via a macro (it was covering explicit token pasting ##). Added
negative lookbehind for CAT( which should cover exisiting concatenation
macros (UTIL_CAT, CONCAT, CAT).

Signed-off-by: Krzysztof Chruściński <[email protected]>
  • Loading branch information
nordic-krch committed Jan 4, 2024
1 parent 1bd736b commit 33cffd8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scripts/ci/check_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,12 @@ def check_no_undef_outside_kconfig(self, kconf):
# so we extract the references from each line ourselves instead.
#
# The regex uses word boundaries (\b) to isolate the reference, and
# negative lookahead to automatically whitelist the following:
# negative lookahead and lookbehind to automatically whitelist the following:
#
# - ##, for token pasting (CONFIG_FOO_##X)
#
# - prefixed with CAT( for token pasting (CAT(CONFIG_FOO_,X) or CONCAT(CONFIG_FOO, X))
#
# - $, e.g. for CMake variable expansion (CONFIG_FOO_${VAR})
#
# - @, e.g. for CMakes's configure_file() (CONFIG_FOO_@VAR@)
Expand All @@ -564,7 +566,7 @@ def check_no_undef_outside_kconfig(self, kconf):
undef_to_locs = collections.defaultdict(list)

# Warning: Needs to work with both --perl-regexp and the 're' module
regex = r"\bCONFIG_[A-Z0-9_]+\b(?!\s*##|[$@{*])"
regex = r"(?<!CAT\()\bCONFIG_[A-Z0-9_]+\b(?!\s*##|[$@{*])"

# Skip doc/releases, which often references removed symbols
grep_stdout = git("grep", "--line-number", "-I", "--null",
Expand Down

0 comments on commit 33cffd8

Please sign in to comment.