From: Ricardo Martincoski Date: Sun, 27 Jan 2019 18:59:42 +0000 (-0200) Subject: utils/check-package: handle ifdef/ifndef in .mk files X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fe7a5d7120a50866315c6b02ce07ad10d32dcc8c;p=buildroot.git utils/check-package: handle ifdef/ifndef in .mk files Currently check-package only knows about ifeq/ifneq. Add code to handle ifdef/ifndef as well. Signed-off-by: Ricardo Martincoski Reviewed-by: Arnout Vandecappelle (Essensium/Mind) Signed-off-by: Peter Korsgaard --- diff --git a/utils/checkpackagelib/lib_mk.py b/utils/checkpackagelib/lib_mk.py index 4387cf7167..51c6577d2c 100644 --- a/utils/checkpackagelib/lib_mk.py +++ b/utils/checkpackagelib/lib_mk.py @@ -12,10 +12,14 @@ from checkpackagelib.lib import EmptyLastLine # noqa: F401 from checkpackagelib.lib import NewlineAtEof # noqa: F401 from checkpackagelib.lib import TrailingSpace # noqa: F401 +# used in more than one check +start_conditional = ["ifdef", "ifeq", "ifndef", "ifneq"] +end_conditional = ["endif"] + class Indent(_CheckFunction): COMMENT = re.compile("^\s*#") - CONDITIONAL = re.compile("^\s*(ifeq|ifneq|endif)\s") + CONDITIONAL = re.compile("^\s*({})\s".format("|".join(start_conditional + end_conditional))) ENDS_WITH_BACKSLASH = re.compile(r"^[^#].*\\$") END_DEFINE = re.compile("^\s*endef\s") MAKEFILE_TARGET = re.compile("^[^# \t]+:\s") @@ -222,8 +226,8 @@ class UselessFlag(_CheckFunction): "_INSTALL_REDISTRIBUTE\s*=\s*YES", "_INSTALL_STAGING\s*=\s*NO", "_INSTALL_TARGET\s*=\s*YES"]))) - END_CONDITIONAL = re.compile("^\s*(endif)") - START_CONDITIONAL = re.compile("^\s*(ifeq|ifneq)") + END_CONDITIONAL = re.compile("^\s*({})".format("|".join(end_conditional))) + START_CONDITIONAL = re.compile("^\s*({})".format("|".join(start_conditional))) def before(self): self.conditional = 0