[libpeas/1.24] Fix meson check for lua 5.1 and lgi



commit 9e8e9f39f174ff75f2443c9240bf25da5daf5d54
Author: Christopher Arndt <chris chrisarndt de>
Date:   Tue Oct 29 17:32:45 2019 +0100

    Fix meson check for lua 5.1 and lgi
    
    Signed-off-by: Christopher Arndt <chris chrisarndt de>

 meson.build | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/meson.build b/meson.build
index 2cfb6b5..42b33d3 100644
--- a/meson.build
+++ b/meson.build
@@ -115,13 +115,31 @@ 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)
-
+lua_lgi_found = false
+lua_lgi_ver = 'not found'
+lua51_prg = find_program('lua5.1', required: false)
 luajit_prg = find_program('luajit', required: false)
 xmllint_prg = find_program('xmllint', required: false)
 
+if (luajit_dep.found() and luajit_prg.found()) or (lua51_dep.found() and lua51_prg.found())
+    if luajit_prg.found()
+        lua_prg = luajit_prg
+    else
+        lua_prf = lua51_prg
+    endif
+    lua_lgi_check = run_command(lua_prg, ['-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)
+            lua_lgi_found = true
+        endif
+    endif
+    message('lua-lgi version: ' + lua_lgi_ver)
+endif
+
 module_suffix = []
 if build_machine.system() == 'darwin'
   config_h.set('OS_OSX', 1)
@@ -188,7 +206,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 = (luajit_dep.found() or lua51_dep.found()) and lua_lgi_found
 if build_lua51_loader and not lua51_found
   build_lua51_loader = false
 endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]