diff mbox series

[OpenWrt-Devel,1/1] build: add support to && in DEPENDS

Message ID mailman.36310.1556144974.2376.openwrt-devel@lists.openwrt.org
State Accepted, archived
Delegated to: Christian Lamparter
Headers show
Series build: add support to && in DEPENDS | expand

Commit Message

gio--- via openwrt-devel April 24, 2019, 10:29 p.m. UTC
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 <cote2004-github@yahoo.com>
diff mbox series

Patch

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;