Skip to content

Commit

Permalink
build: lua 5.1/5.2: use generic version names
Browse files Browse the repository at this point in the history
TL;DR: use --lua=XXX for pkg-config name XXX, e.g. --lua=lua-5.1 .
       For unversioned 'lua.pc', use the name luadef51/luadef52 .
       Autodetection remains the same (5.2 names, luajit, 5.1 names).
       The old names are still supported, but not auto-detected.

Before this patch, if one wanted to choose a specific lua version when
more than one is installed, then the names were a mess, e.g. 51obsd is
also the name detected on Arch linux, and other (distro) names are
also not unique to a specific distro/platform.

So to ask mpv to choose the package name (specifically, the pkg-config
file name), one needs to look at the mpv sources and find the
(arbitrary) distro name which has the same lua version naming as they
do on their own system, e.g. --lua=51obsd on Arch. This is a pain.

Now we add generic names:
- luadef51/luadef52 - generic pkg-config lua.pc (version is inside).
- lua* - exactly the pkg-config name, e.g. --lua=lua-51 for lua-51.pc
  (the names are curated, e.g. --lua=foo won't detect foo.pc).
- The legacy names (e.g. 51deb) are still supported, but undocumented,
  and the new generic names take precedence during auto-detection.

The fact that the generic names all start with "lua" has an additional
benefit that it shows right after "lua" at the output of mpv -v,
while the old names start with numbers, so they're first at the list,
making it hard to understand that e.g. "51obsd" is the lua version.

None of these names are actually used at the mpv code. The C code
checks the version using the lua headers (LUA_VERSION_NUM).
  • Loading branch information
avih committed Oct 3, 2021
1 parent 7c5cd5e commit c3a647f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions waftools/checks/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,28 @@ def check_iconv(ctx, dependency_identifier):
return check_libs(libs, checkfn)(ctx, dependency_identifier)

def check_lua(ctx, dependency_identifier):
# mainline lua 5.1/5.2 doesn't have a .pc file, so each distro chooses
# a different name, either non-versioned (lua.pc) or lua5x/lua5.x/lua-5.x
# and we need to check them all. luadef* are the non-versioned .pc files,
# and the rest represent the .pc file exactly e.g. --lua=lua-5.1
# The non lua* names are legacy in mpv configure, and kept for compat.
lua_versions = [
( 'luadef52','lua >= 5.2.0 lua < 5.3.0' ), # package "lua"
( '52', 'lua >= 5.2.0 lua < 5.3.0' ),
( 'lua52', 'lua52 >= 5.2.0'),
( '52arch', 'lua52 >= 5.2.0'), # Arch
( 'lua5.2', 'lua5.2 >= 5.2.0'),
( '52deb', 'lua5.2 >= 5.2.0'), # debian
( 'lua-5.2','lua-5.2 >= 5.2.0'),
( '52fbsd', 'lua-5.2 >= 5.2.0'), # FreeBSD
( 'luajit', 'luajit >= 2.0.0' ),
( 'luadef51','lua >= 5.1.0 lua < 5.2.0'), # package "lua"
( '51', 'lua >= 5.1.0 lua < 5.2.0'),
( 'lua51', 'lua51 >= 5.1.0'),
( '51obsd', 'lua51 >= 5.1.0'), # OpenBSD
( 'lua5.1', 'lua5.1 >= 5.1.0'),
( '51deb', 'lua5.1 >= 5.1.0'), # debian
( 'lua-5.1','lua-5.1 >= 5.1.0'),
( '51fbsd', 'lua-5.1 >= 5.1.0'), # FreeBSD
]

Expand Down
2 changes: 1 addition & 1 deletion wscript
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ def options(opt):
group.add_option('--lua',
type = 'string',
dest = 'LUA_VER',
help = "select Lua package which should be autodetected. Choices: 51 51deb 51obsd 51fbsd 52 52deb 52arch 52fbsd luajit")
help = "select Lua package to autodetect. Choices (x is 1 or 2): luadef5x, lua5x, lua5.x, lua-5.x, luajit (luadef5x is for pkg-config name 'lua', the rest are exact pkg-config names)")
group.add_option('--swift-flags',
type = 'string',
dest = 'SWIFT_FLAGS',
Expand Down

0 comments on commit c3a647f

Please sign in to comment.