-
Notifications
You must be signed in to change notification settings - Fork 195
254 lines (214 loc) · 7.01 KB
/
binaries.yml
File metadata and controls
254 lines (214 loc) · 7.01 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
name: "binaries"
on: [push]
jobs:
generate-headers:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: leafo/gh-actions-lua@master
with:
luaVersion: "5.1"
- uses: leafo/gh-actions-luarocks@master
- name: Install dependencies
run: |
luarocks install argparse
luarocks make
- name: Generate moonscript.h
run: |
bin/splat.moon -l moonscript moonscript moon > moonscript.lua
xxd -i moonscript.lua > bin/binaries/moonscript.h
- name: Generate moon.h
run: |
awk 'FNR>1' bin/moon > moon.lua
xxd -i moon.lua > bin/binaries/moon.h
- name: Generate argparse.h
run: |
luarocks install argparse --tree=lua_modules
bin/splat.moon --strip-prefix -l argparse $(find lua_modules/share/lua -name "argparse.lua" -exec dirname {} \; | head -1) > bin/binaries/argparse.lua
xxd -i -n argparse_lua bin/binaries/argparse.lua > bin/binaries/argparse.h
- name: Generate moonc.h
run: |
awk 'FNR>1' bin/moonc > moonc.lua
xxd -i moonc.lua > bin/binaries/moonc.h
- name: Upload headers
uses: actions/upload-artifact@v6
with:
name: generated-headers
path: bin/binaries/*.h
linux:
runs-on: ubuntu-latest
needs: generate-headers
strategy:
matrix:
lua_version: ["5.1.5"]
steps:
- uses: actions/checkout@master
- name: Set version suffix
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
echo "VERSION_SUFFIX=${{ github.ref_name }}" >> $GITHUB_ENV
else
echo "VERSION_SUFFIX=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
fi
- name: Download headers
uses: actions/download-artifact@v4
with:
name: generated-headers
path: bin/binaries/
- name: Show GCC
run: gcc -v
- name: Setup Lua
run: |
curl -L -O https://www.lua.org/ftp/lua-${{ matrix.lua_version }}.tar.gz
tar -xzf lua-${{ matrix.lua_version }}.tar.gz
cd lua-${{ matrix.lua_version }}/src && make liblua.a MYCFLAGS=-DLUA_USE_POSIX
- name: Get LPeg
run: |
curl -L -o lpeg.tar.gz https://www.inf.puc-rio.br/~roberto/lpeg/lpeg-1.0.2.tar.gz
tar -xzf lpeg.tar.gz
- name: Get Luafilesystem
run: |
curl -L -o luafilesystem.tar.gz https://github.com/keplerproject/luafilesystem/archive/v1_8_0.tar.gz
tar -xzf luafilesystem.tar.gz
- name: Build
run: |
mkdir -p dist
gcc -static -o dist/moon \
-Ilua-${{ matrix.lua_version }}/src/ \
-Ilpeg-1.0.2/ \
-Ibin/binaries/ \
bin/binaries/moon.c \
bin/binaries/moonscript.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
gcc -static -o dist/moonc \
-Ilua-${{ matrix.lua_version }}/src/ \
-Ilpeg-1.0.2/ \
-Ibin/binaries/ \
bin/binaries/moonc.c \
bin/binaries/moonscript.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 \
luafilesystem-1_8_0/src/lfs.c \
lua-${{ matrix.lua_version }}/src/liblua.a \
-lm -ldl
- name: Test run
run: |
dist/moon -h
dist/moon -e 'print "hello world"'
dist/moonc -h
- name: Upload artifact
uses: actions/upload-artifact@v6
with:
name: moonscript-${{ env.VERSION_SUFFIX }}-linux-lua${{ matrix.lua_version }}
path: dist/
- name: Package for release
if: github.ref_type == 'tag'
run: |
cd dist
tar -czvf ../moonscript-${{ env.VERSION_SUFFIX }}-linux-x86_64.tar.gz *
- name: Upload to release
if: github.ref_type == 'tag'
uses: softprops/action-gh-release@v2
with:
files: moonscript-${{ env.VERSION_SUFFIX }}-linux-x86_64.tar.gz
windows:
runs-on: windows-latest
needs: generate-headers
strategy:
matrix:
lua_version: ["5.1.5"]
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@master
- name: Download headers
uses: actions/download-artifact@v4
with:
name: generated-headers
path: bin/binaries/
- uses: msys2/setup-msys2@v2
with:
install: gcc make curl zip
- name: Set version suffix
shell: bash
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
echo "VERSION_SUFFIX=${{ github.ref_name }}" >> $GITHUB_ENV
else
echo "VERSION_SUFFIX=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
fi
- name: Show GCC
run: gcc -v
- name: Setup Lua
run: |
curl -L -O https://www.lua.org/ftp/lua-${{ matrix.lua_version }}.tar.gz
tar -xzf lua-${{ matrix.lua_version }}.tar.gz
cd lua-${{ matrix.lua_version }}/src && make liblua.a
- name: Get LPeg
run: |
curl -L -o lpeg.tar.gz https://www.inf.puc-rio.br/~roberto/lpeg/lpeg-1.0.2.tar.gz
tar -xzf lpeg.tar.gz
- name: Get Luafilesystem
run: |
curl -L -o luafilesystem.tar.gz https://github.com/keplerproject/luafilesystem/archive/v1_8_0.tar.gz
tar -xzf luafilesystem.tar.gz
- name: Build
run: |
mkdir -p dist
gcc -static -o dist/moon.exe \
-Ilua-${{ matrix.lua_version }}/src/ \
-Ilpeg-1.0.2/ \
-Ibin/binaries/ \
bin/binaries/moon.c \
bin/binaries/moonscript.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
gcc -static -o dist/moonc.exe \
-Ilua-${{ matrix.lua_version }}/src/ \
-Ilpeg-1.0.2/ \
-Ibin/binaries/ \
bin/binaries/moonc.c \
bin/binaries/moonscript.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 \
luafilesystem-1_8_0/src/lfs.c \
lua-${{ matrix.lua_version }}/src/liblua.a \
-lm
- name: Test run
run: |
dist/moon.exe -h
dist/moon.exe -e 'print "hello world"'
dist/moonc.exe -h
- name: Upload artifact
uses: actions/upload-artifact@v6
with:
name: moonscript-${{ env.VERSION_SUFFIX }}-windows-lua${{ matrix.lua_version }}
path: dist/
- name: Package for release
if: github.ref_type == 'tag'
run: |
cd dist
zip ../moonscript-${{ env.VERSION_SUFFIX }}-windows-x86_64.zip *
- name: Upload to release
if: github.ref_type == 'tag'
uses: softprops/action-gh-release@v2
with:
files: moonscript-${{ env.VERSION_SUFFIX }}-windows-x86_64.zip