nanoc is a codegen tool for NanoPack that turns NanoPack schemas to code that enables portable data serialization/deserialization in NanoPack.
- Go >= 1.20
- Formatter installed for the corresponding language:
- C++:
clang-format - Swift:
swift-format - JavaScript/TypeScript:
prettierwill be used vianpx, sonpmneeds to be available
- C++:
nanoc is available as pre-built binaries on the GitHub Releases page.
# Assuming the cwd is in the project directory where go.mod is
go install nanoc/cmd/nanoc
The above compiles the source code, produces an executable called nanoc, and then moves (installs) it to GOBIN, or GOPATH/bin if GOBIN is not set. Make sure either is in PATH.
nanoc has the following arguments:
--languagespecifies the language of the generated code. Can bec++,swift, orts.--factory-out(optional) specifies the folder in which the message factory code file should be put.- The list of relative paths to the NanoPack schemas for which code should be generated.
Generating c++ code for person.yml and car.yml in the current directory:
nanoc --language=c++ ./person.yml ./car.yml
Generating TypeScript code from person.yml and car.yml in the current directory, and also generate the message factory in the current directory:
nanoc --language=ts --factory-out=. ./person.yml ./car.yml