Skip to content

Commit 1db81f0

Browse files
committed
Use lua_runtime argument instead of use_luajit
This makes it easier to add new runtimes in the future
1 parent ac9a2d5 commit 1db81f0

File tree

2 files changed

+42
-41
lines changed

2 files changed

+42
-41
lines changed

.github/workflows/build.yml

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ env:
1010

1111
jobs:
1212
build_linux:
13-
name: ${{ matrix.platform }} (${{ matrix.arch }}, ${{ matrix.target }}, ${{ matrix.luajit && 'luajit' || 'lua' }})
13+
name: ${{ matrix.platform }} (${{ matrix.arch }}, ${{ matrix.target }}, ${{ matrix.lua-runtime }})
1414
runs-on: ${{ matrix.runner || 'ubuntu-latest' }}
1515
strategy:
1616
fail-fast: false
1717
matrix:
1818
target: [template_debug, template_release]
1919
arch: [x86_64, x86_32, arm64, arm32]
2020
platform: [linux, android]
21-
luajit: [false, true]
21+
lua-runtime: [lua, luajit]
2222
include:
2323
- platform: linux
2424
arch: x86_32
@@ -53,29 +53,29 @@ jobs:
5353
uses: actions/cache@v4
5454
with:
5555
path: .scons-cache/
56-
key: ${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.target }}-${{ matrix.luajit && 'luajit' || 'lua' }}-${{ hashfiles('.gitmodules', 'src/**') }}
56+
key: ${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.target }}-${{ matrix.lua-runtime }}-${{ hashfiles('.gitmodules', 'src/**') }}
5757
restore-keys: |
58-
${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.target }}-${{ matrix.luajit && 'luajit' || 'lua' }}-
58+
${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.target }}-${{ matrix.lua-runtime }}-
5959
- name: Build artifact
6060
run: |
61-
scons platform=${{ matrix.platform }} arch=${{ matrix.arch }} target=${{ matrix.target }} luajit=${{ matrix.luajit }}
61+
scons platform=${{ matrix.platform }} arch=${{ matrix.arch }} target=${{ matrix.target }} lua_runtime=${{ matrix.lua-runtime }}
6262
- name: Upload artifact
6363
uses: actions/upload-artifact@v4
6464
with:
65-
name: ${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.target }}-${{ matrix.luajit && 'luajit' || 'lua' }}
65+
name: ${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.target }}-${{ matrix.lua-runtime }}
6666
path: |
6767
addons/lua-gdextension/build/libluagdextension.*
6868
6969
build_windows:
70-
name: ${{ matrix.platform }} (${{ matrix.arch }}, ${{ matrix.target }}, ${{ matrix.luajit && 'luajit' || 'lua' }})
70+
name: ${{ matrix.platform }} (${{ matrix.arch }}, ${{ matrix.target }}, ${{ matrix.lua-runtime }})
7171
runs-on: windows-latest
7272
strategy:
7373
fail-fast: false
7474
matrix:
7575
target: [template_debug, template_release]
7676
arch: [x86_64, x86_32, arm64]
7777
platform: [windows]
78-
luajit: [false, true]
78+
lua-runtime: [lua, luajit]
7979
defaults:
8080
run:
8181
shell: pwsh
@@ -93,28 +93,28 @@ jobs:
9393
uses: actions/cache@v4
9494
with:
9595
path: .scons-cache/
96-
key: ${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.target }}-${{ matrix.luajit && 'luajit' || 'lua' }}-${{ hashfiles('.gitmodules', 'src/**') }}
96+
key: ${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.target }}-${{ matrix.lua-runtime }}-${{ hashfiles('.gitmodules', 'src/**') }}
9797
restore-keys: |
98-
${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.target }}-${{ matrix.luajit && 'luajit' || 'lua' }}-
98+
${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.target }}-${{ matrix.lua-runtime }}-
9999
- name: Build artifact
100100
run: |
101-
scons platform=${{ matrix.platform }} arch=${{ matrix.arch }} target=${{ matrix.target }} luajit=${{ matrix.luajit }} vcvarsall_path="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat"
101+
scons platform=${{ matrix.platform }} arch=${{ matrix.arch }} target=${{ matrix.target }} lua_runtime=${{ matrix.lua-runtime }} vcvarsall_path="C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat"
102102
- name: Upload artifact
103103
uses: actions/upload-artifact@v4
104104
with:
105-
name: ${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.target }}-${{ matrix.luajit && 'luajit' || 'lua' }}
105+
name: ${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.target }}-${{ matrix.lua-runtime }}
106106
path: |
107107
addons/lua-gdextension/build/libluagdextension.*
108108
109109
build_web:
110-
name: web (wasm32, ${{ matrix.target }}, ${{ matrix.threads && 'threads' || 'nothreads' }}, ${{ matrix.luajit && 'luajit' || 'lua' }})
110+
name: web (wasm32, ${{ matrix.target }}, ${{ matrix.threads && 'threads' || 'nothreads' }}, ${{ matrix.lua-runtime }})
111111
runs-on: ubuntu-latest
112112
strategy:
113113
fail-fast: false
114114
matrix:
115115
target: [template_debug, template_release]
116116
threads: [true, false]
117-
luajit: [false, true]
117+
lua-runtime: [lua, luajit]
118118
steps:
119119
- uses: actions/checkout@v4
120120
with:
@@ -128,29 +128,29 @@ jobs:
128128
uses: actions/cache@v4
129129
with:
130130
path: .scons-cache/
131-
key: web-wasm32-${{ matrix.target }}-${{ matrix.threads && 'threads' || 'nothreads' }}-${{ matrix.luajit && 'luajit' || 'lua' }}-${{ hashfiles('.gitmodules', 'src/**') }}
131+
key: web-wasm32-${{ matrix.target }}-${{ matrix.threads && 'threads' || 'nothreads' }}-${{ matrix.lua-runtime }}-${{ hashfiles('.gitmodules', 'src/**') }}
132132
restore-keys: |
133-
web-wasm32-${{ matrix.target }}-${{ matrix.threads && 'threads' || 'nothreads' }}-${{ matrix.luajit && 'luajit' || 'lua' }}-
133+
web-wasm32-${{ matrix.target }}-${{ matrix.threads && 'threads' || 'nothreads' }}-${{ matrix.lua-runtime }}-
134134
- name: Build artifact
135135
run: |
136-
scons platform=web arch=wasm32 target=${{ matrix.target }} threads=${{ matrix.threads }} luajit=${{ matrix.luajit }}
136+
scons platform=web arch=wasm32 target=${{ matrix.target }} threads=${{ matrix.threads }} lua_runtime=${{ matrix.lua-runtime }}
137137
- name: Upload artifact
138138
uses: actions/upload-artifact@v4
139139
with:
140-
name: web-wasm32-${{ matrix.target }}-${{ matrix.threads && 'threads' || 'nothreads' }}-${{ matrix.luajit && 'luajit' || 'lua' }}
140+
name: web-wasm32-${{ matrix.target }}-${{ matrix.threads && 'threads' || 'nothreads' }}-${{ matrix.lua-runtime }}
141141
path: |
142142
addons/lua-gdextension/build/libluagdextension.*
143143
144144
build_macos:
145-
name: ${{ matrix.platform }} (${{ matrix.arch }}, ${{ matrix.target }}, ${{ matrix.luajit && 'luajit' || 'lua' }})
145+
name: ${{ matrix.platform }} (${{ matrix.arch }}, ${{ matrix.target }}, ${{ matrix.lua-runtime }})
146146
runs-on: macos-latest
147147
strategy:
148148
fail-fast: false
149149
matrix:
150150
target: [template_debug, template_release]
151151
arch: [universal]
152152
platform: [macos, ios]
153-
luajit: [false, true]
153+
lua-runtime: [lua, luajit]
154154
steps:
155155
- uses: actions/checkout@v4
156156
with:
@@ -164,30 +164,30 @@ jobs:
164164
uses: actions/cache@v4
165165
with:
166166
path: .scons-cache/
167-
key: ${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.target }}-${{ matrix.luajit && 'luajit' || 'lua' }}-${{ hashfiles('.gitmodules', 'src/**') }}
167+
key: ${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.target }}-${{ matrix.lua-runtime }}-${{ hashfiles('.gitmodules', 'src/**') }}
168168
restore-keys: |
169-
${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.target }}-${{ matrix.luajit && 'luajit' || 'lua' }}-
169+
${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.target }}-${{ matrix.lua-runtime }}-
170170
- name: Build artifact
171171
run: |
172-
scons platform=${{ matrix.platform }} arch=${{ matrix.arch }} target=${{ matrix.target }} luajit=${{ matrix.luajit }}
172+
scons platform=${{ matrix.platform }} arch=${{ matrix.arch }} target=${{ matrix.target }} lua_runtime=${{ matrix.lua-runtime }}
173173
env:
174174
PYTHON_BIN: python3
175175
- name: Upload artifact
176176
uses: actions/upload-artifact@v4
177177
with:
178-
name: ${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.target }}-${{ matrix.luajit && 'luajit' || 'lua' }}
178+
name: ${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.target }}-${{ matrix.lua-runtime }}
179179
path: |
180180
addons/lua-gdextension/build/lib*
181181
182182
test_distribution:
183-
name: Test ${{ matrix.name }} (${{ matrix.luajit && 'luajit' || 'lua' }})
183+
name: Test ${{ matrix.name }} (${{ matrix.lua-runtime }})
184184
needs: [build_linux, build_windows, build_macos, build_web]
185185
runs-on: ${{ matrix.runner-os }}
186186
strategy:
187187
fail-fast: false
188188
matrix:
189189
name: ["Linux", "Linux (arm64)", "Windows", "Windows (arm64)", "macOS"]
190-
luajit: [false, true]
190+
lua-runtime: [lua, luajit]
191191
include:
192192
- name: Linux
193193
runner-os: ubuntu-latest
@@ -221,15 +221,15 @@ jobs:
221221
uses: actions/download-artifact@v4
222222
with:
223223
path: artifacts
224-
pattern: "*-${{ matrix.luajit && 'luajit' || 'lua' }}"
224+
pattern: "*-${{ matrix.lua-runtime }}"
225225
- name: Setup godot-cpp
226226
uses: ./lib/godot-cpp/.github/actions/setup-godot-cpp
227227
with:
228228
platform: linux
229229
scons-version: $SCONS_VERSION
230230
- name: Copy artifacts to build folder
231231
run: |
232-
scons luajit=${{ matrix.luajit }} addons_files
232+
scons lua_runtime=${{ matrix.lua-runtime }} addons_files
233233
cp -r '${{ steps.download.outputs.download-path }}'/**/lib* addons/lua-gdextension/build
234234
- name: Download Godot
235235
run: |
@@ -240,13 +240,13 @@ jobs:
240240
make test
241241
242242
distribute_zip:
243-
name: Distribute zip (${{ matrix.luajit && 'luajit' || 'lua' }}")
243+
name: Distribute zip (${{ matrix.lua-runtime }}")
244244
needs: [build_linux, build_windows, build_macos, build_web]
245245
runs-on: ubuntu-latest
246246
strategy:
247247
fail-fast: false
248248
matrix:
249-
luajit: [false, true]
249+
lua-runtime: [lua, luajit]
250250
steps:
251251
- uses: actions/checkout@v4
252252
with:
@@ -256,20 +256,20 @@ jobs:
256256
uses: actions/download-artifact@v4
257257
with:
258258
path: artifacts
259-
pattern: "*-${{ matrix.luajit && 'luajit' || 'lua' }}"
259+
pattern: "*-${{ matrix.lua-runtime }}"
260260
- name: Setup godot-cpp
261261
uses: ./lib/godot-cpp/.github/actions/setup-godot-cpp
262262
with:
263263
platform: linux
264264
scons-version: $SCONS_VERSION
265265
- name: Copy artifacts to build folder
266266
run: |
267-
scons luajit=${{ matrix.luajit }} addons_files
267+
scons lua_runtime=${{ matrix.lua-runtime }} addons_files
268268
cp -r ${{ steps.download.outputs.download-path }}/**/lib* addons/lua-gdextension/build
269269
- name: Upload artifact
270270
uses: actions/upload-artifact@v4
271271
with:
272-
name: lua-gdextension${{ matrix.luajit && '+luajit' || '' }}
272+
name: ${{ matrix.lua-runtime == 'lua' && 'lua-gdextension' || format('lua-gdextension+{0}', matrix.lua-runtime) }}
273273
path: |
274274
LICENSE
275275
addons/lua-gdextension/**

SConstruct

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ import platform
33
import shutil
44
import sys
55

6-
7-
use_luajit = ARGUMENTS.pop("luajit", False) in ["True", "true", "t", "yes", "on", "1"]
6+
lua_runtime = ARGUMENTS.pop("lua_runtime", "lua")
7+
if lua_runtime.lower() not in ["lua", "luajit"]:
8+
raise ValueError(f"Invalid lua_runtime: expected either 'lua' or 'luajit', got {lua_runtime}")
89
vcvarsall_path = ARGUMENTS.pop("vcvarsall_path", "")
910

1011
env = SConscript("lib/godot-cpp/SConstruct").Clone()
1112
env.Tool("apple", toolpath=["tools"])
1213

13-
# Ok, so LuaJIT is not supported in the web, so we just build with vanilla Lua
14-
if env["platform"] == "web":
15-
use_luajit = False
14+
if env["platform"] == "web" and lua_runtime == "luajit":
15+
print("LuaJIT doesn't support WebAssembly, building with Lua instead")
16+
lua_runtime = "lua"
1617

1718
# Setup variant build dir for each setup
1819
def remove_prefix(s, prefix):
@@ -74,7 +75,7 @@ if env["platform"] == "windows" and not env["use_mingw"]:
7475

7576

7677
# Lua
77-
if not use_luajit:
78+
if lua_runtime == "lua":
7879
env.Append(CPPDEFINES="MAKE_LIB")
7980
if env["platform"] == "windows":
8081
# Lua automatically detects Windows using `defined(_WIN32)`
@@ -95,7 +96,7 @@ if not use_luajit:
9596
env.Append(CPPDEFINES=["SOL_USING_CXX_LUA=1"])
9697
env.Append(CPPPATH="lib/lua")
9798
# LuaJIT
98-
else:
99+
elif lua_runtime == "luajit":
99100
# Make sure luajit.h and jit/vmdef.lua has been generated
100101
env.Execute("make -C lib/luajit/src luajit.h jit/vmdef.lua MACOSX_DEPLOYMENT_TARGET=11.0")
101102

@@ -252,7 +253,7 @@ addons_files = env.Command(
252253
addons_source,
253254
Copy("addons/lua-gdextension", addons_source),
254255
)
255-
if use_luajit:
256+
if lua_runtime == "luajit":
256257
jit_source = Glob("lib/luajit/src/jit/*.lua")
257258
addons_files.extend(env.Command(
258259
[f"addons/lua-gdextension/build/jit/{f}" for f in jit_source],

0 commit comments

Comments
 (0)