forked from dylib-Finally/executor-
-
Notifications
You must be signed in to change notification settings - Fork 1
249 lines (201 loc) · 8.44 KB
/
lua_build.yml
File metadata and controls
249 lines (201 loc) · 8.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
name: Build with Homebrew Lua/Luau
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: macos-latest # Use macOS for iOS compatible builds
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install dependencies
run: |
echo "Installing dependencies..."
# Install essential build tools and Lua/Luau
brew update
brew install cmake pkg-config
brew install luau
brew install lua || true
# Show Lua/Luau installation details
echo "Lua/Luau installation details:"
brew info luau
brew info lua || true
echo "Lua/Luau paths:"
ls -la $(brew --prefix luau)/include || echo "No include directory found"
ls -la $(brew --prefix luau)/lib || echo "No lib directory found"
# Create required directories
mkdir -p external/dobby/include
mkdir -p external/dobby/lib
mkdir -p output/Resources/AIData
mkdir -p build
# Remove any CI_BUILD defines
find source -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.cpp" -o -name "*.mm" -o -name "*.c" \) | \
xargs sed -i '' 's/#define CI_BUILD//g' 2>/dev/null || true
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Build Dobby
id: install-dobby
run: |
echo "Building Dobby from source (required dependency)..."
git clone --depth=1 https://github.com/jmpews/Dobby.git
cd Dobby
mkdir -p build && cd build
# Configure and build Dobby
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DDOBBY_BUILD_SHARED_LIBRARY=OFF \
-DDOBBY_BUILD_STATIC_LIBRARY=ON
cmake --build . --config Release
# Copy Dobby files to expected location
mkdir -p $GITHUB_WORKSPACE/external/dobby/lib
mkdir -p $GITHUB_WORKSPACE/external/dobby/include
cp libdobby.a $GITHUB_WORKSPACE/external/dobby/lib/
cp -r ../include/* $GITHUB_WORKSPACE/external/dobby/include/
echo "Dobby successfully built and installed to external/dobby"
cd $GITHUB_WORKSPACE
- name: Create Minimal Lua API Patch
run: |
echo "Creating minimal patch for Lua API..."
# Create a small header file that just fixes the specific issues
cat > lua_fixes.h << 'EOF'
// Minimal fixes for Lua/Luau API issues
#pragma once
// Only fix the problematic static function pointer
#ifdef lua_pcall
#undef lua_pcall
#endif
extern int lua_pcall(lua_State* L, int nargs, int nresults, int errfunc);
// Fix typeerror and argerror macros
#define luaL_typeerror(L, narg, tname) luaL_typeerrorL(L, narg, tname)
#define luaL_argerror(L, narg, extramsg) luaL_argerrorL(L, narg, extramsg)
EOF
# Create a patch for lua.h to fix the static function pointer
if [ -f "source/cpp/luau/lua.h" ]; then
echo "Patching source/cpp/luau/lua.h..."
# Create a backup
cp source/cpp/luau/lua.h source/cpp/luau/lua.h.bak
# Remove the static function pointer line
sed -i '' 's/static int (\*lua_pcall)(lua_State\* L, int nargs, int nresults, int errfunc);/int lua_pcall(lua_State* L, int nargs, int nresults, int errfunc);/' source/cpp/luau/lua.h
fi
# Copy the fixes to the source directory
cp lua_fixes.h source/
- name: Update CMakeLists.txt to use Homebrew Lua
run: |
echo "Updating CMakeLists.txt to use Homebrew Lua/Luau..."
# Add Lua paths to CMakeLists.txt
cat >> CMakeLists.txt << EOF
# Find and use Homebrew Lua/Luau
list(APPEND CMAKE_PREFIX_PATH $(brew --prefix luau))
set(LUAU_DIR $(brew --prefix luau))
set(LUA_INCLUDE_DIR \${LUAU_DIR}/include)
set(LUA_LIBRARIES \${LUAU_DIR}/lib/libluau.dylib)
# Include our fix header
include_directories(\${CMAKE_SOURCE_DIR}/source)
# Link against Homebrew Lua
target_link_libraries(roblox_executor PRIVATE \${LUA_LIBRARIES})
EOF
# Ensure we include the fix header in lfs.c
if [ -f "source/lfs.c" ]; then
# Add the include to the top of the file
sed -i '' '1i\
// Include minimal fixes for Lua API\
#include "lua_fixes.h"\
' source/lfs.c
fi
- name: Build Dynamic Library
run: |
echo "Building the iOS dynamic library..."
# Create a direct link to Homebrew's luau lib as liblua.dylib (for backward compatibility)
LUAU_LIB=$(brew --prefix luau)/lib
if [ -f "$LUAU_LIB/libluau.dylib" ] && [ ! -f "$LUAU_LIB/liblua.dylib" ]; then
echo "Creating symlink from libluau.dylib to liblua.dylib..."
ln -sf "$LUAU_LIB/libluau.dylib" "$LUAU_LIB/liblua.dylib" || sudo ln -sf "$LUAU_LIB/libluau.dylib" "$LUAU_LIB/liblua.dylib" || true
fi
# Configure with Homebrew Lua paths
echo "Configuring with Lua from: $(brew --prefix luau)"
cmake -S . -B build \
-DCMAKE_OSX_ARCHITECTURES="arm64" \
-DCMAKE_OSX_DEPLOYMENT_TARGET="15.0" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_SYSTEM_NAME=iOS \
-DCMAKE_PREFIX_PATH="$(brew --prefix luau)" \
-DLUA_INCLUDE_DIR="$(brew --prefix luau)/include" \
-DLUA_LIBRARIES="$(brew --prefix luau)/lib/libluau.dylib" \
-DENABLE_AI_FEATURES=ON \
-DUSE_DOBBY=ON
# Print the CMake configuration
cat build/CMakeCache.txt | grep -E "LUA|Lua|luau|DOBBY"
# Build the library
cmake --build build --config Release || {
echo "🔎 Build failed, analyzing errors..."
# Show the problematic part of lua.h
echo "lua.h line with lua_pcall:"
grep -n "lua_pcall" source/cpp/luau/lua.h || echo "Not found"
# Check if the lua_fixes.h was properly included in lfs.c
echo "First 10 lines of lfs.c:"
head -10 source/lfs.c
# Show build errors
if [ -f "build/CMakeFiles/CMakeError.log" ]; then
echo "=== CMakeError.log ==="
cat build/CMakeFiles/CMakeError.log
fi
# Check for specific error logs
echo "Searching for error logs..."
find build -name "*.log" -type f -exec grep -l "error:" {} \; | xargs cat 2>/dev/null || echo "No error logs found"
exit 1
}
# Check if build produced the library
if [ -f "build/lib/libmylibrary.dylib" ]; then
echo "✅ Successfully built libmylibrary.dylib"
ls -la build/lib/libmylibrary.dylib
# Copy to output directory
mkdir -p output
cp build/lib/libmylibrary.dylib output/
# Copy any resources
if [ -d "Resources" ]; then
mkdir -p output/Resources
cp -r Resources/* output/Resources/ 2>/dev/null || true
fi
# Create default config if it doesn't exist
mkdir -p output/Resources/AIData
if [ ! -f "output/Resources/AIData/config.json" ]; then
echo '{"version":"1.0.0","led_effects":true,"ai_features":true,"memory_optimization":true}' > output/Resources/AIData/config.json
fi
echo "== Built files =="
ls -la output/
else
echo "❌ Failed to build libmylibrary.dylib"
echo "== Build directory contents =="
find build -name "*.dylib" -o -name "*.a"
exit 1
fi
- name: Verify Library
run: |
echo "Verifying built dylib..."
if [ -f "output/libmylibrary.dylib" ]; then
echo "✅ libmylibrary.dylib exists"
# Check for exported symbols
echo "Exported symbols:"
nm -g output/libmylibrary.dylib | grep -E "luaopen_|ExecuteScript" || echo "No key symbols found!"
# Check library type
file output/libmylibrary.dylib
# Check library dependencies
otool -L output/libmylibrary.dylib
else
echo "❌ libmylibrary.dylib not found in output directory"
exit 1
fi
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: ios-dylib-with-real-lua
path: |
output/libmylibrary.dylib
output/Resources/**