1 -- Compile all files called *.mluam in a directory and its sub-directories,
2 -- into their *.luac counterpart.
4 -- This script is windows-only, Unices have half-decent shell script languages
5 -- which let you do the same with a find and an xargs.
8 for _, a in ipairs(arg) do
9 local var, val = a :match "^(.-)=(.*)"
10 if var then cfg[var] = val end
13 if not cfg.command or not cfg.directory then
14 error ("Usage: "..arg[0].." command=<metalua command> directory=<library root>")
17 -- List all files, recursively, from newest to oldest
18 local f = io.popen ("dir /S /b /o-D " .. cfg.directory)
21 for src in f:lines() do
23 local base = src:match "^(.+)%.mlua$"
25 local target = base..".luac"
26 if file_seen[target] then
27 -- the target file has been listed before the source ==> it's newer
28 print ("("..target.." up-to-date)")
30 local cmd = cfg.command.." "..src.." -o "..target