mirror of
https://github.com/natnat-mc/moonbuild
synced 2026-05-28 07:19:40 +02:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 37ab4f2299 | |||
| 4cd18877a9 | |||
| 67eb978e43 | |||
| f51be8631b | |||
| 715aa2ebb7 | |||
| bed119a40c | |||
| 57126a7973 | |||
| cd9b0ab159 | |||
| 678313d09f | |||
| ebd380fb0f |
@@ -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'
|
||||||
|
|||||||
+17
-22
@@ -1,4 +1,3 @@
|
|||||||
public var MOONC: 'moonc'
|
|
||||||
public var AMALG: 'amalg.lua'
|
public var AMALG: 'amalg.lua'
|
||||||
public var RM: 'rm', '-f', '--'
|
public var RM: 'rm', '-f', '--'
|
||||||
public var LUA: 'lua5.3'
|
public var LUA: 'lua5.3'
|
||||||
@@ -41,27 +40,23 @@ with public target 'mrproper'
|
|||||||
\after 'clean'
|
\after 'clean'
|
||||||
\fn => _.cmd RM, BIN, LIB
|
\fn => _.cmd RM, BIN, LIB
|
||||||
|
|
||||||
with public target 'bin'
|
with pipeline! -- lib
|
||||||
\depends BIN
|
\sources LIB_SRC
|
||||||
|
\step 'compile-lib'
|
||||||
|
pattern: {'%.moon', '%.lua'}
|
||||||
|
fn: => _.moonc @infile, @out
|
||||||
|
\step 'lib'
|
||||||
|
output: LIB
|
||||||
|
fn: => _.cmd AMALG, '-o', @out, '-s', 'moonbuild/init.lua', _.exclude MODULES, 'moonbuild.init'
|
||||||
|
|
||||||
with public target 'lib'
|
with pipeline! -- bin
|
||||||
\depends LIB_LUA, LIB
|
\sources BIN_SRC
|
||||||
|
\step 'compile-bin'
|
||||||
with target BIN, pattern: 'out/%'
|
pattern: {'%.moon', '%.lua'}
|
||||||
\depends 'bin/%.lua'
|
fn: => _.moonc @infile, @out
|
||||||
\produces 'out/%'
|
\step 'bin'
|
||||||
\mkdirs!
|
pattern: {'bin/%.lua', 'out/%'}
|
||||||
\fn =>
|
mkdirs: true
|
||||||
|
fn: =>
|
||||||
_.writefile @out, "#!/usr/bin/env #{LUA}\n#{_.readfile @infile}"
|
_.writefile @out, "#!/usr/bin/env #{LUA}\n#{_.readfile @infile}"
|
||||||
_.cmd 'chmod', '+x', @out
|
_.cmd 'chmod', '+x', @out
|
||||||
|
|
||||||
with target LIB
|
|
||||||
\depends 'moonbuild/init.lua'
|
|
||||||
\depends LIB_LUA
|
|
||||||
\produces '%'
|
|
||||||
\fn => _.cmd AMALG, '-o', @out, '-s', @infile, _.exclude MODULES, 'moonbuild.init'
|
|
||||||
|
|
||||||
with target {LIB_LUA, BIN_LUA}, pattern: '%.lua'
|
|
||||||
\depends '%.moon'
|
|
||||||
\produces '%.lua'
|
|
||||||
\fn => _.moonc @infile, @out
|
|
||||||
|
|||||||
+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}
|
||||||
|
|||||||
+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
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
Target = require 'moonbuild.core.Target'
|
||||||
|
_ = require 'moonbuild._'
|
||||||
|
import flatten, patsubst from _
|
||||||
|
|
||||||
|
class Pipeline
|
||||||
|
new: (@ctx) =>
|
||||||
|
@lastsources = {}
|
||||||
|
|
||||||
|
sources: (...) =>
|
||||||
|
@lastsources = flatten @lastsources, ...
|
||||||
|
source: (src) =>
|
||||||
|
@lastsources = flatten @lastsources, src
|
||||||
|
|
||||||
|
step: (name, params) =>
|
||||||
|
public = true
|
||||||
|
public, params = false, name if (type name) == 'table'
|
||||||
|
|
||||||
|
tgttype = if params.pattern
|
||||||
|
error "pattern must be a table with the same format as patsubst" unless (type params.pattern) == 'table' and (type params.pattern[1]) == 'string' and (type params.pattern[2]) == 'string'
|
||||||
|
'pattern'
|
||||||
|
elseif params.output or params.out
|
||||||
|
error "output must be a string" unless (type params.output or params.out) == 'string'
|
||||||
|
'single'
|
||||||
|
else
|
||||||
|
error "invalid step type for pipeline: must be pattern or single (out/output)"
|
||||||
|
|
||||||
|
tgtouts = switch tgttype
|
||||||
|
when 'pattern' then patsubst @lastsources, params.pattern[1], params.pattern[2]
|
||||||
|
when 'single' then params.output or params.out
|
||||||
|
|
||||||
|
tgtpatt = switch tgttype
|
||||||
|
when 'pattern' then params.pattern[2]
|
||||||
|
when 'single' then nil
|
||||||
|
|
||||||
|
tgtins = switch tgttype
|
||||||
|
when 'pattern' then params.pattern[1]
|
||||||
|
when 'single' then @lastsources
|
||||||
|
|
||||||
|
tgtprod = switch tgttype
|
||||||
|
when 'pattern' then params.pattern[2]
|
||||||
|
when 'single' then '%'
|
||||||
|
|
||||||
|
tgt = with Target @ctx, tgtouts, pattern: tgtpatt
|
||||||
|
\depends tgtins
|
||||||
|
\produces tgtprod
|
||||||
|
\fn params.fn or error "pipeline steps need a fn"
|
||||||
|
tgt\mkdirs! if params.mkdirs
|
||||||
|
tgt\sync! if params.sync
|
||||||
|
@ctx\addtarget tgt
|
||||||
|
|
||||||
|
if public
|
||||||
|
@ctx\addtarget with Target @ctx, name
|
||||||
|
\depends tgtouts
|
||||||
|
.public = true
|
||||||
|
|
||||||
|
@lastsources = tgtouts
|
||||||
Vendored
+6
-2
@@ -1,5 +1,6 @@
|
|||||||
Target = require 'moonbuild.core.Target'
|
Target = require 'moonbuild.core.Target'
|
||||||
Variable = require 'moonbuild.core.Variable'
|
Variable = require 'moonbuild.core.Variable'
|
||||||
|
Pipeline = require 'moonbuild.core.Pipeline'
|
||||||
_ = require 'moonbuild._'
|
_ = require 'moonbuild._'
|
||||||
import flatten from _
|
import flatten from _
|
||||||
|
|
||||||
@@ -18,8 +19,8 @@ import flatten from _
|
|||||||
rawset env, '_G', env
|
rawset env, '_G', env
|
||||||
rawset env, '_ENV', env
|
rawset env, '_ENV', env
|
||||||
|
|
||||||
rawset env, 'var', (name, ...) ->
|
rawset env, 'var', (...) ->
|
||||||
var = Variable name, ...
|
var = Variable ...
|
||||||
ctx\addvar var
|
ctx\addvar var
|
||||||
rawset varlayer, var.name, var.value
|
rawset varlayer, var.name, var.value
|
||||||
var
|
var
|
||||||
@@ -29,4 +30,7 @@ import flatten from _
|
|||||||
ctx\addtarget target
|
ctx\addtarget target
|
||||||
target
|
target
|
||||||
|
|
||||||
|
rawset env, 'pipeline', ->
|
||||||
|
Pipeline ctx
|
||||||
|
|
||||||
env, varlayer
|
env, varlayer
|
||||||
|
|||||||
Generated
+188
-17
@@ -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;
|
||||||
@@ -973,14 +971,27 @@ mkdir = function(dir)
|
|||||||
end
|
end
|
||||||
local mkdirs
|
local mkdirs
|
||||||
mkdirs = function(dir)
|
mkdirs = function(dir)
|
||||||
if isdir(dir) then
|
do
|
||||||
|
local attr = attributes(normalizepath(dir))
|
||||||
|
if attr then
|
||||||
|
if attr.mode == 'directory' then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if exists(dir) then
|
|
||||||
error("Can't mkdirs " .. tostring(dir) .. ": file exists")
|
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 = { }
|
||||||
@@ -1737,7 +1748,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 +1758,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 +1807,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 +1818,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 +1956,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 +2038,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 +2054,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))
|
||||||
@@ -2107,6 +2159,123 @@ return DepGraph
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
do
|
||||||
|
local _ENV = _ENV
|
||||||
|
package.preload[ "moonbuild.core.Pipeline" ] = function( ... ) local arg = _G.arg;
|
||||||
|
local Target = require('moonbuild.core.Target')
|
||||||
|
local _ = require('moonbuild._')
|
||||||
|
local flatten, patsubst
|
||||||
|
flatten, patsubst = _.flatten, _.patsubst
|
||||||
|
local Pipeline
|
||||||
|
do
|
||||||
|
local _class_0
|
||||||
|
local _base_0 = {
|
||||||
|
sources = function(self, ...)
|
||||||
|
self.lastsources = flatten(self.lastsources, ...)
|
||||||
|
end,
|
||||||
|
source = function(self, src)
|
||||||
|
self.lastsources = flatten(self.lastsources, src)
|
||||||
|
end,
|
||||||
|
step = function(self, name, params)
|
||||||
|
local public = true
|
||||||
|
if (type(name)) == 'table' then
|
||||||
|
public, params = false, name
|
||||||
|
end
|
||||||
|
local tgttype
|
||||||
|
if params.pattern then
|
||||||
|
if not ((type(params.pattern)) == 'table' and (type(params.pattern[1])) == 'string' and (type(params.pattern[2])) == 'string') then
|
||||||
|
error("pattern must be a table with the same format as patsubst")
|
||||||
|
end
|
||||||
|
tgttype = 'pattern'
|
||||||
|
elseif params.output or params.out then
|
||||||
|
if not ((type(params.output or params.out)) == 'string') then
|
||||||
|
error("output must be a string")
|
||||||
|
end
|
||||||
|
tgttype = 'single'
|
||||||
|
else
|
||||||
|
tgttype = error("invalid step type for pipeline: must be pattern or single (out/output)")
|
||||||
|
end
|
||||||
|
local tgtouts
|
||||||
|
local _exp_0 = tgttype
|
||||||
|
if 'pattern' == _exp_0 then
|
||||||
|
tgtouts = patsubst(self.lastsources, params.pattern[1], params.pattern[2])
|
||||||
|
elseif 'single' == _exp_0 then
|
||||||
|
tgtouts = params.output or params.out
|
||||||
|
end
|
||||||
|
local tgtpatt
|
||||||
|
local _exp_1 = tgttype
|
||||||
|
if 'pattern' == _exp_1 then
|
||||||
|
tgtpatt = params.pattern[2]
|
||||||
|
elseif 'single' == _exp_1 then
|
||||||
|
tgtpatt = nil
|
||||||
|
end
|
||||||
|
local tgtins
|
||||||
|
local _exp_2 = tgttype
|
||||||
|
if 'pattern' == _exp_2 then
|
||||||
|
tgtins = params.pattern[1]
|
||||||
|
elseif 'single' == _exp_2 then
|
||||||
|
tgtins = self.lastsources
|
||||||
|
end
|
||||||
|
local tgtprod
|
||||||
|
local _exp_3 = tgttype
|
||||||
|
if 'pattern' == _exp_3 then
|
||||||
|
tgtprod = params.pattern[2]
|
||||||
|
elseif 'single' == _exp_3 then
|
||||||
|
tgtprod = '%'
|
||||||
|
end
|
||||||
|
local tgt
|
||||||
|
do
|
||||||
|
local _with_0 = Target(self.ctx, tgtouts, {
|
||||||
|
pattern = tgtpatt
|
||||||
|
})
|
||||||
|
_with_0:depends(tgtins)
|
||||||
|
_with_0:produces(tgtprod)
|
||||||
|
_with_0:fn(params.fn or error("pipeline steps need a fn"))
|
||||||
|
tgt = _with_0
|
||||||
|
end
|
||||||
|
if params.mkdirs then
|
||||||
|
tgt:mkdirs()
|
||||||
|
end
|
||||||
|
if params.sync then
|
||||||
|
tgt:sync()
|
||||||
|
end
|
||||||
|
self.ctx:addtarget(tgt)
|
||||||
|
if public then
|
||||||
|
self.ctx:addtarget((function()
|
||||||
|
do
|
||||||
|
local _with_0 = Target(self.ctx, name)
|
||||||
|
_with_0:depends(tgtouts)
|
||||||
|
_with_0.public = true
|
||||||
|
return _with_0
|
||||||
|
end
|
||||||
|
end)())
|
||||||
|
end
|
||||||
|
self.lastsources = tgtouts
|
||||||
|
end
|
||||||
|
}
|
||||||
|
_base_0.__index = _base_0
|
||||||
|
_class_0 = setmetatable({
|
||||||
|
__init = function(self, ctx)
|
||||||
|
self.ctx = ctx
|
||||||
|
self.lastsources = { }
|
||||||
|
end,
|
||||||
|
__base = _base_0,
|
||||||
|
__name = "Pipeline"
|
||||||
|
}, {
|
||||||
|
__index = _base_0,
|
||||||
|
__call = function(cls, ...)
|
||||||
|
local _self_0 = setmetatable({}, _base_0)
|
||||||
|
cls.__init(_self_0, ...)
|
||||||
|
return _self_0
|
||||||
|
end
|
||||||
|
})
|
||||||
|
_base_0.__class = _class_0
|
||||||
|
Pipeline = _class_0
|
||||||
|
return _class_0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
do
|
do
|
||||||
local _ENV = _ENV
|
local _ENV = _ENV
|
||||||
package.preload[ "moonbuild.core.Target" ] = function( ... ) local arg = _G.arg;
|
package.preload[ "moonbuild.core.Target" ] = function( ... ) local arg = _G.arg;
|
||||||
@@ -2539,6 +2708,7 @@ local _ENV = _ENV
|
|||||||
package.preload[ "moonbuild.env.init" ] = function( ... ) local arg = _G.arg;
|
package.preload[ "moonbuild.env.init" ] = function( ... ) local arg = _G.arg;
|
||||||
local Target = require('moonbuild.core.Target')
|
local Target = require('moonbuild.core.Target')
|
||||||
local Variable = require('moonbuild.core.Variable')
|
local Variable = require('moonbuild.core.Variable')
|
||||||
|
local Pipeline = require('moonbuild.core.Pipeline')
|
||||||
local _ = require('moonbuild._')
|
local _ = require('moonbuild._')
|
||||||
local flatten
|
local flatten
|
||||||
flatten = _.flatten
|
flatten = _.flatten
|
||||||
@@ -2558,8 +2728,8 @@ return function(ctx)
|
|||||||
rawset(env, '_', _)
|
rawset(env, '_', _)
|
||||||
rawset(env, '_G', env)
|
rawset(env, '_G', env)
|
||||||
rawset(env, '_ENV', env)
|
rawset(env, '_ENV', env)
|
||||||
rawset(env, 'var', function(name, ...)
|
rawset(env, 'var', function(...)
|
||||||
local var = Variable(name, ...)
|
local var = Variable(...)
|
||||||
ctx:addvar(var)
|
ctx:addvar(var)
|
||||||
rawset(varlayer, var.name, var.value)
|
rawset(varlayer, var.name, var.value)
|
||||||
return var
|
return var
|
||||||
@@ -2569,6 +2739,9 @@ return function(ctx)
|
|||||||
ctx:addtarget(target)
|
ctx:addtarget(target)
|
||||||
return target
|
return target
|
||||||
end)
|
end)
|
||||||
|
rawset(env, 'pipeline', function()
|
||||||
|
return Pipeline(ctx)
|
||||||
|
end)
|
||||||
return env, varlayer
|
return env, varlayer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -2616,8 +2789,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')
|
||||||
|
|||||||
@@ -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.4.0",
|
||||||
|
url = "git://github.com/natnat-mc/moonbuild"
|
||||||
|
}
|
||||||
|
version = "2.4.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.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