|
|
@ -36,11 +36,13 @@ end |
|
|
|
do |
|
|
|
do |
|
|
|
local _ENV = _ENV |
|
|
|
local _ENV = _ENV |
|
|
|
package.preload[ "moonbuild._cmd" ] = function( ... ) local arg = _G.arg; |
|
|
|
package.preload[ "moonbuild._cmd" ] = function( ... ) local arg = _G.arg; |
|
|
|
local parseargs, escape |
|
|
|
local parseargs, escape, cmdline |
|
|
|
do |
|
|
|
do |
|
|
|
local _obj_0 = require('moonbuild._cmd.common') |
|
|
|
local _obj_0 = require('moonbuild._cmd.common') |
|
|
|
parseargs, escape = _obj_0.parseargs, _obj_0.escape |
|
|
|
parseargs, escape, cmdline = _obj_0.parseargs, _obj_0.escape, _obj_0.cmdline |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
local verbose |
|
|
|
|
|
|
|
verbose = require('moonbuild._common').verbose |
|
|
|
local ok, cmd, backend = false, nil, nil |
|
|
|
local ok, cmd, backend = false, nil, nil |
|
|
|
if not (ok) then |
|
|
|
if not (ok) then |
|
|
|
ok, cmd = pcall(function() |
|
|
|
ok, cmd = pcall(function() |
|
|
@ -67,6 +69,28 @@ end |
|
|
|
cmd.backend = backend |
|
|
|
cmd.backend = backend |
|
|
|
cmd.parseargs = parseargs |
|
|
|
cmd.parseargs = parseargs |
|
|
|
cmd.escape = escape |
|
|
|
cmd.escape = escape |
|
|
|
|
|
|
|
local _list_0 = ({ |
|
|
|
|
|
|
|
'cmd', |
|
|
|
|
|
|
|
'cmdrst' |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
for _index_0 = 1, #_list_0 do |
|
|
|
|
|
|
|
local f = _list_0[_index_0] |
|
|
|
|
|
|
|
local orig = cmd[f] |
|
|
|
|
|
|
|
cmd[f] = function(...) |
|
|
|
|
|
|
|
local cli = cmdline(...) |
|
|
|
|
|
|
|
verbose(function() |
|
|
|
|
|
|
|
return print("[" .. tostring(f) .. "] " .. tostring(cli)) |
|
|
|
|
|
|
|
end) |
|
|
|
|
|
|
|
return orig(...) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
local _sh = cmd.sh |
|
|
|
|
|
|
|
cmd.sh = function(cli) |
|
|
|
|
|
|
|
verbose(function() |
|
|
|
|
|
|
|
return print("[sh] " .. tostring(cli)) |
|
|
|
|
|
|
|
end) |
|
|
|
|
|
|
|
return _sh(cli) |
|
|
|
|
|
|
|
end |
|
|
|
local _cmd = cmd.cmd |
|
|
|
local _cmd = cmd.cmd |
|
|
|
local _cmdrst = cmd.cmdrst |
|
|
|
local _cmdrst = cmd.cmdrst |
|
|
|
cmd.cmdline = function(cmdline) |
|
|
|
cmd.cmdline = function(cmdline) |
|
|
@ -99,6 +123,8 @@ do |
|
|
|
end |
|
|
|
end |
|
|
|
local concat |
|
|
|
local concat |
|
|
|
concat = table.concat |
|
|
|
concat = table.concat |
|
|
|
|
|
|
|
local flatten |
|
|
|
|
|
|
|
flatten = require('moonbuild._common').flatten |
|
|
|
local specialchars = { |
|
|
|
local specialchars = { |
|
|
|
['\"'] = '\\\"', |
|
|
|
['\"'] = '\\\"', |
|
|
|
['\\'] = '\\\\', |
|
|
|
['\\'] = '\\\\', |
|
|
@ -230,9 +256,24 @@ parseargs = function(argstr) |
|
|
|
end |
|
|
|
end |
|
|
|
return args |
|
|
|
return args |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
local cmdline |
|
|
|
|
|
|
|
cmdline = function(...) |
|
|
|
|
|
|
|
return concat((function(...) |
|
|
|
|
|
|
|
local _accum_0 = { } |
|
|
|
|
|
|
|
local _len_0 = 1 |
|
|
|
|
|
|
|
local _list_0 = flatten(...) |
|
|
|
|
|
|
|
for _index_0 = 1, #_list_0 do |
|
|
|
|
|
|
|
local arg = _list_0[_index_0] |
|
|
|
|
|
|
|
_accum_0[_len_0] = escape(arg) |
|
|
|
|
|
|
|
_len_0 = _len_0 + 1 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
return _accum_0 |
|
|
|
|
|
|
|
end)(...), ' ') |
|
|
|
|
|
|
|
end |
|
|
|
return { |
|
|
|
return { |
|
|
|
escape = escape, |
|
|
|
escape = escape, |
|
|
|
parseargs = parseargs |
|
|
|
parseargs = parseargs, |
|
|
|
|
|
|
|
cmdline = cmdline |
|
|
|
} |
|
|
|
} |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
@ -240,8 +281,8 @@ end |
|
|
|
do |
|
|
|
do |
|
|
|
local _ENV = _ENV |
|
|
|
local _ENV = _ENV |
|
|
|
package.preload[ "moonbuild._cmd.lua" ] = function( ... ) local arg = _G.arg; |
|
|
|
package.preload[ "moonbuild._cmd.lua" ] = function( ... ) local arg = _G.arg; |
|
|
|
local escape |
|
|
|
local cmdline |
|
|
|
escape = require('moonbuild._cmd.common').escape |
|
|
|
cmdline = require('moonbuild._cmd.common').cmdline |
|
|
|
local flatten |
|
|
|
local flatten |
|
|
|
flatten = require('moonbuild._common').flatten |
|
|
|
flatten = require('moonbuild._common').flatten |
|
|
|
local execute |
|
|
|
local execute |
|
|
@ -250,20 +291,6 @@ local popen |
|
|
|
popen = io.popen |
|
|
|
popen = io.popen |
|
|
|
local concat |
|
|
|
local concat |
|
|
|
concat = table.concat |
|
|
|
concat = table.concat |
|
|
|
local cmdline |
|
|
|
|
|
|
|
cmdline = function(...) |
|
|
|
|
|
|
|
return concat((function(...) |
|
|
|
|
|
|
|
local _accum_0 = { } |
|
|
|
|
|
|
|
local _len_0 = 1 |
|
|
|
|
|
|
|
local _list_0 = flatten(...) |
|
|
|
|
|
|
|
for _index_0 = 1, #_list_0 do |
|
|
|
|
|
|
|
local arg = _list_0[_index_0] |
|
|
|
|
|
|
|
_accum_0[_len_0] = escape(arg) |
|
|
|
|
|
|
|
_len_0 = _len_0 + 1 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
return _accum_0 |
|
|
|
|
|
|
|
end)(...), ' ') |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
local cmd |
|
|
|
local cmd |
|
|
|
cmd = function(...) |
|
|
|
cmd = function(...) |
|
|
|
local ok, ret, code = execute(cmdline(...)) |
|
|
|
local ok, ret, code = execute(cmdline(...)) |
|
|
@ -283,6 +310,9 @@ cmdrst = function(...) |
|
|
|
end |
|
|
|
end |
|
|
|
local sh |
|
|
|
local sh |
|
|
|
sh = function(cli) |
|
|
|
sh = function(cli) |
|
|
|
|
|
|
|
verbose(function() |
|
|
|
|
|
|
|
return print('[sh] ' .. cli) |
|
|
|
|
|
|
|
end) |
|
|
|
local ok, ret, code = execute(cli) |
|
|
|
local ok, ret, code = execute(cli) |
|
|
|
if not (ok) then |
|
|
|
if not (ok) then |
|
|
|
return error("command '" .. tostring(cli) .. "' exited with " .. tostring(code) .. " (" .. tostring(ret) .. ")") |
|
|
|
return error("command '" .. tostring(cli) .. "' exited with " .. tostring(code) .. " (" .. tostring(ret) .. ")") |
|
|
@ -354,6 +384,9 @@ cmdrst = function(...) |
|
|
|
end |
|
|
|
end |
|
|
|
local sh |
|
|
|
local sh |
|
|
|
sh = function(cli) |
|
|
|
sh = function(cli) |
|
|
|
|
|
|
|
verbose(function() |
|
|
|
|
|
|
|
return print('[sh] ' .. cli) |
|
|
|
|
|
|
|
end) |
|
|
|
return cmd('sh', '-c', cli) |
|
|
|
return cmd('sh', '-c', cli) |
|
|
|
end |
|
|
|
end |
|
|
|
return { |
|
|
|
return { |
|
|
@ -635,6 +668,21 @@ minmax = function(list) |
|
|
|
end |
|
|
|
end |
|
|
|
return m, M |
|
|
|
return m, M |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
local _verbose = false |
|
|
|
|
|
|
|
local verbose |
|
|
|
|
|
|
|
verbose = function(arg) |
|
|
|
|
|
|
|
if arg == nil then |
|
|
|
|
|
|
|
return _verbose |
|
|
|
|
|
|
|
elseif (type(arg)) == 'function' then |
|
|
|
|
|
|
|
if _verbose then |
|
|
|
|
|
|
|
return arg() |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
elseif (type(arg)) == 'boolean' then |
|
|
|
|
|
|
|
_verbose = arg |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
return error("_.verbose takes either no argument, a boolean or a function") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
common.flatten = flatten |
|
|
|
common.flatten = flatten |
|
|
|
common.first = first |
|
|
|
common.first = first |
|
|
|
common.foreach = foreach |
|
|
|
common.foreach = foreach |
|
|
@ -647,6 +695,7 @@ common.exclude = exclude |
|
|
|
common.min = min |
|
|
|
common.min = min |
|
|
|
common.max = max |
|
|
|
common.max = max |
|
|
|
common.minmax = minmax |
|
|
|
common.minmax = minmax |
|
|
|
|
|
|
|
common.verbose = verbose |
|
|
|
return setmetatable(common, { |
|
|
|
return setmetatable(common, { |
|
|
|
__call = function(self) |
|
|
|
__call = function(self) |
|
|
|
local _accum_0 = { } |
|
|
|
local _accum_0 = { } |
|
|
@ -1260,6 +1309,8 @@ do |
|
|
|
local _obj_0 = require('moonbuild._cmd') |
|
|
|
local _obj_0 = require('moonbuild._cmd') |
|
|
|
parseargs, cmdrst = _obj_0.parseargs, _obj_0.cmdrst |
|
|
|
parseargs, cmdrst = _obj_0.parseargs, _obj_0.cmdrst |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
local verbose |
|
|
|
|
|
|
|
verbose = require('moonbuild._common').verbose |
|
|
|
local gmatch, match, gsub |
|
|
|
local gmatch, match, gsub |
|
|
|
do |
|
|
|
do |
|
|
|
local _obj_0 = string |
|
|
|
local _obj_0 = string |
|
|
@ -1331,6 +1382,9 @@ writefile = function(filename, data) |
|
|
|
end |
|
|
|
end |
|
|
|
local moonc |
|
|
|
local moonc |
|
|
|
moonc = function(infile, outfile) |
|
|
|
moonc = function(infile, outfile) |
|
|
|
|
|
|
|
verbose(function() |
|
|
|
|
|
|
|
return print("[moonc] " .. tostring(infile) .. " " .. tostring(outfile)) |
|
|
|
|
|
|
|
end) |
|
|
|
local code, err = to_lua(readfile(infile)) |
|
|
|
local code, err = to_lua(readfile(infile)) |
|
|
|
if not (code) then |
|
|
|
if not (code) then |
|
|
|
error("Failed to compile " .. tostring(self.infile) .. ": " .. tostring(err)) |
|
|
|
error("Failed to compile " .. tostring(self.infile) .. ": " .. tostring(err)) |
|
|
@ -2830,29 +2884,31 @@ moonbuild = function(...) |
|
|
|
opts.force = force |
|
|
|
opts.force = force |
|
|
|
local verbose = opts.verbose or opts.v or false |
|
|
|
local verbose = opts.verbose or opts.v or false |
|
|
|
opts.verbose = verbose |
|
|
|
opts.verbose = verbose |
|
|
|
|
|
|
|
_.verbose(verbose) |
|
|
|
local ctx = Context() |
|
|
|
local ctx = Context() |
|
|
|
ctx:load((loadfile(buildfile)), opts) |
|
|
|
ctx:load((loadfile(buildfile)), opts) |
|
|
|
if verbose then |
|
|
|
_.verbose(function() |
|
|
|
print("Loaded buildfile") |
|
|
|
return print("Loaded buildfile") |
|
|
|
end |
|
|
|
end) |
|
|
|
ctx:init() |
|
|
|
ctx:init() |
|
|
|
if verbose then |
|
|
|
_.verbose(function() |
|
|
|
print("Initialized buildfile") |
|
|
|
return print("Initialized buildfile") |
|
|
|
end |
|
|
|
end) |
|
|
|
local targets = #opts == 0 and ctx.defaulttargets or opts |
|
|
|
local targets = #opts == 0 and ctx.defaulttargets or opts |
|
|
|
local dag = DepGraph(ctx, targets) |
|
|
|
local dag = DepGraph(ctx, targets) |
|
|
|
if verbose then |
|
|
|
_.verbose(function() |
|
|
|
print("Created dependancy graph") |
|
|
|
return print("Created dependancy graph") |
|
|
|
end |
|
|
|
end) |
|
|
|
local nparallel = parallel == true and Executor:getmaxparallel() or parallel |
|
|
|
local nparallel = parallel == true and Executor:getmaxparallel() or parallel |
|
|
|
if verbose then |
|
|
|
_.verbose(function() |
|
|
|
print("Building with " .. tostring(nparallel) .. " max parallel process" .. tostring(nparallel > 1 and "es" or "")) |
|
|
|
return print("Building with " .. tostring(nparallel) .. " max parallel process" .. tostring(nparallel > 1 and "es" or "")) |
|
|
|
end |
|
|
|
end) |
|
|
|
local executor = Executor(dag, nparallel) |
|
|
|
local executor = Executor(dag, nparallel) |
|
|
|
executor:execute(opts) |
|
|
|
executor:execute(opts) |
|
|
|
if verbose then |
|
|
|
_.verbose(function() |
|
|
|
return print("Finished") |
|
|
|
return print("Finished") |
|
|
|
end |
|
|
|
end) |
|
|
|
|
|
|
|
return print(_.verbose()) |
|
|
|
end |
|
|
|
end |
|
|
|
local table = { |
|
|
|
local table = { |
|
|
|
moonbuild = moonbuild, |
|
|
|
moonbuild = moonbuild, |
|
|
|