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:
- Determine, whether
ngenis already a valid, included module in the Rust source tree.- If not: Will add a
pub mod ngenstatement to the parent directories’main.rs,lib.rsormod.rsto attempt and include the module. - If so: Continue
- If not: Will add a
- If
ngen/mod.rsalready 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.