1
0
mirror of https://github.com/natnat-mc/moonbuild synced 2026-05-28 09:39:40 +02:00

3 Commits

Author SHA1 Message Date
Codinget 803d1093bb added table syntax for var, closes #19 2020-12-01 22:05:04 +01:00
Codinget ec5fc1cf7d added @in (but not working due to moonscript bug) and @out 2020-12-01 21:43:04 +01:00
Codinget 17578bb721 Producing rockspec 2.3.0-2 2020-12-01 21:35:49 +01:00
6 changed files with 82 additions and 29 deletions
+17 -17
View File
@@ -1,17 +1,17 @@
public var 'MOONC', 'moonc' 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'
var 'LIB_SRC', _.wildcard 'moonbuild/**.moon' var LIB_SRC: _.wildcard 'moonbuild/**.moon'
var 'BIN_SRC', _.wildcard 'bin/*.moon' var BIN_SRC: _.wildcard 'bin/*.moon'
var 'LIB_LUA', _.patsubst LIB_SRC, '%.moon', '%.lua' var LIB_LUA: _.patsubst LIB_SRC, '%.moon', '%.lua'
var 'BIN_LUA', _.patsubst BIN_SRC, '%.moon', '%.lua' var BIN_LUA: _.patsubst BIN_SRC, '%.moon', '%.lua'
var 'BIN', _.patsubst BIN_LUA, 'bin/%.lua', 'out/%' var BIN: _.patsubst BIN_LUA, 'bin/%.lua', 'out/%'
var 'LIB', 'out/moonbuild.lua' var LIB: 'out/moonbuild.lua'
var 'MODULES', _.foreach (_.patsubst LIB_LUA, '%.lua', '%'), => @gsub '/', '.' var MODULES: _.foreach (_.patsubst LIB_LUA, '%.lua', '%'), => @gsub '/', '.'
with public default target 'all' with public default target 'all'
\after 'bin' \after 'bin'
@@ -24,13 +24,13 @@ with public target 'install'
with public target 'install-bin' with public target 'install-bin'
\depends BIN \depends BIN
\produces _.patsubst BIN, 'out/%', '/usr/local/bin/%' \produces _.patsubst BIN, 'out/%', '/usr/local/bin/%'
\fn => _.cmd 'sudo', 'cp', @infile, @outfile \fn => _.cmd 'sudo', 'cp', @infile, @out
\sync! \sync!
with public target 'install-lib' with public target 'install-lib'
\depends LIB \depends LIB
\produces "/usr/local/share/lua/#{LUA\gsub 'lua', ''}/moonbuild.lua" \produces "/usr/local/share/lua/#{LUA\gsub 'lua', ''}/moonbuild.lua"
\fn => _.cmd 'sudo', 'cp', @infile, @outfile \fn => _.cmd 'sudo', 'cp', @infile, @out
\sync! \sync!
with public target 'clean' with public target 'clean'
@@ -52,16 +52,16 @@ with target BIN, pattern: 'out/%'
\produces 'out/%' \produces 'out/%'
\mkdirs! \mkdirs!
\fn => \fn =>
_.writefile @outfile, "#!/usr/bin/env #{LUA}\n#{_.readfile @infile}" _.writefile @out, "#!/usr/bin/env #{LUA}\n#{_.readfile @infile}"
_.cmd 'chmod', '+x', @outfile _.cmd 'chmod', '+x', @out
with target LIB with target LIB
\depends 'moonbuild/init.lua' \depends 'moonbuild/init.lua'
\depends LIB_LUA \depends LIB_LUA
\produces '%' \produces '%'
\fn => _.cmd AMALG, '-o', @outfile, '-s', @infile, _.exclude MODULES, 'moonbuild.init' \fn => _.cmd AMALG, '-o', @out, '-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'
\fn => _.moonc @infile, @outfile \fn => _.moonc @infile, @out
+4 -4
View File
@@ -108,12 +108,12 @@ class DepNode
ctx = setmetatable {}, ctx = setmetatable {},
__index: (_, k) -> __index: (_, k) ->
switch k switch k
when 'infile' when 'infile', 'in'
f = first deps f = first deps
f and f.name f and f.name
when 'infiles' when 'infiles'
foreach deps, => @name foreach deps, => @name
when 'outfile' when 'outfile', 'out'
f = first @outs f = first @outs
f and f.name f and f.name
when 'outfiles' when 'outfiles'
@@ -182,9 +182,9 @@ class DepNode
ctx = setmetatable {}, ctx = setmetatable {},
__index: (_, k) -> __index: (_, k) ->
switch k switch k
when 'infile' then @ins[1] when 'infile', 'in' then @ins[1]
when 'infiles' then @ins when 'infiles' then @ins
when 'outfile' then @outs[1] when 'outfile', 'out' then @outs[1]
when 'outfiles' then @outs when 'outfiles' then @outs
when 'name' then @name when 'name' then @name
else error "No such field in TargetContext: #{k}" else error "No such field in TargetContext: #{k}"
+11 -1
View File
@@ -4,7 +4,17 @@ class Variable
new: (@name, ...) => new: (@name, ...) =>
@public = false @public = false
if (select '#', ...) !=1 or (type ...) == 'table' if (type @name) == 'table'
error "not a valid var table: #{next @name}" unless (type next @name) == 'string'
error "more than one var at once: #{next @name}, #{next @name, (next @name)}" if next @name, (next @name)
name = next @name
@name, param = name, @name
val = param[name]
if (select '#', ...) !=0 or (type val) == 'table'
@value = flatten val, ...
else
@value = val
elseif (select '#', ...) !=1 or (type ...) == 'table'
@value = flatten ... @value = flatten ...
else else
@value = ... @value = ...
+1 -1
View File
@@ -21,7 +21,7 @@ import flatten from _
rawset env, 'var', (name, ...) -> rawset env, 'var', (name, ...) ->
var = Variable name, ... var = Variable name, ...
ctx\addvar var ctx\addvar var
rawset varlayer, name, var.value rawset varlayer, var.name, var.value
var var
rawset env, 'target', (name, opts) -> rawset env, 'target', (name, opts) ->
+22 -6
View File
@@ -1952,11 +1952,11 @@ do
local ctx = setmetatable({ }, { local ctx = setmetatable({ }, {
__index = function(_, k) __index = function(_, k)
local _exp_0 = k local _exp_0 = k
if 'infile' == _exp_0 then if 'infile' == _exp_0 or 'in' == _exp_0 then
return self.ins[1] return self.ins[1]
elseif 'infiles' == _exp_0 then elseif 'infiles' == _exp_0 then
return self.ins return self.ins
elseif 'outfile' == _exp_0 then elseif 'outfile' == _exp_0 or 'out' == _exp_0 then
return self.outs[1] return self.outs[1]
elseif 'outfiles' == _exp_0 then elseif 'outfiles' == _exp_0 then
return self.outs return self.outs
@@ -2010,14 +2010,14 @@ do
local ctx = setmetatable({ }, { local ctx = setmetatable({ }, {
__index = function(_, k) __index = function(_, k)
local _exp_0 = k local _exp_0 = k
if 'infile' == _exp_0 then if 'infile' == _exp_0 or 'in' == _exp_0 then
local f = first(deps) local f = first(deps)
return f and f.name return f and f.name
elseif 'infiles' == _exp_0 then elseif 'infiles' == _exp_0 then
return foreach(deps, function(self) return foreach(deps, function(self)
return self.name return self.name
end) end)
elseif 'outfile' == _exp_0 then elseif 'outfile' == _exp_0 or 'out' == _exp_0 then
local f = first(self.outs) local f = first(self.outs)
return f and f.name return f and f.name
elseif 'outfiles' == _exp_0 then elseif 'outfiles' == _exp_0 then
@@ -2227,7 +2227,23 @@ do
__init = function(self, name, ...) __init = function(self, name, ...)
self.name = name self.name = name
self.public = false self.public = false
if (select('#', ...)) ~= 1 or (type(...)) == 'table' then if (type(self.name)) == 'table' then
if not ((type(next(self.name))) == 'string') then
error("not a valid var table: " .. tostring(next(self.name)))
end
if next(self.name, (next(self.name))) then
error("more than one var at once: " .. tostring(next(self.name)) .. ", " .. tostring(next(self.name, (next(self.name)))))
end
name = next(self.name)
local param
self.name, param = name, self.name
local val = param[name]
if (select('#', ...)) ~= 0 or (type(val)) == 'table' then
self.value = flatten(val, ...)
else
self.value = val
end
elseif (select('#', ...)) ~= 1 or (type(...)) == 'table' then
self.value = flatten(...) self.value = flatten(...)
else else
self.value = ... self.value = ...
@@ -2545,7 +2561,7 @@ return function(ctx)
rawset(env, 'var', function(name, ...) rawset(env, 'var', function(name, ...)
local var = Variable(name, ...) local var = Variable(name, ...)
ctx:addvar(var) ctx:addvar(var)
rawset(varlayer, name, var.value) rawset(varlayer, var.name, var.value)
return var return var
end) end)
rawset(env, 'target', function(name, opts) rawset(env, 'target', function(name, opts)
+27
View File
@@ -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.3.0",
url = "git://github.com/natnat-mc/moonbuild"
}
version = "2.3.0-2"