]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
sysrepo-lua: fixed absolute path shared object loading from within Lua
authorVasek Sraier <git@vakabus.cz>
Mon, 27 Jan 2020 13:42:15 +0000 (14:42 +0100)
committerAleš <ales.mrazek@nic.cz>
Mon, 20 Jul 2020 14:54:40 +0000 (16:54 +0200)
modules/sysrepo-lua/ffi.lua.in [moved from modules/sysrepo-lua/ffi.lua with 97% similarity]
modules/sysrepo-lua/meson.build

similarity index 97%
rename from modules/sysrepo-lua/ffi.lua
rename to modules/sysrepo-lua/ffi.lua.in
index 355dcb149feddfb14d4d7d2a5a4f66e2248a8b7b..6fcfc16dc15cdd45a71a07280949da239429fa54 100644 (file)
@@ -1,8 +1,7 @@
 local ffi = require("ffi")
 
--- FIXME remove absolute path
--- the load opens the file relative to CWD. That could be anywhere. So we need to know, where is knot installed.
-local clib = ffi.load("/tmp/kr/lib/knot-resolver/kres_modules/sysrepo-lua/cbindings.so")
+-- The exact path is configured during project build by meson
+local clib = ffi.load("@modules_dir@/sysrepo-lua/cbindings.so")
 
 -------------------------------------------------------------------------------
 --                      FFI initialization
@@ -110,7 +109,7 @@ else
     _KNOT_SYSREPO_FFI_INITIALIZED = true
 end
 
--- TODO version check so that we cant load new module into an old Knot
+-- TODO version check so that we can not load new module into an old Knot
 
 -------------------------------------------------------------------------------
 --                      Data convertsion helpers
index e8ad92316c71396a9538cf4e13aae8b559cb1f05..9391753db37b6b5d61ea2248be88b986be7f8bef 100644 (file)
@@ -1,9 +1,18 @@
 # lua module: sysrepo-lua
 
-sysrepo_lua_src = files([
-  'ffi.lua',
-  'init.lua',
-])
+lua_config = configuration_data()
+lua_config.set('modules_dir', modules_dir)
+
+ffi = configure_file(
+  input: 'ffi.lua.in',
+  output: 'ffi.lua',
+  configuration: lua_config,
+)
+
+sysrepo_lua_src = [
+  ffi,
+  files('init.lua'),
+]
 
 sysrepo_src = files([
   'cbindings/sysrepo_clib.h',