local terra = require'terra'
This is a slightly modified build of the Terra library which allows the Terra runtime to be loaded from Lua as a Lua/C module. The terra module exposes the complete Terra Lua API and installs a require() loader for loading .t files from the same locations that are used for loading Lua files.
NOTE: Terra only runs on x86-64!
NOTE: On Windows Terra is compiled with luapower’s mingw64 toolchain so there’s no need to install Visual Studio to use standard C headers. Instead, mingw64 headers are provided in the mingw64-headers package.
NOTE: The CUDA backend is not available in this build.
Building terra requires llvm.
Bundling terra requires bunding in the llvm static libraries. There’s a script documenting what these are that can be used with bundle directly:
bundle ... -a terra -a "$(csrc/terra/bundle-libs)"
Changes to terra
The source code changes made to terra were kept to a minimum to make it easy to to merge upstream changes back into the luapower terra fork. This is similar to how dynasm was modified for luapower. Anyway, the changelist:
terra dynamic lib does not bundle luajit and is instead exposed as a normal Lua/C module that must be included with
require'terra' from Lua.
- LuaJIT was modified to
require'terra' if loading a
*.t file, and to load the file via
_G.loadfile instead of
terralib.lua was changed to load
terralib_luapower.lua at the end of the file, which changes the following:
loadfile is overloaded to call
terralib.terrahome is set to
package.terrapath is set to match
terralib.linklibrary is modified to also accept
libfoo.dylib respectively, just like
terralist.lua are not bundled into the binary and are provided separately.
strict.lua is not loaded and not included (it’s included with luajit and must be loaded manually as needed).
parsing.t were renamed
terra/parsing.t respectively and are now in the luapower dir along with all Lua files.
- the system include paths for Windows are set for mingw64-headers so building binaries with Terra’s API works out-of-the-box providing the luapower toolchain is installed (needed for linking).
2 months ago
Edit on GitHub