Skip to content

Commit c8c945f

Browse files
committed
add makefile equivalent for making dist/moon
1 parent fb690d6 commit c8c945f

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

.github/workflows/binaries.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ jobs:
3838
gcc -static -o dist/moon -Ilua-${{ matrix.lua_version }}/src/ bin/binaries/moon.c lpeg-1.0.2/lpvm.c lpeg-1.0.2/lpcap.c lpeg-1.0.2/lptree.c lpeg-1.0.2/lpcode.c lpeg-1.0.2/lpprint.c lua-${{ matrix.lua_version }}/src/liblua.a -lm -ldl
3939
4040
- name: Test run
41-
run: dist/moon -e 'print "hello world"'
41+
run: |
42+
dist/moon -h
43+
dist/moon -e 'print "hello world"'
4244
4345
- name: Upload artifact
4446
uses: actions/upload-artifact@v6
@@ -85,7 +87,9 @@ jobs:
8587
gcc -static -o dist/moon.exe -Ilua-${{ matrix.lua_version }}/src/ bin/binaries/moon.c lpeg-1.0.2/lpvm.c lpeg-1.0.2/lpcap.c lpeg-1.0.2/lptree.c lpeg-1.0.2/lpcode.c lpeg-1.0.2/lpprint.c lua-${{ matrix.lua_version }}/src/liblua.a -lm
8688
8789
- name: Test run
88-
run: dist/moon.exe -e 'print "hello world"'
90+
run: |
91+
dist/moon.exe -h
92+
dist/moon.exe -e 'print "hello world"'
8993
9094
- name: Upload artifact
9195
uses: actions/upload-artifact@v6

Makefile

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ LUAROCKS = luarocks --lua-version=$(LUA_VERSION)
44
LUA_PATH_MAKE = $(shell $(LUAROCKS) path --lr-path);./?.lua;./?/init.lua
55
LUA_CPATH_MAKE = $(shell $(LUAROCKS) path --lr-cpath);./?.so
66

7-
.PHONY: test local build watch lint count show
7+
LUA_SRC_VERSION ?= 5.1.5
8+
LPEG_VERSION ?= 1.0.2
9+
10+
.PHONY: test local build watch lint count show test_binary
811

912
build:
1013
LUA_PATH='$(LUA_PATH_MAKE)' LUA_CPATH='$(LUA_CPATH_MAKE)' $(LUA) bin/moonc moon/ moonscript/
@@ -44,3 +47,21 @@ lint:
4447

4548
count:
4649
wc -l $$(git ls-files | grep 'moon$$') | sort -n | tail
50+
51+
# Binary build targets for local verification (Linux only)
52+
lua-$(LUA_SRC_VERSION)/src/liblua.a:
53+
curl -L -O https://www.lua.org/ftp/lua-$(LUA_SRC_VERSION).tar.gz
54+
tar -xzf lua-$(LUA_SRC_VERSION).tar.gz
55+
cd lua-$(LUA_SRC_VERSION)/src && make liblua.a MYCFLAGS=-DLUA_USE_POSIX
56+
57+
lpeg-$(LPEG_VERSION)/lptree.c:
58+
curl -L -o lpeg.tar.gz https://www.inf.puc-rio.br/~roberto/lpeg/lpeg-$(LPEG_VERSION).tar.gz
59+
tar -xzf lpeg.tar.gz
60+
61+
dist/moon: lua-$(LUA_SRC_VERSION)/src/liblua.a lpeg-$(LPEG_VERSION)/lptree.c
62+
mkdir -p dist
63+
gcc -static -o dist/moon -Ilua-$(LUA_SRC_VERSION)/src/ bin/binaries/moon.c lpeg-$(LPEG_VERSION)/lpvm.c lpeg-$(LPEG_VERSION)/lpcap.c lpeg-$(LPEG_VERSION)/lptree.c lpeg-$(LPEG_VERSION)/lpcode.c lpeg-$(LPEG_VERSION)/lpprint.c lua-$(LUA_SRC_VERSION)/src/liblua.a -lm -ldl
64+
65+
test_binary: dist/moon
66+
dist/moon -h
67+
dist/moon -e 'print "hello world"'

0 commit comments

Comments
 (0)