Lynx is a self-contained DSL engine based on mruby and still in development.
To make it on-the-go(without using host's glibc), we statically link the binary against musl-libc and generate a single executable(Linux ELF)
The project has two parts:
mruby-lynx is the Ruby part where the DSL is constructed.
lynx is the C part, mainly to read files and evaluate them. And we put other native runtime dependencies in this repo because we want to get a more fine-grained control of the build and test process.
Notice: If you want to port mruby-lynx, take care of missing dependencies.
Other mruby gems could be found on mruby/mgem-list, we recommend you to read some of them.
On Debian 11 or Ubuntu 20.04
sudo apt install build-essential musl-dev musl-tools
On Arch Linux
sudo pacman -S base-devel musl --needed
bundle install
# Show all commands
$ rake -AT
rake cleanroom:build # Clobber and build
rake libressl:clean # Remove libressl build files
rake libressl:clobber # Remove libressl source and build files
rake libressl:libssl # Build libssl.a libtls.a
rake libressl:source # Fetch libressl source from GitHub
rake lynx:clean # Remove lynx binary
rake lynx:compile # Generate lynx binary which is statically linked against musl
rake mruby:clean # Remove mruby build files
rake mruby:clobber # Remove mruby source and build files
rake mruby:config # Configure mruby
rake mruby:libmruby # Build libmruby.a
rake mruby:source # Fetch mruby source from GitHub
rake run:build # Build release
rake run:clean # Remove build files
rake run:clobber # Remove build files and source files
rake run:test # Run tests
For lynx, we have the following build process:
- Fetch mruby source from GitHub into
./build/mruby
- Install
./build_config/musl_linux_amd64.rb
to./build/mruby/build
- Fetch other native libraries(source) into
./build
- Configure and build all libs, make sure everything is statically linked against musl-libc
- Invoke Rake tasks defined by mruby to generate
libmruby.a
, it will also fetchmruby-lynx
from GitHub - Compile the CLI
src/main.c
and statically link it againstlibmruby.a
and other archives(static libs) - Finally get
./build/lynx
, an ELF for Linux, stripped and statically linked
To build and test:
rake
To remove all temporary files then re-build:
rake run:clobber
rake run:build
or
rake cleanroom:build
Check out build_config/*.rb
and ./Rakefile
first.
Lynx use two ways to test:
- mruby binary test when building
libmruby.a
- integration test, use
open3
to spawn a lynx process, evaluating scripts and capturing outputs