blob: 3760e6f2dd7685a1ac2c69cc36ddbeb2380b50da (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# nimpb_build
**NOTE** nimpb_build is still experimental :-)
A tool for generating suitable Nim code for
[nimpb](https://github.com/oswjk/nimpb). It uses a prebuilt and bundled protoc
compiler. This tool supports the following platforms:
- Linux x86_32
- Linux x86_64
- Linux aarch_64
- OSX x86_64
- Windows
nimpb_build is modeled somewhat after [prost-build](https://github.com/danburkert/prost).
# Install with Nimble
$ nimble install https://github.com/oswjk/nimpb_build
# Usage
Using the tool is simple:
$ nimpb_build -I. --out=. my.proto
It's almost like using protoc directly. In fact, the arguments are basically
passed along to protoc.
You can specify nimpb_build as a dependency for your project in your .nimble
file and create a task for generating code:
requires "nimpb_build"
task proto, "Process .proto files":
exec "nimpb_build -I. --out=. my.proto"
# How it works
nimpb_build includes functionality to invoke the protoc compiler. It also
includes a built-in protoc plugin, that protoc will use to generate the Nim
code.
First, nimpb_build will execute protoc with correct arguments. It will also
pass itself as a plugin using the --plugin argument to protoc. nimpb_build
will set the NIMPB_BUILD_PLUGIN=1 environment variable when executing protoc,
so that when protoc executes nimpb_build, the new nimpb_build instance knows
to work in protoc plugin mode.
|