1
0
mirror of https://github.com/natnat-mc/moonbuild synced 2026-05-12 00:31:13 +02:00

improved verbose

This commit is contained in:
codinget
2022-05-20 16:47:47 +02:00
parent 9450ec9c9d
commit 775d689e0a
7 changed files with 45 additions and 67 deletions
Generated
+11 -20
View File
@@ -6,9 +6,11 @@ do
local _obj_0 = require('moonbuild')
Context, DepGraph, Executor = _obj_0.Context, _obj_0.DepGraph, _obj_0.Executor
end
local Variable = (require('moonbuild'))['core.Variable']
local Variable = require('moonbuild.core.Variable')
local verbose
verbose = require('moonbuild._common').verbose
local parseargs
parseargs = (require('moonbuild'))['_cmd.common'].parseargs
parseargs = require('moonbuild._cmd.common').parseargs
local argparse = require('argparse')
local sort, concat
do
@@ -55,14 +57,11 @@ args.parallel = args.parallel == 'y' and 'y' or ((tonumber(args.parallel)) or er
if args.parallel ~= 'y' and (args.parallel < 1 or args.parallel % 1 ~= 0) then
error("Invalid argument for -j: " .. tostring(args.parallel))
end
if args.verbose then
print("Parsed CLI args")
end
verbose(args.verbose or false)
verbose("Parsed CLI args")
local ctx = Context()
ctx:load((loadfile(args.buildfile)), overrides)
if args.verbose then
print("Loaded buildfile")
end
verbose("Loaded buildfile")
if args.list then
print("Public targets")
local targets, n = { }, 1
@@ -94,20 +93,12 @@ if args.list_variables then
exit(0)
end
ctx:init()
if args.verbose then
print("Initialized buildfile")
end
verbose("Initialized buildfile")
local targets = #args.targets == 0 and ctx.defaulttargets or args.targets
local dag = DepGraph(ctx, targets)
if args.verbose then
print("Created dependancy graph")
end
verbose(print("Created dependancy graph"))
local nparallel = args.parallel == 'y' and Executor:getmaxparallel() or args.parallel
if args.verbose then
print("Building with " .. tostring(nparallel) .. " max parallel process" .. tostring(nparallel > 1 and "es" or ""))
end
verbose("Building with " .. tostring(nparallel) .. " max parallel process" .. tostring(nparallel > 1 and "es" or ""))
local executor = Executor(dag, nparallel)
executor:execute(args)
if args.verbose then
return print("Finished")
end
return verbose("Finished")
+13 -27
View File
@@ -77,18 +77,13 @@ 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)
verbose("[" .. tostring(f) .. "] " .. tostring(cmdline(...)))
return orig(...)
end
end
local _sh = cmd.sh
cmd.sh = function(cli)
verbose(function()
return print("[sh] " .. tostring(cli))
end)
verbose("[sh] " .. tostring(cli))
return _sh(cli)
end
local _cmd = cmd.cmd
@@ -679,8 +674,12 @@ verbose = function(arg)
end
elseif (type(arg)) == 'boolean' then
_verbose = arg
elseif (type(arg)) == 'string' then
if _verbose then
return print(arg)
end
else
return error("_.verbose takes either no argument, a boolean or a function")
return error("_.verbose takes either no argument, a boolean, a function or a string")
end
end
common.flatten = flatten
@@ -1382,9 +1381,7 @@ writefile = function(filename, data)
end
local moonc
moonc = function(infile, outfile)
verbose(function()
return print("[moonc] " .. tostring(infile) .. " " .. tostring(outfile))
end)
verbose("[moonc] " .. tostring(infile) .. " " .. tostring(outfile))
local code, err = to_lua(readfile(infile))
if not (code) then
error("Failed to compile " .. tostring(self.infile) .. ": " .. tostring(err))
@@ -2887,28 +2884,17 @@ moonbuild = function(...)
_.verbose(verbose)
local ctx = Context()
ctx:load((loadfile(buildfile)), opts)
_.verbose(function()
return print("Loaded buildfile")
end)
_.verbose("Loaded buildfile")
ctx:init()
_.verbose(function()
return print("Initialized buildfile")
end)
_.verbose("Initialized buildfile")
local targets = #opts == 0 and ctx.defaulttargets or opts
local dag = DepGraph(ctx, targets)
_.verbose(function()
return print("Created dependancy graph")
end)
_.verbose("Created dependancy graph")
local nparallel = parallel == true and Executor:getmaxparallel() or parallel
_.verbose(function()
return print("Building with " .. tostring(nparallel) .. " max parallel process" .. tostring(nparallel > 1 and "es" or ""))
end)
_.verbose("Building with " .. tostring(nparallel) .. " max parallel process" .. tostring(nparallel > 1 and "es" or ""))
local executor = Executor(dag, nparallel)
executor:execute(opts)
_.verbose(function()
return print("Finished")
end)
return print(_.verbose())
return _.verbose("Finished")
end
local table = {
moonbuild = moonbuild,