A compromise between the speed of make and the ease of use of a build script
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
moonbuild/Build.moon

35 lines
1.1 KiB

SOURCES_MOON = wildcard 'moonbuild/**.moon'
BINARY = 'bin/moonbuild.moon'
4 years ago
OUT_LUA = patsubst SOURCES_MOON, '%.moon', '%.lua'
BINARY_LUA = patsubst BINARY, '%.moon', '%.lua'
OUT_AMALG = 'moonbuild.lua'
4 years ago
public target 'clean', fn: =>
-rm '-f', OUT_LUA, BINARY_LUA
4 years ago
public target 'info', fn: =>
#echo "Moonscript sources:", SOURCES_MOON
#echo "Compiled lua:", OUT_LUA
public target 'compile', deps: OUT_AMALG
public target 'install', from: OUT_AMALG, out: '/usr/local/bin/moonbuild', fn: =>
dfd, err = io.open @outfile, 'w'
error err unless dfd
ifd, err = io.open @infile, 'r'
error err unless ifd
dfd\write '#!/usr/bin/env lua5.3\n'
for line in ifd\lines!
dfd\write line, '\n'
ifd\close!
dfd\close!
-chmod '+x', @outfile
#echo "Installed at:", @outfile
default target OUT_AMALG, from: {BINARY_LUA, OUT_LUA}, out: OUT_AMALG, fn: =>
modules = foreach (patsubst OUT_LUA, '%.lua', '%'), => @gsub '/', '.'
-Command 'amalg.lua', '-o', @outfile, '-s', 'bin/moonbuild.lua', modules
4 years ago
target '%.lua', in: '%.moon', out: '%.lua', fn: =>
-moonc @infile