Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dylibso/xtp-go-bindgen

XTP bindgen support for Go, generating a Go PDK from an XTP Schema
https://github.com/dylibso/xtp-go-bindgen

Last synced: 15 days ago
JSON representation

XTP bindgen support for Go, generating a Go PDK from an XTP Schema

Awesome Lists containing this project

README

        

# XTP Plugin Bindgen

> _Warning_: This is experimental and is still in the alpha phase. Changes will
> be made without warning. Please wait before you start writing new bindgens.

This repository houses the prototype for bingden for Go plug-ins in XTP. It's
based on the [XTP Schema](https://docs.xtp.dylibso.com/docs/concepts/xtp-schema)
as the driving document. This document will be used to generate code and
documentation for plug-in systems and is specifically tailored to
[Extism](https://extism.org/) at the moment.

## Building

An XTP gen template is distributed as a zip file with a `plugin.wasm`,
`config.yaml`, and a `templates` directory of template files. To build this
"bundle" run the `bundle.sh` command:

```
./bundle.sh
```

To test you can use the XTP CLI and `plugin init`. You just need to point it at
a valid [XTP Schema](https://docs.xtp.dylibso.com/docs/concepts/xtp-schema)
file:

```
xtp plugin init --schema-file ./tests/schemas/fruit.yaml --template ./bundle --path myplugin -y
```

> _Note_: If you have not installed the xtp cli: curl
> https://static.dylibso.com/cli/install.sh | sudo sh

## Development

When working on this bindgen project, you will want to test changes as you're
making them. This suggested flow may help you do so.

First, there are a couple different components to the project:

1. the Extism plugin which processes schemas and renders templates.
2. the bindgen templates bundled into the generator (in `bundle.zip`)

Be sure you re-build the Extism plugin (the code in `src`) when making changes
to any schema processing or helper code. **The `bundle.sh` script does this for
you.**

### Testing changes

After you have made changes to either the plugin (in `src`) or the templates (in
`template`), you should test against the shared bindgen-test suite. To download
this suite, run:

```sh
sh bindgen-test.sh install
```

Once you have the `bindgen-test-artifacts`, you can then run the test suite
locally and confirm that a plugin generated by your bindgen project conforms to
the test:

```sh
sh bindgen-test.sh run
```

You should see passing test output or particular test cases that fail for you to
fix.