[libpeas/meson.msvc: 6/12] meson.build: Improve lua search on Windows



commit c8aedcc96fc9782f0f82eb627aba9091070d8e5b
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Tue Nov 19 18:00:16 2019 +0800

    meson.build: Improve lua search on Windows
    
    On Windows, especially Visual Studio builds, lua does not come with a
    pkg-config file, so we may need to look for the dependencies manually.
    
    We first reverse the order of the search in such situations, by looking
    for whether we have lua.exe or luajit.exe in our path, and then we look
    for the lua headers and the lua library[1].  If they could be found, we
    proceed to look for lua-lgi and build as we did before.
    
    [1]: lua51.lib for luajit or lua5[3|2|1].lib for lua 5.[3|2|1].

 meson.build | 44 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)
---
diff --git a/meson.build b/meson.build
index 240c5e4..c331a66 100644
--- a/meson.build
+++ b/meson.build
@@ -2,7 +2,7 @@ project(
   'libpeas', 'c',
   version: '1.26.0',
   license: 'LGPLv2.1+',
-  meson_version: '>= 0.49.0',
+  meson_version: '>= 0.50.0',
   default_options: [
     'buildtype=debugoptimized',
   ]
@@ -149,7 +149,49 @@ endif
 luajit_prg = find_program('luajit', required: false)
 xmllint_prg = find_program('xmllint', required: false)
 
+if cc.get_id() == 'msvc'
+  if luajit_prg.found()
+    # luajit has lua51.lib as its import library
+    lua_names = ['lua51']
+  else
+    lua_names = ['lua53', 'lua52', 'lua51']
+  endif
+
+  lua_headers = ['lua.h', 'lualib.h', 'lauxlib.h']
+  # On Windows, the lua program may be named as lua.exe
+  foreach lua: lua_names + ['lua']
+    if not lua51_prg.found() and not luajit_prg.found()
+      lua51_prg = find_program(lua, required: false)
+    endif
+    if lua51_prg.found()
+      if lua != 'lua'
+        lua51_dep = cc.find_library(lua, has_headers: lua_headers, required: false)
+      endif
+    endif
+  endforeach
+
+  if not lua51_dep.found() and not luajit_dep.found()
+    foreach lualib: lua_names
+      if luajit_prg.found()
+        if not luajit_dep.found()
+          luajit_dep = cc.find_library(lualib, has_headers: lua_headers, required: false)
+        endif
+      endif
+
+      if lua51_prg.found()
+        if not lua51_dep.found()
+          lua51_dep = cc.find_library(lualib, has_headers: lua_headers, required: false)
+        endif
+      endif
+    endforeach
+  endif
+endif
+
 if (luajit_dep.found() and luajit_prg.found()) or (lua51_dep.found() and lua51_prg.found())
+  lua_found = true
+endif
+
+if lua_found
     if luajit_prg.found()
         lua_prg = luajit_prg
     else


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