From 047081fa72b1b5b800e0e62aca9471e061528802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=BD=C3=A1dn=C3=ADk?= Date: Mon, 28 Mar 2022 03:02:19 +0300 Subject: [PATCH] Add a README about changing capnp schema (#4998) * Add a README about changing schema * Add example PRs --- crates/nu-plugin/README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 crates/nu-plugin/README.md diff --git a/crates/nu-plugin/README.md b/crates/nu-plugin/README.md new file mode 100644 index 0000000000..6d2c4d1af1 --- /dev/null +++ b/crates/nu-plugin/README.md @@ -0,0 +1,18 @@ +# nu-plugin + +## Updating Cap'n Proto schema + +When modifying a protocol's struct that is used in plugins (such as Signature), you need to update the capnproto schema file and recompile it into the Rust source code. +The steps are as follows: +1. Change `src/serializers/capnp/schema/plugin.capnp` as necessary +2. Install `capnp` tool (it's a C++ binary, commonly available in package managers) +3. Install Rust support for `capnp` called `capnpc-rust`: + 1. `git clone https://github.com/capnproto/capnproto-rust` somewhere + 2. `cd capnproto-rust/capnpc` + 3. `cargo install --path=.` +4. Then, call `capnp compile -orust plugin.capnp` (change path as necessary) +5. The result should be `plugin_capnp.rs` file: Use it to replace the old `src/plugin_capnp.rs`. +6. It needs to be autoformatted (`cargo fmt --all`) +7. Modify the serialize/deserialize functions. Check the following PRs for details: + * https://github.com/nushell/nushell/pull/4980 + * https://github.com/nushell/nushell/pull/4920