added `from`, fixes #2

alfons-task
Nathan DECHER 5 years ago
parent 7e7c834309
commit 48186658fd
  1. 7
      Build.moon
  2. 4
      README.md
  3. 8
      moonbuild.moon

@ -6,11 +6,12 @@ MAIN = "#{BINARY}.moon"
MAIN_LUA = patsubst MAIN, '%.moon', '%.lua'
OUT_C = patsubst MAIN, '%.moon', '%.lua.c'
PREFIX = env 'PREFIX', '/usr/local'
INSTALL_LOC = "#{PREFIX}/bin"
default public target 'all', deps: BINARY
public target 'install', deps: 'moonbuild', in: 'moonbuild', fn: =>
-install @infile, "#{PREFIX}/bin"
public target 'install', from: BINARY, out: INSTALL_LOC, fn: =>
-install @infile, @outfile
public target 'clean', fn: =>
-rm '-f', OUT_LUA
@ -24,7 +25,7 @@ public target 'info', fn: =>
#echo "Compiled lua:", OUT_LUA
#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'
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`.
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.
`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
- `ins`: the table of inputs
- `infile`: the first input

@ -101,7 +101,13 @@ buildscope=
insert targets, target.name
target
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
setmetatable buildscope,

Loading…
Cancel
Save