diff options
| author | dacctal <dacctal@symlinx.net> | 2026-05-02 08:38:13 +0000 |
|---|---|---|
| committer | dacctal <dacctal@symlinx.net> | 2026-05-02 08:38:13 +0000 |
| commit | 44eb727dc537403be092326639a5b7c6d7182146 (patch) | |
| tree | 1459603e69496400c22f53dcec67ec2c3348400a /src/lua_build.cc | |
| parent | c555d4c25b5526c37e94ee2c593f34bdf28b159e (diff) | |
fixed like half of everything idk, you can install stuff now
Diffstat (limited to 'src/lua_build.cc')
| -rw-r--r-- | src/lua_build.cc | 60 |
1 files changed, 17 insertions, 43 deletions
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 <iostream> -#include <filesystem> -#include <unordered_map> -#include "lua_state.hh" #include "lua_build.hh" +#include "lua_state.hh" #include "vars.hh" +#include <filesystem> +#include <iostream> +#include <unordered_map> -std::unordered_map<std::string, int> 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 |
