Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Generating Code

This section of the ngen documentation covers interacting with the nehwgeneration CLI to generate code.

Command-Line Options

In order to not provide redundant information, please execute

cargo run -p nehwgeneration -- --help

from the workspace root directory to list all available command line options, or

nehwgeneration --help

in case you have installed nehwgeneration on your system.

Configuring the Output Directory

To generate code, you will need a valid ngen.toml configuration file, complete with a configured general configuration.

Consider the following output entry in the general configuration:

[general]
output = "./server-crate/src/ngen/mod.rs"

nehwgeneration will attempt the following, when trying to save the generated code to disk:

  1. Determine, whether ngen is already a valid, included module in the Rust source tree.
    • If not: Will add a pub mod ngen statement to the parent directories’ main.rs, lib.rs or mod.rs to attempt and include the module.
    • If so: Continue
  2. If ngen/mod.rs already exists, all contents of that file will be completely overwritten with the auto-generated ngen code. If the file does not already exist, ngen will create it, and add the generated code to that file.

Tip

It is advised to give ngen-generated code its own module folder.