utils/checkpackagelib/lib_mk.py: handle 'else' and 'elif' statements
authorThomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Wed, 9 Dec 2020 15:32:18 +0000 (16:32 +0100)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Sat, 2 Jan 2021 12:54:59 +0000 (13:54 +0100)
commita1bb132a81889b057134669d8b7135168b2f8024
treeda969d6470fee2bd36f4486518fefad5a7aedd40
parent239f440a173feab7d046dfbb61a90b8626db00af
utils/checkpackagelib/lib_mk.py: handle 'else' and 'elif' statements

An 'else' or 'elif' clause inside a make conditional should not be indented
in the same way as the if/endif clause. check-package did not recognize the
else statement and expected an indentation.

For example:

ifdef FOOBAR
interesting
else
more interesting
endif

would, according to check-package, need to become:

ifdef FOOBAR
interesting
else
more interesting
endif

Treat 'else' and 'elif' the same as if-like keywords in the Indent test, but
take into account that 'else' is also valid shell, so we need to correctly
handle line continuation to prevent complaining about the 'else' in:

ifdef FOOBAR
if true; \
    ... \
else \
    ... \
fi
endif

We don't add the 'else' and 'elif' statements to start_conditional, because
it would cause incorrect nesting counting in class OverriddenVariable.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
utils/checkpackagelib/lib_mk.py