From: Angelo Compagnucci <angelo.compagnucci@gmail.com>
To: buildroot@buildroot.org
Cc: "Joseph Kogut" <joseph.kogut@gmail.com>,
"Marcus Folkesson" <marcus.folkesson@gmail.com>,
"Leo Yu-Chi Liang" <ycliang@andestech.com>,
"Romain Naour" <romain.naour@gmail.com>,
"Antoine Tenart" <atenart@kernel.org>,
"José Luis Salvador Rufo" <salvador.joseluis@gmail.com>,
"Ricardo Martincoski" <ricardo.martincoski@datacom.com.br>,
"Fabrice Fontaine" <fontaine.fabrice@gmail.com>,
"Maxim Kochetkov" <fido_max@inbox.ru>,
"Francois Perrad" <francois.perrad.86@gmail.com>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
"James Knight" <james.d.knight@live.com>,
"Giulio Benetti" <giulio.benetti@benettiengineering.com>,
"Bernd Kuhls" <bernd@kuhls.net>,
"Ricardo Martincoski" <ricardo.martincoski@gmail.com>
Subject: [Buildroot] [PATCH v4 02/15] utils/check-package: support inline flags
Date: Sat, 7 Nov 2026 17:34:01 +0100 [thread overview]
Message-ID: <20261107163414.560896-3-angelo.compagnucci@gmail.com> (raw)
In-Reply-To: <20261107163414.560896-1-angelo.compagnucci@gmail.com>
From: Ricardo Martincoski <ricardo.martincoski@gmail.com>
Currently source files analysed by check-package can use a special
comment to hint the script to completely ignore a CheckFunction for the
next line of the source file:
# check-package Indent
Extend that functionality to also support flags that will trigger
special behaviour.
For instance, by adding the line to a Config.in file:
# check-package Indent_ignore-menu-indent-below
makes the CheckFunction named Indent to set a flag named
ignore-menu-indent-below and use it until the end of the source file
under test.
One example of use for this new special comment is Indent() from
lib_config.py, that currently keeps a list of 4 intree Config.in files
that have a special but legitimate indentation rule.
Instead of keeping the list inside the code, now a special comment can
be used in each of these 4 Config.in files.
A great side effect of this new type of special comment is that it can
also be used in source files from br2-external trees.
Concept reused from James Knight's work in [1] and [2].
[1] http://patchwork.ozlabs.org/project/buildroot/patch/SN4P221MB0682AE13FB1ACA5A755024F1A0689@SN4P221MB0682.NAMP221.PROD.OUTLOOK.COM/
[2] http://patchwork.ozlabs.org/project/buildroot/patch/SN4P221MB06823B0F7326D27ECD5E0FAEA0689@SN4P221MB0682.NAMP221.PROD.OUTLOOK.COM/
Cc: James Knight <james.d.knight@live.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
---
Changes v3 -> v4:
- none (rebased on current master).
utils/checkpackagelib/base.py | 20 ++++++--
utils/checkpackagelib/test_base.py | 82 ++++++++++++++++++++++++++++++
2 files changed, 99 insertions(+), 3 deletions(-)
diff --git a/utils/checkpackagelib/base.py b/utils/checkpackagelib/base.py
index 4636eca3a6..a3aff9e3d8 100644
--- a/utils/checkpackagelib/base.py
+++ b/utils/checkpackagelib/base.py
@@ -4,14 +4,28 @@ import os
class _CheckFunction(object):
+ flags = []
+
def __init__(self, filename, url_to_manual):
self.filename = filename
self.url_to_manual = url_to_manual
- self.disable = re.compile(r"^\s*# check-package .*\b{}\b".format(self.__class__.__name__))
+ if self.flags:
+ flags_pattern = '|_' + '|_'.join(self.flags)
+ else:
+ flags_pattern = ''
+ self.disable = re.compile(r"^\s*# check-package .*\b{}({})\b".format(self.__class__.__name__, flags_pattern))
+ self.enabled_flags = {f: False for f in self.flags}
def check_disabled(self, line_before):
- if self.disable.search(line_before):
- return True
+ found = self.disable.findall(line_before)
+ if found:
+ # catch flags to be used by CheckFunction for a source file, for all lines below
+ flags_found = [f[1:] for f in found if (f != '' and f[0] == '_')]
+ for f in flags_found:
+ self.enabled_flags[f] = True
+
+ ignore_this_line = '' in found
+ return ignore_this_line
return False
def before(self):
diff --git a/utils/checkpackagelib/test_base.py b/utils/checkpackagelib/test_base.py
index ef266d542c..bbe9285466 100644
--- a/utils/checkpackagelib/test_base.py
+++ b/utils/checkpackagelib/test_base.py
@@ -47,3 +47,85 @@ def test_IgnoreNextLine(testname, filename, string, expected):
warnings = util.check_file(CheckFunctionUnderTest, filename, string)
assert warnings == expected
+
+
+SpecialCheckForThisFile = [
+ ('without special comment',
+ 'any',
+ 'content to test\n'
+ '# commented content to test\n'
+ 'content to test\n'
+ 'content to test\n'
+ 'content to test\n',
+ [1, 2, 3, 4, 5]), # set of line numbers for all lines not ignored while testing
+ ('ignore next line (CheckFunction with flags)',
+ 'any',
+ 'content to test\n'
+ '# check-package CheckFunctionUnderTest\n'
+ 'content to ignore\n'
+ 'content to test\n'
+ 'content to test\n',
+ [1, 2, 4, 5]),
+ ('comment to ignore one CheckFunction does not affect another one (CheckFunction with flags)',
+ 'any',
+ 'content to test\n'
+ '# check-package AnotherCheckFunction\n'
+ 'content to test\n'
+ 'content to test\n'
+ 'content to test\n',
+ [1, 2, 3, 4, 5]),
+ ('ignore 2 CheckFunctions for next line (CheckFunction with flags)',
+ 'any',
+ '# check-package CheckFunctionUnderTest, AnotherCheckFunction\n'
+ 'content to ignore\n'
+ '# check-package AnotherCheckFunction, CheckFunctionUnderTest\n'
+ 'content to ignore\n'
+ 'content to test\n',
+ [1, 3, 5]),
+ ('one flag',
+ 'any',
+ 'content to test using default code\n'
+ '# check-package CheckFunctionUnderTest_flag-2\n'
+ 'content to test using flag-2\n'
+ 'content to test using flag-2\n',
+ [1, 2, [3, [-2]], [4, [-2]]]),
+ ('flag and ignore next line in the same file',
+ 'any',
+ 'content to test using default code\n'
+ '# check-package CheckFunctionUnderTest\n'
+ 'content to ignore\n'
+ '# check-package CheckFunctionUnderTest_flag-2\n'
+ 'content to test using flag-2\n'
+ '# check-package CheckFunctionUnderTest\n'
+ 'content to ignore\n'
+ 'content to test using flag-2\n',
+ [1, 2, 4, [5, [-2]], [6, [-2]], [8, [-2]]]),
+ ('2 flags',
+ 'any',
+ 'content to test using default code\n'
+ '# check-package CheckFunctionUnderTest_flag-2\n'
+ 'content to test using flag-2\n'
+ '# check-package CheckFunctionUnderTest_flag-1\n'
+ 'content to test using flag-1 and flag-2\n'
+ 'content to test using flag-1 and flag-2\n',
+ [1, 2, [3, [-2]], [4, [-2]], [5, [-1, -2]], [6, [-1, -2]]]),
+ ]
+
+
+@pytest.mark.parametrize('testname,filename,string,expected', SpecialCheckForThisFile)
+def test_SpecialCheckForThisFile(testname, filename, string, expected):
+ class CheckFunctionUnderTest(m._CheckFunction):
+ flags = ['flag-1', 'flag-2']
+
+ def check_line(self, lineno, text):
+ flags = []
+ if self.enabled_flags['flag-1']:
+ flags.append(-1)
+ if self.enabled_flags['flag-2']:
+ flags.append(-2)
+ if flags:
+ return [lineno, flags]
+ return lineno
+
+ warnings = util.check_file(CheckFunctionUnderTest, filename, string)
+ assert warnings == expected
--
2.53.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
next prev parent reply other threads:[~2026-11-07 16:34 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-03 16:35 [Buildroot] [next v3 0/3] check-package: support inline flags v3 Ricardo Martincoski
2023-09-03 16:35 ` [Buildroot] [next v3 1/3] utils/check-package: factor-out check_disabled() Ricardo Martincoski
2023-09-03 16:35 ` [Buildroot] [next v3 2/3] utils/check-package: support inline flags Ricardo Martincoski
2023-09-03 16:35 ` [Buildroot] [next v3 3/3] utils/check-package: remove hard-coded list from lib_config:Indent Ricardo Martincoski
2026-11-07 16:33 ` [Buildroot] [PATCH v4 00/15] check-package: warn about symbols not recognized by a package infra, support inline flags Angelo Compagnucci
2026-11-07 16:34 ` [Buildroot] [PATCH v4 01/15] utils/check-package: factor-out check_disabled() Angelo Compagnucci
2026-11-07 16:34 ` Angelo Compagnucci [this message]
2026-11-07 16:34 ` [Buildroot] [PATCH v4 03/15] utils/check-package: remove hard-coded list from lib_config:Indent Angelo Compagnucci
2026-11-07 16:34 ` [Buildroot] [PATCH v4 04/15] package/andes-spi-burn: fix the license files variable Angelo Compagnucci
2026-11-07 16:34 ` [Buildroot] [PATCH v4 05/15] package/fbv: drop the unused configure options Angelo Compagnucci
2026-11-07 16:34 ` [Buildroot] [PATCH v4 06/15] package/usbip: fix the configure options variable Angelo Compagnucci
2026-11-07 16:34 ` [Buildroot] [PATCH v4 07/15] package/postgresql: drop the unused install-world options Angelo Compagnucci
2026-11-09 7:13 ` Maxim Kochetkov via buildroot
2026-11-07 16:34 ` [Buildroot] [PATCH v4 08/15] package/libselinux: drop the unused make environment Angelo Compagnucci
2026-11-07 16:34 ` [Buildroot] [PATCH v4 09/15] package/zfs: drop the unused module subdirectories Angelo Compagnucci
2026-11-10 12:52 ` José Luis Salvador Rufo
2026-11-07 16:34 ` [Buildroot] [PATCH v4 10/15] package/mesa3d: drop the unused host Vulkan drivers Angelo Compagnucci
2026-11-07 16:34 ` [Buildroot] [PATCH v4 11/15] package/nxp-mwifiex: drop the unused make options Angelo Compagnucci
2026-11-07 16:34 ` [Buildroot] [PATCH v4 12/15] package/libglib2/libglib2-bootstrap: drop unused variables Angelo Compagnucci
2026-11-11 22:46 ` Fiona Klute via buildroot
2026-11-07 16:34 ` [Buildroot] [PATCH v4 13/15] package/linux-pam: fix linking with the NLS and atomic libraries Angelo Compagnucci
2026-11-07 16:34 ` [Buildroot] [PATCH v4 14/15] utils/check-package: warn about symbols not recognized by a package infra Angelo Compagnucci
2026-11-07 16:34 ` [Buildroot] [PATCH v4 15/15] utils/check-package: warn about disabled install Angelo Compagnucci
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261107163414.560896-3-angelo.compagnucci@gmail.com \
--to=angelo.compagnucci@gmail.com \
--cc=atenart@kernel.org \
--cc=bernd@kuhls.net \
--cc=buildroot@buildroot.org \
--cc=fido_max@inbox.ru \
--cc=fontaine.fabrice@gmail.com \
--cc=francois.perrad.86@gmail.com \
--cc=giulio.benetti@benettiengineering.com \
--cc=james.d.knight@live.com \
--cc=joseph.kogut@gmail.com \
--cc=marcus.folkesson@gmail.com \
--cc=ricardo.martincoski@datacom.com.br \
--cc=ricardo.martincoski@gmail.com \
--cc=romain.naour@gmail.com \
--cc=salvador.joseluis@gmail.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=ycliang@andestech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.