mirror of
https://github.com/natnat-mc/moonbuild
synced 2026-06-11 23:49:40 +02:00
added from, fixes #2
This commit is contained in:
+4
-3
@@ -6,11 +6,12 @@ MAIN = "#{BINARY}.moon"
|
|||||||
MAIN_LUA = patsubst MAIN, '%.moon', '%.lua'
|
MAIN_LUA = patsubst MAIN, '%.moon', '%.lua'
|
||||||
OUT_C = patsubst MAIN, '%.moon', '%.lua.c'
|
OUT_C = patsubst MAIN, '%.moon', '%.lua.c'
|
||||||
PREFIX = env 'PREFIX', '/usr/local'
|
PREFIX = env 'PREFIX', '/usr/local'
|
||||||
|
INSTALL_LOC = "#{PREFIX}/bin"
|
||||||
|
|
||||||
default public target 'all', deps: BINARY
|
default public target 'all', deps: BINARY
|
||||||
|
|
||||||
public target 'install', deps: 'moonbuild', in: 'moonbuild', fn: =>
|
public target 'install', from: BINARY, out: INSTALL_LOC, fn: =>
|
||||||
-install @infile, "#{PREFIX}/bin"
|
-install @infile, @outfile
|
||||||
|
|
||||||
public target 'clean', fn: =>
|
public target 'clean', fn: =>
|
||||||
-rm '-f', OUT_LUA
|
-rm '-f', OUT_LUA
|
||||||
@@ -24,7 +25,7 @@ public target 'info', fn: =>
|
|||||||
#echo "Compiled lua:", OUT_LUA
|
#echo "Compiled lua:", OUT_LUA
|
||||||
#echo "Binary:", BINARY
|
#echo "Binary:", BINARY
|
||||||
|
|
||||||
target BINARY, out: {BINARY, OUT_C}, in: OUT_LUA, deps: OUT_LUA, fn: =>
|
target BINARY, out: {BINARY, OUT_C}, from: OUT_LUA, fn: =>
|
||||||
-luastatic MAIN_LUA, OUT_LUA, '-I/usr/include/lua5.3', '-llua5.3'
|
-luastatic MAIN_LUA, OUT_LUA, '-I/usr/include/lua5.3', '-llua5.3'
|
||||||
|
|
||||||
foreach OUT_LUA, (file) ->
|
foreach OUT_LUA, (file) ->
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ First, you'll need a `Build.moon`, `Buildfile.moon`, `Build` or `Buildfile` in t
|
|||||||
Then, you'll need a few `target`s, and ideally a `default target` (or the default target will be `all`). `public target`s will be listed by `moonbuild -l`.
|
Then, you'll need a few `target`s, and ideally a `default target` (or the default target will be `all`). `public target`s will be listed by `moonbuild -l`.
|
||||||
To execute a command, you can use either `-cmd` or `#cmd` (the former will print it before executing it, the later won't).
|
To execute a command, you can use either `-cmd` or `#cmd` (the former will print it before executing it, the later won't).
|
||||||
|
|
||||||
### `[default] [public] target <name> [deps: <deps>] [in: <inputs>] [out: <outputs>] [fn: <code>]`
|
### `[default] [public] target <name> [deps: <deps>] [in: <inputs>] [out: <outputs>] [from: <from>] [fn: <code>]`
|
||||||
Define a new target, and give it a list of depenancies, inputs, outputs and a function to run to build it.
|
Define a new target, and give it a list of depenancies, inputs, outputs and a function to run to build it.
|
||||||
|
|
||||||
`deps`, `in` and `out` can be either strings or tables. `name` must be a string and `code` must be a function, that will be given a table with the following fields:
|
`deps`, `in` and `out` can be either strings or tables. `from` acts like both `in` and `deps`. `name` must be a string and `code` must be a function, that will be given a table with the following fields:
|
||||||
- `name`: the name of the target
|
- `name`: the name of the target
|
||||||
- `ins`: the table of inputs
|
- `ins`: the table of inputs
|
||||||
- `infile`: the first input
|
- `infile`: the first input
|
||||||
|
|||||||
+7
-1
@@ -101,7 +101,13 @@ buildscope=
|
|||||||
insert targets, target.name
|
insert targets, target.name
|
||||||
target
|
target
|
||||||
target: (name, params) ->
|
target: (name, params) ->
|
||||||
BuildObject name, (flatten params.out), (flatten params.in), (flatten params.deps), params.fn
|
tout=flatten params.out
|
||||||
|
tin=flatten params.in
|
||||||
|
tdeps=flatten params.deps
|
||||||
|
for f in *flatten params.from
|
||||||
|
insert tin, f
|
||||||
|
insert tdeps, f
|
||||||
|
BuildObject name, tout, tin, tdeps, params.fn
|
||||||
buildscope[k]=fn for k, fn in pairs util
|
buildscope[k]=fn for k, fn in pairs util
|
||||||
|
|
||||||
setmetatable buildscope,
|
setmetatable buildscope,
|
||||||
|
|||||||
Reference in New Issue
Block a user