mirror of
https://github.com/natnat-mc/moonbuild
synced 2026-05-28 09:39:40 +02:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d22335d569 |
+1
-3
@@ -1,3 +1 @@
|
|||||||
bin/*.lua
|
*.lua
|
||||||
moonbuild/*.lua
|
|
||||||
moonbuild/*/*.lua
|
|
||||||
|
|||||||
+3
-8
@@ -1,13 +1,8 @@
|
|||||||
tasks:
|
tasks:
|
||||||
bootstrap: => sh "moon bin/moonbuild.moon -jy"
|
build: =>
|
||||||
bootstrapinstall: => sh "moon bin/moonbuild.moon install -jy"
|
load 'moonbuild'
|
||||||
|
tasks.moonbuild j: true
|
||||||
release: =>
|
release: =>
|
||||||
error "no version provided" unless @v
|
error "no version provided" unless @v
|
||||||
tasks.build!
|
tasks.build!
|
||||||
sh "rockbuild -m -t #{@v} upload"
|
sh "rockbuild -m -t #{@v} upload"
|
||||||
|
|
||||||
build: => (require 'moonbuild') j: true
|
|
||||||
install: => (require 'moonbuild') 'install', j: true
|
|
||||||
clean: => (require 'moonbuild') 'clean'
|
|
||||||
mrproper: => (require 'moonbuild') 'mrproper'
|
|
||||||
|
|||||||
+3
-24
@@ -16,22 +16,6 @@ with public default target 'all'
|
|||||||
\after 'bin'
|
\after 'bin'
|
||||||
\after 'lib'
|
\after 'lib'
|
||||||
|
|
||||||
with public target 'install'
|
|
||||||
\after 'install-bin'
|
|
||||||
\after 'install-lib'
|
|
||||||
|
|
||||||
with public target 'install-bin'
|
|
||||||
\depends 'out/moonbuild'
|
|
||||||
\produces '/usr/local/bin/moonbuild'
|
|
||||||
\fn => _.cmd 'sudo', 'cp', @infile, @outfile
|
|
||||||
\sync!
|
|
||||||
|
|
||||||
with public target 'install-lib'
|
|
||||||
\depends 'out/moonbuild.lua'
|
|
||||||
\produces "/usr/local/share/lua/#{LUA\gsub 'lua', ''}/moonbuild.lua"
|
|
||||||
\fn => _.cmd 'sudo', 'cp', @infile, @outfile
|
|
||||||
\sync!
|
|
||||||
|
|
||||||
with public target 'clean'
|
with public target 'clean'
|
||||||
\fn => _.cmd RM, LIB_LUA
|
\fn => _.cmd RM, LIB_LUA
|
||||||
\fn => _.cmd RM, BIN_LUA
|
\fn => _.cmd RM, BIN_LUA
|
||||||
@@ -48,19 +32,14 @@ with public target 'lib'
|
|||||||
|
|
||||||
with target BIN, pattern: 'out/%'
|
with target BIN, pattern: 'out/%'
|
||||||
\depends 'bin/%.lua'
|
\depends 'bin/%.lua'
|
||||||
|
\depends LIB_LUA
|
||||||
\produces 'out/%'
|
\produces 'out/%'
|
||||||
\mkdirs!
|
\mkdirs!
|
||||||
\fn =>
|
\fn =>
|
||||||
_.writefile @outfile, "#!/usr/bin/env #{LUA}\n#{_.readfile @infile}"
|
_.cmd AMALG, '-o', @outfile, '-s', @infile, MODULES
|
||||||
|
_.writefile @outfile, "#!/usr/bin/env #{LUA}\n#{_.readfile @outfile}"
|
||||||
_.cmd 'chmod', '+x', @outfile
|
_.cmd 'chmod', '+x', @outfile
|
||||||
|
|
||||||
with target 'out/moonbuild.lua'
|
|
||||||
\depends 'moonbuild/init.lua'
|
|
||||||
\depends LIB_LUA
|
|
||||||
\produces '%'
|
|
||||||
\fn =>
|
|
||||||
_.cmd AMALG, '-o', @outfile, '-s', @infile, _.exclude MODULES, 'moonbuild.init'
|
|
||||||
|
|
||||||
with target {LIB_LUA, BIN_LUA}, pattern: '%.lua'
|
with target {LIB_LUA, BIN_LUA}, pattern: '%.lua'
|
||||||
\depends '%.moon'
|
\depends '%.moon'
|
||||||
\produces '%.lua'
|
\produces '%.lua'
|
||||||
|
|||||||
@@ -16,9 +16,6 @@ MODULES = $(shell echo $(foreach lib, $(LIB_LUA), $(patsubst %.lua, %, $(lib)))
|
|||||||
|
|
||||||
all: bin lib
|
all: bin lib
|
||||||
|
|
||||||
install: all
|
|
||||||
sudo cp out/moonbuild /usr/local/bin/moonbuild
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) $(LIB_LUA)
|
$(RM) $(LIB_LUA)
|
||||||
$(RM) $(BIN_LUA)
|
$(RM) $(BIN_LUA)
|
||||||
|
|||||||
@@ -24,8 +24,11 @@ You will need `argparse` and `moonscript` installed from luarocks, and `luaposix
|
|||||||
|
|
||||||
### Bootstrapping
|
### Bootstrapping
|
||||||
You can build moonbuild with itself: `moon bin/moonbuild.moon -qjy`.
|
You can build moonbuild with itself: `moon bin/moonbuild.moon -qjy`.
|
||||||
This will leave the binary ready to be used as `out/moonbuild` (it will still depend on the library to be used).
|
This will leave the binary ready to be used as `out/moonbuild`.
|
||||||
The binary and library can then be installed with `bin/moonbuild install`.
|
|
||||||
|
### Using make
|
||||||
|
You can also build moonbuild with make: `make`.
|
||||||
|
This will leave the binary ready to be used as `out/moonbuild`.
|
||||||
|
|
||||||
## Docs
|
## Docs
|
||||||
TODO
|
TODO
|
||||||
|
|||||||
+16
-8
@@ -1,13 +1,14 @@
|
|||||||
-- load everything we need
|
-- load everything we need
|
||||||
import loadfile from require 'moonscript.base'
|
import loadfile from require 'moonscript.base'
|
||||||
import Context, DepGraph, Executor from require 'moonbuild'
|
Context = require 'moonbuild.context'
|
||||||
Variable = (require 'moonbuild')['core.Variable']
|
Variable = require 'moonbuild.core.Variable'
|
||||||
import parseargs from (require 'moonbuild')['_cmd.common']
|
DepGraph = require 'moonbuild.core.DAG'
|
||||||
argparse = require 'argparse'
|
import parseargs from require 'moonbuild._cmd.common'
|
||||||
import sort, concat from table
|
import sort, concat from table
|
||||||
import exit from os
|
import exit from os
|
||||||
|
|
||||||
-- parse the arguments
|
-- parse the arguments
|
||||||
|
argparse = require 'argparse'
|
||||||
parser = with argparse "moonbuild", "A build system in moonscript"
|
parser = with argparse "moonbuild", "A build system in moonscript"
|
||||||
\option '-b --buildfile', "Build file to use", 'Build.moon'
|
\option '-b --buildfile', "Build file to use", 'Build.moon'
|
||||||
\option '-j --parallel', "Sets the number of parallel tasks, 'y' to run as many as we have cores", '1'
|
\option '-j --parallel', "Sets the number of parallel tasks, 'y' to run as many as we have cores", '1'
|
||||||
@@ -73,8 +74,15 @@ dag = DepGraph ctx, targets
|
|||||||
print "Created dependancy graph" if args.verbose
|
print "Created dependancy graph" if args.verbose
|
||||||
|
|
||||||
-- execute the build
|
-- execute the build
|
||||||
nparallel = args.parallel == 'y' and Executor\getmaxparallel! or args.parallel
|
if args.parallel==1
|
||||||
print "Building with #{nparallel} max parallel process#{nparallel>1 and "es" or ""}" if args.verbose
|
Executor = require 'moonbuild.core.singleprocessexecutor'
|
||||||
executor = Executor dag, nparallel
|
executor = Executor dag, args.parallel
|
||||||
executor\execute args
|
executor\execute args
|
||||||
|
else
|
||||||
|
ok, Executor = pcall -> require 'moonbuild.core.multiprocessexecutor'
|
||||||
|
Executor = require 'moonbuild.core.singleprocessexecutor' unless ok
|
||||||
|
nparallel = args.parallel == 'y' and Executor\getmaxparallel! or args.parallel
|
||||||
|
print "Building with #{nparallel} max parallel process#{nparallel>1 and "es" or ""}" if args.verbose
|
||||||
|
executor = Executor dag, nparallel
|
||||||
|
executor\execute args
|
||||||
print "Finished" if args.verbose
|
print "Finished" if args.verbose
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
-- load everything we need
|
||||||
|
import loadfile from require 'moonscript.base'
|
||||||
|
Context = require 'moonbuild.context'
|
||||||
|
DepGraph = require 'moonbuild.core.DAG'
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
moonbuild: =>
|
||||||
|
args = {
|
||||||
|
nparallel: @parallel or @j
|
||||||
|
quiet: @quiet or @q
|
||||||
|
buildfile: @buildfile or @b
|
||||||
|
force: @force or @f
|
||||||
|
}
|
||||||
|
ctx = Context!
|
||||||
|
ctx\load (loadfile args.buildfile or 'Build.moon'), @
|
||||||
|
ctx\init!
|
||||||
|
dag = DepGraph ctx, #@ == 0 and ctx.defaulttargets or @
|
||||||
|
executor = do
|
||||||
|
Executor = do
|
||||||
|
ok, Executor = pcall -> require 'moonbuild.core.multiprocessexecutor'
|
||||||
|
ok and Executor or require 'moonbuild.core.singleprocessexecutor'
|
||||||
|
args.nparallel = Executor\getmaxparallel! if args.nparallel == true
|
||||||
|
Executor dag, args.nparallel
|
||||||
|
executor\execute args
|
||||||
@@ -155,7 +155,6 @@ common.includes = includes
|
|||||||
common.patget = patget
|
common.patget = patget
|
||||||
common.patset = patset
|
common.patset = patset
|
||||||
common.patsubst = patsubst
|
common.patsubst = patsubst
|
||||||
common.exclude = exclude
|
|
||||||
common.min = min
|
common.min = min
|
||||||
common.max = max
|
common.max = max
|
||||||
common.minmax = minmax
|
common.minmax = minmax
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ _cdeps = (cc, cflags, path) ->
|
|||||||
rawlist = gsub (match raw, ':(.+)'), '\\\n', ' '
|
rawlist = gsub (match raw, ':(.+)'), '\\\n', ' '
|
||||||
[v for v in gmatch rawlist, '%S+']
|
[v for v in gmatch rawlist, '%S+']
|
||||||
cdeps = setmetatable {},
|
cdeps = setmetatable {},
|
||||||
__index: (cc) => (path, cflags) -> _cdeps cc, cflags, path
|
__index: (cc) => (cflags, path) -> _cdeps cc, cflags, path
|
||||||
__call: (path, cflags) => _cdeps 'cc', cflags, path
|
__call: (cflags, path) => _cdeps 'cc', cflags, path
|
||||||
|
|
||||||
readfile = (filename) ->
|
readfile = (filename) ->
|
||||||
fd, err = open filename, 'rb'
|
fd, err = open filename, 'rb'
|
||||||
|
|||||||
+14
-47
@@ -1,8 +1,8 @@
|
|||||||
import first, filter, foreach, flatten, patsubst, includes from require 'moonbuild._common'
|
import filter, foreach, flatten, patsubst from require 'moonbuild._common'
|
||||||
import runwithcontext from require 'moonbuild.compat.ctx'
|
import runwithcontext from require 'moonbuild.compat.ctx'
|
||||||
globalenv = require 'moonbuild.env.global'
|
globalenv = require 'moonbuild.env.global'
|
||||||
import exists, parent, mkdirs, clearentry, disableentry, attributes from require 'moonbuild._fs'
|
import exists, parent, mkdirs, clearentry, disableentry, attributes from require 'moonbuild._fs'
|
||||||
import sort, insert, remove from table
|
import sort from table
|
||||||
import huge from math
|
import huge from math
|
||||||
|
|
||||||
local DepNode, FileTarget
|
local DepNode, FileTarget
|
||||||
@@ -12,8 +12,6 @@ nodepriority = (a, b) ->
|
|||||||
tb = type b.name
|
tb = type b.name
|
||||||
da = #a.deps
|
da = #a.deps
|
||||||
db = #b.deps
|
db = #b.deps
|
||||||
sa = a.sync
|
|
||||||
sb = b.sync
|
|
||||||
if ta=='string' and tb!='string'
|
if ta=='string' and tb!='string'
|
||||||
return true
|
return true
|
||||||
elseif ta!='string' and tb=='string'
|
elseif ta!='string' and tb=='string'
|
||||||
@@ -22,10 +20,6 @@ nodepriority = (a, b) ->
|
|||||||
return true
|
return true
|
||||||
elseif a.priority < b.priority
|
elseif a.priority < b.priority
|
||||||
return false
|
return false
|
||||||
elseif sa and not sb
|
|
||||||
return false
|
|
||||||
elseif sb and not sa
|
|
||||||
return true
|
|
||||||
else
|
else
|
||||||
return da < db
|
return da < db
|
||||||
|
|
||||||
@@ -34,7 +28,6 @@ transclosure = (obj, prop) ->
|
|||||||
i = 1
|
i = 1
|
||||||
set = {}
|
set = {}
|
||||||
imp = (e) ->
|
imp = (e) ->
|
||||||
return unless e[prop]
|
|
||||||
for v in *e[prop]
|
for v in *e[prop]
|
||||||
if not set[v]
|
if not set[v]
|
||||||
elems[i], i = v, i+1
|
elems[i], i = v, i+1
|
||||||
@@ -71,25 +64,11 @@ class DepGraph
|
|||||||
nodes = foreach candidates, (candidate) -> a: {pcall -> DepNode @, candidate, name}
|
nodes = foreach candidates, (candidate) -> a: {pcall -> DepNode @, candidate, name}
|
||||||
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"
|
resolved[1] or error "Cannot resolve target #{name}"
|
||||||
|
|
||||||
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]
|
||||||
|
|
||||||
reset: =>
|
|
||||||
n.built = false for k, n in pairs @nodes
|
|
||||||
|
|
||||||
resetchildren: (names) =>
|
|
||||||
done = {}
|
|
||||||
stack = [v for v in *names]
|
|
||||||
while #stack != 0
|
|
||||||
name = remove stack
|
|
||||||
continue if done[name]
|
|
||||||
done[name] = true
|
|
||||||
node = @nodes[name]
|
|
||||||
node.built = false
|
|
||||||
insert stack, n for n in *(node\children!)
|
|
||||||
|
|
||||||
class DepNode
|
class DepNode
|
||||||
new: (@dag, target, @name) =>
|
new: (@dag, target, @name) =>
|
||||||
@priority = target.priority
|
@priority = target.priority
|
||||||
@@ -108,50 +87,38 @@ class DepNode
|
|||||||
ctx = setmetatable {},
|
ctx = setmetatable {},
|
||||||
__index: (_, k) ->
|
__index: (_, k) ->
|
||||||
switch k
|
switch k
|
||||||
when 'infile'
|
when 'infile' then first deps
|
||||||
f = first deps
|
when 'infiles' then flatten deps
|
||||||
f and f.name
|
when 'outfile' then first @outs
|
||||||
when 'infiles'
|
when 'outfiles' then flatten @outs
|
||||||
foreach deps, => @name
|
when 'name' then @name
|
||||||
when 'outfile'
|
else error "No such field in TargetDepsContext: #{k}"
|
||||||
f = first @outs
|
|
||||||
f and f.name
|
|
||||||
when 'outfiles'
|
|
||||||
foreach @outs, => @name
|
|
||||||
when 'name'
|
|
||||||
@name
|
|
||||||
else
|
|
||||||
error "No such field in TargetDepsContext: #{k}"
|
|
||||||
__newindex: (k) =>
|
__newindex: (k) =>
|
||||||
error "Attempt to set field #{k} of TargetDepsContext"
|
error "Attempt to set field #{k} of TargetDepsContext"
|
||||||
for depfn in *target.depfunctions
|
for depfn in *target.depfunctions
|
||||||
deps = flatten deps, foreach (runwithcontext depfn, @dag.env, ctx), resolve
|
deps = flatten deps, foreach depfn, (fn) -> resolve runwithcontext fn, @dag.env, ctx
|
||||||
@ins = foreach deps, (dep) -> dep.name
|
@ins = foreach deps, (dep) -> dep.name
|
||||||
@after = foreach after, (dep) -> dep.name
|
@after = foreach after, (dep) -> dep.name
|
||||||
@deps = flatten { deps, after }
|
@deps = flatten { deps, after }
|
||||||
@built = true if #@deps == 0 and #@buildfunctions == 0
|
@built = true if #@deps == 0 and #@buildfunctions == 0
|
||||||
|
|
||||||
children: =>
|
|
||||||
[k for k, n in pairs @dag.nodes when (includes n.ins, @name) or (includes n.after, @name)]
|
|
||||||
|
|
||||||
canbuild: =>
|
canbuild: =>
|
||||||
for node in *flatten { @ins, @after }
|
for node in *flatten { @ins, @after }
|
||||||
if not @dag.nodes[node].built
|
if not @dag.nodes[node].built
|
||||||
return false
|
return false
|
||||||
for file in *@ins
|
for file in *@ins
|
||||||
if not exists file
|
if not exists file
|
||||||
error "Node #{@name} has ran all of its parents, but can't run since #{file} doesn't exist. Did you mean to use after instead of depends?"
|
error "Node #{name} has ran all of its parents, but can't run since #{file} doesn't exist"
|
||||||
return true
|
return true
|
||||||
|
|
||||||
build: (opts={}) =>
|
build: (opts={}) =>
|
||||||
force = opts.force or false
|
force = opts.force or false
|
||||||
quiet = opts.quiet or false
|
quiet = opts.quiet or false
|
||||||
|
|
||||||
return false if @built or #@buildfunctions == 0
|
return if @built
|
||||||
return false unless force or @shouldbuild!
|
return unless force or @shouldbuild!
|
||||||
print "#{@type == 'virtual' and "Running" or "Building"} #{@name}" unless quiet
|
print "#{@type == 'virtual' and "Running" or "Building"} #{@name}" unless quiet or #@buildfunctions == 0
|
||||||
@actuallybuild!
|
@actuallybuild!
|
||||||
true
|
|
||||||
|
|
||||||
|
|
||||||
shouldbuild: =>
|
shouldbuild: =>
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
ok, MultiProcessExecutor = pcall -> require 'moonbuild.core.multiprocessexecutor'
|
|
||||||
ok and MultiProcessExecutor or require 'moonbuild.core.singleprocessexecutor'
|
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
SingleProcessExecutor = require 'moonbuild.core.singleprocessexecutor'
|
|
||||||
import fork, _exit from require 'posix.unistd'
|
import fork, _exit from require 'posix.unistd'
|
||||||
import wait from require 'posix.sys.wait'
|
import wait from require 'posix.sys.wait'
|
||||||
import open, stderr from io
|
import open, stderr from io
|
||||||
@@ -18,12 +17,8 @@ class Executor
|
|||||||
@processes = {}
|
@processes = {}
|
||||||
@nprocesses = 0
|
@nprocesses = 0
|
||||||
@building = {}
|
@building = {}
|
||||||
@nbuilt = 0
|
|
||||||
|
|
||||||
execute: (opts) =>
|
execute: (opts) =>
|
||||||
if @nparallel == 1
|
|
||||||
return (SingleProcessExecutor @dag, 1)\execute opts
|
|
||||||
|
|
||||||
block = @dag\buildablenodes!
|
block = @dag\buildablenodes!
|
||||||
while #block != 0
|
while #block != 0
|
||||||
for node in *block
|
for node in *block
|
||||||
@@ -41,21 +36,7 @@ class Executor
|
|||||||
for name, node in pairs @dag.nodes
|
for name, node in pairs @dag.nodes
|
||||||
error "Node #{name} wasn't built" unless node.built
|
error "Node #{name} wasn't built" unless node.built
|
||||||
|
|
||||||
unless opts.quiet
|
|
||||||
if @nbuilt == 0
|
|
||||||
print "Nothing to be done"
|
|
||||||
else
|
|
||||||
print "Built #{@nbuilt} targets"
|
|
||||||
|
|
||||||
addprocess: (node, opts) =>
|
addprocess: (node, opts) =>
|
||||||
if node.sync
|
|
||||||
while @nprocesses != 0
|
|
||||||
@waitprocess!
|
|
||||||
node\build opts
|
|
||||||
node.built = true
|
|
||||||
node\updatecache!
|
|
||||||
return
|
|
||||||
|
|
||||||
pid = fork!
|
pid = fork!
|
||||||
error "Failed to fork" unless pid
|
error "Failed to fork" unless pid
|
||||||
if pid!=0
|
if pid!=0
|
||||||
@@ -63,20 +44,18 @@ class Executor
|
|||||||
@nprocesses += 1
|
@nprocesses += 1
|
||||||
@building[node] = true
|
@building[node] = true
|
||||||
else
|
else
|
||||||
ok, status = pcall -> node\build opts
|
ok, err = pcall -> node\build opts
|
||||||
if ok
|
if ok
|
||||||
_exit status and 0 or 2
|
|
||||||
_exit 0
|
_exit 0
|
||||||
else
|
else
|
||||||
stderr\write status
|
stderr\write err
|
||||||
_exit 1
|
_exit 1
|
||||||
|
|
||||||
waitprocess: =>
|
waitprocess: =>
|
||||||
pid, ty, status = wait!
|
pid, ty, status = wait!
|
||||||
error "Failed to wait" unless pid
|
error "Failed to wait" unless pid
|
||||||
error "Failed to build #{@processes[pid].name}" if ty != 'exited' or status != 0 and status != 2
|
error "Failed to build #{@processes[pid].name}" if ty != 'exited' or status != 0
|
||||||
@processes[pid].built = true
|
@processes[pid].built = true
|
||||||
@processes[pid]\updatecache!
|
@processes[pid]\updatecache!
|
||||||
@processes[pid] = nil
|
@processes[pid] = nil
|
||||||
@nprocesses -= 1
|
@nprocesses -= 1
|
||||||
@nbuilt += 1 if status == 0
|
|
||||||
|
|||||||
@@ -4,21 +4,13 @@ class Executor
|
|||||||
new: (@dag, @nparallel) =>
|
new: (@dag, @nparallel) =>
|
||||||
|
|
||||||
execute: (opts) =>
|
execute: (opts) =>
|
||||||
nbuilt = 0
|
|
||||||
|
|
||||||
block = @dag\buildablenodes!
|
block = @dag\buildablenodes!
|
||||||
while #block != 0
|
while #block != 0
|
||||||
for node in *block
|
for node in *block
|
||||||
nbuilt +=1 if node\build opts
|
node\build opts
|
||||||
node\updatecache!
|
node\updatecache!
|
||||||
node.built = true
|
node.built = true
|
||||||
block = @dag\buildablenodes!
|
block = @dag\buildablenodes!
|
||||||
|
|
||||||
for name, node in pairs @dag.nodes
|
for name, node in pairs @dag.nodes
|
||||||
error "Node #{name} wasn't built" unless node.built
|
error "Node #{name} wasn't built" unless node.built
|
||||||
|
|
||||||
unless opts.quiet
|
|
||||||
if nbuilt == 0
|
|
||||||
print "Nothing to be done"
|
|
||||||
else
|
|
||||||
print "Built #{nbuilt} targets"
|
|
||||||
|
|||||||
@@ -1,60 +0,0 @@
|
|||||||
import loadfile from require 'moonscript.base'
|
|
||||||
Context = require 'moonbuild.context'
|
|
||||||
DepGraph = require 'moonbuild.core.DAG'
|
|
||||||
Executor = require 'moonbuild.core.executor'
|
|
||||||
_ = require 'moonbuild._'
|
|
||||||
import insert from table
|
|
||||||
|
|
||||||
moonbuild = (...) ->
|
|
||||||
-- build argument table
|
|
||||||
opts = {}
|
|
||||||
for i=1, select '#', ...
|
|
||||||
arg = select i, ...
|
|
||||||
if (type arg) == 'string'
|
|
||||||
insert opts, arg
|
|
||||||
elseif (type arg) == 'table'
|
|
||||||
for k, v in pairs arg
|
|
||||||
opts[k] = v if (type k) != 'number'
|
|
||||||
for i, v in ipairs arg
|
|
||||||
insert opts, v
|
|
||||||
else
|
|
||||||
error "Invalid argument type #{type arg} for moonbuild"
|
|
||||||
|
|
||||||
-- resolve arguments
|
|
||||||
buildfile = opts.buildfile or opts.b or 'Build.moon'
|
|
||||||
opts.buildfile = buildfile
|
|
||||||
parallel = opts.parallel or opts.j or 1
|
|
||||||
parallel = true if parallel == 'y'
|
|
||||||
opts.parallel = parallel
|
|
||||||
quiet = opts.quiet or opts.q or false
|
|
||||||
opts.quiet = quiet
|
|
||||||
force = opts.force or opts.f or false
|
|
||||||
opts.force = force
|
|
||||||
verbose = opts.verbose or opts.v or false
|
|
||||||
opts.verbose = verbose
|
|
||||||
|
|
||||||
-- create context and DAG
|
|
||||||
ctx = Context!
|
|
||||||
ctx\load (loadfile buildfile), opts
|
|
||||||
print "Loaded buildfile" if verbose
|
|
||||||
ctx\init!
|
|
||||||
print "Initialized buildfile" if verbose
|
|
||||||
targets = #opts==0 and ctx.defaulttargets or opts
|
|
||||||
dag = DepGraph ctx, targets
|
|
||||||
print "Created dependancy graph" if verbose
|
|
||||||
|
|
||||||
-- and build
|
|
||||||
nparallel = parallel == true and Executor\getmaxparallel! or parallel
|
|
||||||
print "Building with #{nparallel} max parallel process#{nparallel>1 and "es" or ""}" if verbose
|
|
||||||
executor = Executor dag, nparallel
|
|
||||||
executor\execute opts
|
|
||||||
print "Finished" if verbose
|
|
||||||
|
|
||||||
table = {
|
|
||||||
:moonbuild, :_
|
|
||||||
:Context, :DepGraph, :Executor
|
|
||||||
}
|
|
||||||
|
|
||||||
setmetatable table,
|
|
||||||
__call: (...) => moonbuild ...
|
|
||||||
__index: (name) => require "moonbuild.#{name}"
|
|
||||||
+2501
-13
File diff suppressed because it is too large
Load Diff
Regular → Executable
+61
-213
@@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/env lua5.3
|
||||||
do
|
do
|
||||||
|
|
||||||
do
|
do
|
||||||
@@ -635,7 +636,6 @@ common.includes = includes
|
|||||||
common.patget = patget
|
common.patget = patget
|
||||||
common.patset = patset
|
common.patset = patset
|
||||||
common.patsubst = patsubst
|
common.patsubst = patsubst
|
||||||
common.exclude = exclude
|
|
||||||
common.min = min
|
common.min = min
|
||||||
common.max = max
|
common.max = max
|
||||||
common.minmax = minmax
|
common.minmax = minmax
|
||||||
@@ -1272,11 +1272,11 @@ _cdeps = function(cc, cflags, path)
|
|||||||
end
|
end
|
||||||
local cdeps = setmetatable({ }, {
|
local cdeps = setmetatable({ }, {
|
||||||
__index = function(self, cc)
|
__index = function(self, cc)
|
||||||
return function(path, cflags)
|
return function(cflags, path)
|
||||||
return _cdeps(cc, cflags, path)
|
return _cdeps(cc, cflags, path)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
__call = function(self, path, cflags)
|
__call = function(self, cflags, path)
|
||||||
return _cdeps('cc', cflags, path)
|
return _cdeps('cc', cflags, path)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
@@ -1646,10 +1646,10 @@ end
|
|||||||
do
|
do
|
||||||
local _ENV = _ENV
|
local _ENV = _ENV
|
||||||
package.preload[ "moonbuild.core.DAG" ] = function( ... ) local arg = _G.arg;
|
package.preload[ "moonbuild.core.DAG" ] = function( ... ) local arg = _G.arg;
|
||||||
local first, filter, foreach, flatten, patsubst, includes
|
local filter, foreach, flatten, patsubst
|
||||||
do
|
do
|
||||||
local _obj_0 = require('moonbuild._common')
|
local _obj_0 = require('moonbuild._common')
|
||||||
first, filter, foreach, flatten, patsubst, includes = _obj_0.first, _obj_0.filter, _obj_0.foreach, _obj_0.flatten, _obj_0.patsubst, _obj_0.includes
|
filter, foreach, flatten, patsubst = _obj_0.filter, _obj_0.foreach, _obj_0.flatten, _obj_0.patsubst
|
||||||
end
|
end
|
||||||
local runwithcontext
|
local runwithcontext
|
||||||
runwithcontext = require('moonbuild.compat.ctx').runwithcontext
|
runwithcontext = require('moonbuild.compat.ctx').runwithcontext
|
||||||
@@ -1659,11 +1659,8 @@ do
|
|||||||
local _obj_0 = require('moonbuild._fs')
|
local _obj_0 = require('moonbuild._fs')
|
||||||
exists, parent, mkdirs, clearentry, disableentry, attributes = _obj_0.exists, _obj_0.parent, _obj_0.mkdirs, _obj_0.clearentry, _obj_0.disableentry, _obj_0.attributes
|
exists, parent, mkdirs, clearentry, disableentry, attributes = _obj_0.exists, _obj_0.parent, _obj_0.mkdirs, _obj_0.clearentry, _obj_0.disableentry, _obj_0.attributes
|
||||||
end
|
end
|
||||||
local sort, insert, remove
|
local sort
|
||||||
do
|
sort = table.sort
|
||||||
local _obj_0 = table
|
|
||||||
sort, insert, remove = _obj_0.sort, _obj_0.insert, _obj_0.remove
|
|
||||||
end
|
|
||||||
local huge
|
local huge
|
||||||
huge = math.huge
|
huge = math.huge
|
||||||
local DepNode, FileTarget
|
local DepNode, FileTarget
|
||||||
@@ -1673,8 +1670,6 @@ nodepriority = function(a, b)
|
|||||||
local tb = type(b.name)
|
local tb = type(b.name)
|
||||||
local da = #a.deps
|
local da = #a.deps
|
||||||
local db = #b.deps
|
local db = #b.deps
|
||||||
local sa = a.sync
|
|
||||||
local sb = b.sync
|
|
||||||
if ta == 'string' and tb ~= 'string' then
|
if ta == 'string' and tb ~= 'string' then
|
||||||
return true
|
return true
|
||||||
elseif ta ~= 'string' and tb == 'string' then
|
elseif ta ~= 'string' and tb == 'string' then
|
||||||
@@ -1683,10 +1678,6 @@ nodepriority = function(a, b)
|
|||||||
return true
|
return true
|
||||||
elseif a.priority < b.priority then
|
elseif a.priority < b.priority then
|
||||||
return false
|
return false
|
||||||
elseif sa and not sb then
|
|
||||||
return false
|
|
||||||
elseif sb and not sa then
|
|
||||||
return true
|
|
||||||
else
|
else
|
||||||
return da < db
|
return da < db
|
||||||
end
|
end
|
||||||
@@ -1698,9 +1689,6 @@ transclosure = function(obj, prop)
|
|||||||
local set = { }
|
local set = { }
|
||||||
local imp
|
local imp
|
||||||
imp = function(e)
|
imp = function(e)
|
||||||
if not (e[prop]) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local _list_0 = e[prop]
|
local _list_0 = e[prop]
|
||||||
for _index_0 = 1, #_list_0 do
|
for _index_0 = 1, #_list_0 do
|
||||||
local v = _list_0[_index_0]
|
local v = _list_0[_index_0]
|
||||||
@@ -1765,7 +1753,7 @@ 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")
|
return resolved[1] or error("Cannot resolve target " .. tostring(name))
|
||||||
end,
|
end,
|
||||||
buildablenodes = function(self)
|
buildablenodes = function(self)
|
||||||
local _accum_0 = { }
|
local _accum_0 = { }
|
||||||
@@ -1777,47 +1765,6 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
return _accum_0
|
return _accum_0
|
||||||
end,
|
|
||||||
reset = function(self)
|
|
||||||
for k, n in pairs(self.nodes) do
|
|
||||||
n.built = false
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
resetchildren = function(self, names)
|
|
||||||
local done = { }
|
|
||||||
local stack
|
|
||||||
do
|
|
||||||
local _accum_0 = { }
|
|
||||||
local _len_0 = 1
|
|
||||||
for _index_0 = 1, #names do
|
|
||||||
local v = names[_index_0]
|
|
||||||
_accum_0[_len_0] = v
|
|
||||||
_len_0 = _len_0 + 1
|
|
||||||
end
|
|
||||||
stack = _accum_0
|
|
||||||
end
|
|
||||||
while #stack ~= 0 do
|
|
||||||
local _continue_0 = false
|
|
||||||
repeat
|
|
||||||
local name = remove(stack)
|
|
||||||
if done[name] then
|
|
||||||
_continue_0 = true
|
|
||||||
break
|
|
||||||
end
|
|
||||||
done[name] = true
|
|
||||||
local node = self.nodes[name]
|
|
||||||
node.built = false
|
|
||||||
local _list_0 = (node:children())
|
|
||||||
for _index_0 = 1, #_list_0 do
|
|
||||||
local n = _list_0[_index_0]
|
|
||||||
insert(stack, n)
|
|
||||||
end
|
|
||||||
_continue_0 = true
|
|
||||||
until true
|
|
||||||
if not _continue_0 then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
_base_0.__index = _base_0
|
_base_0.__index = _base_0
|
||||||
@@ -1850,17 +1797,6 @@ end
|
|||||||
do
|
do
|
||||||
local _class_0
|
local _class_0
|
||||||
local _base_0 = {
|
local _base_0 = {
|
||||||
children = function(self)
|
|
||||||
local _accum_0 = { }
|
|
||||||
local _len_0 = 1
|
|
||||||
for k, n in pairs(self.dag.nodes) do
|
|
||||||
if (includes(n.ins, self.name)) or (includes(n.after, self.name)) then
|
|
||||||
_accum_0[_len_0] = k
|
|
||||||
_len_0 = _len_0 + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return _accum_0
|
|
||||||
end,
|
|
||||||
canbuild = function(self)
|
canbuild = function(self)
|
||||||
local _list_0 = flatten({
|
local _list_0 = flatten({
|
||||||
self.ins,
|
self.ins,
|
||||||
@@ -1876,7 +1812,7 @@ do
|
|||||||
for _index_0 = 1, #_list_1 do
|
for _index_0 = 1, #_list_1 do
|
||||||
local file = _list_1[_index_0]
|
local file = _list_1[_index_0]
|
||||||
if not exists(file) then
|
if not exists(file) then
|
||||||
error("Node " .. tostring(self.name) .. " has ran all of its parents, but can't run since " .. tostring(file) .. " doesn't exist. Did you mean to use after instead of depends?")
|
error("Node " .. tostring(name) .. " has ran all of its parents, but can't run since " .. tostring(file) .. " doesn't exist")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
@@ -1887,17 +1823,16 @@ do
|
|||||||
end
|
end
|
||||||
local force = opts.force or false
|
local force = opts.force or false
|
||||||
local quiet = opts.quiet or false
|
local quiet = opts.quiet or false
|
||||||
if self.built or #self.buildfunctions == 0 then
|
if self.built then
|
||||||
return false
|
return
|
||||||
end
|
end
|
||||||
if not (force or self:shouldbuild()) then
|
if not (force or self:shouldbuild()) then
|
||||||
return false
|
return
|
||||||
end
|
end
|
||||||
if not (quiet) then
|
if not (quiet or #self.buildfunctions == 0) 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))
|
||||||
end
|
end
|
||||||
self:actuallybuild()
|
return self:actuallybuild()
|
||||||
return true
|
|
||||||
end,
|
end,
|
||||||
shouldbuild = function(self)
|
shouldbuild = function(self)
|
||||||
if #self.outs == 0 or #self.ins == 0 or self.type == 'virtual' then
|
if #self.outs == 0 or #self.ins == 0 or self.type == 'virtual' then
|
||||||
@@ -2001,19 +1936,13 @@ do
|
|||||||
__index = function(_, k)
|
__index = function(_, k)
|
||||||
local _exp_0 = k
|
local _exp_0 = k
|
||||||
if 'infile' == _exp_0 then
|
if 'infile' == _exp_0 then
|
||||||
local f = first(deps)
|
return first(deps)
|
||||||
return f and f.name
|
|
||||||
elseif 'infiles' == _exp_0 then
|
elseif 'infiles' == _exp_0 then
|
||||||
return foreach(deps, function(self)
|
return flatten(deps)
|
||||||
return self.name
|
|
||||||
end)
|
|
||||||
elseif 'outfile' == _exp_0 then
|
elseif 'outfile' == _exp_0 then
|
||||||
local f = first(self.outs)
|
return first(self.outs)
|
||||||
return f and f.name
|
|
||||||
elseif 'outfiles' == _exp_0 then
|
elseif 'outfiles' == _exp_0 then
|
||||||
return foreach(self.outs, function(self)
|
return flatten(self.outs)
|
||||||
return self.name
|
|
||||||
end)
|
|
||||||
elseif 'name' == _exp_0 then
|
elseif 'name' == _exp_0 then
|
||||||
return self.name
|
return self.name
|
||||||
else
|
else
|
||||||
@@ -2027,7 +1956,9 @@ do
|
|||||||
local _list_0 = target.depfunctions
|
local _list_0 = target.depfunctions
|
||||||
for _index_0 = 1, #_list_0 do
|
for _index_0 = 1, #_list_0 do
|
||||||
local depfn = _list_0[_index_0]
|
local depfn = _list_0[_index_0]
|
||||||
deps = flatten(deps, foreach((runwithcontext(depfn, self.dag.env, ctx)), resolve))
|
deps = flatten(deps, foreach(depfn, function(fn)
|
||||||
|
return resolve(runwithcontext(fn, self.dag.env, ctx))
|
||||||
|
end))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.ins = foreach(deps, function(dep)
|
self.ins = foreach(deps, function(dep)
|
||||||
@@ -2242,20 +2173,9 @@ end
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
|
||||||
local _ENV = _ENV
|
|
||||||
package.preload[ "moonbuild.core.executor" ] = function( ... ) local arg = _G.arg;
|
|
||||||
local ok, MultiProcessExecutor = pcall(function()
|
|
||||||
return require('moonbuild.core.multiprocessexecutor')
|
|
||||||
end)
|
|
||||||
return ok and MultiProcessExecutor or require('moonbuild.core.singleprocessexecutor')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
do
|
do
|
||||||
local _ENV = _ENV
|
local _ENV = _ENV
|
||||||
package.preload[ "moonbuild.core.multiprocessexecutor" ] = function( ... ) local arg = _G.arg;
|
package.preload[ "moonbuild.core.multiprocessexecutor" ] = function( ... ) local arg = _G.arg;
|
||||||
local SingleProcessExecutor = require('moonbuild.core.singleprocessexecutor')
|
|
||||||
local fork, _exit
|
local fork, _exit
|
||||||
do
|
do
|
||||||
local _obj_0 = require('posix.unistd')
|
local _obj_0 = require('posix.unistd')
|
||||||
@@ -2275,9 +2195,6 @@ do
|
|||||||
local _class_0
|
local _class_0
|
||||||
local _base_0 = {
|
local _base_0 = {
|
||||||
execute = function(self, opts)
|
execute = function(self, opts)
|
||||||
if self.nparallel == 1 then
|
|
||||||
return (SingleProcessExecutor(self.dag, 1)):execute(opts)
|
|
||||||
end
|
|
||||||
local block = self.dag:buildablenodes()
|
local block = self.dag:buildablenodes()
|
||||||
while #block ~= 0 do
|
while #block ~= 0 do
|
||||||
for _index_0 = 1, #block do
|
for _index_0 = 1, #block do
|
||||||
@@ -2325,24 +2242,8 @@ do
|
|||||||
error("Node " .. tostring(name) .. " wasn't built")
|
error("Node " .. tostring(name) .. " wasn't built")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not (opts.quiet) then
|
|
||||||
if self.nbuilt == 0 then
|
|
||||||
return print("Nothing to be done")
|
|
||||||
else
|
|
||||||
return print("Built " .. tostring(self.nbuilt) .. " targets")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
addprocess = function(self, node, opts)
|
addprocess = function(self, node, opts)
|
||||||
if node.sync then
|
|
||||||
while self.nprocesses ~= 0 do
|
|
||||||
self:waitprocess()
|
|
||||||
end
|
|
||||||
node:build(opts)
|
|
||||||
node.built = true
|
|
||||||
node:updatecache()
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local pid = fork()
|
local pid = fork()
|
||||||
if not (pid) then
|
if not (pid) then
|
||||||
error("Failed to fork")
|
error("Failed to fork")
|
||||||
@@ -2352,14 +2253,13 @@ do
|
|||||||
self.nprocesses = self.nprocesses + 1
|
self.nprocesses = self.nprocesses + 1
|
||||||
self.building[node] = true
|
self.building[node] = true
|
||||||
else
|
else
|
||||||
local ok, status = pcall(function()
|
local ok, err = pcall(function()
|
||||||
return node:build(opts)
|
return node:build(opts)
|
||||||
end)
|
end)
|
||||||
if ok then
|
if ok then
|
||||||
_exit(status and 0 or 2)
|
|
||||||
return _exit(0)
|
return _exit(0)
|
||||||
else
|
else
|
||||||
stderr:write(status)
|
stderr:write(err)
|
||||||
return _exit(1)
|
return _exit(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -2369,16 +2269,13 @@ do
|
|||||||
if not (pid) then
|
if not (pid) then
|
||||||
error("Failed to wait")
|
error("Failed to wait")
|
||||||
end
|
end
|
||||||
if ty ~= 'exited' or status ~= 0 and status ~= 2 then
|
if ty ~= 'exited' or status ~= 0 then
|
||||||
error("Failed to build " .. tostring(self.processes[pid].name))
|
error("Failed to build " .. tostring(self.processes[pid].name))
|
||||||
end
|
end
|
||||||
self.processes[pid].built = true
|
self.processes[pid].built = true
|
||||||
self.processes[pid]:updatecache()
|
self.processes[pid]:updatecache()
|
||||||
self.processes[pid] = nil
|
self.processes[pid] = nil
|
||||||
self.nprocesses = self.nprocesses - 1
|
self.nprocesses = self.nprocesses - 1
|
||||||
if status == 0 then
|
|
||||||
self.nbuilt = self.nbuilt + 1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
_base_0.__index = _base_0
|
_base_0.__index = _base_0
|
||||||
@@ -2388,7 +2285,6 @@ do
|
|||||||
self.processes = { }
|
self.processes = { }
|
||||||
self.nprocesses = 0
|
self.nprocesses = 0
|
||||||
self.building = { }
|
self.building = { }
|
||||||
self.nbuilt = 0
|
|
||||||
end,
|
end,
|
||||||
__base = _base_0,
|
__base = _base_0,
|
||||||
__name = "Executor"
|
__name = "Executor"
|
||||||
@@ -2430,14 +2326,11 @@ do
|
|||||||
local _class_0
|
local _class_0
|
||||||
local _base_0 = {
|
local _base_0 = {
|
||||||
execute = function(self, opts)
|
execute = function(self, opts)
|
||||||
local nbuilt = 0
|
|
||||||
local block = self.dag:buildablenodes()
|
local block = self.dag:buildablenodes()
|
||||||
while #block ~= 0 do
|
while #block ~= 0 do
|
||||||
for _index_0 = 1, #block do
|
for _index_0 = 1, #block do
|
||||||
local node = block[_index_0]
|
local node = block[_index_0]
|
||||||
if node:build(opts) then
|
node:build(opts)
|
||||||
nbuilt = nbuilt + 1
|
|
||||||
end
|
|
||||||
node:updatecache()
|
node:updatecache()
|
||||||
node.built = true
|
node.built = true
|
||||||
end
|
end
|
||||||
@@ -2448,13 +2341,6 @@ do
|
|||||||
error("Node " .. tostring(name) .. " wasn't built")
|
error("Node " .. tostring(name) .. " wasn't built")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not (opts.quiet) then
|
|
||||||
if nbuilt == 0 then
|
|
||||||
return print("Nothing to be done")
|
|
||||||
else
|
|
||||||
return print("Built " .. tostring(nbuilt) .. " targets")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
_base_0.__index = _base_0
|
_base_0.__index = _base_0
|
||||||
@@ -2595,80 +2481,42 @@ 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')
|
||||||
|
local Variable = require('moonbuild.core.Variable')
|
||||||
local DepGraph = require('moonbuild.core.DAG')
|
local DepGraph = require('moonbuild.core.DAG')
|
||||||
local Executor = require('moonbuild.core.executor')
|
local sort, concat
|
||||||
local _ = require('moonbuild._')
|
do
|
||||||
local insert
|
local _obj_0 = table
|
||||||
insert = table.insert
|
sort, concat = _obj_0.sort, _obj_0.concat
|
||||||
local moonbuild
|
|
||||||
moonbuild = function(...)
|
|
||||||
local opts = { }
|
|
||||||
for i = 1, select('#', ...) do
|
|
||||||
local arg = select(i, ...)
|
|
||||||
if (type(arg)) == 'string' then
|
|
||||||
insert(opts, arg)
|
|
||||||
elseif (type(arg)) == 'table' then
|
|
||||||
for k, v in pairs(arg) do
|
|
||||||
if (type(k)) ~= 'number' then
|
|
||||||
opts[k] = v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
for i, v in ipairs(arg) do
|
|
||||||
insert(opts, v)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
error("Invalid argument type " .. tostring(type(arg)) .. " for moonbuild")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local buildfile = opts.buildfile or opts.b or 'Build.moon'
|
|
||||||
opts.buildfile = buildfile
|
|
||||||
local parallel = opts.parallel or opts.j or 1
|
|
||||||
if parallel == 'y' then
|
|
||||||
parallel = true
|
|
||||||
end
|
|
||||||
opts.parallel = parallel
|
|
||||||
local quiet = opts.quiet or opts.q or false
|
|
||||||
opts.quiet = quiet
|
|
||||||
local force = opts.force or opts.f or false
|
|
||||||
opts.force = force
|
|
||||||
local verbose = opts.verbose or opts.v or false
|
|
||||||
opts.verbose = verbose
|
|
||||||
local ctx = Context()
|
|
||||||
ctx:load((loadfile(buildfile)), opts)
|
|
||||||
if verbose then
|
|
||||||
print("Loaded buildfile")
|
|
||||||
end
|
|
||||||
ctx:init()
|
|
||||||
if verbose then
|
|
||||||
print("Initialized buildfile")
|
|
||||||
end
|
|
||||||
local targets = #opts == 0 and ctx.defaulttargets or opts
|
|
||||||
local dag = DepGraph(ctx, targets)
|
|
||||||
if verbose then
|
|
||||||
print("Created dependancy graph")
|
|
||||||
end
|
|
||||||
local nparallel = parallel == true and Executor:getmaxparallel() or parallel
|
|
||||||
if verbose then
|
|
||||||
print("Building with " .. tostring(nparallel) .. " max parallel process" .. tostring(nparallel > 1 and "es" or ""))
|
|
||||||
end
|
|
||||||
local executor = Executor(dag, nparallel)
|
|
||||||
executor:execute(opts)
|
|
||||||
if verbose then
|
|
||||||
return print("Finished")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
local table = {
|
return {
|
||||||
moonbuild = moonbuild,
|
tasks = {
|
||||||
_ = _,
|
moonbuild = function(self)
|
||||||
Context = Context,
|
local args = {
|
||||||
DepGraph = DepGraph,
|
nparallel = self.parallel or self.j,
|
||||||
Executor = Executor
|
quiet = self.quiet or self.q,
|
||||||
|
buildfile = self.buildfile or self.b,
|
||||||
|
force = self.force or self.f
|
||||||
|
}
|
||||||
|
local ctx = Context()
|
||||||
|
ctx:load((loadfile(args.buildfile or 'Build.moon')), self)
|
||||||
|
ctx:init()
|
||||||
|
local dag = DepGraph(ctx, #self == 0 and ctx.defaulttargets or self)
|
||||||
|
local executor
|
||||||
|
do
|
||||||
|
local Executor
|
||||||
|
do
|
||||||
|
local ok
|
||||||
|
ok, Executor = pcall(function()
|
||||||
|
return require('moonbuild.core.multiprocessexecutor')
|
||||||
|
end)
|
||||||
|
Executor = ok and Executor or require('moonbuild.core.singleprocessexecutor')
|
||||||
|
end
|
||||||
|
if args.nparallel == true then
|
||||||
|
args.nparallel = Executor:getmaxparallel()
|
||||||
|
end
|
||||||
|
executor = Executor(dag, args.nparallel)
|
||||||
|
end
|
||||||
|
return executor:execute(args)
|
||||||
|
end
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return setmetatable(table, {
|
|
||||||
__call = function(self, ...)
|
|
||||||
return moonbuild(...)
|
|
||||||
end,
|
|
||||||
__index = function(self, name)
|
|
||||||
return require("moonbuild." .. tostring(name))
|
|
||||||
end
|
|
||||||
})
|
|
||||||
@@ -22,5 +22,3 @@ build:
|
|||||||
install:
|
install:
|
||||||
bin:
|
bin:
|
||||||
moonbuild: out/moonbuild
|
moonbuild: out/moonbuild
|
||||||
modules:
|
|
||||||
moonbuild: out/moonbuild.lua
|
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
build = {
|
|
||||||
install = {
|
|
||||||
bin = {
|
|
||||||
moonbuild = "out/moonbuild"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
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.1.0",
|
|
||||||
url = "git://github.com/natnat-mc/moonbuild"
|
|
||||||
}
|
|
||||||
version = "2.1.0-1"
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
build = {
|
|
||||||
install = {
|
|
||||||
bin = {
|
|
||||||
moonbuild = "out/moonbuild"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
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.1.0",
|
|
||||||
url = "git://github.com/natnat-mc/moonbuild"
|
|
||||||
}
|
|
||||||
version = "2.1.0-2"
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
build = {
|
|
||||||
install = {
|
|
||||||
bin = {
|
|
||||||
moonbuild = "out/moonbuild"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
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.1.0",
|
|
||||||
url = "git://github.com/natnat-mc/moonbuild"
|
|
||||||
}
|
|
||||||
version = "2.1.0-3"
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
build = {
|
|
||||||
install = {
|
|
||||||
bin = {
|
|
||||||
moonbuild = "out/moonbuild"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
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.1.1",
|
|
||||||
url = "git://github.com/natnat-mc/moonbuild"
|
|
||||||
}
|
|
||||||
version = "2.1.1-1"
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
build = {
|
|
||||||
install = {
|
|
||||||
bin = {
|
|
||||||
moonbuild = "out/moonbuild"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
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.1.2",
|
|
||||||
url = "git://github.com/natnat-mc/moonbuild"
|
|
||||||
}
|
|
||||||
version = "2.1.2-1"
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
build = {
|
|
||||||
install = {
|
|
||||||
bin = {
|
|
||||||
moonbuild = "out/moonbuild"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
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.1.2",
|
|
||||||
url = "git://github.com/natnat-mc/moonbuild"
|
|
||||||
}
|
|
||||||
version = "2.1.2-2"
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
build = {
|
|
||||||
install = {
|
|
||||||
bin = {
|
|
||||||
moonbuild = "out/moonbuild"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
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.1.3",
|
|
||||||
url = "git://github.com/natnat-mc/moonbuild"
|
|
||||||
}
|
|
||||||
version = "2.1.3-1"
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
build = {
|
|
||||||
install = {
|
|
||||||
bin = {
|
|
||||||
moonbuild = "out/moonbuild"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
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.1.3",
|
|
||||||
url = "git://github.com/natnat-mc/moonbuild"
|
|
||||||
}
|
|
||||||
version = "2.1.3-2"
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
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.2.0",
|
|
||||||
url = "git://github.com/natnat-mc/moonbuild"
|
|
||||||
}
|
|
||||||
version = "2.2.0-1"
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
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.2.0",
|
|
||||||
url = "git://github.com/natnat-mc/moonbuild"
|
|
||||||
}
|
|
||||||
version = "2.2.0-2"
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
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.2.1",
|
|
||||||
url = "git://github.com/natnat-mc/moonbuild"
|
|
||||||
}
|
|
||||||
version = "2.2.1-1"
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
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.2.2",
|
|
||||||
url = "git://github.com/natnat-mc/moonbuild"
|
|
||||||
}
|
|
||||||
version = "2.2.2-1"
|
|
||||||
Reference in New Issue
Block a user