mirror of
https://github.com/natnat-mc/moonbuild
synced 2026-05-28 21:09:40 +02:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d22335d569 |
+2
-1
@@ -1,6 +1,7 @@
|
|||||||
tasks:
|
tasks:
|
||||||
build: =>
|
build: =>
|
||||||
sh "moon bin/moonbuild.moon -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!
|
||||||
|
|||||||
@@ -16,11 +16,6 @@ with public default target 'all'
|
|||||||
\after 'bin'
|
\after 'bin'
|
||||||
\after 'lib'
|
\after 'lib'
|
||||||
|
|
||||||
with public target 'install'
|
|
||||||
\depends 'out/moonbuild'
|
|
||||||
\produces '/usr/local/bin/moonbuild'
|
|
||||||
\fn => _.cmd 'sudo', 'cp', @infile, @outfile
|
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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'
|
||||||
|
|||||||
+9
-17
@@ -1,4 +1,4 @@
|
|||||||
import first, filter, foreach, flatten, patsubst 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'
|
||||||
@@ -64,7 +64,7 @@ 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]
|
||||||
@@ -87,24 +87,16 @@ 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 }
|
||||||
|
|||||||
+12
-16
@@ -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
|
local filter, foreach, flatten, patsubst
|
||||||
do
|
do
|
||||||
local _obj_0 = require('moonbuild._common')
|
local _obj_0 = require('moonbuild._common')
|
||||||
first, filter, foreach, flatten, patsubst = _obj_0.first, _obj_0.filter, _obj_0.foreach, _obj_0.flatten, _obj_0.patsubst
|
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
|
||||||
@@ -1753,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 = { }
|
||||||
@@ -1936,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
|
||||||
@@ -1962,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)
|
||||||
|
|||||||
@@ -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"
|
|
||||||
Reference in New Issue
Block a user