Skip to content

anonymous class sets name slot to false to prevent breaking unpack on… #78

anonymous class sets name slot to false to prevent breaking unpack on…

anonymous class sets name slot to false to prevent breaking unpack on… #78

Workflow file for this run

name: "binaries"
on: [push]
env:
# LuaJIT has no releases; pin a commit from the v2.1 branch
LUAJIT_COMMIT: 346ab587cb235b4ef0b5777b4cd29009808d0cc0
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 embedded chunks
run: |
bin/splat.moon -x moonscript.parse.slow -x moonscript.parse.grammar moonscript moon > moonscript.lua
awk 'FNR>1' bin/moon > moon.lua
awk 'FNR>1' bin/moonc > moonc.lua
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) > argparse.lua
# Embedded chunks are precompiled to bytecode so the binaries skip
# parsing at startup. Unstripped (luac default, luajit -g) so tracebacks
# keep line numbers.
#
# 5.1 bytecode embeds endianness and type sizes; this x86_64 output
# loads on every PUC target in the matrix (all little-endian, 4-byte
# int, 8-byte size_t).
- name: Generate PUC bytecode headers
run: |
luac -v
mkdir -p headers-puc
for chunk in moonscript moon moonc argparse; do
luac -o $chunk.luac $chunk.lua
xxd -i -n ${chunk}_lua $chunk.luac > headers-puc/$chunk.h
done
- name: Build LuaJIT
run: |
curl -L -o luajit.tar.gz https://github.com/LuaJIT/LuaJIT/archive/$LUAJIT_COMMIT.tar.gz
tar -xzf luajit.tar.gz
mv LuaJIT-* luajit
make -C luajit/src -j$(nproc) amalg BUILDMODE=static
# LuaJIT bytecode is portable across architectures but tied to the
# bytecode version and GC64 mode: the pinned commit plus an all-GC64
# matrix (x64 defaults on, arm64 always on) keeps every target
# compatible with this generator build.
# LUA_PATH: -b lives in jit.bcsave, which the uninstalled binary can
# only find in the source tree
- name: Generate LuaJIT bytecode headers
run: |
mkdir -p headers-luajit
for chunk in moonscript moon moonc argparse; do
LUA_PATH="luajit/src/?.lua;;" luajit/src/luajit -bg $chunk.lua $chunk.raw
xxd -i -n ${chunk}_lua $chunk.raw > headers-luajit/$chunk.h
done
- name: Upload PUC headers
uses: actions/upload-artifact@v6
with:
name: generated-headers-puc
path: headers-puc/*.h
- name: Upload LuaJIT headers
uses: actions/upload-artifact@v6
with:
name: generated-headers-luajit
path: headers-luajit/*.h
linux:
runs-on: ${{ matrix.runner }}
needs: generate-headers
strategy:
matrix:
include:
- runner: ubuntu-latest
architecture: x86_64
artifact_suffix: ""
runtime: puc
lua_version: "5.1.5"
runtime_label: "lua5.1.5"
release_suffix: ""
lua_include: lua-5.1.5/src
lua_lib: lua-5.1.5/src/liblua.a
- runner: ubuntu-latest
architecture: x86_64
artifact_suffix: ""
runtime: luajit
runtime_label: "luajit2.1"
release_suffix: "-luajit"
lua_include: luajit/src
lua_lib: luajit/src/libluajit.a
- runner: ubuntu-24.04-arm
architecture: arm64
artifact_suffix: "-arm64"
runtime: puc
lua_version: "5.1.5"
runtime_label: "lua5.1.5"
release_suffix: ""
lua_include: lua-5.1.5/src
lua_lib: lua-5.1.5/src/liblua.a
- runner: ubuntu-24.04-arm
architecture: arm64
artifact_suffix: "-arm64"
runtime: luajit
runtime_label: "luajit2.1"
release_suffix: "-luajit"
lua_include: luajit/src
lua_lib: luajit/src/libluajit.a
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
# commit time, not wall clock, so identical inputs build identical binaries
echo "BUILD_TIME=$(git show -s --format=%cI HEAD)" >> $GITHUB_ENV
- name: Download headers
uses: actions/download-artifact@v4
with:
name: generated-headers-${{ matrix.runtime }}
path: bin/binaries/
- name: Show GCC
run: gcc -v
- name: Setup Lua
if: matrix.runtime == 'puc'
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: Setup LuaJIT
if: matrix.runtime == 'luajit'
run: |
curl -L -o luajit.tar.gz https://github.com/LuaJIT/LuaJIT/archive/$LUAJIT_COMMIT.tar.gz
tar -xzf luajit.tar.gz
mv LuaJIT-* luajit
make -C luajit/src -j$(nproc) amalg BUILDMODE=static
- 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 \
-I${{ matrix.lua_include }} \
-Ilpeg-1.0.2/ \
-Ibin/binaries/ \
-DMOON_BUILD_COMMIT="\"${{ env.VERSION_SUFFIX }}\"" \
-DMOON_BUILD_TIME="\"${{ env.BUILD_TIME }}\"" \
bin/binaries/moon.c \
bin/binaries/moonscript.c \
moonscript/parse/native.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 \
${{ matrix.lua_lib }} \
-lm -ldl
gcc -static -o dist/moonc \
-I${{ matrix.lua_include }} \
-Ilpeg-1.0.2/ \
-Ibin/binaries/ \
-DMOON_BUILD_COMMIT="\"${{ env.VERSION_SUFFIX }}\"" \
-DMOON_BUILD_TIME="\"${{ env.BUILD_TIME }}\"" \
bin/binaries/moonc.c \
bin/binaries/moonscript.c \
moonscript/parse/native.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 \
${{ matrix.lua_lib }} \
-lm -ldl
- name: Test run
run: |
dist/moon -h
dist/moon -e 'print "hello world"'
dist/moonc -h
- name: Test JIT
if: matrix.runtime == 'luajit'
run: dist/moon -e 'print jit.version'
- name: Upload artifact
uses: actions/upload-artifact@v6
with:
name: moonscript-${{ env.VERSION_SUFFIX }}-linux-${{ matrix.runtime_label }}${{ matrix.artifact_suffix }}
path: dist/
- name: Package for release
if: github.ref_type == 'tag'
run: |
cd dist
tar -czvf ../moonscript-${{ env.VERSION_SUFFIX }}-linux-${{ matrix.architecture }}${{ matrix.release_suffix }}.tar.gz *
- name: Upload to release
if: github.ref_type == 'tag'
uses: softprops/action-gh-release@v2
with:
files: moonscript-${{ env.VERSION_SUFFIX }}-linux-${{ matrix.architecture }}${{ matrix.release_suffix }}.tar.gz
windows:
runs-on: windows-latest
needs: generate-headers
strategy:
matrix:
include:
- runtime: puc
lua_version: "5.1.5"
runtime_label: "lua5.1.5"
release_suffix: ""
msys_install: gcc make curl zip
lua_include: lua-5.1.5/src
lua_lib: lua-5.1.5/src/liblua.a
- runtime: luajit
runtime_label: "luajit2.1"
release_suffix: "-luajit"
msys_install: make curl zip mingw-w64-x86_64-gcc
lua_include: luajit/src
lua_lib: luajit/src/libluajit.a
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@master
- name: Download headers
uses: actions/download-artifact@v4
with:
name: generated-headers-${{ matrix.runtime }}
path: bin/binaries/
- uses: msys2/setup-msys2@v2
with:
install: ${{ matrix.msys_install }}
- 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
# commit time, not wall clock, so identical inputs build identical binaries
echo "BUILD_TIME=$(git show -s --format=%cI HEAD)" >> $GITHUB_ENV
- name: Show GCC
run: gcc -v
- name: Setup Lua
if: matrix.runtime == 'puc'
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: Setup LuaJIT
if: matrix.runtime == 'luajit'
run: |
curl -L -o luajit.tar.gz https://github.com/LuaJIT/LuaJIT/archive/$LUAJIT_COMMIT.tar.gz
tar -xzf luajit.tar.gz
mv LuaJIT-* luajit
make -C luajit/src -j$(nproc) amalg BUILDMODE=static
- 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 \
-I${{ matrix.lua_include }} \
-Ilpeg-1.0.2/ \
-Ibin/binaries/ \
-DMOON_BUILD_COMMIT="\"${{ env.VERSION_SUFFIX }}\"" \
-DMOON_BUILD_TIME="\"${{ env.BUILD_TIME }}\"" \
bin/binaries/moon.c \
bin/binaries/moonscript.c \
moonscript/parse/native.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 \
${{ matrix.lua_lib }} \
-lm
gcc -static -o dist/moonc.exe \
-I${{ matrix.lua_include }} \
-Ilpeg-1.0.2/ \
-Ibin/binaries/ \
-DMOON_BUILD_COMMIT="\"${{ env.VERSION_SUFFIX }}\"" \
-DMOON_BUILD_TIME="\"${{ env.BUILD_TIME }}\"" \
bin/binaries/moonc.c \
bin/binaries/moonscript.c \
moonscript/parse/native.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 \
${{ matrix.lua_lib }} \
-lm
- name: Test run
run: |
dist/moon.exe -h
dist/moon.exe -e 'print "hello world"'
dist/moonc.exe -h
- name: Test JIT
if: matrix.runtime == 'luajit'
run: dist/moon.exe -e 'print jit.version'
- name: Upload artifact
uses: actions/upload-artifact@v6
with:
name: moonscript-${{ env.VERSION_SUFFIX }}-windows-${{ matrix.runtime_label }}
path: dist/
- name: Package for release
if: github.ref_type == 'tag'
run: |
cd dist
zip ../moonscript-${{ env.VERSION_SUFFIX }}-windows-x86_64${{ matrix.release_suffix }}.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${{ matrix.release_suffix }}.zip