Skip to content

Commit fdba2d0

Browse files
committed
Rename binaries to build-binaries
1 parent fb9910b commit fdba2d0

2 files changed

Lines changed: 162 additions & 82 deletions

File tree

.github/workflows/binaries.yml

Lines changed: 0 additions & 82 deletions
This file was deleted.
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
name: "build-binaries"
2+
3+
on: [workflow_dispatch]
4+
5+
jobs:
6+
build:
7+
strategy:
8+
matrix:
9+
os:
10+
- runner: ubuntu-latest
11+
shell: bash
12+
plat: linux
13+
gcc-flags: -fpic -O2
14+
moonc: moonc
15+
moon: moon
16+
artifact: gmod-moonscript-linux
17+
18+
- runner: windows-latest
19+
shell: cmd
20+
plat: mingw
21+
gcc-flags: -O2
22+
moonc: moonc.exe
23+
moon: moon.exe
24+
artifact: gmod-moonscript-windows
25+
26+
name: Build Moonscript Binaries (${{matrix.os.runner}})
27+
runs-on: ${{matrix.os.runner}}
28+
defaults:
29+
run:
30+
shell: ${{matrix.os.shell}}
31+
steps:
32+
33+
# Checkout the git repository.
34+
- name: Checkout gmod-moonscript
35+
uses: actions/checkout@v4
36+
37+
# CD to the workspace
38+
- name: CD Workspace
39+
run: cd $GITHUB_WORKSPACE
40+
41+
# Install dependencies for Linux
42+
- name: Install dependencies (Linux)
43+
if: ${{matrix.os.runner}} == 'ubuntu-latest'
44+
run: |
45+
sudo apt-get update
46+
sudo apt-get install gzip xz-utils libreadline-dev tree -y
47+
48+
# Install dependencies for Windows
49+
- name: Install dependencies (Windows)
50+
if: ${{matrix.os.runner}} == 'windows-latest'
51+
uses: msys2/setup-msys2@v2
52+
with:
53+
install: gcc make curl vim
54+
55+
# Output GCC version for debugging purposes.
56+
- name: Show GCC
57+
run: gcc -v
58+
59+
# Download the latest gmod-moonscript compiler to bootstrap the new version.
60+
- name: Install latest gmod-moonscript compiler
61+
uses: robinraju/release-downloader@v1
62+
with:
63+
repository: ${{github.repository}}
64+
latest: true
65+
fileName: '${{matrix.os.artifact}}.zip'
66+
out-file-path: 'bin/binaries/latest-compiler'
67+
extract: true
68+
69+
# Output the tree of the downloaded compiler.
70+
- name: Display compiler tree
71+
run: tree bin/binaries/latest-compiler
72+
73+
# Hop into the binaries folder to fetch moonscript dependencies.
74+
- name: CD Binaries folder
75+
run: cd bin/binaries
76+
77+
# Download and compile Lua 5.1.5
78+
- name: Setup Lua
79+
run: |
80+
curl -O https://www.lua.org/ftp/lua-5.1.5.tar.gz
81+
tar -xzf lua-5.1.5.tar.gz
82+
cd lua-5.1.5
83+
make PLAT=${{matrix.os.plat}}
84+
"src/lua" -v
85+
cd ..
86+
87+
# Download and decompress LPeg
88+
- name: Setup LPeg
89+
run: |
90+
curl -L http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-1.0.2.tar.gz > lpeg.tar.gz
91+
tar -xzf lpeg.tar.gz
92+
93+
# Download and compile LuaFileSystem
94+
- name: Setup LuaFileSystem
95+
run: |
96+
curl -L -o luafilesystem.tar.gz https://github.com/keplerproject/luafilesystem/archive/v1_8_0.tar.gz
97+
tar -xzf luafilesystem.tar.gz
98+
mv luafilesystem-1_8_0/ luafilesystem/
99+
cd luafilesystem
100+
gcc -O2 -Wall -fPIC -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -pedantic -I../lua-5.1.5/src/ -c -o src/lfs.o src/lfs.c
101+
cd ..
102+
103+
104+
# Generate headers required to build moonscript.
105+
- name: Generate headers
106+
run: |
107+
cd ../..
108+
echo Generating moonscript.h
109+
"bin/binaries/latest-compiler/${{matrix.os.artifact}}/moon" bin/splat.moon -l moonscript moonscript moon > bin/binaries/moonscript.lua
110+
cd bin/binaries
111+
rm -fv moonscript.h
112+
xxd -i moonscript.lua > moonscript.h
113+
rm -fv moonscript.lua
114+
115+
echo Generating moon.h
116+
cd ..
117+
awk "FNR>1" moon > binaries/moon.lua
118+
cd binaries
119+
xxd -i moon.lua > moon.h
120+
rm -fv moon.lua
121+
122+
echo Generating moonc.h
123+
cd ..
124+
awk "FNR>1" moonc > binaries/moonc.lua
125+
cd binaries
126+
xxd -i moonc.lua > moonc.h
127+
rm -fv moonc.lua
128+
129+
echo Generating alt_getopt.h
130+
rm -fv alt_getopt.h
131+
xxd -i alt_getopt.lua > alt_getopt.h
132+
133+
echo Generating argparse.h
134+
rm -fv argparse.h
135+
xxd -i argparse.lua > argparse.h
136+
137+
# Create build output directory
138+
- name: Make build output directory
139+
run: mkdir build-output
140+
141+
# Build the moon executable.
142+
- name: Build moon executable
143+
run: gcc ${{matrix.os.gcc-flags}} -Ilua-5.1.5/src/ -I/ -Llua-5.1.5/src/ 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 luafilesystem/src/lfs.o -l:liblua.a -lm -o build-output/${{matrix.os.moon}}
144+
145+
# Build the moon compiler executable.
146+
- name: Build moonc executable
147+
run: gcc ${{matrix.os.gcc-flags}} -Ilua-5.1.5/src/ -I/ -Llua-5.1.5/src/ moonc.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/src/lfs.o -l:liblua.a -lm -o build-output/${{matrix.os.moonc}}
148+
149+
# Archive the moon and moonc executables.
150+
- name: Archive moon & moonc executables
151+
uses: ihiroky/archive-action@v1
152+
with:
153+
root_dir: bin/binaries/build-output
154+
file_path: ${{matrix.os.artifact}}.zip
155+
verbose: true
156+
157+
# Upload them as artifacts
158+
- name: Upload build artifacts
159+
uses: actions/upload-artifact@v4
160+
with:
161+
name: ${{matrix.os.artifact}}
162+
path: ${{matrix.os.artifact}}.zip

0 commit comments

Comments
 (0)