build: Allow to specify which system lua to use

On Exherbo we allow to install different Lua ABIs in parallel and
users can choose per-package which Lua ABI to use, e.g.

  media/wireplumber LUA_ABIS: -* 5.3

However, wireplumber's build system doesn't provide a way of explicitly
requesting a specific version, which makes the build non-deterministic,
since you get a different result if you install today with Lua 5.3
installed and reinstall tomorrow after installing Lua 5.4.

To fix this, I introduced a `system-lua-version` option that allows to
specify an explicit Lua version to check for and build against:

> $ meson .. -Dsystem-lua=true -Dsystem-lua-version=5.4
> The Meson build system
> Version: 0.58.0
> Source dir: /mnt/development/scm/freedesktop/wireplumber
> Build dir: /mnt/development/scm/freedesktop/wireplumber/build/reconfigure
> Build type: native build
> Project name: wireplumber
> Project version: 0.4.1
> [...]
> Run-time dependency lua-5.4 found: YES 5.4.3
> [...]
> Build targets in project: 56
>
> wireplumber 0.4.1
>
>     Lua version                    : 5.4.3 (system)
>     systemd conf data              : YES

If the specified version isn't found, the build will fail loudly:

> $ meson .. -Dsystem-lua=true -Dsystem-lua-version=5.5
> [...]
> Found CMake: /usr/host/bin/cmake (3.20.5)
> Run-time dependency lua-5.5 found: NO (tried pkgconfig and cmake)
> Run-time dependency lua5.5 found: NO (tried pkgconfig and cmake)
>
> ../meson.build:50:6: ERROR: Problem encountered: Specified Lua version "5.5" not found
This commit is contained in:
Marvin Schmidt 2021-07-27 21:04:59 +02:00 committed by George Kiagiadakis
parent 8c9da58d76
commit da8fc024f5
2 changed files with 36 additions and 21 deletions

View file

@ -39,27 +39,39 @@ threads_dep = dependency('threads')
system_lua = get_option('system-lua') system_lua = get_option('system-lua')
if system_lua if system_lua
lua_dep = dependency('lua-5.4', required: false) if get_option('system-lua-version') != 'auto'
if not lua_dep.found() lua_version_requested = get_option('system-lua-version')
lua_dep = dependency('lua5.4', required: false) lua_dep = dependency('lua-' + lua_version_requested, required: false)
endif if not lua_dep.found()
if not lua_dep.found() lua_dep = dependency('lua' + lua_version_requested, required: false)
lua_dep = dependency('lua54', required: false) endif
endif
if not lua_dep.found() if not lua_dep.found()
lua_dep = dependency('lua-5.3', required: false) error('Specified Lua version "' + lua_version_requested + '" not found')
endif endif
if not lua_dep.found() else
lua_dep = dependency('lua5.3', required: false) lua_dep = dependency('lua-5.4', required: false)
endif if not lua_dep.found()
if not lua_dep.found() lua_dep = dependency('lua5.4', required: false)
lua_dep = dependency('lua53', required: false) endif
endif if not lua_dep.found()
if not lua_dep.found() lua_dep = dependency('lua54', required: false)
lua_dep = dependency('lua', version: ['>=5.3.0'], required: false) endif
endif if not lua_dep.found()
if not lua_dep.found() lua_dep = dependency('lua-5.3', required: false)
error ('Could not find lua. Lua version 5.4 or 5.3 required') endif
if not lua_dep.found()
lua_dep = dependency('lua5.3', required: false)
endif
if not lua_dep.found()
lua_dep = dependency('lua53', required: false)
endif
if not lua_dep.found()
lua_dep = dependency('lua', version: ['>=5.3.0'], required: false)
endif
if not lua_dep.found()
error ('Could not find lua. Lua version 5.4 or 5.3 required')
endif
endif endif
else else
lua_proj = subproject('lua', default_options: ['default_library=static']) lua_proj = subproject('lua', default_options: ['default_library=static'])

View file

@ -4,6 +4,9 @@ option('doc', type : 'feature', value : 'auto',
description: 'Enable documentation.') description: 'Enable documentation.')
option('system-lua', type : 'boolean', value : 'false', option('system-lua', type : 'boolean', value : 'false',
description : 'Use lua from the system instead of the bundled one') description : 'Use lua from the system instead of the bundled one')
option('system-lua-version',
type: 'string', value : 'auto',
description: 'The system lua version to use or "auto" for auto-detection')
option('systemd', option('systemd',
type: 'feature', value: 'auto', type: 'feature', value: 'auto',
description: 'Enable installing systemd units') description: 'Enable installing systemd units')