From 2ab442ab2fa864e3abc0643ba3d80ca301337d7f Mon Sep 17 00:00:00 2001 From: Alex Denisov Date: Sun, 1 Dec 2024 19:14:56 +0100 Subject: [PATCH] Update docs to include a hello-world example --- README.md | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 79267cd..b92b086 100644 --- a/README.md +++ b/README.md @@ -4,39 +4,58 @@ Simplified version of Firestorm targeting C instead of machine code directly. # Local Build Setup -Brew: +### Install Dependencies + +You need `ninja`, `cmake` (at least 3.28) and `llvm` 19. + +On macOS: ```bash -brew install ninja cmake ccache hyperfine llvm@19 +brew install ninja cmake hyperfine llvm@19 ``` -Get the sources +On Ubuntu 24.04: ```bash -git clone git@github.com:DragonRuby/lightstorm.git --recursive +sudo apt-get install ninja-build cmake ``` -Create toolchain dir +To install LLVM 19 follow the instructions [here](https://apt.llvm.org). + +### Checkout ```bash -sudo mkdir /opt/lightstorm.toolchain.dir -sudo chown `whoami` /opt/lightstorm.toolchain.dir +git clone git@github.com:DragonRuby/lightstorm.git --recursive ``` -Build lightstorm +### Build & install ```bash -mkdir lightstorm-build; cd lightstorm-build -cmake -G Ninja -DCMAKE_PREFIX_PATH=/opt/homebrew/opt/llvm@19/ \ - -DCMAKE_INSTALL_PREFIX=/opt/lightstorm.toolchain.dir/lightstorm \ - ../lightstorm +# On Ubuntu +cmake --workflow --preset lightstorm-ubuntu-install +# On macOS +cmake --workflow --preset lightstorm-macos-install +``` + +# Build "Hello World" -ninja +```bash +> echo 'puts "Hello, Lightstorm"' > hello.rb +> ./install.dir/bin/lightstorm hello.rb -o hello.rb.c +> clang hello.rb.c -o hello_lightstorm \ + -L./install.dir/lib/ \ + -isystem./third_party/mruby/include -isystem./third_party/mruby/build/host/include/ \ + -llightstorm_runtime_main -llightstorm_mruby -lm +> ./hello_lightstorm +Hello, Lightstorm ``` +# Build and run tests + Build a test (`tests/integration/loads.rb`): ```bash +> cd build.dir > ninja loads.rb.exe > ../lightstorm/tests/integration/Output/loads.rb.tmp.exe 1