matricks / bam

Bam is a fast and flexible build system. Bam uses Lua to describe the build process. It's takes its inspiration for the script files from scons. While scons focuses on being 100% correct when building, bam makes a few sacrifices to acquire fast full and incremental build times.
http://matricks.github.com/bam
Other
146 stars 47 forks source link

Something like AddJob with Lua function instead of command. #155

Closed docbacardi closed 2 years ago

docbacardi commented 2 years ago

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)
matricks commented 2 years ago

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.

docbacardi commented 2 years ago

Thank you for the explanation. Just thinking about multithreading here makes the additional file suddenly a very nice solution.