From patchwork Wed Apr 24 22:29:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Richard via openwrt-devel X-Patchwork-Id: 1090516 X-Patchwork-Delegate: chunkeey@googlemail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=lists.openwrt.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="njIIF8RZ"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44qFPJ0WSNz9s3l for ; Thu, 25 Apr 2019 08:29:55 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Date:Sender:Content-Type: Subject:List-Help:Reply-To:List-Archive:List-Unsubscribe:List-Subscribe:Cc: From:List-Post:List-Id:Message-ID:MIME-Version:References:In-Reply-To:To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+WnXu1gqhaIZjJUzEyZns/jviace41AGux9k+Mtxkhs=; b=njIIF8RZOB48bxKC2P+45Hjhv WU5u1afkpRpbhyMhz0VJGTI0wvl+9TgPh7RW8zUb4TH5xUqI3N8j077skZR5ii0p1VDNfkwVRAqAd hf6ckDMuDdVuaIFBpV01fShi10+zTZBTa1RMVlFn/rjRl8WtYJjG4rsNYF3WCBSd7wpOaK7L2IkQA cG+d5lCc/ZsFuq7a1avd4gNao3krS20c4K3lhHPOKcZL1aa70ehpNM1B5byyChndVIHOU+HPRZMjx G9ycir+HNf1pwAUx96m4Wg5LRbRtZSYgYo5ocpdTjHGx1Kbv8vpB4oiw5bK/ZY//44yHqMgNYCofr yZWrYNoug==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hJQOd-00067K-5s; Wed, 24 Apr 2019 22:29:43 +0000 To: openwrt-devel@lists.openwrt.org In-Reply-To: <20190424222823.20741-1-cote2004-github@yahoo.com> References: <20190424222823.20741-1-cote2004-github@yahoo.com> MIME-Version: 1.0 Message-ID: List-Id: List-Post: X-Patchwork-Original-From: Eneas U de Queiroz via openwrt-devel From: Thomas Richard via openwrt-devel Precedence: list Cc: Eneas U de Queiroz X-Mailman-Version: 2.1.21 X-BeenThere: openwrt-devel@lists.openwrt.org List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: Eneas U de Queiroz List-Help: Subject: [OpenWrt-Devel] [PATCH 1/1] build: add support to && in DEPENDS Sender: "openwrt-devel" Date: Wed, 24 Apr 2019 22:29:43 +0000 Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The sender domain has a DMARC Reject/Quarantine policy which disallows sending mailing list messages using the original "From" header. To mitigate this problem, the original message has been wrapped automatically by the mailing list software. Adds support to && operand in DEPENDS. Also, fixes generation of || dependencies by scripts/package-metadata.pl. The precedence order from higher to lower is && then ||. Use of parentheses to change the order is not supported. As before, they are silently ignored. Use them for readability only. Signed-off-by: Eneas U de Queiroz diff --git a/include/package-ipkg.mk b/include/package-ipkg.mk index 9ca4879bfa..38252b95cd 100644 --- a/include/package-ipkg.mk +++ b/include/package-ipkg.mk @@ -35,7 +35,8 @@ PARENR :=) dep_split=$(subst :,$(space),$(1)) dep_rem=$(subst !,,$(subst $(strip $(PARENL)),,$(subst $(strip $(PARENR)),,$(word 1,$(call dep_split,$(1)))))) -dep_confvar=$(strip $(foreach cond,$(subst ||, ,$(call dep_rem,$(1))),$(CONFIG_$(cond)))) +dep_and=dep_and_res:=$$(and $(subst $(space),$(comma),$(foreach cond,$(subst &&, ,$(1)),$$(CONFIG_$(cond))))) +dep_confvar=$(strip $(foreach cond,$(subst ||, ,$(call dep_rem,$(1))),$(eval $(call dep_and,$(cond)))$(dep_and_res))) dep_pos=$(if $(call dep_confvar,$(1)),$(call dep_val,$(1))) dep_neg=$(if $(call dep_confvar,$(1)),,$(call dep_val,$(1))) dep_if=$(if $(findstring !,$(1)),$(call dep_neg,$(1)),$(call dep_pos,$(1))) diff --git a/scripts/package-metadata.pl b/scripts/package-metadata.pl index e0cdff1e81..76b09a56eb 100755 --- a/scripts/package-metadata.pl +++ b/scripts/package-metadata.pl @@ -358,14 +358,30 @@ sub gen_package_config() { print_package_overrides(); } +sub and_condition($) { + my $condition = shift; + my @spl_and = split('\&\&', $condition); + if (@spl_and == 1) { + return "\$(CONFIG_$spl_and[0])"; + } + return "\$(and " . join (',', map("\$(CONFIG_$_)", @spl_and)) . ")"; +} + +sub gen_condition ($) { + my $condition = shift; + # remove '!()', just as include/package-ipkg.mk does + $condition =~ s/[()!]//g; + return join("", map(and_condition($_), split('\|\|', $condition))); +} + sub get_conditional_dep($$) { my $condition = shift; my $depstr = shift; if ($condition) { if ($condition =~ /^!(.+)/) { - return "\$(if \$(CONFIG_$1),,$depstr)"; + return "\$(if " . gen_condition($1) . ",,$depstr)"; } else { - return "\$(if \$(CONFIG_$condition),$depstr)"; + return "\$(if " . gen_condition($condition) . ",$depstr)"; } } else { return $depstr;