Skip to content
This repository has been archived by the owner on Jan 27, 2022. It is now read-only.

Developing plugins

GGorAA edited this page Nov 14, 2021 · 6 revisions

Developing plugins is pretty simple!

Getting started

To create a plugin project, follow these steps:

  1. Create a project using cargo new --lib <proj_name>
  2. Add this part:
[lib]
crate-type = ["cdylib"]

to Cargo.toml, to compile to a dynamic lib

  1. Add kumitateru_pdk dependency, recommended to use the latest version

And to the code part!:

  1. Clear lib.rs and add this function:
#[no_mangle]
pub extern "C" fn activate() -> kumitateru_pdk::PluginConfig {
    return kumitateru_pdk::PluginConfig {
        name: "Sample".to_string(),
        version: "0.1.0".to_string(),
        author: "ggoraa".to_string(),
        subscriptions: vec![]
    }
}

As an entry point to the plugin, which activates the thing.

Documentation on structs can be found here: https://docs.rs/kumitateru_pdk

Bundling a Kumitateru Plugin Bundle

A plugin bundle is basically a .zip file, which content structure is:

plugin.kpb
├── darwin.dylib
├── win.dll
├── linux.so
└── manifest.toml

darwin.dylib is a macOS distribution of a plugin, linux.so is a Linux distribution, and win.dll is a Windows one.

The manifest.toml is a manifest, that describes a plugin. Contains name, version, and author

You can build a bundle by manually crafting a .zip archive and changing it's extension to .kpb, or by using cargo createkpb subcommand (installed using cargo install cargo-createkpb), which is preferred.

Clone this wiki locally