-
-
Notifications
You must be signed in to change notification settings - Fork 1
HOWTO run the LÖVE playable demo
We are using the LÖVE engine to quickly prototype graphical, interactive applications (also known as games) based on Luna Purpuara's support libraries.
LÖVE provides such things as an event loop and a framebuffer, and handles keyboard input, mouse input, etc., as instructed by scripts written in Lua 5.1. Therefore, bindings which bridge the Luna Purpura libraries (written in C) to Lua need to be written, and compiled. This document describes how to do that.
The overall goal is:
- (1) compile Luna Purpura's libraries (liblpprx, liblpxpk, etc.)
- (2a) compile Luna Purpura's Lua bindings (luaprx.so, luapxpk.so, etc.),
- (2b) while linking against LÖVE's version of Lua, which is actually LuaJIT
- (3) rearrange the Lua bindings in a way with LÖVE expects
- (4) extract a Rockett game to Luna Purpura's 'love' directory
- (5) launch the game
The LÖVE application bundle for OS X uses the "Frameworks" feature.
We can see that love.app
ships with the dynamic libraries it needs in
order to run:
$ ls /Applications/love.app/Contents/Frameworks/
Lua.framework
OpenAL-Soft.framework
SDL2.framework
freetype.framework
libmodplug.framework
love.framework
mpg123.framework
ogg.framework
theora.framework
vorbis.framework
Conveniently, love.app
ships with LuaJIT's header files, too, instead of
only its library:
$ cd /Applications/love.app/Contents/Frameworks/Lua.framework
$ find . -type f
./Versions/A/_CodeSignature/CodeResources
./Versions/A/Resources/en.lproj/InfoPlist.strings
./Versions/A/Resources/Info.plist
./Versions/A/Lua
./Versions/A/Headers/luaconf.h
./Versions/A/Headers/lua.hpp
./Versions/A/Headers/lualib.h
./Versions/A/Headers/luajit.h
./Versions/A/Headers/lauxlib.h
./Versions/A/Headers/lua.h
Therefore, we are able to link Luna Purpura's Lua bindings against precisely the same version of LuaJIT which comes with LÖVE. Unfortunately, as of this writing, Luna Purpura's CMakeLists don't know what OS X Frameworks are, so you have to rearrange these files in a way which CMake can understand.
I personally do something like this:
# Create an easy-to-find directory with LuaJIT's development files -- I'm at
# the top of the Luna Purpura source tree right now
$ mkdir -p ./lua
# Use a regular name for the directory which holds the header files.
$ ln -sf /Applications/love.app/Contents/Frameworks/Lua.framework/Versions/A/Headers ./lua/include
# Use a regular name for the LuaJIT library itself.
$ mkdir -p ./lua/lib
$ ln -sf /Applications/love.app/Contents/Frameworks/Lua.framework/Versions/A/Lua ./lua/lib/libluajit.dylib
Now, CMake will be able to understand what's going on here.
$ mkdir ./build
$ cmake .. \
-DLUNAPURPURA_BUILD_LUA_BINDINGS=ON \
-DLUA_INCLUDEDIR=../lua/include \
-DLUA_LIBDIR=../lua/lib
After building everything with make
, we're still not done yet! Lua's
package loader has certain conventions which are NOT the same as those for a
C linker. So, we now need to copy the Lua bindings we just made (which are C
libraries) and arrange them in a way which LÖVE can understand.
for name in clu prx xpk; do
cp ../build/src/lua/liblua${name}.dylib ../love/lua${name}.so
done
Finally, the 'love' directory of Luna Purpura has all the required code, arranged in the expected way. We are ready to launch the game:
$ cd ../love
$ /Applications/love.app/Contents/MacOS/love ./