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 Zig plug-ins in XTP. It's based on the 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 at the moment.
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
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
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:
- the Extism plugin which processes schemas and renders templates.
- 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.
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 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 bindgen-test.sh run
You should see passing test output or particular test cases that fail for you to fix.