From patchwork Wed Dec 9 15:32:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas De Schampheleire X-Patchwork-Id: 1413488 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=iCb3r2ic; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Crgz54yQCz9sR4 for ; Thu, 10 Dec 2020 02:32:33 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 483BC86D3C; Wed, 9 Dec 2020 15:32:31 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dQ+PBz1b4pKM; Wed, 9 Dec 2020 15:32:29 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id D041686A83; Wed, 9 Dec 2020 15:32:29 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 3CA481BF3C6 for ; Wed, 9 Dec 2020 15:32:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 390C2875FB for ; Wed, 9 Dec 2020 15:32:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XiAj9-6OETGw for ; Wed, 9 Dec 2020 15:32:27 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 4EB7D875F6 for ; Wed, 9 Dec 2020 15:32:27 +0000 (UTC) Received: by mail-ed1-f48.google.com with SMTP id h16so2001797edt.7 for ; Wed, 09 Dec 2020 07:32:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nJEWfvcy98qGHz390fztT3IFp9kN6+xqq+ZJWynVfQo=; b=iCb3r2icj8aNfNNbVFVjiq8U1dEkW4Sjz1Pbzjy9yUHeyW+JbNk8Tb418whZyrTh0V u1YKyewpT/45CoJbt6br8rRUvxEnLsWCTam2+snTLqOV3/l3nZmgp0Jp0l20OjQ89VxZ nqdazAqSdlfONmZ72YHqjDUz3FhUDl5EeK9avBuCvKt7cVqVUFwp5I1rMytm8x/aPkz9 P5bquG660Ujp+dcWlVLiVhOd8jWQjWBrOS6/u/olKQBHLqT8aXRMyg+oDY5K4tb2aPQl ZLUtCTf076EyZt9AjhVVCh6TNQzjxgLIktA6RoqgybMoDcsXBhnTMo+5kOiLkM/74sly FLKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nJEWfvcy98qGHz390fztT3IFp9kN6+xqq+ZJWynVfQo=; b=p7ar6L2LX8Rf3LwLbYflG8T9Wq4otolw3tPOKgtJOG8QwFkPgDFPCMlNfwB+8xbnx7 S8RPMRBbFT8soTZDXqj6Vph4zfEWRP7DS90WdKdDRKpkDZnNDGt4+J6Rj+uDT2i0eqgP DtprZFkCNyMhLiW7VYmFfqwThPtBybNtBu9uNLd4TmQC+2KshgX2S6zc8Quh6gnHzXql OtwTOV/s+L508uzx+Ok54fFDR8uqnMYZELKnqqdkvzCy/E7CAYZKFrnH8FAxiThtSK+O 7U3QzMN+pPwUHXgOMSJWG1h8Ut7bZms/TsT1sN6mj878Jk0Wkfsc7/evvevndgmIi5Wt pSUw== X-Gm-Message-State: AOAM530Mi71dCxTYSJgYLYScRf2LhUFsBaKRfZANzPui4UflTfiqpiwh ixklVEdFQE31sXgG64L1D4/NYsQYO5tDvQ== X-Google-Smtp-Source: ABdhPJwp1OeuAngYhzwVR+ani8se1plfy0V6s0/lBYqgZL/DOefYS7O78JYzUcB70lNmtnmALwG2KA== X-Received: by 2002:a50:d4cd:: with SMTP id e13mr2501091edj.117.1607527945621; Wed, 09 Dec 2020 07:32:25 -0800 (PST) Received: from localhost (ptr-5gw9txf6g5tndjqqqz.18120a2.ip6.access.telenet.be. [2a02:1810:510:3800:1b15:18e4:57d1:eb]) by smtp.gmail.com with ESMTPSA id y17sm1875085ejj.84.2020.12.09.07.32.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 07:32:25 -0800 (PST) From: Thomas De Schampheleire To: buildroot@buildroot.org Date: Wed, 9 Dec 2020 16:32:18 +0100 Message-Id: <20201209153219.17253-1-patrickdepinguin@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Subject: [Buildroot] [PATCH] utils/checkpackagelib/lib_mk.py: handle 'else' and 'elif' statements X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ricardo Martincoski , Thomas De Schampheleire Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" From: Thomas De Schampheleire 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 --- utils/checkpackagelib/lib_mk.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/checkpackagelib/lib_mk.py b/utils/checkpackagelib/lib_mk.py index 45e37e4598..0278354434 100644 --- a/utils/checkpackagelib/lib_mk.py +++ b/utils/checkpackagelib/lib_mk.py @@ -16,12 +16,13 @@ from checkpackagelib.lib import Utf8Characters # noqa: F401 # used in more than one check start_conditional = ["ifdef", "ifeq", "ifndef", "ifneq"] +continue_conditional = ["elif", "else"] end_conditional = ["endif"] class Indent(_CheckFunction): COMMENT = re.compile(r"^\s*#") - CONDITIONAL = re.compile(r"^\s*({})\s".format("|".join(start_conditional + end_conditional))) + CONDITIONAL = re.compile(r"^\s*({})\s".format("|".join(start_conditional + end_conditional + continue_conditional))) ENDS_WITH_BACKSLASH = re.compile(r"^[^#].*\\$") END_DEFINE = re.compile(r"^\s*endef\s") MAKEFILE_TARGET = re.compile(r"^[^# \t]+:\s") @@ -43,7 +44,7 @@ class Indent(_CheckFunction): expect_tabs = False if self.define or self.backslash or self.makefile_target: expect_tabs = True - if self.CONDITIONAL.search(text): + if not self.backslash and self.CONDITIONAL.search(text): expect_tabs = False # calculate for next line