LuaRocks Integration
LRocket supports integration with the luarocks module manager and build system.
In order to enable compilation via lrocket, luarocks projects may add the ‘luarocks-build-lrocket’ module in the dependencies
of their rockspec file. The module provides the lrocket
build type, which invokes lrc
to bundle and compile the project:
Example rockspec:
build = {
type = 'lrocket',
entrypoint = 'main.lua',
output = 'bin/program' -- compiles into ./bin/program or 'bin/program.exe' on windows
},
dependencies = {
'luarocks-build-lrocket'
}
Running the luarocks build
command will now bundle and compile all code contained in the entrypoint main.lua
and produce ./bin/program
(or bin/program.exe
on windows).
Naturally this will also include the code of all additional lua files and c modules required by the file:
> luarocks build
What about C-based rocks and static linking?
luarocks-build-lrocket configures the luarocks package manager to compile all newly installed packages or dependencies that contain C code into both, a shared library (.dll/.so) and a static archive (.a/.lib)!
This means any native package available on luarocks.org and supported by the mechanism* can be statically linked into the executable with no .dll/.so required.
If a native package is not supported, lrc
will automatically fallback to using the .dll/.so instead. This can also be configured using the prefer_c_module_type
rockspec build option (see the section below for a full list of available build options).
* The method is based on the lr-hooks framework and works on any package that uses the luarocks ‘builtin’ build system and is likely to work on packages using a Makefile.
rockspec Build Options
luarocks-build-lrocket generally translates all flags supported by lrc
to rockspec options.
The current list of available build options can be found below:
Option |
Description |
---|---|
|
required: Main lua file |
|
Output filename of the companion C header |
|
Name of the target C module (luaopen_ |
|
Extra arguments to the C compiler |
|
Add debugging information to the output file |
|
Exclude given modules from search |
|
Explicitly include the specified module |
|
Examine complex require statements when resolving modules |
|
Do not remove intermediate C code after compilation |
|
Link against the dynamic variant of the Lua library |
|
Resolve dynamic dependencies of statically linked lua modules by scanning equally named dynamic modules |
|
lrocket compiler: level of verbosity |
|
Ignore standard Lua paths |
|
Enable optimizations |
|
Output file format |
|
Output filename |
'static' |
Choose preferred variant of Lua C modules |
|
Link with /SUBSYSTEM:WINDOWS (or -mwindows for MinGW) |
The Luarocks logo was created by Hisham Muhammad.