Skip to content

Commit 5be17f5

Browse files
committed
Plugin C/C++: Extend documentation
* Provide separated instructions for templates * Separated README file for each template * Extend documentation in source code
1 parent 418faf6 commit 5be17f5

File tree

7 files changed

+70
-16
lines changed

7 files changed

+70
-16
lines changed

plugins/templates/c-cpp/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,27 @@
22

33
This directory contains ready-to-use templates for Chipmunk plugins written in C/C++.
44
Plugin developers can simply copy a template directory to quickly start a new plugin project.
5+
6+
## Step-by-Step Guide
7+
8+
1. **Prerequisites**: Ensure all necessary tools, SDKs, and Chipmunk WIT files are available locally. Refer to the [C/C++ Plugins Development Guide](https://esrlabs.github.io/chipmunk/plugins/development-guide/) for detailed setup instructions.
9+
10+
2. **Configuration**: Provide required paths either directly within the `Makefile` or by passing them as arguments to the `make` CLI command.
11+
12+
3. **Compilation**: Run `make all {arguments}` to compile the template plugins. This command performs the following actions:
13+
* Generates bindings from Chipmunk WIT files.
14+
* Downloads the latest `wasi reactor` if its path is not specified.
15+
* Generates the plugin WASM component file in the `dist` directory. For parser templates, the file will be named `my_parser.wasm`.
16+
17+
4. **Plugin Integration**: To integrate the compiled plugin into Chipmunk:
18+
1. Create a directory for your plugin within the Chipmunk plugins directory. For parser plugins, this path is `~/.chipmunk/plugins/parsers`. The directory name for this template example would be `my_parser`.
19+
2. Copy the compiled plugin WASM component file into the newly created directory.
20+
3. For more detailed integration steps, refer to the [Plugins Integration Documentation](https://esrlabs.github.io/chipmunk/plugins/development-guide/#building-and-integrating-plugins).
21+
22+
5. **Using Plugins in Chipmunk**:
23+
1. Navigate to the **Plugins Manager** in the Chipmunk UI to verify that your plugin is integrated and validated successfully.
24+
2. Start a session, for example, a CLI command session from *Terminal/Execute Command*.
25+
3. Select your plugin from the dropdown menu. For the parser template, it will be named `my_parser`.
26+
4. The configuration schemas defined by the plugin will be displayed on the UI, allowing you to provide necessary inputs.
27+
5. Start the session to view the parsed messages. If Chipmunk is running in a terminal, you can also check logs printed to standard output.
28+
6. For additional details and demonstrations, refer to the [Plugins Integrations in Chipmunk UI](https://esrlabs.github.io/chipmunk/plugins/integration-ui/).

plugins/templates/c-cpp/parser_c/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ WIT_BINDGEN_ALL_GENERATED = $(WIT_BINDGEN_GENERATED_C_SRC) $(WIT_BINDGEN_GENERAT
3636

3737
# Name of the intermediate WASM binary module.
3838
CORE_WASM_MODULE = $(BUILD_DIR)/plugin_intermediate_module.wasm
39-
# Name of plugin final WASM component file.
39+
# Name of plugin final WASM component file. This must match the name of the plugin itself.
4040
FINAL_WASM_COMPONENT := $(DIST_DIR)/my_parser.wasm
4141

4242
# Use clang and sysroots from WASI SDK
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# C Parser Plugin Template
2+
3+
This is a starter template for developing parser plugins in C. Copy this template to quickly begin a new plugin project.
4+
5+
For detailed instructions, please refer to the [Step-by-Step Guide](../README.md).

plugins/templates/c-cpp/parser_c/src/my_parser.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,17 @@ void exports_chipmunk_parser_parser_get_version(
3030
ret->patch = 0;
3131
}
3232

33-
/// Provides the schemas for the configurations required by the plugin, which
34-
/// will be specified by the users.
33+
/// Provides the schemas for the configurations required by the plugin.
3534
///
36-
/// These schemas define the expected structure, types, and constraints
37-
/// for plugin-specific configurations. The values of these configurations
38-
/// will be passed to the initializing method of the parser.
35+
/// These schemas define the expected structure, types, and constraints for
36+
/// plugin-specific configurations that users will specify. Chipmunk uses these
37+
/// schemas to render UI controls, which are presented to users before starting
38+
/// a session, allowing them to provide values for these configurations.
39+
///
40+
/// The values collected from these configurations are then passed to the
41+
/// parser's initialization method. Developers should refer to the WIT files
42+
/// and the generated bindgen for a complete list of available configuration
43+
/// schemas.
3944
void exports_chipmunk_parser_parser_get_config_schemas(
4045
exports_chipmunk_parser_parser_list_config_schema_item_t *ret) {
4146
ret->ptr = (exports_chipmunk_parser_parser_config_schema_item_t *)calloc(
@@ -107,8 +112,13 @@ void exports_chipmunk_parser_parser_get_render_options(
107112
#endif
108113
}
109114

110-
/// Initialize the parser with the given configurations
111-
/// This function will be called upon starting a parsing session.
115+
/// Initializes the parser with the provided configurations.
116+
///
117+
/// This function is called when a parsing session starts. It receives the
118+
/// general parser configurations applicable to all parsing plugins, along
119+
/// with specific configuration values defined by the
120+
/// `exports_chipmunk_parser_parser_get_config_schemas()` function for this
121+
/// plugin.
112122
bool exports_chipmunk_parser_parser_init(
113123
exports_chipmunk_parser_parser_parser_config_t *general_configs,
114124
exports_chipmunk_parser_parser_list_config_item_t *plugin_configs,

plugins/templates/c-cpp/parser_cpp/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ WIT_BINDGEN_COMPILED_C_SRC := $(BUILD_DIR)/parse.o
3939

4040
# Name of the intermediate WASM binary module.
4141
CORE_WASM_MODULE = $(BUILD_DIR)/plugin_intermediate_module.wasm
42-
# Name of plugin final WASM component file.
42+
# Name of plugin final WASM component file. This must match the name of the plugin itself.
4343
FINAL_WASM_COMPONENT := $(DIST_DIR)/my_parser.wasm
4444

4545
# Use clang and sysroots from WASI SDK
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# C++ Parser Plugin Template
2+
3+
This is a starter template for developing parser plugins in C++. Copy this template to quickly begin a new plugin project.
4+
5+
For detailed instructions, please refer to the [Step-by-Step Guide](../README.md).

plugins/templates/c-cpp/parser_cpp/src/my_parser.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,17 @@ void exports_chipmunk_parser_parser_get_version(
2929
ret->patch = 0;
3030
}
3131

32-
/// Provides the schemas for the configurations required by the plugin, which
33-
/// will be specified by the users.
32+
/// Provides the schemas for the configurations required by the plugin.
3433
///
35-
/// These schemas define the expected structure, types, and constraints
36-
/// for plugin-specific configurations. The values of these configurations
37-
/// will be passed to the initializing method of the parser.
34+
/// These schemas define the expected structure, types, and constraints for
35+
/// plugin-specific configurations that users will specify. Chipmunk uses these
36+
/// schemas to render UI controls, which are presented to users before starting
37+
/// a session, allowing them to provide values for these configurations.
38+
///
39+
/// The values collected from these configurations are then passed to the
40+
/// parser's initialization method. Developers should refer to the WIT files
41+
/// and the generated bindgen for a complete list of available configuration
42+
/// schemas.
3843
void exports_chipmunk_parser_parser_get_config_schemas(
3944
exports_chipmunk_parser_parser_list_config_schema_item_t *ret) {
4045
ret->ptr = new exports_chipmunk_parser_parser_config_schema_item_t[3];
@@ -103,8 +108,13 @@ void exports_chipmunk_parser_parser_get_render_options(
103108
#endif
104109
}
105110

106-
/// Initialize the parser with the given configurations
107-
/// This function will be called upon starting a parsing session.
111+
/// Initializes the parser with the provided configurations.
112+
///
113+
/// This function is called when a parsing session starts. It receives the
114+
/// general parser configurations applicable to all parsing plugins, along
115+
/// with specific configuration values defined by the
116+
/// `exports_chipmunk_parser_parser_get_config_schemas()` function for this
117+
/// plugin.
108118
bool exports_chipmunk_parser_parser_init(
109119
exports_chipmunk_parser_parser_parser_config_t *general_configs,
110120
exports_chipmunk_parser_parser_list_config_item_t *plugin_configs,

0 commit comments

Comments
 (0)