Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/luac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Lua compiler
on:
push:
branches:
- 'main'
- '[0-9]+.[0-9]+'
paths:
- 'radio/src/thirdparty/Lua/**'
- '.github/workflows/luac.yml'
pull_request:
paths:
- 'radio/src/thirdparty/Lua/**'
- '.github/workflows/luac.yml'
workflow_dispatch:

jobs:
build:
name: Build edgetx-luac (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- name: Check out the repo
uses: actions/checkout@v7

- name: Build
run: |
cmake -S radio/src/thirdparty/Lua -B build-luac -DCMAKE_BUILD_TYPE=Release
cmake --build build-luac --config Release

- name: Compile a script and check the bytecode header
run: |
LUAC=$(find build-luac -type f \( -name edgetx-luac -o -name edgetx-luac.exe \) | head -1)
cat > ok.lua <<'EOF'
local t = { 1, 2, 3 }
return { run = function() return #t + 0.5 end }
EOF
"$LUAC" -s -o ok.luac ok.lua

# signature, version 5.3, format, LUAC_DATA, then sizeof(int),
# sizeof(size_t) (written as int for the radio), Instruction,
# lua_Integer and lua_Number must all be 4 bytes
expected=1b4c7561530019930d0a1a0a0404040404
actual=$(od -An -tx1 -N17 ok.luac | tr -d ' \n')
if [ "$actual" != "$expected" ]; then
echo "::error::Unexpected bytecode header: $actual (expected $expected)"
exit 1
fi

# load the bytecode back through lundump
"$LUAC" -l -p ok.luac > /dev/null

- name: Reject a script with a syntax error
run: |
LUAC=$(find build-luac -type f \( -name edgetx-luac -o -name edgetx-luac.exe \) | head -1)
printf 'local x =\n' > bad.lua
if "$LUAC" -p bad.lua; then
echo "::error::edgetx-luac accepted a script with a syntax error"
exit 1
fi
2 changes: 1 addition & 1 deletion radio/src/thirdparty/Lua/src/lobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ typedef union Closure {
*/

#define CommonTable CommonHeader; \
lu_byte flags; lu_byte lsizenode; struct Table *metatable;
lu_byte flags; lu_byte lsizenode; struct Table *metatable
/*
** Tables
*/
Expand Down
5 changes: 5 additions & 0 deletions radio/src/thirdparty/Lua/src/luac.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

#if defined(__GNUC__) || defined(__clang__)
#include <alloca.h>
#elif defined(_MSC_VER)
#include <malloc.h>
#if !defined(alloca)
#define alloca _alloca
#endif
#endif
#include <ctype.h>
#include <errno.h>
Expand Down
Loading