Something like AddJob with Lua function instead of command.
Closed this issue · 2 comments
I have compiled and linked some sources with bam which gives me a binary. Now I need to do some work on the binary which can easily be written as a Lua function. My current solution has the Lua code in a separate file and call it with "bam -e" like this:
AddJob(output_file, "Bootimage " .. input_file, _bam_exe .. " -e test_tool.lua " .. input_file .. " " .. output_file)
It works, but feels a bit clumsy due to the extra file. Is there another solution which preferably works without an additional file?
local function do_work(target, inputs)
-- Do work.
end
AddJobFromTheFuture(output_file, "Bootimage " .. input_file, do_work)
This is actually how jobs was done in the first iterations of bam when each job was a lua function instead of a command line. This however caused a bunch of issues when you start threading things as several threads can't touch the Lua VM at the same time. This then lead to performance issues. You could perhaps duplicate the VM etc but that also becomes very very messy quickly. So I reworked everything so you just run lua once during startup instead and added the -e option for doing external scripts which make everything very clear how it works.
Sorry to be a downer, but the current, all tho a bit clumsy I agree, is much cleaner then the alternatives that I've thought about.
Thank you for the explanation. Just thinking about multithreading here makes the additional file suddenly a very nice solution.