Meson checks for Lua 5.1 and lgi fail
The checks for Lua 5.1 in meson.build
always fail on my system (Arch (Manjaro)), because:
- the Lua 5.1. pkg-config file is named
lua51.pc
notlua5.1.pc
, sodependency('lua5.1', ...)
does not work. - There is no pkg-config file for
lgi
(it is a Lua module, not a C-library), so AFAICSdependency()
can't be used to check for it.
It is easy to fix 1.
I fixed 2. by checking for the availability and version of lgi
via find_program('lua5.1')
, run_command()
and .version_compare()
. This check currently ignores the availability of LuaJIT, since I don't know how the situation when both Lua 5.1. and LuaJIT are present should be handled or how it was handled before the introduction of meson.
It seems building the Lua loader is not tested by the CI at all and in issue #25 (closed) it is indicated that there is no desire to maintain Lua support anymore. But, after fixing the build, it still works and (contrary to what is said in #25 (closed)) there are projects using it, e.g. Peasy, so I think building the Lua loader should either be fixed or Lua support should be deprecated and the fact announced in the README.
diff --git a/meson.build b/meson.build
index 14dadf4..59cfe63 100644
--- a/meson.build
+++ b/meson.build
@@ -112,13 +112,26 @@ endif
python2_dep = dependency('python2', version: python2_req, required: false)
pygobject_dep = dependency('pygobject-3.0', version: pygobject_req, required: false)
-lua51_dep = dependency('lua5.1', version: lua_req, required: false)
-lua51_lgi_dep = dependency('lua5.1-lgi', version: lua_lgi_req, required: false)
+lua51_dep = dependency('lua51', version: lua_req, required: false)
luajit_dep = dependency('luajit', version: luajit_req, required: false)
-
+lua51_lgi_found = false
+lua_lgi_ver = 'not found'
+lua51_bin = find_program('lua5.1')
luajit_prg = find_program('luajit', required: false)
xmllint_prg = find_program('xmllint', required: false)
+if lua51_dep.found() and lua51_bin.found()
+ lua_lgi_check = run_command(lua51_bin, ['-e', 'print(require("lgi")._VERSION)'])
+ if lua_lgi_check.returncode() == 0
+ lua_lgi_ver = lua_lgi_check.stdout().strip()
+ if lua_lgi_ver.version_compare(lua_lgi_req)
+ lua51_lgi_dep = declare_dependency(version: lua_lgi_ver)
+ lua51_lgi_found = true
+ endif
+ endif
+ message('lua-lgi version: ' + lua_lgi_ver)
+endif
+
if build_machine.system() == 'darwin'
config_h.set_quoted('OS_OSX', 1)
endif
@@ -182,7 +195,7 @@ if generate_gir and not introspection_dep.found()
endif
build_lua51_loader = get_option('lua51')
-lua51_found = lua51_dep.found() and lua51_lgi_dep.found()
+lua51_found = lua51_dep.found() and lua51_lgi_found
if build_lua51_loader and not lua51_found
build_lua51_loader = false
endif