From 44eb727dc537403be092326639a5b7c6d7182146 Mon Sep 17 00:00:00 2001 From: dacctal Date: Sat, 2 May 2026 08:38:13 +0000 Subject: fixed like half of everything idk, you can install stuff now --- src/lua_build.cc | 60 ++++++++++++++++---------------------------------------- 1 file changed, 17 insertions(+), 43 deletions(-) (limited to 'src/lua_build.cc') diff --git a/src/lua_build.cc b/src/lua_build.cc index 75a626a..fd07184 100644 --- a/src/lua_build.cc +++ b/src/lua_build.cc @@ -1,51 +1,25 @@ -#include -#include -#include -#include "lua_state.hh" #include "lua_build.hh" +#include "lua_state.hh" #include "vars.hh" +#include +#include +#include -std::unordered_map build_files; - -bool lua_build(const char *path) { - init_lua_state(); - lua_State *L = get_lua_state(); - - lua_getglobal(L, "build_systems"); - - if (!lua_istable(L, -1)) { - std::cout << print_error << "lua variable 'build_systems' is not a table.\n"; +bool lua_build(const char *repository, const char *target, const char *path) { + std::cout << print_pkgit << "attempting to use build function specified in 'repositories." << repository << "'..." << std::endl; + if (repo_build(repository)) { + return true; } - lua_pushnil(L); - - bool build_found = false; - while (lua_next(L, -2) != 0) { - const char *key = lua_tostring(L, -2); - int value = lua_type(L, -1); - - if (lua_isfunction(L, -1) == 0) { - std::cout << print_error << "build value is not a function\n"; - lua_pop(L, 1); - continue; - } - - build_files[key] = value; + std::cout << print_pkgit << "attempting to use build function specified in 'bldit.lua'..." << std::endl; + if (bldit(target)) { + return true; + } - for (auto const& dir_entry : std::filesystem::directory_iterator(std::filesystem::current_path().string())) { - std::string string_key = key; - if (dir_entry.path().filename() != string_key) { continue; } - build_found = true; - lua_pushvalue(L, -1); - lua_pushstring(L, std::filesystem::current_path().string().c_str()); - std::cout << "calling lua build function according to key filename '"<< key << "'...\n"; - if (lua_pcall(L, 1, 0, 0) != 0) { - std::cout << print_error << "lua build function failed to run\n"; - break; - } - if (build_found) { break; } - } - lua_pop(L, 1); + std::cout << print_pkgit << "attempting to use build functions specified in 'build_systems'..." << std::endl; + if (config_build(path)) { + return true; } - return build_found; + + return false; } \ No newline at end of file -- cgit v1.2.3