Emilua
A cross-platform execution engine for LuaJIT with support for async IO and flexible threading layout.
Features:
-
Complete fiber API (sync primitives, interruption API, clean-up handlers, fiber local storage, assert-like scheduling constraints, …).
-
TCP, UDP, TLS, file IO, address/service forward/reverse name resolution, UNIX domain sockets, SCM_RIGHTS fd-passing, pipes, serial ports, …
-
Clocks & timers.
-
Filesystem API.
-
Portable error comparison.
-
Integrates with Lua builtins (i.e. you can mix up fibers and coroutines, modules, …).
-
Actor API (each VM is an actor and they’re spawned in thread pools under your control[1]). You can even spawn isolated actors into new Linux namespaces, Landlock & seccomp rules, etc.
-
Native JSON module.
-
Cross-platform (should run anywhere Boost.Asio also runs).
Install
-
Windows: Windows binaries are published on Gitlab after AppVeyor build.
-
ArchLinux: Emilua is available on AUR.
-
GUIX: Emilua is available from the main repository.
-
NixOS: Emilua is available from the unstable repository.
-
Ubuntu: Emilua is available for Ubuntu via this PPA repository.
-
FreeBSD: Emilua is available from the main repository and ports.
LICENSE
-
C/C++ source code dual-licensed under Boost Software License and MIT. This model of license (user picks one from the offered options) makes it easier to contribute code back to both communities Emilua depends on (Boost and LuaJIT).
-
Lua code (including snippets scattered throughout the documentation) distributed in this repo is released as public domain.
-
The file
src/emilua_gperf.awk
is released as public domain. -
Documentation (except for the source code samples contained within) is licensed under the Creative Commons Attribution 4.0 International License.
-
Submodules and dependencies have their own licensing terms.
Emilua provides libraries with the interpreter which are themselves interpreted. This approach is not uncommon. For instance, Perl comes with many Perl modules, and a Java implementation comes with many Java classes. These libraries and the programs that call them are always dynamically linked together. It’s for this reason that Lua source code bundled with Emilua is released as public domain. Bundled public domain libraries that the interpreter loads will impose no additional restriction on your Lua program.
Documentation
You can browse the documentation online at https://docs.emilua.org/.
Alternatively, you may pass -Denable_manpages=true
when building the project
to have the documentation installed as manpages in your system. The reference
pages will be installed in the section 3em
("em" stands for Emilua
Module). Tutorial pages will be installed in section 7, but every page in this
section will be prefixed by "emilua-".
Dependencies
-
Meson 1.2.0 or later.
-
C++20 compiler (GCC 12.1 or newer should work).
-
LuaJIT.
-
Boost.Asio (and other Boost libraries as well).
-
fmt 8.0 or later.
-
re2c
2.1 or later. -
gperf
3.1 or later (maybe it’ll work on older versions as well). -
GNU AWK 5.1 or later.
Optional dependencies
-
Curses: coloured output on errors.
-
asciidoctor: manpages.
-
asciidoctor-diagram: ascii-art diagrams for manpages.
-
PlantUML: ascii-art diagrams for manpages.
BUILD
$ meson setup build
$ meson compile -C build
# meson install -C build
You can also pass options when you invoke meson
. One of the options is -D
enable_file_io=true
.
It’s encouraged that you build luajit with -DLUAJIT_ENABLE_LUA52COMPAT
.
Standalone ASIO
There are two approaches to use standalone ASIO (after tuning the right variable in meson-configure). The first one is to use unmodified ASIO:
$ meson wrap install asio
The second approach is to use a fork instead. The fork will need meson.build
on the root directory:
$ git clone https://gitlab.com/emilua/asio.git subprojects/asio
Tests
$ meson test -C build
Some tests are more intrusive and can only be built if you enable the plugins support.
Some fuzz tests are also available. You can configure the seed for these tests
by setting the EMILUA_TEST_SEED
environment variable. The envirnoment variable
EMILUA_TEST_FUZZER_NITER
can be used to override the number of iterations.