Compiler

The bitproto compiler generates language-specific code, which provides the encode and decode api functions.

Installing the compiler

The bitproto compiler is written in Python, and requires Python3.7+ to work, it’s best to be installed via pip:

$ pip install bitproto

This will install a command named bitproto to your system, you can check it’s version after the installation:

$ bitproto -v
bitproto 0.4.0

If you’re new to Python, or wish to skip a Python installation, you can download the compiler from this download link directly, there provides the prebuilt one-file executables for Mac OS, Windows and Linux, which works without having to install a Python3.7+.

Command line usage

Generates code for given language:

$ bitproto c proto.bitproto
$ bitproto go proto.bitproto
$ bitproto py proto.bitproto

It generates language-specific codes to current directory by default, to specify a output directory:

$ bitproto c proto.bitproto outs/

Validates bitproto source file syntax, exits with a non-zero code if any syntax wrongs:

$ bitproto -c proto.bitproto

The compiler won’t generate files but only run a protocol syntax checking if -c option is given.

By default, the compiler runs a simple protocol linter, which gives warnings if the given bitproto file doesn’t meet the Style Guide, to disable the linter:

$ bitproto c proto.bitproto -q