Skip to content

nyarnalang/nyarna-zig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reference Nyarna Implementation

This is the reference Nyarna implementation, written in Zig.

Building

Nyarna currently depends on zig master, but has not yet been updated for stage2. A release will not be available before zig 0.10.0 drops.

Nix Flakes are used as build system. This pins the versions of zig and third-party libraries. You can install Nix on most Linux distributions and macOS. With Nix installed and Flakes enabled, you can simply do

nix build github:nyarnalang/nyarna-zig#cli

to get the CLI in result.

The plan is to release a source tarball with sources generated by Nix for people on platforms without Nix support (e.g. Windows) once zig 0.10.0 drops.

Windows

You can cross-compile to Windows on a Nix host (e.g. WSL) by doing

nix build github:nyarnalang/nyarna-zig#cli_win64

which generates a zip file you can extract. After extraction, you must set the environment variable NYARNA_STDLIB_PATH to the path of the directory share/lib you have extracted. After that, you can open a terminal and execute bin/nyarna.exe from the extraction directory.

Development

Assumes being in checked-out repository.

nix build .#cli builds the command-line executable.

nix build .#wasm builds the WASM library with JavaScript interface used for the tour on the website.

nix develop starts a bash session where you can do:

  • eval "$configurePhase" to generate build.zig.
  • eval "$buildPhase" to compile (requires build.zig)
  • eval "$checkPhase" to run the tests ()

This should be easier but is currently blocked by this Nix issue. After generating build.zig once, you can also do zig build and zig build test. This is how I develop.

Debugging

After configuring, you can generate the tests and can also debug them:

  • zig build test -Demit_bin=true will give you executables for all tests.
  • use -Dtest-filter="Schema extension" to run only a specific test.
  • use lldb -- ./outputTest $(which zig) to debug a test executable (needs lldb on your system).

The configurePhase also generates a .vscode folder usable with Visual Studio Code that contains debug configurations. You will need to have configured LLDB in your editor. There is a configuration available for each test executable – you need to have generated the executable manually as described above. The tests are not generated automatically by the debug configurations so that you can generate and use filtered executables.

License

MIT

Releases

No releases published

Packages

No packages published

Languages