Skip to content

Commit 57009b1

Browse files
committed
get moonc buildin
1 parent bf965ef commit 57009b1

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

Makefile

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ LUA_CPATH_MAKE = $(shell $(LUAROCKS) path --lr-cpath);./?.so
66

77
LUA_SRC_VERSION ?= 5.1.5
88
LPEG_VERSION ?= 1.0.2
9+
LFS_VERSION ?= 1_8_0
910

1011
.PHONY: test local build watch lint count show test_binary
1112

@@ -61,6 +62,10 @@ lpeg-$(LPEG_VERSION)/lptree.c:
6162
curl -L -o lpeg.tar.gz https://www.inf.puc-rio.br/~roberto/lpeg/lpeg-$(LPEG_VERSION).tar.gz
6263
tar -xzf lpeg.tar.gz
6364

65+
luafilesystem-$(LFS_VERSION)/src/lfs.c:
66+
curl -L -o luafilesystem.tar.gz https://github.com/keplerproject/luafilesystem/archive/v$(LFS_VERSION).tar.gz
67+
tar -xzf luafilesystem.tar.gz
68+
6469
bin/binaries/moonscript.h: moonscript/*.lua moon/*.lua
6570
bin/splat.moon -l moonscript moonscript moon > moonscript.lua
6671
xxd -i moonscript.lua > $@
@@ -75,7 +80,12 @@ bin/binaries/argparse.h: lua_modules
7580
bin/splat.moon --strip-prefix -l argparse $$(find lua_modules/share/lua -name "argparse.lua" -exec dirname {} \; | head -1) > bin/binaries/argparse.lua
7681
xxd -i -n argparse_lua bin/binaries/argparse.lua > $@
7782

78-
dist/moon: lua-$(LUA_SRC_VERSION)/src/liblua.a lpeg-$(LPEG_VERSION)/lptree.c bin/binaries/moonscript.h bin/binaries/moon.h bin/binaries/argparse.h
83+
bin/binaries/moonc.h: bin/moonc
84+
awk 'FNR>1' bin/moonc > moonc.lua
85+
xxd -i moonc.lua > $@
86+
rm moonc.lua
87+
88+
dist/moon: lua-$(LUA_SRC_VERSION)/src/liblua.a lpeg-$(LPEG_VERSION)/lptree.c bin/binaries/moonscript.h bin/binaries/moon.h bin/binaries/argparse.h bin/binaries/moon.c bin/binaries/moonscript.c
7989
mkdir -p dist
8090
gcc -static -o dist/moon \
8191
-Ilua-$(LUA_SRC_VERSION)/src/ \
@@ -91,5 +101,22 @@ dist/moon: lua-$(LUA_SRC_VERSION)/src/liblua.a lpeg-$(LPEG_VERSION)/lptree.c bin
91101
lua-$(LUA_SRC_VERSION)/src/liblua.a \
92102
-lm -ldl
93103

104+
dist/moonc: lua-$(LUA_SRC_VERSION)/src/liblua.a lpeg-$(LPEG_VERSION)/lptree.c luafilesystem-$(LFS_VERSION)/src/lfs.c bin/binaries/moonscript.h bin/binaries/moonc.h bin/binaries/argparse.h bin/binaries/moonc.c bin/binaries/moonscript.c
105+
mkdir -p dist
106+
gcc -static -o dist/moonc \
107+
-Ilua-$(LUA_SRC_VERSION)/src/ \
108+
-Ilpeg-$(LPEG_VERSION)/ \
109+
-Ibin/binaries/ \
110+
bin/binaries/moonc.c \
111+
bin/binaries/moonscript.c \
112+
lpeg-$(LPEG_VERSION)/lpvm.c \
113+
lpeg-$(LPEG_VERSION)/lpcap.c \
114+
lpeg-$(LPEG_VERSION)/lptree.c \
115+
lpeg-$(LPEG_VERSION)/lpcode.c \
116+
lpeg-$(LPEG_VERSION)/lpprint.c \
117+
luafilesystem-$(LFS_VERSION)/src/lfs.c \
118+
lua-$(LUA_SRC_VERSION)/src/liblua.a \
119+
-lm -ldl
120+
94121
test_binary: dist/moon
95122
dist/moon

bin/splat.moon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env moon
22
argparse = require "argparse"
33

4+
-- TODO: it would be cool if you could just point this at a luarocks tree, pass a list of top level module names, and it figures it out for you.
5+
-- Perhaps even merge the header generation into here as well to avoid using xxd
6+
47
normalize = (path) ->
58
path\match("(.-)/*$").."/"
69

0 commit comments

Comments
 (0)