[Buildroot] [PATCH 5/5] check-package: detect the use of ${} in .mk files
Ricardo Martincoski
ricardo.martincoski at gmail.com
Sun Jul 8 05:17:01 UTC 2018
And warn to use $() instead.
For examples see [1] and [2].
In the regexp, search for ${VARIABLE} but:
- ignore comments;
- ignore variables to be expanded by the shell "$${}";
- do not use \w as it would give false warnings for this sed contruct
in mesa3d-headers.mk: 's:@includedir@:${prefix}/include:'.
[1] http://lists.busybox.net/pipermail/buildroot/2018-July/225211.html
[2] https://github.com/buildroot/buildroot/commit/36305380db1312442623128689fe5067d9058381
Signed-off-by: Ricardo Martincoski <ricardo.martincoski at gmail.com>
Cc: Arnout Vandecappelle <arnout at mind.be>
Cc: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
---
With only this patch applied:
https://gitlab.com/RicardoMartincoski/buildroot/-/jobs/80161018
---
utils/checkpackagelib/lib_mk.py | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/utils/checkpackagelib/lib_mk.py b/utils/checkpackagelib/lib_mk.py
index 86e9aa2d97..423e592de1 100644
--- a/utils/checkpackagelib/lib_mk.py
+++ b/utils/checkpackagelib/lib_mk.py
@@ -251,3 +251,13 @@ class UselessFlag(_CheckFunction):
"({}#_infrastructure_for_autotools_based_packages)"
.format(self.filename, lineno, self.url_to_manual),
text]
+
+
+class VariableWithBraces(_CheckFunction):
+ VARIABLE_WITH_BRACES = re.compile(r"^[^#].*[^$]\${[A-Z0-9_]+}")
+
+ def check_line(self, lineno, text):
+ if self.VARIABLE_WITH_BRACES.match(text.rstrip()):
+ return ["{}:{}: use $() to delimit variables, not ${{}}"
+ .format(self.filename, lineno),
+ text]
--
2.17.1
More information about the buildroot
mailing list