Compiling the runtime

Prerequisites

To compile, you will need the following:

  • CMake v3.22+
  • C++ Compiler with at least C++17 support (any recent compiler)
  • Python 3.8+
  • OpenSSL for luasec
  • (optional) pkgconf for LuaJIT support
  • vcpkg for installing OpenSSL and (optional) LuaJIT
  • (optional) ccache for faster rebuilds

Getting the repository

$ git clone https://github.com/sunabagg/sunaba.git
$ cd sunaba

Build & Install

Here's an example of how to build & install a release version (use the terminal to run the following commands in the parent directory of this repo):

Not MSVC or Emscripten

$ cmake -B sunaba-build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=sunaba-install sunaba
$ cmake --build sunaba-build --parallel
$ cmake --install sunaba-build

Emscripten

$ emcmake cmake -B sunaba-build-web -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=sunaba-install-web -DCMAKE_CXX_FLAGS="-sSIDE_MODULE -fPIC -msimd128 -std=c++17 -sSUPPORT_LONGJMP=emscripten -o3 -pthread --target=wasm32-unknown-emscripten -sSHARED_MEMORY=1 -flto=thin" -DCMAKE_C_FLAGS="-sSIDE_MODULE -fPIC -msimd128 -sSUPPORT_LONGJMP=emscripten -o3 --target=wasm32-unknown-emscripten -sSHARED_MEMORY=1" -DCMAKE_EXE_LINKER_FLAGS="-sINITIAL_MEMORY=104857600 -sALLOW_MEMORY_GROWTH=1 -sSHARED_MEMORY=1"
$ cmake --build sunaba-build-web
$ cmake --install sunaba-build-web

MSVC

cmake -B sunaba-build -G"Visual Studio 17 2022"  -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=sunaba-install sunaba
Copy-Item "lua51.lib" -Destination "sunaba-build\lua51.lib"
cmake --build sunaba-build --config Release
cmake --install sunaba-build

This tells CMake to use Visual Studio 2022. There is a list of Visual Studio generators on the CMake site - pick the one you are using.