1
Description: Use system Lua 5.1 instead of bundled version
2
FCEUX not only has a bundled version of Lua 5.1, it relies on being able
3
to access internal data structures in the Lua library which were never meant
4
to be accessed from outside, and do thus not provide a stable API, and FCEUX
5
would then potentially need to be rebuilt from source when a new version of
6
Lua 5.1 is released (if any).
7
This patch removes the optimization in FCEUX that was relying on being able
8
to access these data structures, and links it against the system-installed
9
version of the lua library..
11
Author: Alexander Toresson <alexander.toresson@gmail.com>
12
Author: Joe Nahmias <jello@debian.org>
14
--- fceux.orig/SConstruct
19
# Default compiler flags:
20
-env.Append(CCFLAGS = ['-Wall', '-Wno-write-strings', '-Wno-sign-compare', '-Isrc/lua/src'])
21
+env.Append(CCFLAGS = ['-Wall', '-Wno-write-strings', '-Wno-sign-compare'])
23
if os.environ.has_key('PLATFORM'):
24
env.Replace(PLATFORM = os.environ['PLATFORM'])
26
env['LIBS'] = ['wsock32'];
28
if env['PLATFORM'] == 'win32':
29
- env.Append(CPPPATH = [".", "drivers/win/", "drivers/common/", "drivers/", "drivers/win/zlib", "drivers/win/directx", "drivers/win/lua/include"])
30
+ env.Append(CPPPATH = [".", "drivers/win/", "drivers/common/", "drivers/", "drivers/win/zlib", "drivers/win/directx"])
31
env.Append(CPPDEFINES = ["PSS_STYLE=2", "WIN32", "_USE_SHARED_MEMORY_", "NETWORK", "FCEUDEF_DEBUGGER", "NOMINMAX", "NEED_MINGW_HACKS", "_WIN32_IE=0x0600"])
32
env.Append(LIBS = ["rpcrt4", "comctl32", "vfw32", "winmm", "ws2_32", "comdlg32", "ole32", "gdi32", "htmlhelp"])
35
env.Append(CCFLAGS = ["-DLUA_USE_LINUX"])
37
if conf.CheckLib('lua5.1'):
38
+ env.Append(CCFLAGS = ["-I/usr/include/lua5.1"])
39
env.Append(LINKFLAGS = ["-ldl", "-llua5.1"])
41
elif conf.CheckLib('lua'):
42
--- fceux.orig/src/lua-engine.cpp
43
+++ fceux/src/lua-engine.cpp
50
int iuplua_open(lua_State * L);
51
int iupcontrolslua_open(lua_State * L);
52
@@ -1157,17 +1156,10 @@
54
if (lua_isfunction(L, -1))
56
- // since the scriptdata can be very expensive to load
57
- // (e.g. the registered save function returned some huge tables)
58
- // check the number of parameters the registered load function expects
59
- // and don't bother loading the parameters it wouldn't receive anyway
60
- int numParamsExpected = (L->top - 1)->value.gc->cl.l.p->numparams; // NOTE: if this line crashes, that means your Lua headers are out of sync with your Lua lib
61
- if(numParamsExpected) numParamsExpected--; // minus one for the savestate number we always pass in
63
int prevGarbage = lua_gc(L, LUA_GCCOUNT, 0);
65
lua_pushinteger(L, savestateNumber);
66
- saveData.LoadRecord(L, LUA_DATARECORDKEY, numParamsExpected);
67
+ saveData.LoadRecord(L, LUA_DATARECORDKEY, (unsigned int) -1);
68
int n = lua_gettop(L) - 1;
70
int ret = lua_pcall(L, n, 0, 0);