Added hot reload of loaders button and did a bit of luadebug

This commit is contained in:
Joppe Blondel
2025-10-24 14:53:00 +02:00
parent 1cd7b378b6
commit 8f5d71a6b9
4 changed files with 100 additions and 9 deletions

View File

@ -1,6 +1,25 @@
local core = require "core"
local process = require "process"
-- Dump any table to a string
---@param o any
---@param force bool|nil
---@return nil
---@diagnostic disable-next-line: unused-function
local function dump(o, force)
force = force or false
if type(o) == 'table' or force then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return type(o)..": "..tostring(o)
end
end
---@class LDB
local LDB = {
name = "luadebug"
@ -8,8 +27,42 @@ local LDB = {
---@param target table Target table
---@param name string Name of the target to run
---@praam debuginfo table Debugging information
---@return process|nil
function LDB:run(target, name)
function LDB:run(target, name, debuginfo)
if target.entry == nil then
core.error("[jpdebug][luadebug] target.entry is required")
return
end
local entry = target.entry
local lua = target.lua or {"lua"}
local cwd = target.cwd or "."
local env = target.env or {}
-- Build the inline lua launcher
local dbg_call = string.format([[
print("Here will the call to mobdebug be")
]])
local launcher = string.format([[
%s
dofile(%q)
]], dbg_call, entry)
-- Spawn the process
local cmd = lua
-- table.insert(lua, "-e")
table.insert(lua, entry)
local proc = process.start(cmd, {
cwd = cwd,
env = env,
stdout = process.REDIRECT_PIPE,
stderr = process.REDIRECT_PIPE,
})
if proc == nil then
core.error("[jpdebug][luadebug] Failed to start "..entry)
return nil
end
return proc
end
-- Wait untill it ends, possibly with timeout

View File

@ -9,8 +9,10 @@ local M = {
-- Run a shell command
---@param target table Target table
---@param name string Name of the target to run
---@praam debuginfo table Debugging information
---@return process|nil
function M:run(target, name)
---@diagnostic disable-next-line: unused-local
function M:run(target, name, debuginfo)
core.log("[jpdebug] Running shell command")
local opts = {
cwd = target.cwd or ".",