cloudflared-mirror/vendor/zombiezen.com/go/capnproto2/std/capnp
Areg Harutyunyan d06fc520c7 TUN-528: Move cloudflared into a separate repo 2018-07-19 15:02:24 -05:00
..
cxx TUN-528: Move cloudflared into a separate repo 2018-07-19 15:02:24 -05:00
json TUN-528: Move cloudflared into a separate repo 2018-07-19 15:02:24 -05:00
persistent TUN-528: Move cloudflared into a separate repo 2018-07-19 15:02:24 -05:00
rpc TUN-528: Move cloudflared into a separate repo 2018-07-19 15:02:24 -05:00
rpctwoparty TUN-528: Move cloudflared into a separate repo 2018-07-19 15:02:24 -05:00
schema TUN-528: Move cloudflared into a separate repo 2018-07-19 15:02:24 -05:00
README.md TUN-528: Move cloudflared into a separate repo 2018-07-19 15:02:24 -05:00
c++.capnp TUN-528: Move cloudflared into a separate repo 2018-07-19 15:02:24 -05:00
gen.sh TUN-528: Move cloudflared into a separate repo 2018-07-19 15:02:24 -05:00
json.capnp TUN-528: Move cloudflared into a separate repo 2018-07-19 15:02:24 -05:00
persistent.capnp TUN-528: Move cloudflared into a separate repo 2018-07-19 15:02:24 -05:00
rpc-twoparty.capnp TUN-528: Move cloudflared into a separate repo 2018-07-19 15:02:24 -05:00
rpc.capnp TUN-528: Move cloudflared into a separate repo 2018-07-19 15:02:24 -05:00
schema.capnp TUN-528: Move cloudflared into a separate repo 2018-07-19 15:02:24 -05:00

README.md

This directory contains go packages for all of the capnproto schemas that ship with capnproto itself. They are generated with the help of ./gen.sh. Though some manual modifications have been made to the schema to correct name collisions (See below).

./gen.sh Usage

Executing:

./gen.sh import /path/to/schemas

Will copy all the *.capnp files from the given directory into this directory, and add annotations to them specifying package names and import paths for capnpc-go.

./gen.sh compile

Will generate go packages for each of the schemas in the current directory.

./gen.sh clean-go

Will remove all generated go source files from this directory. Finally,

./gen.sh clean-all

Will remove both the go source files and the imported schemas.

gen.sh does some name mangling to ensure that the generated packages are actually legal go. However, this is not meant to be a general-purpose solution; it is only intended to work for the base schemas.

Extra Annotations

Under certain circumstances, capnpc-go will sometimes generate illegal go code. As an example, if two declarations Foo and foo exist in the schema, capnpc-go will capitalize the latter so that it will be exported, which will cause a name collision.

To address this kind of issue, some of the schema have been manually modified after importing, adding $Go.name annotations which prevent these errors.

Versions

The schemas checked in to this repository are those in capnproto commit ad4079b (master at the time of writing). Unfortunately, the stable release is very old, and some schemas out in the wild (notably sandstorm) have started expecting more recent versions of the base schemas.

Directory Structure

The directory structure of this repository is designed such that when compiling other schema, it should be sufficient to execute:

capnp compile -I ${path_to_this_repository}/std -ogo ${schama_name}.capnp

And have the $import statements in existing schema "just work."

To achieve this, the base schemas themselves are stored as /std/capnp/${schema_name}.capnp. The generated go source files are stored in a subdirectory, to make them their own package: /std/capnp/${mangled_schema_name}/${mangled_schema_name}.capnp.go.

In addition to the upstream base schemas, we also ship a schema /std/go.capnp, which contains annotations used by go-capnpc. Its usage is described in the top-level README. The generated source is placed in the root of the repository, making it part of the go package zombiezen.com/go/capnproto2.