4.7 KiB
Building Codex
Table of Contents
Optional
Prerequisites
To build nim-codex, developer tools need to be installed and accessible in the OS.
Instructions below correspond roughly to environmental setups in nim-codex's CI workflow and are known to work.
Other approaches may be viable. On macOS, some users may prefer MacPorts to Homebrew. On Windows, rather than use MSYS2, some users may prefer to install developer tools with winget, Scoop, or Chocolatey, or download installers for e.g. Make and CMake while otherwise relying on official Windows developer tools. Community contributions to these docs and our build system are welcome!
Linux
Package manager commands may require sudo
depending on OS setup.
On a bare bones installation of Debian (or a distribution derived from Debian, such as Ubuntu), run
$ apt-get update && apt-get install build-essential cmake curl git
Non-Debian distributions have different package managers: apk
, dnf
, pacman
, rpm
, yum
, etc.
For example, on a bare bones installation of Fedora, run
$ dnf install @development-tools cmake gcc-c++ which
macOS
Install the Xcode Command Line Tools by opening a terminal and running
$ xcode-select --install
Install Homebrew (brew
) and in a new terminal run
$ brew install bash cmake
Check that PATH
is setup correctly
$ which bash cmake
/usr/local/bin/bash
/usr/local/bin/cmake
Windows + MSYS2
Instructions below assume the OS is 64-bit Windows and that the hardware or VM is x86-64 compatible.
Download and run the installer from msys2.org.
Launch an MSYS2 environment. UCRT64 is generally recommended: from the Windows Start menu select MSYS2 MinGW UCRT x64
.
Assuming a UCRT64 environment, in Bash run
$ pacman -S base-devel git unzip mingw-w64-ucrt-x86_64-toolchain mingw-w64-ucrt-x86_64-cmake
Other
It is possible that nim-codex can be built and run on other platforms supported by the Nim language: BSD family, older versions of Windows, etc. There has not been sufficient experimentation with nim-codex on such platforms, so instructions are not provided. Community contributions to these docs and our build system are welcome!
Repository
In Bash run
$ git clone https://github.com/status-im/nim-codex.git repos/nim-codex && cd repos/nim-codex
nim-codex uses the nimbus-build-system, so next run
$ make update
This step can take a while to complete because by default it builds the Nim compiler.
To see more output from make
pass V=1
. This works for all make
targets in projects using the nimbus-build-system
$ make V=1 update
Executable
In Bash run
$ make exec
The exec
target creates the build/codex
executable.
Example usage
See the instructions in the main readme.
Tests
In Bash run
$ make test
testAll
The testAll
target runs the same tests as make test
and also runs tests for nim-codex's Ethereum contracts, as well a basic suite of integration tests.
To run make testAll
, Node.js needs to be installed. Node Version Manager (nvm
) is a flexible means to do that and it works on Linux, macOS, and Windows + MSYS2.
With nvm
installed, launch a separate terminal and download the latest LTS version of Node.js
$ nvm install --lts
In that same terminal run
$ cd repos/nim-codex/vendor/codex-contracts-eth && npm install && npm start
Those commands install and launch a Hardhat environment with nim-codex's Ethereum contracts.
In the other terminal run
$ make testAll