-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuild.moon
62 lines (51 loc) · 1.54 KB
/
Build.moon
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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_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 '/', '.'
with public default target 'all'
\after 'bin'
\after 'lib'
with public target 'install'
\after 'install-bin'
\after 'install-lib'
with public target 'install-bin'
\depends BIN
\produces _.patsubst BIN, 'out/%', '/usr/local/bin/%'
\fn => _.cmd 'sudo', 'cp', @infile, @out
\sync!
with public target 'install-lib'
\depends LIB
\produces "/usr/local/share/lua/#{LUA\gsub 'lua', ''}/moonbuild.lua"
\fn => _.cmd 'sudo', 'cp', @infile, @out
\sync!
with public target 'clean'
\fn => _.cmd RM, LIB_LUA
\fn => _.cmd RM, BIN_LUA
with public target 'mrproper'
\after 'clean'
\fn => _.cmd RM, BIN, LIB
with pipeline! -- lib
\sources LIB_SRC
\step 'compile-lib'
pattern: {'%.moon', '%.lua'}
fn: => _.moonc @infile, @out
\step 'lib'
output: LIB
fn: => _.cmd AMALG, '-o', @out, '-s', 'moonbuild/init.lua', _.exclude MODULES, 'moonbuild.init'
with pipeline! -- bin
\sources BIN_SRC
\step 'compile-bin'
pattern: {'%.moon', '%.lua'}
fn: => _.moonc @infile, @out
\step 'bin'
pattern: {'bin/%.lua', 'out/%'}
mkdirs: true
fn: =>
_.writefile @out, "#!/usr/bin/env #{LUA}\n#{_.readfile @infile}"
_.cmd 'chmod', '+x', @out