]> git.lizzy.rs Git - metalua.git/blob - src/build-utils/precompile.lua
rewrote the build and install system, tested on linux and windows
[metalua.git] / src / build-utils / precompile.lua
1 -- Compile all files called *.mluam in a directory and its sub-directories,
2 -- into their *.luac counterpart.
3 --
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.
6
7 cfg = { }
8 for _, a in ipairs(arg) do
9    local var, val = a :match "^(.-)=(.*)"
10    if var then cfg[var] = val end
11 end
12
13 if not cfg.command or not cfg.directory then
14    error ("Usage: "..arg[0].." command=<metalua command> directory=<library root>")
15 end
16
17 local f = io.popen ("dir /S /b " .. cfg.directory)
18 for src in f:lines() do
19    local base = src:match "^(.+)%.mlua$"
20    if base then
21       local cmd = cfg.command.." "..src.." -o "..base..".luac"
22       print (cmd)
23       os.execute (cmd)
24    end
25 end
26
27