mirror of
https://github.com/natnat-mc/moonbuild
synced 2026-05-22 17:51:13 +02:00
rewrote Build.moon and Makefile to actually work correctly
This commit is contained in:
+8
-8
@@ -9,6 +9,7 @@ var 'BIN_SRC', _.wildcard 'bin/*.moon'
|
|||||||
var 'LIB_LUA', _.patsubst LIB_SRC, '%.moon', '%.lua'
|
var 'LIB_LUA', _.patsubst LIB_SRC, '%.moon', '%.lua'
|
||||||
var 'BIN_LUA', _.patsubst BIN_SRC, '%.moon', '%.lua'
|
var 'BIN_LUA', _.patsubst BIN_SRC, '%.moon', '%.lua'
|
||||||
var 'BIN', _.patsubst BIN_LUA, 'bin/%.lua', 'out/%'
|
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 '/', '.'
|
||||||
|
|
||||||
@@ -21,13 +22,13 @@ with public target 'install'
|
|||||||
\after 'install-lib'
|
\after 'install-lib'
|
||||||
|
|
||||||
with public target 'install-bin'
|
with public target 'install-bin'
|
||||||
\depends 'out/moonbuild'
|
\depends BIN
|
||||||
\produces '/usr/local/bin/moonbuild'
|
\produces _.patsubst BIN, 'out/%', '/usr/local/bin/%'
|
||||||
\fn => _.cmd 'sudo', 'cp', @infile, @outfile
|
\fn => _.cmd 'sudo', 'cp', @infile, @outfile
|
||||||
\sync!
|
\sync!
|
||||||
|
|
||||||
with public target 'install-lib'
|
with public target 'install-lib'
|
||||||
\depends 'out/moonbuild.lua'
|
\depends LIB
|
||||||
\produces "/usr/local/share/lua/#{LUA\gsub 'lua', ''}/moonbuild.lua"
|
\produces "/usr/local/share/lua/#{LUA\gsub 'lua', ''}/moonbuild.lua"
|
||||||
\fn => _.cmd 'sudo', 'cp', @infile, @outfile
|
\fn => _.cmd 'sudo', 'cp', @infile, @outfile
|
||||||
\sync!
|
\sync!
|
||||||
@@ -38,13 +39,13 @@ with public target 'clean'
|
|||||||
|
|
||||||
with public target 'mrproper'
|
with public target 'mrproper'
|
||||||
\after 'clean'
|
\after 'clean'
|
||||||
\fn => _.cmd RM, BIN
|
\fn => _.cmd RM, BIN, LIB
|
||||||
|
|
||||||
with public target 'bin'
|
with public target 'bin'
|
||||||
\depends BIN
|
\depends BIN
|
||||||
|
|
||||||
with public target 'lib'
|
with public target 'lib'
|
||||||
\depends LIB_LUA
|
\depends LIB_LUA, LIB
|
||||||
|
|
||||||
with target BIN, pattern: 'out/%'
|
with target BIN, pattern: 'out/%'
|
||||||
\depends 'bin/%.lua'
|
\depends 'bin/%.lua'
|
||||||
@@ -54,12 +55,11 @@ with target BIN, pattern: 'out/%'
|
|||||||
_.writefile @outfile, "#!/usr/bin/env #{LUA}\n#{_.readfile @infile}"
|
_.writefile @outfile, "#!/usr/bin/env #{LUA}\n#{_.readfile @infile}"
|
||||||
_.cmd 'chmod', '+x', @outfile
|
_.cmd 'chmod', '+x', @outfile
|
||||||
|
|
||||||
with target 'out/moonbuild.lua'
|
with target LIB
|
||||||
\depends 'moonbuild/init.lua'
|
\depends 'moonbuild/init.lua'
|
||||||
\depends LIB_LUA
|
\depends LIB_LUA
|
||||||
\produces '%'
|
\produces '%'
|
||||||
\fn =>
|
\fn => _.cmd AMALG, '-o', @outfile, '-s', @infile, _.exclude MODULES, 'moonbuild.init'
|
||||||
_.cmd AMALG, '-o', @outfile, '-s', @infile, _.exclude MODULES, 'moonbuild.init'
|
|
||||||
|
|
||||||
with target {LIB_LUA, BIN_LUA}, pattern: '%.lua'
|
with target {LIB_LUA, BIN_LUA}, pattern: '%.lua'
|
||||||
\depends '%.moon'
|
\depends '%.moon'
|
||||||
|
|||||||
@@ -16,27 +16,27 @@ MODULES = $(shell echo $(foreach lib, $(LIB_LUA), $(patsubst %.lua, %, $(lib)))
|
|||||||
|
|
||||||
all: bin lib
|
all: bin lib
|
||||||
|
|
||||||
install: all
|
|
||||||
sudo cp out/moonbuild /usr/local/bin/moonbuild
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) $(LIB_LUA)
|
$(RM) $(LIB_LUA)
|
||||||
$(RM) $(BIN_LUA)
|
$(RM) $(BIN_LUA)
|
||||||
|
|
||||||
mrproper: clean
|
mrproper: clean
|
||||||
$(RM) $(BIN)
|
$(RM) $(BIN) out/moonbuild.lua
|
||||||
|
|
||||||
bin: $(BIN)
|
bin: $(BIN)
|
||||||
|
|
||||||
lib: $(LIB_LUA)
|
lib: $(LIB_LUA) out/moonbuild.lua
|
||||||
|
|
||||||
out/%: bin/%.lua $(LIB_LUA)
|
out/%: bin/%.lua $(LIB_LUA)
|
||||||
@mkdir -p `dirname $@`
|
@mkdir -p `dirname $@`
|
||||||
$(AMALG) -o $@.body -s $< $(MODULES)
|
|
||||||
@printf '#!/usr/bin/env %s\n' $(LUA) > $@.headline
|
@printf '#!/usr/bin/env %s\n' $(LUA) > $@.headline
|
||||||
@cat $@.headline $@.body > $@
|
@cat $@.headline $< > $@
|
||||||
@rm $@.headline $@.body
|
@rm $@.headline
|
||||||
chmod +x $@
|
chmod +x $@
|
||||||
|
|
||||||
|
out/moonbuild.lua: moonbuild/init.lua $(LIB_LUA)
|
||||||
|
@mkdir -p `dirname $@`
|
||||||
|
$(AMALG) -o $@ -s $< $(MODULES)
|
||||||
|
|
||||||
%.lua: %.moon
|
%.lua: %.moon
|
||||||
moonc $^
|
moonc $^
|
||||||
|
|||||||
Reference in New Issue
Block a user