mirror of
https://github.com/natnat-mc/moonbuild
synced 2026-05-28 06:09:41 +02:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 803d1093bb | |||
| ec5fc1cf7d | |||
| 17578bb721 | |||
| d3c8414086 | |||
| d43e9350d3 | |||
| 0f3506c7b7 | |||
| eb28c9c8bb | |||
| e0afeaaf07 | |||
| e13705f232 | |||
| c6004f1582 | |||
| ce942f9da8 | |||
| cc776ef24e | |||
| 603d09fc84 | |||
| 2b3337fc69 |
+3
-1
@@ -1 +1,3 @@
|
||||
*.lua
|
||||
bin/*.lua
|
||||
moonbuild/*.lua
|
||||
moonbuild/*/*.lua
|
||||
|
||||
+7
-7
@@ -1,13 +1,13 @@
|
||||
tasks:
|
||||
bootstrap: => sh "moon bin/moonbuild.moon -jy"
|
||||
bootstrapinstall: => sh "moon bin/moonbuild.moon install -jy"
|
||||
require 'moonscript'
|
||||
moonbuild = require 'moonbuild'
|
||||
|
||||
tasks:
|
||||
release: =>
|
||||
error "no version provided" unless @v
|
||||
tasks.build!
|
||||
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'
|
||||
build: => moonbuild j: true
|
||||
install: => moonbuild 'install', j: true
|
||||
clean: => moonbuild 'clean'
|
||||
mrproper: => moonbuild 'mrproper'
|
||||
|
||||
+23
-25
@@ -1,16 +1,17 @@
|
||||
public var 'MOONC', 'moonc'
|
||||
public var 'AMALG', 'amalg.lua'
|
||||
public var 'RM', 'rm', '-f', '--'
|
||||
public var 'LUA', 'lua5.3'
|
||||
public var MOONC: 'moonc'
|
||||
public var AMALG: 'amalg.lua'
|
||||
public var RM: 'rm', '-f', '--'
|
||||
public var LUA: 'lua5.3'
|
||||
|
||||
var 'LIB_SRC', _.wildcard 'moonbuild/**.moon'
|
||||
var 'BIN_SRC', _.wildcard 'bin/*.moon'
|
||||
var LIB_SRC: _.wildcard 'moonbuild/**.moon'
|
||||
var BIN_SRC: _.wildcard 'bin/*.moon'
|
||||
|
||||
var 'LIB_LUA', _.patsubst LIB_SRC, '%.moon', '%.lua'
|
||||
var 'BIN_LUA', _.patsubst BIN_SRC, '%.moon', '%.lua'
|
||||
var 'BIN', _.patsubst BIN_LUA, 'bin/%.lua', 'out/%'
|
||||
var LIB_LUA: _.patsubst LIB_SRC, '%.moon', '%.lua'
|
||||
var BIN_LUA: _.patsubst BIN_SRC, '%.moon', '%.lua'
|
||||
var BIN: _.patsubst BIN_LUA, 'bin/%.lua', 'out/%'
|
||||
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'
|
||||
\after 'bin'
|
||||
@@ -21,15 +22,15 @@ with public target 'install'
|
||||
\after 'install-lib'
|
||||
|
||||
with public target 'install-bin'
|
||||
\depends 'out/moonbuild'
|
||||
\produces '/usr/local/bin/moonbuild'
|
||||
\fn => _.cmd 'sudo', 'cp', @infile, @outfile
|
||||
\depends BIN
|
||||
\produces _.patsubst BIN, 'out/%', '/usr/local/bin/%'
|
||||
\fn => _.cmd 'sudo', 'cp', @infile, @out
|
||||
\sync!
|
||||
|
||||
with public target 'install-lib'
|
||||
\depends 'out/moonbuild.lua'
|
||||
\depends LIB
|
||||
\produces "/usr/local/share/lua/#{LUA\gsub 'lua', ''}/moonbuild.lua"
|
||||
\fn => _.cmd 'sudo', 'cp', @infile, @outfile
|
||||
\fn => _.cmd 'sudo', 'cp', @infile, @out
|
||||
\sync!
|
||||
|
||||
with public target 'clean'
|
||||
@@ -38,32 +39,29 @@ with public target 'clean'
|
||||
|
||||
with public target 'mrproper'
|
||||
\after 'clean'
|
||||
\fn => _.cmd RM, BIN
|
||||
\fn => _.cmd RM, BIN, LIB
|
||||
|
||||
with public target 'bin'
|
||||
\depends BIN
|
||||
|
||||
with public target 'lib'
|
||||
\depends LIB_LUA
|
||||
\depends LIB_LUA, LIB
|
||||
|
||||
with target BIN, pattern: 'out/%'
|
||||
\depends 'bin/%.lua'
|
||||
\depends LIB_LUA
|
||||
\produces 'out/%'
|
||||
\mkdirs!
|
||||
\fn =>
|
||||
_.cmd AMALG, '-o', @outfile, '-s', @infile, MODULES
|
||||
_.writefile @outfile, "#!/usr/bin/env #{LUA}\n#{_.readfile @outfile}"
|
||||
_.cmd 'chmod', '+x', @outfile
|
||||
_.writefile @out, "#!/usr/bin/env #{LUA}\n#{_.readfile @infile}"
|
||||
_.cmd 'chmod', '+x', @out
|
||||
|
||||
with target 'out/moonbuild.lua'
|
||||
with target LIB
|
||||
\depends 'moonbuild/init.lua'
|
||||
\depends LIB_LUA
|
||||
\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'
|
||||
\depends '%.moon'
|
||||
\produces '%.lua'
|
||||
\fn => _.moonc @infile, @outfile
|
||||
\fn => _.moonc @infile, @out
|
||||
|
||||
@@ -16,27 +16,27 @@ MODULES = $(shell echo $(foreach lib, $(LIB_LUA), $(patsubst %.lua, %, $(lib)))
|
||||
|
||||
all: bin lib
|
||||
|
||||
install: all
|
||||
sudo cp out/moonbuild /usr/local/bin/moonbuild
|
||||
|
||||
clean:
|
||||
$(RM) $(LIB_LUA)
|
||||
$(RM) $(BIN_LUA)
|
||||
|
||||
mrproper: clean
|
||||
$(RM) $(BIN)
|
||||
$(RM) $(BIN) out/moonbuild.lua
|
||||
|
||||
bin: $(BIN)
|
||||
|
||||
lib: $(LIB_LUA)
|
||||
lib: $(LIB_LUA) out/moonbuild.lua
|
||||
|
||||
out/%: bin/%.lua $(LIB_LUA)
|
||||
@mkdir -p `dirname $@`
|
||||
$(AMALG) -o $@.body -s $< $(MODULES)
|
||||
@printf '#!/usr/bin/env %s\n' $(LUA) > $@.headline
|
||||
@cat $@.headline $@.body > $@
|
||||
@rm $@.headline $@.body
|
||||
@cat $@.headline $< > $@
|
||||
@rm $@.headline
|
||||
chmod +x $@
|
||||
|
||||
out/moonbuild.lua: moonbuild/init.lua $(LIB_LUA)
|
||||
@mkdir -p `dirname $@`
|
||||
$(AMALG) -o $@ -s $< $(MODULES)
|
||||
|
||||
%.lua: %.moon
|
||||
moonc $^
|
||||
|
||||
@@ -24,8 +24,13 @@ You will need `argparse` and `moonscript` installed from luarocks, and `luaposix
|
||||
|
||||
### Bootstrapping
|
||||
You can build moonbuild with itself: `moon bin/moonbuild.moon -qjy`.
|
||||
This will leave the binary ready to be used as `out/moonbuild`.
|
||||
This will leave the binary ready to be used as `out/moonbuild` (it will still depend on the library to be used).
|
||||
The binary and library can then be installed with `bin/moonbuild install`.
|
||||
|
||||
You can combine these steps with `moon bin/moonbuild.moon -qjy install` which will build and install moonbuild.
|
||||
|
||||
### With `Alfons`
|
||||
Alfons can use the devel version of moonbuild directly from its sources, so `alfons build` and `alfons install` will work directly.
|
||||
|
||||
## Docs
|
||||
TODO
|
||||
|
||||
+4
-6
@@ -1,15 +1,13 @@
|
||||
-- load everything we need
|
||||
import loadfile from require 'moonscript.base'
|
||||
Context = require 'moonbuild.context'
|
||||
Variable = require 'moonbuild.core.Variable'
|
||||
DepGraph = require 'moonbuild.core.DAG'
|
||||
Executor = require 'moonbuild.core.executor'
|
||||
import parseargs from require 'moonbuild._cmd.common'
|
||||
import Context, DepGraph, Executor from require 'moonbuild'
|
||||
Variable = (require 'moonbuild')['core.Variable']
|
||||
import parseargs from (require 'moonbuild')['_cmd.common']
|
||||
argparse = require 'argparse'
|
||||
import sort, concat from table
|
||||
import exit from os
|
||||
|
||||
-- parse the arguments
|
||||
argparse = require 'argparse'
|
||||
parser = with argparse "moonbuild", "A build system in moonscript"
|
||||
\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'
|
||||
|
||||
+7
-1
@@ -17,5 +17,11 @@ cmd.backend = backend
|
||||
cmd.parseargs = parseargs
|
||||
cmd.escape = escape
|
||||
|
||||
-- derived cmd functions
|
||||
_cmd = cmd.cmd
|
||||
_cmdrst = cmd.cmdrst
|
||||
cmd.cmdline = (cmdline) -> _cmd parseargs cmdline
|
||||
cmd.cmdlinerst = (cmdline) -> _cmdrst parseargs cmdline
|
||||
|
||||
-- the library itself
|
||||
setmetatable cmd, __call: => {'cmd', 'cmdrst', 'sh'}
|
||||
setmetatable cmd, __call: => {'cmd', 'cmdrst', 'cmdline', 'cmdlinerst', 'sh'}
|
||||
|
||||
@@ -108,12 +108,12 @@ class DepNode
|
||||
ctx = setmetatable {},
|
||||
__index: (_, k) ->
|
||||
switch k
|
||||
when 'infile'
|
||||
when 'infile', 'in'
|
||||
f = first deps
|
||||
f and f.name
|
||||
when 'infiles'
|
||||
foreach deps, => @name
|
||||
when 'outfile'
|
||||
when 'outfile', 'out'
|
||||
f = first @outs
|
||||
f and f.name
|
||||
when 'outfiles'
|
||||
@@ -182,9 +182,9 @@ class DepNode
|
||||
ctx = setmetatable {},
|
||||
__index: (_, k) ->
|
||||
switch k
|
||||
when 'infile' then @ins[1]
|
||||
when 'infile', 'in' then @ins[1]
|
||||
when 'infiles' then @ins
|
||||
when 'outfile' then @outs[1]
|
||||
when 'outfile', 'out' then @outs[1]
|
||||
when 'outfiles' then @outs
|
||||
when 'name' then @name
|
||||
else error "No such field in TargetContext: #{k}"
|
||||
|
||||
@@ -4,7 +4,17 @@ class Variable
|
||||
|
||||
new: (@name, ...) =>
|
||||
@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 ...
|
||||
else
|
||||
@value = ...
|
||||
|
||||
Vendored
+1
-1
@@ -21,7 +21,7 @@ import flatten from _
|
||||
rawset env, 'var', (name, ...) ->
|
||||
var = Variable name, ...
|
||||
ctx\addvar var
|
||||
rawset varlayer, name, var.value
|
||||
rawset varlayer, var.name, var.value
|
||||
var
|
||||
|
||||
rawset env, 'target', (name, opts) ->
|
||||
|
||||
+7
-2685
File diff suppressed because it is too large
Load Diff
+2700
File diff suppressed because it is too large
Load Diff
@@ -22,5 +22,5 @@ build:
|
||||
install:
|
||||
bin:
|
||||
moonbuild: out/moonbuild
|
||||
modules:
|
||||
moonbuild: out/moonbuild.lua
|
||||
modules:
|
||||
moonbuild: out/moonbuild.lua
|
||||
|
||||
@@ -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.2.0",
|
||||
url = "git://github.com/natnat-mc/moonbuild"
|
||||
}
|
||||
version = "2.2.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.2.0",
|
||||
url = "git://github.com/natnat-mc/moonbuild"
|
||||
}
|
||||
version = "2.2.0-2"
|
||||
@@ -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.2.1",
|
||||
url = "git://github.com/natnat-mc/moonbuild"
|
||||
}
|
||||
version = "2.2.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.2.2",
|
||||
url = "git://github.com/natnat-mc/moonbuild"
|
||||
}
|
||||
version = "2.2.2-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.2.2",
|
||||
url = "git://github.com/natnat-mc/moonbuild"
|
||||
}
|
||||
version = "2.2.2-2"
|
||||
@@ -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-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.3.0",
|
||||
url = "git://github.com/natnat-mc/moonbuild"
|
||||
}
|
||||
version = "2.3.0-2"
|
||||
Reference in New Issue
Block a user