diff options
| author | forever2k38 <forever2k38@forever2k38.net> | 2026-10-13 22:10:24 +0200 |
|---|---|---|
| committer | forever2k38 <forever2k38@forever2k38.net> | 2026-10-13 22:10:24 +0200 |
| commit | 8781a6d4f9d5840c7c9954706c972564bd40e76e (patch) | |
| tree | 74e49fc74bb14fd8a390a2323b06f7fdd8ac40d1 /src/config.c | |
| parent | 63f6adddc8b2098daf223be85e79f74c07db3ad4 (diff) | |
feat: copy build config instead of just makeopts
Diffstat (limited to 'src/config.c')
| -rw-r--r-- | src/config.c | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/src/config.c b/src/config.c index 7cfde0c..cbbbbe2 100644 --- a/src/config.c +++ b/src/config.c @@ -6,18 +6,16 @@ #include "stdlib.h" #include "string.h" -int pow_open_config(pow_config *cfg, char *path) { +int pow_open_config(lua_State *L_global, pow_config *cfg, char *path) { int err; - cfg->L = luaL_newstate(); + cfg->L_global = L_global; - if (!cfg->L) { - return 1; - } + luaL_openlibs(L_global); - lua_State *L = cfg->L; // just easier to access + lua_State *L = lua_newthread(L_global); - luaL_openlibs(L); + cfg->L_cfg = L; err = luaL_loadfile(L, path); @@ -101,7 +99,7 @@ int pow_open_config(pow_config *cfg, char *path) { lua_pop(L, 1); lua_pop(L, 1); - free(repo->path); + free((void*)repo->path); free(repo); return 1; @@ -119,19 +117,15 @@ int pow_open_config(pow_config *cfg, char *path) { lua_pop(L, 1); - lua_getfield(L, -1, "makeopts"); + lua_getfield(L, -1, "build"); - if (!lua_isstring(L, -1)) { - pow_log_info("no makeopts specified"); + if (!lua_istable(L, -1)) { + pow_log_info("no build options specified"); } else { - cfg->makeopts = strdup(lua_tostring(L, -1)); - - if (!cfg->makeopts) { - pow_log_error("failed to strdup makeopts"); - - return 1; - } + pow_log_info("build opts defined"); } + + cfg->build_cfg_ref = luaL_ref(L, LUA_REGISTRYINDEX); } return 0; @@ -139,14 +133,13 @@ int pow_open_config(pow_config *cfg, char *path) { int pow_close_config(pow_config *cfg) { for (size_t i = 0; i < cfg->repos_count; i++) { - free(cfg->repos[i]->path); + free((void*)cfg->repos[i]->path); free(cfg->repos[i]); } free(cfg->repos); - free(cfg->makeopts); - lua_close(cfg->L); + lua_close(cfg->L_cfg); return 0; } |
