aboutsummaryrefslogtreecommitdiff
path: root/Mk/Uses/lua.mk
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2020-07-24 04:39:25 +0000
committerKyle Evans <kevans@FreeBSD.org>2020-07-24 04:39:25 +0000
commit11c50937c985de632d338262e3904f0d87cd4f97 (patch)
tree54bd0a914110ab42455fbc22dcf64f5476354147 /Mk/Uses/lua.mk
parent08d8ce4b7e453d6208e8d1a53c1ad8ab32c6ed61 (diff)
downloadports-11c50937c985de632d338262e3904f0d87cd4f97.tar.gz
ports-11c50937c985de632d338262e3904f0d87cd4f97.zip
Update version selection logic for USES= lua
Per discussion on D14709, this patch implements Antoine's suggested "closest version" logic in place of the previous "highest version" when the default version is not in the range allowed by the port. Submitted by: Andrew Gierth <andrew_tao173.riddles.org.uk> MFH: no Differential Revision: https://reviews.freebsd.org/D24492
Notes
Notes: svn path=/head/; revision=543000
Diffstat (limited to 'Mk/Uses/lua.mk')
-rw-r--r--Mk/Uses/lua.mk37
1 files changed, 25 insertions, 12 deletions
diff --git a/Mk/Uses/lua.mk b/Mk/Uses/lua.mk
index 5029223ded04..75bf69095899 100644
--- a/Mk/Uses/lua.mk
+++ b/Mk/Uses/lua.mk
@@ -29,10 +29,14 @@
#
# core for building Lua itself
#
-# If more than one version is allowed, then the LUA_DEFAULT version
-# (as set in DEFAULT_VERSIONS) is chosen if it is allowed, otherwise
-# the highest allowed version is chosen. But if "flavors" was requested,
-# and FLAVOR is set, we use that version.
+# If more than one version is allowed, then the LUA_DEFAULT version (as set
+# in DEFAULT_VERSIONS) is chosen if it is in the allowed range, otherwise
+# the closest allowed version to the default is chosen, preferring the
+# larger version in case of a tie.
+#
+# But if "flavors" was requested, and FLAVOR is set, we use that version
+# exactly. (It is an error to specify a flavor that isn't supported, but
+# that is checked in bsd.port.mk, not here.)
#
# LUA_FLAVOR is defined to the desired flavor whether or not "flavors" was
# selected; ports should use this to specify the flavor of dependencies
@@ -46,6 +50,8 @@
# used. However, they should still use LUA_FLAVOR as needed when specifying
# dependencies.
#
+# We assume Lua versions can be represented as 2 digits.
+#
.if !defined(_INCLUDE_USES_LUA_MK)
_INCLUDE_USES_LUA_MK= yes
@@ -165,15 +171,22 @@ IGNORE= USES=lua:xx-yy did not find any valid version
_LUA_WANTED_VERSIONS:= ${_LUA_VALID_VERSIONS}
.endif
-#
-# By now, _LUA_WANTED_VERSIONS is the list of valid version numbers that the
-# caller has allowed through. We want to put the default version, if it's in
-# the list, first, followed by all other versions in desc order; then the
-# first element is the one we want (or the default flavor in the flavor case)
-#
+# The "preferred" version, which must always exist, is defined as the
+# closest value to the default version, preferring higher versions in
+# case of ties. We find this by constructing values in sequence:
+# VV VV+1 VV-1 VV+2 VV-2 ...
+# and then filtering against the allowed versions. The result is the
+# final list of "wanted" versions, with the preferred version first.
+
+_LUA_NUM_ASC:= \
+ ${:U:range=99:@_v@${${_v} > ${_LUA_DEFAULT_VERSION}:?${_v}:}@}
+_LUA_NUM_DESC:= \
+ ${:U:range=99:[-1..1]:@_v@${${_v} <= ${_LUA_DEFAULT_VERSION}:?${_v}:}@}
+_LUA_NUM_ALL:= \
+ ${:U:range=99:@_v@${_LUA_NUM_DESC:[${_v}]} ${_LUA_NUM_ASC:[${_v}]}@}
+
_LUA_WANTED_VERSIONS:= \
- ${_LUA_WANTED_VERSIONS:M${_LUA_DEFAULT_VERSION}} \
- ${_LUA_WANTED_VERSIONS:N${_LUA_DEFAULT_VERSION}:O:u:[-1..1]}
+ ${_LUA_NUM_ALL:@_v@${_LUA_WANTED_VERSIONS:M${_v}}@}
.if ${_LUA_ARG_FLAVORS}
. if empty(FLAVORS)