From 574708a5f97907c4b4e67788d38f89fac0981b70 Mon Sep 17 00:00:00 2001 From: dacctal Date: Tue, 14 Apr 2026 22:54:24 +0000 Subject: added root config --- src/read_config.cc | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/read_config.cc (limited to 'src/read_config.cc') diff --git a/src/read_config.cc b/src/read_config.cc new file mode 100644 index 0000000..560b978 --- /dev/null +++ b/src/read_config.cc @@ -0,0 +1,40 @@ +extern "C" { +#include +#include +#include +} + +#include + +void set_install_directories() { + lua_State *L = lua_open(); + luaL_openlibs(L); + + if (luaL_loadfile(L, config_file.c_str()) || lua_pcall(L, 0, 0, 0)){ + std::cout << print_error << "cannot run configuration script: " << lua_tostring(L, -1) << "\n"; + return; + } + + lua_getglobal(L, "install_directories"); + + if (!lua_istable(L, -1)) { + std::cout << print_error << "lua variable 'install_directories' is not a table.\n"; + } + + lua_pushnil(L); + + while (lua_next(L, -2) != 0) { + const char *key = lua_tostring(L, -2); + const char *value = lua_tostring(L, -1); + + install_dirs[key] = value; + + lua_pop(L, 1); + } + + bin = install_dirs["bin"]; + lib = install_dirs["lib"]; + include = install_dirs["include"]; + pkgblds = install_dirs["pkgblds"]; + +} -- cgit v1.2.3