package/lua: add options for coercion between number and string

The default behavior of Lua 5.3/5.4 interperter (and the only way with
Lua 5.1) is the automatic coercion. This default behavior could change
in future version (ie. Lua 5.5).

Disabling automatic coercion increases the performance of the interpreter.

Currently, using automatic coercion is not a good/recommended practice,
but there are no way (expect testing) to say if a Lua module relies on it.

We add two options to drive coercion in either way, and we make those
options default to y, as this was the de-facto situation until now; lua
5.1 forces those options: this will help when/if we have packages that
actually requires them, but has otherwise no requirement on the lua
version.

Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
[yann.morin.1998@free.fr:
  - don't limit options to lua 5.3||5.4
  - force those options for lua 5.1
  - extend commit log accordingly
]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
This commit is contained in:
Francois Perrad 2023-01-18 16:46:14 +01:00 committed by Yann E. MORIN
parent e7797603d2
commit c77c66b7df
2 changed files with 24 additions and 0 deletions

View File

@ -21,6 +21,8 @@ choice
config BR2_PACKAGE_LUA_5_1
bool "Lua 5.1.x"
select BR2_PACKAGE_LUAINTERPRETER_ABI_VERSION_5_1
select BR2_PACKAGE_LUA_CVT_N2S
select BR2_PACKAGE_LUA_CVT_S2N
config BR2_PACKAGE_LUA_5_3
bool "Lua 5.3.x"
@ -43,6 +45,20 @@ config BR2_PACKAGE_LUA_32BITS
endif
config BR2_PACKAGE_LUA_CVT_N2S
bool "automatic coercion from number to string"
default y # legacy
help
If unsure, say y, this is the default behavior of the Lua
interpreter. See LUA_NOCVTN2S in luaconf.h
config BR2_PACKAGE_LUA_CVT_S2N
bool "automatic coercion from string to number"
default y # legacy
help
If unsure, say y, this is the default behavior of the Lua
interpreter. See LUA_NOCVTN2S in luaconf.h
choice
prompt "Lua command-line editing"
default BR2_PACKAGE_LUA_EDITING_NONE

View File

@ -31,6 +31,14 @@ else ifeq ($(BR2_PACKAGE_LUA_5_3),y)
LUA_CFLAGS += -DLUA_COMPAT_5_2
endif
ifeq ($(BR2_PACKAGE_LUA_CVT_N2S),)
LUA_CFLAGS += -DLUA_NOCVTN2S
endif
ifeq ($(BR2_PACKAGE_LUA_CVT_S2N),)
LUA_CFLAGS += -DLUA_NOCVTS2N
endif
ifeq ($(BR2_STATIC_LIBS),y)
LUA_BUILDMODE = static
else