Shinobi is a single file library and program to convert 'build.ninja' files into 'build.zig' files. The purpose of this is to remove the need to translate native C++ build scripts such as CMake or Meson files into a 'build.zig' file by hand. This is done by running the appropriate C++ build system to generate the 'build.ninja' file, then Shinobi will translate this file into a 'build.zig' file.
Shinobi can be used in two methods, as a standalone program or imported into a zig project. This section describes how they can be used in each method. In order to properly use Shinobi, two other dependencies must be installed on the host system, the native build system such as CMake, and Ninja.
The library is a single 'shinobi.zig' file that can be copied into the same directory as the root 'build.zig' file. The library can then be imported into the project's 'build.zig' file and can be used to add the external directory containing the native C++ project. This is done by using the 'shinobi.addDirectory' function, which will attempt to find the 'build.ninja' file associated with the dependency or create one through the native C++ build system if the file is not found. After the 'build.ninja' is parsed, shinobi will return all libraries and executables in the 'shinobi.Result' object. The 'Result.libraries' and 'Result.executables' fields are string hash maps. The associated library or executable can be retrieved by the name given within the native C++ build system. The user can then link any of the returned libraries using the 'linkLibrary' function of their project modules.
This project comes with usage of this method in the 'examples' folder. Users can refer to the build.zig file in the 'plutovg' example.
A standalone program can be used to generate the 'build.zig' files which can be used in zig projects. The program is a command-line application that takes in arguments to control how the build file is generated.
The first argument is required, and is the path argument. This can be an already generated 'build.zig' file or a directory. If the path is a directory, Shinobi will first look to find a 'build.ninja' file. If one does not exist, Shinobi will look for the appropriate native build file and run the associated tool to generate the 'build.ninja' file. Currently, only CMake is supported.
This section describes what options can be passed into the library or program to control how the native generator behaves before the user can consume the translated output. A table is provided to show how each option can be specified either through the library or the program.
| Name | Description | Library | Program |
|---|---|---|---|
| print_summary | Prints a summary of what artifacts were generated. | .print_summary | --print-summary |
| target | Controls what architecture to target. | .target | Not Supported Yet |
| configuration | Controls whether to use debug or release optimizations. | .configuration | Not Supported Yet |
| cmake_bin_path | Specify the directory where the 'cmake' executable is located if not in the environment path. | .cmake_bin_path | --cmake-bin-path |
| definitions | Add definitions to be passed into the native generator. | addDefinition(key, value) | -D{DEFINITION} |
| verbosity | Controls how much information is logged out during execution. | .none/.minimal/.verbose | --verbose [none/minimal/verbose] |