mirror of
https://github.com/natnat-mc/moonbuild
synced 2026-05-28 09:39:40 +02:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| de7ab2ddbf | |||
| 37ab4f2299 | |||
| 4cd18877a9 | |||
| 67eb978e43 | |||
| f51be8631b | |||
| 715aa2ebb7 | |||
| bed119a40c | |||
| 57126a7973 | |||
| cd9b0ab159 |
@@ -0,0 +1,3 @@
|
|||||||
|
*.lua linguist-generated
|
||||||
|
out/* linguist-generated
|
||||||
|
Makefile -linguist-detectable
|
||||||
@@ -7,6 +7,7 @@ tasks:
|
|||||||
tasks.build!
|
tasks.build!
|
||||||
sh "rockbuild -m -t #{@v} upload"
|
sh "rockbuild -m -t #{@v} upload"
|
||||||
|
|
||||||
|
watch: => watch {'.'}, {'.git'}, 'live', (glob '*.moon'), pcall -> moonbuild j: true
|
||||||
build: => moonbuild j: true
|
build: => moonbuild j: true
|
||||||
install: => moonbuild 'install', j: true
|
install: => moonbuild 'install', j: true
|
||||||
clean: => moonbuild 'clean'
|
clean: => moonbuild 'clean'
|
||||||
|
|||||||
+14
-1
@@ -1,4 +1,5 @@
|
|||||||
import parseargs, escape from require 'moonbuild._cmd.common'
|
import parseargs, escape, cmdline from require 'moonbuild._cmd.common'
|
||||||
|
import verbose from require 'moonbuild._common'
|
||||||
|
|
||||||
ok, cmd, backend = false, nil, nil
|
ok, cmd, backend = false, nil, nil
|
||||||
unless ok
|
unless ok
|
||||||
@@ -17,6 +18,18 @@ cmd.backend = backend
|
|||||||
cmd.parseargs = parseargs
|
cmd.parseargs = parseargs
|
||||||
cmd.escape = escape
|
cmd.escape = escape
|
||||||
|
|
||||||
|
-- make verbose verisons of _.cmd, _.cmdrst and _.sh
|
||||||
|
for f in *({'cmd', 'cmdrst'})
|
||||||
|
orig = cmd[f]
|
||||||
|
cmd[f] = (...) ->
|
||||||
|
cli = cmdline ...
|
||||||
|
verbose -> print "[#{f}] #{cli}"
|
||||||
|
orig ...
|
||||||
|
_sh = cmd.sh
|
||||||
|
cmd.sh = (cli) ->
|
||||||
|
verbose -> print "[sh] #{cli}"
|
||||||
|
_sh cli
|
||||||
|
|
||||||
-- derived cmd functions
|
-- derived cmd functions
|
||||||
_cmd = cmd.cmd
|
_cmd = cmd.cmd
|
||||||
_cmdrst = cmd.cmdrst
|
_cmdrst = cmd.cmdrst
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import gsub, sub, match from string
|
import gsub, sub, match from string
|
||||||
import concat from table
|
import concat from table
|
||||||
|
import flatten from require 'moonbuild._common'
|
||||||
|
|
||||||
specialchars =
|
specialchars =
|
||||||
'\"': '\\\"'
|
'\"': '\\\"'
|
||||||
@@ -115,7 +116,11 @@ parseargs = (argstr) ->
|
|||||||
|
|
||||||
args
|
args
|
||||||
|
|
||||||
|
cmdline = (...) ->
|
||||||
|
concat [escape arg for arg in *flatten ...], ' '
|
||||||
|
|
||||||
{
|
{
|
||||||
:escape
|
:escape
|
||||||
:parseargs
|
:parseargs
|
||||||
|
:cmdline
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
import escape from require 'moonbuild._cmd.common'
|
import cmdline from require 'moonbuild._cmd.common'
|
||||||
import flatten from require 'moonbuild._common'
|
import flatten from require 'moonbuild._common'
|
||||||
import execute from require 'moonbuild.compat.execute'
|
import execute from require 'moonbuild.compat.execute'
|
||||||
import popen from io
|
import popen from io
|
||||||
import concat from table
|
import concat from table
|
||||||
|
|
||||||
cmdline = (...) ->
|
|
||||||
concat [escape arg for arg in *flatten ...], ' '
|
|
||||||
|
|
||||||
cmd = (...) ->
|
cmd = (...) ->
|
||||||
ok, ret, code = execute cmdline ...
|
ok, ret, code = execute cmdline ...
|
||||||
error "command #{first ...} exited with #{code} (#{ret})" unless ok
|
error "command #{first ...} exited with #{code} (#{ret})" unless ok
|
||||||
@@ -19,6 +16,7 @@ cmdrst = (...) ->
|
|||||||
data
|
data
|
||||||
|
|
||||||
sh = (cli) ->
|
sh = (cli) ->
|
||||||
|
verbose -> print '[sh] ' .. cli
|
||||||
ok, ret, code = execute cli
|
ok, ret, code = execute cli
|
||||||
error "command '#{cli}' exited with #{code} (#{ret})" unless ok
|
error "command '#{cli}' exited with #{code} (#{ret})" unless ok
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ cmdrst = (...) ->
|
|||||||
data
|
data
|
||||||
|
|
||||||
sh = (cli) ->
|
sh = (cli) ->
|
||||||
|
verbose -> print '[sh] ' .. cli
|
||||||
cmd 'sh', '-c', cli
|
cmd 'sh', '-c', cli
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -147,6 +147,17 @@ minmax = (list) ->
|
|||||||
M = e if e>M
|
M = e if e>M
|
||||||
m, M
|
m, M
|
||||||
|
|
||||||
|
_verbose = false
|
||||||
|
verbose = (arg) ->
|
||||||
|
if arg == nil
|
||||||
|
_verbose
|
||||||
|
elseif (type arg) == 'function'
|
||||||
|
arg! if _verbose
|
||||||
|
elseif (type arg) == 'boolean'
|
||||||
|
_verbose = arg
|
||||||
|
else
|
||||||
|
error "_.verbose takes either no argument, a boolean or a function"
|
||||||
|
|
||||||
common.flatten = flatten
|
common.flatten = flatten
|
||||||
common.first = first
|
common.first = first
|
||||||
common.foreach = foreach
|
common.foreach = foreach
|
||||||
@@ -159,5 +170,6 @@ common.exclude = exclude
|
|||||||
common.min = min
|
common.min = min
|
||||||
common.max = max
|
common.max = max
|
||||||
common.minmax = minmax
|
common.minmax = minmax
|
||||||
|
common.verbose = verbose
|
||||||
|
|
||||||
setmetatable common, __call: => [k for k in pairs common]
|
setmetatable common, __call: => [k for k in pairs common]
|
||||||
|
|||||||
+9
-3
@@ -166,10 +166,16 @@ mkdir = (dir) ->
|
|||||||
clearentry parent dir
|
clearentry parent dir
|
||||||
|
|
||||||
mkdirs = (dir) ->
|
mkdirs = (dir) ->
|
||||||
return if isdir dir
|
if attr = attributes normalizepath dir
|
||||||
error "Can't mkdirs #{dir}: file exists" if exists dir
|
return if attr.mode == 'directory'
|
||||||
|
error "Can't mkdirs #{dir}: file exists"
|
||||||
mkdirs parent dir
|
mkdirs parent dir
|
||||||
mkdir dir
|
unless pcall -> actualmkdir dir
|
||||||
|
clearentry parent dir
|
||||||
|
clearentry dir
|
||||||
|
error "Failed to mkdirs #{dir}: last mkdir failed" unless isdir dir
|
||||||
|
clearentry parent dir
|
||||||
|
clearentry dir
|
||||||
|
|
||||||
-- from the backend
|
-- from the backend
|
||||||
fs = {k, withcache fn for k, fn in pairs fs}
|
fs = {k, withcache fn for k, fn in pairs fs}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import to_lua from require 'moonscript.base'
|
import to_lua from require 'moonscript.base'
|
||||||
import parseargs, cmdrst from require 'moonbuild._cmd'
|
import parseargs, cmdrst from require 'moonbuild._cmd'
|
||||||
|
import verbose from require 'moonbuild._common'
|
||||||
import gmatch, match, gsub from string
|
import gmatch, match, gsub from string
|
||||||
import open from io
|
import open from io
|
||||||
|
|
||||||
@@ -34,6 +35,7 @@ writefile = (filename, data) ->
|
|||||||
nil
|
nil
|
||||||
|
|
||||||
moonc = (infile, outfile) ->
|
moonc = (infile, outfile) ->
|
||||||
|
verbose -> print "[moonc] #{infile} #{outfile}"
|
||||||
code, err = to_lua readfile infile
|
code, err = to_lua readfile infile
|
||||||
error "Failed to compile #{@infile}: #{err}" unless code
|
error "Failed to compile #{@infile}: #{err}" unless code
|
||||||
writefile outfile, code
|
writefile outfile, code
|
||||||
|
|||||||
+30
-8
@@ -56,22 +56,44 @@ class DepGraph
|
|||||||
|
|
||||||
addnode: (name) =>
|
addnode: (name) =>
|
||||||
return if @nodes[name]
|
return if @nodes[name]
|
||||||
elected = @resolvedeps name
|
elected = @topresolvedeps name
|
||||||
@nodes[name] = elected
|
@nodes[name] = elected
|
||||||
for dep in *(transclosure elected, 'deps')
|
for dep in *(transclosure elected, 'deps')
|
||||||
@nodes[dep.name] = dep
|
@nodes[dep.name] = dep
|
||||||
dep.deps = nil
|
dep.deps = nil
|
||||||
elected.deps = nil
|
elected.deps = nil
|
||||||
|
|
||||||
resolvedeps: (name) =>
|
topresolvedeps: (name) =>
|
||||||
|
errors = {}
|
||||||
|
ok, rst = pcall -> @resolvedeps name, nil, errors
|
||||||
|
if ok
|
||||||
|
rst
|
||||||
|
else
|
||||||
|
msg = {"Failed to resolve target \'#{name}\'\n"}
|
||||||
|
for e in *errors
|
||||||
|
if e.err\match '^moonbuild'
|
||||||
|
e.err = e.err\match ': (.+)$'
|
||||||
|
for i=#errors, 1, -1
|
||||||
|
e = errors[i]
|
||||||
|
insert msg, "#{string.rep '| ', e.level - 1}+-[#{e.name}] level #{e.level}: #{e.err}"
|
||||||
|
insert msg, ''
|
||||||
|
error table.concat msg, '\n'
|
||||||
|
|
||||||
|
resolvedeps: (name, level=1, errors={}) =>
|
||||||
do
|
do
|
||||||
node = @nodes[name]
|
node = @nodes[name]
|
||||||
return node, {} if node
|
if node
|
||||||
|
print "deps(#{name}) = #{node.name or '[noname]'}"
|
||||||
|
return node, {}
|
||||||
candidates = filter {@ctx.targets, FileTarget!}, (target) -> target\matches name
|
candidates = filter {@ctx.targets, FileTarget!}, (target) -> target\matches name
|
||||||
nodes = foreach candidates, (candidate) -> a: {pcall -> DepNode @, candidate, name}
|
nodes = foreach candidates, (candidate) -> a: {pcall -> DepNode @, candidate, name, level, errors}
|
||||||
resolved = foreach (filter nodes, (node) -> node.a[1]), (node) -> node.a[2]
|
resolved = foreach (filter nodes, (node) -> node.a[1]), (node) -> node.a[2]
|
||||||
sort resolved, nodepriority
|
sort resolved, nodepriority
|
||||||
resolved[1] or error "Cannot resolve target #{name}: #{#candidates} candidates, #{#resolved} resolved"
|
unless resolved[1]
|
||||||
|
err = "Cannot resolve target #{name}: #{#candidates} candidates, #{#resolved} resolved"
|
||||||
|
table.insert errors, {:name, :level, :err}
|
||||||
|
error err
|
||||||
|
resolved[1]
|
||||||
|
|
||||||
buildablenodes: =>
|
buildablenodes: =>
|
||||||
[v for k, v in pairs @nodes when v\canbuild! and not v.built]
|
[v for k, v in pairs @nodes when v\canbuild! and not v.built]
|
||||||
@@ -91,7 +113,7 @@ class DepGraph
|
|||||||
insert stack, n for n in *(node\children!)
|
insert stack, n for n in *(node\children!)
|
||||||
|
|
||||||
class DepNode
|
class DepNode
|
||||||
new: (@dag, target, @name) =>
|
new: (@dag, target, @name, @level, errors) =>
|
||||||
@priority = target.priority
|
@priority = target.priority
|
||||||
@buildfunctions = target.buildfunctions
|
@buildfunctions = target.buildfunctions
|
||||||
@mkdirs = target._mkdirs
|
@mkdirs = target._mkdirs
|
||||||
@@ -101,7 +123,7 @@ class DepNode
|
|||||||
@type = 'virtual' if #@outs == 0
|
@type = 'virtual' if #@outs == 0
|
||||||
@built = false
|
@built = false
|
||||||
|
|
||||||
resolve = (name) -> @dag\resolvedeps patsubst @name, target.pattern, name
|
resolve = (name) -> @dag\resolvedeps (patsubst @name, target.pattern, name), level + 1, errors
|
||||||
after = flatten foreach target.needtargets, resolve
|
after = flatten foreach target.needtargets, resolve
|
||||||
deps = flatten foreach target.infiles, resolve
|
deps = flatten foreach target.infiles, resolve
|
||||||
if #target.depfunctions!=0
|
if #target.depfunctions!=0
|
||||||
@@ -149,7 +171,7 @@ class DepNode
|
|||||||
|
|
||||||
return false if @built or #@buildfunctions == 0
|
return false if @built or #@buildfunctions == 0
|
||||||
return false unless force or @shouldbuild!
|
return false unless force or @shouldbuild!
|
||||||
print "#{@type == 'virtual' and "Running" or "Building"} #{@name}" unless quiet
|
print "#{@type == 'virtual' and "Running" or "Building"} #{@name} [level #{@level}]" unless quiet
|
||||||
@actuallybuild!
|
@actuallybuild!
|
||||||
true
|
true
|
||||||
|
|
||||||
|
|||||||
+10
-5
@@ -33,22 +33,27 @@ moonbuild = (...) ->
|
|||||||
verbose = opts.verbose or opts.v or false
|
verbose = opts.verbose or opts.v or false
|
||||||
opts.verbose = verbose
|
opts.verbose = verbose
|
||||||
|
|
||||||
|
-- set verbosity level
|
||||||
|
_.verbose verbose
|
||||||
|
|
||||||
-- create context and DAG
|
-- create context and DAG
|
||||||
ctx = Context!
|
ctx = Context!
|
||||||
ctx\load (loadfile buildfile), opts
|
ctx\load (loadfile buildfile), opts
|
||||||
print "Loaded buildfile" if verbose
|
_.verbose -> print "Loaded buildfile"
|
||||||
ctx\init!
|
ctx\init!
|
||||||
print "Initialized buildfile" if verbose
|
_.verbose -> print "Initialized buildfile"
|
||||||
targets = #opts==0 and ctx.defaulttargets or opts
|
targets = #opts==0 and ctx.defaulttargets or opts
|
||||||
dag = DepGraph ctx, targets
|
dag = DepGraph ctx, targets
|
||||||
print "Created dependancy graph" if verbose
|
_.verbose -> print "Created dependancy graph"
|
||||||
|
|
||||||
-- and build
|
-- and build
|
||||||
nparallel = parallel == true and Executor\getmaxparallel! or parallel
|
nparallel = parallel == true and Executor\getmaxparallel! or parallel
|
||||||
print "Building with #{nparallel} max parallel process#{nparallel>1 and "es" or ""}" if verbose
|
_.verbose -> print "Building with #{nparallel} max parallel process#{nparallel>1 and "es" or ""}"
|
||||||
executor = Executor dag, nparallel
|
executor = Executor dag, nparallel
|
||||||
executor\execute opts
|
executor\execute opts
|
||||||
print "Finished" if verbose
|
_.verbose -> print "Finished"
|
||||||
|
|
||||||
|
print _.verbose!
|
||||||
|
|
||||||
table = {
|
table = {
|
||||||
:moonbuild, :_
|
:moonbuild, :_
|
||||||
|
|||||||
Generated
+160
-54
@@ -1,5 +1,3 @@
|
|||||||
do
|
|
||||||
|
|
||||||
do
|
do
|
||||||
local _ENV = _ENV
|
local _ENV = _ENV
|
||||||
package.preload[ "moonbuild._" ] = function( ... ) local arg = _G.arg;
|
package.preload[ "moonbuild._" ] = function( ... ) local arg = _G.arg;
|
||||||
@@ -38,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()
|
||||||
@@ -69,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)
|
||||||
@@ -101,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 = {
|
||||||
['\"'] = '\\\"',
|
['\"'] = '\\\"',
|
||||||
['\\'] = '\\\\',
|
['\\'] = '\\\\',
|
||||||
@@ -232,26 +256,6 @@ parseargs = function(argstr)
|
|||||||
end
|
end
|
||||||
return args
|
return args
|
||||||
end
|
end
|
||||||
return {
|
|
||||||
escape = escape,
|
|
||||||
parseargs = parseargs
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
do
|
|
||||||
local _ENV = _ENV
|
|
||||||
package.preload[ "moonbuild._cmd.lua" ] = function( ... ) local arg = _G.arg;
|
|
||||||
local escape
|
|
||||||
escape = require('moonbuild._cmd.common').escape
|
|
||||||
local flatten
|
|
||||||
flatten = require('moonbuild._common').flatten
|
|
||||||
local execute
|
|
||||||
execute = require('moonbuild.compat.execute').execute
|
|
||||||
local popen
|
|
||||||
popen = io.popen
|
|
||||||
local concat
|
|
||||||
concat = table.concat
|
|
||||||
local cmdline
|
local cmdline
|
||||||
cmdline = function(...)
|
cmdline = function(...)
|
||||||
return concat((function(...)
|
return concat((function(...)
|
||||||
@@ -266,6 +270,27 @@ cmdline = function(...)
|
|||||||
return _accum_0
|
return _accum_0
|
||||||
end)(...), ' ')
|
end)(...), ' ')
|
||||||
end
|
end
|
||||||
|
return {
|
||||||
|
escape = escape,
|
||||||
|
parseargs = parseargs,
|
||||||
|
cmdline = cmdline
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
do
|
||||||
|
local _ENV = _ENV
|
||||||
|
package.preload[ "moonbuild._cmd.lua" ] = function( ... ) local arg = _G.arg;
|
||||||
|
local cmdline
|
||||||
|
cmdline = require('moonbuild._cmd.common').cmdline
|
||||||
|
local flatten
|
||||||
|
flatten = require('moonbuild._common').flatten
|
||||||
|
local execute
|
||||||
|
execute = require('moonbuild.compat.execute').execute
|
||||||
|
local popen
|
||||||
|
popen = io.popen
|
||||||
|
local concat
|
||||||
|
concat = table.concat
|
||||||
local cmd
|
local cmd
|
||||||
cmd = function(...)
|
cmd = function(...)
|
||||||
local ok, ret, code = execute(cmdline(...))
|
local ok, ret, code = execute(cmdline(...))
|
||||||
@@ -285,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) .. ")")
|
||||||
@@ -356,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 {
|
||||||
@@ -637,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
|
||||||
@@ -649,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 = { }
|
||||||
@@ -973,14 +1020,27 @@ mkdir = function(dir)
|
|||||||
end
|
end
|
||||||
local mkdirs
|
local mkdirs
|
||||||
mkdirs = function(dir)
|
mkdirs = function(dir)
|
||||||
if isdir(dir) then
|
do
|
||||||
return
|
local attr = attributes(normalizepath(dir))
|
||||||
end
|
if attr then
|
||||||
if exists(dir) then
|
if attr.mode == 'directory' then
|
||||||
error("Can't mkdirs " .. tostring(dir) .. ": file exists")
|
return
|
||||||
|
end
|
||||||
|
error("Can't mkdirs " .. tostring(dir) .. ": file exists")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
mkdirs(parent(dir))
|
mkdirs(parent(dir))
|
||||||
return mkdir(dir)
|
if not (pcall(function()
|
||||||
|
return actualmkdir(dir)
|
||||||
|
end)) then
|
||||||
|
clearentry(parent(dir))
|
||||||
|
clearentry(dir)
|
||||||
|
if not (isdir(dir)) then
|
||||||
|
error("Failed to mkdirs " .. tostring(dir) .. ": last mkdir failed")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
clearentry(parent(dir))
|
||||||
|
return clearentry(dir)
|
||||||
end
|
end
|
||||||
do
|
do
|
||||||
local _tbl_0 = { }
|
local _tbl_0 = { }
|
||||||
@@ -1249,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
|
||||||
@@ -1320,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))
|
||||||
@@ -1737,7 +1802,7 @@ do
|
|||||||
if self.nodes[name] then
|
if self.nodes[name] then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local elected = self:resolvedeps(name)
|
local elected = self:topresolvedeps(name)
|
||||||
self.nodes[name] = elected
|
self.nodes[name] = elected
|
||||||
local _list_0 = (transclosure(elected, 'deps'))
|
local _list_0 = (transclosure(elected, 'deps'))
|
||||||
for _index_0 = 1, #_list_0 do
|
for _index_0 = 1, #_list_0 do
|
||||||
@@ -1747,10 +1812,42 @@ do
|
|||||||
end
|
end
|
||||||
elected.deps = nil
|
elected.deps = nil
|
||||||
end,
|
end,
|
||||||
resolvedeps = function(self, name)
|
topresolvedeps = function(self, name)
|
||||||
|
local errors = { }
|
||||||
|
local ok, rst = pcall(function()
|
||||||
|
return self:resolvedeps(name, nil, errors)
|
||||||
|
end)
|
||||||
|
if ok then
|
||||||
|
return rst
|
||||||
|
else
|
||||||
|
local msg = {
|
||||||
|
"Failed to resolve target \'" .. tostring(name) .. "\'\n"
|
||||||
|
}
|
||||||
|
for _index_0 = 1, #errors do
|
||||||
|
local e = errors[_index_0]
|
||||||
|
if e.err:match('^moonbuild') then
|
||||||
|
e.err = e.err:match(': (.+)$')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for i = #errors, 1, -1 do
|
||||||
|
local e = errors[i]
|
||||||
|
insert(msg, tostring(string.rep('| ', e.level - 1)) .. "+-[" .. tostring(e.name) .. "] level " .. tostring(e.level) .. ": " .. tostring(e.err))
|
||||||
|
end
|
||||||
|
insert(msg, '')
|
||||||
|
return error(table.concat(msg, '\n'))
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
resolvedeps = function(self, name, level, errors)
|
||||||
|
if level == nil then
|
||||||
|
level = 1
|
||||||
|
end
|
||||||
|
if errors == nil then
|
||||||
|
errors = { }
|
||||||
|
end
|
||||||
do
|
do
|
||||||
local node = self.nodes[name]
|
local node = self.nodes[name]
|
||||||
if node then
|
if node then
|
||||||
|
print("deps(" .. tostring(name) .. ") = " .. tostring(node.name or '[noname]'))
|
||||||
return node, { }
|
return node, { }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1764,7 +1861,7 @@ do
|
|||||||
return {
|
return {
|
||||||
a = {
|
a = {
|
||||||
pcall(function()
|
pcall(function()
|
||||||
return DepNode(self, candidate, name)
|
return DepNode(self, candidate, name, level, errors)
|
||||||
end)
|
end)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1775,7 +1872,16 @@ do
|
|||||||
return node.a[2]
|
return node.a[2]
|
||||||
end)
|
end)
|
||||||
sort(resolved, nodepriority)
|
sort(resolved, nodepriority)
|
||||||
return resolved[1] or error("Cannot resolve target " .. tostring(name) .. ": " .. tostring(#candidates) .. " candidates, " .. tostring(#resolved) .. " resolved")
|
if not (resolved[1]) then
|
||||||
|
local err = "Cannot resolve target " .. tostring(name) .. ": " .. tostring(#candidates) .. " candidates, " .. tostring(#resolved) .. " resolved"
|
||||||
|
table.insert(errors, {
|
||||||
|
name = name,
|
||||||
|
level = level,
|
||||||
|
err = err
|
||||||
|
})
|
||||||
|
error(err)
|
||||||
|
end
|
||||||
|
return resolved[1]
|
||||||
end,
|
end,
|
||||||
buildablenodes = function(self)
|
buildablenodes = function(self)
|
||||||
local _accum_0 = { }
|
local _accum_0 = { }
|
||||||
@@ -1904,7 +2010,7 @@ do
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
if not (quiet) then
|
if not (quiet) then
|
||||||
print(tostring(self.type == 'virtual' and "Running" or "Building") .. " " .. tostring(self.name))
|
print(tostring(self.type == 'virtual' and "Running" or "Building") .. " " .. tostring(self.name) .. " [level " .. tostring(self.level) .. "]")
|
||||||
end
|
end
|
||||||
self:actuallybuild()
|
self:actuallybuild()
|
||||||
return true
|
return true
|
||||||
@@ -1986,8 +2092,8 @@ do
|
|||||||
}
|
}
|
||||||
_base_0.__index = _base_0
|
_base_0.__index = _base_0
|
||||||
_class_0 = setmetatable({
|
_class_0 = setmetatable({
|
||||||
__init = function(self, dag, target, name)
|
__init = function(self, dag, target, name, level, errors)
|
||||||
self.dag, self.name = dag, name
|
self.dag, self.name, self.level = dag, name, level
|
||||||
self.priority = target.priority
|
self.priority = target.priority
|
||||||
self.buildfunctions = target.buildfunctions
|
self.buildfunctions = target.buildfunctions
|
||||||
self.mkdirs = target._mkdirs
|
self.mkdirs = target._mkdirs
|
||||||
@@ -2002,7 +2108,7 @@ do
|
|||||||
self.built = false
|
self.built = false
|
||||||
local resolve
|
local resolve
|
||||||
resolve = function(name)
|
resolve = function(name)
|
||||||
return self.dag:resolvedeps(patsubst(self.name, target.pattern, name))
|
return self.dag:resolvedeps((patsubst(self.name, target.pattern, name)), level + 1, errors)
|
||||||
end
|
end
|
||||||
local after = flatten(foreach(target.needtargets, resolve))
|
local after = flatten(foreach(target.needtargets, resolve))
|
||||||
local deps = flatten(foreach(target.infiles, resolve))
|
local deps = flatten(foreach(target.infiles, resolve))
|
||||||
@@ -2737,8 +2843,6 @@ end
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
local loadfile
|
local loadfile
|
||||||
loadfile = require('moonscript.base').loadfile
|
loadfile = require('moonscript.base').loadfile
|
||||||
local Context = require('moonbuild.context')
|
local Context = require('moonbuild.context')
|
||||||
@@ -2780,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,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package: moonbuild
|
package: moonbuild
|
||||||
source:
|
source:
|
||||||
url: git://github.com/natnat-mc/moonbuild
|
url: git+http://github.com/natnat-mc/moonbuild
|
||||||
description:
|
description:
|
||||||
summary: Small build system in between make and a build.sh
|
summary: Small build system in between make and a build.sh
|
||||||
detailed: >
|
detailed: >
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
build = {
|
||||||
|
install = {
|
||||||
|
bin = {
|
||||||
|
moonbuild = "out/moonbuild"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
modules = {
|
||||||
|
moonbuild = "out/moonbuild.lua"
|
||||||
|
},
|
||||||
|
type = "builtin"
|
||||||
|
}
|
||||||
|
dependencies = {
|
||||||
|
"lua >= 5.1",
|
||||||
|
"argparse >= 0.7.1-1",
|
||||||
|
"moonscript >= 0.5.0-1"
|
||||||
|
}
|
||||||
|
description = {
|
||||||
|
detailed = "moonbuild is a small build system that simplifies your build definitions by allowing you to use declarative as well as imperative rules. It represents the build as a DAG with explicit ordering, and doesn't give you any default confusing rules (unlike make). If you can, installing luaposix and/or luafilesystem will speed up builds and increase stability.\n",
|
||||||
|
summary = "Small build system in between make and a build.sh"
|
||||||
|
}
|
||||||
|
package = "moonbuild"
|
||||||
|
rockspec_format = "3.0"
|
||||||
|
source = {
|
||||||
|
tag = "v2.5.0",
|
||||||
|
url = "git://github.com/natnat-mc/moonbuild"
|
||||||
|
}
|
||||||
|
version = "2.5.0-1"
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
build = {
|
||||||
|
install = {
|
||||||
|
bin = {
|
||||||
|
moonbuild = "out/moonbuild"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
modules = {
|
||||||
|
moonbuild = "out/moonbuild.lua"
|
||||||
|
},
|
||||||
|
type = "builtin"
|
||||||
|
}
|
||||||
|
dependencies = {
|
||||||
|
"lua >= 5.1",
|
||||||
|
"argparse >= 0.7.1-1",
|
||||||
|
"moonscript >= 0.5.0-1"
|
||||||
|
}
|
||||||
|
description = {
|
||||||
|
detailed = "moonbuild is a small build system that simplifies your build definitions by allowing you to use declarative as well as imperative rules. It represents the build as a DAG with explicit ordering, and doesn't give you any default confusing rules (unlike make). If you can, installing luaposix and/or luafilesystem will speed up builds and increase stability.\n",
|
||||||
|
summary = "Small build system in between make and a build.sh"
|
||||||
|
}
|
||||||
|
package = "moonbuild"
|
||||||
|
rockspec_format = "3.0"
|
||||||
|
source = {
|
||||||
|
tag = "v2.5.1",
|
||||||
|
url = "git://github.com/natnat-mc/moonbuild"
|
||||||
|
}
|
||||||
|
version = "2.5.1-1"
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
build = {
|
||||||
|
install = {
|
||||||
|
bin = {
|
||||||
|
moonbuild = "out/moonbuild"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
modules = {
|
||||||
|
moonbuild = "out/moonbuild.lua"
|
||||||
|
},
|
||||||
|
type = "builtin"
|
||||||
|
}
|
||||||
|
dependencies = {
|
||||||
|
"lua >= 5.1",
|
||||||
|
"argparse >= 0.7.1-1",
|
||||||
|
"moonscript >= 0.5.0-1"
|
||||||
|
}
|
||||||
|
description = {
|
||||||
|
detailed = "moonbuild is a small build system that simplifies your build definitions by allowing you to use declarative as well as imperative rules. It represents the build as a DAG with explicit ordering, and doesn't give you any default confusing rules (unlike make). If you can, installing luaposix and/or luafilesystem will speed up builds and increase stability.\n",
|
||||||
|
summary = "Small build system in between make and a build.sh"
|
||||||
|
}
|
||||||
|
package = "moonbuild"
|
||||||
|
rockspec_format = "3.0"
|
||||||
|
source = {
|
||||||
|
tag = "v2.6.0",
|
||||||
|
url = "git+http://github.com/natnat-mc/moonbuild"
|
||||||
|
}
|
||||||
|
version = "2.6.0-1"
|
||||||
Reference in New Issue
Block a user