Skip to content

Commit 8751844

Browse files
author
Polaris
committed
Initial release 1.0.0
0 parents  commit 8751844

29 files changed

Lines changed: 4906 additions & 0 deletions

.github/workflows/release.yml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
env:
13+
VERSION: ${{ github.ref_type == 'tag' && github.ref_name || '0.0.0-dev' }}
14+
15+
jobs:
16+
linux:
17+
name: Linux ${{ matrix.arch }}
18+
runs-on: ${{ matrix.runner }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
include:
23+
- arch: x64
24+
runner: ubuntu-latest
25+
- arch: arm64
26+
runner: ubuntu-24.04-arm
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- name: Install build dependencies
32+
run: |
33+
sudo apt-get update
34+
sudo apt-get install -y git cmake build-essential libreadline-dev
35+
36+
- name: Build VM
37+
run: make vm
38+
39+
- name: Package artifact
40+
run: |
41+
VERSION_CLEAN="${VERSION#v}"
42+
PKG_DIR="dist/pkg-linux-${{ matrix.arch }}"
43+
ASSET="cfxlua-${VERSION_CLEAN}-linux-${{ matrix.arch }}.tar.gz"
44+
mkdir -p "$PKG_DIR/bin" "$PKG_DIR/runtime" "$PKG_DIR/vm/build"
45+
cp -a bin/cfxlua "$PKG_DIR/bin/"
46+
cp -a runtime/. "$PKG_DIR/runtime/"
47+
cp -a vm/build/cfxlua-vm "$PKG_DIR/vm/build/"
48+
cp -a tools/release/install.sh "$PKG_DIR/install.sh"
49+
chmod +x "$PKG_DIR/install.sh"
50+
tar -C dist -czf "dist/$ASSET" "pkg-linux-${{ matrix.arch }}"
51+
52+
- name: Upload release asset
53+
if: startsWith(github.ref, 'refs/tags/')
54+
uses: softprops/action-gh-release@v2
55+
with:
56+
files: dist/*.tar.gz
57+
58+
macos:
59+
name: macOS tarball
60+
runs-on: macos-latest
61+
62+
steps:
63+
- uses: actions/checkout@v4
64+
65+
- name: Install build dependencies
66+
run: brew install cmake readline
67+
68+
- name: Build VM
69+
run: make vm
70+
71+
- name: Package artifact
72+
run: |
73+
VERSION_CLEAN="${VERSION#v}"
74+
ASSET="cfxlua-${VERSION_CLEAN}-macos.tar.gz"
75+
PKG_DIR="dist/pkg-macos"
76+
mkdir -p "$PKG_DIR/bin" "$PKG_DIR/runtime" "$PKG_DIR/vm/build"
77+
cp -a bin/cfxlua "$PKG_DIR/bin/"
78+
cp -a runtime/. "$PKG_DIR/runtime/"
79+
cp -a vm/build/cfxlua-vm "$PKG_DIR/vm/build/"
80+
cp -a tools/release/install.sh "$PKG_DIR/install.sh"
81+
chmod +x "$PKG_DIR/install.sh"
82+
tar -C dist -czf "dist/$ASSET" "pkg-macos"
83+
echo "ASSET=$ASSET" >> "$GITHUB_ENV"
84+
85+
- name: Upload release asset
86+
if: startsWith(github.ref, 'refs/tags/')
87+
uses: softprops/action-gh-release@v2
88+
with:
89+
files: dist/*.tar.gz
90+
91+
windows:
92+
name: Windows installer
93+
runs-on: windows-latest
94+
95+
steps:
96+
- uses: actions/checkout@v4
97+
98+
- name: Build VM
99+
shell: pwsh
100+
run: |
101+
git clone --depth=1 --branch luaglm-dev/cfx https://github.com/citizenfx/lua.git vendor/citizenfx-lua
102+
git -C vendor/citizenfx-lua submodule update --init --recursive
103+
New-Item -ItemType Directory -Force -Path vm/build | Out-Null
104+
cmake -S vendor/citizenfx-lua -B vm/build -DCMAKE_BUILD_TYPE=Release -DGRIT_POWER_COMPOUND=ON -DGRIT_POWER_SAFENAV=ON -DGRIT_POWER_INTABLE=ON -DGRIT_POWER_JOAAT=ON -DGRIT_POWER_DEFER=ON
105+
cmake --build vm/build --config Release
106+
if (Test-Path vm/build/Release/lua.exe) {
107+
Copy-Item vm/build/Release/lua.exe vm/build/cfxlua-vm.exe -Force
108+
} elseif (Test-Path vm/build/lua.exe) {
109+
Copy-Item vm/build/lua.exe vm/build/cfxlua-vm.exe -Force
110+
} else {
111+
throw "lua.exe not found"
112+
}
113+
114+
- name: Prepare installer payload
115+
shell: pwsh
116+
run: |
117+
New-Item -ItemType Directory -Force -Path dist/windows/bin | Out-Null
118+
New-Item -ItemType Directory -Force -Path dist/windows/runtime | Out-Null
119+
New-Item -ItemType Directory -Force -Path dist/windows/vm/build | Out-Null
120+
Copy-Item bin/cfxlua.cmd dist/windows/bin/cfxlua.cmd -Force
121+
Copy-Item bin/cfxlua.ps1 dist/windows/bin/cfxlua.ps1 -Force
122+
Copy-Item -Recurse runtime/* dist/windows/runtime -Force
123+
Copy-Item vm/build/cfxlua-vm.exe dist/windows/vm/build/cfxlua-vm.exe -Force
124+
125+
- name: Normalize version string
126+
shell: pwsh
127+
run: |
128+
$v = '${{ github.ref_name }}'
129+
if ($v.StartsWith('v')) { $v = $v.Substring(1) }
130+
"CFXLUA_VERSION=$v" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
131+
132+
- name: Build Inno Setup installer
133+
uses: Minionguyjpro/Inno-Setup-Action@v1.2.2
134+
with:
135+
path: packaging/windows/cfxlua.iss
136+
137+
- name: Upload release asset
138+
if: startsWith(github.ref, 'refs/tags/')
139+
uses: softprops/action-gh-release@v2
140+
with:
141+
files: dist/*.exe

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# External dependency clones (generated by make)
2+
/vendor/
3+
4+
# VM build artifacts
5+
/vm/build/
6+
7+
# Local release packaging output
8+
/dist/
9+
10+
# Generated stubs output
11+
/runtime/stubs_generated.lua

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Polaris
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# =============================================================================
2+
# Makefile — CfxLua Standalone Interpreter
3+
# =============================================================================
4+
# Targets:
5+
# make — clone + build the LuaGLM VM (alias for 'make vm')
6+
# make vm — clone citizenfx/lua and cmake-build the interpreter
7+
# make install — install 'cfxlua' wrapper to PREFIX/bin (default /usr/local)
8+
# make test — run the test suite using the built VM (or system Lua)
9+
# make stubs — regenerate runtime/stubs.lua from cfxlua-vscode annotations
10+
# make clean — remove build artefacts (keeps cloned sources)
11+
# make distclean — remove everything including cloned repos
12+
#
13+
# Variables:
14+
# PREFIX Install prefix (default: /usr/local)
15+
# JOBS Parallel build jobs (default: nproc || 4)
16+
# VSCODE_PATH Path to cfxlua-vscode repo (default: ./vendor/cfxlua-vscode)
17+
# =============================================================================
18+
19+
PREFIX ?= /usr/local
20+
VSCODE_PATH ?= vendor/cfxlua-vscode
21+
JOBS ?= $(shell nproc 2>/dev/null || echo 4)
22+
23+
REPO_LUA := https://github.com/citizenfx/lua.git
24+
REPO_VSCODE := https://github.com/overextended/cfxlua-vscode.git
25+
BRANCH_LUA := luaglm-dev/cfx
26+
27+
LUA_SRC := vendor/citizenfx-lua
28+
LUA_BUILD := vm/build
29+
VM_BIN := $(LUA_BUILD)/cfxlua-vm
30+
31+
# ---------------------------------------------------------------------------
32+
.PHONY: all vm install test stubs clean distclean help
33+
34+
all: vm
35+
36+
help:
37+
@echo "CfxLua Standalone Interpreter — build targets:"
38+
@echo ""
39+
@echo " make Build the LuaGLM VM binary"
40+
@echo " make install Install cfxlua to $(PREFIX)/bin"
41+
@echo " make test Run the test suite"
42+
@echo " make stubs Regenerate runtime/stubs.lua from cfxlua-vscode"
43+
@echo " make clean Remove build artifacts"
44+
@echo " make distclean Remove build artifacts and vendor directory"
45+
@echo ""
46+
@echo "Variables:"
47+
@echo " PREFIX=$(PREFIX)"
48+
@echo " JOBS=$(JOBS)"
49+
@echo " VSCODE_PATH=$(VSCODE_PATH)"
50+
51+
# ---------------------------------------------------------------------------
52+
# Clone citizenfx/lua if not already present
53+
# ---------------------------------------------------------------------------
54+
$(LUA_SRC)/.git:
55+
@echo "[cfxlua] Cloning citizenfx/lua (branch: $(BRANCH_LUA))..."
56+
@mkdir -p vendor
57+
git clone --depth=1 --branch "$(BRANCH_LUA)" "$(REPO_LUA)" "$(LUA_SRC)"
58+
@echo "[cfxlua] Initialising submodules (GLM)..."
59+
cd "$(LUA_SRC)" && git submodule update --init --recursive
60+
61+
# ---------------------------------------------------------------------------
62+
# Build the LuaGLM VM with all CfxLua power-patches enabled.
63+
#
64+
# CMake flags explained:
65+
# GRIT_POWER_COMPOUND — compound assignment operators: += -= *= /= %=
66+
# GRIT_POWER_SAFENAV — safe navigation: t?.field t?[key] t?:method()
67+
# GRIT_POWER_INTABLE — in-table destructuring: local a, b in t
68+
# GRIT_POWER_JOAAT — backtick Jenkins hashes: `Hello` == 0x3E0B8C49
69+
# GRIT_POWER_DEFER — defer statement: defer fn() (runs on scope exit)
70+
# GRIT_POWER_SETCONS — set constructors: { .a, .b } from a table
71+
# LUA_GLM — enable vec2/3/4, quat, mat primitives as VM tags
72+
# LUA_GLM_EXT — additional GLM functions (cross, dot, normalize…)
73+
#
74+
# The output binary is renamed from `lua` to `cfxlua-vm` by the install step.
75+
# ---------------------------------------------------------------------------
76+
$(VM_BIN): $(LUA_SRC)/.git
77+
@echo "[cfxlua] Configuring LuaGLM with cmake..."
78+
@mkdir -p "$(LUA_BUILD)"
79+
cd "$(LUA_BUILD)" && cmake \
80+
-G "Unix Makefiles" \
81+
-DCMAKE_BUILD_TYPE=Release \
82+
-DGRIT_POWER_COMPOUND=ON \
83+
-DGRIT_POWER_SAFENAV=ON \
84+
-DGRIT_POWER_INTABLE=ON \
85+
-DGRIT_POWER_JOAAT=ON \
86+
-DGRIT_POWER_DEFER=ON \
87+
-DGRIT_POWER_CHRONO=OFF \
88+
-DGRIT_POWER_SETCONS=ON \
89+
-DLUA_GLM=ON \
90+
-DLUA_GLM_EXT=ON \
91+
-DCMAKE_INSTALL_PREFIX="$(abspath $(LUA_BUILD))" \
92+
"../../$(LUA_SRC)"
93+
@echo "[cfxlua] Building LuaGLM ($(JOBS) jobs)..."
94+
$(MAKE) -C "$(LUA_BUILD)" -j$(JOBS)
95+
@# Rename the output binary to cfxlua-vm
96+
@if [ -f "$(LUA_BUILD)/lua" ]; then \
97+
cp "$(LUA_BUILD)/lua" "$(VM_BIN)"; \
98+
chmod +x "$(VM_BIN)"; \
99+
echo "[cfxlua] VM binary: $(VM_BIN)"; \
100+
fi
101+
102+
vm: $(VM_BIN)
103+
@echo "[cfxlua] LuaGLM VM ready at: $(VM_BIN)"
104+
@$(VM_BIN) -v
105+
106+
# ---------------------------------------------------------------------------
107+
# Install wrapper to PREFIX/bin
108+
# ---------------------------------------------------------------------------
109+
install: $(VM_BIN)
110+
@echo "[cfxlua] Installing to $(PREFIX)/bin ..."
111+
@mkdir -p "$(PREFIX)/bin"
112+
install -m 755 "$(VM_BIN)" "$(PREFIX)/bin/cfxlua-vm"
113+
install -m 755 bin/cfxlua "$(PREFIX)/bin/cfxlua"
114+
@echo "[cfxlua] Installed cfxlua and cfxlua-vm to $(PREFIX)/bin"
115+
@echo " You may need to add $(PREFIX)/bin to your PATH."
116+
117+
# ---------------------------------------------------------------------------
118+
# Run test suite
119+
# The wrapper falls back to system Lua if cfxlua-vm hasn't been built yet,
120+
# so tests run without needing a full build first.
121+
# ---------------------------------------------------------------------------
122+
test:
123+
@echo "[cfxlua] Running test suite..."
124+
@if [ -x "$(VM_BIN)" ]; then \
125+
CFXLUA_VM="$(abspath $(VM_BIN))" bash bin/cfxlua tests/run_tests.lua; \
126+
else \
127+
echo "[cfxlua] cfxlua-vm not built; running with system Lua (no LuaGLM)"; \
128+
bash bin/cfxlua tests/run_tests.lua; \
129+
fi
130+
131+
# Quick test without the build system (useful in CI before VM is compiled)
132+
test-quick:
133+
@$(shell command -v lua5.4 2>/dev/null || command -v lua) \
134+
-e "__cfx_bootstrapPath = '.'" \
135+
runtime/bootstrap.lua tests/run_tests.lua
136+
137+
# ---------------------------------------------------------------------------
138+
# Regenerate stubs from cfxlua-vscode annotations
139+
# ---------------------------------------------------------------------------
140+
$(VSCODE_PATH)/.git:
141+
@echo "[cfxlua] Cloning cfxlua-vscode for stub generation..."
142+
@mkdir -p vendor
143+
git clone --depth=1 "$(REPO_VSCODE)" "$(VSCODE_PATH)"
144+
145+
stubs: $(VSCODE_PATH)/.git
146+
@echo "[cfxlua] Generating stubs from cfxlua-vscode annotations..."
147+
$(shell command -v lua5.4 2>/dev/null || command -v lua) \
148+
tools/gen_stubs.lua "$(VSCODE_PATH)" server \
149+
> runtime/stubs_generated.lua
150+
@echo "[cfxlua] Generated runtime/stubs_generated.lua"
151+
@echo " Review and merge into runtime/stubs.lua as needed."
152+
153+
# ---------------------------------------------------------------------------
154+
# Clean
155+
# ---------------------------------------------------------------------------
156+
clean:
157+
rm -rf "$(LUA_BUILD)"
158+
@echo "[cfxlua] Removed $(LUA_BUILD)"
159+
160+
distclean: clean
161+
rm -rf vendor/
162+
@echo "[cfxlua] Removed vendor/"

0 commit comments

Comments
 (0)